@sphereon/ssi-sdk.oid4vci-holder 0.34.1-feature.SSISDK.65.redirect.fix.260 → 0.34.1-feature.SSISDK.70.integrate.digidentity.307

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sphereon/ssi-sdk.oid4vci-holder",
3
- "version": "0.34.1-feature.SSISDK.65.redirect.fix.260+6e576ccc",
3
+ "version": "0.34.1-feature.SSISDK.70.integrate.digidentity.307+d492f291",
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-feature.SSISDK.65.redirect.fix.194",
29
+ "@sphereon/did-auth-siop": "0.19.1-next.220",
30
30
  "@sphereon/kmp-mdoc-core": "0.2.0-SNAPSHOT.26",
31
- "@sphereon/oid4vci-client": "0.19.1-feature.SSISDK.65.redirect.fix.194",
32
- "@sphereon/oid4vci-common": "0.19.1-feature.SSISDK.65.redirect.fix.194",
33
- "@sphereon/ssi-sdk-ext.did-utils": "0.34.1-feature.SSISDK.65.redirect.fix.260+6e576ccc",
34
- "@sphereon/ssi-sdk-ext.identifier-resolution": "0.34.1-feature.SSISDK.65.redirect.fix.260+6e576ccc",
35
- "@sphereon/ssi-sdk-ext.jwt-service": "0.34.1-feature.SSISDK.65.redirect.fix.260+6e576ccc",
36
- "@sphereon/ssi-sdk-ext.key-utils": "0.34.1-feature.SSISDK.65.redirect.fix.260+6e576ccc",
37
- "@sphereon/ssi-sdk.contact-manager": "0.34.1-feature.SSISDK.65.redirect.fix.260+6e576ccc",
38
- "@sphereon/ssi-sdk.core": "0.34.1-feature.SSISDK.65.redirect.fix.260+6e576ccc",
39
- "@sphereon/ssi-sdk.credential-store": "0.34.1-feature.SSISDK.65.redirect.fix.260+6e576ccc",
40
- "@sphereon/ssi-sdk.credential-validation": "0.34.1-feature.SSISDK.65.redirect.fix.260+6e576ccc",
41
- "@sphereon/ssi-sdk.data-store-types": "0.34.1-feature.SSISDK.65.redirect.fix.260+6e576ccc",
42
- "@sphereon/ssi-sdk.issuance-branding": "0.34.1-feature.SSISDK.65.redirect.fix.260+6e576ccc",
43
- "@sphereon/ssi-sdk.mdl-mdoc": "0.34.1-feature.SSISDK.65.redirect.fix.260+6e576ccc",
44
- "@sphereon/ssi-sdk.oidf-client": "0.34.1-feature.SSISDK.65.redirect.fix.260+6e576ccc",
45
- "@sphereon/ssi-sdk.sd-jwt": "0.34.1-feature.SSISDK.65.redirect.fix.260+6e576ccc",
46
- "@sphereon/ssi-sdk.siopv2-oid4vp-common": "0.34.1-feature.SSISDK.65.redirect.fix.260+6e576ccc",
47
- "@sphereon/ssi-sdk.siopv2-oid4vp-op-auth": "0.34.1-feature.SSISDK.65.redirect.fix.260+6e576ccc",
48
- "@sphereon/ssi-sdk.xstate-machine-persistence": "0.34.1-feature.SSISDK.65.redirect.fix.260+6e576ccc",
49
- "@sphereon/ssi-types": "0.34.1-feature.SSISDK.65.redirect.fix.260+6e576ccc",
31
+ "@sphereon/oid4vci-client": "0.19.1-next.220",
32
+ "@sphereon/oid4vci-common": "0.19.1-next.220",
33
+ "@sphereon/ssi-sdk-ext.did-utils": "0.34.1-feature.SSISDK.70.integrate.digidentity.307+d492f291",
34
+ "@sphereon/ssi-sdk-ext.identifier-resolution": "0.34.1-feature.SSISDK.70.integrate.digidentity.307+d492f291",
35
+ "@sphereon/ssi-sdk-ext.jwt-service": "0.34.1-feature.SSISDK.70.integrate.digidentity.307+d492f291",
36
+ "@sphereon/ssi-sdk-ext.key-utils": "0.34.1-feature.SSISDK.70.integrate.digidentity.307+d492f291",
37
+ "@sphereon/ssi-sdk.contact-manager": "0.34.1-feature.SSISDK.70.integrate.digidentity.307+d492f291",
38
+ "@sphereon/ssi-sdk.core": "0.34.1-feature.SSISDK.70.integrate.digidentity.307+d492f291",
39
+ "@sphereon/ssi-sdk.credential-store": "0.34.1-feature.SSISDK.70.integrate.digidentity.307+d492f291",
40
+ "@sphereon/ssi-sdk.credential-validation": "0.34.1-feature.SSISDK.70.integrate.digidentity.307+d492f291",
41
+ "@sphereon/ssi-sdk.data-store-types": "0.34.1-feature.SSISDK.70.integrate.digidentity.307+d492f291",
42
+ "@sphereon/ssi-sdk.issuance-branding": "0.34.1-feature.SSISDK.70.integrate.digidentity.307+d492f291",
43
+ "@sphereon/ssi-sdk.mdl-mdoc": "0.34.1-feature.SSISDK.70.integrate.digidentity.307+d492f291",
44
+ "@sphereon/ssi-sdk.oidf-client": "0.34.1-feature.SSISDK.70.integrate.digidentity.307+d492f291",
45
+ "@sphereon/ssi-sdk.sd-jwt": "0.34.1-feature.SSISDK.70.integrate.digidentity.307+d492f291",
46
+ "@sphereon/ssi-sdk.siopv2-oid4vp-common": "0.34.1-feature.SSISDK.70.integrate.digidentity.307+d492f291",
47
+ "@sphereon/ssi-sdk.siopv2-oid4vp-op-auth": "0.34.1-feature.SSISDK.70.integrate.digidentity.307+d492f291",
48
+ "@sphereon/ssi-sdk.xstate-machine-persistence": "0.34.1-feature.SSISDK.70.integrate.digidentity.307+d492f291",
49
+ "@sphereon/ssi-types": "0.34.1-feature.SSISDK.70.integrate.digidentity.307+d492f291",
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-feature.SSISDK.65.redirect.fix.194",
63
- "@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.34.1-feature.SSISDK.65.redirect.fix.260+6e576ccc",
62
+ "@sphereon/oid4vc-common": "0.19.1-next.220",
63
+ "@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.34.1-feature.SSISDK.70.integrate.digidentity.307+d492f291",
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": "6e576ccc1d43004dbedfd8c958193a0ff5884fae"
93
+ "gitHead": "d492f291b97aeb09842fb97268a3ee196b41a99f"
94
94
  }
