@metamask-previews/kyc-controller 0.0.0-preview-6b4bcdab3 → 0.0.0-preview-0b5bfc2
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 +3 -42
- package/dist/KycController-method-action-types.cjs.map +1 -1
- package/dist/KycController-method-action-types.d.cts +2 -48
- package/dist/KycController-method-action-types.d.cts.map +1 -1
- package/dist/KycController-method-action-types.d.mts +2 -48
- 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 +13 -472
- package/dist/KycController.cjs.map +1 -1
- package/dist/KycController.d.cts +5 -109
- package/dist/KycController.d.cts.map +1 -1
- package/dist/KycController.d.mts +5 -109
- package/dist/KycController.d.mts.map +1 -1
- package/dist/KycController.mjs +13 -472
- 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 +2 -38
- package/dist/KycService-method-action-types.d.cts.map +1 -1
- package/dist/KycService-method-action-types.d.mts +2 -38
- 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 +29 -184
- package/dist/KycService.cjs.map +1 -1
- package/dist/KycService.d.cts +14 -99
- package/dist/KycService.d.cts.map +1 -1
- package/dist/KycService.d.mts +14 -99
- package/dist/KycService.d.mts.map +1 -1
- package/dist/KycService.mjs +30 -185
- 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 +10 -49
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +10 -49
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +2 -2
package/dist/KycController.d.cts
CHANGED
|
@@ -5,7 +5,7 @@ import type { UserStorageControllerPerformGetStorageAction, UserStorageControlle
|
|
|
5
5
|
import type { Json } from "@metamask/utils";
|
|
6
6
|
import type { KycControllerMethodActions } from "./KycController-method-action-types.cjs";
|
|
7
7
|
import type { KycServiceMethodActions } from "./KycService-method-action-types.cjs";
|
|
8
|
-
import type {
|
|
8
|
+
import type { KycDisclaimer, KycPhase, KycProduct, KycSessionStatus, KycSumSubLauncher, KycSumSubStatus } from "./types.cjs";
|
|
9
9
|
export declare const controllerName = "KycController";
|
|
10
10
|
/**
|
|
11
11
|
* Describes the shape of the state object for {@link KycController}.
|
|
@@ -23,26 +23,6 @@ export type KycControllerState = {
|
|
|
23
23
|
termsAcceptedAt: string | null;
|
|
24
24
|
/** IDs of the disclaimers the customer accepted (persisted). */
|
|
25
25
|
acceptedDisclaimerIds: string[];
|
|
26
|
-
/**
|
|
27
|
-
* The vendor whose disclaimers `acceptedDisclaimerIds` belong to (persisted).
|
|
28
|
-
* Each vendor serves its own disclaimer set, so acceptance recorded for one
|
|
29
|
-
* vendor must not be reused for another. `null` when nothing is accepted.
|
|
30
|
-
*/
|
|
31
|
-
termsAcceptedVendor: KycVendor | null;
|
|
32
|
-
/**
|
|
33
|
-
* Whether the customer accepted the SumSub T&C (T&C2) during the last
|
|
34
|
-
* terms acceptance (persisted). Consents-path vendors require this flag
|
|
35
|
-
* when resuming a session. `null` for acceptance recorded before this
|
|
36
|
-
* field existed (treated as requiring reacceptance).
|
|
37
|
-
*/
|
|
38
|
-
sumsubTncAccepted: boolean | null;
|
|
39
|
-
/**
|
|
40
|
-
* Whether the customer accepted the idOS T&C (T&C2) during the last
|
|
41
|
-
* terms acceptance (persisted). Consents-path vendors require this flag
|
|
42
|
-
* when resuming a session. `null` for acceptance recorded before this
|
|
43
|
-
* field existed (treated as requiring reacceptance).
|
|
44
|
-
*/
|
|
45
|
-
idosTncAccepted: boolean | null;
|
|
46
26
|
/** Disclaimers fetched for the current country. */
|
|
47
27
|
disclaimers: KycDisclaimer[];
|
|
48
28
|
/** Error encountered while loading disclaimers, or `null`. */
|
|
@@ -55,12 +35,6 @@ export type KycControllerState = {
|
|
|
55
35
|
accessToken: string | null;
|
|
56
36
|
/** Vendor customer id, used for the SumSub hand-off. */
|
|
57
37
|
moonpayCustomerId: string | null;
|
|
58
|
-
/**
|
|
59
|
-
* The identity vendor driving the current flow. Captured at `initialize`.
|
|
60
|
-
* Defaults to `moonpay` when omitted so existing ramps/card callers keep
|
|
61
|
-
* the Check/Auth frame path. Non-MoonPay vendors skip those frames.
|
|
62
|
-
*/
|
|
63
|
-
activeVendor: KycVendor;
|
|
64
38
|
/**
|
|
65
39
|
* The product the current flow is running for. Captured at `initialize`
|
|
66
40
|
* (or `acceptTermsAndStartSession`) and used to automatically run the
|
|
@@ -73,16 +47,6 @@ export type KycControllerState = {
|
|
|
73
47
|
kycRequiredByProduct: Partial<Record<KycProduct, boolean>>;
|
|
74
48
|
/** ISO-8601 timestamp of the last KYC-required check (persisted). */
|
|
75
49
|
lastCheckedAt: string | null;
|
|
76
|
-
/**
|
|
77
|
-
* User-keyed simplified KYC status from `GET /kyc/status` (persisted so the
|
|
78
|
-
* Money toast can render across cold starts). `null` until the first
|
|
79
|
-
* successful `refreshKycStatus`.
|
|
80
|
-
*/
|
|
81
|
-
userStatus: KycUserStatus | null;
|
|
82
|
-
/** Optional SumSub session id for the retryable error path. */
|
|
83
|
-
userStatusSumsubSessionId: string | null;
|
|
84
|
-
/** Optional machine-readable error code for terminal / EDD UX. */
|
|
85
|
-
userStatusErrorCode: string | null;
|
|
86
50
|
/** SumSub document-verification sub-flow state. */
|
|
87
51
|
sumsub: {
|
|
88
52
|
status: KycSumSubStatus;
|
|
@@ -106,20 +70,7 @@ export type KycControllerGetStateAction = ControllerGetStateAction<typeof contro
|
|
|
106
70
|
export type KycControllerActions = KycControllerGetStateAction | KycControllerMethodActions;
|
|
107
71
|
type AllowedActions = KycServiceMethodActions | UserStorageControllerPerformGetStorageAction | UserStorageControllerPerformSetStorageAction;
|
|
108
72
|
export type KycControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, KycControllerState>;
|
|
109
|
-
|
|
110
|
-
* Published when the user-keyed simplified KYC status changes (Money toast).
|
|
111
|
-
*/
|
|
112
|
-
export type KycControllerStatusChangedEvent = {
|
|
113
|
-
type: `${typeof controllerName}:statusChanged`;
|
|
114
|
-
payload: [
|
|
115
|
-
{
|
|
116
|
-
status: KycUserStatus;
|
|
117
|
-
sumsubSessionId: string | null;
|
|
118
|
-
errorCode: string | null;
|
|
119
|
-
}
|
|
120
|
-
];
|
|
121
|
-
};
|
|
122
|
-
export type KycControllerEvents = KycControllerStateChangeEvent | KycControllerStatusChangedEvent;
|
|
73
|
+
export type KycControllerEvents = KycControllerStateChangeEvent;
|
|
123
74
|
type AllowedEvents = never;
|
|
124
75
|
export type KycControllerMessenger = Messenger<typeof controllerName, KycControllerActions | AllowedActions, KycControllerEvents | AllowedEvents>;
|
|
125
76
|
/**
|
|
@@ -139,12 +90,6 @@ export type KycControllerOptions = {
|
|
|
139
90
|
* {@link DEFAULT_SESSION_STATUS_POLL_INTERVAL_MS}.
|
|
140
91
|
*/
|
|
141
92
|
sessionStatusPollIntervalMs?: number;
|
|
142
|
-
/**
|
|
143
|
-
* How often, in milliseconds, to refresh `GET /kyc/status` while the
|
|
144
|
-
* simplified user status is `pending`. Defaults to
|
|
145
|
-
* {@link DEFAULT_USER_STATUS_POLL_INTERVAL_MS}.
|
|
146
|
-
*/
|
|
147
|
-
userStatusPollIntervalMs?: number;
|
|
148
93
|
};
|
|
149
94
|
/**
|
|
150
95
|
* `KycController` orchestrates the vendor-backed KYC / identity-verification
|
|
@@ -164,10 +109,8 @@ export declare class KycController extends BaseController<typeof controllerName,
|
|
|
164
109
|
* @param options.sumsubLauncher - The platform SumSub launcher adapter.
|
|
165
110
|
* @param options.sessionStatusPollIntervalMs - How often to poll the UKYC
|
|
166
111
|
* session status after the SumSub SDK completes.
|
|
167
|
-
* @param options.userStatusPollIntervalMs - How often to refresh the
|
|
168
|
-
* user-keyed KYC status while it is still `pending`.
|
|
169
112
|
*/
|
|
170
|
-
constructor({ messenger, state, sumsubLauncher, sessionStatusPollIntervalMs,
|
|
113
|
+
constructor({ messenger, state, sumsubLauncher, sessionStatusPollIntervalMs, }: KycControllerOptions);
|
|
171
114
|
/**
|
|
172
115
|
* Resolves persisted terms + geolocation, and auto-creates a session when
|
|
173
116
|
* terms are already accepted and an email is available.
|
|
@@ -179,26 +122,10 @@ export declare class KycController extends BaseController<typeof controllerName,
|
|
|
179
122
|
* authentication completes (and chains into document verification when KYC
|
|
180
123
|
* is required). When omitted, the flow stops at `form` and the consumer must
|
|
181
124
|
* call `checkKycRequired` manually.
|
|
182
|
-
* @param params.vendor - Identity vendor for this flow. Non-MoonPay vendors
|
|
183
|
-
* skip Check/Auth frames and use the consents path. Defaults to `moonpay`.
|
|
184
125
|
*/
|
|
185
126
|
initialize(params?: {
|
|
186
127
|
email?: string;
|
|
187
128
|
product?: KycProduct;
|
|
188
|
-
vendor?: KycVendor;
|
|
189
|
-
}): Promise<void>;
|
|
190
|
-
/**
|
|
191
|
-
* Creates (or resumes) an empty-shell customer for the given identity
|
|
192
|
-
* vendor. Exposed so a consumer can ensure the customer exists before
|
|
193
|
-
* showing T&C screens independently of {@link initialize}.
|
|
194
|
-
*
|
|
195
|
-
* @param params - The parameters.
|
|
196
|
-
* @param params.vendor - Identity vendor for the customer.
|
|
197
|
-
* @param params.email - Email for the vendor customer.
|
|
198
|
-
*/
|
|
199
|
-
createVendorCustomer(params: {
|
|
200
|
-
vendor: KycVendor;
|
|
201
|
-
email: string;
|
|
202
129
|
}): Promise<void>;
|
|
203
130
|
/**
|
|
204
131
|
* Loads the disclaimers for the resolved (or provided) country.
|
|
@@ -213,21 +140,15 @@ export declare class KycController extends BaseController<typeof controllerName,
|
|
|
213
140
|
* Captures terms acceptance for the currently loaded disclaimers and creates
|
|
214
141
|
* a session.
|
|
215
142
|
*
|
|
216
|
-
* @param params -
|
|
143
|
+
* @param params - Optional parameters.
|
|
217
144
|
* @param params.email - The account email to associate with the session.
|
|
218
145
|
* @param params.product - The consuming feature the flow runs for. See
|
|
219
146
|
* {@link initialize} for how the product drives the automatic post
|
|
220
147
|
* authentication continuation.
|
|
221
|
-
* @param params.sumsubTncSigned - Whether Sumsub T&C were accepted (T&C2).
|
|
222
|
-
* Required for every vendor so callers explicitly declare acceptance.
|
|
223
|
-
* @param params.idosTncSigned - Whether idOS T&C were accepted (T&C2).
|
|
224
|
-
* Required for every vendor so callers explicitly declare acceptance.
|
|
225
148
|
*/
|
|
226
|
-
acceptTermsAndStartSession(params
|
|
149
|
+
acceptTermsAndStartSession(params?: {
|
|
227
150
|
email?: string;
|
|
228
151
|
product?: KycProduct;
|
|
229
|
-
sumsubTncSigned: boolean;
|
|
230
|
-
idosTncSigned: boolean;
|
|
231
152
|
}): Promise<void>;
|
|
232
153
|
/**
|
|
233
154
|
* Clears the persisted terms acceptance.
|
|
@@ -288,19 +209,6 @@ export declare class KycController extends BaseController<typeof controllerName,
|
|
|
288
209
|
getKycStatus(params: {
|
|
289
210
|
product: KycProduct;
|
|
290
211
|
}): boolean | undefined;
|
|
291
|
-
/**
|
|
292
|
-
* Returns the vendor-scoped identity for the currently authenticated
|
|
293
|
-
* customer, or `null` when the flow has not yet captured a vendor customer
|
|
294
|
-
* id (before authentication or after {@link reset}).
|
|
295
|
-
*
|
|
296
|
-
* Exposed so consumers (e.g. ramps autoramp creation) can attach the vendor
|
|
297
|
-
* customer id to downstream calls without reading the full KYC state, which
|
|
298
|
-
* also holds session/access tokens. The id is session-scoped and never
|
|
299
|
-
* persisted.
|
|
300
|
-
*
|
|
301
|
-
* @returns The current {@link KycCustomerIdentity}, or `null`.
|
|
302
|
-
*/
|
|
303
|
-
getCustomerIdentity(): KycCustomerIdentity | null;
|
|
304
212
|
/**
|
|
305
213
|
* Runs the SumSub document-verification sub-flow end to end:
|
|
306
214
|
*
|
|
@@ -328,18 +236,6 @@ export declare class KycController extends BaseController<typeof controllerName,
|
|
|
328
236
|
locale?: string;
|
|
329
237
|
debug?: boolean;
|
|
330
238
|
}): Promise<Record<string, unknown>>;
|
|
331
|
-
/**
|
|
332
|
-
* Refreshes the user-keyed simplified KYC status from `GET /kyc/status`,
|
|
333
|
-
* stores it on state, publishes {@link KycControllerStatusChangedEvent}, and
|
|
334
|
-
* schedules short-interval polling while the status is `pending`.
|
|
335
|
-
*
|
|
336
|
-
* @returns The latest status payload.
|
|
337
|
-
*/
|
|
338
|
-
refreshKycStatus(): Promise<{
|
|
339
|
-
status: KycUserStatus;
|
|
340
|
-
sumsubSessionId: string | null;
|
|
341
|
-
errorCode: string | null;
|
|
342
|
-
}>;
|
|
343
239
|
/**
|
|
344
240
|
* Fetches the current UKYC session status for the active sub-flow and records
|
|
345
241
|
* it on state. Useful for a one-off refresh outside the automatic polling
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KycController.d.cts","sourceRoot":"","sources":["../src/KycController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EACV,4CAA4C,EAC5C,4CAA4C,EAC7C,uDAAuD;AACxD,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAM5C,OAAO,KAAK,EAAE,0BAA0B,EAAE,gDAA+C;AACzF,OAAO,KAAK,EAAE,uBAAuB,EAAE,6CAA4C;
|
|
1
|
+
{"version":3,"file":"KycController.d.cts","sourceRoot":"","sources":["../src/KycController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EA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;OAsBG;IACG,WAAW,CAAC,MAAM,CAAC,EAAE;QACzB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IA0MpC;;;;;;;OAOG;IACG,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAmHnD;;;OAGG;IACH,KAAK,IAAI,IAAI;CAkFd"}
|
package/dist/KycController.d.mts
CHANGED
|
@@ -5,7 +5,7 @@ import type { UserStorageControllerPerformGetStorageAction, UserStorageControlle
|
|
|
5
5
|
import type { Json } from "@metamask/utils";
|
|
6
6
|
import type { KycControllerMethodActions } from "./KycController-method-action-types.mjs";
|
|
7
7
|
import type { KycServiceMethodActions } from "./KycService-method-action-types.mjs";
|
|
8
|
-
import type {
|
|
8
|
+
import type { KycDisclaimer, KycPhase, KycProduct, KycSessionStatus, KycSumSubLauncher, KycSumSubStatus } from "./types.mjs";
|
|
9
9
|
export declare const controllerName = "KycController";
|
|
10
10
|
/**
|
|
11
11
|
* Describes the shape of the state object for {@link KycController}.
|
|
@@ -23,26 +23,6 @@ export type KycControllerState = {
|
|
|
23
23
|
termsAcceptedAt: string | null;
|
|
24
24
|
/** IDs of the disclaimers the customer accepted (persisted). */
|
|
25
25
|
acceptedDisclaimerIds: string[];
|
|
26
|
-
/**
|
|
27
|
-
* The vendor whose disclaimers `acceptedDisclaimerIds` belong to (persisted).
|
|
28
|
-
* Each vendor serves its own disclaimer set, so acceptance recorded for one
|
|
29
|
-
* vendor must not be reused for another. `null` when nothing is accepted.
|
|
30
|
-
*/
|
|
31
|
-
termsAcceptedVendor: KycVendor | null;
|
|
32
|
-
/**
|
|
33
|
-
* Whether the customer accepted the SumSub T&C (T&C2) during the last
|
|
34
|
-
* terms acceptance (persisted). Consents-path vendors require this flag
|
|
35
|
-
* when resuming a session. `null` for acceptance recorded before this
|
|
36
|
-
* field existed (treated as requiring reacceptance).
|
|
37
|
-
*/
|
|
38
|
-
sumsubTncAccepted: boolean | null;
|
|
39
|
-
/**
|
|
40
|
-
* Whether the customer accepted the idOS T&C (T&C2) during the last
|
|
41
|
-
* terms acceptance (persisted). Consents-path vendors require this flag
|
|
42
|
-
* when resuming a session. `null` for acceptance recorded before this
|
|
43
|
-
* field existed (treated as requiring reacceptance).
|
|
44
|
-
*/
|
|
45
|
-
idosTncAccepted: boolean | null;
|
|
46
26
|
/** Disclaimers fetched for the current country. */
|
|
47
27
|
disclaimers: KycDisclaimer[];
|
|
48
28
|
/** Error encountered while loading disclaimers, or `null`. */
|
|
@@ -55,12 +35,6 @@ export type KycControllerState = {
|
|
|
55
35
|
accessToken: string | null;
|
|
56
36
|
/** Vendor customer id, used for the SumSub hand-off. */
|
|
57
37
|
moonpayCustomerId: string | null;
|
|
58
|
-
/**
|
|
59
|
-
* The identity vendor driving the current flow. Captured at `initialize`.
|
|
60
|
-
* Defaults to `moonpay` when omitted so existing ramps/card callers keep
|
|
61
|
-
* the Check/Auth frame path. Non-MoonPay vendors skip those frames.
|
|
62
|
-
*/
|
|
63
|
-
activeVendor: KycVendor;
|
|
64
38
|
/**
|
|
65
39
|
* The product the current flow is running for. Captured at `initialize`
|
|
66
40
|
* (or `acceptTermsAndStartSession`) and used to automatically run the
|
|
@@ -73,16 +47,6 @@ export type KycControllerState = {
|
|
|
73
47
|
kycRequiredByProduct: Partial<Record<KycProduct, boolean>>;
|
|
74
48
|
/** ISO-8601 timestamp of the last KYC-required check (persisted). */
|
|
75
49
|
lastCheckedAt: string | null;
|
|
76
|
-
/**
|
|
77
|
-
* User-keyed simplified KYC status from `GET /kyc/status` (persisted so the
|
|
78
|
-
* Money toast can render across cold starts). `null` until the first
|
|
79
|
-
* successful `refreshKycStatus`.
|
|
80
|
-
*/
|
|
81
|
-
userStatus: KycUserStatus | null;
|
|
82
|
-
/** Optional SumSub session id for the retryable error path. */
|
|
83
|
-
userStatusSumsubSessionId: string | null;
|
|
84
|
-
/** Optional machine-readable error code for terminal / EDD UX. */
|
|
85
|
-
userStatusErrorCode: string | null;
|
|
86
50
|
/** SumSub document-verification sub-flow state. */
|
|
87
51
|
sumsub: {
|
|
88
52
|
status: KycSumSubStatus;
|
|
@@ -106,20 +70,7 @@ export type KycControllerGetStateAction = ControllerGetStateAction<typeof contro
|
|
|
106
70
|
export type KycControllerActions = KycControllerGetStateAction | KycControllerMethodActions;
|
|
107
71
|
type AllowedActions = KycServiceMethodActions | UserStorageControllerPerformGetStorageAction | UserStorageControllerPerformSetStorageAction;
|
|
108
72
|
export type KycControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, KycControllerState>;
|
|
109
|
-
|
|
110
|
-
* Published when the user-keyed simplified KYC status changes (Money toast).
|
|
111
|
-
*/
|
|
112
|
-
export type KycControllerStatusChangedEvent = {
|
|
113
|
-
type: `${typeof controllerName}:statusChanged`;
|
|
114
|
-
payload: [
|
|
115
|
-
{
|
|
116
|
-
status: KycUserStatus;
|
|
117
|
-
sumsubSessionId: string | null;
|
|
118
|
-
errorCode: string | null;
|
|
119
|
-
}
|
|
120
|
-
];
|
|
121
|
-
};
|
|
122
|
-
export type KycControllerEvents = KycControllerStateChangeEvent | KycControllerStatusChangedEvent;
|
|
73
|
+
export type KycControllerEvents = KycControllerStateChangeEvent;
|
|
123
74
|
type AllowedEvents = never;
|
|
124
75
|
export type KycControllerMessenger = Messenger<typeof controllerName, KycControllerActions | AllowedActions, KycControllerEvents | AllowedEvents>;
|
|
125
76
|
/**
|
|
@@ -139,12 +90,6 @@ export type KycControllerOptions = {
|
|
|
139
90
|
* {@link DEFAULT_SESSION_STATUS_POLL_INTERVAL_MS}.
|
|
140
91
|
*/
|
|
141
92
|
sessionStatusPollIntervalMs?: number;
|
|
142
|
-
/**
|
|
143
|
-
* How often, in milliseconds, to refresh `GET /kyc/status` while the
|
|
144
|
-
* simplified user status is `pending`. Defaults to
|
|
145
|
-
* {@link DEFAULT_USER_STATUS_POLL_INTERVAL_MS}.
|
|
146
|
-
*/
|
|
147
|
-
userStatusPollIntervalMs?: number;
|
|
148
93
|
};
|
|
149
94
|
/**
|
|
150
95
|
* `KycController` orchestrates the vendor-backed KYC / identity-verification
|
|
@@ -164,10 +109,8 @@ export declare class KycController extends BaseController<typeof controllerName,
|
|
|
164
109
|
* @param options.sumsubLauncher - The platform SumSub launcher adapter.
|
|
165
110
|
* @param options.sessionStatusPollIntervalMs - How often to poll the UKYC
|
|
166
111
|
* session status after the SumSub SDK completes.
|
|
167
|
-
* @param options.userStatusPollIntervalMs - How often to refresh the
|
|
168
|
-
* user-keyed KYC status while it is still `pending`.
|
|
169
112
|
*/
|
|
170
|
-
constructor({ messenger, state, sumsubLauncher, sessionStatusPollIntervalMs,
|
|
113
|
+
constructor({ messenger, state, sumsubLauncher, sessionStatusPollIntervalMs, }: KycControllerOptions);
|
|
171
114
|
/**
|
|
172
115
|
* Resolves persisted terms + geolocation, and auto-creates a session when
|
|
173
116
|
* terms are already accepted and an email is available.
|
|
@@ -179,26 +122,10 @@ export declare class KycController extends BaseController<typeof controllerName,
|
|
|
179
122
|
* authentication completes (and chains into document verification when KYC
|
|
180
123
|
* is required). When omitted, the flow stops at `form` and the consumer must
|
|
181
124
|
* call `checkKycRequired` manually.
|
|
182
|
-
* @param params.vendor - Identity vendor for this flow. Non-MoonPay vendors
|
|
183
|
-
* skip Check/Auth frames and use the consents path. Defaults to `moonpay`.
|
|
184
125
|
*/
|
|
185
126
|
initialize(params?: {
|
|
186
127
|
email?: string;
|
|
187
128
|
product?: KycProduct;
|
|
188
|
-
vendor?: KycVendor;
|
|
189
|
-
}): Promise<void>;
|
|
190
|
-
/**
|
|
191
|
-
* Creates (or resumes) an empty-shell customer for the given identity
|
|
192
|
-
* vendor. Exposed so a consumer can ensure the customer exists before
|
|
193
|
-
* showing T&C screens independently of {@link initialize}.
|
|
194
|
-
*
|
|
195
|
-
* @param params - The parameters.
|
|
196
|
-
* @param params.vendor - Identity vendor for the customer.
|
|
197
|
-
* @param params.email - Email for the vendor customer.
|
|
198
|
-
*/
|
|
199
|
-
createVendorCustomer(params: {
|
|
200
|
-
vendor: KycVendor;
|
|
201
|
-
email: string;
|
|
202
129
|
}): Promise<void>;
|
|
203
130
|
/**
|
|
204
131
|
* Loads the disclaimers for the resolved (or provided) country.
|
|
@@ -213,21 +140,15 @@ export declare class KycController extends BaseController<typeof controllerName,
|
|
|
213
140
|
* Captures terms acceptance for the currently loaded disclaimers and creates
|
|
214
141
|
* a session.
|
|
215
142
|
*
|
|
216
|
-
* @param params -
|
|
143
|
+
* @param params - Optional parameters.
|
|
217
144
|
* @param params.email - The account email to associate with the session.
|
|
218
145
|
* @param params.product - The consuming feature the flow runs for. See
|
|
219
146
|
* {@link initialize} for how the product drives the automatic post
|
|
220
147
|
* authentication continuation.
|
|
221
|
-
* @param params.sumsubTncSigned - Whether Sumsub T&C were accepted (T&C2).
|
|
222
|
-
* Required for every vendor so callers explicitly declare acceptance.
|
|
223
|
-
* @param params.idosTncSigned - Whether idOS T&C were accepted (T&C2).
|
|
224
|
-
* Required for every vendor so callers explicitly declare acceptance.
|
|
225
148
|
*/
|
|
226
|
-
acceptTermsAndStartSession(params
|
|
149
|
+
acceptTermsAndStartSession(params?: {
|
|
227
150
|
email?: string;
|
|
228
151
|
product?: KycProduct;
|
|
229
|
-
sumsubTncSigned: boolean;
|
|
230
|
-
idosTncSigned: boolean;
|
|
231
152
|
}): Promise<void>;
|
|
232
153
|
/**
|
|
233
154
|
* Clears the persisted terms acceptance.
|
|
@@ -288,19 +209,6 @@ export declare class KycController extends BaseController<typeof controllerName,
|
|
|
288
209
|
getKycStatus(params: {
|
|
289
210
|
product: KycProduct;
|
|
290
211
|
}): boolean | undefined;
|
|
291
|
-
/**
|
|
292
|
-
* Returns the vendor-scoped identity for the currently authenticated
|
|
293
|
-
* customer, or `null` when the flow has not yet captured a vendor customer
|
|
294
|
-
* id (before authentication or after {@link reset}).
|
|
295
|
-
*
|
|
296
|
-
* Exposed so consumers (e.g. ramps autoramp creation) can attach the vendor
|
|
297
|
-
* customer id to downstream calls without reading the full KYC state, which
|
|
298
|
-
* also holds session/access tokens. The id is session-scoped and never
|
|
299
|
-
* persisted.
|
|
300
|
-
*
|
|
301
|
-
* @returns The current {@link KycCustomerIdentity}, or `null`.
|
|
302
|
-
*/
|
|
303
|
-
getCustomerIdentity(): KycCustomerIdentity | null;
|
|
304
212
|
/**
|
|
305
213
|
* Runs the SumSub document-verification sub-flow end to end:
|
|
306
214
|
*
|
|
@@ -328,18 +236,6 @@ export declare class KycController extends BaseController<typeof controllerName,
|
|
|
328
236
|
locale?: string;
|
|
329
237
|
debug?: boolean;
|
|
330
238
|
}): Promise<Record<string, unknown>>;
|
|
331
|
-
/**
|
|
332
|
-
* Refreshes the user-keyed simplified KYC status from `GET /kyc/status`,
|
|
333
|
-
* stores it on state, publishes {@link KycControllerStatusChangedEvent}, and
|
|
334
|
-
* schedules short-interval polling while the status is `pending`.
|
|
335
|
-
*
|
|
336
|
-
* @returns The latest status payload.
|
|
337
|
-
*/
|
|
338
|
-
refreshKycStatus(): Promise<{
|
|
339
|
-
status: KycUserStatus;
|
|
340
|
-
sumsubSessionId: string | null;
|
|
341
|
-
errorCode: string | null;
|
|
342
|
-
}>;
|
|
343
239
|
/**
|
|
344
240
|
* Fetches the current UKYC session status for the active sub-flow and records
|
|
345
241
|
* it on state. Useful for a one-off refresh outside the automatic polling
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KycController.d.mts","sourceRoot":"","sources":["../src/KycController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EACV,4CAA4C,EAC5C,4CAA4C,EAC7C,uDAAuD;AACxD,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AA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