@metamask-previews/kyc-controller 0.0.0-preview-7cfd8be → 0.0.0-preview-a3cea003b
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 +29 -3
- package/dist/KycController-method-action-types.cjs.map +1 -1
- package/dist/KycController-method-action-types.d.cts +48 -2
- package/dist/KycController-method-action-types.d.cts.map +1 -1
- package/dist/KycController-method-action-types.d.mts +48 -2
- 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 +469 -12
- package/dist/KycController.cjs.map +1 -1
- package/dist/KycController.d.cts +109 -5
- package/dist/KycController.d.cts.map +1 -1
- package/dist/KycController.d.mts +109 -5
- package/dist/KycController.d.mts.map +1 -1
- package/dist/KycController.mjs +469 -12
- 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 +38 -2
- package/dist/KycService-method-action-types.d.cts.map +1 -1
- package/dist/KycService-method-action-types.d.mts +38 -2
- 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 +177 -22
- package/dist/KycService.cjs.map +1 -1
- package/dist/KycService.d.cts +97 -12
- package/dist/KycService.d.cts.map +1 -1
- package/dist/KycService.d.mts +97 -12
- package/dist/KycService.d.mts.map +1 -1
- package/dist/KycService.mjs +178 -23
- package/dist/KycService.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +5 -5
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +49 -10
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +49 -10
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +1 -1
package/dist/KycController.cjs
CHANGED
|
@@ -10,7 +10,7 @@ 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, _KycController_keypair, _KycController_authClientToken, _KycController_generation, _KycController_sessionStatusPollIntervalMs, _KycController_pollTimer, _KycController_pollToken, _KycController_localUserSecretStore, _KycController_createSession, _KycController_clearAcceptedTerms, _KycController_handleCheckOutcome, _KycController_handleAuthOutcome, _KycController_continueAfterAuthentication, _KycController_requireTermsReacceptance, _KycController_startSessionStatusPolling, _KycController_pollSessionStatusOnce, _KycController_stopPolling, _KycController_updateIfCurrent, _KycController_applyUpdate, _KycController_fail;
|
|
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_createSession, _KycController_clearAcceptedTerms, _KycController_hasTermsForVendor, _KycController_handleCheckOutcome, _KycController_handleAuthOutcome, _KycController_continueAfterAuthentication, _KycController_requireTermsReacceptance, _KycController_buildUkycSessionVendorFields, _KycController_fetchAndApplyUserStatus, _KycController_applyUserStatus, _KycController_ensureUserStatusPolling, _KycController_stopUserStatusPolling, _KycController_startSessionStatusPolling, _KycController_pollSessionStatusOnce, _KycController_stopPolling, _KycController_updateIfCurrent, _KycController_applyUpdate, _KycController_fail;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.KycController = exports.getDefaultKycControllerState = exports.controllerName = void 0;
|
|
16
16
|
const base_controller_1 = require("@metamask/base-controller");
|
|
@@ -87,6 +87,12 @@ const SUCCESSFUL_SESSION_STATUSES = new Set([
|
|
|
87
87
|
// to do, so the sub-flow stops before launching the SDK and surfaces this
|
|
88
88
|
// message.
|
|
89
89
|
const VENDOR_PROCESSING_MESSAGE = 'Your KYC has been submitted and is being processed by the vendor.';
|
|
90
|
+
// UKYC / relay error indicating the applicant already finished KYC. Mapped to
|
|
91
|
+
// the simplified `completed` user status for the Money toast surface.
|
|
92
|
+
const SESSION_NOT_IN_VALID_STATE = 'session_not_in_valid_state';
|
|
93
|
+
// How often to refresh the user-keyed `GET /kyc/status` while the simplified
|
|
94
|
+
// status is still `pending`. Overridable via the constructor.
|
|
95
|
+
const DEFAULT_USER_STATUS_POLL_INTERVAL_MS = 15000;
|
|
90
96
|
const kycControllerMetadata = {
|
|
91
97
|
phase: {
|
|
92
98
|
includeInDebugSnapshot: true,
|
|
@@ -124,6 +130,24 @@ const kycControllerMetadata = {
|
|
|
124
130
|
persist: true,
|
|
125
131
|
usedInUi: false,
|
|
126
132
|
},
|
|
133
|
+
termsAcceptedVendor: {
|
|
134
|
+
includeInDebugSnapshot: true,
|
|
135
|
+
includeInStateLogs: true,
|
|
136
|
+
persist: true,
|
|
137
|
+
usedInUi: false,
|
|
138
|
+
},
|
|
139
|
+
sumsubTncAccepted: {
|
|
140
|
+
includeInDebugSnapshot: true,
|
|
141
|
+
includeInStateLogs: true,
|
|
142
|
+
persist: true,
|
|
143
|
+
usedInUi: false,
|
|
144
|
+
},
|
|
145
|
+
idosTncAccepted: {
|
|
146
|
+
includeInDebugSnapshot: true,
|
|
147
|
+
includeInStateLogs: true,
|
|
148
|
+
persist: true,
|
|
149
|
+
usedInUi: false,
|
|
150
|
+
},
|
|
127
151
|
disclaimers: {
|
|
128
152
|
includeInDebugSnapshot: false,
|
|
129
153
|
includeInStateLogs: false,
|
|
@@ -160,6 +184,12 @@ const kycControllerMetadata = {
|
|
|
160
184
|
persist: false,
|
|
161
185
|
usedInUi: false,
|
|
162
186
|
},
|
|
187
|
+
activeVendor: {
|
|
188
|
+
includeInDebugSnapshot: true,
|
|
189
|
+
includeInStateLogs: true,
|
|
190
|
+
persist: false,
|
|
191
|
+
usedInUi: true,
|
|
192
|
+
},
|
|
163
193
|
activeProduct: {
|
|
164
194
|
includeInDebugSnapshot: true,
|
|
165
195
|
includeInStateLogs: true,
|
|
@@ -178,6 +208,24 @@ const kycControllerMetadata = {
|
|
|
178
208
|
persist: true,
|
|
179
209
|
usedInUi: false,
|
|
180
210
|
},
|
|
211
|
+
userStatus: {
|
|
212
|
+
includeInDebugSnapshot: true,
|
|
213
|
+
includeInStateLogs: true,
|
|
214
|
+
persist: true,
|
|
215
|
+
usedInUi: true,
|
|
216
|
+
},
|
|
217
|
+
userStatusSumsubSessionId: {
|
|
218
|
+
includeInDebugSnapshot: false,
|
|
219
|
+
includeInStateLogs: false,
|
|
220
|
+
persist: true,
|
|
221
|
+
usedInUi: true,
|
|
222
|
+
},
|
|
223
|
+
userStatusErrorCode: {
|
|
224
|
+
includeInDebugSnapshot: true,
|
|
225
|
+
includeInStateLogs: true,
|
|
226
|
+
persist: true,
|
|
227
|
+
usedInUi: true,
|
|
228
|
+
},
|
|
181
229
|
sumsub: {
|
|
182
230
|
includeInDebugSnapshot: false,
|
|
183
231
|
includeInStateLogs: false,
|
|
@@ -198,15 +246,22 @@ function getDefaultKycControllerState() {
|
|
|
198
246
|
email: null,
|
|
199
247
|
termsAcceptedAt: null,
|
|
200
248
|
acceptedDisclaimerIds: [],
|
|
249
|
+
termsAcceptedVendor: null,
|
|
250
|
+
sumsubTncAccepted: null,
|
|
251
|
+
idosTncAccepted: null,
|
|
201
252
|
disclaimers: [],
|
|
202
253
|
disclaimersError: null,
|
|
203
254
|
geoCountry: null,
|
|
204
255
|
sessionToken: null,
|
|
205
256
|
accessToken: null,
|
|
206
257
|
moonpayCustomerId: null,
|
|
258
|
+
activeVendor: 'moonpay',
|
|
207
259
|
activeProduct: null,
|
|
208
260
|
kycRequiredByProduct: {},
|
|
209
261
|
lastCheckedAt: null,
|
|
262
|
+
userStatus: null,
|
|
263
|
+
userStatusSumsubSessionId: null,
|
|
264
|
+
userStatusErrorCode: null,
|
|
210
265
|
sumsub: {
|
|
211
266
|
status: 'idle',
|
|
212
267
|
result: null,
|
|
@@ -217,11 +272,34 @@ function getDefaultKycControllerState() {
|
|
|
217
272
|
};
|
|
218
273
|
}
|
|
219
274
|
exports.getDefaultKycControllerState = getDefaultKycControllerState;
|
|
275
|
+
/**
|
|
276
|
+
* Whether an error indicates the applicant already finished KYC — the UKYC /
|
|
277
|
+
* relay `session_not_in_valid_state` signal — which the controller maps to the
|
|
278
|
+
* simplified `completed` user status.
|
|
279
|
+
*
|
|
280
|
+
* @param error - The caught error.
|
|
281
|
+
* @returns `true` when the error carries the `session_not_in_valid_state`
|
|
282
|
+
* marker.
|
|
283
|
+
*/
|
|
284
|
+
function isSessionAlreadyCompletedError(error) {
|
|
285
|
+
return String(error).includes(SESSION_NOT_IN_VALID_STATE);
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Vendors other than MoonPay skip Check/Auth frames and use the empty-shell
|
|
289
|
+
* customer + consents path instead.
|
|
290
|
+
*
|
|
291
|
+
* @param vendor - The identity vendor for the current flow.
|
|
292
|
+
* @returns `true` when the vendor uses the consents session path.
|
|
293
|
+
*/
|
|
294
|
+
function usesConsentsFlow(vendor) {
|
|
295
|
+
return vendor !== 'moonpay';
|
|
296
|
+
}
|
|
220
297
|
// === MESSENGER ===
|
|
221
298
|
const MESSENGER_EXPOSED_METHODS = [
|
|
222
299
|
'initialize',
|
|
223
300
|
'loadDisclaimers',
|
|
224
301
|
'acceptTermsAndStartSession',
|
|
302
|
+
'createVendorCustomer',
|
|
225
303
|
'clearSavedTerms',
|
|
226
304
|
'handleFrameMessage',
|
|
227
305
|
'buildCheckFrameUrl',
|
|
@@ -229,6 +307,8 @@ const MESSENGER_EXPOSED_METHODS = [
|
|
|
229
307
|
'buildResetFrameUrl',
|
|
230
308
|
'checkKycRequired',
|
|
231
309
|
'getKycStatus',
|
|
310
|
+
'getCustomerIdentity',
|
|
311
|
+
'refreshKycStatus',
|
|
232
312
|
'startSumSub',
|
|
233
313
|
'getSessionStatus',
|
|
234
314
|
'reset',
|
|
@@ -251,8 +331,10 @@ class KycController extends base_controller_1.BaseController {
|
|
|
251
331
|
* @param options.sumsubLauncher - The platform SumSub launcher adapter.
|
|
252
332
|
* @param options.sessionStatusPollIntervalMs - How often to poll the UKYC
|
|
253
333
|
* session status after the SumSub SDK completes.
|
|
334
|
+
* @param options.userStatusPollIntervalMs - How often to refresh the
|
|
335
|
+
* user-keyed KYC status while it is still `pending`.
|
|
254
336
|
*/
|
|
255
|
-
constructor({ messenger, state, sumsubLauncher, sessionStatusPollIntervalMs = DEFAULT_SESSION_STATUS_POLL_INTERVAL_MS, }) {
|
|
337
|
+
constructor({ messenger, state, sumsubLauncher, sessionStatusPollIntervalMs = DEFAULT_SESSION_STATUS_POLL_INTERVAL_MS, userStatusPollIntervalMs = DEFAULT_USER_STATUS_POLL_INTERVAL_MS, }) {
|
|
256
338
|
super({
|
|
257
339
|
messenger,
|
|
258
340
|
metadata: kycControllerMetadata,
|
|
@@ -283,8 +365,23 @@ class KycController extends base_controller_1.BaseController {
|
|
|
283
365
|
* let an already-awaiting request finish and reschedule.
|
|
284
366
|
*/
|
|
285
367
|
_KycController_pollToken.set(this, 0);
|
|
368
|
+
/** Interval, in milliseconds, between user-keyed status polls. */
|
|
369
|
+
_KycController_userStatusPollIntervalMs.set(this, void 0);
|
|
370
|
+
/** Handle for the scheduled next user-status poll, or `null`. */
|
|
371
|
+
_KycController_userStatusPollTimer.set(this, null);
|
|
372
|
+
/**
|
|
373
|
+
* Whether a user-status poll loop is currently active. Tracked separately
|
|
374
|
+
* from {@link #userStatusPollTimer} because a scheduled tick clears the timer
|
|
375
|
+
* handle before awaiting `fetchKycStatus`; relying on the handle alone would
|
|
376
|
+
* let a concurrent {@link refreshKycStatus} start a second loop on the same
|
|
377
|
+
* token during that in-flight window.
|
|
378
|
+
*/
|
|
379
|
+
_KycController_userStatusPolling.set(this, false);
|
|
380
|
+
/** Monotonic token for the user-status poll loop (see `#pollToken`). */
|
|
381
|
+
_KycController_userStatusPollToken.set(this, 0);
|
|
286
382
|
__classPrivateFieldSet(this, _KycController_sumsubLauncher, sumsubLauncher, "f");
|
|
287
383
|
__classPrivateFieldSet(this, _KycController_sessionStatusPollIntervalMs, sessionStatusPollIntervalMs, "f");
|
|
384
|
+
__classPrivateFieldSet(this, _KycController_userStatusPollIntervalMs, userStatusPollIntervalMs, "f");
|
|
288
385
|
__classPrivateFieldSet(this, _KycController_keypair, (0, crypto_js_1.generateKeyPair)(), "f");
|
|
289
386
|
this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
|
|
290
387
|
}
|
|
@@ -299,6 +396,8 @@ class KycController extends base_controller_1.BaseController {
|
|
|
299
396
|
* authentication completes (and chains into document verification when KYC
|
|
300
397
|
* is required). When omitted, the flow stops at `form` and the consumer must
|
|
301
398
|
* call `checkKycRequired` manually.
|
|
399
|
+
* @param params.vendor - Identity vendor for this flow. Non-MoonPay vendors
|
|
400
|
+
* skip Check/Auth frames and use the consents path. Defaults to `moonpay`.
|
|
302
401
|
*/
|
|
303
402
|
async initialize(params) {
|
|
304
403
|
// A repeat `initialize` while a session flow is already in progress must
|
|
@@ -309,6 +408,7 @@ class KycController extends base_controller_1.BaseController {
|
|
|
309
408
|
if (IN_PROGRESS_PHASES.includes(this.state.phase)) {
|
|
310
409
|
return;
|
|
311
410
|
}
|
|
411
|
+
const vendor = params?.vendor ?? 'moonpay';
|
|
312
412
|
// `initialize` starts a fresh flow, so `activeProduct` is always reset to
|
|
313
413
|
// this call's product (or `null`). Otherwise a prior run's product could
|
|
314
414
|
// linger and cause `#continueAfterAuthentication` to auto-run the check /
|
|
@@ -317,6 +417,19 @@ class KycController extends base_controller_1.BaseController {
|
|
|
317
417
|
if (params?.email) {
|
|
318
418
|
state.email = params.email;
|
|
319
419
|
}
|
|
420
|
+
// Terms acceptance is vendor-scoped: reusing another vendor's saved
|
|
421
|
+
// acceptance would skip loading this vendor's disclaimers and submit its
|
|
422
|
+
// ids to the wrong vendor.
|
|
423
|
+
if (!__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_hasTermsForVendor).call(this, vendor)) {
|
|
424
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_clearAcceptedTerms).call(this, state);
|
|
425
|
+
}
|
|
426
|
+
state.activeVendor = vendor;
|
|
427
|
+
// `moonpayCustomerId` is only ever issued by the MoonPay Check / Auth
|
|
428
|
+
// frames. Leaving it set while the flow switches to another vendor would
|
|
429
|
+
// make `getCustomerIdentity` report a MoonPay id under the wrong vendor.
|
|
430
|
+
if (vendor !== 'moonpay') {
|
|
431
|
+
state.moonpayCustomerId = null;
|
|
432
|
+
}
|
|
320
433
|
state.activeProduct = params?.product ?? null;
|
|
321
434
|
});
|
|
322
435
|
// Capture the flow generation so a `reset()` landing while the async
|
|
@@ -333,10 +446,48 @@ class KycController extends base_controller_1.BaseController {
|
|
|
333
446
|
catch {
|
|
334
447
|
// Ignore; disclaimers loading will surface a country error if needed.
|
|
335
448
|
}
|
|
449
|
+
if (usesConsentsFlow(vendor) && this.state.email) {
|
|
450
|
+
try {
|
|
451
|
+
await this.messenger.call('KycService:createVendorCustomer', {
|
|
452
|
+
vendor,
|
|
453
|
+
email: this.state.email,
|
|
454
|
+
});
|
|
455
|
+
if (__classPrivateFieldGet(this, _KycController_generation, "f") !== generation) {
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
catch (error) {
|
|
460
|
+
if (__classPrivateFieldGet(this, _KycController_generation, "f") !== generation) {
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_fail).call(this, `Vendor customer creation failed: ${String(error)}`);
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
336
467
|
const hasTerms = Boolean(this.state.termsAcceptedAt) &&
|
|
337
468
|
this.state.acceptedDisclaimerIds.length > 0;
|
|
338
469
|
if (hasTerms && this.state.email) {
|
|
339
|
-
|
|
470
|
+
if (usesConsentsFlow(vendor)) {
|
|
471
|
+
// Consents-path vendors require T&C2 flags; if they weren't persisted
|
|
472
|
+
// (i.e. null from pre-migration state), require reacceptance.
|
|
473
|
+
const sumsubTncSigned = this.state.sumsubTncAccepted;
|
|
474
|
+
const idosTncSigned = this.state.idosTncAccepted;
|
|
475
|
+
if (sumsubTncSigned === null || idosTncSigned === null) {
|
|
476
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_applyUpdate).call(this, (state) => {
|
|
477
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_clearAcceptedTerms).call(this, state);
|
|
478
|
+
state.phase = 'terms';
|
|
479
|
+
});
|
|
480
|
+
await this.loadDisclaimers();
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
await __classPrivateFieldGet(this, _KycController_instances, "m", _KycController_startConsentsSession).call(this, {
|
|
484
|
+
sumsubTncSigned,
|
|
485
|
+
idosTncSigned,
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
else {
|
|
489
|
+
await __classPrivateFieldGet(this, _KycController_instances, "m", _KycController_createSession).call(this);
|
|
490
|
+
}
|
|
340
491
|
return;
|
|
341
492
|
}
|
|
342
493
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_applyUpdate).call(this, (state) => {
|
|
@@ -344,6 +495,43 @@ class KycController extends base_controller_1.BaseController {
|
|
|
344
495
|
});
|
|
345
496
|
await this.loadDisclaimers();
|
|
346
497
|
}
|
|
498
|
+
/**
|
|
499
|
+
* Creates (or resumes) an empty-shell customer for the given identity
|
|
500
|
+
* vendor. Exposed so a consumer can ensure the customer exists before
|
|
501
|
+
* showing T&C screens independently of {@link initialize}.
|
|
502
|
+
*
|
|
503
|
+
* @param params - The parameters.
|
|
504
|
+
* @param params.vendor - Identity vendor for the customer.
|
|
505
|
+
* @param params.email - Email for the vendor customer.
|
|
506
|
+
*/
|
|
507
|
+
async createVendorCustomer(params) {
|
|
508
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_applyUpdate).call(this, (state) => {
|
|
509
|
+
state.email = params.email;
|
|
510
|
+
// See `initialize`: acceptance recorded for another vendor cannot carry
|
|
511
|
+
// over, and a MoonPay-issued customer id must not survive a switch to
|
|
512
|
+
// another vendor or `getCustomerIdentity` reports the wrong vendor.
|
|
513
|
+
if (!__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_hasTermsForVendor).call(this, params.vendor)) {
|
|
514
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_clearAcceptedTerms).call(this, state);
|
|
515
|
+
}
|
|
516
|
+
state.activeVendor = params.vendor;
|
|
517
|
+
if (params.vendor !== 'moonpay') {
|
|
518
|
+
state.moonpayCustomerId = null;
|
|
519
|
+
}
|
|
520
|
+
});
|
|
521
|
+
const generation = __classPrivateFieldGet(this, _KycController_generation, "f");
|
|
522
|
+
try {
|
|
523
|
+
await this.messenger.call('KycService:createVendorCustomer', {
|
|
524
|
+
vendor: params.vendor,
|
|
525
|
+
email: params.email,
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
catch (error) {
|
|
529
|
+
if (__classPrivateFieldGet(this, _KycController_generation, "f") !== generation) {
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_fail).call(this, `Vendor customer creation failed: ${String(error)}`);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
347
535
|
/**
|
|
348
536
|
* Loads the disclaimers for the resolved (or provided) country.
|
|
349
537
|
*
|
|
@@ -364,7 +552,10 @@ class KycController extends base_controller_1.BaseController {
|
|
|
364
552
|
state.geoCountry = country;
|
|
365
553
|
});
|
|
366
554
|
}
|
|
367
|
-
const disclaimers = await this.messenger.call('KycService:fetchDisclaimers', {
|
|
555
|
+
const disclaimers = await this.messenger.call('KycService:fetchDisclaimers', {
|
|
556
|
+
vendor: this.state.activeVendor,
|
|
557
|
+
country,
|
|
558
|
+
});
|
|
368
559
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_updateIfCurrent).call(this, generation, (state) => {
|
|
369
560
|
state.disclaimers = disclaimers;
|
|
370
561
|
state.disclaimersError = null;
|
|
@@ -380,25 +571,43 @@ class KycController extends base_controller_1.BaseController {
|
|
|
380
571
|
* Captures terms acceptance for the currently loaded disclaimers and creates
|
|
381
572
|
* a session.
|
|
382
573
|
*
|
|
383
|
-
* @param params -
|
|
574
|
+
* @param params - The parameters.
|
|
384
575
|
* @param params.email - The account email to associate with the session.
|
|
385
576
|
* @param params.product - The consuming feature the flow runs for. See
|
|
386
577
|
* {@link initialize} for how the product drives the automatic post
|
|
387
578
|
* authentication continuation.
|
|
579
|
+
* @param params.sumsubTncSigned - Whether Sumsub T&C were accepted (T&C2).
|
|
580
|
+
* Required for every vendor so callers explicitly declare acceptance.
|
|
581
|
+
* @param params.idosTncSigned - Whether idOS T&C were accepted (T&C2).
|
|
582
|
+
* Required for every vendor so callers explicitly declare acceptance.
|
|
388
583
|
*/
|
|
389
584
|
async acceptTermsAndStartSession(params) {
|
|
585
|
+
const sumsubTncSigned = params?.sumsubTncSigned;
|
|
586
|
+
const idosTncSigned = params?.idosTncSigned;
|
|
587
|
+
if (typeof sumsubTncSigned !== 'boolean' ||
|
|
588
|
+
typeof idosTncSigned !== 'boolean') {
|
|
589
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_fail).call(this, 'Missing T&C2 acceptance flags.');
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
390
592
|
const termsAcceptedAt = new Date().toISOString();
|
|
391
593
|
const disclaimerIds = this.state.disclaimers.map((disclaimer) => disclaimer.id);
|
|
392
594
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_applyUpdate).call(this, (state) => {
|
|
393
|
-
if (params
|
|
595
|
+
if (params.email) {
|
|
394
596
|
state.email = params.email;
|
|
395
597
|
}
|
|
396
|
-
if (params
|
|
598
|
+
if (params.product) {
|
|
397
599
|
state.activeProduct = params.product;
|
|
398
600
|
}
|
|
399
601
|
state.termsAcceptedAt = termsAcceptedAt;
|
|
400
602
|
state.acceptedDisclaimerIds = disclaimerIds;
|
|
603
|
+
state.termsAcceptedVendor = state.activeVendor;
|
|
604
|
+
state.sumsubTncAccepted = sumsubTncSigned;
|
|
605
|
+
state.idosTncAccepted = idosTncSigned;
|
|
401
606
|
});
|
|
607
|
+
if (usesConsentsFlow(this.state.activeVendor)) {
|
|
608
|
+
await __classPrivateFieldGet(this, _KycController_instances, "m", _KycController_startConsentsSession).call(this, { sumsubTncSigned, idosTncSigned });
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
402
611
|
await __classPrivateFieldGet(this, _KycController_instances, "m", _KycController_createSession).call(this);
|
|
403
612
|
}
|
|
404
613
|
/**
|
|
@@ -580,6 +789,25 @@ class KycController extends base_controller_1.BaseController {
|
|
|
580
789
|
getKycStatus(params) {
|
|
581
790
|
return this.state.kycRequiredByProduct[params.product];
|
|
582
791
|
}
|
|
792
|
+
/**
|
|
793
|
+
* Returns the vendor-scoped identity for the currently authenticated
|
|
794
|
+
* customer, or `null` when the flow has not yet captured a vendor customer
|
|
795
|
+
* id (before authentication or after {@link reset}).
|
|
796
|
+
*
|
|
797
|
+
* Exposed so consumers (e.g. ramps autoramp creation) can attach the vendor
|
|
798
|
+
* customer id to downstream calls without reading the full KYC state, which
|
|
799
|
+
* also holds session/access tokens. The id is session-scoped and never
|
|
800
|
+
* persisted.
|
|
801
|
+
*
|
|
802
|
+
* @returns The current {@link KycCustomerIdentity}, or `null`.
|
|
803
|
+
*/
|
|
804
|
+
getCustomerIdentity() {
|
|
805
|
+
const { moonpayCustomerId, activeVendor } = this.state;
|
|
806
|
+
if (!moonpayCustomerId) {
|
|
807
|
+
return null;
|
|
808
|
+
}
|
|
809
|
+
return { vendor: activeVendor, id: moonpayCustomerId };
|
|
810
|
+
}
|
|
583
811
|
/**
|
|
584
812
|
* Runs the SumSub document-verification sub-flow end to end:
|
|
585
813
|
*
|
|
@@ -660,10 +888,7 @@ class KycController extends base_controller_1.BaseController {
|
|
|
660
888
|
});
|
|
661
889
|
const { sessionId, kycStatus, finalStatus } = await this.messenger.call('KycService:createUkycSession', {
|
|
662
890
|
jwtToken,
|
|
663
|
-
|
|
664
|
-
moonPayAccessToken: this.state.accessToken,
|
|
665
|
-
moonPayUserId: this.state.moonpayCustomerId,
|
|
666
|
-
},
|
|
891
|
+
...__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_buildUkycSessionVendorFields).call(this),
|
|
667
892
|
wrappedEncryptionKey,
|
|
668
893
|
ukycCapabilityToken,
|
|
669
894
|
});
|
|
@@ -753,6 +978,28 @@ class KycController extends base_controller_1.BaseController {
|
|
|
753
978
|
return result;
|
|
754
979
|
}
|
|
755
980
|
catch (error) {
|
|
981
|
+
// Applicant already finished KYC — treat as completed for Money toast.
|
|
982
|
+
if (isSessionAlreadyCompletedError(error)) {
|
|
983
|
+
// A reset() may have landed while `launch` was in flight; forcing
|
|
984
|
+
// `completed` (and publishing `statusChanged`) on an idle controller
|
|
985
|
+
// would resurrect a flow the consumer already tore down.
|
|
986
|
+
if (__classPrivateFieldGet(this, _KycController_generation, "f") !== generation) {
|
|
987
|
+
return { alreadyCompleted: true };
|
|
988
|
+
}
|
|
989
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_applyUserStatus).call(this, {
|
|
990
|
+
status: 'completed',
|
|
991
|
+
sumsubSessionId: null,
|
|
992
|
+
errorCode: null,
|
|
993
|
+
});
|
|
994
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_updateIfCurrent).call(this, generation, (state) => {
|
|
995
|
+
state.sumsub.status = 'complete';
|
|
996
|
+
state.sumsub.result = { alreadyCompleted: true };
|
|
997
|
+
state.statusMessage = 'KYC already completed.';
|
|
998
|
+
state.phase = 'done';
|
|
999
|
+
state.error = null;
|
|
1000
|
+
});
|
|
1001
|
+
return { alreadyCompleted: true };
|
|
1002
|
+
}
|
|
756
1003
|
const result = { error: String(error) };
|
|
757
1004
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_updateIfCurrent).call(this, generation, (state) => {
|
|
758
1005
|
state.sumsub.status = 'failed';
|
|
@@ -761,6 +1008,31 @@ class KycController extends base_controller_1.BaseController {
|
|
|
761
1008
|
return result;
|
|
762
1009
|
}
|
|
763
1010
|
}
|
|
1011
|
+
/**
|
|
1012
|
+
* Refreshes the user-keyed simplified KYC status from `GET /kyc/status`,
|
|
1013
|
+
* stores it on state, publishes {@link KycControllerStatusChangedEvent}, and
|
|
1014
|
+
* schedules short-interval polling while the status is `pending`.
|
|
1015
|
+
*
|
|
1016
|
+
* @returns The latest status payload.
|
|
1017
|
+
*/
|
|
1018
|
+
async refreshKycStatus() {
|
|
1019
|
+
const generation = __classPrivateFieldGet(this, _KycController_generation, "f");
|
|
1020
|
+
const payload = await __classPrivateFieldGet(this, _KycController_instances, "m", _KycController_fetchAndApplyUserStatus).call(this);
|
|
1021
|
+
// A `reset()` landing while the request was in flight already stopped
|
|
1022
|
+
// polling and left the flow idle, and the payload above is the pre-reset
|
|
1023
|
+
// cached status. Starting a loop from it would poll — and publish
|
|
1024
|
+
// `statusChanged` — on a torn-down flow.
|
|
1025
|
+
if (__classPrivateFieldGet(this, _KycController_generation, "f") !== generation) {
|
|
1026
|
+
return payload;
|
|
1027
|
+
}
|
|
1028
|
+
if (payload.status === 'pending') {
|
|
1029
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_ensureUserStatusPolling).call(this);
|
|
1030
|
+
}
|
|
1031
|
+
else {
|
|
1032
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_stopUserStatusPolling).call(this);
|
|
1033
|
+
}
|
|
1034
|
+
return payload;
|
|
1035
|
+
}
|
|
764
1036
|
/**
|
|
765
1037
|
* Fetches the current UKYC session status for the active sub-flow and records
|
|
766
1038
|
* it on state. Useful for a one-off refresh outside the automatic polling
|
|
@@ -792,6 +1064,7 @@ class KycController extends base_controller_1.BaseController {
|
|
|
792
1064
|
// Stop any session-status polling so a late poll cannot write onto the
|
|
793
1065
|
// now-idle controller.
|
|
794
1066
|
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_stopPolling).call(this);
|
|
1067
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_stopUserStatusPolling).call(this);
|
|
795
1068
|
// Invalidate any in-flight async work started before this reset so its
|
|
796
1069
|
// results are discarded rather than written onto the now-idle controller.
|
|
797
1070
|
__classPrivateFieldSet(this, _KycController_generation, __classPrivateFieldGet(this, _KycController_generation, "f") + 1, "f");
|
|
@@ -804,6 +1077,7 @@ class KycController extends base_controller_1.BaseController {
|
|
|
804
1077
|
state.sessionToken = null;
|
|
805
1078
|
state.accessToken = null;
|
|
806
1079
|
state.moonpayCustomerId = null;
|
|
1080
|
+
state.activeVendor = 'moonpay';
|
|
807
1081
|
state.activeProduct = null;
|
|
808
1082
|
state.sumsub = {
|
|
809
1083
|
status: 'idle',
|
|
@@ -816,11 +1090,91 @@ class KycController extends base_controller_1.BaseController {
|
|
|
816
1090
|
}
|
|
817
1091
|
}
|
|
818
1092
|
exports.KycController = KycController;
|
|
819
|
-
_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_instances = new WeakSet(), _KycController_localUserSecretStore = function _KycController_localUserSecretStore() {
|
|
1093
|
+
_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() {
|
|
820
1094
|
return {
|
|
821
1095
|
get: async (path, entropySourceId) => this.messenger.call('UserStorageController:performGetStorage', path, entropySourceId),
|
|
822
1096
|
set: async (path, value, entropySourceId) => this.messenger.call('UserStorageController:performSetStorage', path, value, entropySourceId),
|
|
823
1097
|
};
|
|
1098
|
+
}, _KycController_startConsentsSession =
|
|
1099
|
+
/**
|
|
1100
|
+
* Consents-path vendors: post vendor signings + Sumsub/idOS ack, then
|
|
1101
|
+
* launch SumSub — skipping MoonPay Check/Auth frames.
|
|
1102
|
+
*
|
|
1103
|
+
* @param consents - T&C2 boolean flags.
|
|
1104
|
+
* @param consents.sumsubTncSigned - Whether Sumsub T&C were accepted.
|
|
1105
|
+
* @param consents.idosTncSigned - Whether idOS T&C were accepted.
|
|
1106
|
+
*/
|
|
1107
|
+
async function _KycController_startConsentsSession(consents) {
|
|
1108
|
+
const { email, acceptedDisclaimerIds } = this.state;
|
|
1109
|
+
if (!email) {
|
|
1110
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_fail).call(this, 'Missing email for consents session.');
|
|
1111
|
+
return;
|
|
1112
|
+
}
|
|
1113
|
+
if (acceptedDisclaimerIds.length === 0) {
|
|
1114
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_fail).call(this, 'Missing disclaimer acceptance.');
|
|
1115
|
+
return;
|
|
1116
|
+
}
|
|
1117
|
+
const generation = __classPrivateFieldGet(this, _KycController_generation, "f");
|
|
1118
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_applyUpdate).call(this, (state) => {
|
|
1119
|
+
state.error = null;
|
|
1120
|
+
state.phase = 'session';
|
|
1121
|
+
state.statusMessage = 'Submitting consents...';
|
|
1122
|
+
// Consents-path vendors have no MoonPay session/access tokens.
|
|
1123
|
+
state.sessionToken = null;
|
|
1124
|
+
state.accessToken = null;
|
|
1125
|
+
});
|
|
1126
|
+
try {
|
|
1127
|
+
await this.messenger.call('KycService:submitConsents', {
|
|
1128
|
+
disclaimerIds: acceptedDisclaimerIds,
|
|
1129
|
+
sumsubTncSigned: consents.sumsubTncSigned,
|
|
1130
|
+
idosTncSigned: consents.idosTncSigned,
|
|
1131
|
+
});
|
|
1132
|
+
if (__classPrivateFieldGet(this, _KycController_generation, "f") !== generation) {
|
|
1133
|
+
return;
|
|
1134
|
+
}
|
|
1135
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_applyUpdate).call(this, (state) => {
|
|
1136
|
+
state.phase = 'submit';
|
|
1137
|
+
state.statusMessage = 'Starting document verification...';
|
|
1138
|
+
});
|
|
1139
|
+
const sumsubResult = await this.startSumSub();
|
|
1140
|
+
if (__classPrivateFieldGet(this, _KycController_generation, "f") !== generation) {
|
|
1141
|
+
return;
|
|
1142
|
+
}
|
|
1143
|
+
const sumsubError = sumsubResult?.error;
|
|
1144
|
+
if (typeof sumsubError === 'string') {
|
|
1145
|
+
throw new Error(sumsubError);
|
|
1146
|
+
}
|
|
1147
|
+
// After SumSub, refresh user-keyed status for the Money toast and start
|
|
1148
|
+
// polling while still pending. Soft-fail: toast refresh must not rewind
|
|
1149
|
+
// the consent / SumSub outcome.
|
|
1150
|
+
try {
|
|
1151
|
+
await this.refreshKycStatus();
|
|
1152
|
+
}
|
|
1153
|
+
catch (statusError) {
|
|
1154
|
+
console.error('KYC status refresh failed:', statusError);
|
|
1155
|
+
}
|
|
1156
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_updateIfCurrent).call(this, generation, (state) => {
|
|
1157
|
+
if (state.phase !== 'error' && state.phase !== 'done') {
|
|
1158
|
+
state.phase = 'done';
|
|
1159
|
+
state.statusMessage = 'KYC submitted.';
|
|
1160
|
+
}
|
|
1161
|
+
});
|
|
1162
|
+
}
|
|
1163
|
+
catch (error) {
|
|
1164
|
+
console.error('Consents session failed:', error);
|
|
1165
|
+
if (__classPrivateFieldGet(this, _KycController_generation, "f") !== generation) {
|
|
1166
|
+
return;
|
|
1167
|
+
}
|
|
1168
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_applyUpdate).call(this, (state) => {
|
|
1169
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_clearAcceptedTerms).call(this, state);
|
|
1170
|
+
state.activeProduct = null;
|
|
1171
|
+
state.error = `Consents session failed: ${String(error)}`;
|
|
1172
|
+
state.statusMessage =
|
|
1173
|
+
'Consent / verification failed — accept the terms to try again.';
|
|
1174
|
+
state.phase = 'terms';
|
|
1175
|
+
});
|
|
1176
|
+
await this.loadDisclaimers();
|
|
1177
|
+
}
|
|
824
1178
|
}, _KycController_createSession =
|
|
825
1179
|
/**
|
|
826
1180
|
* Creates a vendor session from the currently stored terms + email.
|
|
@@ -889,6 +1243,14 @@ async function _KycController_createSession() {
|
|
|
889
1243
|
}, _KycController_clearAcceptedTerms = function _KycController_clearAcceptedTerms(state) {
|
|
890
1244
|
state.termsAcceptedAt = null;
|
|
891
1245
|
state.acceptedDisclaimerIds = [];
|
|
1246
|
+
state.termsAcceptedVendor = null;
|
|
1247
|
+
state.sumsubTncAccepted = null;
|
|
1248
|
+
state.idosTncAccepted = null;
|
|
1249
|
+
}, _KycController_hasTermsForVendor = function _KycController_hasTermsForVendor(vendor) {
|
|
1250
|
+
if (this.state.termsAcceptedVendor === null) {
|
|
1251
|
+
return false;
|
|
1252
|
+
}
|
|
1253
|
+
return this.state.termsAcceptedVendor === vendor;
|
|
892
1254
|
}, _KycController_handleCheckOutcome =
|
|
893
1255
|
/**
|
|
894
1256
|
* Applies a Check-frame outcome.
|
|
@@ -986,6 +1348,101 @@ async function _KycController_continueAfterAuthentication() {
|
|
|
986
1348
|
state.statusMessage =
|
|
987
1349
|
'The vendor updated its Terms of Use — please re-accept.';
|
|
988
1350
|
});
|
|
1351
|
+
}, _KycController_buildUkycSessionVendorFields = function _KycController_buildUkycSessionVendorFields() {
|
|
1352
|
+
if (this.state.activeVendor === 'moonpay') {
|
|
1353
|
+
return {
|
|
1354
|
+
vendor: 'moonpay',
|
|
1355
|
+
vendorMetadata: {
|
|
1356
|
+
moonPayAccessToken: this.state.accessToken,
|
|
1357
|
+
moonPayUserId: this.state.moonpayCustomerId,
|
|
1358
|
+
},
|
|
1359
|
+
};
|
|
1360
|
+
}
|
|
1361
|
+
return { vendor: this.state.activeVendor };
|
|
1362
|
+
}, _KycController_fetchAndApplyUserStatus =
|
|
1363
|
+
/**
|
|
1364
|
+
* Fetches `GET /kyc/status` and applies it to state without managing the
|
|
1365
|
+
* poll loop (used by both {@link refreshKycStatus} and the poll tick).
|
|
1366
|
+
*
|
|
1367
|
+
* @returns The latest status payload.
|
|
1368
|
+
*/
|
|
1369
|
+
async function _KycController_fetchAndApplyUserStatus() {
|
|
1370
|
+
const generation = __classPrivateFieldGet(this, _KycController_generation, "f");
|
|
1371
|
+
const response = await this.messenger.call('KycService:fetchKycStatus');
|
|
1372
|
+
if (__classPrivateFieldGet(this, _KycController_generation, "f") !== generation) {
|
|
1373
|
+
return {
|
|
1374
|
+
status: this.state.userStatus ?? 'not-started',
|
|
1375
|
+
sumsubSessionId: this.state.userStatusSumsubSessionId,
|
|
1376
|
+
errorCode: this.state.userStatusErrorCode,
|
|
1377
|
+
};
|
|
1378
|
+
}
|
|
1379
|
+
const payload = {
|
|
1380
|
+
status: response.status,
|
|
1381
|
+
sumsubSessionId: response.sumsubSessionId ?? null,
|
|
1382
|
+
errorCode: response.errorCode ?? null,
|
|
1383
|
+
};
|
|
1384
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_applyUserStatus).call(this, payload);
|
|
1385
|
+
return payload;
|
|
1386
|
+
}, _KycController_applyUserStatus = function _KycController_applyUserStatus(payload) {
|
|
1387
|
+
const previous = this.state.userStatus;
|
|
1388
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_applyUpdate).call(this, (state) => {
|
|
1389
|
+
state.userStatus = payload.status;
|
|
1390
|
+
state.userStatusSumsubSessionId = payload.sumsubSessionId;
|
|
1391
|
+
state.userStatusErrorCode = payload.errorCode;
|
|
1392
|
+
});
|
|
1393
|
+
if (previous !== payload.status) {
|
|
1394
|
+
this.messenger.publish(`${exports.controllerName}:statusChanged`, payload);
|
|
1395
|
+
}
|
|
1396
|
+
}, _KycController_ensureUserStatusPolling = function _KycController_ensureUserStatusPolling() {
|
|
1397
|
+
if (__classPrivateFieldGet(this, _KycController_userStatusPolling, "f")) {
|
|
1398
|
+
return;
|
|
1399
|
+
}
|
|
1400
|
+
__classPrivateFieldSet(this, _KycController_userStatusPolling, true, "f");
|
|
1401
|
+
const token = __classPrivateFieldGet(this, _KycController_userStatusPollToken, "f");
|
|
1402
|
+
const tick = async () => {
|
|
1403
|
+
try {
|
|
1404
|
+
const payload = await __classPrivateFieldGet(this, _KycController_instances, "m", _KycController_fetchAndApplyUserStatus).call(this);
|
|
1405
|
+
// Race with `reset()` / `#stopUserStatusPolling` while the request was
|
|
1406
|
+
// in flight — do not reschedule onto an idle controller.
|
|
1407
|
+
/* istanbul ignore next */
|
|
1408
|
+
if (__classPrivateFieldGet(this, _KycController_userStatusPollToken, "f") !== token) {
|
|
1409
|
+
return;
|
|
1410
|
+
}
|
|
1411
|
+
if (payload.status !== 'pending') {
|
|
1412
|
+
__classPrivateFieldGet(this, _KycController_instances, "m", _KycController_stopUserStatusPolling).call(this);
|
|
1413
|
+
return;
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
catch {
|
|
1417
|
+
// Keep polling on transient errors, unless the loop was superseded.
|
|
1418
|
+
/* istanbul ignore next */
|
|
1419
|
+
if (__classPrivateFieldGet(this, _KycController_userStatusPollToken, "f") !== token) {
|
|
1420
|
+
return;
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
__classPrivateFieldSet(this, _KycController_userStatusPollTimer, setTimeout(() => {
|
|
1424
|
+
__classPrivateFieldSet(this, _KycController_userStatusPollTimer, null, "f");
|
|
1425
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
1426
|
+
tick();
|
|
1427
|
+
}, __classPrivateFieldGet(this, _KycController_userStatusPollIntervalMs, "f")), "f");
|
|
1428
|
+
// Allow the process to exit while a pending-status poll is scheduled.
|
|
1429
|
+
// React Native / browser timers are numbers with no `unref`, hence the
|
|
1430
|
+
// optional call.
|
|
1431
|
+
__classPrivateFieldGet(this, _KycController_userStatusPollTimer, "f").unref?.();
|
|
1432
|
+
};
|
|
1433
|
+
__classPrivateFieldSet(this, _KycController_userStatusPollTimer, setTimeout(() => {
|
|
1434
|
+
__classPrivateFieldSet(this, _KycController_userStatusPollTimer, null, "f");
|
|
1435
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
1436
|
+
tick();
|
|
1437
|
+
}, __classPrivateFieldGet(this, _KycController_userStatusPollIntervalMs, "f")), "f");
|
|
1438
|
+
__classPrivateFieldGet(this, _KycController_userStatusPollTimer, "f").unref?.();
|
|
1439
|
+
}, _KycController_stopUserStatusPolling = function _KycController_stopUserStatusPolling() {
|
|
1440
|
+
__classPrivateFieldSet(this, _KycController_userStatusPollToken, __classPrivateFieldGet(this, _KycController_userStatusPollToken, "f") + 1, "f");
|
|
1441
|
+
__classPrivateFieldSet(this, _KycController_userStatusPolling, false, "f");
|
|
1442
|
+
if (__classPrivateFieldGet(this, _KycController_userStatusPollTimer, "f") !== null) {
|
|
1443
|
+
clearTimeout(__classPrivateFieldGet(this, _KycController_userStatusPollTimer, "f"));
|
|
1444
|
+
__classPrivateFieldSet(this, _KycController_userStatusPollTimer, null, "f");
|
|
1445
|
+
}
|
|
989
1446
|
}, _KycController_startSessionStatusPolling =
|
|
990
1447
|
/**
|
|
991
1448
|
* Begins polling the UKYC session status until a terminal decision is
|