Skip to content

Commit

Permalink
fix: update dcql and incorporate feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
auer-martin committed Nov 25, 2024
1 parent c654a7b commit 76be4cc
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 19 deletions.
4 changes: 2 additions & 2 deletions packages/siop-oid4vp/lib/authorization-request/Payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ export const createPresentationDefinitionClaimsProperties = (opts: ClaimPayloadO

return {
...(opts.id_token ? { id_token: opts.id_token } : {}),
...((opts.vp_token.presentation_definition || opts.vp_token.presentation_definition_uri || opts.vp_token.dcql_query) && {
...((opts.vp_token.presentation_definition || opts.vp_token.presentation_definition_uri) && {
vp_token: {
...(!opts.vp_token.presentation_definition_uri && { presentation_definition: opts.vp_token.presentation_definition }),
...(opts.vp_token.presentation_definition_uri && { presentation_definition_uri: opts.vp_token.presentation_definition_uri }),
...(opts.vp_token.dcql_query && { dcql_query: opts.vp_token.dcql_query }),
},
}),
...(opts.vp_token.dcql_query && { vp_token: { dcql_query: opts.vp_token.dcql_query } }),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export class AuthorizationResponse {

if (responseOpts.presentationExchange) {
const wrappedPresentations = response.payload.vp_token
? await extractPresentationsFromVpToken(response.payload.vp_token, {
? extractPresentationsFromVpToken(response.payload.vp_token, {
hasher: verifyOpts.hasher,
})
: []
Expand All @@ -144,14 +144,12 @@ export class AuthorizationResponse {
hasher: verifyOpts.hasher,
},
})
} else {
const dcqlQuery = verifiedAuthorizationRequest.dcqlQuery
if (!dcqlQuery) {
throw new Error('vp_token is present, but no presentation definitions or dcql query provided')
}
assertValidDcqlPresentationResult(responseOpts.dcqlQuery.dcqlPresentation as DcqlPresentation, dcqlQuery, {
} else if (verifiedAuthorizationRequest.dcqlQuery) {
assertValidDcqlPresentationResult(responseOpts.dcqlQuery.dcqlPresentation as DcqlPresentation, verifiedAuthorizationRequest.dcqlQuery, {
hasher: verifyOpts.hasher,
})
} else {
throw new Error('vp_token is present, but no presentation definitions or dcql query provided')
}

return response
Expand Down
4 changes: 2 additions & 2 deletions packages/siop-oid4vp/lib/authorization-response/Dcql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ export const getDcqlPresentationResult = (record: DcqlPresentation | string, dcq
if (p.format === 'mso_mdoc') {
return [
queryId,
{ credentialFormat: 'mso_mdoc', doctype: p.vcs[0].credential.toJson().docType, namespaces: p.vcs[0].decoded } satisfies DcqlMdocCredential,
{ credential_format: 'mso_mdoc', doctype: p.vcs[0].credential.toJson().docType, namespaces: p.vcs[0].decoded } satisfies DcqlMdocCredential,
]
} else if (p.format === 'vc+sd-jwt') {
return [queryId, { credentialFormat: 'vc+sd-jwt', vct: p.vcs[0].decoded.vct, claims: p.vcs[0].decoded } satisfies DcqlSdJwtVcCredential]
return [queryId, { credential_format: 'vc+sd-jwt', vct: p.vcs[0].decoded.vct, claims: p.vcs[0].decoded } satisfies DcqlSdJwtVcCredential]
} else {
throw new Error('DcqlPresentation atm only supports mso_mdoc and vc+sd-jwt')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const verifyPresentations = async (
}
} else {
const presentations = authorizationResponse.payload.vp_token
? await extractPresentationsFromVpToken(authorizationResponse.payload.vp_token, { hasher: verifyOpts.hasher })
? extractPresentationsFromVpToken(authorizationResponse.payload.vp_token, { hasher: verifyOpts.hasher })
: []
wrappedPresentations = Array.isArray(presentations) ? presentations : [presentations]

Expand Down
2 changes: 1 addition & 1 deletion packages/siop-oid4vp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@sphereon/jarm": "workspace:*",
"@sphereon/oid4vc-common": "workspace:*",
"@sphereon/pex": "5.0.0-unstable.24",
"dcql": "^0.2.13",
"dcql": "^0.2.15",
"@sphereon/pex-models": "^2.3.1",
"@sphereon/ssi-types": "0.30.2-next.279",
"cross-fetch": "^4.0.0",
Expand Down
12 changes: 6 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 76be4cc

Please sign in to comment.