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