From bb79dc4080fef9d3a9666b0396983580a1d419cb Mon Sep 17 00:00:00 2001 From: lovesh Date: Wed, 27 Sep 2023 03:11:04 +0530 Subject: [PATCH] fix parsing options Signed-off-by: lovesh --- src/modules/did/did.js | 2 -- src/utils/vc/crypto/common/DockCryptoSignature.js | 11 ++++++++--- tests/integration/anoncreds/issuing.test.js | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/modules/did/did.js b/src/modules/did/did.js index 5121b2ab5..71f17a6ae 100644 --- a/src/modules/did/did.js +++ b/src/modules/did/did.js @@ -853,7 +853,6 @@ class DIDModule { } if (this.api.query.offchainSignatures != null) { const resp = await this.api.query.offchainSignatures.publicKeys.multi(queryKeys); - let currentIter = 0; for (let r of resp) { // The gaps in `keyId` might correspond to removed keys @@ -885,7 +884,6 @@ class DIDModule { } } else { const resp = await this.api.query.bbsPlus.bbsPlusKeys.multi(queryKeys); - let currentIter = 0; for (const r of resp) { // The gaps in `keyId` might correspond to removed keys diff --git a/src/utils/vc/crypto/common/DockCryptoSignature.js b/src/utils/vc/crypto/common/DockCryptoSignature.js index 5159a7bba..45296b5fa 100644 --- a/src/utils/vc/crypto/common/DockCryptoSignature.js +++ b/src/utils/vc/crypto/common/DockCryptoSignature.js @@ -115,10 +115,15 @@ export default withExtendedStaticProperties( let credSchema; if (document.credentialSchema) { credSchema = CredentialSchema.fromJSON({ - parsingOptions: DEFAULT_PARSING_OPTS, + // Passing all the default parsing options. Ideally `document.credentialSchema` should contain these + parsingOptions: { + useDefaults: false, + defaultMinimumInteger: -((2 ** 32) - 1), + defaultMinimumDate: -((2 ** 44) - 1), + defaultDecimalPlaces: 0, + }, ...document.credentialSchema, }); - // TODO: support documentloader for schemas here so we can use dock chain schemas // requires that the presentation wrapper passes a documentloader to this method // const loadedSchema = (await documentLoader(document.credentialSchema.id)).document; @@ -136,7 +141,7 @@ export default withExtendedStaticProperties( // Passing old parsing options and version { useDefaults: false, - defaultMinimumInteger: -(Math.pow(2, 32) - 1), + defaultMinimumInteger: -((2 ** 32) - 1), defaultDecimalPlaces: 0, }, false, diff --git a/tests/integration/anoncreds/issuing.test.js b/tests/integration/anoncreds/issuing.test.js index afd0c8f22..a2e39a8ae 100644 --- a/tests/integration/anoncreds/issuing.test.js +++ b/tests/integration/anoncreds/issuing.test.js @@ -161,7 +161,7 @@ for (const { expect(resultWithSchema).toMatchObject( expect.objectContaining(getProofMatcherDoc()), ); - }, 30000); + }, 30000); test(`Can issue+verify a ${Name} credential with default schema`, async () => { const issuerKey = getKeyDoc(did1, keypair, keypair.type, keypair.id);