From 6cf06431a18f35bc30e816f25c1f2db10e6ceffd Mon Sep 17 00:00:00 2001 From: Martin Auer Date: Mon, 25 Nov 2024 14:43:26 +0100 Subject: [PATCH] fix: update dcql and incorporate feedback --- .../siop-oid4vp/lib/authorization-request/Payload.ts | 4 ++-- .../authorization-response/AuthorizationResponse.ts | 10 ++++------ .../siop-oid4vp/lib/authorization-response/Dcql.ts | 4 ++-- packages/siop-oid4vp/package.json | 2 +- pnpm-lock.yaml | 12 ++++++------ 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/packages/siop-oid4vp/lib/authorization-request/Payload.ts b/packages/siop-oid4vp/lib/authorization-request/Payload.ts index b21d7c70..07290006 100644 --- a/packages/siop-oid4vp/lib/authorization-request/Payload.ts +++ b/packages/siop-oid4vp/lib/authorization-request/Payload.ts @@ -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 } }), } } diff --git a/packages/siop-oid4vp/lib/authorization-response/AuthorizationResponse.ts b/packages/siop-oid4vp/lib/authorization-response/AuthorizationResponse.ts index 09d91a6c..da33733a 100644 --- a/packages/siop-oid4vp/lib/authorization-response/AuthorizationResponse.ts +++ b/packages/siop-oid4vp/lib/authorization-response/AuthorizationResponse.ts @@ -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 diff --git a/packages/siop-oid4vp/lib/authorization-response/Dcql.ts b/packages/siop-oid4vp/lib/authorization-response/Dcql.ts index 77ab1da5..7740fdb3 100644 --- a/packages/siop-oid4vp/lib/authorization-response/Dcql.ts +++ b/packages/siop-oid4vp/lib/authorization-response/Dcql.ts @@ -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') } diff --git a/packages/siop-oid4vp/package.json b/packages/siop-oid4vp/package.json index 937ce385..acb5d152 100644 --- a/packages/siop-oid4vp/package.json +++ b/packages/siop-oid4vp/package.json @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f4e47bc6..4b704bde 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -461,8 +461,8 @@ importers: specifier: ^4.0.0 version: 4.0.0(encoding@0.1.13) dcql: - specifier: ^0.2.13 - version: 0.2.13(typescript@5.4.5) + specifier: ^0.2.15 + version: 0.2.16(typescript@5.4.5) debug: specifier: ^4.3.5 version: 4.3.7 @@ -1867,7 +1867,7 @@ packages: '@expo/bunyan@4.0.1': resolution: {integrity: sha512-+Lla7nYSiHZirgK+U/uYzsLv/X+HaJienbD5AKX1UQZHYfWaP+9uuQluRB4GrEVWF0GZ7vEVp/jzaOT9k/SQlg==} - engines: {node: '>=0.10.0'} + engines: {'0': node >=0.10.0} '@expo/cli@0.7.3': resolution: {integrity: sha512-uMGHbAhApqXR2sd1KPhgvpbOhBBnspad8msEqHleT2PHXwKIwTUDzBGO9+jdOAWwCx2MJfw3+asYjzoD3DN9Bg==} @@ -4015,8 +4015,8 @@ packages: dayjs@1.11.13: resolution: {integrity: sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg==} - dcql@0.2.13: - resolution: {integrity: sha512-XfePsSz9ULj9HH3VFNguzK/xlFnliKDX2iUDb1tIrn97S+TfftcFo+jipw16m9jPlWLhhBx48QniF0D8KotIWA==} + dcql@0.2.16: + resolution: {integrity: sha512-sZpx8QZYc/vdPsOy0PyFWPNmTrDTPyLGsV0wPJJ6u/F+RFkQlw5LHV4fIfzPefdDKUF5YvGm3oDiBt3qzz9/zg==} debug@2.6.9: resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==} @@ -13835,7 +13835,7 @@ snapshots: dayjs@1.11.13: {} - dcql@0.2.13(typescript@5.4.5): + dcql@0.2.16(typescript@5.4.5): dependencies: valibot: 0.37.0(typescript@5.4.5) transitivePeerDependencies: