@sphereon/ssi-sdk.oid4vci-holder 0.32.1-next.54 → 0.33.1-feature.vcdm2.4

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 (48) hide show
  1. package/dist/agent/OID4VCIHolder.d.ts +1 -0
  2. package/dist/agent/OID4VCIHolder.d.ts.map +1 -1
  3. package/dist/agent/OID4VCIHolder.js +733 -721
  4. package/dist/agent/OID4VCIHolder.js.map +1 -1
  5. package/dist/index.d.ts +1 -0
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +8 -27
  8. package/dist/index.js.map +1 -1
  9. package/dist/link-handler/index.d.ts.map +1 -1
  10. package/dist/link-handler/index.js +55 -49
  11. package/dist/link-handler/index.js.map +1 -1
  12. package/dist/listeners/headlessStateNavListener.js +7 -20
  13. package/dist/listeners/headlessStateNavListener.js.map +1 -1
  14. package/dist/localization/Localization.js +38 -43
  15. package/dist/localization/Localization.js.map +1 -1
  16. package/dist/machines/firstPartyMachine.d.ts.map +1 -1
  17. package/dist/machines/firstPartyMachine.js +89 -88
  18. package/dist/machines/firstPartyMachine.js.map +1 -1
  19. package/dist/machines/oid4vciMachine.d.ts.map +1 -1
  20. package/dist/machines/oid4vciMachine.js +307 -326
  21. package/dist/machines/oid4vciMachine.js.map +1 -1
  22. package/dist/mappers/OIDC4VCIBrandingMapper.d.ts.map +1 -1
  23. package/dist/mappers/OIDC4VCIBrandingMapper.js +164 -136
  24. package/dist/mappers/OIDC4VCIBrandingMapper.js.map +1 -1
  25. package/dist/services/FirstPartyMachineServices.d.ts.map +1 -1
  26. package/dist/services/FirstPartyMachineServices.js +20 -30
  27. package/dist/services/FirstPartyMachineServices.js.map +1 -1
  28. package/dist/services/OID4VCIHolderService.d.ts.map +1 -1
  29. package/dist/services/OID4VCIHolderService.js +147 -154
  30. package/dist/services/OID4VCIHolderService.js.map +1 -1
  31. package/dist/types/FirstPartyMachine.d.ts.map +1 -1
  32. package/dist/types/FirstPartyMachine.js +6 -9
  33. package/dist/types/FirstPartyMachine.js.map +1 -1
  34. package/dist/types/IOID4VCIHolder.d.ts +6 -6
  35. package/dist/types/IOID4VCIHolder.d.ts.map +1 -1
  36. package/dist/types/IOID4VCIHolder.js +20 -23
  37. package/dist/types/IOID4VCIHolder.js.map +1 -1
  38. package/package.json +26 -25
  39. package/src/agent/OID4VCIHolder.ts +33 -11
  40. package/src/index.ts +1 -0
  41. package/src/link-handler/index.ts +6 -8
  42. package/src/machines/firstPartyMachine.ts +60 -69
  43. package/src/machines/oid4vciMachine.ts +9 -11
  44. package/src/mappers/OIDC4VCIBrandingMapper.ts +26 -25
  45. package/src/services/FirstPartyMachineServices.ts +11 -10
  46. package/src/services/OID4VCIHolderService.ts +25 -24
  47. package/src/types/FirstPartyMachine.ts +56 -64
  48. package/src/types/IOID4VCIHolder.ts +35 -32
@@ -1,20 +1,8 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.OID4VCIMachine = void 0;
13
- const oid4vci_common_1 = require("@sphereon/oid4vci-common");
14
- const xstate_1 = require("xstate");
15
- const Localization_1 = require("../localization/Localization");
16
- const IOID4VCIHolder_1 = require("../types/IOID4VCIHolder");
17
- const FirstPartyMachine_1 = require("../types/FirstPartyMachine");
1
+ import { AuthzFlowType, toAuthorizationResponsePayload } from '@sphereon/oid4vci-common';
2
+ import { assign, createMachine, interpret } from 'xstate';
3
+ import { translate } from '../localization/Localization';
4
+ import { OID4VCIMachineAddContactStates, OID4VCIMachineEvents, OID4VCIMachineGuards, OID4VCIMachineServices, OID4VCIMachineStates, OID4VCIMachineVerifyPinStates, } from '../types/IOID4VCIHolder';
5
+ import { FirstPartyMachineStateTypes } from '../types/FirstPartyMachine';
18
6
  const oid4vciHasNoContactGuard = (_ctx, _event) => {
19
7
  const { contact } = _ctx;
20
8
  return contact === undefined;
@@ -32,9 +20,8 @@ const oid4vciCredentialsToSelectRequiredGuard = (_ctx, _event) => {
32
20
  return credentialToSelectFrom && credentialToSelectFrom.length > 1;
33
21
  };
34
22
  const oid4vciRequirePinGuard = (_ctx, _event) => {
35
- var _a;
36
23
  const { requestData } = _ctx;
37
- return ((_a = requestData === null || requestData === void 0 ? void 0 : requestData.credentialOffer) === null || _a === void 0 ? void 0 : _a.userPinRequired) === true;
24
+ return requestData?.credentialOffer?.userPinRequired === true;
38
25
  };
39
26
  const oid4vciHasNoContactIdentityGuard = (_ctx, _event) => {
40
27
  const { contact, credentialsToAccept } = _ctx;
@@ -42,7 +29,7 @@ const oid4vciHasNoContactIdentityGuard = (_ctx, _event) => {
42
29
  if (toAcceptId.match(/^https?:\/\/.*/)) {
43
30
  toAcceptId = new URL(toAcceptId).hostname;
44
31
  }
45
- return !(contact === null || contact === void 0 ? void 0 : contact.identities.some((identity) => identity.identifier.correlationId === toAcceptId));
32
+ return !contact?.identities.some((identity) => identity.identifier.correlationId === toAcceptId);
46
33
  };
47
34
  const oid4vciVerificationCodeGuard = (_ctx, _event) => {
48
35
  const { verificationCode } = _ctx;
@@ -66,7 +53,6 @@ const oid4vciNoAuthorizationGuard = (ctx, _event) => {
66
53
  };
67
54
  // FIXME refactor this guard
68
55
  const oid4vciRequireAuthorizationGuard = (ctx, _event) => {
69
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
70
56
  const { openID4VCIClientState } = ctx;
71
57
  if (!openID4VCIClientState) {
72
58
  throw Error('Missing openID4VCI client state in context');
@@ -77,37 +63,34 @@ const oid4vciRequireAuthorizationGuard = (ctx, _event) => {
77
63
  else if (openID4VCIClientState.authorizationRequestOpts) {
78
64
  // We have authz options or there is not credential offer to begin with.
79
65
  // We require authz as long as we do not have the authz code response
80
- return !((_a = ctx.openID4VCIClientState) === null || _a === void 0 ? void 0 : _a.authorizationCodeResponse);
66
+ return !ctx.openID4VCIClientState?.authorizationCodeResponse;
81
67
  }
82
- else if ((_c = (_b = openID4VCIClientState.credentialOffer) === null || _b === void 0 ? void 0 : _b.supportedFlows) === null || _c === void 0 ? void 0 : _c.includes(oid4vci_common_1.AuthzFlowType.AUTHORIZATION_CODE_FLOW)) {
83
- return !((_d = ctx.openID4VCIClientState) === null || _d === void 0 ? void 0 : _d.authorizationCodeResponse);
68
+ else if (openID4VCIClientState.credentialOffer?.supportedFlows?.includes(AuthzFlowType.AUTHORIZATION_CODE_FLOW)) {
69
+ return !ctx.openID4VCIClientState?.authorizationCodeResponse;
84
70
  }
85
- else if ((_f = (_e = openID4VCIClientState.credentialOffer) === null || _e === void 0 ? void 0 : _e.supportedFlows) === null || _f === void 0 ? void 0 : _f.includes(oid4vci_common_1.AuthzFlowType.PRE_AUTHORIZED_CODE_FLOW)) {
71
+ else if (openID4VCIClientState.credentialOffer?.supportedFlows?.includes(AuthzFlowType.PRE_AUTHORIZED_CODE_FLOW)) {
86
72
  return false;
87
73
  }
88
- else if ((_h = (_g = openID4VCIClientState.endpointMetadata) === null || _g === void 0 ? void 0 : _g.credentialIssuerMetadata) === null || _h === void 0 ? void 0 : _h.authorization_endpoint) {
89
- return !((_j = ctx.openID4VCIClientState) === null || _j === void 0 ? void 0 : _j.authorizationCodeResponse);
74
+ else if (openID4VCIClientState.endpointMetadata?.credentialIssuerMetadata?.authorization_endpoint) {
75
+ return !ctx.openID4VCIClientState?.authorizationCodeResponse;
90
76
  }
91
77
  return false;
92
78
  };
93
79
  const oid4vciHasAuthorizationResponse = (ctx, _event) => {
94
- var _a;
95
- return !!((_a = ctx.openID4VCIClientState) === null || _a === void 0 ? void 0 : _a.authorizationCodeResponse);
80
+ return !!ctx.openID4VCIClientState?.authorizationCodeResponse;
96
81
  };
97
82
  const oid4vciIsFirstPartyApplication = (ctx, _event) => {
98
- var _a;
99
- return !!((_a = ctx.serverMetadata) === null || _a === void 0 ? void 0 : _a.authorization_challenge_endpoint);
83
+ return !!ctx.serverMetadata?.authorization_challenge_endpoint;
100
84
  };
101
85
  const createOID4VCIMachine = (opts) => {
102
- var _a, _b;
103
86
  const initialContext = {
104
87
  // 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
105
- accessTokenOpts: opts === null || opts === void 0 ? void 0 : opts.accessTokenOpts,
106
- requestData: opts === null || opts === void 0 ? void 0 : opts.requestData,
107
- trustAnchors: (_a = opts === null || opts === void 0 ? void 0 : opts.trustAnchors) !== null && _a !== void 0 ? _a : [],
108
- issuanceOpt: opts === null || opts === void 0 ? void 0 : opts.issuanceOpt,
109
- didMethodPreferences: opts === null || opts === void 0 ? void 0 : opts.didMethodPreferences,
110
- locale: opts === null || opts === void 0 ? void 0 : opts.locale,
88
+ accessTokenOpts: opts?.accessTokenOpts,
89
+ requestData: opts?.requestData,
90
+ trustAnchors: opts?.trustAnchors ?? [],
91
+ issuanceOpt: opts?.issuanceOpt,
92
+ didMethodPreferences: opts?.didMethodPreferences,
93
+ locale: opts?.locale,
111
94
  credentialsSupported: {},
112
95
  credentialToSelectFrom: [],
113
96
  selectedCredentials: [],
@@ -115,10 +98,10 @@ const createOID4VCIMachine = (opts) => {
115
98
  hasContactConsent: true,
116
99
  contactAlias: '',
117
100
  };
118
- return (0, xstate_1.createMachine)({
119
- id: (_b = opts === null || opts === void 0 ? void 0 : opts.machineName) !== null && _b !== void 0 ? _b : 'OID4VCIHolder',
101
+ return createMachine({
102
+ id: opts?.machineName ?? 'OID4VCIHolder',
120
103
  predictableActionArguments: true,
121
- initial: IOID4VCIHolder_1.OID4VCIMachineStates.start,
104
+ initial: OID4VCIMachineStates.start,
122
105
  schema: {
123
106
  events: {},
124
107
  guards: {},
@@ -126,25 +109,25 @@ const createOID4VCIMachine = (opts) => {
126
109
  },
127
110
  context: initialContext,
128
111
  states: {
129
- [IOID4VCIHolder_1.OID4VCIMachineStates.start]: {
130
- id: IOID4VCIHolder_1.OID4VCIMachineStates.start,
112
+ [OID4VCIMachineStates.start]: {
113
+ id: OID4VCIMachineStates.start,
131
114
  invoke: {
132
- src: IOID4VCIHolder_1.OID4VCIMachineServices.start,
115
+ src: OID4VCIMachineServices.start,
133
116
  onDone: {
134
- target: IOID4VCIHolder_1.OID4VCIMachineStates.createCredentialsToSelectFrom,
135
- actions: (0, xstate_1.assign)({
117
+ target: OID4VCIMachineStates.createCredentialsToSelectFrom,
118
+ actions: assign({
136
119
  authorizationCodeURL: (_ctx, _event) => _event.data.authorizationCodeURL,
137
- credentialBranding: (_ctx, _event) => { var _a; return (_a = _event.data.credentialBranding) !== null && _a !== void 0 ? _a : {}; },
120
+ credentialBranding: (_ctx, _event) => _event.data.credentialBranding ?? {},
138
121
  credentialsSupported: (_ctx, _event) => _event.data.credentialsSupported,
139
122
  serverMetadata: (_ctx, _event) => _event.data.serverMetadata,
140
123
  openID4VCIClientState: (_ctx, _event) => _event.data.oid4vciClientState,
141
124
  }),
142
125
  },
143
126
  onError: {
144
- target: IOID4VCIHolder_1.OID4VCIMachineStates.handleError,
145
- actions: (0, xstate_1.assign)({
127
+ target: OID4VCIMachineStates.handleError,
128
+ actions: assign({
146
129
  error: (_ctx, _event) => ({
147
- title: (0, Localization_1.translate)('oid4vci_machine_initiation_error_title'),
130
+ title: translate('oid4vci_machine_initiation_error_title'),
148
131
  message: _event.data.message,
149
132
  stack: _event.data.stack,
150
133
  }),
@@ -152,23 +135,23 @@ const createOID4VCIMachine = (opts) => {
152
135
  },
153
136
  },
154
137
  },
155
- [IOID4VCIHolder_1.OID4VCIMachineStates.createCredentialsToSelectFrom]: {
156
- id: IOID4VCIHolder_1.OID4VCIMachineStates.createCredentialsToSelectFrom,
138
+ [OID4VCIMachineStates.createCredentialsToSelectFrom]: {
139
+ id: OID4VCIMachineStates.createCredentialsToSelectFrom,
157
140
  invoke: {
158
- src: IOID4VCIHolder_1.OID4VCIMachineServices.createCredentialsToSelectFrom,
141
+ src: OID4VCIMachineServices.createCredentialsToSelectFrom,
159
142
  onDone: {
160
- target: IOID4VCIHolder_1.OID4VCIMachineStates.getContact,
161
- actions: (0, xstate_1.assign)({
143
+ target: OID4VCIMachineStates.getContact,
144
+ actions: assign({
162
145
  credentialToSelectFrom: (_ctx, _event) => _event.data,
163
146
  }),
164
147
  // TODO WAL-670 would be nice if we can have guard that checks if we have at least 1 item in the selection. not sure if this can occur but it would be more defensive.
165
148
  // Still cannot find a nice way to do this inside of an invoke besides adding another transition state
166
149
  },
167
150
  onError: {
168
- target: IOID4VCIHolder_1.OID4VCIMachineStates.handleError,
169
- actions: (0, xstate_1.assign)({
151
+ target: OID4VCIMachineStates.handleError,
152
+ actions: assign({
170
153
  error: (_ctx, _event) => ({
171
- title: (0, Localization_1.translate)('oid4vci_machine_credential_selection_error_title'),
154
+ title: translate('oid4vci_machine_credential_selection_error_title'),
172
155
  message: _event.data.message,
173
156
  stack: _event.data.stack,
174
157
  }),
@@ -176,19 +159,19 @@ const createOID4VCIMachine = (opts) => {
176
159
  },
177
160
  },
178
161
  },
179
- [IOID4VCIHolder_1.OID4VCIMachineStates.getContact]: {
180
- id: IOID4VCIHolder_1.OID4VCIMachineStates.getContact,
162
+ [OID4VCIMachineStates.getContact]: {
163
+ id: OID4VCIMachineStates.getContact,
181
164
  invoke: {
182
- src: IOID4VCIHolder_1.OID4VCIMachineServices.getContact,
165
+ src: OID4VCIMachineServices.getContact,
183
166
  onDone: {
184
- target: IOID4VCIHolder_1.OID4VCIMachineStates.getIssuerBranding,
185
- actions: (0, xstate_1.assign)({ contact: (_ctx, _event) => _event.data }),
167
+ target: OID4VCIMachineStates.getIssuerBranding,
168
+ actions: assign({ contact: (_ctx, _event) => _event.data }),
186
169
  },
187
170
  onError: {
188
- target: IOID4VCIHolder_1.OID4VCIMachineStates.handleError,
189
- actions: (0, xstate_1.assign)({
171
+ target: OID4VCIMachineStates.handleError,
172
+ actions: assign({
190
173
  error: (_ctx, _event) => ({
191
- title: (0, Localization_1.translate)('oid4vci_machine_retrieve_contact_error_title'),
174
+ title: translate('oid4vci_machine_retrieve_contact_error_title'),
192
175
  message: _event.data.message,
193
176
  stack: _event.data.stack,
194
177
  }),
@@ -196,30 +179,30 @@ const createOID4VCIMachine = (opts) => {
196
179
  },
197
180
  },
198
181
  },
199
- [IOID4VCIHolder_1.OID4VCIMachineStates.getIssuerBranding]: {
200
- id: IOID4VCIHolder_1.OID4VCIMachineStates.getIssuerBranding,
182
+ [OID4VCIMachineStates.getIssuerBranding]: {
183
+ id: OID4VCIMachineStates.getIssuerBranding,
201
184
  invoke: {
202
- src: IOID4VCIHolder_1.OID4VCIMachineServices.getIssuerBranding,
185
+ src: OID4VCIMachineServices.getIssuerBranding,
203
186
  onDone: [
204
187
  {
205
- target: IOID4VCIHolder_1.OID4VCIMachineStates.getFederationTrust,
206
- cond: IOID4VCIHolder_1.OID4VCIMachineGuards.isOIDFOriginGuard,
207
- actions: (0, xstate_1.assign)({
188
+ target: OID4VCIMachineStates.getFederationTrust,
189
+ cond: OID4VCIMachineGuards.isOIDFOriginGuard,
190
+ actions: assign({
208
191
  issuerBranding: (_ctx, _event) => _event.data,
209
192
  }),
210
193
  },
211
194
  {
212
- target: IOID4VCIHolder_1.OID4VCIMachineStates.transitionFromSetup,
213
- actions: (0, xstate_1.assign)({
195
+ target: OID4VCIMachineStates.transitionFromSetup,
196
+ actions: assign({
214
197
  issuerBranding: (_ctx, _event) => _event.data,
215
198
  }),
216
199
  },
217
200
  ],
218
201
  onError: {
219
- target: IOID4VCIHolder_1.OID4VCIMachineStates.handleError,
220
- actions: (0, xstate_1.assign)({
202
+ target: OID4VCIMachineStates.handleError,
203
+ actions: assign({
221
204
  error: (_ctx, _event) => ({
222
- title: (0, Localization_1.translate)('oid4vci_machine_retrieve_issuer_branding_error_title'),
205
+ title: translate('oid4vci_machine_retrieve_issuer_branding_error_title'),
223
206
  message: _event.data.message,
224
207
  stack: _event.data.stack,
225
208
  }),
@@ -227,21 +210,21 @@ const createOID4VCIMachine = (opts) => {
227
210
  },
228
211
  },
229
212
  },
230
- [IOID4VCIHolder_1.OID4VCIMachineStates.getFederationTrust]: {
231
- id: IOID4VCIHolder_1.OID4VCIMachineStates.getFederationTrust,
213
+ [OID4VCIMachineStates.getFederationTrust]: {
214
+ id: OID4VCIMachineStates.getFederationTrust,
232
215
  invoke: {
233
- src: IOID4VCIHolder_1.OID4VCIMachineServices.getFederationTrust,
216
+ src: OID4VCIMachineServices.getFederationTrust,
234
217
  onDone: {
235
- target: IOID4VCIHolder_1.OID4VCIMachineStates.transitionFromSetup,
236
- actions: (0, xstate_1.assign)({
218
+ target: OID4VCIMachineStates.transitionFromSetup,
219
+ actions: assign({
237
220
  trustedAnchors: (_ctx, _event) => _event.data,
238
221
  }),
239
222
  },
240
223
  onError: {
241
- target: IOID4VCIHolder_1.OID4VCIMachineStates.handleError,
242
- actions: (0, xstate_1.assign)({
224
+ target: OID4VCIMachineStates.handleError,
225
+ actions: assign({
243
226
  error: (_ctx, _event) => ({
244
- title: (0, Localization_1.translate)('oid4vci_machine_retrieve_federation_trust_error_title'),
227
+ title: translate('oid4vci_machine_retrieve_federation_trust_error_title'),
245
228
  message: _event.data.message,
246
229
  stack: _event.data.stack,
247
230
  }),
@@ -249,101 +232,101 @@ const createOID4VCIMachine = (opts) => {
249
232
  },
250
233
  },
251
234
  },
252
- [IOID4VCIHolder_1.OID4VCIMachineStates.transitionFromSetup]: {
253
- id: IOID4VCIHolder_1.OID4VCIMachineStates.transitionFromSetup,
235
+ [OID4VCIMachineStates.transitionFromSetup]: {
236
+ id: OID4VCIMachineStates.transitionFromSetup,
254
237
  always: [
255
238
  {
256
- target: IOID4VCIHolder_1.OID4VCIMachineStates.addContact,
257
- cond: IOID4VCIHolder_1.OID4VCIMachineGuards.hasNoContactGuard,
239
+ target: OID4VCIMachineStates.addContact,
240
+ cond: OID4VCIMachineGuards.hasNoContactGuard,
258
241
  },
259
242
  {
260
- target: IOID4VCIHolder_1.OID4VCIMachineStates.reviewContact,
261
- cond: IOID4VCIHolder_1.OID4VCIMachineGuards.contactHasLowTrustGuard,
243
+ target: OID4VCIMachineStates.reviewContact,
244
+ cond: OID4VCIMachineGuards.contactHasLowTrustGuard,
262
245
  },
263
246
  {
264
- target: IOID4VCIHolder_1.OID4VCIMachineStates.selectCredentials,
265
- cond: IOID4VCIHolder_1.OID4VCIMachineGuards.credentialsToSelectRequiredGuard,
247
+ target: OID4VCIMachineStates.selectCredentials,
248
+ cond: OID4VCIMachineGuards.credentialsToSelectRequiredGuard,
266
249
  },
267
250
  {
268
- target: IOID4VCIHolder_1.OID4VCIMachineStates.startFirstPartApplicationFlow,
269
- cond: IOID4VCIHolder_1.OID4VCIMachineGuards.isFirstPartyApplication,
251
+ target: OID4VCIMachineStates.startFirstPartApplicationFlow,
252
+ cond: OID4VCIMachineGuards.isFirstPartyApplication,
270
253
  },
271
254
  {
272
- target: IOID4VCIHolder_1.OID4VCIMachineStates.initiateAuthorizationRequest,
273
- cond: IOID4VCIHolder_1.OID4VCIMachineGuards.requireAuthorizationGuard,
255
+ target: OID4VCIMachineStates.initiateAuthorizationRequest,
256
+ cond: OID4VCIMachineGuards.requireAuthorizationGuard,
274
257
  },
275
258
  {
276
- target: IOID4VCIHolder_1.OID4VCIMachineStates.verifyPin,
277
- cond: IOID4VCIHolder_1.OID4VCIMachineGuards.requirePinGuard,
259
+ target: OID4VCIMachineStates.verifyPin,
260
+ cond: OID4VCIMachineGuards.requirePinGuard,
278
261
  },
279
262
  {
280
- target: IOID4VCIHolder_1.OID4VCIMachineStates.getCredentials,
263
+ target: OID4VCIMachineStates.getCredentials,
281
264
  },
282
265
  ],
283
266
  on: {
284
- [IOID4VCIHolder_1.OID4VCIMachineEvents.SET_AUTHORIZATION_CODE_URL]: {
285
- actions: (0, xstate_1.assign)({ authorizationCodeURL: (_ctx, _event) => _event.data }),
267
+ [OID4VCIMachineEvents.SET_AUTHORIZATION_CODE_URL]: {
268
+ actions: assign({ authorizationCodeURL: (_ctx, _event) => _event.data }),
286
269
  },
287
270
  },
288
271
  },
289
- [IOID4VCIHolder_1.OID4VCIMachineStates.addContact]: {
290
- id: IOID4VCIHolder_1.OID4VCIMachineStates.addContact,
291
- initial: IOID4VCIHolder_1.OID4VCIMachineAddContactStates.idle,
272
+ [OID4VCIMachineStates.addContact]: {
273
+ id: OID4VCIMachineStates.addContact,
274
+ initial: OID4VCIMachineAddContactStates.idle,
292
275
  on: {
293
- [IOID4VCIHolder_1.OID4VCIMachineEvents.SET_CONTACT_CONSENT]: {
294
- actions: (0, xstate_1.assign)({ hasContactConsent: (_ctx, _event) => _event.data }),
276
+ [OID4VCIMachineEvents.SET_CONTACT_CONSENT]: {
277
+ actions: assign({ hasContactConsent: (_ctx, _event) => _event.data }),
295
278
  },
296
- [IOID4VCIHolder_1.OID4VCIMachineEvents.SET_CONTACT_ALIAS]: {
297
- actions: (0, xstate_1.assign)({ contactAlias: (_ctx, _event) => _event.data }),
279
+ [OID4VCIMachineEvents.SET_CONTACT_ALIAS]: {
280
+ actions: assign({ contactAlias: (_ctx, _event) => _event.data }),
298
281
  },
299
- [IOID4VCIHolder_1.OID4VCIMachineEvents.CREATE_CONTACT]: {
300
- target: `.${IOID4VCIHolder_1.OID4VCIMachineAddContactStates.next}`,
301
- actions: (0, xstate_1.assign)({ contact: (_ctx, _event) => _event.data }),
302
- cond: IOID4VCIHolder_1.OID4VCIMachineGuards.createContactGuard,
282
+ [OID4VCIMachineEvents.CREATE_CONTACT]: {
283
+ target: `.${OID4VCIMachineAddContactStates.next}`,
284
+ actions: assign({ contact: (_ctx, _event) => _event.data }),
285
+ cond: OID4VCIMachineGuards.createContactGuard,
303
286
  },
304
- [IOID4VCIHolder_1.OID4VCIMachineEvents.DECLINE]: {
305
- target: IOID4VCIHolder_1.OID4VCIMachineStates.declined,
287
+ [OID4VCIMachineEvents.DECLINE]: {
288
+ target: OID4VCIMachineStates.declined,
306
289
  },
307
- [IOID4VCIHolder_1.OID4VCIMachineEvents.PREVIOUS]: {
308
- target: IOID4VCIHolder_1.OID4VCIMachineStates.aborted,
290
+ [OID4VCIMachineEvents.PREVIOUS]: {
291
+ target: OID4VCIMachineStates.aborted,
309
292
  },
310
293
  },
311
294
  states: {
312
- [IOID4VCIHolder_1.OID4VCIMachineAddContactStates.idle]: {},
313
- [IOID4VCIHolder_1.OID4VCIMachineAddContactStates.next]: {
295
+ [OID4VCIMachineAddContactStates.idle]: {},
296
+ [OID4VCIMachineAddContactStates.next]: {
314
297
  always: {
315
- target: `#${IOID4VCIHolder_1.OID4VCIMachineStates.storeIssuerBranding}`,
316
- cond: IOID4VCIHolder_1.OID4VCIMachineGuards.hasContactGuard,
298
+ target: `#${OID4VCIMachineStates.storeIssuerBranding}`,
299
+ cond: OID4VCIMachineGuards.hasContactGuard,
317
300
  },
318
301
  },
319
302
  },
320
303
  },
321
- [IOID4VCIHolder_1.OID4VCIMachineStates.reviewContact]: {
322
- id: IOID4VCIHolder_1.OID4VCIMachineStates.reviewContact,
304
+ [OID4VCIMachineStates.reviewContact]: {
305
+ id: OID4VCIMachineStates.reviewContact,
323
306
  on: {
324
- [IOID4VCIHolder_1.OID4VCIMachineEvents.NEXT]: {
325
- target: IOID4VCIHolder_1.OID4VCIMachineStates.transitionFromContactSetup,
307
+ [OID4VCIMachineEvents.NEXT]: {
308
+ target: OID4VCIMachineStates.transitionFromContactSetup,
326
309
  },
327
- [IOID4VCIHolder_1.OID4VCIMachineEvents.DECLINE]: {
328
- target: IOID4VCIHolder_1.OID4VCIMachineStates.declined,
310
+ [OID4VCIMachineEvents.DECLINE]: {
311
+ target: OID4VCIMachineStates.declined,
329
312
  },
330
- [IOID4VCIHolder_1.OID4VCIMachineEvents.PREVIOUS]: {
331
- target: IOID4VCIHolder_1.OID4VCIMachineStates.aborted,
313
+ [OID4VCIMachineEvents.PREVIOUS]: {
314
+ target: OID4VCIMachineStates.aborted,
332
315
  },
333
316
  },
334
317
  },
335
- [IOID4VCIHolder_1.OID4VCIMachineStates.storeIssuerBranding]: {
336
- id: IOID4VCIHolder_1.OID4VCIMachineStates.storeIssuerBranding,
318
+ [OID4VCIMachineStates.storeIssuerBranding]: {
319
+ id: OID4VCIMachineStates.storeIssuerBranding,
337
320
  invoke: {
338
- src: IOID4VCIHolder_1.OID4VCIMachineServices.storeIssuerBranding,
321
+ src: OID4VCIMachineServices.storeIssuerBranding,
339
322
  onDone: {
340
- target: IOID4VCIHolder_1.OID4VCIMachineStates.transitionFromContactSetup,
323
+ target: OID4VCIMachineStates.transitionFromContactSetup,
341
324
  },
342
325
  onError: {
343
- target: IOID4VCIHolder_1.OID4VCIMachineStates.handleError,
344
- actions: (0, xstate_1.assign)({
326
+ target: OID4VCIMachineStates.handleError,
327
+ actions: assign({
345
328
  error: (_ctx, _event) => ({
346
- title: (0, Localization_1.translate)('oid4vci_machine_store_issuer_branding_error_title'),
329
+ title: translate('oid4vci_machine_store_issuer_branding_error_title'),
347
330
  message: _event.data.message,
348
331
  stack: _event.data.stack,
349
332
  }),
@@ -351,199 +334,196 @@ const createOID4VCIMachine = (opts) => {
351
334
  },
352
335
  },
353
336
  },
354
- [IOID4VCIHolder_1.OID4VCIMachineStates.transitionFromContactSetup]: {
355
- id: IOID4VCIHolder_1.OID4VCIMachineStates.transitionFromContactSetup,
337
+ [OID4VCIMachineStates.transitionFromContactSetup]: {
338
+ id: OID4VCIMachineStates.transitionFromContactSetup,
356
339
  always: [
357
340
  {
358
- target: IOID4VCIHolder_1.OID4VCIMachineStates.selectCredentials,
359
- cond: IOID4VCIHolder_1.OID4VCIMachineGuards.credentialsToSelectRequiredGuard,
341
+ target: OID4VCIMachineStates.selectCredentials,
342
+ cond: OID4VCIMachineGuards.credentialsToSelectRequiredGuard,
360
343
  },
361
344
  {
362
- target: IOID4VCIHolder_1.OID4VCIMachineStates.startFirstPartApplicationFlow,
363
- cond: IOID4VCIHolder_1.OID4VCIMachineGuards.isFirstPartyApplication,
345
+ target: OID4VCIMachineStates.startFirstPartApplicationFlow,
346
+ cond: OID4VCIMachineGuards.isFirstPartyApplication,
364
347
  },
365
348
  {
366
- target: IOID4VCIHolder_1.OID4VCIMachineStates.initiateAuthorizationRequest,
367
- cond: IOID4VCIHolder_1.OID4VCIMachineGuards.requireAuthorizationGuard,
349
+ target: OID4VCIMachineStates.initiateAuthorizationRequest,
350
+ cond: OID4VCIMachineGuards.requireAuthorizationGuard,
368
351
  },
369
352
  {
370
- target: IOID4VCIHolder_1.OID4VCIMachineStates.verifyPin,
371
- cond: IOID4VCIHolder_1.OID4VCIMachineGuards.requirePinGuard,
353
+ target: OID4VCIMachineStates.verifyPin,
354
+ cond: OID4VCIMachineGuards.requirePinGuard,
372
355
  },
373
356
  {
374
- target: IOID4VCIHolder_1.OID4VCIMachineStates.getCredentials,
357
+ target: OID4VCIMachineStates.getCredentials,
375
358
  },
376
359
  ],
377
360
  },
378
- [IOID4VCIHolder_1.OID4VCIMachineStates.startFirstPartApplicationFlow]: {
379
- id: IOID4VCIHolder_1.OID4VCIMachineStates.startFirstPartApplicationFlow,
361
+ [OID4VCIMachineStates.startFirstPartApplicationFlow]: {
362
+ id: OID4VCIMachineStates.startFirstPartApplicationFlow,
380
363
  invoke: {
381
- src: IOID4VCIHolder_1.OID4VCIMachineServices.startFirstPartApplicationFlow,
364
+ src: OID4VCIMachineServices.startFirstPartApplicationFlow,
382
365
  onDone: [
383
366
  {
384
- target: IOID4VCIHolder_1.OID4VCIMachineStates.aborted,
385
- cond: (_ctx, _event) => _event.data === FirstPartyMachine_1.FirstPartyMachineStateTypes.aborted,
367
+ target: OID4VCIMachineStates.aborted,
368
+ cond: (_ctx, _event) => _event.data === FirstPartyMachineStateTypes.aborted,
386
369
  },
387
370
  {
388
- target: IOID4VCIHolder_1.OID4VCIMachineStates.declined,
389
- cond: (_ctx, _event) => _event.data === FirstPartyMachine_1.FirstPartyMachineStateTypes.declined,
371
+ target: OID4VCIMachineStates.declined,
372
+ cond: (_ctx, _event) => _event.data === FirstPartyMachineStateTypes.declined,
390
373
  },
391
374
  {
392
- target: IOID4VCIHolder_1.OID4VCIMachineStates.getCredentials,
393
- actions: (0, xstate_1.assign)({
375
+ target: OID4VCIMachineStates.getCredentials,
376
+ actions: assign({
394
377
  openID4VCIClientState: (_ctx, _event) => {
395
- const authorizationCodeResponse = (0, oid4vci_common_1.toAuthorizationResponsePayload)(_event.data);
396
- return Object.assign(Object.assign({}, _ctx.openID4VCIClientState), { authorizationCodeResponse });
397
- }
398
- })
399
- }
378
+ const authorizationCodeResponse = toAuthorizationResponsePayload(_event.data);
379
+ return { ..._ctx.openID4VCIClientState, authorizationCodeResponse };
380
+ },
381
+ }),
382
+ },
400
383
  ],
401
384
  onError: {
402
- target: IOID4VCIHolder_1.OID4VCIMachineStates.handleError,
403
- actions: (0, xstate_1.assign)({
404
- error: (_ctx, _event) => {
405
- var _a;
406
- return ({
407
- title: (_a = _event.data.title) !== null && _a !== void 0 ? _a : (0, Localization_1.translate)('oid4vci_machine_first_party_error_title'),
408
- message: _event.data.message,
409
- stack: _event.data.stack,
410
- });
411
- },
385
+ target: OID4VCIMachineStates.handleError,
386
+ actions: assign({
387
+ error: (_ctx, _event) => ({
388
+ title: _event.data.title ?? translate('oid4vci_machine_first_party_error_title'),
389
+ message: _event.data.message,
390
+ stack: _event.data.stack,
391
+ }),
412
392
  }),
413
393
  },
414
394
  },
415
395
  },
416
- [IOID4VCIHolder_1.OID4VCIMachineStates.selectCredentials]: {
417
- id: IOID4VCIHolder_1.OID4VCIMachineStates.selectCredentials,
396
+ [OID4VCIMachineStates.selectCredentials]: {
397
+ id: OID4VCIMachineStates.selectCredentials,
418
398
  on: {
419
- [IOID4VCIHolder_1.OID4VCIMachineEvents.SET_SELECTED_CREDENTIALS]: {
420
- actions: (0, xstate_1.assign)({ selectedCredentials: (_ctx, _event) => _event.data }),
399
+ [OID4VCIMachineEvents.SET_SELECTED_CREDENTIALS]: {
400
+ actions: assign({ selectedCredentials: (_ctx, _event) => _event.data }),
421
401
  },
422
- [IOID4VCIHolder_1.OID4VCIMachineEvents.NEXT]: {
423
- target: IOID4VCIHolder_1.OID4VCIMachineStates.transitionFromSelectingCredentials,
424
- cond: IOID4VCIHolder_1.OID4VCIMachineGuards.hasSelectedCredentialsGuard,
402
+ [OID4VCIMachineEvents.NEXT]: {
403
+ target: OID4VCIMachineStates.transitionFromSelectingCredentials,
404
+ cond: OID4VCIMachineGuards.hasSelectedCredentialsGuard,
425
405
  },
426
- [IOID4VCIHolder_1.OID4VCIMachineEvents.PREVIOUS]: {
427
- target: IOID4VCIHolder_1.OID4VCIMachineStates.aborted,
406
+ [OID4VCIMachineEvents.PREVIOUS]: {
407
+ target: OID4VCIMachineStates.aborted,
428
408
  },
429
409
  },
430
410
  },
431
- [IOID4VCIHolder_1.OID4VCIMachineStates.transitionFromSelectingCredentials]: {
432
- id: IOID4VCIHolder_1.OID4VCIMachineStates.transitionFromSelectingCredentials,
411
+ [OID4VCIMachineStates.transitionFromSelectingCredentials]: {
412
+ id: OID4VCIMachineStates.transitionFromSelectingCredentials,
433
413
  always: [
434
414
  {
435
- target: IOID4VCIHolder_1.OID4VCIMachineStates.startFirstPartApplicationFlow,
436
- cond: IOID4VCIHolder_1.OID4VCIMachineGuards.isFirstPartyApplication,
415
+ target: OID4VCIMachineStates.startFirstPartApplicationFlow,
416
+ cond: OID4VCIMachineGuards.isFirstPartyApplication,
437
417
  },
438
418
  {
439
- target: IOID4VCIHolder_1.OID4VCIMachineStates.verifyPin,
440
- cond: IOID4VCIHolder_1.OID4VCIMachineGuards.requirePinGuard,
419
+ target: OID4VCIMachineStates.verifyPin,
420
+ cond: OID4VCIMachineGuards.requirePinGuard,
441
421
  },
442
422
  {
443
- target: IOID4VCIHolder_1.OID4VCIMachineStates.initiateAuthorizationRequest,
444
- cond: IOID4VCIHolder_1.OID4VCIMachineGuards.requireAuthorizationGuard,
423
+ target: OID4VCIMachineStates.initiateAuthorizationRequest,
424
+ cond: OID4VCIMachineGuards.requireAuthorizationGuard,
445
425
  },
446
426
  {
447
- target: IOID4VCIHolder_1.OID4VCIMachineStates.getCredentials,
427
+ target: OID4VCIMachineStates.getCredentials,
448
428
  },
449
429
  ],
450
430
  },
451
- [IOID4VCIHolder_1.OID4VCIMachineStates.initiateAuthorizationRequest]: {
452
- id: IOID4VCIHolder_1.OID4VCIMachineStates.initiateAuthorizationRequest,
431
+ [OID4VCIMachineStates.initiateAuthorizationRequest]: {
432
+ id: OID4VCIMachineStates.initiateAuthorizationRequest,
453
433
  on: {
454
- [IOID4VCIHolder_1.OID4VCIMachineEvents.PREVIOUS]: {
455
- target: IOID4VCIHolder_1.OID4VCIMachineStates.selectCredentials,
434
+ [OID4VCIMachineEvents.PREVIOUS]: {
435
+ target: OID4VCIMachineStates.selectCredentials,
456
436
  },
457
- [IOID4VCIHolder_1.OID4VCIMachineEvents.INVOKED_AUTHORIZATION_CODE_REQUEST]: {
458
- target: IOID4VCIHolder_1.OID4VCIMachineStates.waitForAuthorizationResponse,
437
+ [OID4VCIMachineEvents.INVOKED_AUTHORIZATION_CODE_REQUEST]: {
438
+ target: OID4VCIMachineStates.waitForAuthorizationResponse,
459
439
  },
460
440
  },
461
441
  },
462
- [IOID4VCIHolder_1.OID4VCIMachineStates.waitForAuthorizationResponse]: {
463
- id: IOID4VCIHolder_1.OID4VCIMachineStates.waitForAuthorizationResponse,
442
+ [OID4VCIMachineStates.waitForAuthorizationResponse]: {
443
+ id: OID4VCIMachineStates.waitForAuthorizationResponse,
464
444
  on: {
465
- [IOID4VCIHolder_1.OID4VCIMachineEvents.PREVIOUS]: {
466
- target: IOID4VCIHolder_1.OID4VCIMachineStates.initiateAuthorizationRequest,
445
+ [OID4VCIMachineEvents.PREVIOUS]: {
446
+ target: OID4VCIMachineStates.initiateAuthorizationRequest,
467
447
  },
468
- [IOID4VCIHolder_1.OID4VCIMachineEvents.PROVIDE_AUTHORIZATION_CODE_RESPONSE]: {
469
- actions: (0, xstate_1.assign)({
448
+ [OID4VCIMachineEvents.PROVIDE_AUTHORIZATION_CODE_RESPONSE]: {
449
+ actions: assign({
470
450
  openID4VCIClientState: (_ctx, _event) => {
471
- const authorizationCodeResponse = (0, oid4vci_common_1.toAuthorizationResponsePayload)(_event.data);
472
- return Object.assign(Object.assign({}, _ctx.openID4VCIClientState), { authorizationCodeResponse });
451
+ const authorizationCodeResponse = toAuthorizationResponsePayload(_event.data);
452
+ return { ..._ctx.openID4VCIClientState, authorizationCodeResponse };
473
453
  },
474
454
  }),
475
455
  },
476
456
  },
477
457
  always: [
478
458
  {
479
- cond: IOID4VCIHolder_1.OID4VCIMachineGuards.hasAuthorizationResponse,
480
- target: IOID4VCIHolder_1.OID4VCIMachineStates.getCredentials,
459
+ cond: OID4VCIMachineGuards.hasAuthorizationResponse,
460
+ target: OID4VCIMachineStates.getCredentials,
481
461
  },
482
462
  ],
483
463
  },
484
- [IOID4VCIHolder_1.OID4VCIMachineStates.verifyPin]: {
485
- id: IOID4VCIHolder_1.OID4VCIMachineStates.verifyPin,
486
- initial: IOID4VCIHolder_1.OID4VCIMachineVerifyPinStates.idle,
464
+ [OID4VCIMachineStates.verifyPin]: {
465
+ id: OID4VCIMachineStates.verifyPin,
466
+ initial: OID4VCIMachineVerifyPinStates.idle,
487
467
  on: {
488
- [IOID4VCIHolder_1.OID4VCIMachineEvents.SET_VERIFICATION_CODE]: {
489
- target: `.${IOID4VCIHolder_1.OID4VCIMachineVerifyPinStates.next}`,
490
- actions: (0, xstate_1.assign)({ verificationCode: (_ctx, _event) => _event.data }),
468
+ [OID4VCIMachineEvents.SET_VERIFICATION_CODE]: {
469
+ target: `.${OID4VCIMachineVerifyPinStates.next}`,
470
+ actions: assign({ verificationCode: (_ctx, _event) => _event.data }),
491
471
  },
492
- [IOID4VCIHolder_1.OID4VCIMachineEvents.PREVIOUS]: [
472
+ [OID4VCIMachineEvents.PREVIOUS]: [
493
473
  {
494
- target: IOID4VCIHolder_1.OID4VCIMachineStates.selectCredentials,
495
- cond: IOID4VCIHolder_1.OID4VCIMachineGuards.credentialsToSelectRequiredGuard,
474
+ target: OID4VCIMachineStates.selectCredentials,
475
+ cond: OID4VCIMachineGuards.credentialsToSelectRequiredGuard,
496
476
  },
497
477
  {
498
- target: IOID4VCIHolder_1.OID4VCIMachineStates.aborted,
478
+ target: OID4VCIMachineStates.aborted,
499
479
  },
500
480
  ],
501
481
  },
502
482
  states: {
503
- [IOID4VCIHolder_1.OID4VCIMachineVerifyPinStates.idle]: {},
504
- [IOID4VCIHolder_1.OID4VCIMachineVerifyPinStates.next]: {
483
+ [OID4VCIMachineVerifyPinStates.idle]: {},
484
+ [OID4VCIMachineVerifyPinStates.next]: {
505
485
  always: {
506
- target: `#${IOID4VCIHolder_1.OID4VCIMachineStates.getCredentials}`,
507
- cond: IOID4VCIHolder_1.OID4VCIMachineGuards.verificationCodeGuard,
486
+ target: `#${OID4VCIMachineStates.getCredentials}`,
487
+ cond: OID4VCIMachineGuards.verificationCodeGuard,
508
488
  },
509
489
  },
510
490
  },
511
491
  },
512
- [IOID4VCIHolder_1.OID4VCIMachineStates.getCredentials]: {
513
- id: IOID4VCIHolder_1.OID4VCIMachineStates.getCredentials,
492
+ [OID4VCIMachineStates.getCredentials]: {
493
+ id: OID4VCIMachineStates.getCredentials,
514
494
  invoke: {
515
- src: IOID4VCIHolder_1.OID4VCIMachineServices.getCredentials,
495
+ src: OID4VCIMachineServices.getCredentials,
516
496
  onDone: {
517
- target: IOID4VCIHolder_1.OID4VCIMachineStates.verifyCredentials,
518
- actions: (0, xstate_1.assign)({
497
+ target: OID4VCIMachineStates.verifyCredentials,
498
+ actions: assign({
519
499
  credentialsToAccept: (_ctx, _event) => _event.data,
520
500
  }),
521
501
  },
522
502
  onError: {
523
- target: IOID4VCIHolder_1.OID4VCIMachineStates.handleError,
524
- actions: (0, xstate_1.assign)({
503
+ target: OID4VCIMachineStates.handleError,
504
+ actions: assign({
525
505
  error: (_ctx, _event) => ({
526
- title: (0, Localization_1.translate)('oid4vci_machine_retrieve_credentials_error_title'),
506
+ title: translate('oid4vci_machine_retrieve_credentials_error_title'),
527
507
  message: _event.data.message,
528
508
  stack: _event.data.stack,
529
509
  }),
530
510
  }),
531
511
  },
532
512
  },
533
- exit: (0, xstate_1.assign)({ verificationCode: undefined }),
513
+ exit: assign({ verificationCode: undefined }),
534
514
  },
535
- [IOID4VCIHolder_1.OID4VCIMachineStates.verifyCredentials]: {
536
- id: IOID4VCIHolder_1.OID4VCIMachineStates.verifyCredentials,
515
+ [OID4VCIMachineStates.verifyCredentials]: {
516
+ id: OID4VCIMachineStates.verifyCredentials,
537
517
  invoke: {
538
- src: IOID4VCIHolder_1.OID4VCIMachineServices.assertValidCredentials,
518
+ src: OID4VCIMachineServices.assertValidCredentials,
539
519
  onDone: {
540
- target: IOID4VCIHolder_1.OID4VCIMachineStates.transitionFromWalletInput,
520
+ target: OID4VCIMachineStates.transitionFromWalletInput,
541
521
  },
542
522
  onError: {
543
- target: IOID4VCIHolder_1.OID4VCIMachineStates.handleError,
544
- actions: (0, xstate_1.assign)({
523
+ target: OID4VCIMachineStates.handleError,
524
+ actions: assign({
545
525
  error: (_ctx, _event) => ({
546
- title: (0, Localization_1.translate)('oid4vci_machine_verify_credentials_error_title'),
526
+ title: translate('oid4vci_machine_verify_credentials_error_title'),
547
527
  message: _event.data.message,
548
528
  stack: _event.data.stack,
549
529
  }),
@@ -551,34 +531,33 @@ const createOID4VCIMachine = (opts) => {
551
531
  },
552
532
  },
553
533
  },
554
- [IOID4VCIHolder_1.OID4VCIMachineStates.transitionFromWalletInput]: {
555
- id: IOID4VCIHolder_1.OID4VCIMachineStates.transitionFromWalletInput,
534
+ [OID4VCIMachineStates.transitionFromWalletInput]: {
535
+ id: OID4VCIMachineStates.transitionFromWalletInput,
556
536
  always: [
557
537
  {
558
- target: IOID4VCIHolder_1.OID4VCIMachineStates.addContactIdentity,
559
- cond: IOID4VCIHolder_1.OID4VCIMachineGuards.hasNoContactIdentityGuard,
538
+ target: OID4VCIMachineStates.addContactIdentity,
539
+ cond: OID4VCIMachineGuards.hasNoContactIdentityGuard,
560
540
  },
561
541
  {
562
- target: IOID4VCIHolder_1.OID4VCIMachineStates.reviewCredentials,
542
+ target: OID4VCIMachineStates.reviewCredentials,
563
543
  },
564
544
  ],
565
545
  },
566
- [IOID4VCIHolder_1.OID4VCIMachineStates.addContactIdentity]: {
567
- id: IOID4VCIHolder_1.OID4VCIMachineStates.addContactIdentity,
546
+ [OID4VCIMachineStates.addContactIdentity]: {
547
+ id: OID4VCIMachineStates.addContactIdentity,
568
548
  invoke: {
569
- src: IOID4VCIHolder_1.OID4VCIMachineServices.addContactIdentity,
549
+ src: OID4VCIMachineServices.addContactIdentity,
570
550
  onDone: {
571
- target: IOID4VCIHolder_1.OID4VCIMachineStates.addIssuerBrandingAfterIdentity,
551
+ target: OID4VCIMachineStates.addIssuerBrandingAfterIdentity,
572
552
  actions: (_ctx, _event) => {
573
- var _a;
574
- (_a = _ctx.contact) === null || _a === void 0 ? void 0 : _a.identities.push(_event.data);
553
+ _ctx.contact?.identities.push(_event.data);
575
554
  },
576
555
  },
577
556
  onError: {
578
- target: IOID4VCIHolder_1.OID4VCIMachineStates.handleError,
579
- actions: (0, xstate_1.assign)({
557
+ target: OID4VCIMachineStates.handleError,
558
+ actions: assign({
580
559
  error: (_ctx, _event) => ({
581
- title: (0, Localization_1.translate)('oid4vci_machine_add_contact_identity_error_title'),
560
+ title: translate('oid4vci_machine_add_contact_identity_error_title'),
582
561
  message: _event.data.message,
583
562
  stack: _event.data.stack,
584
563
  }),
@@ -586,18 +565,18 @@ const createOID4VCIMachine = (opts) => {
586
565
  },
587
566
  },
588
567
  },
589
- [IOID4VCIHolder_1.OID4VCIMachineStates.addIssuerBrandingAfterIdentity]: {
590
- id: IOID4VCIHolder_1.OID4VCIMachineStates.addIssuerBrandingAfterIdentity,
568
+ [OID4VCIMachineStates.addIssuerBrandingAfterIdentity]: {
569
+ id: OID4VCIMachineStates.addIssuerBrandingAfterIdentity,
591
570
  invoke: {
592
- src: IOID4VCIHolder_1.OID4VCIMachineServices.storeIssuerBranding,
571
+ src: OID4VCIMachineServices.storeIssuerBranding,
593
572
  onDone: {
594
- target: IOID4VCIHolder_1.OID4VCIMachineStates.reviewCredentials,
573
+ target: OID4VCIMachineStates.reviewCredentials,
595
574
  },
596
575
  onError: {
597
- target: IOID4VCIHolder_1.OID4VCIMachineStates.handleError,
598
- actions: (0, xstate_1.assign)({
576
+ target: OID4VCIMachineStates.handleError,
577
+ actions: assign({
599
578
  error: (_ctx, _event) => ({
600
- title: (0, Localization_1.translate)('oid4vci_machine_store_issuer_branding_error_title'),
579
+ title: translate('oid4vci_machine_store_issuer_branding_error_title'),
601
580
  message: _event.data.message,
602
581
  stack: _event.data.stack,
603
582
  }),
@@ -605,32 +584,32 @@ const createOID4VCIMachine = (opts) => {
605
584
  },
606
585
  },
607
586
  },
608
- [IOID4VCIHolder_1.OID4VCIMachineStates.reviewCredentials]: {
609
- id: IOID4VCIHolder_1.OID4VCIMachineStates.reviewCredentials,
587
+ [OID4VCIMachineStates.reviewCredentials]: {
588
+ id: OID4VCIMachineStates.reviewCredentials,
610
589
  on: {
611
- [IOID4VCIHolder_1.OID4VCIMachineEvents.NEXT]: {
612
- target: IOID4VCIHolder_1.OID4VCIMachineStates.storeCredentialBranding,
590
+ [OID4VCIMachineEvents.NEXT]: {
591
+ target: OID4VCIMachineStates.storeCredentialBranding,
613
592
  },
614
- [IOID4VCIHolder_1.OID4VCIMachineEvents.DECLINE]: {
615
- target: IOID4VCIHolder_1.OID4VCIMachineStates.declined,
593
+ [OID4VCIMachineEvents.DECLINE]: {
594
+ target: OID4VCIMachineStates.declined,
616
595
  },
617
- [IOID4VCIHolder_1.OID4VCIMachineEvents.PREVIOUS]: {
618
- target: IOID4VCIHolder_1.OID4VCIMachineStates.aborted,
596
+ [OID4VCIMachineEvents.PREVIOUS]: {
597
+ target: OID4VCIMachineStates.aborted,
619
598
  },
620
599
  },
621
600
  },
622
- [IOID4VCIHolder_1.OID4VCIMachineStates.storeCredentialBranding]: {
623
- id: IOID4VCIHolder_1.OID4VCIMachineStates.storeCredentialBranding,
601
+ [OID4VCIMachineStates.storeCredentialBranding]: {
602
+ id: OID4VCIMachineStates.storeCredentialBranding,
624
603
  invoke: {
625
- src: IOID4VCIHolder_1.OID4VCIMachineServices.storeCredentialBranding,
604
+ src: OID4VCIMachineServices.storeCredentialBranding,
626
605
  onDone: {
627
- target: IOID4VCIHolder_1.OID4VCIMachineStates.storeCredentials,
606
+ target: OID4VCIMachineStates.storeCredentials,
628
607
  },
629
608
  onError: {
630
- target: IOID4VCIHolder_1.OID4VCIMachineStates.handleError,
631
- actions: (0, xstate_1.assign)({
609
+ target: OID4VCIMachineStates.handleError,
610
+ actions: assign({
632
611
  error: (_ctx, _event) => ({
633
- title: (0, Localization_1.translate)('oid4vci_machine_store_credential_branding_error_title'),
612
+ title: translate('oid4vci_machine_store_credential_branding_error_title'),
634
613
  message: _event.data.message,
635
614
  stack: _event.data.stack,
636
615
  }),
@@ -638,18 +617,18 @@ const createOID4VCIMachine = (opts) => {
638
617
  },
639
618
  },
640
619
  },
641
- [IOID4VCIHolder_1.OID4VCIMachineStates.storeCredentials]: {
642
- id: IOID4VCIHolder_1.OID4VCIMachineStates.storeCredentials,
620
+ [OID4VCIMachineStates.storeCredentials]: {
621
+ id: OID4VCIMachineStates.storeCredentials,
643
622
  invoke: {
644
- src: IOID4VCIHolder_1.OID4VCIMachineServices.storeCredentials,
623
+ src: OID4VCIMachineServices.storeCredentials,
645
624
  onDone: {
646
- target: IOID4VCIHolder_1.OID4VCIMachineStates.done,
625
+ target: OID4VCIMachineStates.done,
647
626
  },
648
627
  onError: {
649
- target: IOID4VCIHolder_1.OID4VCIMachineStates.handleError,
650
- actions: (0, xstate_1.assign)({
628
+ target: OID4VCIMachineStates.handleError,
629
+ actions: assign({
651
630
  error: (_ctx, _event) => ({
652
- title: (0, Localization_1.translate)('oid4vci_machine_store_credential_error_title'),
631
+ title: translate('oid4vci_machine_store_credential_error_title'),
653
632
  message: _event.data.message,
654
633
  stack: _event.data.stack,
655
634
  }),
@@ -657,71 +636,73 @@ const createOID4VCIMachine = (opts) => {
657
636
  },
658
637
  },
659
638
  },
660
- [IOID4VCIHolder_1.OID4VCIMachineStates.handleError]: {
661
- id: IOID4VCIHolder_1.OID4VCIMachineStates.handleError,
639
+ [OID4VCIMachineStates.handleError]: {
640
+ id: OID4VCIMachineStates.handleError,
662
641
  on: {
663
- [IOID4VCIHolder_1.OID4VCIMachineEvents.NEXT]: {
664
- target: IOID4VCIHolder_1.OID4VCIMachineStates.error,
642
+ [OID4VCIMachineEvents.NEXT]: {
643
+ target: OID4VCIMachineStates.error,
665
644
  },
666
- [IOID4VCIHolder_1.OID4VCIMachineEvents.PREVIOUS]: {
667
- target: IOID4VCIHolder_1.OID4VCIMachineStates.error,
645
+ [OID4VCIMachineEvents.PREVIOUS]: {
646
+ target: OID4VCIMachineStates.error,
668
647
  },
669
648
  },
670
649
  },
671
- [IOID4VCIHolder_1.OID4VCIMachineStates.aborted]: {
672
- id: IOID4VCIHolder_1.OID4VCIMachineStates.aborted,
650
+ [OID4VCIMachineStates.aborted]: {
651
+ id: OID4VCIMachineStates.aborted,
673
652
  type: 'final',
674
653
  },
675
- [IOID4VCIHolder_1.OID4VCIMachineStates.declined]: {
676
- id: IOID4VCIHolder_1.OID4VCIMachineStates.declined,
654
+ [OID4VCIMachineStates.declined]: {
655
+ id: OID4VCIMachineStates.declined,
677
656
  type: 'final',
678
657
  },
679
- [IOID4VCIHolder_1.OID4VCIMachineStates.error]: {
680
- id: IOID4VCIHolder_1.OID4VCIMachineStates.error,
658
+ [OID4VCIMachineStates.error]: {
659
+ id: OID4VCIMachineStates.error,
681
660
  type: 'final',
682
661
  },
683
- [IOID4VCIHolder_1.OID4VCIMachineStates.done]: {
684
- id: IOID4VCIHolder_1.OID4VCIMachineStates.done,
662
+ [OID4VCIMachineStates.done]: {
663
+ id: OID4VCIMachineStates.done,
685
664
  type: 'final',
686
665
  },
687
666
  },
688
667
  });
689
668
  };
690
- class OID4VCIMachine {
691
- static newInstance(opts, context) {
692
- return __awaiter(this, void 0, void 0, function* () {
693
- const interpreter = (0, xstate_1.interpret)(createOID4VCIMachine(opts).withConfig({
694
- services: Object.assign({}, opts === null || opts === void 0 ? void 0 : opts.services),
695
- guards: Object.assign({ oid4vciHasNoContactGuard,
696
- oid4vciCredentialsToSelectRequiredGuard,
697
- oid4vciRequirePinGuard,
698
- oid4vciHasNoContactIdentityGuard,
699
- oid4vciVerificationCodeGuard,
700
- oid4vciHasContactGuard,
701
- oid4vciCreateContactGuard,
702
- oid4vciHasSelectedCredentialsGuard,
703
- oid4vciRequireAuthorizationGuard,
704
- oid4vciNoAuthorizationGuard,
705
- oid4vciHasAuthorizationResponse,
706
- oid4vciIsOIDFOriginGuard,
707
- oid4vciContactHasLowTrustGuard,
708
- oid4vciIsFirstPartyApplication }, opts === null || opts === void 0 ? void 0 : opts.guards),
709
- }));
710
- if (typeof (opts === null || opts === void 0 ? void 0 : opts.subscription) === 'function') {
711
- interpreter.onTransition(opts.subscription);
712
- }
713
- if ((opts === null || opts === void 0 ? void 0 : opts.requireCustomNavigationHook) !== true) {
714
- if (typeof (opts === null || opts === void 0 ? void 0 : opts.stateNavigationListener) === 'function') {
715
- interpreter.onTransition((snapshot) => {
716
- if (opts === null || opts === void 0 ? void 0 : opts.stateNavigationListener) {
717
- opts.stateNavigationListener(interpreter, snapshot);
718
- }
719
- });
720
- }
669
+ export class OID4VCIMachine {
670
+ static async newInstance(opts, context) {
671
+ const interpreter = interpret(createOID4VCIMachine(opts).withConfig({
672
+ services: {
673
+ ...opts?.services,
674
+ },
675
+ guards: {
676
+ oid4vciHasNoContactGuard,
677
+ oid4vciCredentialsToSelectRequiredGuard,
678
+ oid4vciRequirePinGuard,
679
+ oid4vciHasNoContactIdentityGuard,
680
+ oid4vciVerificationCodeGuard,
681
+ oid4vciHasContactGuard,
682
+ oid4vciCreateContactGuard,
683
+ oid4vciHasSelectedCredentialsGuard,
684
+ oid4vciRequireAuthorizationGuard,
685
+ oid4vciNoAuthorizationGuard,
686
+ oid4vciHasAuthorizationResponse,
687
+ oid4vciIsOIDFOriginGuard,
688
+ oid4vciContactHasLowTrustGuard,
689
+ oid4vciIsFirstPartyApplication,
690
+ ...opts?.guards,
691
+ },
692
+ }));
693
+ if (typeof opts?.subscription === 'function') {
694
+ interpreter.onTransition(opts.subscription);
695
+ }
696
+ if (opts?.requireCustomNavigationHook !== true) {
697
+ if (typeof opts?.stateNavigationListener === 'function') {
698
+ interpreter.onTransition((snapshot) => {
699
+ if (opts?.stateNavigationListener) {
700
+ opts.stateNavigationListener(interpreter, snapshot);
701
+ }
702
+ });
721
703
  }
722
- return { interpreter };
723
- });
704
+ }
705
+ return { interpreter };
724
706
  }
725
707
  }
726
- exports.OID4VCIMachine = OID4VCIMachine;
727
708
  //# sourceMappingURL=oid4vciMachine.js.map