@sphereon/ssi-sdk.oid4vci-holder 0.36.1-next.11 → 0.36.1-next.115

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.36.1-next.11+262d209a",
3
+ "version": "0.36.1-next.115+0fab323a",
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.20.1-next.3",
29
+ "@sphereon/did-auth-siop": "0.20.1-next.8",
30
30
  "@sphereon/kmp-mdoc-core": "0.2.0-SNAPSHOT.26",
31
- "@sphereon/oid4vci-client": "0.20.1-next.3",
32
- "@sphereon/oid4vci-common": "0.20.1-next.3",
33
- "@sphereon/ssi-sdk-ext.did-utils": "0.36.1-next.11+262d209a",
34
- "@sphereon/ssi-sdk-ext.identifier-resolution": "0.36.1-next.11+262d209a",
35
- "@sphereon/ssi-sdk-ext.jwt-service": "0.36.1-next.11+262d209a",
36
- "@sphereon/ssi-sdk-ext.key-utils": "0.36.1-next.11+262d209a",
37
- "@sphereon/ssi-sdk.contact-manager": "0.36.1-next.11+262d209a",
38
- "@sphereon/ssi-sdk.core": "0.36.1-next.11+262d209a",
39
- "@sphereon/ssi-sdk.credential-store": "0.36.1-next.11+262d209a",
40
- "@sphereon/ssi-sdk.credential-validation": "0.36.1-next.11+262d209a",
41
- "@sphereon/ssi-sdk.data-store-types": "0.36.1-next.11+262d209a",
42
- "@sphereon/ssi-sdk.issuance-branding": "0.36.1-next.11+262d209a",
43
- "@sphereon/ssi-sdk.mdl-mdoc": "0.36.1-next.11+262d209a",
44
- "@sphereon/ssi-sdk.oidf-client": "0.36.1-next.11+262d209a",
45
- "@sphereon/ssi-sdk.sd-jwt": "0.36.1-next.11+262d209a",
46
- "@sphereon/ssi-sdk.siopv2-oid4vp-common": "0.36.1-next.11+262d209a",
47
- "@sphereon/ssi-sdk.siopv2-oid4vp-op-auth": "0.36.1-next.11+262d209a",
48
- "@sphereon/ssi-sdk.xstate-machine-persistence": "0.36.1-next.11+262d209a",
49
- "@sphereon/ssi-types": "0.36.1-next.11+262d209a",
31
+ "@sphereon/oid4vci-client": "0.20.1-next.8",
32
+ "@sphereon/oid4vci-common": "0.20.1-next.8",
33
+ "@sphereon/ssi-sdk-ext.did-utils": "0.36.1-next.115+0fab323a",
34
+ "@sphereon/ssi-sdk-ext.identifier-resolution": "0.36.1-next.115+0fab323a",
35
+ "@sphereon/ssi-sdk-ext.jwt-service": "0.36.1-next.115+0fab323a",
36
+ "@sphereon/ssi-sdk-ext.key-utils": "0.36.1-next.115+0fab323a",
37
+ "@sphereon/ssi-sdk.contact-manager": "0.36.1-next.115+0fab323a",
38
+ "@sphereon/ssi-sdk.core": "0.36.1-next.115+0fab323a",
39
+ "@sphereon/ssi-sdk.credential-store": "0.36.1-next.115+0fab323a",
40
+ "@sphereon/ssi-sdk.credential-validation": "0.36.1-next.115+0fab323a",
41
+ "@sphereon/ssi-sdk.data-store-types": "0.36.1-next.115+0fab323a",
42
+ "@sphereon/ssi-sdk.issuance-branding": "0.36.1-next.115+0fab323a",
43
+ "@sphereon/ssi-sdk.mdl-mdoc": "0.36.1-next.115+0fab323a",
44
+ "@sphereon/ssi-sdk.oidf-client": "0.36.1-next.115+0fab323a",
45
+ "@sphereon/ssi-sdk.sd-jwt": "0.36.1-next.115+0fab323a",
46
+ "@sphereon/ssi-sdk.siopv2-oid4vp-common": "0.36.1-next.115+0fab323a",
47
+ "@sphereon/ssi-sdk.siopv2-oid4vp-op-auth": "0.36.1-next.115+0fab323a",
48
+ "@sphereon/ssi-sdk.xstate-machine-persistence": "0.36.1-next.115+0fab323a",
49
+ "@sphereon/ssi-types": "0.36.1-next.115+0fab323a",
50
50
  "@veramo/core": "4.2.0",
