@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.
- package/dist/agent/OID4VCIHolder.d.ts +1 -0
- package/dist/agent/OID4VCIHolder.d.ts.map +1 -1
- package/dist/agent/OID4VCIHolder.js +733 -721
- package/dist/agent/OID4VCIHolder.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -27
- package/dist/index.js.map +1 -1
- package/dist/link-handler/index.d.ts.map +1 -1
- package/dist/link-handler/index.js +55 -49
- package/dist/link-handler/index.js.map +1 -1
- package/dist/listeners/headlessStateNavListener.js +7 -20
- package/dist/listeners/headlessStateNavListener.js.map +1 -1
- package/dist/localization/Localization.js +38 -43
- package/dist/localization/Localization.js.map +1 -1
- package/dist/machines/firstPartyMachine.d.ts.map +1 -1
- package/dist/machines/firstPartyMachine.js +89 -88
- package/dist/machines/firstPartyMachine.js.map +1 -1
- package/dist/machines/oid4vciMachine.d.ts.map +1 -1
- package/dist/machines/oid4vciMachine.js +307 -326
- package/dist/machines/oid4vciMachine.js.map +1 -1
- package/dist/mappers/OIDC4VCIBrandingMapper.d.ts.map +1 -1
- package/dist/mappers/OIDC4VCIBrandingMapper.js +164 -136
- package/dist/mappers/OIDC4VCIBrandingMapper.js.map +1 -1
- package/dist/services/FirstPartyMachineServices.d.ts.map +1 -1
- package/dist/services/FirstPartyMachineServices.js +20 -30
- package/dist/services/FirstPartyMachineServices.js.map +1 -1
- package/dist/services/OID4VCIHolderService.d.ts.map +1 -1
- package/dist/services/OID4VCIHolderService.js +147 -154
- package/dist/services/OID4VCIHolderService.js.map +1 -1
- package/dist/types/FirstPartyMachine.d.ts.map +1 -1
- package/dist/types/FirstPartyMachine.js +6 -9
- package/dist/types/FirstPartyMachine.js.map +1 -1
- package/dist/types/IOID4VCIHolder.d.ts +6 -6
- package/dist/types/IOID4VCIHolder.d.ts.map +1 -1
- package/dist/types/IOID4VCIHolder.js +20 -23
- package/dist/types/IOID4VCIHolder.js.map +1 -1
- package/package.json +26 -25
- package/src/agent/OID4VCIHolder.ts +33 -11
- package/src/index.ts +1 -0
- package/src/link-handler/index.ts +6 -8
- package/src/machines/firstPartyMachine.ts +60 -69
- package/src/machines/oid4vciMachine.ts +9 -11
- package/src/mappers/OIDC4VCIBrandingMapper.ts +26 -25
- package/src/services/FirstPartyMachineServices.ts +11 -10
- package/src/services/OID4VCIHolderService.ts +25 -24
- package/src/types/FirstPartyMachine.ts +56 -64
- package/src/types/IOID4VCIHolder.ts +35 -32
|
@@ -1,20 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
|
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 !
|
|
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 !
|
|
66
|
+
return !ctx.openID4VCIClientState?.authorizationCodeResponse;
|
|
81
67
|
}
|
|
82
|
-
else if (
|
|
83
|
-
return !
|
|
68
|
+
else if (openID4VCIClientState.credentialOffer?.supportedFlows?.includes(AuthzFlowType.AUTHORIZATION_CODE_FLOW)) {
|
|
69
|
+
return !ctx.openID4VCIClientState?.authorizationCodeResponse;
|
|
84
70
|
}
|
|
85
|
-
else if (
|
|
71
|
+
else if (openID4VCIClientState.credentialOffer?.supportedFlows?.includes(AuthzFlowType.PRE_AUTHORIZED_CODE_FLOW)) {
|
|
86
72
|
return false;
|
|
87
73
|
}
|
|
88
|
-
else if (
|
|
89
|
-
return !
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
106
|
-
requestData: opts
|
|
107
|
-
trustAnchors:
|
|
108
|
-
issuanceOpt: opts
|
|
109
|
-
didMethodPreferences: opts
|
|
110
|
-
locale: opts
|
|
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
|
|
119
|
-
id:
|
|
101
|
+
return createMachine({
|
|
102
|
+
id: opts?.machineName ?? 'OID4VCIHolder',
|
|
120
103
|
predictableActionArguments: true,
|
|
121
|
-
initial:
|
|
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
|
-
[
|
|
130
|
-
id:
|
|
112
|
+
[OID4VCIMachineStates.start]: {
|
|
113
|
+
id: OID4VCIMachineStates.start,
|
|
131
114
|
invoke: {
|
|
132
|
-
src:
|
|
115
|
+
src: OID4VCIMachineServices.start,
|
|
133
116
|
onDone: {
|
|
134
|
-
target:
|
|
135
|
-
actions:
|
|
117
|
+
target: OID4VCIMachineStates.createCredentialsToSelectFrom,
|
|
118
|
+
actions: assign({
|
|
136
119
|
authorizationCodeURL: (_ctx, _event) => _event.data.authorizationCodeURL,
|
|
137
|
-
credentialBranding: (_ctx, _event) =>
|
|
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:
|
|
145
|
-
actions:
|
|
127
|
+
target: OID4VCIMachineStates.handleError,
|
|
128
|
+
actions: assign({
|
|
146
129
|
error: (_ctx, _event) => ({
|
|
147
|
-
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
|
-
[
|
|
156
|
-
id:
|
|
138
|
+
[OID4VCIMachineStates.createCredentialsToSelectFrom]: {
|
|
139
|
+
id: OID4VCIMachineStates.createCredentialsToSelectFrom,
|
|
157
140
|
invoke: {
|
|
158
|
-
src:
|
|
141
|
+
src: OID4VCIMachineServices.createCredentialsToSelectFrom,
|
|
159
142
|
onDone: {
|
|
160
|
-
target:
|
|
161
|
-
actions:
|
|
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:
|
|
169
|
-
actions:
|
|
151
|
+
target: OID4VCIMachineStates.handleError,
|
|
152
|
+
actions: assign({
|
|
170
153
|
error: (_ctx, _event) => ({
|
|
171
|
-
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
|
-
[
|
|
180
|
-
id:
|
|
162
|
+
[OID4VCIMachineStates.getContact]: {
|
|
163
|
+
id: OID4VCIMachineStates.getContact,
|
|
181
164
|
invoke: {
|
|
182
|
-
src:
|
|
165
|
+
src: OID4VCIMachineServices.getContact,
|
|
183
166
|
onDone: {
|
|
184
|
-
target:
|
|
185
|
-
actions:
|
|
167
|
+
target: OID4VCIMachineStates.getIssuerBranding,
|
|
168
|
+
actions: assign({ contact: (_ctx, _event) => _event.data }),
|
|
186
169
|
},
|
|
187
170
|
onError: {
|
|
188
|
-
target:
|
|
189
|
-
actions:
|
|
171
|
+
target: OID4VCIMachineStates.handleError,
|
|
172
|
+
actions: assign({
|
|
190
173
|
error: (_ctx, _event) => ({
|
|
191
|
-
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
|
-
[
|
|
200
|
-
id:
|
|
182
|
+
[OID4VCIMachineStates.getIssuerBranding]: {
|
|
183
|
+
id: OID4VCIMachineStates.getIssuerBranding,
|
|
201
184
|
invoke: {
|
|
202
|
-
src:
|
|
185
|
+
src: OID4VCIMachineServices.getIssuerBranding,
|
|
203
186
|
onDone: [
|
|
204
187
|
{
|
|
205
|
-
target:
|
|
206
|
-
cond:
|
|
207
|
-
actions:
|
|
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:
|
|
213
|
-
actions:
|
|
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:
|
|
220
|
-
actions:
|
|
202
|
+
target: OID4VCIMachineStates.handleError,
|
|
203
|
+
actions: assign({
|
|
221
204
|
error: (_ctx, _event) => ({
|
|
222
|
-
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
|
-
[
|
|
231
|
-
id:
|
|
213
|
+
[OID4VCIMachineStates.getFederationTrust]: {
|
|
214
|
+
id: OID4VCIMachineStates.getFederationTrust,
|
|
232
215
|
invoke: {
|
|
233
|
-
src:
|
|
216
|
+
src: OID4VCIMachineServices.getFederationTrust,
|
|
234
217
|
onDone: {
|
|
235
|
-
target:
|
|
236
|
-
actions:
|
|
218
|
+
target: OID4VCIMachineStates.transitionFromSetup,
|
|
219
|
+
actions: assign({
|
|
237
220
|
trustedAnchors: (_ctx, _event) => _event.data,
|
|
238
221
|
}),
|
|
239
222
|
},
|
|
240
223
|
onError: {
|
|
241
|
-
target:
|
|
242
|
-
actions:
|
|
224
|
+
target: OID4VCIMachineStates.handleError,
|
|
225
|
+
actions: assign({
|
|
243
226
|
error: (_ctx, _event) => ({
|
|
244
|
-
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
|
-
[
|
|
253
|
-
id:
|
|
235
|
+
[OID4VCIMachineStates.transitionFromSetup]: {
|
|
236
|
+
id: OID4VCIMachineStates.transitionFromSetup,
|
|
254
237
|
always: [
|
|
255
238
|
{
|
|
256
|
-
target:
|
|
257
|
-
cond:
|
|
239
|
+
target: OID4VCIMachineStates.addContact,
|
|
240
|
+
cond: OID4VCIMachineGuards.hasNoContactGuard,
|
|
258
241
|
},
|
|
259
242
|
{
|
|
260
|
-
target:
|
|
261
|
-
cond:
|
|
243
|
+
target: OID4VCIMachineStates.reviewContact,
|
|
244
|
+
cond: OID4VCIMachineGuards.contactHasLowTrustGuard,
|
|
262
245
|
},
|
|
263
246
|
{
|
|
264
|
-
target:
|
|
265
|
-
cond:
|
|
247
|
+
target: OID4VCIMachineStates.selectCredentials,
|
|
248
|
+
cond: OID4VCIMachineGuards.credentialsToSelectRequiredGuard,
|
|
266
249
|
},
|
|
267
250
|
{
|
|
268
|
-
target:
|
|
269
|
-
cond:
|
|
251
|
+
target: OID4VCIMachineStates.startFirstPartApplicationFlow,
|
|
252
|
+
cond: OID4VCIMachineGuards.isFirstPartyApplication,
|
|
270
253
|
},
|
|
271
254
|
{
|
|
272
|
-
target:
|
|
273
|
-
cond:
|
|
255
|
+
target: OID4VCIMachineStates.initiateAuthorizationRequest,
|
|
256
|
+
cond: OID4VCIMachineGuards.requireAuthorizationGuard,
|
|
274
257
|
},
|
|
275
258
|
{
|
|
276
|
-
target:
|
|
277
|
-
cond:
|
|
259
|
+
target: OID4VCIMachineStates.verifyPin,
|
|
260
|
+
cond: OID4VCIMachineGuards.requirePinGuard,
|
|
278
261
|
},
|
|
279
262
|
{
|
|
280
|
-
target:
|
|
263
|
+
target: OID4VCIMachineStates.getCredentials,
|
|
281
264
|
},
|
|
282
265
|
],
|
|
283
266
|
on: {
|
|
284
|
-
[
|
|
285
|
-
actions:
|
|
267
|
+
[OID4VCIMachineEvents.SET_AUTHORIZATION_CODE_URL]: {
|
|
268
|
+
actions: assign({ authorizationCodeURL: (_ctx, _event) => _event.data }),
|
|
286
269
|
},
|
|
287
270
|
},
|
|
288
271
|
},
|
|
289
|
-
[
|
|
290
|
-
id:
|
|
291
|
-
initial:
|
|
272
|
+
[OID4VCIMachineStates.addContact]: {
|
|
273
|
+
id: OID4VCIMachineStates.addContact,
|
|
274
|
+
initial: OID4VCIMachineAddContactStates.idle,
|
|
292
275
|
on: {
|
|
293
|
-
[
|
|
294
|
-
actions:
|
|
276
|
+
[OID4VCIMachineEvents.SET_CONTACT_CONSENT]: {
|
|
277
|
+
actions: assign({ hasContactConsent: (_ctx, _event) => _event.data }),
|
|
295
278
|
},
|
|
296
|
-
[
|
|
297
|
-
actions:
|
|
279
|
+
[OID4VCIMachineEvents.SET_CONTACT_ALIAS]: {
|
|
280
|
+
actions: assign({ contactAlias: (_ctx, _event) => _event.data }),
|
|
298
281
|
},
|
|
299
|
-
[
|
|
300
|
-
target: `.${
|
|
301
|
-
actions:
|
|
302
|
-
cond:
|
|
282
|
+
[OID4VCIMachineEvents.CREATE_CONTACT]: {
|
|
283
|
+
target: `.${OID4VCIMachineAddContactStates.next}`,
|
|
284
|
+
actions: assign({ contact: (_ctx, _event) => _event.data }),
|
|
285
|
+
cond: OID4VCIMachineGuards.createContactGuard,
|
|
303
286
|
},
|
|
304
|
-
[
|
|
305
|
-
target:
|
|
287
|
+
[OID4VCIMachineEvents.DECLINE]: {
|
|
288
|
+
target: OID4VCIMachineStates.declined,
|
|
306
289
|
},
|
|
307
|
-
[
|
|
308
|
-
target:
|
|
290
|
+
[OID4VCIMachineEvents.PREVIOUS]: {
|
|
291
|
+
target: OID4VCIMachineStates.aborted,
|
|
309
292
|
},
|
|
310
293
|
},
|
|
311
294
|
states: {
|
|
312
|
-
[
|
|
313
|
-
[
|
|
295
|
+
[OID4VCIMachineAddContactStates.idle]: {},
|
|
296
|
+
[OID4VCIMachineAddContactStates.next]: {
|
|
314
297
|
always: {
|
|
315
|
-
target: `#${
|
|
316
|
-
cond:
|
|
298
|
+
target: `#${OID4VCIMachineStates.storeIssuerBranding}`,
|
|
299
|
+
cond: OID4VCIMachineGuards.hasContactGuard,
|
|
317
300
|
},
|
|
318
301
|
},
|
|
319
302
|
},
|
|
320
303
|
},
|
|
321
|
-
[
|
|
322
|
-
id:
|
|
304
|
+
[OID4VCIMachineStates.reviewContact]: {
|
|
305
|
+
id: OID4VCIMachineStates.reviewContact,
|
|
323
306
|
on: {
|
|
324
|
-
[
|
|
325
|
-
target:
|
|
307
|
+
[OID4VCIMachineEvents.NEXT]: {
|
|
308
|
+
target: OID4VCIMachineStates.transitionFromContactSetup,
|
|
326
309
|
},
|
|
327
|
-
[
|
|
328
|
-
target:
|
|
310
|
+
[OID4VCIMachineEvents.DECLINE]: {
|
|
311
|
+
target: OID4VCIMachineStates.declined,
|
|
329
312
|
},
|
|
330
|
-
[
|
|
331
|
-
target:
|
|
313
|
+
[OID4VCIMachineEvents.PREVIOUS]: {
|
|
314
|
+
target: OID4VCIMachineStates.aborted,
|
|
332
315
|
},
|
|
333
316
|
},
|
|
334
317
|
},
|
|
335
|
-
[
|
|
336
|
-
id:
|
|
318
|
+
[OID4VCIMachineStates.storeIssuerBranding]: {
|
|
319
|
+
id: OID4VCIMachineStates.storeIssuerBranding,
|
|
337
320
|
invoke: {
|
|
338
|
-
src:
|
|
321
|
+
src: OID4VCIMachineServices.storeIssuerBranding,
|
|
339
322
|
onDone: {
|
|
340
|
-
target:
|
|
323
|
+
target: OID4VCIMachineStates.transitionFromContactSetup,
|
|
341
324
|
},
|
|
342
325
|
onError: {
|
|
343
|
-
target:
|
|
344
|
-
actions:
|
|
326
|
+
target: OID4VCIMachineStates.handleError,
|
|
327
|
+
actions: assign({
|
|
345
328
|
error: (_ctx, _event) => ({
|
|
346
|
-
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
|
-
[
|
|
355
|
-
id:
|
|
337
|
+
[OID4VCIMachineStates.transitionFromContactSetup]: {
|
|
338
|
+
id: OID4VCIMachineStates.transitionFromContactSetup,
|
|
356
339
|
always: [
|
|
357
340
|
{
|
|
358
|
-
target:
|
|
359
|
-
cond:
|
|
341
|
+
target: OID4VCIMachineStates.selectCredentials,
|
|
342
|
+
cond: OID4VCIMachineGuards.credentialsToSelectRequiredGuard,
|
|
360
343
|
},
|
|
361
344
|
{
|
|
362
|
-
target:
|
|
363
|
-
cond:
|
|
345
|
+
target: OID4VCIMachineStates.startFirstPartApplicationFlow,
|
|
346
|
+
cond: OID4VCIMachineGuards.isFirstPartyApplication,
|
|
364
347
|
},
|
|
365
348
|
{
|
|
366
|
-
target:
|
|
367
|
-
cond:
|
|
349
|
+
target: OID4VCIMachineStates.initiateAuthorizationRequest,
|
|
350
|
+
cond: OID4VCIMachineGuards.requireAuthorizationGuard,
|
|
368
351
|
},
|
|
369
352
|
{
|
|
370
|
-
target:
|
|
371
|
-
cond:
|
|
353
|
+
target: OID4VCIMachineStates.verifyPin,
|
|
354
|
+
cond: OID4VCIMachineGuards.requirePinGuard,
|
|
372
355
|
},
|
|
373
356
|
{
|
|
374
|
-
target:
|
|
357
|
+
target: OID4VCIMachineStates.getCredentials,
|
|
375
358
|
},
|
|
376
359
|
],
|
|
377
360
|
},
|
|
378
|
-
[
|
|
379
|
-
id:
|
|
361
|
+
[OID4VCIMachineStates.startFirstPartApplicationFlow]: {
|
|
362
|
+
id: OID4VCIMachineStates.startFirstPartApplicationFlow,
|
|
380
363
|
invoke: {
|
|
381
|
-
src:
|
|
364
|
+
src: OID4VCIMachineServices.startFirstPartApplicationFlow,
|
|
382
365
|
onDone: [
|
|
383
366
|
{
|
|
384
|
-
target:
|
|
385
|
-
cond: (_ctx, _event) => _event.data ===
|
|
367
|
+
target: OID4VCIMachineStates.aborted,
|
|
368
|
+
cond: (_ctx, _event) => _event.data === FirstPartyMachineStateTypes.aborted,
|
|
386
369
|
},
|
|
387
370
|
{
|
|
388
|
-
target:
|
|
389
|
-
cond: (_ctx, _event) => _event.data ===
|
|
371
|
+
target: OID4VCIMachineStates.declined,
|
|
372
|
+
cond: (_ctx, _event) => _event.data === FirstPartyMachineStateTypes.declined,
|
|
390
373
|
},
|
|
391
374
|
{
|
|
392
|
-
target:
|
|
393
|
-
actions:
|
|
375
|
+
target: OID4VCIMachineStates.getCredentials,
|
|
376
|
+
actions: assign({
|
|
394
377
|
openID4VCIClientState: (_ctx, _event) => {
|
|
395
|
-
const authorizationCodeResponse =
|
|
396
|
-
return
|
|
397
|
-
}
|
|
398
|
-
})
|
|
399
|
-
}
|
|
378
|
+
const authorizationCodeResponse = toAuthorizationResponsePayload(_event.data);
|
|
379
|
+
return { ..._ctx.openID4VCIClientState, authorizationCodeResponse };
|
|
380
|
+
},
|
|
381
|
+
}),
|
|
382
|
+
},
|
|
400
383
|
],
|
|
401
384
|
onError: {
|
|
402
|
-
target:
|
|
403
|
-
actions:
|
|
404
|
-
error: (_ctx, _event) => {
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
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
|
-
[
|
|
417
|
-
id:
|
|
396
|
+
[OID4VCIMachineStates.selectCredentials]: {
|
|
397
|
+
id: OID4VCIMachineStates.selectCredentials,
|
|
418
398
|
on: {
|
|
419
|
-
[
|
|
420
|
-
actions:
|
|
399
|
+
[OID4VCIMachineEvents.SET_SELECTED_CREDENTIALS]: {
|
|
400
|
+
actions: assign({ selectedCredentials: (_ctx, _event) => _event.data }),
|
|
421
401
|
},
|
|
422
|
-
[
|
|
423
|
-
target:
|
|
424
|
-
cond:
|
|
402
|
+
[OID4VCIMachineEvents.NEXT]: {
|
|
403
|
+
target: OID4VCIMachineStates.transitionFromSelectingCredentials,
|
|
404
|
+
cond: OID4VCIMachineGuards.hasSelectedCredentialsGuard,
|
|
425
405
|
},
|
|
426
|
-
[
|
|
427
|
-
target:
|
|
406
|
+
[OID4VCIMachineEvents.PREVIOUS]: {
|
|
407
|
+
target: OID4VCIMachineStates.aborted,
|
|
428
408
|
},
|
|
429
409
|
},
|
|
430
410
|
},
|
|
431
|
-
[
|
|
432
|
-
id:
|
|
411
|
+
[OID4VCIMachineStates.transitionFromSelectingCredentials]: {
|
|
412
|
+
id: OID4VCIMachineStates.transitionFromSelectingCredentials,
|
|
433
413
|
always: [
|
|
434
414
|
{
|
|
435
|
-
target:
|
|
436
|
-
cond:
|
|
415
|
+
target: OID4VCIMachineStates.startFirstPartApplicationFlow,
|
|
416
|
+
cond: OID4VCIMachineGuards.isFirstPartyApplication,
|
|
437
417
|
},
|
|
438
418
|
{
|
|
439
|
-
target:
|
|
440
|
-
cond:
|
|
419
|
+
target: OID4VCIMachineStates.verifyPin,
|
|
420
|
+
cond: OID4VCIMachineGuards.requirePinGuard,
|
|
441
421
|
},
|
|
442
422
|
{
|
|
443
|
-
target:
|
|
444
|
-
cond:
|
|
423
|
+
target: OID4VCIMachineStates.initiateAuthorizationRequest,
|
|
424
|
+
cond: OID4VCIMachineGuards.requireAuthorizationGuard,
|
|
445
425
|
},
|
|
446
426
|
{
|
|
447
|
-
target:
|
|
427
|
+
target: OID4VCIMachineStates.getCredentials,
|
|
448
428
|
},
|
|
449
429
|
],
|
|
450
430
|
},
|
|
451
|
-
[
|
|
452
|
-
id:
|
|
431
|
+
[OID4VCIMachineStates.initiateAuthorizationRequest]: {
|
|
432
|
+
id: OID4VCIMachineStates.initiateAuthorizationRequest,
|
|
453
433
|
on: {
|
|
454
|
-
[
|
|
455
|
-
target:
|
|
434
|
+
[OID4VCIMachineEvents.PREVIOUS]: {
|
|
435
|
+
target: OID4VCIMachineStates.selectCredentials,
|
|
456
436
|
},
|
|
457
|
-
[
|
|
458
|
-
target:
|
|
437
|
+
[OID4VCIMachineEvents.INVOKED_AUTHORIZATION_CODE_REQUEST]: {
|
|
438
|
+
target: OID4VCIMachineStates.waitForAuthorizationResponse,
|
|
459
439
|
},
|
|
460
440
|
},
|
|
461
441
|
},
|
|
462
|
-
[
|
|
463
|
-
id:
|
|
442
|
+
[OID4VCIMachineStates.waitForAuthorizationResponse]: {
|
|
443
|
+
id: OID4VCIMachineStates.waitForAuthorizationResponse,
|
|
464
444
|
on: {
|
|
465
|
-
[
|
|
466
|
-
target:
|
|
445
|
+
[OID4VCIMachineEvents.PREVIOUS]: {
|
|
446
|
+
target: OID4VCIMachineStates.initiateAuthorizationRequest,
|
|
467
447
|
},
|
|
468
|
-
[
|
|
469
|
-
actions:
|
|
448
|
+
[OID4VCIMachineEvents.PROVIDE_AUTHORIZATION_CODE_RESPONSE]: {
|
|
449
|
+
actions: assign({
|
|
470
450
|
openID4VCIClientState: (_ctx, _event) => {
|
|
471
|
-
const authorizationCodeResponse =
|
|
472
|
-
return
|
|
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:
|
|
480
|
-
target:
|
|
459
|
+
cond: OID4VCIMachineGuards.hasAuthorizationResponse,
|
|
460
|
+
target: OID4VCIMachineStates.getCredentials,
|
|
481
461
|
},
|
|
482
462
|
],
|
|
483
463
|
},
|
|
484
|
-
[
|
|
485
|
-
id:
|
|
486
|
-
initial:
|
|
464
|
+
[OID4VCIMachineStates.verifyPin]: {
|
|
465
|
+
id: OID4VCIMachineStates.verifyPin,
|
|
466
|
+
initial: OID4VCIMachineVerifyPinStates.idle,
|
|
487
467
|
on: {
|
|
488
|
-
[
|
|
489
|
-
target: `.${
|
|
490
|
-
actions:
|
|
468
|
+
[OID4VCIMachineEvents.SET_VERIFICATION_CODE]: {
|
|
469
|
+
target: `.${OID4VCIMachineVerifyPinStates.next}`,
|
|
470
|
+
actions: assign({ verificationCode: (_ctx, _event) => _event.data }),
|
|
491
471
|
},
|
|
492
|
-
[
|
|
472
|
+
[OID4VCIMachineEvents.PREVIOUS]: [
|
|
493
473
|
{
|
|
494
|
-
target:
|
|
495
|
-
cond:
|
|
474
|
+
target: OID4VCIMachineStates.selectCredentials,
|
|
475
|
+
cond: OID4VCIMachineGuards.credentialsToSelectRequiredGuard,
|
|
496
476
|
},
|
|
497
477
|
{
|
|
498
|
-
target:
|
|
478
|
+
target: OID4VCIMachineStates.aborted,
|
|
499
479
|
},
|
|
500
480
|
],
|
|
501
481
|
},
|
|
502
482
|
states: {
|
|
503
|
-
[
|
|
504
|
-
[
|
|
483
|
+
[OID4VCIMachineVerifyPinStates.idle]: {},
|
|
484
|
+
[OID4VCIMachineVerifyPinStates.next]: {
|
|
505
485
|
always: {
|
|
506
|
-
target: `#${
|
|
507
|
-
cond:
|
|
486
|
+
target: `#${OID4VCIMachineStates.getCredentials}`,
|
|
487
|
+
cond: OID4VCIMachineGuards.verificationCodeGuard,
|
|
508
488
|
},
|
|
509
489
|
},
|
|
510
490
|
},
|
|
511
491
|
},
|
|
512
|
-
[
|
|
513
|
-
id:
|
|
492
|
+
[OID4VCIMachineStates.getCredentials]: {
|
|
493
|
+
id: OID4VCIMachineStates.getCredentials,
|
|
514
494
|
invoke: {
|
|
515
|
-
src:
|
|
495
|
+
src: OID4VCIMachineServices.getCredentials,
|
|
516
496
|
onDone: {
|
|
517
|
-
target:
|
|
518
|
-
actions:
|
|
497
|
+
target: OID4VCIMachineStates.verifyCredentials,
|
|
498
|
+
actions: assign({
|
|
519
499
|
credentialsToAccept: (_ctx, _event) => _event.data,
|
|
520
500
|
}),
|
|
521
501
|
},
|
|
522
502
|
onError: {
|
|
523
|
-
target:
|
|
524
|
-
actions:
|
|
503
|
+
target: OID4VCIMachineStates.handleError,
|
|
504
|
+
actions: assign({
|
|
525
505
|
error: (_ctx, _event) => ({
|
|
526
|
-
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:
|
|
513
|
+
exit: assign({ verificationCode: undefined }),
|
|
534
514
|
},
|
|
535
|
-
[
|
|
536
|
-
id:
|
|
515
|
+
[OID4VCIMachineStates.verifyCredentials]: {
|
|
516
|
+
id: OID4VCIMachineStates.verifyCredentials,
|
|
537
517
|
invoke: {
|
|
538
|
-
src:
|
|
518
|
+
src: OID4VCIMachineServices.assertValidCredentials,
|
|
539
519
|
onDone: {
|
|
540
|
-
target:
|
|
520
|
+
target: OID4VCIMachineStates.transitionFromWalletInput,
|
|
541
521
|
},
|
|
542
522
|
onError: {
|
|
543
|
-
target:
|
|
544
|
-
actions:
|
|
523
|
+
target: OID4VCIMachineStates.handleError,
|
|
524
|
+
actions: assign({
|
|
545
525
|
error: (_ctx, _event) => ({
|
|
546
|
-
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
|
-
[
|
|
555
|
-
id:
|
|
534
|
+
[OID4VCIMachineStates.transitionFromWalletInput]: {
|
|
535
|
+
id: OID4VCIMachineStates.transitionFromWalletInput,
|
|
556
536
|
always: [
|
|
557
537
|
{
|
|
558
|
-
target:
|
|
559
|
-
cond:
|
|
538
|
+
target: OID4VCIMachineStates.addContactIdentity,
|
|
539
|
+
cond: OID4VCIMachineGuards.hasNoContactIdentityGuard,
|
|
560
540
|
},
|
|
561
541
|
{
|
|
562
|
-
target:
|
|
542
|
+
target: OID4VCIMachineStates.reviewCredentials,
|
|
563
543
|
},
|
|
564
544
|
],
|
|
565
545
|
},
|
|
566
|
-
[
|
|
567
|
-
id:
|
|
546
|
+
[OID4VCIMachineStates.addContactIdentity]: {
|
|
547
|
+
id: OID4VCIMachineStates.addContactIdentity,
|
|
568
548
|
invoke: {
|
|
569
|
-
src:
|
|
549
|
+
src: OID4VCIMachineServices.addContactIdentity,
|
|
570
550
|
onDone: {
|
|
571
|
-
target:
|
|
551
|
+
target: OID4VCIMachineStates.addIssuerBrandingAfterIdentity,
|
|
572
552
|
actions: (_ctx, _event) => {
|
|
573
|
-
|
|
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:
|
|
579
|
-
actions:
|
|
557
|
+
target: OID4VCIMachineStates.handleError,
|
|
558
|
+
actions: assign({
|
|
580
559
|
error: (_ctx, _event) => ({
|
|
581
|
-
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
|
-
[
|
|
590
|
-
id:
|
|
568
|
+
[OID4VCIMachineStates.addIssuerBrandingAfterIdentity]: {
|
|
569
|
+
id: OID4VCIMachineStates.addIssuerBrandingAfterIdentity,
|
|
591
570
|
invoke: {
|
|
592
|
-
src:
|
|
571
|
+
src: OID4VCIMachineServices.storeIssuerBranding,
|
|
593
572
|
onDone: {
|
|
594
|
-
target:
|
|
573
|
+
target: OID4VCIMachineStates.reviewCredentials,
|
|
595
574
|
},
|
|
596
575
|
onError: {
|
|
597
|
-
target:
|
|
598
|
-
actions:
|
|
576
|
+
target: OID4VCIMachineStates.handleError,
|
|
577
|
+
actions: assign({
|
|
599
578
|
error: (_ctx, _event) => ({
|
|
600
|
-
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
|
-
[
|
|
609
|
-
id:
|
|
587
|
+
[OID4VCIMachineStates.reviewCredentials]: {
|
|
588
|
+
id: OID4VCIMachineStates.reviewCredentials,
|
|
610
589
|
on: {
|
|
611
|
-
[
|
|
612
|
-
target:
|
|
590
|
+
[OID4VCIMachineEvents.NEXT]: {
|
|
591
|
+
target: OID4VCIMachineStates.storeCredentialBranding,
|
|
613
592
|
},
|
|
614
|
-
[
|
|
615
|
-
target:
|
|
593
|
+
[OID4VCIMachineEvents.DECLINE]: {
|
|
594
|
+
target: OID4VCIMachineStates.declined,
|
|
616
595
|
},
|
|
617
|
-
[
|
|
618
|
-
target:
|
|
596
|
+
[OID4VCIMachineEvents.PREVIOUS]: {
|
|
597
|
+
target: OID4VCIMachineStates.aborted,
|
|
619
598
|
},
|
|
620
599
|
},
|
|
621
600
|
},
|
|
622
|
-
[
|
|
623
|
-
id:
|
|
601
|
+
[OID4VCIMachineStates.storeCredentialBranding]: {
|
|
602
|
+
id: OID4VCIMachineStates.storeCredentialBranding,
|
|
624
603
|
invoke: {
|
|
625
|
-
src:
|
|
604
|
+
src: OID4VCIMachineServices.storeCredentialBranding,
|
|
626
605
|
onDone: {
|
|
627
|
-
target:
|
|
606
|
+
target: OID4VCIMachineStates.storeCredentials,
|
|
628
607
|
},
|
|
629
608
|
onError: {
|
|
630
|
-
target:
|
|
631
|
-
actions:
|
|
609
|
+
target: OID4VCIMachineStates.handleError,
|
|
610
|
+
actions: assign({
|
|
632
611
|
error: (_ctx, _event) => ({
|
|
633
|
-
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
|
-
[
|
|
642
|
-
id:
|
|
620
|
+
[OID4VCIMachineStates.storeCredentials]: {
|
|
621
|
+
id: OID4VCIMachineStates.storeCredentials,
|
|
643
622
|
invoke: {
|
|
644
|
-
src:
|
|
623
|
+
src: OID4VCIMachineServices.storeCredentials,
|
|
645
624
|
onDone: {
|
|
646
|
-
target:
|
|
625
|
+
target: OID4VCIMachineStates.done,
|
|
647
626
|
},
|
|
648
627
|
onError: {
|
|
649
|
-
target:
|
|
650
|
-
actions:
|
|
628
|
+
target: OID4VCIMachineStates.handleError,
|
|
629
|
+
actions: assign({
|
|
651
630
|
error: (_ctx, _event) => ({
|
|
652
|
-
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
|
-
[
|
|
661
|
-
id:
|
|
639
|
+
[OID4VCIMachineStates.handleError]: {
|
|
640
|
+
id: OID4VCIMachineStates.handleError,
|
|
662
641
|
on: {
|
|
663
|
-
[
|
|
664
|
-
target:
|
|
642
|
+
[OID4VCIMachineEvents.NEXT]: {
|
|
643
|
+
target: OID4VCIMachineStates.error,
|
|
665
644
|
},
|
|
666
|
-
[
|
|
667
|
-
target:
|
|
645
|
+
[OID4VCIMachineEvents.PREVIOUS]: {
|
|
646
|
+
target: OID4VCIMachineStates.error,
|
|
668
647
|
},
|
|
669
648
|
},
|
|
670
649
|
},
|
|
671
|
-
[
|
|
672
|
-
id:
|
|
650
|
+
[OID4VCIMachineStates.aborted]: {
|
|
651
|
+
id: OID4VCIMachineStates.aborted,
|
|
673
652
|
type: 'final',
|
|
674
653
|
},
|
|
675
|
-
[
|
|
676
|
-
id:
|
|
654
|
+
[OID4VCIMachineStates.declined]: {
|
|
655
|
+
id: OID4VCIMachineStates.declined,
|
|
677
656
|
type: 'final',
|
|
678
657
|
},
|
|
679
|
-
[
|
|
680
|
-
id:
|
|
658
|
+
[OID4VCIMachineStates.error]: {
|
|
659
|
+
id: OID4VCIMachineStates.error,
|
|
681
660
|
type: 'final',
|
|
682
661
|
},
|
|
683
|
-
[
|
|
684
|
-
id:
|
|
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
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
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
|
-
|
|
723
|
-
}
|
|
704
|
+
}
|
|
705
|
+
return { interpreter };
|
|
724
706
|
}
|
|
725
707
|
}
|
|
726
|
-
exports.OID4VCIMachine = OID4VCIMachine;
|
|
727
708
|
//# sourceMappingURL=oid4vciMachine.js.map
|