From 36e0f0b683c49170a50c33cf56e4cd926537a37f Mon Sep 17 00:00:00 2001 From: DJHunn39 Date: Tue, 29 Oct 2024 14:33:48 +0000 Subject: [PATCH 1/2] fix: remove unnecessary if block Signed-off-by: DJHunn39 --- .../openid4vc-verifier/OpenId4VcSiopVerifierService.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/packages/openid4vc/src/openid4vc-verifier/OpenId4VcSiopVerifierService.ts b/packages/openid4vc/src/openid4vc-verifier/OpenId4VcSiopVerifierService.ts index 555ad5606c..181d412cb1 100644 --- a/packages/openid4vc/src/openid4vc-verifier/OpenId4VcSiopVerifierService.ts +++ b/packages/openid4vc/src/openid4vc-verifier/OpenId4VcSiopVerifierService.ts @@ -643,14 +643,6 @@ export class OpenId4VcSiopVerifierService { isValid = verificationResult.isValid } - // FIXME: we throw an error here as there's a bug in sphereon library where they - // don't check the returned 'verified' property and only catch errors thrown. - // Once https://github.com/Sphereon-Opensource/SIOP-OID4VP/pull/70 is merged we - // can remove this. - if (!isValid) { - throw new CredoError('Presentation verification failed.') - } - return { verified: isValid, } From 9a966ac4ca268d4bf04ed8b7e3931d6bdf1a0de6 Mon Sep 17 00:00:00 2001 From: DJHunn39 Date: Tue, 29 Oct 2024 14:57:37 +0000 Subject: [PATCH 2/2] feat: add reason property to verificationResult Signed-off-by: DJHunn39 --- .../src/openid4vc-verifier/OpenId4VcSiopVerifierService.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/openid4vc/src/openid4vc-verifier/OpenId4VcSiopVerifierService.ts b/packages/openid4vc/src/openid4vc-verifier/OpenId4VcSiopVerifierService.ts index 181d412cb1..b6e6450e22 100644 --- a/packages/openid4vc/src/openid4vc-verifier/OpenId4VcSiopVerifierService.ts +++ b/packages/openid4vc/src/openid4vc-verifier/OpenId4VcSiopVerifierService.ts @@ -607,6 +607,7 @@ export class OpenId4VcSiopVerifierService { if (!encodedPresentation) throw new CredoError('Did not receive a presentation for verification.') let isValid: boolean + let reason: string | undefined // TODO: it might be better here to look at the presentation submission to know // If presentation includes a ~, we assume it's an SD-JWT-VC @@ -622,6 +623,7 @@ export class OpenId4VcSiopVerifierService { }) isValid = verificationResult.verification.isValid + reason = verificationResult.isValid ? undefined : verificationResult.error.message } else if (typeof encodedPresentation === 'string') { const verificationResult = await this.w3cCredentialService.verifyPresentation(agentContext, { presentation: encodedPresentation, @@ -633,6 +635,7 @@ export class OpenId4VcSiopVerifierService { }) isValid = verificationResult.isValid + reason = verificationResult.error?.message } else { const verificationResult = await this.w3cCredentialService.verifyPresentation(agentContext, { presentation: JsonTransformer.fromJSON(encodedPresentation, W3cJsonLdVerifiablePresentation), @@ -641,10 +644,12 @@ export class OpenId4VcSiopVerifierService { }) isValid = verificationResult.isValid + reason = verificationResult.error?.message } return { verified: isValid, + reason, } } catch (error) { agentContext.config.logger.warn('Error occurred during verification of presentation', {