From 29f51f82f5dcd41edf468a9cacfc19db1ce0a492 Mon Sep 17 00:00:00 2001 From: Dave Longley Date: Mon, 27 Nov 2023 11:09:11 -0500 Subject: [PATCH] Rename `prefixVC` to `prefixJwtVcPath`. --- lib/oid4vp.js | 11 +++++------ tests/unit/oid4vp.spec.js | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/oid4vp.js b/lib/oid4vp.js index 57a1d68..d40d286 100644 --- a/lib/oid4vp.js +++ b/lib/oid4vp.js @@ -297,7 +297,7 @@ export async function toVpr({ // converts a VPR to partial "authorization request" export function fromVpr({ - verifiablePresentationRequest, strict = false, prefixVC = false + verifiablePresentationRequest, strict = false, prefixJwtVcPath = false } = {}) { try { let {query} = verifiablePresentationRequest; @@ -326,7 +326,7 @@ export function fromVpr({ id: uuid(), input_descriptors: credentialQuery.map(q => _fromQueryByExampleQuery({ credentialQuery: q, - prefixVC + prefixJwtVcPath })) }, response_mode: 'direct_post' @@ -563,7 +563,7 @@ function _matchesInputDescriptor({ } // exported for testing purposes only -export function _fromQueryByExampleQuery({credentialQuery, prefixVC}) { +export function _fromQueryByExampleQuery({credentialQuery, prefixJwtVcPath}) { const fields = []; const inputDescriptor = { id: uuid(), @@ -599,13 +599,12 @@ export function _fromQueryByExampleQuery({credentialQuery, prefixVC}) { filter.const = value; } const fieldsPath = [JSONPath.toPathString(path)]; - // Include 'vc' path for JWT purposes - if(prefixVC) { + // include 'vc' path for queries against JWT payloads instead of VCs + if(prefixJwtVcPath) { const vcPath = [...path]; vcPath.splice(1, 0, 'vc'); fieldsPath.push(JSONPath.toPathString(vcPath)); } - fields.push({ path: fieldsPath, filter diff --git a/tests/unit/oid4vp.spec.js b/tests/unit/oid4vp.spec.js index a81e45b..19ed4bf 100644 --- a/tests/unit/oid4vp.spec.js +++ b/tests/unit/oid4vp.spec.js @@ -25,7 +25,7 @@ describe('OID4VP', () => { ] } }, - prefixVC: true + prefixJwtVcPath: true }); expect(presentation_definition.constraints.fields[0].path).to.eql([ '$[\'@context\']',