@@ -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),
@@ -426,7 +431,7 @@ export class OID4VCIHolder implements IAgentPlugin {
426
431
  credentialIssuer: uri,
427
432
  authorizationRequest: authorizationRequestOpts,
428
433
  clientId: authorizationRequestOpts.clientId,
429
- createAuthorizationRequestURL: requestData.createAuthorizationRequestURL ?? true,
434
+ createAuthorizationRequestURL: false, // requestData.createAuthorizationRequestURL ?? true,
430
435
  })
431
436
  } else {
432
437
  logger.log(`Credential offer received: ${uri}`)
@@ -434,7 +439,7 @@ export class OID4VCIHolder implements IAgentPlugin {
434
439
  uri,
435
440
  authorizationRequest: authorizationRequestOpts,
436
441
  clientId: authorizationRequestOpts.clientId,
437
- createAuthorizationRequestURL: requestData.createAuthorizationRequestURL ?? true,
442
+ createAuthorizationRequestURL: false, // requestData.createAuthorizationRequestURL ?? true,
438
443
  })
439
444
  }
440
445
  }
@@ -457,14 +462,9 @@ export class OID4VCIHolder implements IAgentPlugin {
457
462
 
458
463
  const serverMetadata = await oid4vciClient.retrieveServerMetadata()
459
464
  const credentialBranding = await getCredentialBranding({ credentialsSupported, context })
460
- const authorizationCodeURL = oid4vciClient.authorizationURL
461
- if (authorizationCodeURL) {
462
- logger.log(`authorization code URL ${authorizationCodeURL}`)
463
- }
464
465
  const oid4vciClientState = JSON.parse(await oid4vciClient.exportState())
465
466
 
466
467
  return {
467
- authorizationCodeURL,
468
468
  credentialBranding,
469
469
  credentialsSupported,
470
470
  serverMetadata,
@@ -472,6 +472,42 @@ export class OID4VCIHolder implements IAgentPlugin {
472
472
  }
473
473
  }
474
474
 
475
+ private async oid4vciHolderPrepareAuthorizationRequest(
476
+ args: PrepareAuthorizationRequestArgs,
477
+ context: RequiredContext,
478
+ ): Promise<PrepareAuthorizationResult> {
479
+ const { openID4VCIClientState, contact } = args
480
+ if (!openID4VCIClientState) {
481
+ return Promise.reject(Error('Missing openID4VCI client state in context'))
482
+ }
483
+
484
+ const clientId = contact?.identities
485
+ .map((identity) => {
486
+ const connectionConfig = identity.connection?.config
487
+ if (connectionConfig && 'clientId' in connectionConfig) {
488
+ return connectionConfig.clientId
489
+ }
490
+ return undefined
491
+ })
492
+ .find((clientId) => clientId)
493
+
494
+ if (!clientId) {
495
+ return Promise.reject(Error(`Missing client id in contact's connectionConfig`))
496
+ }
497
+ const client = await OpenID4VCIClient.fromState({ state: openID4VCIClientState })
498
+ const authorizationCodeURL = await client.createAuthorizationRequestUrl({
499
+ authorizationRequest: {
500
+ clientId: clientId,
501
+ } satisfies AuthorizationRequestOpts,
502
+ })
503
+ if (authorizationCodeURL) {
504
+ logger.log(`authorization code URL ${authorizationCodeURL}`)
505
+ }
506
+ return {
507
+ authorizationCodeURL,
508
+ }
509
+ }
510
+
475
511
  private async oid4vciHolderCreateCredentialsToSelectFrom(
476
512
  args: CreateCredentialsToSelectFromArgs,
477
513
  context: RequiredContext,
@@ -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 (!openID4VCIClientState.authorizationURL) {
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.initiateAuthorizationRequest,
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 = await sdJwtDecodedCredentialToUniformCredential(
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')
@@ -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>