51
51
  "@veramo/data-store": "4.2.0",
52
52
  "@veramo/utils": "4.2.0",
@@ -60,7 +60,7 @@
60
60
  },
61
61
  "devDependencies": {
62
62
  "@sphereon/oid4vc-common": "0.20.1-feat.SSISDK.83.1",
63
- "@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.36.1-next.11+262d209a",
63
+ "@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.36.1-next.115+0fab323a",
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": "262d209a803fecfba1ad5878724c4f6f91f86cec"
93
+ "gitHead": "0fab323abf92edba332557800ab79493e3681e1f"
94
94
  }
@@ -123,6 +123,7 @@ import {
123
123
  VerificationResult,
124
124
  VerifyEBSICredentialIssuerArgs,
125
125
  VerifyEBSICredentialIssuerResult,
126
+ WalletType,
126
127
  } from '../types/IOID4VCIHolder'
127
128
 
128
129
  /**
@@ -206,6 +207,7 @@ export async function verifyEBSICredentialIssuer(args: VerifyEBSICredentialIssue
206
207
 
207
208
  export class OID4VCIHolder implements IAgentPlugin {
208
209
  private readonly hasher?: HasherSync
210
+ private readonly defaultHolderIdentifier?: string
209
211
  readonly eventTypes: Array<OID4VCIHolderEvent> = [
210
212
  OID4VCIHolderEvent.CONTACT_IDENTITY_CREATED,
211
213
  OID4VCIHolderEvent.CREDENTIAL_STORED,
@@ -269,9 +271,11 @@ export class OID4VCIHolder implements IAgentPlugin {
269
271
  jwtCryptographicSuitePreferences,
270
272
  defaultAuthorizationRequestOptions,
271
273
  hasher = defaultHasher,
274
+ defaultHolderIdentifier,
272
275
  } = { ...options }
273
276
 
274
277
  this.hasher = hasher
278
+ this.defaultHolderIdentifier = defaultHolderIdentifier
275
279
  if (vcFormatPreferences !== undefined && vcFormatPreferences.length > 0) {
276
280
  this.vcFormatPreferences = vcFormatPreferences
277
281
  }
@@ -493,7 +497,7 @@ export class OID4VCIHolder implements IAgentPlugin {
493
497
  if (!clientId) {
494
498
  return Promise.reject(Error(`Missing client id in contact's connectionConfig`))
495
499
  }
496
- const client = await OpenID4VCIClient.fromState({ state: openID4VCIClientState })
500
+ const client = await OpenID4VCIClientV1_0_15.fromState({ state: openID4VCIClientState })
497
501
  const authorizationCodeURL = await client.createAuthorizationRequestUrl({
498
502
  authorizationRequest: {
499
503
  clientId: clientId,
@@ -505,7 +509,7 @@ export class OID4VCIHolder implements IAgentPlugin {
505
509
  return {
506
510
  authorizationCodeURL,
507
511
  // Needed, because the above createAuthorizationRequestUrl manipulates the state, adding pkce opts to the state
508
- oid4vciClientState: JSON.parse(await client.exportState())
512
+ oid4vciClientState: JSON.parse(await client.exportState()),
509
513
  }
510
514
  }
511
515
 
@@ -617,7 +621,7 @@ export class OID4VCIHolder implements IAgentPlugin {
617
621
  }
618
622
 
619
623
  private async oid4vciHolderGetCredentials(args: GetCredentialsArgs, context: RequiredContext): Promise<Array<MappedCredentialToAccept>> {
620
- const { verificationCode, openID4VCIClientState, didMethodPreferences = this.didMethodPreferences, issuanceOpt, accessTokenOpts } = args
624
+ const { verificationCode, openID4VCIClientState, didMethodPreferences, issuanceOpt, accessTokenOpts, walletType } = args
621
625
  logger.debug(`Getting credentials`, issuanceOpt, accessTokenOpts)
622
626
 
623
627
  if (!openID4VCIClientState) {
@@ -636,7 +640,7 @@ export class OID4VCIHolder implements IAgentPlugin {
636
640
  credentialsSupported,
637
641
  serverMetadata,
638
642
  context,
639
- didMethodPreferences: Array.isArray(didMethodPreferences) && didMethodPreferences.length > 0 ? didMethodPreferences : this.didMethodPreferences,
643
+ didMethodPreferences: this.selectDidMethodPreferences(didMethodPreferences, walletType),
640
644
  jwtCryptographicSuitePreferences: this.jwtCryptographicSuitePreferences,
641
645
  jsonldCryptographicSuitePreferences: this.jsonldCryptographicSuitePreferences,
642
646
  ...(issuanceOpt && { forceIssuanceOpt: issuanceOpt }),
@@ -661,6 +665,15 @@ export class OID4VCIHolder implements IAgentPlugin {
661
665
  return allCredentials
662
666
  }
663
667
 
668
+ private selectDidMethodPreferences(didMethodPreferences: Array<SupportedDidMethodEnum> | undefined, walletType: WalletType) {
669
+ const supportedDidMethodEnums =
670
+ Array.isArray(didMethodPreferences) && didMethodPreferences.length > 0 ? didMethodPreferences : this.didMethodPreferences
671
+ if (walletType === 'ORGANIZATIONAL') {
672
+ return [SupportedDidMethodEnum.DID_WEB, ...supportedDidMethodEnums]
673
+ }
674
+ return supportedDidMethodEnums
675
+ }
676
+
664
677
  private async oid4vciHolderGetCredential(args: GetCredentialArgs, context: RequiredContext): Promise<MappedCredentialToAccept> {
665
678
  const { issuanceOpt, pin, client, accessTokenOpts } = args
666
679
  logger.info(`Getting credential`, issuanceOpt)
@@ -669,7 +682,7 @@ export class OID4VCIHolder implements IAgentPlugin {
669
682
  return Promise.reject(Error(`Cannot get credential issuance options`))
670
683
  }
671
684
 
672
- const identifier = await getIdentifierOpts({ issuanceOpt, context })
685
+ const identifier = await getIdentifierOpts({ issuanceOpt, context, defaultHolderIdentifier: this.defaultHolderIdentifier })
673
686
  issuanceOpt.identifier = identifier
674
687
  logger.info(`ID opts`, identifier)
675
688
  const alg: JoseSignatureAlgorithm | JoseSignatureAlgorithmString = await signatureAlgorithmFromKey({ key: identifier.key })
@@ -731,6 +744,7 @@ export class OID4VCIHolder implements IAgentPlugin {
731
744
  format: issuanceOpt.format,
732
745
  // TODO: We need to update the machine and add notifications support for actual deferred credentials instead of just waiting/retrying
733
746
  deferredCredentialAwait: true,
747
+ ...(issuanceOpt.id && typeof issuanceOpt.id === 'string' ? { credentialConfigurationId: issuanceOpt.id } : undefined),
734
748
  ...(!jwk && { kid }), // vci client either wants a jwk or kid. If we have used the jwk method do not provide the kid
735
749
  jwk,
736
750
  alg,
@@ -3,7 +3,7 @@ import { AuthorizationRequestOpts, AuthorizationServerClientOpts, AuthzFlowType,
3
3
  import { DefaultLinkPriorities, LinkHandlerAdapter } from '@sphereon/ssi-sdk.core'
4
4
  import { IMachineStatePersistence, interpreterStartOrResume, SerializableState } from '@sphereon/ssi-sdk.xstate-machine-persistence'
5
5
  import { IAgentContext } from '@veramo/core'
6
- import { GetMachineArgs, IOID4VCIHolder, OID4VCIMachineEvents, OID4VCIMachineStateNavigationListener } from '../types/IOID4VCIHolder'
6
+ import { GetMachineArgs, IOID4VCIHolder, OID4VCIMachineEvents, OID4VCIMachineStateNavigationListener, WalletType } from '../types/IOID4VCIHolder'
7
7
  import { FirstPartyMachineStateNavigationListener } from '../types/FirstPartyMachine'
8
8
 
9
9
  /**
@@ -14,6 +14,7 @@ export class OID4VCIHolderLinkHandler extends LinkHandlerAdapter {
14
14
  private readonly stateNavigationListener?: OID4VCIMachineStateNavigationListener
15
15
  private readonly firstPartyStateNavigationListener?: FirstPartyMachineStateNavigationListener
16
16
  private readonly noStateMachinePersistence: boolean
17
+ private readonly walletType: WalletType
17
18
  private readonly authorizationRequestOpts?: AuthorizationRequestOpts
18
19
  private readonly clientOpts?: AuthorizationServerClientOpts
19
20
  private readonly trustAnchors?: Array<string>
@@ -21,7 +22,7 @@ export class OID4VCIHolderLinkHandler extends LinkHandlerAdapter {
21
22
  constructor(
22
23
  args: Pick<
23
24
  GetMachineArgs,
24
- 'stateNavigationListener' | 'authorizationRequestOpts' | 'clientOpts' | 'trustAnchors' | 'firstPartyStateNavigationListener'
25
+ 'stateNavigationListener' | 'authorizationRequestOpts' | 'clientOpts' | 'trustAnchors' | 'firstPartyStateNavigationListener' | 'walletType'
25
26
  > & {
26
27
  priority?: number | DefaultLinkPriorities
27
28
  protocols?: Array<string | RegExp>
@@ -33,6 +34,7 @@ export class OID4VCIHolderLinkHandler extends LinkHandlerAdapter {
33
34
  this.authorizationRequestOpts = args.authorizationRequestOpts
34
35
  this.clientOpts = args.clientOpts
35
36
  this.context = args.context
37
+ this.walletType = args.walletType ?? 'NATURAL_PERSON'
36
38
  this.noStateMachinePersistence = args.noStateMachinePersistence === true
37
39
  this.stateNavigationListener = args.stateNavigationListener
38
40
  this.firstPartyStateNavigationListener = args.firstPartyStateNavigationListener
@@ -68,6 +70,7 @@ export class OID4VCIHolderLinkHandler extends LinkHandlerAdapter {
68
70
  ...((clientOpts.clientId || clientOpts.clientAssertionType) && { clientOpts: clientOpts as AuthorizationServerClientOpts }),
69
71
  stateNavigationListener: this.stateNavigationListener,
70
72
  firstPartyStateNavigationListener: this.firstPartyStateNavigationListener,
73
+ walletType: this.walletType,
71
74
  })
72
75
 
73
76
  const interpreter = oid4vciMachine.interpreter
@@ -126,6 +126,7 @@ const createOID4VCIMachine = (opts?: CreateOID4VCIMachineOpts): OID4VCIStateMach
126
126
  // TODO WAL-671 we need to store the data from OpenIdProvider here in the context and make sure we can restart the machine with it and init the OpenIdProvider
127
127
  accessTokenOpts: opts?.accessTokenOpts,
128
128
  requestData: opts?.requestData,
129
+ walletType: opts?.walletType ?? 'NATURAL_PERSON',
129
130
  trustAnchors: opts?.trustAnchors ?? [],
130
131
  issuanceOpt: opts?.issuanceOpt,
131
132
  didMethodPreferences: opts?.didMethodPreferences,
@@ -347,7 +348,7 @@ const createOID4VCIMachine = (opts?: CreateOID4VCIMachineOpts): OID4VCIStateMach
347
348
  cond: OID4VCIMachineGuards.isFirstPartyApplication,
348
349
  },
349
350
  {
350
- target: OID4VCIMachineStates.initiateAuthorizationRequest,
351
+ target: OID4VCIMachineStates.prepareAuthorizationRequest,
351
352
  cond: OID4VCIMachineGuards.requireAuthorizationGuard,
352
353
  },
353
354
  {
@@ -444,10 +445,6 @@ const createOID4VCIMachine = (opts?: CreateOID4VCIMachineOpts): OID4VCIStateMach
444
445
  target: OID4VCIMachineStates.prepareAuthorizationRequest,
445
446
  cond: OID4VCIMachineGuards.requireAuthorizationGuard,
446
447
  },
447
- {
448
- target: OID4VCIMachineStates.initiateAuthorizationRequest,
449
- cond: OID4VCIMachineGuards.requireAuthorizationGuard,
450
- },
451
448
  {
452
449
  target: OID4VCIMachineStates.verifyPin,
453
450
  cond: OID4VCIMachineGuards.requirePinGuard,
@@ -524,10 +521,6 @@ const createOID4VCIMachine = (opts?: CreateOID4VCIMachineOpts): OID4VCIStateMach
524
521
  target: OID4VCIMachineStates.verifyPin,
525
522
  cond: OID4VCIMachineGuards.requirePinGuard,
526
523
  },
527
- {
528
- target: OID4VCIMachineStates.prepareAuthorizationRequest,
529
- cond: OID4VCIMachineGuards.requireAuthorizationGuard,
530
- },
531
524
  {
532
525
  target: OID4VCIMachineStates.getCredentials,
533
526
  },
@@ -214,7 +214,7 @@ export const mapCredentialToAccept = async (args: MapCredentialToAcceptArgs): Pr
214
214
  if (!hasher) {
215
215
  return Promise.reject('a hasher is required for encoded SD-JWT credentials')
216
216
  }
217
- const asyncHasher: Hasher = (data: string | ArrayBuffer, algorithm: string) => Promise.resolve(hasher(data, algorithm))
217
+ const asyncHasher: Hasher = (data: string | ArrayBuffer | SharedArrayBuffer, algorithm: string) => Promise.resolve(hasher(data, algorithm))
218
218
  const decodedSdJwt = await CredentialMapper.decodeSdJwtVcAsync(wrappedVerifiableCredential.credential, asyncHasher)
219
219
  uniformVerifiableCredential = sdJwtDecodedCredentialToUniformCredential(<SdJwtDecodedVerifiableCredential>decodedSdJwt)
220
220
  } else if (CredentialMapper.isMsoMdocDecodedCredential(wrappedVerifiableCredential.credential)) {
@@ -263,7 +263,7 @@ export const extractCredentialFromResponse = (credentialResponse: CredentialResp
263
263
  }
264
264
 
265
265
  export const getIdentifierOpts = async (args: GetIdentifierArgs): Promise<ManagedIdentifierResult> => {
266
- const { issuanceOpt, context } = args
266
+ const { issuanceOpt, context, defaultHolderIdentifier } = args
267
267
  const { identifier: identifierArg } = issuanceOpt
268
268
  if (identifierArg && isManagedIdentifierResult(identifierArg)) {
269
269
  return identifierArg
@@ -295,6 +295,11 @@ export const getIdentifierOpts = async (args: GetIdentifierArgs): Promise<Manage
295
295
  (!supportedBindingMethods || supportedBindingMethods.length === 0 || supportedBindingMethods.filter((method) => method.startsWith('did')))
296
296
  ) {
297
297
  // previous code for managing DIDs only
298
+ const identifierFilter = defaultHolderIdentifier
299
+ ? defaultHolderIdentifier.startsWith('did:')
300
+ ? { did: defaultHolderIdentifier }
301
+ : { alias: defaultHolderIdentifier }
302
+ : {}
298
303
  const { result, created } = await getOrCreatePrimaryIdentifier(agentContext, {
299
304
  method: supportedPreferredDidMethod,
300
305
  createOpts: {
@@ -303,6 +308,7 @@ export const getIdentifierOpts = async (args: GetIdentifierArgs): Promise<Manage
303
308
  use: KeyUse.Signature,
304
309
  codecName: issuanceOpt.codecName,
305
310
  kms: issuanceOpt.kms,
311
+ ...identifierFilter,
306
312
  },
307
313
  },
308
314
  })
@@ -113,6 +113,7 @@ export type OID4VCIHolderOptions = {
113
113
  didMethodPreferences?: Array<SupportedDidMethodEnum>
114
114
  jwtCryptographicSuitePreferences?: Array<JoseSignatureAlgorithm | JoseSignatureAlgorithmString>
115
115
  hasher?: HasherSync
116
+ defaultHolderIdentifier?: string
116
117
  }
117
118
 
118
119
  export type OnContactIdentityCreatedArgs = {
@@ -136,6 +137,7 @@ export type OnIdentifierCreatedArgs = {
136
137
 
137
138
  export type GetMachineArgs = {
138
139
  requestData: RequestData
140
+ walletType: WalletType
139
141
  trustAnchors?: Array<string>
140
142
  authorizationRequestOpts?: AuthorizationRequestOpts
141
143
  clientOpts?: AuthorizationServerClientOpts
@@ -157,7 +159,7 @@ export type CreateCredentialsToSelectFromArgs = Pick<
157
159
  export type GetContactArgs = Pick<OID4VCIMachineContext, 'serverMetadata'>
158
160
  export type GetCredentialsArgs = Pick<
159
161
  OID4VCIMachineContext,
160
- 'verificationCode' | 'openID4VCIClientState' | 'selectedCredentials' | 'didMethodPreferences' | 'issuanceOpt' | 'accessTokenOpts'
162
+ 'verificationCode' | 'openID4VCIClientState' | 'selectedCredentials' | 'didMethodPreferences' | 'issuanceOpt' | 'accessTokenOpts' | 'walletType'
161
163
  >
162
164
  export type AddContactIdentityArgs = Pick<OID4VCIMachineContext, 'credentialsToAccept' | 'contact'>
163
165
  export type GetIssuerBrandingArgs = Pick<OID4VCIMachineContext, 'serverMetadata' | 'contact'>
@@ -233,6 +235,7 @@ export type OID4VCIMachineContext = {
233
235
  openID4VCIClientState?: OpenID4VCIClientState
234
236
  credentialToSelectFrom: Array<CredentialToSelectFromResult>
235
237
  contactAlias: string
238
+ walletType: WalletType
236
239
  contact?: Party
237
240
  selectedCredentials: Array<string>
238
241
  credentialsToAccept: Array<MappedCredentialToAccept>
@@ -316,6 +319,7 @@ export type OID4VCIStateMachine = StateMachine<
316
319
 
317
320
  export type CreateOID4VCIMachineOpts = {
318
321
  requestData: RequestData
322
+ walletType: WalletType
319
323
  machineName?: string
320
324
  locale?: string
321
325
  trustAnchors?: Array<string>
@@ -568,6 +572,7 @@ export type DefaultIssuanceOpts = {
568
572
  export type GetIdentifierArgs = {
569
573
  issuanceOpt: IssuanceOpts
570
574
  context: RequiredContext
575
+ defaultHolderIdentifier?: string
571
576
  }
572
577
 
573
578
  export type GetAuthenticationKeyArgs = {
@@ -729,6 +734,8 @@ export type DynamicRegistrationClientMetadataDisplay = Pick<
729
734
  'client_name' | 'client_uri' | 'contacts' | 'tos_uri' | 'policy_uri' | 'logo_uri'
730
735
  >
731
736
 
737
+ export type WalletType = 'NATURAL_PERSON' | 'ORGANIZATIONAL'
738
+
732
739
  export type DidAgents = TAgent<IResolver & IDIDManager>
733
740
 
734
741
  export type RequiredContext = IAgentContext<