Skip to content

Commit

Permalink
Rename prefixVC to prefixJwtVcPath.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlongley committed Nov 27, 2023
1 parent 429d24d commit 29f51f8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions lib/oid4vp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -326,7 +326,7 @@ export function fromVpr({
id: uuid(),
input_descriptors: credentialQuery.map(q => _fromQueryByExampleQuery({
credentialQuery: q,
prefixVC
prefixJwtVcPath
}))
},
response_mode: 'direct_post'
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/oid4vp.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('OID4VP', () => {
]
}
},
prefixVC: true
prefixJwtVcPath: true
});
expect(presentation_definition.constraints.fields[0].path).to.eql([
'$[\'@context\']',
Expand Down

0 comments on commit 29f51f8

Please sign in to comment.