From f031236c4153e71b53292b4751643d0595a4b617 Mon Sep 17 00:00:00 2001 From: Timo Glastra Date: Sun, 28 Jan 2024 15:49:36 +0700 Subject: [PATCH] fix: do not use path nested for sd-jwt Signed-off-by: Timo Glastra --- lib/evaluation/evaluationClientWrapper.ts | 6 +++++- test/SdJwt.spec.ts | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/evaluation/evaluationClientWrapper.ts b/lib/evaluation/evaluationClientWrapper.ts index 7272431b..94d3bfc2 100644 --- a/lib/evaluation/evaluationClientWrapper.ts +++ b/lib/evaluation/evaluationClientWrapper.ts @@ -431,10 +431,14 @@ export class EvaluationClientWrapper { if (descriptor.path_nested) { return descriptor; } + // sd-jwt doesn't use path_nested and format is the same for vc or vp + else if (descriptor.format === 'vc+sd-jwt') { + return descriptor; + } + const format = descriptor.format; const nestedDescriptor = { ...descriptor }; nestedDescriptor.path_nested = { ...descriptor }; - // todo: delete id? nestedDescriptor.path = '$'; // todo: We really should also look at the context of the VP, to determine whether it is jwt_vp vs jwt_vp_json instead of relying on the VC type if (format.startsWith('ldp_')) { diff --git a/test/SdJwt.spec.ts b/test/SdJwt.spec.ts index 228e42d8..2b297b56 100644 --- a/test/SdJwt.spec.ts +++ b/test/SdJwt.spec.ts @@ -254,9 +254,13 @@ describe('evaluate', () => { ).toString('base64url')}.signature`; return `${presentation.compactSdJwtVc}${kbJwt}`; }, - {}, + { + presentationSubmissionLocation: PresentationSubmissionLocation.EXTERNAL, + }, ); + // path_nested should not be used for sd-jwt + expect(presentationResult.presentationSubmission.descriptor_map[0].path_nested).toBeUndefined(); expect(presentationResult.presentationSubmission).toEqual({ definition_id: '32f54163-7166-48f1-93d8-ff217bdb0653', descriptor_map: [