@sphereon/ssi-sdk.oid4vci-holder 0.34.1-next.299 → 0.34.1-next.322
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +93 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -11
- package/dist/index.d.ts +18 -11
- package/dist/index.js +78 -23
- package/dist/index.js.map +1 -1
- package/package.json +24 -24
- package/src/agent/OID4VCIHolder.ts +56 -21
- package/src/machines/oid4vciMachine.ts +37 -5
- package/src/services/OID4VCIHolderService.ts +2 -4
- package/src/types/IOID4VCIHolder.ts +18 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.oid4vci-holder",
|
|
3
|
-
"version": "0.34.1-next.
|
|
3
|
+
"version": "0.34.1-next.322+78f8dd31",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -26,27 +26,27 @@
|
|
|
26
26
|
"build": "tsup --config ../../tsup.config.ts --tsconfig ../../tsconfig.tsup.json"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@sphereon/did-auth-siop": "0.19.1-next.
|
|
29
|
+
"@sphereon/did-auth-siop": "0.19.1-next.234",
|
|
30
30
|
"@sphereon/kmp-mdoc-core": "0.2.0-SNAPSHOT.26",
|
|
31
|
-
"@sphereon/oid4vci-client": "0.19.1-next.
|
|
32
|
-
"@sphereon/oid4vci-common": "0.19.1-next.
|
|
33
|
-
"@sphereon/ssi-sdk-ext.did-utils": "0.34.1-next.
|
|
34
|
-
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.34.1-next.
|
|
35
|
-
"@sphereon/ssi-sdk-ext.jwt-service": "0.34.1-next.
|
|
36
|
-
"@sphereon/ssi-sdk-ext.key-utils": "0.34.1-next.
|
|
37
|
-
"@sphereon/ssi-sdk.contact-manager": "0.34.1-next.
|
|
38
|
-
"@sphereon/ssi-sdk.core": "0.34.1-next.
|
|
39
|
-
"@sphereon/ssi-sdk.credential-store": "0.34.1-next.
|
|
40
|
-
"@sphereon/ssi-sdk.credential-validation": "0.34.1-next.
|
|
41
|
-
"@sphereon/ssi-sdk.data-store-types": "0.34.1-next.
|
|
42
|
-
"@sphereon/ssi-sdk.issuance-branding": "0.34.1-next.
|
|
43
|
-
"@sphereon/ssi-sdk.mdl-mdoc": "0.34.1-next.
|
|
44
|
-
"@sphereon/ssi-sdk.oidf-client": "0.34.1-next.
|
|
45
|
-
"@sphereon/ssi-sdk.sd-jwt": "0.34.1-next.
|
|
46
|
-
"@sphereon/ssi-sdk.siopv2-oid4vp-common": "0.34.1-next.
|
|
47
|
-
"@sphereon/ssi-sdk.siopv2-oid4vp-op-auth": "0.34.1-next.
|
|
48
|
-
"@sphereon/ssi-sdk.xstate-machine-persistence": "0.34.1-next.
|
|
49
|
-
"@sphereon/ssi-types": "0.34.1-next.
|
|
31
|
+
"@sphereon/oid4vci-client": "0.19.1-next.234",
|
|
32
|
+
"@sphereon/oid4vci-common": "0.19.1-next.234",
|
|
33
|
+
"@sphereon/ssi-sdk-ext.did-utils": "0.34.1-next.322+78f8dd31",
|
|
34
|
+
"@sphereon/ssi-sdk-ext.identifier-resolution": "0.34.1-next.322+78f8dd31",
|
|
35
|
+
"@sphereon/ssi-sdk-ext.jwt-service": "0.34.1-next.322+78f8dd31",
|
|
36
|
+
"@sphereon/ssi-sdk-ext.key-utils": "0.34.1-next.322+78f8dd31",
|
|
37
|
+
"@sphereon/ssi-sdk.contact-manager": "0.34.1-next.322+78f8dd31",
|
|
38
|
+
"@sphereon/ssi-sdk.core": "0.34.1-next.322+78f8dd31",
|
|
39
|
+
"@sphereon/ssi-sdk.credential-store": "0.34.1-next.322+78f8dd31",
|
|
40
|
+
"@sphereon/ssi-sdk.credential-validation": "0.34.1-next.322+78f8dd31",
|
|
41
|
+
"@sphereon/ssi-sdk.data-store-types": "0.34.1-next.322+78f8dd31",
|
|
42
|
+
"@sphereon/ssi-sdk.issuance-branding": "0.34.1-next.322+78f8dd31",
|
|
43
|
+
"@sphereon/ssi-sdk.mdl-mdoc": "0.34.1-next.322+78f8dd31",
|
|
44
|
+
"@sphereon/ssi-sdk.oidf-client": "0.34.1-next.322+78f8dd31",
|
|
45
|
+
"@sphereon/ssi-sdk.sd-jwt": "0.34.1-next.322+78f8dd31",
|
|
46
|
+
"@sphereon/ssi-sdk.siopv2-oid4vp-common": "0.34.1-next.322+78f8dd31",
|
|
47
|
+
"@sphereon/ssi-sdk.siopv2-oid4vp-op-auth": "0.34.1-next.322+78f8dd31",
|
|
48
|
+
"@sphereon/ssi-sdk.xstate-machine-persistence": "0.34.1-next.322+78f8dd31",
|
|
49
|
+
"@sphereon/ssi-types": "0.34.1-next.322+78f8dd31",
|
|
50
50
|
"@veramo/core": "4.2.0",
|
|
51
51
|
"@veramo/data-store": "4.2.0",
|
|
52
52
|
"@veramo/utils": "4.2.0",
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
"xstate": "^4.38.3"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@sphereon/oid4vc-common": "0.19.1-next.
|
|
63
|
-
"@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.34.1-next.
|
|
62
|
+
"@sphereon/oid4vc-common": "0.19.1-next.234",
|
|
63
|
+
"@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.34.1-next.322+78f8dd31",
|
|
64
64
|
"@sphereon/ssi-sdk.siopv2-oid4vp-common": "workspace:*",
|
|
65
65
|
"@types/i18n-js": "^3.8.9",
|
|
66
66
|
"@types/lodash.memoize": "^4.1.9",
|
|
@@ -90,5 +90,5 @@
|
|
|
90
90
|
"OID4VCI",
|
|
91
91
|
"State Machine"
|
|
92
92
|
],
|
|
93
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "78f8dd3157066ae8cf11d2ae50c8c3d8f43b8ed0"
|
|
94
94
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CredentialOfferClient, MetadataClient, OpenID4VCIClient } from '@sphereon/oid4vci-client'
|
|
1
|
+
import { CredentialOfferClient, MetadataClient, OpenID4VCIClient, OpenID4VCIClientV1_0_15 } from '@sphereon/oid4vci-client'
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
AuthorizationDetailsV1_0_15,
|
|
4
4
|
AuthorizationRequestOpts,
|
|
5
5
|
AuthorizationServerClientOpts,
|
|
6
6
|
AuthorizationServerOpts,
|
|
@@ -29,11 +29,11 @@ import {
|
|
|
29
29
|
import { IJwtService, JwsHeader } from '@sphereon/ssi-sdk-ext.jwt-service'
|
|
30
30
|
import { signatureAlgorithmFromKey } from '@sphereon/ssi-sdk-ext.key-utils'
|
|
31
31
|
import { defaultHasher } from '@sphereon/ssi-sdk.core'
|
|
32
|
-
import { ensureRawDocument } from '@sphereon/ssi-sdk.data-store-types'
|
|
33
32
|
import {
|
|
34
33
|
ConnectionType,
|
|
35
34
|
CorrelationIdentifierType,
|
|
36
35
|
CredentialCorrelationType,
|
|
36
|
+
ensureRawDocument,
|
|
37
37
|
FindPartyArgs,
|
|
38
38
|
IBasicCredentialLocaleBranding,
|
|
39
39
|
IBasicIssuerLocaleBranding,
|
|
@@ -109,6 +109,8 @@ import {
|
|
|
109
109
|
OnContactIdentityCreatedArgs,
|
|
110
110
|
OnCredentialStoredArgs,
|
|
111
111
|
OnIdentifierCreatedArgs,
|
|
112
|
+
PrepareAuthorizationRequestArgs,
|
|
113
|
+
PrepareAuthorizationResult,
|
|
112
114
|
PrepareStartArgs,
|
|
113
115
|
RequestType,
|
|
114
116
|
RequiredContext,
|
|
@@ -214,6 +216,7 @@ export class OID4VCIHolder implements IAgentPlugin {
|
|
|
214
216
|
oid4vciHolderStart: this.oid4vciHolderStart.bind(this),
|
|
215
217
|
oid4vciHolderGetIssuerMetadata: this.oid4vciHolderGetIssuerMetadata.bind(this),
|
|
216
218
|
oid4vciHolderGetMachineInterpreter: this.oid4vciHolderGetMachineInterpreter.bind(this),
|
|
219
|
+
oid4vciHolderPrepareAuthorizationRequest: this.oid4vciHolderPrepareAuthorizationRequest.bind(this),
|
|
217
220
|
oid4vciHolderCreateCredentialsToSelectFrom: this.oid4vciHolderCreateCredentialsToSelectFrom.bind(this),
|
|
218
221
|
oid4vciHolderGetContact: this.oid4vciHolderGetContact.bind(this),
|
|
219
222
|
oid4vciHolderGetCredentials: this.oid4vciHolderGetCredentials.bind(this),
|
|
@@ -324,6 +327,8 @@ export class OID4VCIHolder implements IAgentPlugin {
|
|
|
324
327
|
startFirstPartApplicationMachine({ ...args, stateNavigationListener: opts.firstPartyStateNavigationListener }, context),
|
|
325
328
|
[OID4VCIMachineServices.createCredentialsToSelectFrom]: (args: CreateCredentialsToSelectFromArgs) =>
|
|
326
329
|
this.oid4vciHolderCreateCredentialsToSelectFrom(args, context),
|
|
330
|
+
[OID4VCIMachineServices.prepareAuthorizationRequest]: (args: PrepareAuthorizationRequestArgs) =>
|
|
331
|
+
this.oid4vciHolderPrepareAuthorizationRequest(args, context),
|
|
327
332
|
[OID4VCIMachineServices.getContact]: (args: GetContactArgs) => this.oid4vciHolderGetContact(args, context),
|
|
328
333
|
[OID4VCIMachineServices.getCredentials]: (args: GetCredentialsArgs) =>
|
|
329
334
|
this.oid4vciHolderGetCredentials({ accessTokenOpts: args.accessTokenOpts ?? opts.accessTokenOpts, ...args }, context),
|
|
@@ -373,11 +378,9 @@ export class OID4VCIHolder implements IAgentPlugin {
|
|
|
373
378
|
}
|
|
374
379
|
|
|
375
380
|
const authorizationRequestOpts = { ...this.defaultAuthorizationRequestOpts, ...args.authorizationRequestOpts } satisfies AuthorizationRequestOpts
|
|
376
|
-
//
|
|
381
|
+
// TODO: Previously we filtered the details first against our vcformat prefs. However auth details does not have the notion of formats anymore
|
|
377
382
|
authorizationRequestOpts.authorizationDetails = authorizationRequestOpts?.authorizationDetails
|
|
378
|
-
? asArray(authorizationRequestOpts.authorizationDetails)
|
|
379
|
-
(detail) => typeof detail === 'string' || this.vcFormatPreferences.includes(detail.format),
|
|
380
|
-
)
|
|
383
|
+
? asArray(authorizationRequestOpts.authorizationDetails)
|
|
381
384
|
: undefined
|
|
382
385
|
|
|
383
386
|
if (!authorizationRequestOpts.redirectUri) {
|
|
@@ -389,18 +392,19 @@ export class OID4VCIHolder implements IAgentPlugin {
|
|
|
389
392
|
authorizationRequestOpts.clientId = authorizationRequestOpts.redirectUri
|
|
390
393
|
}
|
|
391
394
|
|
|
395
|
+
// TODO: This entire filter and formats population should not work anymore, as the auth details no longer have the format property.
|
|
392
396
|
let formats: string[] = this.vcFormatPreferences
|
|
393
397
|
const authFormats = authorizationRequestOpts?.authorizationDetails
|
|
394
|
-
?.map((detail:
|
|
398
|
+
?.map((detail: AuthorizationDetailsV1_0_15) => (typeof detail === 'object' && 'format' in detail && detail.format ? detail.format : undefined))
|
|
395
399
|
.filter((format) => !!format)
|
|
396
400
|
.map((format) => format as string)
|
|
397
401
|
if (authFormats && authFormats.length > 0) {
|
|
398
402
|
formats = Array.from(new Set(authFormats))
|
|
399
403
|
}
|
|
400
|
-
let oid4vciClient:
|
|
404
|
+
let oid4vciClient: OpenID4VCIClientV1_0_15
|
|
401
405
|
let offer: CredentialOfferRequestWithBaseUrl | undefined
|
|
402
406
|
if (requestData.existingClientState) {
|
|
403
|
-
oid4vciClient = await
|
|
407
|
+
oid4vciClient = await OpenID4VCIClientV1_0_15.fromState({ state: requestData.existingClientState })
|
|
404
408
|
offer = oid4vciClient.credentialOffer
|
|
405
409
|
} else {
|
|
406
410
|
offer = requestData.credentialOffer
|
|
@@ -422,19 +426,19 @@ export class OID4VCIHolder implements IAgentPlugin {
|
|
|
422
426
|
if (!offer) {
|
|
423
427
|
// else no offer, meaning we have an issuer URL
|
|
424
428
|
logger.log(`Issuer url received (no credential offer): ${uri}`)
|
|
425
|
-
oid4vciClient = await
|
|
429
|
+
oid4vciClient = await OpenID4VCIClientV1_0_15.fromCredentialIssuer({
|
|
426
430
|
credentialIssuer: uri,
|
|
427
431
|
authorizationRequest: authorizationRequestOpts,
|
|
428
432
|
clientId: authorizationRequestOpts.clientId,
|
|
429
|
-
createAuthorizationRequestURL: requestData.createAuthorizationRequestURL ?? true,
|
|
433
|
+
createAuthorizationRequestURL: false, // requestData.createAuthorizationRequestURL ?? true,
|
|
430
434
|
})
|
|
431
435
|
} else {
|
|
432
436
|
logger.log(`Credential offer received: ${uri}`)
|
|
433
|
-
oid4vciClient = await
|
|
437
|
+
oid4vciClient = await OpenID4VCIClientV1_0_15.fromURI({
|
|
434
438
|
uri,
|
|
435
439
|
authorizationRequest: authorizationRequestOpts,
|
|
436
440
|
clientId: authorizationRequestOpts.clientId,
|
|
437
|
-
createAuthorizationRequestURL: requestData.createAuthorizationRequestURL ?? true,
|
|
441
|
+
createAuthorizationRequestURL: false, // requestData.createAuthorizationRequestURL ?? true,
|
|
438
442
|
})
|
|
439
443
|
}
|
|
440
444
|
}
|
|
@@ -444,7 +448,7 @@ export class OID4VCIHolder implements IAgentPlugin {
|
|
|
444
448
|
configurationIds = offer.original_credential_offer.credential_configuration_ids
|
|
445
449
|
} else {
|
|
446
450
|
configurationIds = asArray(authorizationRequestOpts.authorizationDetails)
|
|
447
|
-
.filter((authDetails): authDetails is Exclude<
|
|
451
|
+
// .filter((authDetails): authDetails is Exclude<AuthorizationDetailsV1_0_15, string> => typeof authDetails !== 'string')
|
|
448
452
|
.map((authReqOpts) => authReqOpts.credential_configuration_id)
|
|
449
453
|
.filter((id): id is string => !!id)
|
|
450
454
|
}
|
|
@@ -457,14 +461,9 @@ export class OID4VCIHolder implements IAgentPlugin {
|
|
|
457
461
|
|
|
458
462
|
const serverMetadata = await oid4vciClient.retrieveServerMetadata()
|
|
459
463
|
const credentialBranding = await getCredentialBranding({ credentialsSupported, context })
|
|
460
|
-
const authorizationCodeURL = oid4vciClient.authorizationURL
|
|
461
|
-
if (authorizationCodeURL) {
|
|
462
|
-
logger.log(`authorization code URL ${authorizationCodeURL}`)
|
|
463
|
-
}
|
|
464
464
|
const oid4vciClientState = JSON.parse(await oid4vciClient.exportState())
|
|
465
465
|
|
|
466
466
|
return {
|
|
467
|
-
authorizationCodeURL,
|
|
468
467
|
credentialBranding,
|
|
469
468
|
credentialsSupported,
|
|
470
469
|
serverMetadata,
|
|
@@ -472,6 +471,42 @@ export class OID4VCIHolder implements IAgentPlugin {
|
|
|
472
471
|
}
|
|
473
472
|
}
|
|
474
473
|
|
|
474
|
+
private async oid4vciHolderPrepareAuthorizationRequest(
|
|
475
|
+
args: PrepareAuthorizationRequestArgs,
|
|
476
|
+
context: RequiredContext,
|
|
477
|
+
): Promise<PrepareAuthorizationResult> {
|
|
478
|
+
const { openID4VCIClientState, contact } = args
|
|
479
|
+
if (!openID4VCIClientState) {
|
|
480
|
+
return Promise.reject(Error('Missing openID4VCI client state in context'))
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
const clientId = contact?.identities
|
|
484
|
+
.map((identity) => {
|
|
485
|
+
const connectionConfig = identity.connection?.config
|
|
486
|
+
if (connectionConfig && 'clientId' in connectionConfig) {
|
|
487
|
+
return connectionConfig.clientId
|
|
488
|
+
}
|
|
489
|
+
return undefined
|
|
490
|
+
})
|
|
491
|
+
.find((clientId) => clientId)
|
|
492
|
+
|
|
493
|
+
if (!clientId) {
|
|
494
|
+
return Promise.reject(Error(`Missing client id in contact's connectionConfig`))
|
|
495
|
+
}
|
|
496
|
+
const client = await OpenID4VCIClient.fromState({ state: openID4VCIClientState })
|
|
497
|
+
const authorizationCodeURL = await client.createAuthorizationRequestUrl({
|
|
498
|
+
authorizationRequest: {
|
|
499
|
+
clientId: clientId,
|
|
500
|
+
} satisfies AuthorizationRequestOpts,
|
|
501
|
+
})
|
|
502
|
+
if (authorizationCodeURL) {
|
|
503
|
+
logger.log(`authorization code URL ${authorizationCodeURL}`)
|
|
504
|
+
}
|
|
505
|
+
return {
|
|
506
|
+
authorizationCodeURL,
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
475
510
|
private async oid4vciHolderCreateCredentialsToSelectFrom(
|
|
476
511
|
args: CreateCredentialsToSelectFromArgs,
|
|
477
512
|
context: RequiredContext,
|
|
@@ -587,7 +622,7 @@ export class OID4VCIHolder implements IAgentPlugin {
|
|
|
587
622
|
return Promise.reject(Error('Missing openID4VCI client state in context'))
|
|
588
623
|
}
|
|
589
624
|
|
|
590
|
-
const client = await
|
|
625
|
+
const client = await OpenID4VCIClientV1_0_15.fromState({ state: openID4VCIClientState })
|
|
591
626
|
const credentialsSupported = await getCredentialConfigsSupportedMerged({
|
|
592
627
|
client,
|
|
593
628
|
vcFormatPreferences: this.vcFormatPreferences,
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
SelectCredentialsEvent,
|
|
29
29
|
SetAuthorizationCodeURLEvent,
|
|
30
30
|
VerificationCodeEvent,
|
|
31
|
+
PrepareAuthorizationResult,
|
|
31
32
|
} from '../types/IOID4VCIHolder'
|
|
32
33
|
import { FirstPartyMachineStateTypes } from '../types/FirstPartyMachine'
|
|
33
34
|
|
|
@@ -98,9 +99,7 @@ const oid4vciRequireAuthorizationGuard = (ctx: OID4VCIMachineContext, _event: OI
|
|
|
98
99
|
throw Error('Missing openID4VCI client state in context')
|
|
99
100
|
}
|
|
100
101
|
|
|
101
|
-
if (
|
|
102
|
-
return false
|
|
103
|
-
} else if (openID4VCIClientState.authorizationRequestOpts) {
|
|
102
|
+
if (openID4VCIClientState.authorizationURL && openID4VCIClientState.authorizationRequestOpts) {
|
|
104
103
|
// We have authz options or there is not credential offer to begin with.
|
|
105
104
|
// We require authz as long as we do not have the authz code response
|
|
106
105
|
return !ctx.openID4VCIClientState?.authorizationCodeResponse
|
|
@@ -164,6 +163,9 @@ const createOID4VCIMachine = (opts?: CreateOID4VCIMachineOpts): OID4VCIStateMach
|
|
|
164
163
|
[OID4VCIMachineServices.start]: {
|
|
165
164
|
data: StartResult
|
|
166
165
|
}
|
|
166
|
+
[OID4VCIMachineServices.prepareAuthorizationRequest]: {
|
|
167
|
+
data: PrepareAuthorizationResult
|
|
168
|
+
}
|
|
167
169
|
[OID4VCIMachineServices.createCredentialsToSelectFrom]: {
|
|
168
170
|
data: Array<CredentialToSelectFromResult>
|
|
169
171
|
}
|
|
@@ -208,7 +210,6 @@ const createOID4VCIMachine = (opts?: CreateOID4VCIMachineOpts): OID4VCIStateMach
|
|
|
208
210
|
onDone: {
|
|
209
211
|
target: OID4VCIMachineStates.createCredentialsToSelectFrom,
|
|
210
212
|
actions: assign({
|
|
211
|
-
authorizationCodeURL: (_ctx: OID4VCIMachineContext, _event: DoneInvokeEvent<StartResult>) => _event.data.authorizationCodeURL,
|
|
212
213
|
credentialBranding: (_ctx: OID4VCIMachineContext, _event: DoneInvokeEvent<StartResult>) => _event.data.credentialBranding ?? {},
|
|
213
214
|
credentialsSupported: (_ctx: OID4VCIMachineContext, _event: DoneInvokeEvent<StartResult>) => _event.data.credentialsSupported,
|
|
214
215
|
serverMetadata: (_ctx: OID4VCIMachineContext, _event: DoneInvokeEvent<StartResult>) => _event.data.serverMetadata,
|
|
@@ -439,6 +440,10 @@ const createOID4VCIMachine = (opts?: CreateOID4VCIMachineOpts): OID4VCIStateMach
|
|
|
439
440
|
target: OID4VCIMachineStates.startFirstPartApplicationFlow,
|
|
440
441
|
cond: OID4VCIMachineGuards.isFirstPartyApplication,
|
|
441
442
|
},
|
|
443
|
+
{
|
|
444
|
+
target: OID4VCIMachineStates.prepareAuthorizationRequest,
|
|
445
|
+
cond: OID4VCIMachineGuards.requireAuthorizationGuard,
|
|
446
|
+
},
|
|
442
447
|
{
|
|
443
448
|
target: OID4VCIMachineStates.initiateAuthorizationRequest,
|
|
444
449
|
cond: OID4VCIMachineGuards.requireAuthorizationGuard,
|
|
@@ -511,12 +516,16 @@ const createOID4VCIMachine = (opts?: CreateOID4VCIMachineOpts): OID4VCIStateMach
|
|
|
511
516
|
target: OID4VCIMachineStates.startFirstPartApplicationFlow,
|
|
512
517
|
cond: OID4VCIMachineGuards.isFirstPartyApplication,
|
|
513
518
|
},
|
|
519
|
+
{
|
|
520
|
+
target: OID4VCIMachineStates.prepareAuthorizationRequest,
|
|
521
|
+
cond: OID4VCIMachineGuards.requireAuthorizationGuard,
|
|
522
|
+
},
|
|
514
523
|
{
|
|
515
524
|
target: OID4VCIMachineStates.verifyPin,
|
|
516
525
|
cond: OID4VCIMachineGuards.requirePinGuard,
|
|
517
526
|
},
|
|
518
527
|
{
|
|
519
|
-
target: OID4VCIMachineStates.
|
|
528
|
+
target: OID4VCIMachineStates.prepareAuthorizationRequest,
|
|
520
529
|
cond: OID4VCIMachineGuards.requireAuthorizationGuard,
|
|
521
530
|
},
|
|
522
531
|
{
|
|
@@ -524,6 +533,29 @@ const createOID4VCIMachine = (opts?: CreateOID4VCIMachineOpts): OID4VCIStateMach
|
|
|
524
533
|
},
|
|
525
534
|
],
|
|
526
535
|
},
|
|
536
|
+
[OID4VCIMachineStates.prepareAuthorizationRequest]: {
|
|
537
|
+
id: OID4VCIMachineStates.prepareAuthorizationRequest,
|
|
538
|
+
invoke: {
|
|
539
|
+
src: OID4VCIMachineServices.prepareAuthorizationRequest,
|
|
540
|
+
onDone: {
|
|
541
|
+
target: OID4VCIMachineStates.initiateAuthorizationRequest,
|
|
542
|
+
actions: assign({
|
|
543
|
+
authorizationCodeURL: (_ctx: OID4VCIMachineContext, _event: DoneInvokeEvent<PrepareAuthorizationResult>) =>
|
|
544
|
+
_event.data.authorizationCodeURL,
|
|
545
|
+
}),
|
|
546
|
+
},
|
|
547
|
+
onError: {
|
|
548
|
+
target: OID4VCIMachineStates.handleError,
|
|
549
|
+
actions: assign({
|
|
550
|
+
error: (_ctx: OID4VCIMachineContext, _event: DoneInvokeEvent<Error>): ErrorDetails => ({
|
|
551
|
+
title: translate('oid4vci_machine_prepare_authorization_error_title'),
|
|
552
|
+
message: _event.data.message,
|
|
553
|
+
stack: _event.data.stack,
|
|
554
|
+
}),
|
|
555
|
+
}),
|
|
556
|
+
},
|
|
557
|
+
},
|
|
558
|
+
},
|
|
527
559
|
[OID4VCIMachineStates.initiateAuthorizationRequest]: {
|
|
528
560
|
id: OID4VCIMachineStates.initiateAuthorizationRequest,
|
|
529
561
|
on: {
|
|
@@ -209,9 +209,7 @@ export const mapCredentialToAccept = async (args: MapCredentialToAcceptArgs): Pr
|
|
|
209
209
|
)
|
|
210
210
|
let uniformVerifiableCredential: IVerifiableCredential
|
|
211
211
|
if (CredentialMapper.isSdJwtDecodedCredential(wrappedVerifiableCredential.credential)) {
|
|
212
|
-
uniformVerifiableCredential =
|
|
213
|
-
<SdJwtDecodedVerifiableCredential>wrappedVerifiableCredential.credential,
|
|
214
|
-
)
|
|
212
|
+
uniformVerifiableCredential = sdJwtDecodedCredentialToUniformCredential(<SdJwtDecodedVerifiableCredential>wrappedVerifiableCredential.credential)
|
|
215
213
|
} else if (CredentialMapper.isSdJwtEncoded(wrappedVerifiableCredential.credential)) {
|
|
216
214
|
if (!hasher) {
|
|
217
215
|
return Promise.reject('a hasher is required for encoded SD-JWT credentials')
|
|
@@ -384,7 +382,7 @@ export const getCredentialConfigsSupportedBySingleTypeOrId = async (
|
|
|
384
382
|
}
|
|
385
383
|
|
|
386
384
|
if (configurationId) {
|
|
387
|
-
const allSupported = client.getCredentialsSupported(format)
|
|
385
|
+
const allSupported = client.getCredentialsSupported(undefined, format)
|
|
388
386
|
return Object.fromEntries(
|
|
389
387
|
Object.entries(allSupported).filter(
|
|
390
388
|
([id, supported]) => id === configurationId || supported.id === configurationId || createIdFromTypes(supported) === configurationId,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DynamicRegistrationClientMetadata } from '@sphereon/oid4vc-common'
|
|
2
|
+
import { OpenID4VCIClientState, OpenID4VCIClientV1_0_15 } from '@sphereon/oid4vci-client'
|
|
2
3
|
import {
|
|
3
4
|
AuthorizationRequestOpts,
|
|
4
5
|
AuthorizationResponse,
|
|
@@ -15,7 +16,6 @@ import {
|
|
|
15
16
|
MetadataDisplay,
|
|
16
17
|
NotificationRequest,
|
|
17
18
|
} from '@sphereon/oid4vci-common'
|
|
18
|
-
import { DynamicRegistrationClientMetadata } from '@sphereon/oid4vc-common'
|
|
19
19
|
import { CreateOrGetIdentifierOpts, IdentifierProviderOpts, SupportedDidMethodEnum } from '@sphereon/ssi-sdk-ext.did-utils'
|
|
20
20
|
import {
|
|
21
21
|
IIdentifierResolution,
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
import { IJwtService } from '@sphereon/ssi-sdk-ext.jwt-service'
|
|
27
27
|
import { IContactManager } from '@sphereon/ssi-sdk.contact-manager'
|
|
28
28
|
import { ICredentialStore } from '@sphereon/ssi-sdk.credential-store'
|
|
29
|
+
import { ICredentialValidation, SchemaValidation } from '@sphereon/ssi-sdk.credential-validation'
|
|
29
30
|
import {
|
|
30
31
|
DigitalCredential,
|
|
31
32
|
IBasicCredentialClaim,
|
|
@@ -38,7 +39,6 @@ import {
|
|
|
38
39
|
import { IIssuanceBranding } from '@sphereon/ssi-sdk.issuance-branding'
|
|
39
40
|
import { ImDLMdoc } from '@sphereon/ssi-sdk.mdl-mdoc'
|
|
40
41
|
import { ISDJwtPlugin } from '@sphereon/ssi-sdk.sd-jwt'
|
|
41
|
-
import { ICredentialValidation, SchemaValidation } from '@sphereon/ssi-sdk.credential-validation'
|
|
42
42
|
import { IDidAuthSiopOpAuthenticator } from '@sphereon/ssi-sdk.siopv2-oid4vp-op-auth'
|
|
43
43
|
import {
|
|
44
44
|
HasherSync,
|
|
@@ -79,6 +79,7 @@ export interface IOID4VCIHolder extends IPluginMethodMap {
|
|
|
79
79
|
context: RequiredContext,
|
|
80
80
|
): Promise<Array<CredentialToSelectFromResult>>
|
|
81
81
|
|
|
82
|
+
oid4vciHolderPrepareAuthorizationRequest(args: PrepareAuthorizationRequestArgs, context: RequiredContext): Promise<PrepareAuthorizationResult>
|
|
82
83
|
oid4vciHolderGetContact(args: GetContactArgs, context: RequiredContext): Promise<Party | undefined>
|
|
83
84
|
|
|
84
85
|
oid4vciHolderGetCredentials(args: GetCredentialsArgs, context: RequiredContext): Promise<Array<MappedCredentialToAccept>>
|
|
@@ -148,6 +149,7 @@ export type PrepareStartArgs = Pick<
|
|
|
148
149
|
OID4VCIMachineContext,
|
|
149
150
|
'requestData' | 'authorizationRequestOpts' | 'didMethodPreferences' | 'issuanceOpt' | 'accessTokenOpts'
|
|
150
151
|
>
|
|
152
|
+
export type PrepareAuthorizationRequestArgs = Pick<OID4VCIMachineContext, 'openID4VCIClientState' | 'contact'>
|
|
151
153
|
export type CreateCredentialsToSelectFromArgs = Pick<
|
|
152
154
|
OID4VCIMachineContext,
|
|
153
155
|
'credentialsSupported' | 'credentialBranding' | 'selectedCredentials' | 'locale' | 'openID4VCIClientState'
|
|
@@ -256,6 +258,7 @@ export enum OID4VCIMachineStates {
|
|
|
256
258
|
selectCredentials = 'selectCredentials',
|
|
257
259
|
transitionFromSelectingCredentials = 'transitionFromSelectingCredentials',
|
|
258
260
|
verifyPin = 'verifyPin',
|
|
261
|
+
prepareAuthorizationRequest = 'prepareAuthorizationRequest',
|
|
259
262
|
initiateAuthorizationRequest = 'initiateAuthorizationRequest',
|
|
260
263
|
waitForAuthorizationResponse = 'waitForAuthorizationResponse',
|
|
261
264
|
getCredentials = 'getCredentials',
|
|
@@ -395,6 +398,7 @@ export enum OID4VCIMachineServices {
|
|
|
395
398
|
getFederationTrust = 'getFederationTrust',
|
|
396
399
|
addContactIdentity = 'addContactIdentity',
|
|
397
400
|
createCredentialsToSelectFrom = 'createCredentialsToSelectFrom',
|
|
401
|
+
prepareAuthorizationRequest = 'prepareAuthorizationRequest',
|
|
398
402
|
getIssuerBranding = 'getIssuerBranding',
|
|
399
403
|
storeIssuerBranding = 'storeIssuerBranding',
|
|
400
404
|
getCredentials = 'getCredentials',
|
|
@@ -460,13 +464,16 @@ export type OID4VCIMachine = {
|
|
|
460
464
|
}
|
|
461
465
|
|
|
462
466
|
export type StartResult = {
|
|
463
|
-
authorizationCodeURL?: string
|
|
464
467
|
credentialBranding?: Record<string, Array<IBasicCredentialLocaleBranding>>
|
|
465
468
|
credentialsSupported: Record<string, CredentialConfigurationSupported>
|
|
466
469
|
serverMetadata: EndpointMetadataResult
|
|
467
470
|
oid4vciClientState: OpenID4VCIClientState
|
|
468
471
|
}
|
|
469
472
|
|
|
473
|
+
export type PrepareAuthorizationResult = {
|
|
474
|
+
authorizationCodeURL?: string
|
|
475
|
+
}
|
|
476
|
+
|
|
470
477
|
export type SelectAppLocaleBrandingArgs = {
|
|
471
478
|
locale?: string
|
|
472
479
|
localeBranding?: Array<IBasicCredentialLocaleBranding | IBasicIssuerLocaleBranding>
|
|
@@ -507,7 +514,7 @@ export type CredentialToAccept = {
|
|
|
507
514
|
}
|
|
508
515
|
|
|
509
516
|
export type GetCredentialConfigsSupportedArgs = {
|
|
510
|
-
client:
|
|
517
|
+
client: OpenID4VCIClientV1_0_15
|
|
511
518
|
vcFormatPreferences: Array<string>
|
|
512
519
|
format?: Array<string>
|
|
513
520
|
types?: Array<Array<string>>
|
|
@@ -519,7 +526,7 @@ export type GetCredentialConfigsSupportedArgs = {
|
|
|
519
526
|
* It can potentially return multiple results mainly because of different formats.
|
|
520
527
|
*/
|
|
521
528
|
export type GetCredentialConfigsSupportedBySingleTypeOrIdArgs = {
|
|
522
|
-
client:
|
|
529
|
+
client: OpenID4VCIClientV1_0_15
|
|
523
530
|
vcFormatPreferences: Array<string>
|
|
524
531
|
format?: string[]
|
|
525
532
|
types?: string[]
|
|
@@ -554,7 +561,7 @@ export type GetDefaultIssuanceOptsArgs = {
|
|
|
554
561
|
}
|
|
555
562
|
|
|
556
563
|
export type DefaultIssuanceOpts = {
|
|
557
|
-
client:
|
|
564
|
+
client: OpenID4VCIClientV1_0_15
|
|
558
565
|
}
|
|
559
566
|
|
|
560
567
|
export type GetIdentifierArgs = {
|
|
@@ -591,7 +598,7 @@ export type CreateIdentifierCreateOpts = {
|
|
|
591
598
|
}
|
|
592
599
|
|
|
593
600
|
export type GetIssuanceOptsArgs = {
|
|
594
|
-
client:
|
|
601
|
+
client: OpenID4VCIClientV1_0_15
|
|
595
602
|
credentialsSupported: Record<string, CredentialConfigurationSupported>
|
|
596
603
|
serverMetadata: EndpointMetadataResult
|
|
597
604
|
context: RequiredContext
|
|
@@ -603,13 +610,13 @@ export type GetIssuanceOptsArgs = {
|
|
|
603
610
|
|
|
604
611
|
export type GetIssuanceDidMethodArgs = {
|
|
605
612
|
credentialSupported: CredentialConfigurationSupported
|
|
606
|
-
client:
|
|
613
|
+
client: OpenID4VCIClientV1_0_15
|
|
607
614
|
didMethodPreferences: Array<SupportedDidMethodEnum>
|
|
608
615
|
}
|
|
609
616
|
|
|
610
617
|
export type GetIssuanceCryptoSuiteArgs = {
|
|
611
618
|
credentialSupported: CredentialConfigurationSupported
|
|
612
|
-
client:
|
|
619
|
+
client: OpenID4VCIClientV1_0_15
|
|
613
620
|
jwtCryptographicSuitePreferences: Array<JoseSignatureAlgorithm | JoseSignatureAlgorithmString>
|
|
614
621
|
jsonldCryptographicSuitePreferences: Array<string>
|
|
615
622
|
}
|
|
@@ -617,7 +624,7 @@ export type GetIssuanceCryptoSuiteArgs = {
|
|
|
617
624
|
export type GetCredentialArgs = {
|
|
618
625
|
pin?: string
|
|
619
626
|
issuanceOpt: IssuanceOpts
|
|
620
|
-
client:
|
|
627
|
+
client: OpenID4VCIClientV1_0_15
|
|
621
628
|
accessTokenOpts?: AccessTokenOpts
|
|
622
629
|
}
|
|
623
630
|
|