Skip to content

Commit

Permalink
Refactor: Rolled back the changes in response type and updated DCQL l…
Browse files Browse the repository at this point in the history
…ibrary.
  • Loading branch information
zoemaas committed Jan 8, 2025
1 parent 9e2035b commit d002379
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 30 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"resolutions": {
"@sphereon/ssi-types": "0.32.0",
"dcql": "0.2.11",
"dcql": "0.2.17",
"node-fetch": "2.6.12"
},
"prettier": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
IVerifiablePresentation,
OriginalVerifiableCredential,
} from '@sphereon/ssi-types'
import { DcqlCredentialRepresentation, DcqlPresentationRecord, DcqlQuery, DcqlQueryResult } from 'dcql'
import { DcqlCredential, DcqlPresentation, DcqlQuery, DcqlQueryResult } from 'dcql'

import {
AuthorizationResponse,
Expand All @@ -28,7 +28,7 @@ import {
VerifyAuthorizationRequestOpts,
VPTokenLocation,
} from '..'
import { createPresentationSubmission } from '../authorization-response/OpenID4VP'
import { createPresentationSubmission } from '../authorization-response'
import SIOPErrors from '../types/Errors'

import { getCreateJwtCallback, getVerifyJwtCallback } from './DidJwtTestUtils'
Expand Down Expand Up @@ -749,21 +749,22 @@ describe('create JWT from Request JWT should', () => {
},
}

const vc: DcqlCredentialRepresentation = {
const vc: DcqlCredential = {
credential_format: 'vc+sd-jwt',
vct: sdjwt.decodedPayload.payload.vct,
claims: sdjwt.decodedPayload.payload,
}

const dcqlQueryResult: DcqlQueryResult = DcqlQuery.query(dcqlQuery, [vc])

const presentation: DcqlPresentationRecord.Output = {}
const presentation: DcqlPresentation.Output = {}
for (const [key, value] of Object.entries(dcqlQueryResult.credential_matches)) {
if (value.success) {
presentation[key] = sdjwt.compactJwtVc
}
}

const encodedPresentationRecord = DcqlPresentationRecord.parse(presentation)
const dcqlPresentation = DcqlPresentation.parse(presentation)

const responseOpts: AuthorizationResponseOpts = {
responseURI: EXAMPLE_REDIRECT_URL,
Expand All @@ -776,7 +777,7 @@ describe('create JWT from Request JWT should', () => {
}),
jwtIssuer: { method: 'did', didUrl: `${mockResEntity.did}#controller`, alg: SigningAlgo.ES256K },
dcqlQuery: {
encodedPresentationRecord,
dcqlPresentation
},
responseMode: ResponseMode.DIRECT_POST,
}
Expand Down
10 changes: 5 additions & 5 deletions packages/siop-oid4vp/lib/__tests__/SdJwt.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defaultHasher, SigningAlgo } from '@sphereon/oid4vc-common'
import { IPresentationDefinition } from '@sphereon/pex'
import { decodeSdJwtVc, OriginalVerifiableCredential } from '@sphereon/ssi-types'
import { DcqlCredentialRepresentation, DcqlQuery } from 'dcql'
import { DcqlCredential, DcqlQuery } from 'dcql'
import { Json } from 'dcql/dist/src/u-dcql'

import {
Expand Down Expand Up @@ -438,7 +438,7 @@ describe.skip('RP and OP interaction should', () => {
expect(verifiedAuthReqWithJWT.issuer).toMatch(rpMockEntity.did)

// The KB property is added to the JWT when the presentation is signed. Passing a VC will make the test fail
const dcqlCredentials: DcqlCredentialRepresentation[] = [KB_SD_JWT_PRESENTATION].map(vc => ({ claims: decodeSdJwtVc(vc as string, defaultHasher).decodedPayload as { [x: string]: Json }, vct: decodeSdJwtVc(vc as string, defaultHasher).decodedPayload.vct } ))
const dcqlCredentials: DcqlCredential[] = [KB_SD_JWT_PRESENTATION].map(vc => ({ credential_format: 'vc+sd-jwt', claims: decodeSdJwtVc(vc as string, defaultHasher).decodedPayload as { [x: string]: Json }, vct: decodeSdJwtVc(vc as string, defaultHasher).decodedPayload.vct } ))

const queryResult = DcqlQuery.query(sdJwtVcQuery, dcqlCredentials)

Expand Down Expand Up @@ -509,14 +509,14 @@ describe.skip('RP and OP interaction should', () => {
]
})

const encodedPresentationRecord: { [x: string]: string | { [x: string]: Json } } = {}
const dcqlPresentation: { [x: string]: string | { [x: string]: Json } } = {}

for (const [key, _] of Object.entries(queryResult.credential_matches)) {
encodedPresentationRecord[key] = KB_SD_JWT_PRESENTATION as string | { [x: string]: Json }
dcqlPresentation[key] = KB_SD_JWT_PRESENTATION as string | { [x: string]: Json }
}

const authenticationResponseWithJWT = await op.createAuthorizationResponse(verifiedAuthReqWithJWT, {
dcqlQuery: { encodedPresentationRecord },
dcqlQuery: { dcqlPresentation },
})
expect(authenticationResponseWithJWT.response.payload).toBeDefined()
expect(authenticationResponseWithJWT.response.idToken).toBeDefined()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ describe('Mattr OID4VP v18 credential offer', () => {
})

expect(verification).toBeDefined()
expect(verification.versions).toEqual([SupportedVersion.SIOPv2_D12_OID4VP_D18])
expect(verification.versions).toEqual([SupportedVersion.SIOPv2_D12_OID4VP_D20, SupportedVersion.SIOPv2_D12_OID4VP_D18])

/**
* pd value: {"id":"dae5d9b6-8145-4297-99b2-b8fcc5abb5ad","input_descriptors":[{"id":"OpenBadgeCredential","format":{"jwt_vc_json":{"alg":["EdDSA"]},"jwt_vc":{"alg":["EdDSA"]}},"constraints":{"fields":[{"path":["$.vc.type"],"filter":{"type":"array","items":{"type":"string"},"contains":{"const":"OpenBadgeCredential"}}}]}}]}
Expand Down
2 changes: 1 addition & 1 deletion packages/siop-oid4vp/lib/helpers/SIOPSpecVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const authorizationRequestVersionDiscovery = (authorizationRequest: Autho
!authorizationRequestCopy.registration_uri &&
!authorizationRequestCopy.registration &&
!(authorizationRequestCopy.claims && 'vp_token' in authorizationRequestCopy.claims) &&
authorizationRequestCopy.response_mode !== ResponseMode.DIRECT_POST // Post has been replaced by direct post
authorizationRequestCopy.response_mode !== ResponseMode.POST // Post has been replaced by direct post
) {
versions.push(SupportedVersion.SIOPv2_D12_OID4VP_D20)
}
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.28",
"dcql": "0.2.11",
"dcql": "0.2.17",
"@sphereon/pex-models": "^2.3.2",
"@sphereon/ssi-types": "0.32.0",
"cross-fetch": "^4.0.0",
Expand Down
30 changes: 15 additions & 15 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 d002379

Please sign in to comment.