Skip to content

Commit 74b465c

Browse files
committed
Merge branch 'feature/DIIPv4' into feature/SSISDK-41_credential_sets
# Conflicts: # packages/siop-oid4vp/lib/authorization-response/OpenID4VP.ts # packages/siop-oid4vp/lib/types/SIOP.types.ts
2 parents 95e4de2 + d7b55db commit 74b465c

78 files changed

Lines changed: 3111 additions & 5883 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
[![CI](https://github.com/Sphereon-Opensource/OID4VC/actions/workflows/build-test-on-pr.yml/badge.svg)](https://github.com/Sphereon-Opensource/OID4VC/actions/workflows/build-test-on-pr.yml) [![codecov](https://codecov.io/gh/Sphereon-Opensource/OID4VC/branch/develop/graph/badge.svg)](https://codecov.io/gh/Sphereon-Opensource/OID4VC) [![NPM Version](https://img.shields.io/npm/v/@sphereon/oid4vci-client.svg)](https://npm.im/@sphereon/oid4vci-client)
99

10-
_IMPORTANT the packages are still in an early development stage, which means that breaking changes are to be expected_
10+
_IMPORTANT the packages are still in an early development stage, which means that breaking changes are to be expected The current branch only supports OID4VCI draft v15, for draft v13 and lower use branch archive/draft-v13-support_
1111

1212
# Background
1313

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"pnpm": ">=10"
2727
},
2828
"resolutions": {
29-
"@sphereon/ssi-types": "0.34.1-feat.SSISDK.35.61",
29+
"@sphereon/ssi-types": "0.34.1-feature.DIIPv4.164",
3030
"dcql": "1.0.1",
3131
"node-fetch": "2.6.12",
3232
"typescript": "5.8.3"

packages/callback-example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"@sphereon/oid4vci-client": "workspace:^",
3131
"@sphereon/oid4vci-common": "workspace:^",
3232
"@sphereon/oid4vci-issuer": "workspace:^",
33-
"@sphereon/ssi-types": "0.34.1-feat.SSISDK.35.61",
33+
"@sphereon/ssi-types": "0.34.1-feature.DIIPv4.164",
3434
"jose": "^4.10.0"
3535
},
3636
"devDependencies": {

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/client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"dependencies": {
3030
"@sphereon/oid4vc-common": "workspace:^",
3131
"@sphereon/oid4vci-common": "workspace:^",
32-
"@sphereon/ssi-types": "0.34.1-feat.SSISDK.35.61",
32+
"@sphereon/ssi-types": "0.34.1-feature.DIIPv4.164",
3333
"cross-fetch": "^4.1.0",
3434
"debug": "^4.4.0"
3535
},

packages/common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"test": "vitest run --config ../../vitest.config.ts --coverage"
2323
},
2424
"dependencies": {
25-
"@sphereon/ssi-types": "0.34.1-feat.SSISDK.35.61",
25+
"@sphereon/ssi-types": "0.34.1-feature.DIIPv4.164",
2626
"jwt-decode": "^4.0.0",
2727
"uint8arrays": "^3.1.1",
2828
"uuid": "^9.0.0"

packages/issuer-rest/lib/OID4VCIServer.ts

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
getCredentialOfferEndpoint,
2828
getCredentialOfferReferenceEndpoint,
2929
getIssueStatusEndpoint,
30-
getMetadataEndpoints,
30+
getMetadataEndpoints, nonceEndpoint,
3131
pushedAuthorizationEndpoint
3232
} from './oid4vci-api-functions'
3333

@@ -38,7 +38,7 @@ function buildVCIFromEnvironment() {
3838
.withFormat(process.env.credential_supported_format as unknown as OID4VCICredentialFormat)
3939
.withCredentialName(process.env.credential_supported_name_1 as string)
4040
.withCredentialDefinition({
41-
type: [process.env.credential_supported_1_definition_type_1 as string, process.env.credential_supported_1_definition_type_2 as string],
41+
type: [process.env.credential_supported_1_definition_type_1 as string, process.env.credential_supported_1_definition_type_2 as string]
4242
// TODO: setup credentialSubject here from env
4343
// credentialSubject
4444
})
@@ -47,20 +47,24 @@ function buildVCIFromEnvironment() {
4747
locale: process.env.credential_display_locale as string,
4848
logo: {
4949
url: process.env.credential_display_logo_url as string,
50-
alt_text: process.env.credential_display_logo_alt_text as string,
50+
alt_text: process.env.credential_display_logo_alt_text as string
5151
},
5252
background_color: process.env.credential_display_background_color as string,
53-
text_color: process.env.credential_display_text_color as string,
53+
text_color: process.env.credential_display_text_color as string
5454
})
5555
.build()
5656
const issuerBuilder = new VcIssuerBuilder()
57-
.withTXCode({ length: process.env.user_pin_length as unknown as number, input_mode: process.env.user_pin_input_mode as 'numeric' | 'text' })
57+
.withTXCode({
58+
length: process.env.user_pin_length as unknown as number,
59+
input_mode: process.env.user_pin_input_mode as 'numeric' | 'text'
60+
})
5861
.withAuthorizationServers(process.env.authorization_server as string)
5962
.withCredentialEndpoint(process.env.credential_endpoint as string)
63+
.withNonceEndpoint(process.env.nonce_endpoint as string)
6064
.withCredentialIssuer(process.env.credential_issuer as string)
6165
.withIssuerDisplay({
6266
name: process.env.issuer_name as string,
63-
locale: process.env.issuer_locale as string,
67+
locale: process.env.issuer_locale as string
6468
})
6569
.withCredentialConfigurationsSupported(credentialsSupported)
6670
.withInMemoryCredentialOfferState()
@@ -73,7 +77,7 @@ function buildVCIFromEnvironment() {
7377
issuerBuilder.withASClientMetadataParams({
7478
client_id: process.env.authorization_server_client_id,
7579
client_secret: process.env.authorization_server_client_secret,
76-
redirect_uris: [process.env.authorization_server_redirect_uri],
80+
redirect_uris: [process.env.authorization_server_redirect_uri]
7781
})
7882
}
7983

@@ -133,6 +137,11 @@ export interface IOID4VCIEndpointOpts {
133137
getIssuePayloadOpts?: IGetIssuePayloadEndpointOpts
134138
parOpts?: ISingleEndpointOpts
135139
authorizationChallengeOpts?: IAuthorizationChallengeEndpointOpts
140+
nonceOpts?: INonceEndpointOpts
141+
}
142+
143+
export interface INonceEndpointOpts extends ISingleEndpointOpts {
144+
baseUrl: string | URL
136145
}
137146

138147
export interface IOID4VCIServerOpts extends HasEndpointOpts {
@@ -153,7 +162,9 @@ export class OID4VCIServer {
153162

154163
constructor(
155164
expressSupport: ExpressSupport,
156-
opts: IOID4VCIServerOpts & { issuer?: VcIssuer } /*If not supplied as argument, it will be fully configured from environment variables*/,
165+
opts: IOID4VCIServerOpts & {
166+
issuer?: VcIssuer
167+
} /*If not supplied as argument, it will be fully configured from environment variables*/
157168
) {
158169
this._baseUrl = new URL(opts?.baseUrl ?? process.env.BASE_URL ?? opts?.issuer?.issuerMetadata?.credential_issuer ?? 'http://localhost')
159170
this._expressSupport = expressSupport
@@ -169,7 +180,7 @@ export class OID4VCIServer {
169180
if (this.isGetIssuePayloadEndpointEnabled(opts?.endpointOpts?.getIssuePayloadOpts)) {
170181
issuerPayloadPath = getCredentialOfferReferenceEndpoint(this.router, this.issuer, {
171182
...opts?.endpointOpts?.getIssuePayloadOpts,
172-
baseUrl: this.baseUrl,
183+
baseUrl: this.baseUrl
173184
})
174185
}
175186

@@ -185,11 +196,11 @@ export class OID4VCIServer {
185196
opts.endpointOpts?.tokenEndpointOpts?.accessTokenVerificationCallback ??
186197
(this._asClientOpts
187198
? oidcAccessTokenVerifyCallback({
188-
clientMetadata: this._asClientOpts,
189-
credentialIssuer: this._issuer.issuerMetadata.credential_issuer,
190-
authorizationServer: this._issuer.issuerMetadata.authorization_servers![0],
191-
})
192-
: undefined),
199+
clientMetadata: this._asClientOpts,
200+
credentialIssuer: this._issuer.issuerMetadata.credential_issuer,
201+
authorizationServer: this._issuer.issuerMetadata.authorization_servers![0]
202+
})
203+
: undefined)
193204
})
194205
this.assertAccessTokenHandling()
195206
if (!this.isTokenEndpointDisabled(opts?.endpointOpts?.tokenEndpointOpts, opts?.asClientOpts)) {
@@ -204,7 +215,17 @@ export class OID4VCIServer {
204215
} else if (!opts?.endpointOpts?.authorizationChallengeOpts?.verifyAuthResponseCallback) {
205216
throw Error(`Unable to enable authorization challenge endpoint. No verifyAuthResponseCallback present in authorization challenge options`)
206217
}
207-
authorizationChallengeEndpoint(this.router, this.issuer, { ...opts?.endpointOpts?.authorizationChallengeOpts, baseUrl: this.baseUrl })
218+
authorizationChallengeEndpoint(this.router, this.issuer, {
219+
...opts?.endpointOpts?.authorizationChallengeOpts,
220+
baseUrl: this.baseUrl
221+
})
222+
}
223+
224+
if (this.isNonceEndpointEnabled(opts?.endpointOpts?.nonceOpts)) {
225+
nonceEndpoint(this.router, this.issuer, {
226+
...opts?.endpointOpts?.nonceOpts,
227+
baseUrl: this.baseUrl,
228+
})
208229
}
209230
this._app.use(getBasePath(this.baseUrl), this._router)
210231
}
@@ -253,7 +274,7 @@ export class OID4VCIServer {
253274
if (this.isTokenEndpointDisabled(tokenEndpointOpts, this.issuer.asClientOpts)) {
254275
if (!authServer || authServer.length === 0) {
255276
throw Error(
256-
`No Authorization Server (AS) is defined in the issuer metadata and the token endpoint is disabled. An AS or token endpoints needs to be present`,
277+
`No Authorization Server (AS) is defined in the issuer metadata and the token endpoint is disabled. An AS or token endpoints needs to be present`
257278
)
258279
}
259280
if (this.issuer.asClientOpts) {
@@ -264,13 +285,18 @@ export class OID4VCIServer {
264285
} else {
265286
if (authServer && authServer.some((as) => as !== this.issuer.issuerMetadata.credential_issuer)) {
266287
throw Error(
267-
`An external Authorization Server (AS) was already enabled in the issuer metadata (${authServer}). Cannot both have an AS and enable the token endpoint at the same time `,
288+
`An external Authorization Server (AS) was already enabled in the issuer metadata (${authServer}). Cannot both have an AS and enable the token endpoint at the same time `
268289
)
269290
} else if (this._asClientOpts) {
270291
throw Error(`OIDC Client metadata is set, but the token endpoint is not disabled. This is not supported.`)
271292
}
272293
}
273294
}
295+
296+
private isNonceEndpointEnabled(nonceEndpointOpts?: INonceEndpointOpts) {
297+
return nonceEndpointOpts?.enabled !== false || process.env.NONCE_ENDPOINT_ENABLED !== 'false'
298+
}
299+
274300
get baseUrl(): URL {
275301
return this._baseUrl
276302
}

0 commit comments

Comments
 (0)