-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ref-imp): #760 - Fixed long-form resolution not verifying delta size
- Loading branch information
1 parent
be481c0
commit fc1e8a9
Showing
20 changed files
with
122 additions
and
78 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
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,22 @@ | ||
import ErrorCode from './ErrorCode'; | ||
import ProtocolParameters from './ProtocolParameters'; | ||
import SidetreeError from '../../../common/SidetreeError'; | ||
|
||
/** | ||
* Class containing reusable operation delta functionalities. | ||
*/ | ||
export default class Delta { | ||
|
||
/** | ||
* Validates size of the encoded delta string. | ||
* @throws `SidetreeError` if fails validation. | ||
*/ | ||
public static validateEncodedDeltaSize (encodedDelta: string) { | ||
const deltaBuffer = Buffer.from(encodedDelta); | ||
if (deltaBuffer.length > ProtocolParameters.maxDeltaSizeInBytes) { | ||
const errorMessage = `${deltaBuffer.length} bytes of 'delta' exceeded limit of ${ProtocolParameters.maxDeltaSizeInBytes} bytes.`; | ||
console.info(errorMessage); | ||
throw new SidetreeError(ErrorCode.DeltaExceedsMaximumSize, errorMessage); | ||
} | ||
} | ||
} |
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
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
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
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,22 @@ | ||
import ErrorCode from './ErrorCode'; | ||
import ProtocolParameters from './ProtocolParameters'; | ||
import SidetreeError from '../../../common/SidetreeError'; | ||
|
||
/** | ||
* Class containing reusable operation delta functionalities. | ||
*/ | ||
export default class Delta { | ||
|
||
/** | ||
* Validates size of the encoded delta string. | ||
* @throws `SidetreeError` if fails validation. | ||
*/ | ||
public static validateEncodedDeltaSize (encodedDelta: string) { | ||
const deltaBuffer = Buffer.from(encodedDelta); | ||
if (deltaBuffer.length > ProtocolParameters.maxDeltaSizeInBytes) { | ||
const errorMessage = `${deltaBuffer.length} bytes of 'delta' exceeded limit of ${ProtocolParameters.maxDeltaSizeInBytes} bytes.`; | ||
console.info(errorMessage); | ||
throw new SidetreeError(ErrorCode.DeltaExceedsMaximumSize, errorMessage); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.