Skip to content

Commit 0e8d79b

Browse files
committed
Merge remote-tracking branch 'origin/feature/DIIPv4' into feature/DIIPv4
2 parents 9152518 + a539d92 commit 0e8d79b

13 files changed

Lines changed: 109 additions & 24 deletions

File tree

packages/client/lib/__tests__/EBSIE2E.spec.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { CredentialMapper } from '@sphereon/ssi-types'
44
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
55
//@ts-ignore
66
import { from } from '@trust/keyto'
7-
import { fetch } from 'cross-fetch'
7+
import fetch from 'cross-fetch'
88
import pkg from 'debug'
99
const { debug: Debug } = pkg
1010
import { base64url, importJWK, JWK, SignJWT } from 'jose'

packages/client/lib/__tests__/MattrE2E.spec.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Alg, Jwt } from '@sphereon/oid4vci-common'
22
import { CredentialMapper } from '@sphereon/ssi-types'
3-
import { fetch } from 'cross-fetch'
3+
import fetch from 'cross-fetch'
44
import { importJWK, JWK, SignJWT } from 'jose'
55
import { describe, expect, it } from 'vitest'
66

packages/client/lib/__tests__/SphereonE2E.spec.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { uuidv4 } from '@sphereon/oid4vc-common'
44
import { Alg, Jwt, ProofOfPossessionCallbacks } from '@sphereon/oid4vci-common'
55
import { CredentialMapper } from '@sphereon/ssi-types'
66
import * as didts from '@transmute/did-key.js'
7-
import { fetch } from 'cross-fetch'
7+
import fetch from 'cross-fetch'
88
import { importJWK, JWK, SignJWT } from 'jose'
99
import { describe, expect, it } from 'vitest'
1010

packages/client/lib/functions/CredentialOfferCommons.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
PRE_AUTH_GRANT_LITERAL,
77
UniformCredentialOfferRequest,
88
} from '@sphereon/oid4vci-common'
9-
import { fetch } from 'cross-fetch'
9+
import fetch from 'cross-fetch'
1010

1111
export function isUriEncoded(str: string): boolean {
1212
const pattern = /%[0-9A-F]{2}/i

packages/oid4vci-common/lib/functions/HttpUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Loggers } from '@sphereon/ssi-types'
2-
import { fetch } from 'cross-fetch'
2+
import fetch from 'cross-fetch'
33

44
import { Encoding, OpenIDResponse } from '../types'
55

packages/siop-oid4vp/lib/__tests__/IT.spec.ts

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,3 +1755,75 @@ describe.skip('RP and OP interaction should', () => {
17551755
expect(resState?.status).toBe('error')
17561756
})
17571757
})
1758+
1759+
1760+
describe('credential_sets tests', () => {
1761+
it('DCQL credential_sets: happy flow (single required option is satisfied)', () => {
1762+
const queryWithSet: DcqlQuery.Input = {
1763+
credentials: [
1764+
{
1765+
id: 'credA',
1766+
format: 'ldp_vc',
1767+
meta: {
1768+
type_values: [
1769+
['https://www.w3.org/2018/credentials#VerifiableCredential'],
1770+
['PermanentResidentCard']
1771+
]
1772+
},
1773+
claims: [{ path: ['givenName'], values: ['JANE'] }]
1774+
}
1775+
],
1776+
credential_sets: [
1777+
{
1778+
options: [['credA']],
1779+
required: true,
1780+
purpose: 'must include credA'
1781+
}
1782+
]
1783+
}
1784+
1785+
const parsed = DcqlQuery.parse(queryWithSet)
1786+
DcqlQuery.validate(parsed) // validates structure + credential_sets references
1787+
1788+
const dcqlCredential: DcqlW3cVcCredential = {
1789+
credential_format: 'ldp_vc',
1790+
claims: (getVCs()[0].credentialSubject as { [x: string]: Json }),
1791+
type: getVCs()[0].type,
1792+
cryptographic_holder_binding: true
1793+
}
1794+
1795+
const result: DcqlQueryResult = DcqlQuery.query(parsed, [dcqlCredential])
1796+
1797+
// set is satisfied and matching_options should include ['credA']
1798+
expect(result.can_be_satisfied).toBe(true)
1799+
expect(result.credential_sets?.[0].matching_options).toEqual([['credA']])
1800+
})
1801+
1802+
it('DCQL credential_sets: invalid rule (references unknown credential id) fails validation', () => {
1803+
const queryWithBadSet: DcqlQuery.Input = {
1804+
credentials: [
1805+
{
1806+
id: 'credA',
1807+
format: 'ldp_vc',
1808+
meta: {
1809+
type_values: [
1810+
['https://www.w3.org/2018/credentials#VerifiableCredential'],
1811+
['PermanentResidentCard']
1812+
]
1813+
},
1814+
claims: [{ path: ['givenName'], values: ['JANE'] }]
1815+
}
1816+
],
1817+
credential_sets: [
1818+
{
1819+
// This option references a non-existent credential query id
1820+
options: [['does_not_exist']],
1821+
required: true
1822+
}
1823+
]
1824+
}
1825+
1826+
const parsed = DcqlQuery.parse(queryWithBadSet)
1827+
expect(() => DcqlQuery.validate(parsed)).toThrowError(/Credential set contains undefined credential id/i)
1828+
})
1829+
})

