@metamask-previews/kyc-controller 0.0.0-preview-e12b5ece6 → 0.0.0-preview-e0510042f
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/CHANGELOG.md +0 -12
- package/dist/KycController-method-action-types.cjs.map +1 -1
- package/dist/KycController-method-action-types.d.cts +4 -6
- package/dist/KycController-method-action-types.d.cts.map +1 -1
- package/dist/KycController-method-action-types.d.mts +4 -6
- package/dist/KycController-method-action-types.d.mts.map +1 -1
- package/dist/KycController-method-action-types.mjs.map +1 -1
- package/dist/KycController.cjs +150 -186
- package/dist/KycController.cjs.map +1 -1
- package/dist/KycController.d.cts +37 -43
- package/dist/KycController.d.cts.map +1 -1
- package/dist/KycController.d.mts +37 -43
- package/dist/KycController.d.mts.map +1 -1
- package/dist/KycController.mjs +149 -183
- package/dist/KycController.mjs.map +1 -1
- package/dist/KycService-method-action-types.cjs.map +1 -1
- package/dist/KycService-method-action-types.d.cts +6 -23
- package/dist/KycService-method-action-types.d.cts.map +1 -1
- package/dist/KycService-method-action-types.d.mts +6 -23
- package/dist/KycService-method-action-types.d.mts.map +1 -1
- package/dist/KycService-method-action-types.mjs.map +1 -1
- package/dist/KycService.cjs +119 -100
- package/dist/KycService.cjs.map +1 -1
- package/dist/KycService.d.cts +12 -38
- package/dist/KycService.d.cts.map +1 -1
- package/dist/KycService.d.mts +12 -38
- package/dist/KycService.d.mts.map +1 -1
- package/dist/KycService.mjs +119 -100
- package/dist/KycService.mjs.map +1 -1
- package/dist/index.cjs +1 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +5 -53
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +5 -53
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/dist/ukyc/wrapEncryptionKey.cjs +9 -4
- package/dist/ukyc/wrapEncryptionKey.cjs.map +1 -1
- package/dist/ukyc/wrapEncryptionKey.d.cts +10 -8
- package/dist/ukyc/wrapEncryptionKey.d.cts.map +1 -1
- package/dist/ukyc/wrapEncryptionKey.d.mts +10 -8
- package/dist/ukyc/wrapEncryptionKey.d.mts.map +1 -1
- package/dist/ukyc/wrapEncryptionKey.mjs +9 -4
- package/dist/ukyc/wrapEncryptionKey.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/logger.cjs +0 -9
- package/dist/logger.cjs.map +0 -1
- package/dist/logger.d.cts +0 -6
- package/dist/logger.d.cts.map +0 -1
- package/dist/logger.d.mts +0 -6
- package/dist/logger.d.mts.map +0 -1
- package/dist/logger.mjs +0 -6
- package/dist/logger.mjs.map +0 -1
- package/dist/vendorDisclaimerAcceptance.cjs +0 -74
- package/dist/vendorDisclaimerAcceptance.cjs.map +0 -1
- package/dist/vendorDisclaimerAcceptance.d.cts +0 -39
- package/dist/vendorDisclaimerAcceptance.d.cts.map +0 -1
- package/dist/vendorDisclaimerAcceptance.d.mts +0 -39
- package/dist/vendorDisclaimerAcceptance.d.mts.map +0 -1
- package/dist/vendorDisclaimerAcceptance.mjs +0 -67
- package/dist/vendorDisclaimerAcceptance.mjs.map +0 -1
package/dist/KycController.mjs
CHANGED
|
@@ -9,19 +9,17 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _KycController_instances, _KycController_sumsubLauncher,
|
|
12
|
+
var _KycController_instances, _KycController_sumsubLauncher, _KycController_keypair, _KycController_authClientToken, _KycController_generation, _KycController_sessionStatusPollIntervalMs, _KycController_pollTimer, _KycController_pollToken, _KycController_userStatusPollIntervalMs, _KycController_userStatusPollTimer, _KycController_userStatusPolling, _KycController_userStatusPollToken, _KycController_localUserSecretStore, _KycController_startConsentsSession, _KycController_recordSessionDisclaimers, _KycController_createSession, _KycController_clearAcceptedTerms, _KycController_clearMoonPaySession, _KycController_dropTermsUnlessForVendor, _KycController_hasTermsForVendor, _KycController_handleCheckOutcome, _KycController_handleAuthOutcome, _KycController_continueAfterAuthentication, _KycController_requireTermsReacceptance, _KycController_buildUkycSessionVendorFields, _KycController_createUkycSession, _KycController_fetchAndApplyUserStatus, _KycController_applyUserStatus, _KycController_ensureUserStatusPolling, _KycController_stopUserStatusPolling, _KycController_startSessionStatusPolling, _KycController_pollSessionStatusOnce, _KycController_stopPolling, _KycController_cancelPendingSession, _KycController_updateIfCurrent, _KycController_applyUpdate, _KycController_assertAttestedServerPublicKey, _KycController_fail;
|
|
13
13
|
import { BaseController } from "@metamask/base-controller";
|
|
14
14
|
import { stringToBytes } from "@metamask/utils";
|
|
15
15
|
import { x25519 } from "@noble/curves/ed25519";
|
|
16
16
|
import { decryptCredentials, generateKeyPair } from "./crypto.mjs";
|
|
17
17
|
import { toBase64Url } from "./encoding.mjs";
|
|
18
|
-
import { controllerLog } from "./logger.mjs";
|
|
19
18
|
import { deriveClientMaterial } from "./ukyc/deriveClientMaterial.mjs";
|
|
20
19
|
import { verifyJwtChain } from "./ukyc/jwtChain.mjs";
|
|
21
20
|
import { getOrCreateLocalUserSecret } from "./ukyc/localUserSecret.mjs";
|
|
22
21
|
import { encodeStorageAccessTokenForHeader, signStorageAccessToken } from "./ukyc/storageAccessToken.mjs";
|
|
23
22
|
import { wrapEncryptionKey } from "./ukyc/wrapEncryptionKey.mjs";
|
|
24
|
-
import { clearVendorDisclaimerAcceptance, hasVendorDisclaimerAcceptance, ironDisclaimerIds, recordVendorDisclaimerAcceptance } from "./vendorDisclaimerAcceptance.mjs";
|
|
25
23
|
// === GENERAL ===
|
|
26
24
|
export const controllerName = 'KycController';
|
|
27
25
|
const FRAMES_BASE_URL = 'https://blocks.moonpay.com/platform/v1';
|
|
@@ -118,19 +116,31 @@ const kycControllerMetadata = {
|
|
|
118
116
|
persist: false,
|
|
119
117
|
usedInUi: false,
|
|
120
118
|
},
|
|
121
|
-
|
|
119
|
+
termsAcceptedAt: {
|
|
122
120
|
includeInDebugSnapshot: true,
|
|
123
121
|
includeInStateLogs: true,
|
|
124
122
|
persist: true,
|
|
125
123
|
usedInUi: false,
|
|
126
124
|
},
|
|
127
|
-
|
|
125
|
+
acceptedDisclaimerIds: {
|
|
128
126
|
includeInDebugSnapshot: true,
|
|
129
127
|
includeInStateLogs: true,
|
|
130
128
|
persist: true,
|
|
131
129
|
usedInUi: false,
|
|
132
130
|
},
|
|
133
|
-
|
|
131
|
+
termsAcceptedVendor: {
|
|
132
|
+
includeInDebugSnapshot: true,
|
|
133
|
+
includeInStateLogs: true,
|
|
134
|
+
persist: true,
|
|
135
|
+
usedInUi: false,
|
|
136
|
+
},
|
|
137
|
+
sumsubTncAccepted: {
|
|
138
|
+
includeInDebugSnapshot: true,
|
|
139
|
+
includeInStateLogs: true,
|
|
140
|
+
persist: true,
|
|
141
|
+
usedInUi: false,
|
|
142
|
+
},
|
|
143
|
+
idosTncAccepted: {
|
|
134
144
|
includeInDebugSnapshot: true,
|
|
135
145
|
includeInStateLogs: true,
|
|
136
146
|
persist: true,
|
|
@@ -142,13 +152,13 @@ const kycControllerMetadata = {
|
|
|
142
152
|
persist: false,
|
|
143
153
|
usedInUi: false,
|
|
144
154
|
},
|
|
145
|
-
|
|
155
|
+
disclaimers: {
|
|
146
156
|
includeInDebugSnapshot: false,
|
|
147
157
|
includeInStateLogs: false,
|
|
148
158
|
persist: false,
|
|
149
159
|
usedInUi: true,
|
|
150
160
|
},
|
|
151
|
-
|
|
161
|
+
disclaimersError: {
|
|
152
162
|
includeInDebugSnapshot: true,
|
|
153
163
|
includeInStateLogs: true,
|
|
154
164
|
persist: false,
|
|
@@ -166,13 +176,13 @@ const kycControllerMetadata = {
|
|
|
166
176
|
persist: false,
|
|
167
177
|
usedInUi: true,
|
|
168
178
|
},
|
|
169
|
-
|
|
179
|
+
sessionToken: {
|
|
170
180
|
includeInDebugSnapshot: false,
|
|
171
181
|
includeInStateLogs: false,
|
|
172
182
|
persist: false,
|
|
173
183
|
usedInUi: false,
|
|
174
184
|
},
|
|
175
|
-
|
|
185
|
+
accessToken: {
|
|
176
186
|
includeInDebugSnapshot: false,
|
|
177
187
|
includeInStateLogs: false,
|
|
178
188
|
persist: false,
|
|
@@ -233,17 +243,6 @@ const kycControllerMetadata = {
|
|
|
233
243
|
usedInUi: true,
|
|
234
244
|
},
|
|
235
245
|
};
|
|
236
|
-
/**
|
|
237
|
-
* Constructs the default {@link KycVendorDisclaimersAccepted} value.
|
|
238
|
-
*
|
|
239
|
-
* @returns The default vendor-disclaimer acceptance map.
|
|
240
|
-
*/
|
|
241
|
-
export function getDefaultKycVendorDisclaimersAccepted() {
|
|
242
|
-
return { moonpay: null, iron: null };
|
|
243
|
-
}
|
|
244
|
-
export function getDefaultKycProviderDisclaimersAccepted() {
|
|
245
|
-
return { sumsub: null };
|
|
246
|
-
}
|
|
247
246
|
/**
|
|
248
247
|
* Constructs the default {@link KycController} state.
|
|
249
248
|
*
|
|
@@ -255,16 +254,18 @@ export function getDefaultKycControllerState() {
|
|
|
255
254
|
statusMessage: '',
|
|
256
255
|
error: null,
|
|
257
256
|
email: null,
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
257
|
+
termsAcceptedAt: null,
|
|
258
|
+
acceptedDisclaimerIds: [],
|
|
259
|
+
termsAcceptedVendor: null,
|
|
260
|
+
sumsubTncAccepted: null,
|
|
261
|
+
idosTncAccepted: null,
|
|
261
262
|
credentialReusabilityConsentGiven: null,
|
|
262
|
-
|
|
263
|
-
|
|
263
|
+
disclaimers: [],
|
|
264
|
+
disclaimersError: null,
|
|
264
265
|
sessionDisclaimers: null,
|
|
265
266
|
geoCountry: null,
|
|
266
|
-
|
|
267
|
-
|
|
267
|
+
sessionToken: null,
|
|
268
|
+
accessToken: null,
|
|
268
269
|
moonpayCustomerId: null,
|
|
269
270
|
activeVendor: 'moonpay',
|
|
270
271
|
activeProduct: null,
|
|
@@ -308,62 +309,45 @@ function isConsentConflictError(error) {
|
|
|
308
309
|
error.httpStatus === 409);
|
|
309
310
|
}
|
|
310
311
|
/**
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
*
|
|
314
|
-
*/
|
|
315
|
-
function isValidConsentRecordList(value) {
|
|
316
|
-
return (Array.isArray(value) &&
|
|
317
|
-
value.every((item) => typeof item === 'object' &&
|
|
318
|
-
item !== null &&
|
|
319
|
-
typeof item.key === 'string' &&
|
|
320
|
-
typeof item.version === 'string'));
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* Maps accepted disclaimer records onto unconsented catalog documents.
|
|
312
|
+
* Maps a session-disclaimer catalog into the `{ key, version }` records the
|
|
313
|
+
* record-consents API expects, or an empty list when the user declined that
|
|
314
|
+
* category.
|
|
324
315
|
*
|
|
325
316
|
* @param documents - Catalog documents for one consent category.
|
|
326
|
-
* @param accepted -
|
|
327
|
-
* @returns Consent records
|
|
317
|
+
* @param accepted - Whether the user accepted that category.
|
|
318
|
+
* @returns Consent records, or `[]` when not accepted.
|
|
328
319
|
*/
|
|
329
|
-
function
|
|
330
|
-
if (accepted
|
|
320
|
+
function consentRecordsFromCatalog(documents, accepted) {
|
|
321
|
+
if (!accepted) {
|
|
331
322
|
return [];
|
|
332
323
|
}
|
|
333
|
-
const acceptedKeys = new Set(accepted.map((record) => `${record.key}:${record.version}`));
|
|
334
324
|
return documents
|
|
335
|
-
.filter((document) => !document.consented
|
|
336
|
-
acceptedKeys.has(`${document.key}:${document.version}`))
|
|
325
|
+
.filter((document) => !document.consented)
|
|
337
326
|
.map(({ key, version }) => ({ key, version }));
|
|
338
327
|
}
|
|
339
328
|
/**
|
|
340
|
-
* Whether accepted
|
|
329
|
+
* Whether an accepted T&C2 category has no catalog documents. An empty list
|
|
330
|
+
* would otherwise skip the POST and count as success.
|
|
341
331
|
*
|
|
342
332
|
* @param documents - Catalog documents for one consent category.
|
|
343
|
-
* @param accepted -
|
|
344
|
-
* @returns `true` when the
|
|
333
|
+
* @param accepted - Whether the user accepted that category.
|
|
334
|
+
* @returns `true` when the user accepted and the catalog is empty.
|
|
345
335
|
*/
|
|
346
336
|
function isAcceptedCategoryEmpty(documents, accepted) {
|
|
347
|
-
return accepted
|
|
337
|
+
return accepted && documents.length === 0;
|
|
348
338
|
}
|
|
349
339
|
/**
|
|
350
|
-
* Whether accepted
|
|
351
|
-
* empty catalog or any
|
|
340
|
+
* Whether an accepted category is still missing consent after a 409 re-GET:
|
|
341
|
+
* empty catalog or any document still unconsented.
|
|
352
342
|
*
|
|
353
343
|
* @param documents - Latest catalog documents for one consent category.
|
|
354
|
-
* @param accepted -
|
|
344
|
+
* @param accepted - Whether the user accepted that category.
|
|
355
345
|
* @returns `true` when accepted documents are not fully consented.
|
|
356
346
|
*/
|
|
357
347
|
function acceptedCategoryStillMissing(documents, accepted) {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
if (documents.length === 0) {
|
|
362
|
-
return true;
|
|
363
|
-
}
|
|
364
|
-
const acceptedKeys = new Set(accepted.map((record) => `${record.key}:${record.version}`));
|
|
365
|
-
const relevant = documents.filter((document) => acceptedKeys.has(`${document.key}:${document.version}`));
|
|
366
|
-
return (relevant.length === 0 || relevant.some((document) => !document.consented));
|
|
348
|
+
return (accepted &&
|
|
349
|
+
(documents.length === 0 ||
|
|
350
|
+
documents.some((document) => !document.consented)));
|
|
367
351
|
}
|
|
368
352
|
/**
|
|
369
353
|
* Vendors other than MoonPay skip Check/Auth frames and use the empty-shell
|
|
@@ -425,8 +409,8 @@ export class KycController extends BaseController {
|
|
|
425
409
|
});
|
|
426
410
|
_KycController_instances.add(this);
|
|
427
411
|
_KycController_sumsubLauncher.set(this, void 0);
|
|
428
|
-
/**
|
|
429
|
-
|
|
412
|
+
/** Ephemeral X25519 keypair for the frame key exchange (never persisted). */
|
|
413
|
+
_KycController_keypair.set(this, void 0);
|
|
430
414
|
/** Auth-frame client token, kept out of state. */
|
|
431
415
|
_KycController_authClientToken.set(this, null);
|
|
432
416
|
/**
|
|
@@ -465,6 +449,7 @@ export class KycController extends BaseController {
|
|
|
465
449
|
__classPrivateFieldSet(this, _KycController_sumsubLauncher, sumsubLauncher, "f");
|
|
466
450
|
__classPrivateFieldSet(this, _KycController_sessionStatusPollIntervalMs, sessionStatusPollIntervalMs, "f");
|
|
467
451
|
__classPrivateFieldSet(this, _KycController_userStatusPollIntervalMs, userStatusPollIntervalMs, "f");
|
|
452
|
+
__classPrivateFieldSet(this, _KycController_keypair, generateKeyPair(), "f");
|
|
468
453
|
this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
|
|
469
454
|
}
|
|
470
455
|
/**
|
|
@@ -487,19 +472,10 @@ export class KycController extends BaseController {
|
|
|
487
472
|
// forces `phase` back through `session`/`check`, breaking an in-flight
|
|
488
473
|
// Check/Auth frame flow. Leave the active flow untouched and let the
|
|
489
474
|
// consumer drive it (or call `reset` first to start over).
|
|
490
|
-
const vendor = params?.vendor ?? 'moonpay';
|
|
491
475
|
if (IN_PROGRESS_PHASES.includes(this.state.phase)) {
|
|
492
|
-
if (vendor === 'moonpay' && !__classPrivateFieldGet(this, _KycController_moonpayFrameKeypair, "f")) {
|
|
493
|
-
__classPrivateFieldSet(this, _KycController_moonpayFrameKeypair, generateKeyPair(), "f");
|
|
494
|
-
}
|
|
495
476
|
return;
|
|
496
477
|
}
|
|
497
|
-
|
|
498
|
-
__classPrivateFieldSet(this, _KycController_moonpayFrameKeypair, generateKeyPair(), "f");
|
|
499
|
-
}
|
|
500
|
-
else {
|
|
501
|
-
__classPrivateFieldSet(this, _KycController_moonpayFrameKeypair, null, "f");
|
|
502
|
-
}
|
|
478
|
+
const vendor = params?.vendor ?? 'moonpay';
|
|
503
479
|
// `initialize` starts a fresh flow, so `activeProduct` is always reset to
|
|
504
480
|
// this call's product (or `null`). Otherwise a prior run's product could
|
|
505
481
|
// linger and cause `#continueAfterAuthentication` to auto-run the check /
|
|
@@ -510,8 +486,8 @@ export class KycController extends BaseController {
|
|
|
510
486
|
}
|
|
511
487
|
state.activeVendor = vendor;
|
|
512
488
|
// MoonPay Check/Auth artifacts must not survive a switch to another
|
|
513
|
-
// vendor: leftover `
|
|
514
|
-
// leftover `
|
|
489
|
+
// vendor: leftover `sessionToken` would keep `buildCheckFrameUrl` alive,
|
|
490
|
+
// leftover `accessToken` / `#authClientToken` would keep Auth / KYC
|
|
515
491
|
// calls bound to MoonPay, and leftover `moonpayCustomerId` would make
|
|
516
492
|
// `getCustomerIdentity` report a MoonPay id under the wrong vendor.
|
|
517
493
|
if (vendor !== 'moonpay') {
|
|
@@ -564,14 +540,16 @@ export class KycController extends BaseController {
|
|
|
564
540
|
if (__classPrivateFieldGet(this, _KycController_generation, "f") !== generation) {
|
|
565
541
|
return;
|
|
566
542
|
}
|
|
567
|
-
|
|
543
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_dropTermsUnlessForVendor).call(this, vendor);
|
|
544
|
+
const hasTerms = Boolean(this.state.termsAcceptedAt) &&
|
|
545
|
+
this.state.acceptedDisclaimerIds.length > 0;
|
|
568
546
|
if (hasTerms && this.state.email) {
|
|
569
547
|
if (usesConsentsFlow(vendor)) {
|
|
570
548
|
// Consents-path vendors require T&C2 flags; if they weren't persisted
|
|
571
549
|
// (i.e. null from pre-migration state), require reacceptance.
|
|
572
|
-
const
|
|
573
|
-
|
|
574
|
-
|
|
550
|
+
const sumsubTncSigned = this.state.sumsubTncAccepted;
|
|
551
|
+
const idosTncSigned = this.state.idosTncAccepted;
|
|
552
|
+
if (sumsubTncSigned === null || idosTncSigned === null) {
|
|
575
553
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_applyUpdate).call(this, (state) => {
|
|
576
554
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_clearAcceptedTerms).call(this, state);
|
|
577
555
|
state.phase = 'terms';
|
|
@@ -580,19 +558,12 @@ export class KycController extends BaseController {
|
|
|
580
558
|
return;
|
|
581
559
|
}
|
|
582
560
|
await __classPrivateFieldGet(this, _KycController_instances, "m", _KycController_startConsentsSession).call(this, {
|
|
583
|
-
|
|
584
|
-
|
|
561
|
+
sumsubTncSigned,
|
|
562
|
+
idosTncSigned,
|
|
585
563
|
credentialReusabilityConsentGiven: this.state.credentialReusabilityConsentGiven ?? false,
|
|
586
564
|
});
|
|
587
565
|
}
|
|
588
566
|
else {
|
|
589
|
-
// TODO: should this be here? or should it exist at all?
|
|
590
|
-
if (vendor === 'moonpay' && this.state.vendorDisclaimers.length === 0) {
|
|
591
|
-
await this.loadDisclaimers();
|
|
592
|
-
if (__classPrivateFieldGet(this, _KycController_generation, "f") !== generation) {
|
|
593
|
-
return;
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
567
|
await __classPrivateFieldGet(this, _KycController_instances, "m", _KycController_createSession).call(this);
|
|
597
568
|
}
|
|
598
569
|
return;
|
|
@@ -627,7 +598,6 @@ export class KycController extends BaseController {
|
|
|
627
598
|
state.activeVendor = params.vendor;
|
|
628
599
|
if (params.vendor !== 'moonpay') {
|
|
629
600
|
__classPrivateFieldSet(this, _KycController_authClientToken, null, "f");
|
|
630
|
-
__classPrivateFieldSet(this, _KycController_moonpayFrameKeypair, null, "f");
|
|
631
601
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_clearMoonPaySession).call(this, state);
|
|
632
602
|
}
|
|
633
603
|
});
|
|
@@ -637,6 +607,10 @@ export class KycController extends BaseController {
|
|
|
637
607
|
vendor: params.vendor,
|
|
638
608
|
email: params.email,
|
|
639
609
|
});
|
|
610
|
+
if (__classPrivateFieldGet(this, _KycController_generation, "f") !== generation) {
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_dropTermsUnlessForVendor).call(this, params.vendor);
|
|
640
614
|
}
|
|
641
615
|
catch (error) {
|
|
642
616
|
if (__classPrivateFieldGet(this, _KycController_generation, "f") !== generation) {
|
|
@@ -665,18 +639,18 @@ export class KycController extends BaseController {
|
|
|
665
639
|
state.geoCountry = country;
|
|
666
640
|
});
|
|
667
641
|
}
|
|
668
|
-
const disclaimers = await this.messenger.call('KycService:
|
|
642
|
+
const disclaimers = await this.messenger.call('KycService:fetchDisclaimers', {
|
|
669
643
|
vendor: this.state.activeVendor,
|
|
670
644
|
country,
|
|
671
645
|
});
|
|
672
646
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_updateIfCurrent).call(this, generation, (state) => {
|
|
673
|
-
state.
|
|
674
|
-
state.
|
|
647
|
+
state.disclaimers = disclaimers;
|
|
648
|
+
state.disclaimersError = null;
|
|
675
649
|
});
|
|
676
650
|
}
|
|
677
651
|
catch (error) {
|
|
678
652
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_updateIfCurrent).call(this, generation, (state) => {
|
|
679
|
-
state.
|
|
653
|
+
state.disclaimersError = `Failed to load disclaimers: ${String(error)}`;
|
|
680
654
|
});
|
|
681
655
|
}
|
|
682
656
|
}
|
|
@@ -689,47 +663,44 @@ export class KycController extends BaseController {
|
|
|
689
663
|
* @param params.product - The consuming feature the flow runs for. See
|
|
690
664
|
* {@link initialize} for how the product drives the automatic post
|
|
691
665
|
* authentication continuation.
|
|
692
|
-
* @param params.
|
|
693
|
-
*
|
|
694
|
-
*
|
|
695
|
-
*
|
|
696
|
-
* customer accepted (`{ key, version }` records). Required for every vendor
|
|
697
|
-
* so callers explicitly declare acceptance.
|
|
666
|
+
* @param params.sumsubTncSigned - Whether Sumsub T&C were accepted (T&C2).
|
|
667
|
+
* Required for every vendor so callers explicitly declare acceptance.
|
|
668
|
+
* @param params.idosTncSigned - Whether idOS T&C were accepted (T&C2).
|
|
669
|
+
* Required for every vendor so callers explicitly declare acceptance.
|
|
698
670
|
* @param params.credentialReusabilityConsentGiven - Whether the customer
|
|
699
671
|
* consented to reuse existing idOS credentials. Used when recording
|
|
700
672
|
* session-scoped disclaimers on the consents path. Defaults to `false`.
|
|
701
673
|
*/
|
|
702
674
|
async acceptTermsAndStartSession(params) {
|
|
703
|
-
const
|
|
704
|
-
const
|
|
705
|
-
if (
|
|
706
|
-
|
|
675
|
+
const sumsubTncSigned = params?.sumsubTncSigned;
|
|
676
|
+
const idosTncSigned = params?.idosTncSigned;
|
|
677
|
+
if (typeof sumsubTncSigned !== 'boolean' ||
|
|
678
|
+
typeof idosTncSigned !== 'boolean') {
|
|
707
679
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_fail).call(this, 'Missing T&C2 acceptance flags.');
|
|
708
680
|
return;
|
|
709
681
|
}
|
|
710
|
-
const credentialReusabilityConsentGiven = params
|
|
682
|
+
const credentialReusabilityConsentGiven = params.credentialReusabilityConsentGiven ?? false;
|
|
711
683
|
const termsAcceptedAt = new Date().toISOString();
|
|
712
|
-
const disclaimerIds = this.state.
|
|
684
|
+
const disclaimerIds = this.state.disclaimers.map((disclaimer) => disclaimer.id);
|
|
713
685
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_applyUpdate).call(this, (state) => {
|
|
714
|
-
if (params
|
|
686
|
+
if (params.email) {
|
|
715
687
|
state.email = params.email;
|
|
716
688
|
}
|
|
717
|
-
if (params
|
|
689
|
+
if (params.product) {
|
|
718
690
|
state.activeProduct = params.product;
|
|
719
691
|
}
|
|
720
|
-
state.
|
|
721
|
-
state.
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
state.idosDisclaimersAccepted = idosDisclaimersAccepted;
|
|
692
|
+
state.termsAcceptedAt = termsAcceptedAt;
|
|
693
|
+
state.acceptedDisclaimerIds = disclaimerIds;
|
|
694
|
+
state.termsAcceptedVendor = state.activeVendor;
|
|
695
|
+
state.sumsubTncAccepted = sumsubTncSigned;
|
|
696
|
+
state.idosTncAccepted = idosTncSigned;
|
|
726
697
|
state.credentialReusabilityConsentGiven =
|
|
727
698
|
credentialReusabilityConsentGiven;
|
|
728
699
|
});
|
|
729
700
|
if (usesConsentsFlow(this.state.activeVendor)) {
|
|
730
701
|
await __classPrivateFieldGet(this, _KycController_instances, "m", _KycController_startConsentsSession).call(this, {
|
|
731
|
-
|
|
732
|
-
|
|
702
|
+
sumsubTncSigned,
|
|
703
|
+
idosTncSigned,
|
|
733
704
|
credentialReusabilityConsentGiven,
|
|
734
705
|
});
|
|
735
706
|
return;
|
|
@@ -741,12 +712,7 @@ export class KycController extends BaseController {
|
|
|
741
712
|
*/
|
|
742
713
|
clearSavedTerms() {
|
|
743
714
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_applyUpdate).call(this, (state) => {
|
|
744
|
-
|
|
745
|
-
getDefaultKycVendorDisclaimersAccepted();
|
|
746
|
-
state.providerDisclaimersAccepted =
|
|
747
|
-
getDefaultKycProviderDisclaimersAccepted();
|
|
748
|
-
state.idosDisclaimersAccepted = null;
|
|
749
|
-
state.credentialReusabilityConsentGiven = null;
|
|
715
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_clearAcceptedTerms).call(this, state);
|
|
750
716
|
});
|
|
751
717
|
}
|
|
752
718
|
/**
|
|
@@ -804,9 +770,9 @@ export class KycController extends BaseController {
|
|
|
804
770
|
}
|
|
805
771
|
let accessToken;
|
|
806
772
|
let clientToken;
|
|
807
|
-
if (credsEnvelope
|
|
773
|
+
if (credsEnvelope) {
|
|
808
774
|
try {
|
|
809
|
-
const { credentials } = decryptCredentials(credsEnvelope, __classPrivateFieldGet(this,
|
|
775
|
+
const { credentials } = decryptCredentials(credsEnvelope, __classPrivateFieldGet(this, _KycController_keypair, "f").privateKey);
|
|
810
776
|
accessToken = credentials.accessToken;
|
|
811
777
|
clientToken = credentials.clientToken;
|
|
812
778
|
}
|
|
@@ -829,14 +795,12 @@ export class KycController extends BaseController {
|
|
|
829
795
|
* @returns The Check-frame URL or `null`.
|
|
830
796
|
*/
|
|
831
797
|
buildCheckFrameUrl() {
|
|
832
|
-
if (this.state.activeVendor !== 'moonpay' ||
|
|
833
|
-
!this.state.moonpaySessionToken ||
|
|
834
|
-
!__classPrivateFieldGet(this, _KycController_moonpayFrameKeypair, "f")) {
|
|
798
|
+
if (this.state.activeVendor !== 'moonpay' || !this.state.sessionToken) {
|
|
835
799
|
return null;
|
|
836
800
|
}
|
|
837
801
|
const url = new URL(`${FRAMES_BASE_URL}/check-connection`);
|
|
838
|
-
url.searchParams.set('sessionToken', this.state.
|
|
839
|
-
url.searchParams.set('publicKey', __classPrivateFieldGet(this,
|
|
802
|
+
url.searchParams.set('sessionToken', this.state.sessionToken);
|
|
803
|
+
url.searchParams.set('publicKey', __classPrivateFieldGet(this, _KycController_keypair, "f").publicKeyHex);
|
|
840
804
|
url.searchParams.set('channelId', CHANNEL_CHECK);
|
|
841
805
|
url.searchParams.set('skipKyc', 'true');
|
|
842
806
|
return url.toString();
|
|
@@ -847,14 +811,12 @@ export class KycController extends BaseController {
|
|
|
847
811
|
* @returns The Auth-frame URL or `null`.
|
|
848
812
|
*/
|
|
849
813
|
buildAuthFrameUrl() {
|
|
850
|
-
if (this.state.activeVendor !== 'moonpay' ||
|
|
851
|
-
!__classPrivateFieldGet(this, _KycController_authClientToken, "f") ||
|
|
852
|
-
!__classPrivateFieldGet(this, _KycController_moonpayFrameKeypair, "f")) {
|
|
814
|
+
if (this.state.activeVendor !== 'moonpay' || !__classPrivateFieldGet(this, _KycController_authClientToken, "f")) {
|
|
853
815
|
return null;
|
|
854
816
|
}
|
|
855
817
|
const url = new URL(`${FRAMES_BASE_URL}/auth`);
|
|
856
818
|
url.searchParams.set('clientToken', __classPrivateFieldGet(this, _KycController_authClientToken, "f"));
|
|
857
|
-
url.searchParams.set('publicKey', __classPrivateFieldGet(this,
|
|
819
|
+
url.searchParams.set('publicKey', __classPrivateFieldGet(this, _KycController_keypair, "f").publicKeyHex);
|
|
858
820
|
url.searchParams.set('channelId', CHANNEL_AUTH);
|
|
859
821
|
return url.toString();
|
|
860
822
|
}
|
|
@@ -877,9 +839,9 @@ export class KycController extends BaseController {
|
|
|
877
839
|
* @returns Whether KYC is required.
|
|
878
840
|
*/
|
|
879
841
|
async checkKycRequired(params) {
|
|
880
|
-
const {
|
|
881
|
-
if (!
|
|
882
|
-
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_fail).call(this, 'Missing
|
|
842
|
+
const { accessToken } = this.state;
|
|
843
|
+
if (!accessToken) {
|
|
844
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_fail).call(this, 'Missing accessToken — repeat the authentication step.');
|
|
883
845
|
return false;
|
|
884
846
|
}
|
|
885
847
|
const country = params.country ?? this.state.geoCountry;
|
|
@@ -895,11 +857,7 @@ export class KycController extends BaseController {
|
|
|
895
857
|
state.statusMessage = 'Checking KYC status...';
|
|
896
858
|
});
|
|
897
859
|
try {
|
|
898
|
-
const { kycRequired } = await this.messenger.call('KycService:checkKycRequired', {
|
|
899
|
-
accessToken: moonpayAccessToken,
|
|
900
|
-
country,
|
|
901
|
-
capabilities: [{ product: params.product }],
|
|
902
|
-
});
|
|
860
|
+
const { kycRequired } = await this.messenger.call('KycService:checkKycRequired', { accessToken, country, capabilities: [{ product: params.product }] });
|
|
903
861
|
// The flow was reset while the check was in flight; discard the result
|
|
904
862
|
// rather than resurrecting a done/cached state on an idle controller.
|
|
905
863
|
const applied = __classPrivateFieldGet(this, _KycController_instances, "m", _KycController_updateIfCurrent).call(this, generation, (state) => {
|
|
@@ -1184,12 +1142,12 @@ export class KycController extends BaseController {
|
|
|
1184
1142
|
state.phase = 'idle';
|
|
1185
1143
|
state.statusMessage = '';
|
|
1186
1144
|
state.error = null;
|
|
1187
|
-
state.
|
|
1188
|
-
state.
|
|
1145
|
+
state.disclaimers = [];
|
|
1146
|
+
state.disclaimersError = null;
|
|
1189
1147
|
state.sessionDisclaimers = null;
|
|
1190
1148
|
state.credentialReusabilityConsentGiven = null;
|
|
1191
|
-
state.
|
|
1192
|
-
state.
|
|
1149
|
+
state.sessionToken = null;
|
|
1150
|
+
state.accessToken = null;
|
|
1193
1151
|
state.moonpayCustomerId = null;
|
|
1194
1152
|
state.activeVendor = 'moonpay';
|
|
1195
1153
|
state.activeProduct = null;
|
|
@@ -1217,7 +1175,7 @@ export class KycController extends BaseController {
|
|
|
1217
1175
|
});
|
|
1218
1176
|
}
|
|
1219
1177
|
}
|
|
1220
|
-
_KycController_sumsubLauncher = new WeakMap(),
|
|
1178
|
+
_KycController_sumsubLauncher = new WeakMap(), _KycController_keypair = new WeakMap(), _KycController_authClientToken = new WeakMap(), _KycController_generation = new WeakMap(), _KycController_sessionStatusPollIntervalMs = new WeakMap(), _KycController_pollTimer = new WeakMap(), _KycController_pollToken = new WeakMap(), _KycController_userStatusPollIntervalMs = new WeakMap(), _KycController_userStatusPollTimer = new WeakMap(), _KycController_userStatusPolling = new WeakMap(), _KycController_userStatusPollToken = new WeakMap(), _KycController_instances = new WeakSet(), _KycController_localUserSecretStore = function _KycController_localUserSecretStore() {
|
|
1221
1179
|
return {
|
|
1222
1180
|
get: async (path, entropySourceId) => this.messenger.call('UserStorageController:performGetStorage', path, entropySourceId),
|
|
1223
1181
|
set: async (path, value, entropySourceId) => this.messenger.call('UserStorageController:performSetStorage', path, value, entropySourceId),
|
|
@@ -1229,14 +1187,13 @@ _KycController_sumsubLauncher = new WeakMap(), _KycController_moonpayFrameKeypai
|
|
|
1229
1187
|
* SumSub — skipping MoonPay Check/Auth frames.
|
|
1230
1188
|
*
|
|
1231
1189
|
* @param consents - T&C2 flags mapped onto the session disclaimer catalog.
|
|
1232
|
-
* @param consents.
|
|
1233
|
-
* @param consents.
|
|
1190
|
+
* @param consents.sumsubTncSigned - Whether Sumsub T&C were accepted.
|
|
1191
|
+
* @param consents.idosTncSigned - Whether idOS T&C were accepted.
|
|
1234
1192
|
* @param consents.credentialReusabilityConsentGiven - Whether credential
|
|
1235
1193
|
* reuse was accepted.
|
|
1236
1194
|
*/
|
|
1237
1195
|
async function _KycController_startConsentsSession(consents) {
|
|
1238
|
-
const { email } = this.state;
|
|
1239
|
-
const acceptedDisclaimerIds = ironDisclaimerIds(this.state.vendorDisclaimersAccepted);
|
|
1196
|
+
const { email, acceptedDisclaimerIds } = this.state;
|
|
1240
1197
|
if (!email) {
|
|
1241
1198
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_fail).call(this, 'Missing email for consents session.');
|
|
1242
1199
|
return;
|
|
@@ -1280,7 +1237,7 @@ async function _KycController_startConsentsSession(consents) {
|
|
|
1280
1237
|
await this.refreshKycStatus();
|
|
1281
1238
|
}
|
|
1282
1239
|
catch (statusError) {
|
|
1283
|
-
|
|
1240
|
+
console.error('KYC status refresh failed:', statusError);
|
|
1284
1241
|
}
|
|
1285
1242
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_updateIfCurrent).call(this, generation, (state) => {
|
|
1286
1243
|
state.phase = 'done';
|
|
@@ -1316,7 +1273,7 @@ async function _KycController_startConsentsSession(consents) {
|
|
|
1316
1273
|
await this.refreshKycStatus();
|
|
1317
1274
|
}
|
|
1318
1275
|
catch (statusError) {
|
|
1319
|
-
|
|
1276
|
+
console.error('KYC status refresh failed:', statusError);
|
|
1320
1277
|
}
|
|
1321
1278
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_updateIfCurrent).call(this, generation, (state) => {
|
|
1322
1279
|
if (state.phase !== 'error' && state.phase !== 'done') {
|
|
@@ -1344,7 +1301,7 @@ async function _KycController_startConsentsSession(consents) {
|
|
|
1344
1301
|
});
|
|
1345
1302
|
return;
|
|
1346
1303
|
}
|
|
1347
|
-
|
|
1304
|
+
console.error('Consents session failed:', error);
|
|
1348
1305
|
if (__classPrivateFieldGet(this, _KycController_generation, "f") !== generation) {
|
|
1349
1306
|
return;
|
|
1350
1307
|
}
|
|
@@ -1371,8 +1328,8 @@ async function _KycController_startConsentsSession(consents) {
|
|
|
1371
1328
|
*
|
|
1372
1329
|
* @param sessionId - The UKYC session id.
|
|
1373
1330
|
* @param consents - T&C2 flags mapped onto catalog documents.
|
|
1374
|
-
* @param consents.
|
|
1375
|
-
* @param consents.
|
|
1331
|
+
* @param consents.sumsubTncSigned - Whether Sumsub T&C were accepted.
|
|
1332
|
+
* @param consents.idosTncSigned - Whether idOS T&C were accepted.
|
|
1376
1333
|
* @param consents.credentialReusabilityConsentGiven - Whether credential
|
|
1377
1334
|
* reuse was accepted.
|
|
1378
1335
|
* @param generation - Flow generation captured by the caller.
|
|
@@ -1386,12 +1343,12 @@ async function _KycController_recordSessionDisclaimers(sessionId, consents, gene
|
|
|
1386
1343
|
state.sessionDisclaimers = catalog;
|
|
1387
1344
|
state.statusMessage = 'Submitting consents...';
|
|
1388
1345
|
});
|
|
1389
|
-
if (isAcceptedCategoryEmpty(catalog.idOS, consents.
|
|
1390
|
-
isAcceptedCategoryEmpty(catalog.kycProvider, consents.
|
|
1346
|
+
if (isAcceptedCategoryEmpty(catalog.idOS, consents.idosTncSigned) ||
|
|
1347
|
+
isAcceptedCategoryEmpty(catalog.kycProvider, consents.sumsubTncSigned)) {
|
|
1391
1348
|
throw new Error('Session disclaimer catalog is missing documents for an accepted category.');
|
|
1392
1349
|
}
|
|
1393
|
-
const idOS =
|
|
1394
|
-
const kycProvider =
|
|
1350
|
+
const idOS = consentRecordsFromCatalog(catalog.idOS, consents.idosTncSigned);
|
|
1351
|
+
const kycProvider = consentRecordsFromCatalog(catalog.kycProvider, consents.sumsubTncSigned);
|
|
1395
1352
|
const reuseUnchanged = catalog.credentialReusabilityConsentGiven ===
|
|
1396
1353
|
consents.credentialReusabilityConsentGiven;
|
|
1397
1354
|
if (idOS.length === 0 && kycProvider.length === 0 && reuseUnchanged) {
|
|
@@ -1422,9 +1379,8 @@ async function _KycController_recordSessionDisclaimers(sessionId, consents, gene
|
|
|
1422
1379
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_applyUpdate).call(this, (state) => {
|
|
1423
1380
|
state.sessionDisclaimers = latest;
|
|
1424
1381
|
});
|
|
1425
|
-
|
|
1426
|
-
const
|
|
1427
|
-
const stillMissingProvider = acceptedCategoryStillMissing(latest.kycProvider, consents.providerDisclaimersAccepted);
|
|
1382
|
+
const stillMissingIdos = acceptedCategoryStillMissing(latest.idOS, consents.idosTncSigned);
|
|
1383
|
+
const stillMissingProvider = acceptedCategoryStillMissing(latest.kycProvider, consents.sumsubTncSigned);
|
|
1428
1384
|
const stillMissingReuse = consents.credentialReusabilityConsentGiven &&
|
|
1429
1385
|
!latest.credentialReusabilityConsentGiven;
|
|
1430
1386
|
if (stillMissingIdos || stillMissingProvider || stillMissingReuse) {
|
|
@@ -1436,9 +1392,7 @@ async function _KycController_recordSessionDisclaimers(sessionId, consents, gene
|
|
|
1436
1392
|
* Creates a vendor session from the currently stored terms + email.
|
|
1437
1393
|
*/
|
|
1438
1394
|
async function _KycController_createSession() {
|
|
1439
|
-
const { email } = this.state;
|
|
1440
|
-
const termsAcceptedAt = this.state.vendorDisclaimersAccepted.moonpay?.termsAcceptedAt;
|
|
1441
|
-
const acceptedDisclaimerIds = this.state.vendorDisclaimers.map((disclaimer) => disclaimer.id);
|
|
1395
|
+
const { email, termsAcceptedAt, acceptedDisclaimerIds } = this.state;
|
|
1442
1396
|
if (!email) {
|
|
1443
1397
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_fail).call(this, 'Missing email for session creation.');
|
|
1444
1398
|
return;
|
|
@@ -1453,7 +1407,7 @@ async function _KycController_createSession() {
|
|
|
1453
1407
|
// (or, on failure, invalid) session token, `buildAuthFrameUrl` cannot
|
|
1454
1408
|
// return a URL tied to an old client token, and `checkKycRequired` cannot
|
|
1455
1409
|
// run with an access token from an earlier authentication. The Check/Auth
|
|
1456
|
-
// frames re-populate these for the new session. Because `
|
|
1410
|
+
// frames re-populate these for the new session. Because `sessionToken` is
|
|
1457
1411
|
// cleared here and only re-set on success, a failed creation leaves it
|
|
1458
1412
|
// `null` rather than resurrecting the previous session.
|
|
1459
1413
|
// Capture the flow generation so a `reset()` landing while the create
|
|
@@ -1466,19 +1420,19 @@ async function _KycController_createSession() {
|
|
|
1466
1420
|
state.error = null;
|
|
1467
1421
|
state.phase = 'session';
|
|
1468
1422
|
state.statusMessage = 'Creating session...';
|
|
1469
|
-
state.
|
|
1470
|
-
state.
|
|
1423
|
+
state.sessionToken = null;
|
|
1424
|
+
state.accessToken = null;
|
|
1471
1425
|
});
|
|
1472
1426
|
try {
|
|
1473
1427
|
const { sessionToken } = await this.messenger.call('KycService:createSession', { email, termsAcceptedAt, disclaimerIds: acceptedDisclaimerIds });
|
|
1474
1428
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_updateIfCurrent).call(this, generation, (state) => {
|
|
1475
|
-
state.
|
|
1429
|
+
state.sessionToken = sessionToken;
|
|
1476
1430
|
state.phase = 'check';
|
|
1477
1431
|
state.statusMessage = 'Authenticating via Check frame...';
|
|
1478
1432
|
});
|
|
1479
1433
|
}
|
|
1480
1434
|
catch (error) {
|
|
1481
|
-
|
|
1435
|
+
console.error('Session creation failed:', error);
|
|
1482
1436
|
// A reset() superseded this flow while the request was in flight; leave
|
|
1483
1437
|
// the idle controller alone rather than forcing it back to `terms`.
|
|
1484
1438
|
if (__classPrivateFieldGet(this, _KycController_generation, "f") !== generation) {
|
|
@@ -1498,17 +1452,29 @@ async function _KycController_createSession() {
|
|
|
1498
1452
|
});
|
|
1499
1453
|
await this.loadDisclaimers();
|
|
1500
1454
|
}
|
|
1501
|
-
}, _KycController_clearAcceptedTerms = function _KycController_clearAcceptedTerms(state
|
|
1502
|
-
|
|
1503
|
-
state.
|
|
1504
|
-
state.
|
|
1505
|
-
|
|
1506
|
-
state.
|
|
1455
|
+
}, _KycController_clearAcceptedTerms = function _KycController_clearAcceptedTerms(state) {
|
|
1456
|
+
state.termsAcceptedAt = null;
|
|
1457
|
+
state.acceptedDisclaimerIds = [];
|
|
1458
|
+
state.termsAcceptedVendor = null;
|
|
1459
|
+
state.sumsubTncAccepted = null;
|
|
1460
|
+
state.idosTncAccepted = null;
|
|
1507
1461
|
state.credentialReusabilityConsentGiven = null;
|
|
1508
1462
|
}, _KycController_clearMoonPaySession = function _KycController_clearMoonPaySession(state) {
|
|
1509
1463
|
state.moonpayCustomerId = null;
|
|
1510
|
-
state.
|
|
1511
|
-
state.
|
|
1464
|
+
state.sessionToken = null;
|
|
1465
|
+
state.accessToken = null;
|
|
1466
|
+
}, _KycController_dropTermsUnlessForVendor = function _KycController_dropTermsUnlessForVendor(vendor) {
|
|
1467
|
+
if (__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_hasTermsForVendor).call(this, vendor)) {
|
|
1468
|
+
return;
|
|
1469
|
+
}
|
|
1470
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_applyUpdate).call(this, (state) => {
|
|
1471
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_clearAcceptedTerms).call(this, state);
|
|
1472
|
+
});
|
|
1473
|
+
}, _KycController_hasTermsForVendor = function _KycController_hasTermsForVendor(vendor) {
|
|
1474
|
+
if (this.state.termsAcceptedVendor === null) {
|
|
1475
|
+
return false;
|
|
1476
|
+
}
|
|
1477
|
+
return this.state.termsAcceptedVendor === vendor;
|
|
1512
1478
|
}, _KycController_handleCheckOutcome =
|
|
1513
1479
|
/**
|
|
1514
1480
|
* Applies a Check-frame outcome.
|
|
@@ -1520,7 +1486,7 @@ async function _KycController_createSession() {
|
|
|
1520
1486
|
async function _KycController_handleCheckOutcome(status, accessToken, clientToken) {
|
|
1521
1487
|
if (status === 'active' && accessToken) {
|
|
1522
1488
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_applyUpdate).call(this, (state) => {
|
|
1523
|
-
state.
|
|
1489
|
+
state.accessToken = accessToken;
|
|
1524
1490
|
state.phase = 'form';
|
|
1525
1491
|
state.statusMessage = 'Already authenticated. Review to submit.';
|
|
1526
1492
|
});
|
|
@@ -1550,7 +1516,7 @@ async function _KycController_handleCheckOutcome(status, accessToken, clientToke
|
|
|
1550
1516
|
async function _KycController_handleAuthOutcome(status, accessToken) {
|
|
1551
1517
|
if (status === 'active' && accessToken) {
|
|
1552
1518
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_applyUpdate).call(this, (state) => {
|
|
1553
|
-
state.
|
|
1519
|
+
state.accessToken = accessToken;
|
|
1554
1520
|
state.phase = 'form';
|
|
1555
1521
|
state.statusMessage = 'Authenticated. Review to submit.';
|
|
1556
1522
|
});
|
|
@@ -1613,7 +1579,7 @@ async function _KycController_continueAfterAuthentication() {
|
|
|
1613
1579
|
return {
|
|
1614
1580
|
vendor: 'moonpay',
|
|
1615
1581
|
vendorMetadata: {
|
|
1616
|
-
moonPayAccessToken: this.state.
|
|
1582
|
+
moonPayAccessToken: this.state.accessToken,
|
|
1617
1583
|
moonPayUserId: this.state.moonpayCustomerId,
|
|
1618
1584
|
},
|
|
1619
1585
|
};
|