diff --git a/package.json b/package.json index ce4ed6657..a6f54aa52 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@docknetwork/sdk", - "version": "8.1.2", + "version": "8.1.3", "main": "index.js", "license": "MIT", "repository": { diff --git a/src/utils/vc/credentials.js b/src/utils/vc/credentials.js index 3f8b96bf7..6ac3359cc 100644 --- a/src/utils/vc/credentials.js +++ b/src/utils/vc/credentials.js @@ -40,7 +40,15 @@ import { Bls12381BBSSignatureProofDock2022, Bls12381BBSSignatureDock2023, Bls12381BBSSignatureProofDock2023, + Bls12381BBS23SigProofDockSigName, + Bls12381PSSigProofDockSigName, JsonWebSignature2020, + Bls12381PSSigDockSigName, + Bls12381BBSSigDockSigName, + Bls12381BBSSigProofDockSigName, + Bls12381BBS23SigDockSigName, + Bls12381BDDT16MacDockName, + Bls12381BDDT16MacProofDockName, } from './custom_crypto'; import { signJWS } from './jws'; import Bls12381BDDT16MACProofDock2024 from './crypto/Bls12381BDDT16MACProofDock2024'; @@ -69,6 +77,20 @@ function dateStringToTimestamp(dateStr) { return Math.floor(Date.parse(dateStr) / 1000); } +export function isAnoncredsProofType(verifiableCredential) { + const proofType = verifiableCredential.proof && verifiableCredential.proof.type; + return ( + proofType === Bls12381BBSSigDockSigName + || proofType === Bls12381BBSSigProofDockSigName + || proofType === Bls12381BBS23SigProofDockSigName + || proofType === Bls12381PSSigProofDockSigName + || proofType === Bls12381BBS23SigDockSigName + || proofType === Bls12381BDDT16MacDockName + || proofType === Bls12381BDDT16MacProofDockName + || proofType === Bls12381PSSigDockSigName + ); +} + export function formatToJWTPayload(keyDoc, cred) { const kid = keyDoc.id; const credentialIssuer = cred.issuer; @@ -294,7 +316,11 @@ export async function verifyCredential( documentLoader: docLoader, }); - if (!skipSchemaCheck) { + // Determine if we should validate the schema when verifying + // NOTE: derived anoncreds do not need JSON schema validation as the anoncreds library validates it + // and it can fail when required attributes are not revealed + const isAnoncredsDerived = isAnoncredsProofType(credential); + if (!skipSchemaCheck && !isAnoncredsDerived) { await getAndValidateSchemaIfPresent( expandedCredential, credential[credentialContextField], diff --git a/src/utils/vc/custom_crypto.js b/src/utils/vc/custom_crypto.js index 45793def6..5980b23ba 100644 --- a/src/utils/vc/custom_crypto.js +++ b/src/utils/vc/custom_crypto.js @@ -16,6 +16,8 @@ import { Bls12381PSDockVerKeyName, Bls12381PSSigDockSigName, Bls12381PSSigProofDockSigName, + Bls12381BDDT16MacDockName, + Bls12381BDDT16MacProofDockName, } from './crypto/constants'; import EcdsaSecp256k1VerificationKey2019 from './crypto/EcdsaSecp256k1VerificationKey2019'; @@ -64,5 +66,7 @@ export { Bls12381PSDockVerKeyName, Bls12381PSSigDockSigName, Bls12381PSSigProofDockSigName, + Bls12381BDDT16MacDockName, + Bls12381BDDT16MacProofDockName, JsonWebSignature2020, }; diff --git a/tests/integration/anoncreds/derived-credentials.test.js b/tests/integration/anoncreds/derived-credentials.test.js index 399405fed..08eba8db4 100644 --- a/tests/integration/anoncreds/derived-credentials.test.js +++ b/tests/integration/anoncreds/derived-credentials.test.js @@ -67,7 +67,7 @@ const residentCardSchema = { minimum: 0, }, }, - required: [], + required: ['givenName', 'familyName', 'lprNumber'], }, }, };