Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'Timo/fix/presentation-callback-result' …
Browse files Browse the repository at this point in the history
…into fix/idtoken_vptoken-andv18-fixes
  • Loading branch information
nklomp committed Feb 29, 2024
2 parents 65f5273 + 6546ffc commit 867bbf7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/authorization-response/PresentationExchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
9 changes: 6 additions & 3 deletions src/authorization-response/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,14 @@ export enum VPTokenLocation {
TOKEN_RESPONSE = 'token_response',
}

export type PresentationVerificationResult = { verified: boolean };
export type PresentationVerificationResult = { verified: boolean; reason?: string };

export type PresentationVerificationCallback = (args: W3CVerifiablePresentation, presentationSubmissionn) => Promise<PresentationVerificationResult>;
export type PresentationVerificationCallback = (
args: W3CVerifiablePresentation | CompactSdJwtVc,
presentationSubmission: PresentationSubmission
) => Promise<PresentationVerificationResult>;

export type PresentationSignCallback = (args: PresentationSignCallBackParams) => Promise<W3CVerifiablePresentation>;
export type PresentationSignCallback = (args: PresentationSignCallBackParams) => Promise<W3CVerifiablePresentation | CompactSdJwtVc>;

export interface VerifyAuthorizationResponseOpts {
correlationId: string;
Expand Down

0 comments on commit 867bbf7

Please sign in to comment.