From 915a0193c0f95a09776dbcf015623bd119319f69 Mon Sep 17 00:00:00 2001 From: Timo Glastra Date: Thu, 25 Jan 2024 14:28:54 +0700 Subject: [PATCH 1/2] fix: add some missing sd-jwt types Signed-off-by: Timo Glastra --- src/authorization-response/types.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/authorization-response/types.ts b/src/authorization-response/types.ts index 750edf5..ca1954d 100644 --- a/src/authorization-response/types.ts +++ b/src/authorization-response/types.ts @@ -89,9 +89,12 @@ export enum VPTokenLocation { export type PresentationVerificationResult = { verified: boolean }; -export type PresentationVerificationCallback = (args: W3CVerifiablePresentation, presentationSubmissionn) => Promise; +export type PresentationVerificationCallback = ( + args: W3CVerifiablePresentation | CompactSdJwtVc, + presentationSubmission: PresentationSubmission +) => Promise; -export type PresentationSignCallback = (args: PresentationSignCallBackParams) => Promise; +export type PresentationSignCallback = (args: PresentationSignCallBackParams) => Promise; export interface VerifyAuthorizationResponseOpts { correlationId: string; From 6546ffcae8432b02b5be2a16cc6fc200054db5cf Mon Sep 17 00:00:00 2001 From: Timo Glastra Date: Fri, 26 Jan 2024 17:58:45 +0700 Subject: [PATCH 2/2] fix: check presentation callback result Signed-off-by: Timo Glastra --- src/authorization-response/PresentationExchange.ts | 7 ++++++- src/authorization-response/types.ts | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/authorization-response/PresentationExchange.ts b/src/authorization-response/PresentationExchange.ts index 9636dae..671b82b 100644 --- a/src/authorization-response/PresentationExchange.ts +++ b/src/authorization-response/PresentationExchange.ts @@ -344,7 +344,12 @@ export class PresentationExchange { // So the behavior here is to bypass it if not present if (verifyPresentationCallback) { try { - await verifyPresentationCallback(vpw.original as W3CVerifiablePresentation, presentationSubmission); + const verificationResult = await verifyPresentationCallback(vpw.original as W3CVerifiablePresentation, presentationSubmission); + if (!verificationResult.verified) { + throw new Error( + SIOPErrors.VERIFIABLE_PRESENTATION_SIGNATURE_NOT_VALID + verificationResult.reason ? `. ${verificationResult.reason}` : '' + ); + } } catch (error: unknown) { throw new Error(SIOPErrors.VERIFIABLE_PRESENTATION_SIGNATURE_NOT_VALID); } diff --git a/src/authorization-response/types.ts b/src/authorization-response/types.ts index ca1954d..3589558 100644 --- a/src/authorization-response/types.ts +++ b/src/authorization-response/types.ts @@ -87,7 +87,7 @@ export enum VPTokenLocation { TOKEN_RESPONSE = 'token_response', } -export type PresentationVerificationResult = { verified: boolean }; +export type PresentationVerificationResult = { verified: boolean; reason?: string }; export type PresentationVerificationCallback = ( args: W3CVerifiablePresentation | CompactSdJwtVc,