@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.cjs
CHANGED
|
@@ -10,21 +10,19 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
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");
|
|
11
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
12
|
};
|
|
13
|
-
var _KycController_instances, _KycController_sumsubLauncher,
|
|
13
|
+
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;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.KycController = exports.getDefaultKycControllerState = exports.
|
|
15
|
+
exports.KycController = exports.getDefaultKycControllerState = exports.controllerName = void 0;
|
|
16
16
|
const base_controller_1 = require("@metamask/base-controller");
|
|
17
17
|
const utils_1 = require("@metamask/utils");
|
|
18
18
|
const ed25519_1 = require("@noble/curves/ed25519");
|
|
19
19
|
const crypto_js_1 = require("./crypto.cjs");
|
|
20
20
|
const encoding_js_1 = require("./encoding.cjs");
|
|
21
|
-
const logger_js_1 = require("./logger.cjs");
|
|
22
21
|
const deriveClientMaterial_js_1 = require("./ukyc/deriveClientMaterial.cjs");
|
|
23
22
|
const jwtChain_js_1 = require("./ukyc/jwtChain.cjs");
|
|
24
23
|
const localUserSecret_js_1 = require("./ukyc/localUserSecret.cjs");
|
|
25
24
|
const storageAccessToken_js_1 = require("./ukyc/storageAccessToken.cjs");
|
|
26
25
|
const wrapEncryptionKey_js_1 = require("./ukyc/wrapEncryptionKey.cjs");
|
|
27
|
-
const vendorDisclaimerAcceptance_js_1 = require("./vendorDisclaimerAcceptance.cjs");
|
|
28
26
|
// === GENERAL ===
|
|
29
27
|
exports.controllerName = 'KycController';
|
|
30
28
|
const FRAMES_BASE_URL = 'https://blocks.moonpay.com/platform/v1';
|
|
@@ -121,19 +119,31 @@ const kycControllerMetadata = {
|
|
|
121
119
|
persist: false,
|
|
122
120
|
usedInUi: false,
|
|
123
121
|
},
|
|
124
|
-
|
|
122
|
+
termsAcceptedAt: {
|
|
125
123
|
includeInDebugSnapshot: true,
|
|
126
124
|
includeInStateLogs: true,
|
|
127
125
|
persist: true,
|
|
128
126
|
usedInUi: false,
|
|
129
127
|
},
|
|
130
|
-
|
|
128
|
+
acceptedDisclaimerIds: {
|
|
131
129
|
includeInDebugSnapshot: true,
|
|
132
130
|
includeInStateLogs: true,
|
|
133
131
|
persist: true,
|
|
134
132
|
usedInUi: false,
|
|
135
133
|
},
|
|
136
|
-
|
|
134
|
+
termsAcceptedVendor: {
|
|
135
|
+
includeInDebugSnapshot: true,
|
|
136
|
+
includeInStateLogs: true,
|
|
137
|
+
persist: true,
|
|
138
|
+
usedInUi: false,
|
|
139
|
+
},
|
|
140
|
+
sumsubTncAccepted: {
|
|
141
|
+
includeInDebugSnapshot: true,
|
|
142
|
+
includeInStateLogs: true,
|
|
143
|
+
persist: true,
|
|
144
|
+
usedInUi: false,
|
|
145
|
+
},
|
|
146
|
+
idosTncAccepted: {
|
|
137
147
|
includeInDebugSnapshot: true,
|
|
138
148
|
includeInStateLogs: true,
|
|
139
149
|
persist: true,
|
|
@@ -145,13 +155,13 @@ const kycControllerMetadata = {
|
|
|
145
155
|
persist: false,
|
|
146
156
|
usedInUi: false,
|
|
147
157
|
},
|
|
148
|
-
|
|
158
|
+
disclaimers: {
|
|
149
159
|
includeInDebugSnapshot: false,
|
|
150
160
|
includeInStateLogs: false,
|
|
151
161
|
persist: false,
|
|
152
162
|
usedInUi: true,
|
|
153
163
|
},
|
|
154
|
-
|
|
164
|
+
disclaimersError: {
|
|
155
165
|
includeInDebugSnapshot: true,
|
|
156
166
|
includeInStateLogs: true,
|
|
157
167
|
persist: false,
|
|
@@ -169,13 +179,13 @@ const kycControllerMetadata = {
|
|
|
169
179
|
persist: false,
|
|
170
180
|
usedInUi: true,
|
|
171
181
|
},
|
|
172
|
-
|
|
182
|
+
sessionToken: {
|
|
173
183
|
includeInDebugSnapshot: false,
|
|
174
184
|
includeInStateLogs: false,
|
|
175
185
|
persist: false,
|
|
176
186
|
usedInUi: false,
|
|
177
187
|
},
|
|
178
|
-
|
|
188
|
+
accessToken: {
|
|
179
189
|
includeInDebugSnapshot: false,
|
|
180
190
|
includeInStateLogs: false,
|
|
181
191
|
persist: false,
|
|
@@ -236,19 +246,6 @@ const kycControllerMetadata = {
|
|
|
236
246
|
usedInUi: true,
|
|
237
247
|
},
|
|
238
248
|
};
|
|
239
|
-
/**
|
|
240
|
-
* Constructs the default {@link KycVendorDisclaimersAccepted} value.
|
|
241
|
-
*
|
|
242
|
-
* @returns The default vendor-disclaimer acceptance map.
|
|
243
|
-
*/
|
|
244
|
-
function getDefaultKycVendorDisclaimersAccepted() {
|
|
245
|
-
return { moonpay: null, iron: null };
|
|
246
|
-
}
|
|
247
|
-
exports.getDefaultKycVendorDisclaimersAccepted = getDefaultKycVendorDisclaimersAccepted;
|
|
248
|
-
function getDefaultKycProviderDisclaimersAccepted() {
|
|
249
|
-
return { sumsub: null };
|
|
250
|
-
}
|
|
251
|
-
exports.getDefaultKycProviderDisclaimersAccepted = getDefaultKycProviderDisclaimersAccepted;
|
|
252
249
|
/**
|
|
253
250
|
* Constructs the default {@link KycController} state.
|
|
254
251
|
*
|
|
@@ -260,16 +257,18 @@ function getDefaultKycControllerState() {
|
|
|
260
257
|
statusMessage: '',
|
|
261
258
|
error: null,
|
|
262
259
|
email: null,
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
260
|
+
termsAcceptedAt: null,
|
|
261
|
+
acceptedDisclaimerIds: [],
|
|
262
|
+
termsAcceptedVendor: null,
|
|
263
|
+
sumsubTncAccepted: null,
|
|
264
|
+
idosTncAccepted: null,
|
|
266
265
|
credentialReusabilityConsentGiven: null,
|
|
267
|
-
|
|
268
|
-
|
|
266
|
+
disclaimers: [],
|
|
267
|
+
disclaimersError: null,
|
|
269
268
|
sessionDisclaimers: null,
|
|
270
269
|
geoCountry: null,
|
|
271
|
-
|
|
272
|
-
|
|
270
|
+
sessionToken: null,
|
|
271
|
+
accessToken: null,
|
|
273
272
|
moonpayCustomerId: null,
|
|
274
273
|
activeVendor: 'moonpay',
|
|
275
274
|
activeProduct: null,
|
|
@@ -314,62 +313,45 @@ function isConsentConflictError(error) {
|
|
|
314
313
|
error.httpStatus === 409);
|
|
315
314
|
}
|
|
316
315
|
/**
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
*/
|
|
321
|
-
function isValidConsentRecordList(value) {
|
|
322
|
-
return (Array.isArray(value) &&
|
|
323
|
-
value.every((item) => typeof item === 'object' &&
|
|
324
|
-
item !== null &&
|
|
325
|
-
typeof item.key === 'string' &&
|
|
326
|
-
typeof item.version === 'string'));
|
|
327
|
-
}
|
|
328
|
-
/**
|
|
329
|
-
* Maps accepted disclaimer records onto unconsented catalog documents.
|
|
316
|
+
* Maps a session-disclaimer catalog into the `{ key, version }` records the
|
|
317
|
+
* record-consents API expects, or an empty list when the user declined that
|
|
318
|
+
* category.
|
|
330
319
|
*
|
|
331
320
|
* @param documents - Catalog documents for one consent category.
|
|
332
|
-
* @param accepted -
|
|
333
|
-
* @returns Consent records
|
|
321
|
+
* @param accepted - Whether the user accepted that category.
|
|
322
|
+
* @returns Consent records, or `[]` when not accepted.
|
|
334
323
|
*/
|
|
335
|
-
function
|
|
336
|
-
if (accepted
|
|
324
|
+
function consentRecordsFromCatalog(documents, accepted) {
|
|
325
|
+
if (!accepted) {
|
|
337
326
|
return [];
|
|
338
327
|
}
|
|
339
|
-
const acceptedKeys = new Set(accepted.map((record) => `${record.key}:${record.version}`));
|
|
340
328
|
return documents
|
|
341
|
-
.filter((document) => !document.consented
|
|
342
|
-
acceptedKeys.has(`${document.key}:${document.version}`))
|
|
329
|
+
.filter((document) => !document.consented)
|
|
343
330
|
.map(({ key, version }) => ({ key, version }));
|
|
344
331
|
}
|
|
345
332
|
/**
|
|
346
|
-
* Whether accepted
|
|
333
|
+
* Whether an accepted T&C2 category has no catalog documents. An empty list
|
|
334
|
+
* would otherwise skip the POST and count as success.
|
|
347
335
|
*
|
|
348
336
|
* @param documents - Catalog documents for one consent category.
|
|
349
|
-
* @param accepted -
|
|
350
|
-
* @returns `true` when the
|
|
337
|
+
* @param accepted - Whether the user accepted that category.
|
|
338
|
+
* @returns `true` when the user accepted and the catalog is empty.
|
|
351
339
|
*/
|
|
352
340
|
function isAcceptedCategoryEmpty(documents, accepted) {
|
|
353
|
-
return accepted
|
|
341
|
+
return accepted && documents.length === 0;
|
|
354
342
|
}
|
|
355
343
|
/**
|
|
356
|
-
* Whether accepted
|
|
357
|
-
* empty catalog or any
|
|
344
|
+
* Whether an accepted category is still missing consent after a 409 re-GET:
|
|
345
|
+
* empty catalog or any document still unconsented.
|
|
358
346
|
*
|
|
359
347
|
* @param documents - Latest catalog documents for one consent category.
|
|
360
|
-
* @param accepted -
|
|
348
|
+
* @param accepted - Whether the user accepted that category.
|
|
361
349
|
* @returns `true` when accepted documents are not fully consented.
|
|
362
350
|
*/
|
|
363
351
|
function acceptedCategoryStillMissing(documents, accepted) {
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
if (documents.length === 0) {
|
|
368
|
-
return true;
|
|
369
|
-
}
|
|
370
|
-
const acceptedKeys = new Set(accepted.map((record) => `${record.key}:${record.version}`));
|
|
371
|
-
const relevant = documents.filter((document) => acceptedKeys.has(`${document.key}:${document.version}`));
|
|
372
|
-
return (relevant.length === 0 || relevant.some((document) => !document.consented));
|
|
352
|
+
return (accepted &&
|
|
353
|
+
(documents.length === 0 ||
|
|
354
|
+
documents.some((document) => !document.consented)));
|
|
373
355
|
}
|
|
374
356
|
/**
|
|
375
357
|
* Vendors other than MoonPay skip Check/Auth frames and use the empty-shell
|
|
@@ -431,8 +413,8 @@ class KycController extends base_controller_1.BaseController {
|
|
|
431
413
|
});
|
|
432
414
|
_KycController_instances.add(this);
|
|
433
415
|
_KycController_sumsubLauncher.set(this, void 0);
|
|
434
|
-
/**
|
|
435
|
-
|
|
416
|
+
/** Ephemeral X25519 keypair for the frame key exchange (never persisted). */
|
|
417
|
+
_KycController_keypair.set(this, void 0);
|
|
436
418
|
/** Auth-frame client token, kept out of state. */
|
|
437
419
|
_KycController_authClientToken.set(this, null);
|
|
438
420
|
/**
|
|
@@ -471,6 +453,7 @@ class KycController extends base_controller_1.BaseController {
|
|
|
471
453
|
__classPrivateFieldSet(this, _KycController_sumsubLauncher, sumsubLauncher, "f");
|
|
472
454
|
__classPrivateFieldSet(this, _KycController_sessionStatusPollIntervalMs, sessionStatusPollIntervalMs, "f");
|
|
473
455
|
__classPrivateFieldSet(this, _KycController_userStatusPollIntervalMs, userStatusPollIntervalMs, "f");
|
|
456
|
+
__classPrivateFieldSet(this, _KycController_keypair, (0, crypto_js_1.generateKeyPair)(), "f");
|
|
474
457
|
this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
|
|
475
458
|
}
|
|
476
459
|
/**
|
|
@@ -493,19 +476,10 @@ class KycController extends base_controller_1.BaseController {
|
|
|
493
476
|
// forces `phase` back through `session`/`check`, breaking an in-flight
|
|
494
477
|
// Check/Auth frame flow. Leave the active flow untouched and let the
|
|
495
478
|
// consumer drive it (or call `reset` first to start over).
|
|
496
|
-
const vendor = params?.vendor ?? 'moonpay';
|
|
497
479
|
if (IN_PROGRESS_PHASES.includes(this.state.phase)) {
|
|
498
|
-
if (vendor === 'moonpay' && !__classPrivateFieldGet(this, _KycController_moonpayFrameKeypair, "f")) {
|
|
499
|
-
__classPrivateFieldSet(this, _KycController_moonpayFrameKeypair, (0, crypto_js_1.generateKeyPair)(), "f");
|
|
500
|
-
}
|
|
501
480
|
return;
|
|
502
481
|
}
|
|
503
|
-
|
|
504
|
-
__classPrivateFieldSet(this, _KycController_moonpayFrameKeypair, (0, crypto_js_1.generateKeyPair)(), "f");
|
|
505
|
-
}
|
|
506
|
-
else {
|
|
507
|
-
__classPrivateFieldSet(this, _KycController_moonpayFrameKeypair, null, "f");
|
|
508
|
-
}
|
|
482
|
+
const vendor = params?.vendor ?? 'moonpay';
|
|
509
483
|
// `initialize` starts a fresh flow, so `activeProduct` is always reset to
|
|
510
484
|
// this call's product (or `null`). Otherwise a prior run's product could
|
|
511
485
|
// linger and cause `#continueAfterAuthentication` to auto-run the check /
|
|
@@ -516,8 +490,8 @@ class KycController extends base_controller_1.BaseController {
|
|
|
516
490
|
}
|
|
517
491
|
state.activeVendor = vendor;
|
|
518
492
|
// MoonPay Check/Auth artifacts must not survive a switch to another
|
|
519
|
-
// vendor: leftover `
|
|
520
|
-
// leftover `
|
|
493
|
+
// vendor: leftover `sessionToken` would keep `buildCheckFrameUrl` alive,
|
|
494
|
+
// leftover `accessToken` / `#authClientToken` would keep Auth / KYC
|
|
521
495
|
// calls bound to MoonPay, and leftover `moonpayCustomerId` would make
|
|
522
496
|
// `getCustomerIdentity` report a MoonPay id under the wrong vendor.
|
|
523
497
|
if (vendor !== 'moonpay') {
|
|
@@ -570,14 +544,16 @@ class KycController extends base_controller_1.BaseController {
|
|
|
570
544
|
if (__classPrivateFieldGet(this, _KycController_generation, "f") !== generation) {
|
|
571
545
|
return;
|
|
572
546
|
}
|
|
573
|
-
|
|
547
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_dropTermsUnlessForVendor).call(this, vendor);
|
|
548
|
+
const hasTerms = Boolean(this.state.termsAcceptedAt) &&
|
|
549
|
+
this.state.acceptedDisclaimerIds.length > 0;
|
|
574
550
|
if (hasTerms && this.state.email) {
|
|
575
551
|
if (usesConsentsFlow(vendor)) {
|
|
576
552
|
// Consents-path vendors require T&C2 flags; if they weren't persisted
|
|
577
553
|
// (i.e. null from pre-migration state), require reacceptance.
|
|
578
|
-
const
|
|
579
|
-
|
|
580
|
-
|
|
554
|
+
const sumsubTncSigned = this.state.sumsubTncAccepted;
|
|
555
|
+
const idosTncSigned = this.state.idosTncAccepted;
|
|
556
|
+
if (sumsubTncSigned === null || idosTncSigned === null) {
|
|
581
557
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_applyUpdate).call(this, (state) => {
|
|
582
558
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_clearAcceptedTerms).call(this, state);
|
|
583
559
|
state.phase = 'terms';
|
|
@@ -586,19 +562,12 @@ class KycController extends base_controller_1.BaseController {
|
|
|
586
562
|
return;
|
|
587
563
|
}
|
|
588
564
|
await __classPrivateFieldGet(this, _KycController_instances, "m", _KycController_startConsentsSession).call(this, {
|
|
589
|
-
|
|
590
|
-
|
|
565
|
+
sumsubTncSigned,
|
|
566
|
+
idosTncSigned,
|
|
591
567
|
credentialReusabilityConsentGiven: this.state.credentialReusabilityConsentGiven ?? false,
|
|
592
568
|
});
|
|
593
569
|
}
|
|
594
570
|
else {
|
|
595
|
-
// TODO: should this be here? or should it exist at all?
|
|
596
|
-
if (vendor === 'moonpay' && this.state.vendorDisclaimers.length === 0) {
|
|
597
|
-
await this.loadDisclaimers();
|
|
598
|
-
if (__classPrivateFieldGet(this, _KycController_generation, "f") !== generation) {
|
|
599
|
-
return;
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
571
|
await __classPrivateFieldGet(this, _KycController_instances, "m", _KycController_createSession).call(this);
|
|
603
572
|
}
|
|
604
573
|
return;
|
|
@@ -633,7 +602,6 @@ class KycController extends base_controller_1.BaseController {
|
|
|
633
602
|
state.activeVendor = params.vendor;
|
|
634
603
|
if (params.vendor !== 'moonpay') {
|
|
635
604
|
__classPrivateFieldSet(this, _KycController_authClientToken, null, "f");
|
|
636
|
-
__classPrivateFieldSet(this, _KycController_moonpayFrameKeypair, null, "f");
|
|
637
605
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_clearMoonPaySession).call(this, state);
|
|
638
606
|
}
|
|
639
607
|
});
|
|
@@ -643,6 +611,10 @@ class KycController extends base_controller_1.BaseController {
|
|
|
643
611
|
vendor: params.vendor,
|
|
644
612
|
email: params.email,
|
|
645
613
|
});
|
|
614
|
+
if (__classPrivateFieldGet(this, _KycController_generation, "f") !== generation) {
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_dropTermsUnlessForVendor).call(this, params.vendor);
|
|
646
618
|
}
|
|
647
619
|
catch (error) {
|
|
648
620
|
if (__classPrivateFieldGet(this, _KycController_generation, "f") !== generation) {
|
|
@@ -671,18 +643,18 @@ class KycController extends base_controller_1.BaseController {
|
|
|
671
643
|
state.geoCountry = country;
|
|
672
644
|
});
|
|
673
645
|
}
|
|
674
|
-
const disclaimers = await this.messenger.call('KycService:
|
|
646
|
+
const disclaimers = await this.messenger.call('KycService:fetchDisclaimers', {
|
|
675
647
|
vendor: this.state.activeVendor,
|
|
676
648
|
country,
|
|
677
649
|
});
|
|
678
650
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_updateIfCurrent).call(this, generation, (state) => {
|
|
679
|
-
state.
|
|
680
|
-
state.
|
|
651
|
+
state.disclaimers = disclaimers;
|
|
652
|
+
state.disclaimersError = null;
|
|
681
653
|
});
|
|
682
654
|
}
|
|
683
655
|
catch (error) {
|
|
684
656
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_updateIfCurrent).call(this, generation, (state) => {
|
|
685
|
-
state.
|
|
657
|
+
state.disclaimersError = `Failed to load disclaimers: ${String(error)}`;
|
|
686
658
|
});
|
|
687
659
|
}
|
|
688
660
|
}
|
|
@@ -695,47 +667,44 @@ class KycController extends base_controller_1.BaseController {
|
|
|
695
667
|
* @param params.product - The consuming feature the flow runs for. See
|
|
696
668
|
* {@link initialize} for how the product drives the automatic post
|
|
697
669
|
* authentication continuation.
|
|
698
|
-
* @param params.
|
|
699
|
-
*
|
|
700
|
-
*
|
|
701
|
-
*
|
|
702
|
-
* customer accepted (`{ key, version }` records). Required for every vendor
|
|
703
|
-
* so callers explicitly declare acceptance.
|
|
670
|
+
* @param params.sumsubTncSigned - Whether Sumsub T&C were accepted (T&C2).
|
|
671
|
+
* Required for every vendor so callers explicitly declare acceptance.
|
|
672
|
+
* @param params.idosTncSigned - Whether idOS T&C were accepted (T&C2).
|
|
673
|
+
* Required for every vendor so callers explicitly declare acceptance.
|
|
704
674
|
* @param params.credentialReusabilityConsentGiven - Whether the customer
|
|
705
675
|
* consented to reuse existing idOS credentials. Used when recording
|
|
706
676
|
* session-scoped disclaimers on the consents path. Defaults to `false`.
|
|
707
677
|
*/
|
|
708
678
|
async acceptTermsAndStartSession(params) {
|
|
709
|
-
const
|
|
710
|
-
const
|
|
711
|
-
if (
|
|
712
|
-
|
|
679
|
+
const sumsubTncSigned = params?.sumsubTncSigned;
|
|
680
|
+
const idosTncSigned = params?.idosTncSigned;
|
|
681
|
+
if (typeof sumsubTncSigned !== 'boolean' ||
|
|
682
|
+
typeof idosTncSigned !== 'boolean') {
|
|
713
683
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_fail).call(this, 'Missing T&C2 acceptance flags.');
|
|
714
684
|
return;
|
|
715
685
|
}
|
|
716
|
-
const credentialReusabilityConsentGiven = params
|
|
686
|
+
const credentialReusabilityConsentGiven = params.credentialReusabilityConsentGiven ?? false;
|
|
717
687
|
const termsAcceptedAt = new Date().toISOString();
|
|
718
|
-
const disclaimerIds = this.state.
|
|
688
|
+
const disclaimerIds = this.state.disclaimers.map((disclaimer) => disclaimer.id);
|
|
719
689
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_applyUpdate).call(this, (state) => {
|
|
720
|
-
if (params
|
|
690
|
+
if (params.email) {
|
|
721
691
|
state.email = params.email;
|
|
722
692
|
}
|
|
723
|
-
if (params
|
|
693
|
+
if (params.product) {
|
|
724
694
|
state.activeProduct = params.product;
|
|
725
695
|
}
|
|
726
|
-
state.
|
|
727
|
-
state.
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
state.idosDisclaimersAccepted = idosDisclaimersAccepted;
|
|
696
|
+
state.termsAcceptedAt = termsAcceptedAt;
|
|
697
|
+
state.acceptedDisclaimerIds = disclaimerIds;
|
|
698
|
+
state.termsAcceptedVendor = state.activeVendor;
|
|
699
|
+
state.sumsubTncAccepted = sumsubTncSigned;
|
|
700
|
+
state.idosTncAccepted = idosTncSigned;
|
|
732
701
|
state.credentialReusabilityConsentGiven =
|
|
733
702
|
credentialReusabilityConsentGiven;
|
|
734
703
|
});
|
|
735
704
|
if (usesConsentsFlow(this.state.activeVendor)) {
|
|
736
705
|
await __classPrivateFieldGet(this, _KycController_instances, "m", _KycController_startConsentsSession).call(this, {
|
|
737
|
-
|
|
738
|
-
|
|
706
|
+
sumsubTncSigned,
|
|
707
|
+
idosTncSigned,
|
|
739
708
|
credentialReusabilityConsentGiven,
|
|
740
709
|
});
|
|
741
710
|
return;
|
|
@@ -747,12 +716,7 @@ class KycController extends base_controller_1.BaseController {
|
|
|
747
716
|
*/
|
|
748
717
|
clearSavedTerms() {
|
|
749
718
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_applyUpdate).call(this, (state) => {
|
|
750
|
-
|
|
751
|
-
getDefaultKycVendorDisclaimersAccepted();
|
|
752
|
-
state.providerDisclaimersAccepted =
|
|
753
|
-
getDefaultKycProviderDisclaimersAccepted();
|
|
754
|
-
state.idosDisclaimersAccepted = null;
|
|
755
|
-
state.credentialReusabilityConsentGiven = null;
|
|
719
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_clearAcceptedTerms).call(this, state);
|
|
756
720
|
});
|
|
757
721
|
}
|
|
758
722
|
/**
|
|
@@ -810,9 +774,9 @@ class KycController extends base_controller_1.BaseController {
|
|
|
810
774
|
}
|
|
811
775
|
let accessToken;
|
|
812
776
|
let clientToken;
|
|
813
|
-
if (credsEnvelope
|
|
777
|
+
if (credsEnvelope) {
|
|
814
778
|
try {
|
|
815
|
-
const { credentials } = (0, crypto_js_1.decryptCredentials)(credsEnvelope, __classPrivateFieldGet(this,
|
|
779
|
+
const { credentials } = (0, crypto_js_1.decryptCredentials)(credsEnvelope, __classPrivateFieldGet(this, _KycController_keypair, "f").privateKey);
|
|
816
780
|
accessToken = credentials.accessToken;
|
|
817
781
|
clientToken = credentials.clientToken;
|
|
818
782
|
}
|
|
@@ -835,14 +799,12 @@ class KycController extends base_controller_1.BaseController {
|
|
|
835
799
|
* @returns The Check-frame URL or `null`.
|
|
836
800
|
*/
|
|
837
801
|
buildCheckFrameUrl() {
|
|
838
|
-
if (this.state.activeVendor !== 'moonpay' ||
|
|
839
|
-
!this.state.moonpaySessionToken ||
|
|
840
|
-
!__classPrivateFieldGet(this, _KycController_moonpayFrameKeypair, "f")) {
|
|
802
|
+
if (this.state.activeVendor !== 'moonpay' || !this.state.sessionToken) {
|
|
841
803
|
return null;
|
|
842
804
|
}
|
|
843
805
|
const url = new URL(`${FRAMES_BASE_URL}/check-connection`);
|
|
844
|
-
url.searchParams.set('sessionToken', this.state.
|
|
845
|
-
url.searchParams.set('publicKey', __classPrivateFieldGet(this,
|
|
806
|
+
url.searchParams.set('sessionToken', this.state.sessionToken);
|
|
807
|
+
url.searchParams.set('publicKey', __classPrivateFieldGet(this, _KycController_keypair, "f").publicKeyHex);
|
|
846
808
|
url.searchParams.set('channelId', CHANNEL_CHECK);
|
|
847
809
|
url.searchParams.set('skipKyc', 'true');
|
|
848
810
|
return url.toString();
|
|
@@ -853,14 +815,12 @@ class KycController extends base_controller_1.BaseController {
|
|
|
853
815
|
* @returns The Auth-frame URL or `null`.
|
|
854
816
|
*/
|
|
855
817
|
buildAuthFrameUrl() {
|
|
856
|
-
if (this.state.activeVendor !== 'moonpay' ||
|
|
857
|
-
!__classPrivateFieldGet(this, _KycController_authClientToken, "f") ||
|
|
858
|
-
!__classPrivateFieldGet(this, _KycController_moonpayFrameKeypair, "f")) {
|
|
818
|
+
if (this.state.activeVendor !== 'moonpay' || !__classPrivateFieldGet(this, _KycController_authClientToken, "f")) {
|
|
859
819
|
return null;
|
|
860
820
|
}
|
|
861
821
|
const url = new URL(`${FRAMES_BASE_URL}/auth`);
|
|
862
822
|
url.searchParams.set('clientToken', __classPrivateFieldGet(this, _KycController_authClientToken, "f"));
|
|
863
|
-
url.searchParams.set('publicKey', __classPrivateFieldGet(this,
|
|
823
|
+
url.searchParams.set('publicKey', __classPrivateFieldGet(this, _KycController_keypair, "f").publicKeyHex);
|
|
864
824
|
url.searchParams.set('channelId', CHANNEL_AUTH);
|
|
865
825
|
return url.toString();
|
|
866
826
|
}
|
|
@@ -883,9 +843,9 @@ class KycController extends base_controller_1.BaseController {
|
|
|
883
843
|
* @returns Whether KYC is required.
|
|
884
844
|
*/
|
|
885
845
|
async checkKycRequired(params) {
|
|
886
|
-
const {
|
|
887
|
-
if (!
|
|
888
|
-
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_fail).call(this, 'Missing
|
|
846
|
+
const { accessToken } = this.state;
|
|
847
|
+
if (!accessToken) {
|
|
848
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_fail).call(this, 'Missing accessToken — repeat the authentication step.');
|
|
889
849
|
return false;
|
|
890
850
|
}
|
|
891
851
|
const country = params.country ?? this.state.geoCountry;
|
|
@@ -901,11 +861,7 @@ class KycController extends base_controller_1.BaseController {
|
|
|
901
861
|
state.statusMessage = 'Checking KYC status...';
|
|
902
862
|
});
|
|
903
863
|
try {
|
|
904
|
-
const { kycRequired } = await this.messenger.call('KycService:checkKycRequired', {
|
|
905
|
-
accessToken: moonpayAccessToken,
|
|
906
|
-
country,
|
|
907
|
-
capabilities: [{ product: params.product }],
|
|
908
|
-
});
|
|
864
|
+
const { kycRequired } = await this.messenger.call('KycService:checkKycRequired', { accessToken, country, capabilities: [{ product: params.product }] });
|
|
909
865
|
// The flow was reset while the check was in flight; discard the result
|
|
910
866
|
// rather than resurrecting a done/cached state on an idle controller.
|
|
911
867
|
const applied = __classPrivateFieldGet(this, _KycController_instances, "m", _KycController_updateIfCurrent).call(this, generation, (state) => {
|
|
@@ -1190,12 +1146,12 @@ class KycController extends base_controller_1.BaseController {
|
|
|
1190
1146
|
state.phase = 'idle';
|
|
1191
1147
|
state.statusMessage = '';
|
|
1192
1148
|
state.error = null;
|
|
1193
|
-
state.
|
|
1194
|
-
state.
|
|
1149
|
+
state.disclaimers = [];
|
|
1150
|
+
state.disclaimersError = null;
|
|
1195
1151
|
state.sessionDisclaimers = null;
|
|
1196
1152
|
state.credentialReusabilityConsentGiven = null;
|
|
1197
|
-
state.
|
|
1198
|
-
state.
|
|
1153
|
+
state.sessionToken = null;
|
|
1154
|
+
state.accessToken = null;
|
|
1199
1155
|
state.moonpayCustomerId = null;
|
|
1200
1156
|
state.activeVendor = 'moonpay';
|
|
1201
1157
|
state.activeProduct = null;
|
|
@@ -1224,7 +1180,7 @@ class KycController extends base_controller_1.BaseController {
|
|
|
1224
1180
|
}
|
|
1225
1181
|
}
|
|
1226
1182
|
exports.KycController = KycController;
|
|
1227
|
-
_KycController_sumsubLauncher = new WeakMap(),
|
|
1183
|
+
_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() {
|
|
1228
1184
|
return {
|
|
1229
1185
|
get: async (path, entropySourceId) => this.messenger.call('UserStorageController:performGetStorage', path, entropySourceId),
|
|
1230
1186
|
set: async (path, value, entropySourceId) => this.messenger.call('UserStorageController:performSetStorage', path, value, entropySourceId),
|
|
@@ -1236,14 +1192,13 @@ _KycController_sumsubLauncher = new WeakMap(), _KycController_moonpayFrameKeypai
|
|
|
1236
1192
|
* SumSub — skipping MoonPay Check/Auth frames.
|
|
1237
1193
|
*
|
|
1238
1194
|
* @param consents - T&C2 flags mapped onto the session disclaimer catalog.
|
|
1239
|
-
* @param consents.
|
|
1240
|
-
* @param consents.
|
|
1195
|
+
* @param consents.sumsubTncSigned - Whether Sumsub T&C were accepted.
|
|
1196
|
+
* @param consents.idosTncSigned - Whether idOS T&C were accepted.
|
|
1241
1197
|
* @param consents.credentialReusabilityConsentGiven - Whether credential
|
|
1242
1198
|
* reuse was accepted.
|
|
1243
1199
|
*/
|
|
1244
1200
|
async function _KycController_startConsentsSession(consents) {
|
|
1245
|
-
const { email } = this.state;
|
|
1246
|
-
const acceptedDisclaimerIds = (0, vendorDisclaimerAcceptance_js_1.ironDisclaimerIds)(this.state.vendorDisclaimersAccepted);
|
|
1201
|
+
const { email, acceptedDisclaimerIds } = this.state;
|
|
1247
1202
|
if (!email) {
|
|
1248
1203
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_fail).call(this, 'Missing email for consents session.');
|
|
1249
1204
|
return;
|
|
@@ -1287,7 +1242,7 @@ async function _KycController_startConsentsSession(consents) {
|
|
|
1287
1242
|
await this.refreshKycStatus();
|
|
1288
1243
|
}
|
|
1289
1244
|
catch (statusError) {
|
|
1290
|
-
|
|
1245
|
+
console.error('KYC status refresh failed:', statusError);
|
|
1291
1246
|
}
|
|
1292
1247
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_updateIfCurrent).call(this, generation, (state) => {
|
|
1293
1248
|
state.phase = 'done';
|
|
@@ -1323,7 +1278,7 @@ async function _KycController_startConsentsSession(consents) {
|
|
|
1323
1278
|
await this.refreshKycStatus();
|
|
1324
1279
|
}
|
|
1325
1280
|
catch (statusError) {
|
|
1326
|
-
|
|
1281
|
+
console.error('KYC status refresh failed:', statusError);
|
|
1327
1282
|
}
|
|
1328
1283
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_updateIfCurrent).call(this, generation, (state) => {
|
|
1329
1284
|
if (state.phase !== 'error' && state.phase !== 'done') {
|
|
@@ -1351,7 +1306,7 @@ async function _KycController_startConsentsSession(consents) {
|
|
|
1351
1306
|
});
|
|
1352
1307
|
return;
|
|
1353
1308
|
}
|
|
1354
|
-
|
|
1309
|
+
console.error('Consents session failed:', error);
|
|
1355
1310
|
if (__classPrivateFieldGet(this, _KycController_generation, "f") !== generation) {
|
|
1356
1311
|
return;
|
|
1357
1312
|
}
|
|
@@ -1378,8 +1333,8 @@ async function _KycController_startConsentsSession(consents) {
|
|
|
1378
1333
|
*
|
|
1379
1334
|
* @param sessionId - The UKYC session id.
|
|
1380
1335
|
* @param consents - T&C2 flags mapped onto catalog documents.
|
|
1381
|
-
* @param consents.
|
|
1382
|
-
* @param consents.
|
|
1336
|
+
* @param consents.sumsubTncSigned - Whether Sumsub T&C were accepted.
|
|
1337
|
+
* @param consents.idosTncSigned - Whether idOS T&C were accepted.
|
|
1383
1338
|
* @param consents.credentialReusabilityConsentGiven - Whether credential
|
|
1384
1339
|
* reuse was accepted.
|
|
1385
1340
|
* @param generation - Flow generation captured by the caller.
|
|
@@ -1393,12 +1348,12 @@ async function _KycController_recordSessionDisclaimers(sessionId, consents, gene
|
|
|
1393
1348
|
state.sessionDisclaimers = catalog;
|
|
1394
1349
|
state.statusMessage = 'Submitting consents...';
|
|
1395
1350
|
});
|
|
1396
|
-
if (isAcceptedCategoryEmpty(catalog.idOS, consents.
|
|
1397
|
-
isAcceptedCategoryEmpty(catalog.kycProvider, consents.
|
|
1351
|
+
if (isAcceptedCategoryEmpty(catalog.idOS, consents.idosTncSigned) ||
|
|
1352
|
+
isAcceptedCategoryEmpty(catalog.kycProvider, consents.sumsubTncSigned)) {
|
|
1398
1353
|
throw new Error('Session disclaimer catalog is missing documents for an accepted category.');
|
|
1399
1354
|
}
|
|
1400
|
-
const idOS =
|
|
1401
|
-
const kycProvider =
|
|
1355
|
+
const idOS = consentRecordsFromCatalog(catalog.idOS, consents.idosTncSigned);
|
|
1356
|
+
const kycProvider = consentRecordsFromCatalog(catalog.kycProvider, consents.sumsubTncSigned);
|
|
1402
1357
|
const reuseUnchanged = catalog.credentialReusabilityConsentGiven ===
|
|
1403
1358
|
consents.credentialReusabilityConsentGiven;
|
|
1404
1359
|
if (idOS.length === 0 && kycProvider.length === 0 && reuseUnchanged) {
|
|
@@ -1429,9 +1384,8 @@ async function _KycController_recordSessionDisclaimers(sessionId, consents, gene
|
|
|
1429
1384
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_applyUpdate).call(this, (state) => {
|
|
1430
1385
|
state.sessionDisclaimers = latest;
|
|
1431
1386
|
});
|
|
1432
|
-
|
|
1433
|
-
const
|
|
1434
|
-
const stillMissingProvider = acceptedCategoryStillMissing(latest.kycProvider, consents.providerDisclaimersAccepted);
|
|
1387
|
+
const stillMissingIdos = acceptedCategoryStillMissing(latest.idOS, consents.idosTncSigned);
|
|
1388
|
+
const stillMissingProvider = acceptedCategoryStillMissing(latest.kycProvider, consents.sumsubTncSigned);
|
|
1435
1389
|
const stillMissingReuse = consents.credentialReusabilityConsentGiven &&
|
|
1436
1390
|
!latest.credentialReusabilityConsentGiven;
|
|
1437
1391
|
if (stillMissingIdos || stillMissingProvider || stillMissingReuse) {
|
|
@@ -1443,9 +1397,7 @@ async function _KycController_recordSessionDisclaimers(sessionId, consents, gene
|
|
|
1443
1397
|
* Creates a vendor session from the currently stored terms + email.
|
|
1444
1398
|
*/
|
|
1445
1399
|
async function _KycController_createSession() {
|
|
1446
|
-
const { email } = this.state;
|
|
1447
|
-
const termsAcceptedAt = this.state.vendorDisclaimersAccepted.moonpay?.termsAcceptedAt;
|
|
1448
|
-
const acceptedDisclaimerIds = this.state.vendorDisclaimers.map((disclaimer) => disclaimer.id);
|
|
1400
|
+
const { email, termsAcceptedAt, acceptedDisclaimerIds } = this.state;
|
|
1449
1401
|
if (!email) {
|
|
1450
1402
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_fail).call(this, 'Missing email for session creation.');
|
|
1451
1403
|
return;
|
|
@@ -1460,7 +1412,7 @@ async function _KycController_createSession() {
|
|
|
1460
1412
|
// (or, on failure, invalid) session token, `buildAuthFrameUrl` cannot
|
|
1461
1413
|
// return a URL tied to an old client token, and `checkKycRequired` cannot
|
|
1462
1414
|
// run with an access token from an earlier authentication. The Check/Auth
|
|
1463
|
-
// frames re-populate these for the new session. Because `
|
|
1415
|
+
// frames re-populate these for the new session. Because `sessionToken` is
|
|
1464
1416
|
// cleared here and only re-set on success, a failed creation leaves it
|
|
1465
1417
|
// `null` rather than resurrecting the previous session.
|
|
1466
1418
|
// Capture the flow generation so a `reset()` landing while the create
|
|
@@ -1473,19 +1425,19 @@ async function _KycController_createSession() {
|
|
|
1473
1425
|
state.error = null;
|
|
1474
1426
|
state.phase = 'session';
|
|
1475
1427
|
state.statusMessage = 'Creating session...';
|
|
1476
|
-
state.
|
|
1477
|
-
state.
|
|
1428
|
+
state.sessionToken = null;
|
|
1429
|
+
state.accessToken = null;
|
|
1478
1430
|
});
|
|
1479
1431
|
try {
|
|
1480
1432
|
const { sessionToken } = await this.messenger.call('KycService:createSession', { email, termsAcceptedAt, disclaimerIds: acceptedDisclaimerIds });
|
|
1481
1433
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_updateIfCurrent).call(this, generation, (state) => {
|
|
1482
|
-
state.
|
|
1434
|
+
state.sessionToken = sessionToken;
|
|
1483
1435
|
state.phase = 'check';
|
|
1484
1436
|
state.statusMessage = 'Authenticating via Check frame...';
|
|
1485
1437
|
});
|
|
1486
1438
|
}
|
|
1487
1439
|
catch (error) {
|
|
1488
|
-
|
|
1440
|
+
console.error('Session creation failed:', error);
|
|
1489
1441
|
// A reset() superseded this flow while the request was in flight; leave
|
|
1490
1442
|
// the idle controller alone rather than forcing it back to `terms`.
|
|
1491
1443
|
if (__classPrivateFieldGet(this, _KycController_generation, "f") !== generation) {
|
|
@@ -1505,17 +1457,29 @@ async function _KycController_createSession() {
|
|
|
1505
1457
|
});
|
|
1506
1458
|
await this.loadDisclaimers();
|
|
1507
1459
|
}
|
|
1508
|
-
}, _KycController_clearAcceptedTerms = function _KycController_clearAcceptedTerms(state
|
|
1509
|
-
|
|
1510
|
-
state.
|
|
1511
|
-
state.
|
|
1512
|
-
|
|
1513
|
-
state.
|
|
1460
|
+
}, _KycController_clearAcceptedTerms = function _KycController_clearAcceptedTerms(state) {
|
|
1461
|
+
state.termsAcceptedAt = null;
|
|
1462
|
+
state.acceptedDisclaimerIds = [];
|
|
1463
|
+
state.termsAcceptedVendor = null;
|
|
1464
|
+
state.sumsubTncAccepted = null;
|
|
1465
|
+
state.idosTncAccepted = null;
|
|
1514
1466
|
state.credentialReusabilityConsentGiven = null;
|
|
1515
1467
|
}, _KycController_clearMoonPaySession = function _KycController_clearMoonPaySession(state) {
|
|
1516
1468
|
state.moonpayCustomerId = null;
|
|
1517
|
-
state.
|
|
1518
|
-
state.
|
|
1469
|
+
state.sessionToken = null;
|
|
1470
|
+
state.accessToken = null;
|
|
1471
|
+
}, _KycController_dropTermsUnlessForVendor = function _KycController_dropTermsUnlessForVendor(vendor) {
|
|
1472
|
+
if (__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_hasTermsForVendor).call(this, vendor)) {
|
|
1473
|
+
return;
|
|
1474
|
+
}
|
|
1475
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_applyUpdate).call(this, (state) => {
|
|
1476
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_clearAcceptedTerms).call(this, state);
|
|
1477
|
+
});
|
|
1478
|
+
}, _KycController_hasTermsForVendor = function _KycController_hasTermsForVendor(vendor) {
|
|
1479
|
+
if (this.state.termsAcceptedVendor === null) {
|
|
1480
|
+
return false;
|
|
1481
|
+
}
|
|
1482
|
+
return this.state.termsAcceptedVendor === vendor;
|
|
1519
1483
|
}, _KycController_handleCheckOutcome =
|
|
1520
1484
|
/**
|
|
1521
1485
|
* Applies a Check-frame outcome.
|
|
@@ -1527,7 +1491,7 @@ async function _KycController_createSession() {
|
|
|
1527
1491
|
async function _KycController_handleCheckOutcome(status, accessToken, clientToken) {
|
|
1528
1492
|
if (status === 'active' && accessToken) {
|
|
1529
1493
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_applyUpdate).call(this, (state) => {
|
|
1530
|
-
state.
|
|
1494
|
+
state.accessToken = accessToken;
|
|
1531
1495
|
state.phase = 'form';
|
|
1532
1496
|
state.statusMessage = 'Already authenticated. Review to submit.';
|
|
1533
1497
|
});
|
|
@@ -1557,7 +1521,7 @@ async function _KycController_handleCheckOutcome(status, accessToken, clientToke
|
|
|
1557
1521
|
async function _KycController_handleAuthOutcome(status, accessToken) {
|
|
1558
1522
|
if (status === 'active' && accessToken) {
|
|
1559
1523
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_applyUpdate).call(this, (state) => {
|
|
1560
|
-
state.
|
|
1524
|
+
state.accessToken = accessToken;
|
|
1561
1525
|
state.phase = 'form';
|
|
1562
1526
|
state.statusMessage = 'Authenticated. Review to submit.';
|
|
1563
1527
|
});
|
|
@@ -1620,7 +1584,7 @@ async function _KycController_continueAfterAuthentication() {
|
|
|
1620
1584
|
return {
|
|
1621
1585
|
vendor: 'moonpay',
|
|
1622
1586
|
vendorMetadata: {
|
|
1623
|
-
moonPayAccessToken: this.state.
|
|
1587
|
+
moonPayAccessToken: this.state.accessToken,
|
|
1624
1588
|
moonPayUserId: this.state.moonpayCustomerId,
|
|
1625
1589
|
},
|
|
1626
1590
|
};
|