packages/siop-oid4vp/lib/__tests__/e2e/mattr.launchpad.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { PresentationSignCallBackParams } from '@sphereon/pex'
33
import { W3CVerifiablePresentation } from '@sphereon/ssi-types'
44
import { DcqlPresentation, DcqlQuery, DcqlQueryResult, DcqlW3cVcCredential } from 'dcql'
55
import * as ed25519 from '@transmute/did-key-ed25519'
6-
import { fetch } from 'cross-fetch'
6+
import fetch from 'cross-fetch'
77
import { DIDDocument, DIDResolutionResult } from 'did-resolver'
88
import { importJWK, JWK, SignJWT } from 'jose'
99
// eslint-disable-next-line @typescript-eslint/ban-ts-comment

packages/siop-oid4vp/lib/authorization-response/Dcql.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export class Dcql {
5757
opts: {
5858
hasher?: HasherSync
5959
},
60-
) => {
60+
) : DcqlPresentationResult.Output => {
6161
const dcqlPresentation = Object.fromEntries(
6262
// FIXME SSISDK-41
6363
Object.entries(extractDcqlPresentationFromDcqlVpToken(record, opts)).map(([queryId, p]) => {

packages/siop-oid4vp/lib/authorization-response/OpenID4VP.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {DcqlPresentation, DcqlQuery} from 'dcql'
1313
import {verifyRevocation} from '../helpers'
1414
import {AuthorizationResponse} from './AuthorizationResponse'
1515
import {Dcql} from './Dcql'
16-
import {RevocationVerification, VerifiedOpenID4VPSubmission} from '../types'
16+
import {PresentationSubmission, RevocationVerification, VerifiedOpenID4VPSubmission} from '../types'
1717
import {VerifyAuthorizationResponseOpts,} from './types'
1818

1919
export const extractNonceFromWrappedVerifiablePresentation = (wrappedVp: WrappedVerifiablePresentation): string | undefined => {
@@ -50,6 +50,7 @@ export const verifyPresentations = async (
5050
verifyOpts: VerifyAuthorizationResponseOpts,
5151
): Promise<{ dcql: VerifiedOpenID4VPSubmission }> => {
5252
const dcqlQuery = DcqlQuery.parse(verifyOpts.dcqlQuery ?? authorizationResponse?.authorizationRequest.payload.dcql_query as DcqlQuery)
53+
DcqlQuery.validate(dcqlQuery)
5354
const dcqlPresentation = extractDcqlPresentationFromDcqlVpToken(authorizationResponse.payload.vp_token as string, { hasher: verifyOpts.hasher })
5455

5556
const wrappedPresentations = Object.values(dcqlPresentation)
@@ -59,7 +60,7 @@ export const verifyPresentations = async (
5960
),
6061
)
6162

62-
await Dcql.assertValidDcqlPresentationResult(authorizationResponse.payload.vp_token as string, dcqlQuery, { hasher: verifyOpts.hasher })
63+
const dcqlPresentationResult = await Dcql.assertValidDcqlPresentationResult(authorizationResponse.payload.vp_token as string, dcqlQuery, { hasher: verifyOpts.hasher })
6364

6465
if (verifiedPresentations.some((verified) => !verified)) {
6566
const message = verifiedPresentations
@@ -95,13 +96,13 @@ export const verifyPresentations = async (
9596
}
9697
}
9798

98-
return { dcql: { nonce, presentation: dcqlPresentation, dcqlQuery } }
99+
return { dcql: { nonce, presentation: dcqlPresentation, dcqlQuery , dcqlPresentationResult} }
99100
}
100101

101102
export const extractDcqlPresentationFromDcqlVpToken = (
102103
vpToken: DcqlPresentation.Input | string,
103104
opts?: { hasher?: HasherSync },
104-
): { [credentialQueryId: string]: WrappedVerifiablePresentation } => {
105+
): PresentationSubmission => {
105106
return Object.fromEntries(
106107
Object.entries(DcqlPresentation.parse(vpToken)).map(([credentialQueryId, vp]) => [
107108
credentialQueryId,

packages/siop-oid4vp/lib/helpers/HttpUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Loggers } from '@sphereon/ssi-types'
2-
import { fetch } from 'cross-fetch'
2+
import fetch from 'cross-fetch'
33
import { ContentType, SIOPErrors, SIOPResonse } from '../types'
44

55
const logger = Loggers.DEFAULT.get('sphereon:siopv2:http')

0 commit comments

Comments
 (0)