@sphereon/ssi-sdk.oid4vci-holder 0.32.1-next.54 → 0.33.1-feature.jose.vcdm.55

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.
Files changed (64) hide show
  1. package/dist/index.cjs +3143 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +786 -0
  4. package/dist/index.d.ts +784 -9
  5. package/dist/index.js +3112 -30
  6. package/dist/index.js.map +1 -1
  7. package/package.json +45 -33
  8. package/src/agent/OID4VCIHolder.ts +42 -16
  9. package/src/index.ts +1 -0
  10. package/src/link-handler/index.ts +6 -8
  11. package/src/machines/firstPartyMachine.ts +60 -69
  12. package/src/machines/oid4vciMachine.ts +9 -11
  13. package/src/mappers/OIDC4VCIBrandingMapper.ts +26 -25
  14. package/src/services/FirstPartyMachineServices.ts +11 -10
  15. package/src/services/OID4VCIHolderService.ts +25 -24
  16. package/src/types/FirstPartyMachine.ts +56 -64
  17. package/src/types/IOID4VCIHolder.ts +35 -32
  18. package/dist/agent/OID4VCIHolder.d.ts +0 -58
  19. package/dist/agent/OID4VCIHolder.d.ts.map +0 -1
  20. package/dist/agent/OID4VCIHolder.js +0 -870
  21. package/dist/agent/OID4VCIHolder.js.map +0 -1
  22. package/dist/index.d.ts.map +0 -1
  23. package/dist/link-handler/index.d.ts +0 -31
  24. package/dist/link-handler/index.d.ts.map +0 -1
  25. package/dist/link-handler/index.js +0 -65
  26. package/dist/link-handler/index.js.map +0 -1
  27. package/dist/listeners/headlessStateNavListener.d.ts +0 -3
  28. package/dist/listeners/headlessStateNavListener.d.ts.map +0 -1
  29. package/dist/listeners/headlessStateNavListener.js +0 -45
  30. package/dist/listeners/headlessStateNavListener.js.map +0 -1
  31. package/dist/localization/Localization.d.ts +0 -9
  32. package/dist/localization/Localization.d.ts.map +0 -1
  33. package/dist/localization/Localization.js +0 -46
  34. package/dist/localization/Localization.js.map +0 -1
  35. package/dist/localization/translations/en.json +0 -19
  36. package/dist/localization/translations/nl.json +0 -18
  37. package/dist/machines/firstPartyMachine.d.ts +0 -15
  38. package/dist/machines/firstPartyMachine.d.ts.map +0 -1
  39. package/dist/machines/firstPartyMachine.js +0 -222
  40. package/dist/machines/firstPartyMachine.js.map +0 -1
  41. package/dist/machines/oid4vciMachine.d.ts +0 -7
  42. package/dist/machines/oid4vciMachine.d.ts.map +0 -1
  43. package/dist/machines/oid4vciMachine.js +0 -727
  44. package/dist/machines/oid4vciMachine.js.map +0 -1
  45. package/dist/mappers/OIDC4VCIBrandingMapper.d.ts +0 -16
  46. package/dist/mappers/OIDC4VCIBrandingMapper.d.ts.map +0 -1
  47. package/dist/mappers/OIDC4VCIBrandingMapper.js +0 -201
  48. package/dist/mappers/OIDC4VCIBrandingMapper.js.map +0 -1
  49. package/dist/services/FirstPartyMachineServices.d.ts +0 -9
  50. package/dist/services/FirstPartyMachineServices.d.ts.map +0 -1
  51. package/dist/services/FirstPartyMachineServices.js +0 -52
  52. package/dist/services/FirstPartyMachineServices.js.map +0 -1
  53. package/dist/services/OID4VCIHolderService.d.ts +0 -28
  54. package/dist/services/OID4VCIHolderService.d.ts.map +0 -1
  55. package/dist/services/OID4VCIHolderService.js +0 -523
  56. package/dist/services/OID4VCIHolderService.js.map +0 -1
  57. package/dist/types/FirstPartyMachine.d.ts +0 -112
  58. package/dist/types/FirstPartyMachine.d.ts.map +0 -1
  59. package/dist/types/FirstPartyMachine.js +0 -30
  60. package/dist/types/FirstPartyMachine.js.map +0 -1
  61. package/dist/types/IOID4VCIHolder.d.ts +0 -558
  62. package/dist/types/IOID4VCIHolder.d.ts.map +0 -1
  63. package/dist/types/IOID4VCIHolder.js +0 -114
  64. package/dist/types/IOID4VCIHolder.js.map +0 -1
@@ -1,15 +1,6 @@
1
1
  import { CredentialsSupportedDisplay, NameAndLocale } from '@sphereon/oid4vci-common'
