This repository has been archived by the owner on Jan 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: do not allow to change ownerId and entropy
* fix: validate components of the `Document.$id` when replacing * chore: split errors
- Loading branch information
Showing
4 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const ConsensusError = require('./ConsensusError'); | ||
|
||
class DocumentEntropyMismatchError extends ConsensusError { | ||
/** | ||
* @param {Document} document | ||
* @param {Document} fetchedDocument | ||
*/ | ||
constructor(document, fetchedDocument) { | ||
super('Document entropy mismatch with previous versions'); | ||
|
||
this.document = document; | ||
this.fetchedDocument = fetchedDocument; | ||
} | ||
|
||
/** | ||
* Get Document | ||
* | ||
* @return {Document} | ||
*/ | ||
getDocument() { | ||
return this.document; | ||
} | ||
|
||
/** | ||
* Get fetched Document | ||
* | ||
* @return {Document} | ||
*/ | ||
getFetchedDocument() { | ||
return this.fetchedDocument; | ||
} | ||
} | ||
|
||
module.exports = DocumentEntropyMismatchError; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const ConsensusError = require('./ConsensusError'); | ||
|
||
class DocumentOwnerIdMismatchError extends ConsensusError { | ||
/** | ||
* @param {Document} document | ||
* @param {Document} fetchedDocument | ||
*/ | ||
constructor(document, fetchedDocument) { | ||
super('Document owner id mismatch with previous versions'); | ||
|
||
this.document = document; | ||
this.fetchedDocument = fetchedDocument; | ||
} | ||
|
||
/** | ||
* Get Document | ||
* | ||
* @return {Document} | ||
*/ | ||
getDocument() { | ||
return this.document; | ||
} | ||
|
||
/** | ||
* Get fetched Document | ||
* | ||
* @return {Document} | ||
*/ | ||
getFetchedDocument() { | ||
return this.fetchedDocument; | ||
} | ||
} | ||
|
||
module.exports = DocumentOwnerIdMismatchError; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters