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