From cdaa99e9098f404ac0eb80ac806329a8275fb57c Mon Sep 17 00:00:00 2001 From: martines3000 Date: Tue, 5 Nov 2024 11:30:09 +0100 Subject: [PATCH] fix: change credential decoding in `handleAuthorizationRequest` --- .changeset/wicked-cherries-happen.md | 5 ++++ packages/snap/snap.manifest.json | 2 +- packages/snap/src/veramo/Veramo.service.ts | 27 ++++++---------------- 3 files changed, 13 insertions(+), 21 deletions(-) create mode 100644 .changeset/wicked-cherries-happen.md diff --git a/.changeset/wicked-cherries-happen.md b/.changeset/wicked-cherries-happen.md new file mode 100644 index 00000000..af599b33 --- /dev/null +++ b/.changeset/wicked-cherries-happen.md @@ -0,0 +1,5 @@ +--- +"@blockchain-lab-um/masca": minor +--- + +Fixes credential decoding in handleAuthorizationRequest diff --git a/packages/snap/snap.manifest.json b/packages/snap/snap.manifest.json index 4b9c0dcf..17198a32 100644 --- a/packages/snap/snap.manifest.json +++ b/packages/snap/snap.manifest.json @@ -26,7 +26,7 @@ "./files/circuits/credentialAtomicQuerySigV2/circuit_final.zkey", "./files/circuits/credentialAtomicQuerySigV2/verification_key.json" ], - "shasum": "nb6d1TmK0UaDb4uoutgzRlNYcftbFe/mdawtXk4UeLM=" + "shasum": "8z+x2k7IWORaxqEwcU2DDZZDy0IhYelIz+P/nqeRBso=" }, "initialPermissions": { "endowment:ethereum-provider": {}, diff --git a/packages/snap/src/veramo/Veramo.service.ts b/packages/snap/src/veramo/Veramo.service.ts index 2a31aa9b..c9a475d2 100644 --- a/packages/snap/src/veramo/Veramo.service.ts +++ b/packages/snap/src/veramo/Veramo.service.ts @@ -842,24 +842,13 @@ class VeramoService { throw new Error(selectCredentialsResult.error); } - // return { - // isUserInteractionRequired: true, - // credentials: selectCredentialsResult.data, - // presentationDefinition: authorizationRequest.presentation_definition, - // } - // } - - // const selectCredentialsResult = await agent.selectCredentials({ - // credentials: credentials as any, - // }); - - // if (isError(selectCredentialsResult)) { - // throw new Error(selectCredentialsResult.error); - // } + const decodedCredentials = selectCredentialsResult.data.map( + (credential) => decodeCredentialToObject(credential) + ); const createPresentationSubmissionResult = await VeramoService.instance.createPresentationSubmission({ - credentials: selectCredentialsResult.data, + credentials: decodedCredentials as any, }); if (isError(createPresentationSubmissionResult)) { @@ -868,15 +857,13 @@ class VeramoService { const presentationSubmission = createPresentationSubmissionResult.data; - const decodedCredentials = selectCredentialsResult.data.map( - (credential) => decodeCredentialToObject(credential).proof.jwt - ); - const veramoPresentation = await VeramoService.instance.createVerifiablePresentation({ presentation: { holder: did, - verifiableCredential: decodedCredentials, + verifiableCredential: decodedCredentials.map( + (credential) => credential.proof.jwt + ), }, proofFormat: 'jwt', });