2
- import {
3
- IBasicCredentialClaim,
4
- IBasicCredentialLocaleBranding,
5
- IBasicIssuerLocaleBranding
6
- } from '@sphereon/ssi-sdk.data-store'
7
- import {
8
- SdJwtClaimDisplayMetadata,
9
- SdJwtClaimMetadata,
10
- SdJwtClaimPath,
11
- SdJwtTypeDisplayMetadata
12
- } from '@sphereon/ssi-types'
2
+ import { IBasicCredentialClaim, IBasicCredentialLocaleBranding, IBasicIssuerLocaleBranding } from '@sphereon/ssi-sdk.data-store'
3
+ import { SdJwtClaimDisplayMetadata, SdJwtClaimMetadata, SdJwtClaimPath, SdJwtTypeDisplayMetadata } from '@sphereon/ssi-types'
13
4
  import {
14
5
  IssuerLocaleBrandingFromArgs,
15
6
  Oid4vciCombineDisplayLocalesFromArgs,
@@ -26,7 +17,9 @@ import {
26
17
 
27
18
  // FIXME should we not move this to the branding plugin?
28
19
 
29
- export const oid4vciGetCredentialBrandingFrom = async (args: Oid4vciGetCredentialBrandingFromArgs): Promise<Array<IBasicCredentialLocaleBranding>> => {
20
+ export const oid4vciGetCredentialBrandingFrom = async (
21
+ args: Oid4vciGetCredentialBrandingFromArgs,
22
+ ): Promise<Array<IBasicCredentialLocaleBranding>> => {
30
23
  const { credentialDisplay, issuerCredentialSubject } = args
31
24
 
32
25
  return oid4vciCombineDisplayLocalesFrom({
@@ -35,7 +28,9 @@ export const oid4vciGetCredentialBrandingFrom = async (args: Oid4vciGetCredentia
35
28
  })
36
29
  }
37
30
 
38
- export const oid4vciCredentialDisplayLocalesFrom = async (args: Oid4vciCredentialDisplayLocalesFromArgs): Promise<Map<string, CredentialsSupportedDisplay>> => {
31
+ export const oid4vciCredentialDisplayLocalesFrom = async (
32
+ args: Oid4vciCredentialDisplayLocalesFromArgs,
33
+ ): Promise<Map<string, CredentialsSupportedDisplay>> => {
39
34
  const { credentialDisplay } = args
40
35
  return credentialDisplay.reduce((localeDisplays, display) => {
41
36
  const localeKey = display.locale || ''
@@ -44,7 +39,9 @@ export const oid4vciCredentialDisplayLocalesFrom = async (args: Oid4vciCredentia
44
39
  }, new Map<string, CredentialsSupportedDisplay>())
45
40
  }
46
41
 
47
- export const oid4vciIssuerCredentialSubjectLocalesFrom = async (args: Oid4vciIssuerCredentialSubjectLocalesFromArgs): Promise<Map<string, Array<IBasicCredentialClaim>>> => {
42
+ export const oid4vciIssuerCredentialSubjectLocalesFrom = async (
43
+ args: Oid4vciIssuerCredentialSubjectLocalesFromArgs,
44
+ ): Promise<Map<string, Array<IBasicCredentialClaim>>> => {
48
45
  const { issuerCredentialSubject } = args
49
46
  const localeClaims = new Map<string, Array<IBasicCredentialClaim>>()
50
47
 
@@ -125,7 +122,9 @@ export const oid4vciCredentialLocaleBrandingFrom = async (args: Oid4vciCredentia
125
122
  }
126
123
  }
127
124
 
128
- export const oid4vciCombineDisplayLocalesFrom = async (args: Oid4vciCombineDisplayLocalesFromArgs): Promise<Array<IBasicCredentialLocaleBranding>> => {
125
+ export const oid4vciCombineDisplayLocalesFrom = async (
126
+ args: Oid4vciCombineDisplayLocalesFromArgs,
127
+ ): Promise<Array<IBasicCredentialLocaleBranding>> => {
129
128
  const {
130
129
  credentialDisplayLocales = new Map<string, CredentialsSupportedDisplay>(),
131
130
  issuerCredentialSubjectLocales = new Map<string, Array<IBasicCredentialClaim>>(),
@@ -156,7 +155,9 @@ export const sdJwtGetCredentialBrandingFrom = async (args: SdJwtGetCredentialBra
156
155
  })
157
156
  }
158
157
 
159
- export const sdJwtCredentialDisplayLocalesFrom = async (args: SdJwtCredentialDisplayLocalesFromArgs): Promise<Map<string, SdJwtTypeDisplayMetadata>> => {
158
+ export const sdJwtCredentialDisplayLocalesFrom = async (
159
+ args: SdJwtCredentialDisplayLocalesFromArgs,
160
+ ): Promise<Map<string, SdJwtTypeDisplayMetadata>> => {
160
161
  const { credentialDisplay } = args
161
162
  return credentialDisplay.reduce((localeDisplays, display) => {
162
163
  const localeKey = display.lang || ''
@@ -165,14 +166,16 @@ export const sdJwtCredentialDisplayLocalesFrom = async (args: SdJwtCredentialDis
165
166
  }, new Map<string, SdJwtTypeDisplayMetadata>())
166
167
  }
167
168
 
168
- export const sdJwtCredentialClaimLocalesFrom = async (args: SdJwtCredentialClaimLocalesFromArgs): Promise<Map<string, Array<IBasicCredentialClaim>>> => {
169
+ export const sdJwtCredentialClaimLocalesFrom = async (
170
+ args: SdJwtCredentialClaimLocalesFromArgs,
171
+ ): Promise<Map<string, Array<IBasicCredentialClaim>>> => {
169
172
  const { claimsMetadata } = args
170
173
  const localeClaims = new Map<string, Array<IBasicCredentialClaim>>()
171
174
 
172
175
  claimsMetadata.forEach((claim: SdJwtClaimMetadata): void => {
173
176
  claim.display?.forEach((display: SdJwtClaimDisplayMetadata): void => {
174
- const { lang = '', label } = display;
175
- const key = claim.path.map((value: SdJwtClaimPath) => String(value)).join('.');
177
+ const { lang = '', label } = display
178
+ const key = claim.path.map((value: SdJwtClaimPath) => String(value)).join('.')
176
179
  if (!localeClaims.has(lang)) {
177
180
  localeClaims.set(lang, [])
178
181
  }
@@ -180,7 +183,7 @@ export const sdJwtCredentialClaimLocalesFrom = async (args: SdJwtCredentialClaim
180
183
  })
181
184
  })
182
185
 
183
- return localeClaims;
186
+ return localeClaims
184
187
  }
185
188
 
186
189
  export const sdJwtCredentialLocaleBrandingFrom = async (args: SdJwtCredentialLocaleBrandingFromArgs): Promise<IBasicCredentialLocaleBranding> => {
@@ -213,17 +216,15 @@ export const sdJwtCredentialLocaleBrandingFrom = async (args: SdJwtCredentialLoc
213
216
  }),
214
217
  ...(credentialDisplay.rendering?.simple?.background_color && {
215
218
  background: {
216
- color: credentialDisplay.rendering.simple.background_color ,
219
+ color: credentialDisplay.rendering.simple.background_color,
217
220
  },
218
221
  }),
219
222
  }
220
223
  }
221
224
 
222
225
  export const sdJwtCombineDisplayLocalesFrom = async (args: SdJwtCombineDisplayLocalesFromArgs): Promise<Array<IBasicCredentialLocaleBranding>> => {
223
- const {
224
- credentialDisplayLocales = new Map<string, SdJwtTypeDisplayMetadata>(),
225
- claimsMetadata = new Map<string, Array<IBasicCredentialClaim>>(),
226
- } = args
226
+ const { credentialDisplayLocales = new Map<string, SdJwtTypeDisplayMetadata>(), claimsMetadata = new Map<string, Array<IBasicCredentialClaim>>() } =
227
+ args
227
228
 
228
229
  const locales: Array<string> = Array.from(new Set([...claimsMetadata.keys(), ...credentialDisplayLocales.keys()]))
229
230
 
@@ -9,7 +9,7 @@ import {
9
9
  GetSiopRequestArgs,
10
10
  SendAuthorizationChallengeRequestArgs,
11
11
  SendAuthorizationResponseArgs,
12
- SiopV2AuthorizationRequestData
12
+ SiopV2AuthorizationRequestData,
13
13
  } from '../types/FirstPartyMachine'
14
14
 
15
15
  export const sendAuthorizationChallengeRequest = async (args: SendAuthorizationChallengeRequestArgs): Promise<AuthorizationChallengeCodeResponse> => {
@@ -19,31 +19,32 @@ export const sendAuthorizationChallengeRequest = async (args: SendAuthorizationC
19
19
  return oid4vciClient.acquireAuthorizationChallengeCode({
20
20
  clientId: oid4vciClient.clientId ?? uuidv4(),
21
21
  ...(authSession && { authSession }),
22
- ...(!authSession && openID4VCIClientState.credentialOffer?.preAuthorizedCode && { issuerState: openID4VCIClientState.credentialOffer?.preAuthorizedCode }),
22
+ ...(!authSession &&
23
+ openID4VCIClientState.credentialOffer?.preAuthorizedCode && { issuerState: openID4VCIClientState.credentialOffer?.preAuthorizedCode }),
23
24
  ...(!authSession && openID4VCIClientState.credentialOffer?.issuerState && { issuerState: openID4VCIClientState.credentialOffer?.issuerState }),
24
- ...(presentationDuringIssuanceSession && { presentationDuringIssuanceSession })
25
+ ...(presentationDuringIssuanceSession && { presentationDuringIssuanceSession }),
25
26
  })
26
27
  }
27
28
 
28
29
  export const createConfig = async (args: CreateConfigArgs, context: RequiredContext): Promise<CreateConfigResult> => {
29
- const { presentationUri } = args;
30
+ const { presentationUri } = args
30
31
 
31
32
  if (!presentationUri) {
32
- return Promise.reject(Error('Missing presentation uri in context'));
33
+ return Promise.reject(Error('Missing presentation uri in context'))
33
34
  }
34
35
 
35
36
  return context.agent.siopCreateConfig({ url: presentationUri })
36
- };
37
+ }
37
38
 
38
39
  export const getSiopRequest = async (args: GetSiopRequestArgs, context: RequiredContext): Promise<SiopV2AuthorizationRequestData> => {
39
- const {didAuthConfig, presentationUri} = args;
40
+ const { didAuthConfig, presentationUri } = args
40
41
 
41
42
  if (presentationUri === undefined) {
42
- return Promise.reject(Error('Missing presentation uri in context'));
43
+ return Promise.reject(Error('Missing presentation uri in context'))
43
44
  }
44
45
 
45
46
  if (didAuthConfig === undefined) {
46
- return Promise.reject(Error('Missing did auth config in context'));
47
+ return Promise.reject(Error('Missing did auth config in context'))
47
48
  }
48
49
 
49
50
  return context.agent.siopGetSiopRequest({ didAuthConfig, url: presentationUri })
@@ -56,7 +57,7 @@ export const sendAuthorizationResponse = async (args: SendAuthorizationResponseA
56
57
  authorizationRequestData,
57
58
  selectedCredentials,
58
59
  didAuthConfig,
59
- isFirstParty: true
60
+ isFirstParty: true,
60
61
  })
61
62
 
62
63
  return (<AuthorizationChallengeValidationResponse>responseData.body).presentation_during_issuance_session
@@ -10,7 +10,7 @@ import {
10
10
  getTypesFromObject,
11
11
  MetadataDisplay,
12
12
  OpenId4VCIVersion,
13
- AuthorizationChallengeCodeResponse
13
+ AuthorizationChallengeCodeResponse,
14
14
  } from '@sphereon/oid4vci-common'
15
15
  import { KeyUse } from '@sphereon/ssi-sdk-ext.did-resolver-jwk'
16
16
  import { getOrCreatePrimaryIdentifier, SupportedDidMethodEnum } from '@sphereon/ssi-sdk-ext.did-utils'
@@ -26,6 +26,7 @@ import { keyTypeFromCryptographicSuite } from '@sphereon/ssi-sdk-ext.key-utils'
26
26
  import { IBasicCredentialLocaleBranding, IBasicIssuerLocaleBranding } from '@sphereon/ssi-sdk.data-store'
27
27
  import {
28
28
  CredentialMapper,
29
+ Hasher,
29
30
  IVerifiableCredential,
30
31
  JoseSignatureAlgorithm,
31
32
  JoseSignatureAlgorithmString,
@@ -58,15 +59,12 @@ import {
58
59
  VerificationResult,
59
60
  VerifyCredentialToAcceptArgs,
60
61
  StartFirstPartApplicationMachine,
61
- RequiredContext
62
+ RequiredContext,
62
63
  } from '../types/IOID4VCIHolder'
63
- import {
64
- oid4vciGetCredentialBrandingFrom,
65
- sdJwtGetCredentialBrandingFrom,
66
- issuerLocaleBrandingFrom
67
- } from '../mappers/OIDC4VCIBrandingMapper'
64
+ import { oid4vciGetCredentialBrandingFrom, sdJwtGetCredentialBrandingFrom, issuerLocaleBrandingFrom } from '../mappers/OIDC4VCIBrandingMapper'
68
65
  import { FirstPartyMachine } from '../machines/firstPartyMachine'
69
66
  import { FirstPartyMachineState, FirstPartyMachineStateTypes } from '../types/FirstPartyMachine'
67
+ import { defaultHasher } from '@sphereon/ssi-sdk.core'
70
68
 
71
69
  export const getCredentialBranding = async (args: GetCredentialBrandingArgs): Promise<Record<string, Array<IBasicCredentialLocaleBranding>>> => {
72
70
  const { credentialsSupported, context } = args
@@ -88,14 +86,14 @@ export const getCredentialBranding = async (args: GetCredentialBrandingArgs): Pr
88
86
  if (sdJwtTypeMetadata) {
89
87
  mappedLocaleBranding = await sdJwtGetCredentialBrandingFrom({
90
88
  credentialDisplay: sdJwtTypeMetadata.display,
91
- claimsMetadata: sdJwtTypeMetadata.claims
89
+ claimsMetadata: sdJwtTypeMetadata.claims,
92
90
  })
93
91
  } else {
94
92
  mappedLocaleBranding = await oid4vciGetCredentialBrandingFrom({
95
93
  credentialDisplay: credentialsConfigSupported.display,
96
94
  issuerCredentialSubject:
97
- // @ts-ignore // FIXME SPRIND-123 add proper support for type recognition as claim display can be located elsewhere for v13
98
- credentialsSupported.claims !== undefined ? credentialsConfigSupported.claims : credentialsConfigSupported.credentialSubject,
95
+ // @ts-ignore // FIXME SPRIND-123 add proper support for type recognition as claim display can be located elsewhere for v13
96
+ credentialsSupported.claims !== undefined ? credentialsConfigSupported.claims : credentialsConfigSupported.credentialSubject,
99
97
  })
100
98
  }
101
99
  // TODO we should make the mapper part of the plugin, so that the logic for getting the branding becomes more clear and easier to use
@@ -160,7 +158,7 @@ export const verifyCredentialToAccept = async (args: VerifyCredentialToAcceptArg
160
158
  return Promise.reject(Error('No credential found in credential response'))
161
159
  }
162
160
 
163
- const wrappedVC = CredentialMapper.toWrappedVerifiableCredential(credential, { hasher })
161
+ const wrappedVC = CredentialMapper.toWrappedVerifiableCredential(credential, { hasher: hasher ?? defaultHasher })
164
162
  if (
165
163
  wrappedVC.decoded?.iss?.includes('did:ebsi:') ||
166
164
  (typeof wrappedVC.decoded?.vc?.issuer === 'string'
@@ -226,7 +224,7 @@ export const mapCredentialToAccept = async (args: MapCredentialToAcceptArgs): Pr
226
224
  if (!hasher) {
227
225
  return Promise.reject('a hasher is required for encoded SD-JWT credentials')
228
226
  }
229
- const asyncHasher = (data: string, algorithm: string) => Promise.resolve(hasher(data, algorithm))
227
+ const asyncHasher: Hasher = (data: string | ArrayBuffer, algorithm: string) => Promise.resolve(hasher(data, algorithm))
230
228
  const decodedSdJwt = await CredentialMapper.decodeSdJwtVcAsync(wrappedVerifiableCredential.credential, asyncHasher)
231
229
  uniformVerifiableCredential = sdJwtDecodedCredentialToUniformCredential(<SdJwtDecodedVerifiableCredential>decodedSdJwt)
232
230
  } else if (CredentialMapper.isMsoMdocDecodedCredential(wrappedVerifiableCredential.credential)) {
@@ -621,7 +619,10 @@ export const getIssuanceCryptoSuite = async (opts: GetIssuanceCryptoSuiteArgs):
621
619
  }
622
620
  }
623
621
 
624
- export const startFirstPartApplicationMachine = async (args: StartFirstPartApplicationMachine, context: RequiredContext): Promise<AuthorizationChallengeCodeResponse | string> => {
622
+ export const startFirstPartApplicationMachine = async (
623
+ args: StartFirstPartApplicationMachine,
624
+ context: RequiredContext,
625
+ ): Promise<AuthorizationChallengeCodeResponse | string> => {
625
626
  const { openID4VCIClientState, stateNavigationListener, contact } = args
626
627
 
627
628
  if (!openID4VCIClientState) {
@@ -636,8 +637,8 @@ export const startFirstPartApplicationMachine = async (args: StartFirstPartAppli
636
637
  openID4VCIClientState,
637
638
  contact,
638
639
  agentContext: context,
639
- stateNavigationListener
640
- });
640
+ stateNavigationListener,
641
+ })
641
642
 
642
643
  return new Promise((resolve, reject) => {
643
644
  try {
@@ -645,20 +646,20 @@ export const startFirstPartApplicationMachine = async (args: StartFirstPartAppli
645
646
  if (state.matches(FirstPartyMachineStateTypes.done)) {
646
647
  const authorizationCodeResponse = state.context.authorizationCodeResponse
647
648
  if (!authorizationCodeResponse) {
648
- reject(Error('No authorizationCodeResponse acquired'));
649
+ reject(Error('No authorizationCodeResponse acquired'))
649
650
  }
650
- resolve(authorizationCodeResponse!);
651
+ resolve(authorizationCodeResponse!)
651
652
  } else if (state.matches(FirstPartyMachineStateTypes.aborted)) {
652
- resolve(FirstPartyMachineStateTypes.aborted);
653
+ resolve(FirstPartyMachineStateTypes.aborted)
653
654
  } else if (state.matches(FirstPartyMachineStateTypes.declined)) {
654
- resolve(FirstPartyMachineStateTypes.declined);
655
+ resolve(FirstPartyMachineStateTypes.declined)
655
656
  } else if (state.matches(FirstPartyMachineStateTypes.error)) {
656
- reject(state.context.error);
657
+ reject(state.context.error)
657
658
  }
658
659
  })
659
- firstPartyMachineInstance.start();
660
+ firstPartyMachineInstance.start()
660
661
  } catch (error) {
661
- reject(error);
662
+ reject(error)
662
663
  }
663
- });
664
- };
664
+ })
665
+ }
@@ -1,18 +1,7 @@
1
- import {
2
- BaseActionObject,
3
- Interpreter,
4
- ResolveTypegenMeta,
5
- ServiceMap, State,
6
- StateMachine,
7
- StatesConfig,
8
- TypegenDisabled
9
- } from 'xstate'
1
+ import { BaseActionObject, Interpreter, ResolveTypegenMeta, ServiceMap, State, StateMachine, StatesConfig, TypegenDisabled } from 'xstate'
10
2
  import { OpenID4VCIClientState } from '@sphereon/oid4vci-client'
11
3
  import { DidAuthConfig, Party } from '@sphereon/ssi-sdk.data-store'
12
- import {
13
- PresentationDefinitionWithLocation,
14
- RPRegistrationMetadataPayload
15
- } from '@sphereon/did-auth-siop'
4
+ import { PresentationDefinitionWithLocation, RPRegistrationMetadataPayload } from '@sphereon/did-auth-siop'
16
5
  import { UniqueDigitalCredential } from '@sphereon/ssi-sdk.credential-store'
17
6
  import { AuthorizationChallengeCodeResponse } from '@sphereon/oid4vci-common'
18
7
  import { IIdentifier } from '@veramo/core'
@@ -27,7 +16,7 @@ export enum FirstPartyMachineStateTypes {
27
16
  error = 'error',
28
17
  done = 'done',
29
18
  aborted = 'aborted',
30
- declined = 'declined'
19
+ declined = 'declined',
31
20
  }
32
21
 
33
22
  export enum FirstPartyMachineServices {
@@ -37,7 +26,7 @@ export enum FirstPartyMachineServices {
37
26
  getSiopRequest = 'getSiopRequest',
38
27
  }
39
28
 
40
- export type FirstPartyMachineStates = Record<FirstPartyMachineStateTypes, {}>;
29
+ export type FirstPartyMachineStates = Record<FirstPartyMachineStateTypes, {}>
41
30
 
42
31
  export type FirstPartyMachineContext = {
43
32
  openID4VCIClientState: OpenID4VCIClientState
@@ -50,115 +39,118 @@ export type FirstPartyMachineContext = {
50
39
  authorizationRequestData?: SiopV2AuthorizationRequestData
51
40
  presentationDuringIssuanceSession?: string
52
41
  authorizationCodeResponse?: AuthorizationChallengeCodeResponse
53
- error?: ErrorDetails;
54
- };
42
+ error?: ErrorDetails
43
+ }
55
44
 
56
45
  export enum FirstPartyMachineEvents {
57
46
  NEXT = 'NEXT',
58
47
  PREVIOUS = 'PREVIOUS',
59
48
  DECLINE = 'DECLINE',
60
- SET_SELECTED_CREDENTIALS = 'SET_SELECTED_CREDENTIALS'
49
+ SET_SELECTED_CREDENTIALS = 'SET_SELECTED_CREDENTIALS',
61
50
  }
62
51
 
63
- export type FirstPartyNextEvent = {type: FirstPartyMachineEvents.NEXT};
64
- export type FirstPartyPreviousEvent = {type: FirstPartyMachineEvents.PREVIOUS};
65
- export type FirstPartyDeclineEvent = {type: FirstPartyMachineEvents.DECLINE};
52
+ export type FirstPartyNextEvent = { type: FirstPartyMachineEvents.NEXT }
53
+ export type FirstPartyPreviousEvent = { type: FirstPartyMachineEvents.PREVIOUS }
54
+ export type FirstPartyDeclineEvent = { type: FirstPartyMachineEvents.DECLINE }
66
55
  export type FirstPartySelectCredentialsEvent = {
67
- type: FirstPartyMachineEvents.SET_SELECTED_CREDENTIALS;
68
- data: Array<UniqueDigitalCredential>;
69
- };
56
+ type: FirstPartyMachineEvents.SET_SELECTED_CREDENTIALS
57
+ data: Array<UniqueDigitalCredential>
58
+ }
70
59
 
71
- export type FirstPartyMachineEventTypes =
72
- FirstPartyNextEvent |
73
- FirstPartyPreviousEvent |
74
- FirstPartyDeclineEvent |
75
- FirstPartySelectCredentialsEvent
60
+ export type FirstPartyMachineEventTypes = FirstPartyNextEvent | FirstPartyPreviousEvent | FirstPartyDeclineEvent | FirstPartySelectCredentialsEvent
76
61
 
77
62
  export type FirstPartyMachineStatesConfig = StatesConfig<
78
63
  FirstPartyMachineContext,
79
64
  {
80
- states: FirstPartyMachineStates;
65
+ states: FirstPartyMachineStates
81
66
  },
82
67
  FirstPartyMachineEventTypes,
83
68
  any
84
- >;
69
+ >
85
70
 
86
71
  export type CreateFirstPartyMachineOpts = {
87
72
  openID4VCIClientState: OpenID4VCIClientState
88
73
  contact: Party
89
74
  agentContext: RequiredContext
90
- machineId?: string;
91
- };
75
+ machineId?: string
76
+ }
92
77
 
93
78
  export type FirstPartyStateMachine = StateMachine<
94
79
  FirstPartyMachineContext,
95
80
  any,
96
81
  FirstPartyMachineEventTypes,
97
82
  {
98
- value: any;
99
- context: FirstPartyMachineContext;
83
+ value: any
84
+ context: FirstPartyMachineContext
100
85
  },
101
86
  BaseActionObject,
102
87
  ServiceMap,
103
88
  ResolveTypegenMeta<TypegenDisabled, FirstPartyMachineEventTypes, BaseActionObject, ServiceMap>
104
- >;
89
+ >
105
90
 
106
91
  export type FirstPartyMachineInterpreter = Interpreter<
107
92
  FirstPartyMachineContext,
108
93
  any,
109
94
  FirstPartyMachineEventTypes,
110
95
  {
111
- value: any;
112
- context: FirstPartyMachineContext;
96
+ value: any
97
+ context: FirstPartyMachineContext
113
98
  },
114
99
  any
115
- >;
100
+ >
116
101
 
117
- export type FirstPartyMachineStateNavigationListener = (firstPartyMachine: FirstPartyMachineInterpreter, state: FirstPartyMachineState, navigation?: any) => Promise<void>
102
+ export type FirstPartyMachineStateNavigationListener = (
103
+ firstPartyMachine: FirstPartyMachineInterpreter,
104
+ state: FirstPartyMachineState,
105
+ navigation?: any,
106
+ ) => Promise<void>
118
107
 
119
108
  export type InstanceFirstPartyMachineOpts = {
120
- services?: any;
121
- guards?: any;
122
- subscription?: () => void;
123
- requireCustomNavigationHook?: boolean;
109
+ services?: any
110
+ guards?: any
111
+ subscription?: () => void
112
+ requireCustomNavigationHook?: boolean
124
113
  stateNavigationListener?: FirstPartyMachineStateNavigationListener
125
- } & CreateFirstPartyMachineOpts;
114
+ } & CreateFirstPartyMachineOpts
126
115
 
127
116
  export type FirstPartyMachineState = State<
128
117
  FirstPartyMachineContext,
129
118
  FirstPartyMachineEventTypes,
130
119
  any,
131
120
  {
132
- value: any;
133
- context: FirstPartyMachineContext;
121
+ value: any
122
+ context: FirstPartyMachineContext
134
123
  },
135
124
  any
136
- >;
125
+ >
137
126
 
138
- export type FirstPartyMachineServiceDefinitions = Record<
139
- keyof typeof FirstPartyMachineServices,
140
- (...args: Array<any>) => any
141
- >;
127
+ export type FirstPartyMachineServiceDefinitions = Record<keyof typeof FirstPartyMachineServices, (...args: Array<any>) => any>
142
128
 
143
- export type SendAuthorizationChallengeRequestArgs = Pick<FirstPartyMachineContext, 'openID4VCIClientState' | 'authSession' | 'presentationDuringIssuanceSession'>
129
+ export type SendAuthorizationChallengeRequestArgs = Pick<
130
+ FirstPartyMachineContext,
131
+ 'openID4VCIClientState' | 'authSession' | 'presentationDuringIssuanceSession'
132
+ >
144
133
 
145
- export type SendAuthorizationResponseArgs = Pick<FirstPartyMachineContext, 'authSession' | 'presentationUri' | 'didAuthConfig' | 'authorizationRequestData' | 'selectedCredentials'>
134
+ export type SendAuthorizationResponseArgs = Pick<
135
+ FirstPartyMachineContext,
136
+ 'authSession' | 'presentationUri' | 'didAuthConfig' | 'authorizationRequestData' | 'selectedCredentials'
137
+ >
146
138
 
147
139
  export type CreateConfigArgs = Pick<FirstPartyMachineContext, 'presentationUri' | 'identifier'>
148
140
 
149
141
  export type GetSiopRequestArgs = Pick<FirstPartyMachineContext, 'didAuthConfig' | 'presentationUri'>
150
142
 
151
143
  export type SiopV2AuthorizationRequestData = {
152
- correlationId: string;
153
- registrationMetadataPayload: RPRegistrationMetadataPayload;
154
- issuer?: string;
155
- name?: string;
156
- uri?: URL;
157
- clientIdScheme?: string;
158
- clientId?: string;
159
- entityId?: string;
160
- presentationDefinitions?: PresentationDefinitionWithLocation[];
161
- };
144
+ correlationId: string
145
+ registrationMetadataPayload: RPRegistrationMetadataPayload
146
+ issuer?: string
147
+ name?: string
148
+ uri?: URL
149
+ clientIdScheme?: string
150
+ clientId?: string
151
+ entityId?: string
152
+ presentationDefinitions?: PresentationDefinitionWithLocation[]
153
+ }
162
154
 
163
155
  export type FirstPartyMachineNavigationArgs = {
164
156
  firstPartyMachine: FirstPartyMachineInterpreter
@@ -7,12 +7,12 @@ import {
7
7
  CredentialConfigurationSupported,
8
8
  CredentialOfferRequestWithBaseUrl,
9
9
  CredentialResponse,
10
+ CredentialsSupportedDisplay,
10
11
  EndpointMetadataResult,
11
12
  ExperimentalSubjectIssuance,
13
+ IssuerCredentialSubject,
12
14
  MetadataDisplay,
13
15
  NotificationRequest,
14
- CredentialsSupportedDisplay,
15
- IssuerCredentialSubject,
16
16
  } from '@sphereon/oid4vci-common'
17
17
  import { DynamicRegistrationClientMetadata } from '@sphereon/oid4vc-common'
18
18
  import { CreateOrGetIdentifierOpts, IdentifierProviderOpts, SupportedDidMethodEnum } from '@sphereon/ssi-sdk-ext.did-utils'
@@ -40,16 +40,16 @@ import { ISDJwtPlugin } from '@sphereon/ssi-sdk.sd-jwt'
40
40
  import { ICredentialValidation, SchemaValidation } from '@sphereon/ssi-sdk.credential-validation'
41
41
  import { IDidAuthSiopOpAuthenticator } from '@sphereon/ssi-sdk.siopv2-oid4vp-op-auth'
42
42
  import {
43
- Hasher,
43
+ HasherSync,
44
44
  IVerifiableCredential,
45
45
  JoseSignatureAlgorithm,
46
46
  JoseSignatureAlgorithmString,
47
47
  OriginalVerifiableCredential,
48
- SdJwtTypeDisplayMetadata,
49
48
  SdJwtClaimMetadata,
49
+ SdJwtTypeDisplayMetadata,
50
50
  W3CVerifiableCredential,
51
51
  WrappedVerifiableCredential,
52
- WrappedVerifiablePresentation
52
+ WrappedVerifiablePresentation,
53
53
  } from '@sphereon/ssi-types'
54
54
  import {
55
55
  IAgentContext,
@@ -110,7 +110,7 @@ export type OID4VCIHolderOptions = {
110
110
  defaultAuthorizationRequestOptions?: AuthorizationRequestOpts
111
111
  didMethodPreferences?: Array<SupportedDidMethodEnum>
112
112
  jwtCryptographicSuitePreferences?: Array<JoseSignatureAlgorithm | JoseSignatureAlgorithmString>
113
- hasher?: Hasher
113
+ hasher?: HasherSync
114
114
  }
115
115
 
116
116
  export type OnContactIdentityCreatedArgs = {
@@ -173,7 +173,9 @@ export type SendNotificationArgs = Pick<
173
173
  'credentialsToAccept' | 'serverMetadata' | 'credentialsSupported' | 'openID4VCIClientState'
174
174
  > & { notificationRequest?: NotificationRequest; stored: boolean }
175
175
  export type GetFederationTrustArgs = Pick<OID4VCIMachineContext, 'requestData' | 'trustAnchors' | 'serverMetadata'>
176
- export type StartFirstPartApplicationMachine = Pick<OID4VCIMachineContext, 'openID4VCIClientState' | 'contact'> & { stateNavigationListener?: FirstPartyMachineStateNavigationListener }
176
+ export type StartFirstPartApplicationMachine = Pick<OID4VCIMachineContext, 'openID4VCIClientState' | 'contact'> & {
177
+ stateNavigationListener?: FirstPartyMachineStateNavigationListener
178
+ }
177
179
 
178
180
  export enum OID4VCIHolderEvent {
179
181
  CONTACT_IDENTITY_CREATED = 'contact_identity_created',
@@ -199,7 +201,7 @@ export enum SupportedLanguage {
199
201
  export type VerifyCredentialToAcceptArgs = {
200
202
  mappedCredential: MappedCredentialToAccept
201
203
  onVerifyEBSICredentialIssuer?: (args: VerifyEBSICredentialIssuerArgs) => Promise<VerifyEBSICredentialIssuerResult>
202
- hasher?: Hasher
204
+ hasher?: HasherSync
203
205
  schemaValidation?: SchemaValidation
204
206
  context: RequiredContext
205
207
  }
@@ -319,7 +321,11 @@ export type CreateOID4VCIMachineOpts = {
319
321
  issuanceOpt?: IssuanceOpts
320
322
  }
321
323
 
322
- export type OID4VCIMachineStateNavigationListener = (oid4vciMachine: OID4VCIMachineInterpreter, state: OID4VCIMachineState, navigation?: any) => Promise<void>
324
+ export type OID4VCIMachineStateNavigationListener = (
325
+ oid4vciMachine: OID4VCIMachineInterpreter,
326
+ state: OID4VCIMachineState,
327
+ navigation?: any,
328
+ ) => Promise<void>
323
329
 
324
330
  export type OID4VCIMachineInstanceOpts = {
325
331
  services?: any
@@ -378,7 +384,7 @@ export enum OID4VCIMachineGuards {
378
384
  hasSelectedCredentialsGuard = 'oid4vciHasSelectedCredentialsGuard',
379
385
  isOIDFOriginGuard = 'oid4vciIsOIDFOriginGuard',
380
386
  contactHasLowTrustGuard = 'oid4vciContactHasLowTrustGuard',
381
- isFirstPartyApplication = 'oid4vciIsFirstPartyApplication'
387
+ isFirstPartyApplication = 'oid4vciIsFirstPartyApplication',
382
388
  }
383
389
 
384
390
  export enum OID4VCIMachineServices {
@@ -394,13 +400,10 @@ export enum OID4VCIMachineServices {
394
400
  storeCredentialBranding = 'storeCredentialBranding',
395
401
  sendNotification = 'sendNotification',
396
402
  storeCredentials = 'storeCredentials',
397
- startFirstPartApplicationFlow = 'startFirstPartApplicationFlow'
403
+ startFirstPartApplicationFlow = 'startFirstPartApplicationFlow',
398
404
  }
399
405
 
400
- export type OID4VCIMachineServiceDefinitions = Record<
401
- keyof typeof OID4VCIMachineServices,
402
- (...args: Array<any>) => any
403
- >;
406
+ export type OID4VCIMachineServiceDefinitions = Record<keyof typeof OID4VCIMachineServices, (...args: Array<any>) => any>
404
407
 
405
408
  export type NextEvent = { type: OID4VCIMachineEvents.NEXT }
406
409
  export type PreviousEvent = { type: OID4VCIMachineEvents.PREVIOUS }
@@ -411,8 +414,8 @@ export type VerificationCodeEvent = { type: OID4VCIMachineEvents.SET_VERIFICATIO
411
414
  export type ContactConsentEvent = { type: OID4VCIMachineEvents.SET_CONTACT_CONSENT; data: boolean }
412
415
  export type ContactAliasEvent = { type: OID4VCIMachineEvents.SET_CONTACT_ALIAS; data: string }
413
416
  export type SetAuthorizationCodeURLEvent = { type: OID4VCIMachineEvents.SET_AUTHORIZATION_CODE_URL; data: string }
414
- export type InvokeAuthorizationRequestEvent = { type: OID4VCIMachineEvents.INVOKED_AUTHORIZATION_CODE_REQUEST, data: string }
415
- export type AuthorizationResponseEvent = { type: OID4VCIMachineEvents.PROVIDE_AUTHORIZATION_CODE_RESPONSE, data: string | AuthorizationResponse }
417
+ export type InvokeAuthorizationRequestEvent = { type: OID4VCIMachineEvents.INVOKED_AUTHORIZATION_CODE_REQUEST; data: string }
418
+ export type AuthorizationResponseEvent = { type: OID4VCIMachineEvents.PROVIDE_AUTHORIZATION_CODE_RESPONSE; data: string | AuthorizationResponse }
416
419
 
417
420
  export type OID4VCIMachineEventTypes =
418
421
  | NextEvent
@@ -539,7 +542,7 @@ export type GetPreferredCredentialFormatsArgs = {
539
542
 
540
543
  export type MapCredentialToAcceptArgs = {
541
544
  credentialToAccept: CredentialToAccept
542
- hasher?: Hasher
545
+ hasher?: HasherSync
543
546
  }
544
547
 
545
548
  export type GetDefaultIssuanceOptsArgs = {
@@ -632,7 +635,7 @@ export type CredentialVerificationError = {
632
635
 
633
636
  export type VerifyMdocArgs = { credential: string }
634
637
 
635
- export type VerifySDJWTCredentialArgs = { credential: string; hasher?: Hasher }
638
+ export type VerifySDJWTCredentialArgs = { credential: string; hasher?: HasherSync }
636
639
 
637
640
  export interface VerifyCredentialArgs {
638
641
  credential: OriginalVerifiableCredential
@@ -720,17 +723,17 @@ export type DidAgents = TAgent<IResolver & IDIDManager>
720
723
 
721
724
  export type RequiredContext = IAgentContext<
722
725
  IIssuanceBranding &
723
- IContactManager &
724
- ICredentialValidation &
725
- ICredentialVerifier &
726
- ICredentialIssuer &
727
- ICredentialStore &
728
- IIdentifierResolution &
729
- IJwtService &
730
- IDIDManager &
731
- IResolver &
732
- IKeyManager &
733
- ISDJwtPlugin &
734
- ImDLMdoc &
735
- IDidAuthSiopOpAuthenticator
726
+ IContactManager &
727
+ ICredentialValidation &
728
+ ICredentialVerifier &
729
+ ICredentialIssuer &
730
+ ICredentialStore &
731
+ IIdentifierResolution &
732
+ IJwtService &
733
+ IDIDManager &
734
+ IResolver &
735
+ IKeyManager &
736
+ ISDJwtPlugin &
737
+ ImDLMdoc &
738
+ IDidAuthSiopOpAuthenticator
736
739
  >