@metamask-previews/kyc-controller 0.0.0-preview-11d78534e
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 +21 -0
- package/LICENSE +6 -0
- package/LICENSE.APACHE2 +201 -0
- package/LICENSE.MIT +21 -0
- package/README.md +648 -0
- package/dist/KycController-method-action-types.cjs +7 -0
- package/dist/KycController-method-action-types.cjs.map +1 -0
- package/dist/KycController-method-action-types.d.cts +143 -0
- package/dist/KycController-method-action-types.d.cts.map +1 -0
- package/dist/KycController-method-action-types.d.mts +143 -0
- package/dist/KycController-method-action-types.d.mts.map +1 -0
- package/dist/KycController-method-action-types.mjs +6 -0
- package/dist/KycController-method-action-types.mjs.map +1 -0
- package/dist/KycController.cjs +800 -0
- package/dist/KycController.cjs.map +1 -0
- package/dist/KycController.d.cts +219 -0
- package/dist/KycController.d.cts.map +1 -0
- package/dist/KycController.d.mts +219 -0
- package/dist/KycController.d.mts.map +1 -0
- package/dist/KycController.mjs +795 -0
- package/dist/KycController.mjs.map +1 -0
- package/dist/KycService-method-action-types.cjs +7 -0
- package/dist/KycService-method-action-types.cjs.map +1 -0
- package/dist/KycService-method-action-types.d.cts +74 -0
- package/dist/KycService-method-action-types.d.cts.map +1 -0
- package/dist/KycService-method-action-types.d.mts +74 -0
- package/dist/KycService-method-action-types.d.mts.map +1 -0
- package/dist/KycService-method-action-types.mjs +6 -0
- package/dist/KycService-method-action-types.mjs.map +1 -0
- package/dist/KycService.cjs +238 -0
- package/dist/KycService.cjs.map +1 -0
- package/dist/KycService.d.cts +169 -0
- package/dist/KycService.d.cts.map +1 -0
- package/dist/KycService.d.mts +169 -0
- package/dist/KycService.d.mts.map +1 -0
- package/dist/KycService.mjs +234 -0
- package/dist/KycService.mjs.map +1 -0
- package/dist/countryCodes.cjs +274 -0
- package/dist/countryCodes.cjs.map +1 -0
- package/dist/countryCodes.d.cts +18 -0
- package/dist/countryCodes.d.cts.map +1 -0
- package/dist/countryCodes.d.mts +18 -0
- package/dist/countryCodes.d.mts.map +1 -0
- package/dist/countryCodes.mjs +270 -0
- package/dist/countryCodes.mjs.map +1 -0
- package/dist/crypto.cjs +165 -0
- package/dist/crypto.cjs.map +1 -0
- package/dist/crypto.d.cts +83 -0
- package/dist/crypto.d.cts.map +1 -0
- package/dist/crypto.d.mts +83 -0
- package/dist/crypto.d.mts.map +1 -0
- package/dist/crypto.mjs +160 -0
- package/dist/crypto.mjs.map +1 -0
- package/dist/index.cjs +21 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +12 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +12 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +6 -0
- package/dist/index.mjs.map +1 -0
- package/dist/selectors.cjs +30 -0
- package/dist/selectors.cjs.map +1 -0
- package/dist/selectors.d.cts +24 -0
- package/dist/selectors.d.cts.map +1 -0
- package/dist/selectors.d.mts +24 -0
- package/dist/selectors.d.mts.map +1 -0
- package/dist/selectors.mjs +24 -0
- package/dist/selectors.mjs.map +1 -0
- package/dist/types.cjs +10 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +93 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +93 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +9 -0
- package/dist/types.mjs.map +1 -0
- package/package.json +89 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.selectIsKycRequiredForProduct = exports.selectKycSumSub = exports.selectKycPhase = void 0;
|
|
4
|
+
const reselect_1 = require("reselect");
|
|
5
|
+
const selectKycRequiredByProduct = (state) => state.kycRequiredByProduct;
|
|
6
|
+
/**
|
|
7
|
+
* Selects the current flow phase.
|
|
8
|
+
*
|
|
9
|
+
* @param state - The KycController state.
|
|
10
|
+
* @returns The current phase.
|
|
11
|
+
*/
|
|
12
|
+
const selectKycPhase = (state) => state.phase;
|
|
13
|
+
exports.selectKycPhase = selectKycPhase;
|
|
14
|
+
/**
|
|
15
|
+
* Selects the SumSub sub-flow state.
|
|
16
|
+
*
|
|
17
|
+
* @param state - The KycController state.
|
|
18
|
+
* @returns The SumSub state.
|
|
19
|
+
*/
|
|
20
|
+
const selectKycSumSub = (state) => state.sumsub;
|
|
21
|
+
exports.selectKycSumSub = selectKycSumSub;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a selector that returns whether KYC is required for a product.
|
|
24
|
+
*
|
|
25
|
+
* @param product - The consuming feature.
|
|
26
|
+
* @returns A selector returning the cached requirement, or `undefined`.
|
|
27
|
+
*/
|
|
28
|
+
const selectIsKycRequiredForProduct = (product) => (0, reselect_1.createSelector)([selectKycRequiredByProduct], (map) => map[product]);
|
|
29
|
+
exports.selectIsKycRequiredForProduct = selectIsKycRequiredForProduct;
|
|
30
|
+
//# sourceMappingURL=selectors.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectors.cjs","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":";;;AAAA,uCAA0C;AAK1C,MAAM,0BAA0B,GAAG,CACjC,KAAyB,EACmB,EAAE,CAAC,KAAK,CAAC,oBAAoB,CAAC;AAE5E;;;;;GAKG;AACI,MAAM,cAAc,GAAG,CAC5B,KAAyB,EACI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC;AAFjC,QAAA,cAAc,kBAEmB;AAE9C;;;;;GAKG;AACI,MAAM,eAAe,GAAG,CAC7B,KAAyB,EACK,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC;AAFnC,QAAA,eAAe,mBAEoB;AAEhD;;;;;GAKG;AACI,MAAM,6BAA6B,GAAG,CAC3C,OAAmB,EACmC,EAAE,CACxD,IAAA,yBAAc,EACZ,CAAC,0BAA0B,CAAC,EAC5B,CAAC,GAAG,EAAuB,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAC3C,CAAC;AANS,QAAA,6BAA6B,iCAMtC","sourcesContent":["import { createSelector } from 'reselect';\n\nimport type { KycControllerState } from './KycController';\nimport type { KycProduct } from './types';\n\nconst selectKycRequiredByProduct = (\n state: KycControllerState,\n): KycControllerState['kycRequiredByProduct'] => state.kycRequiredByProduct;\n\n/**\n * Selects the current flow phase.\n *\n * @param state - The KycController state.\n * @returns The current phase.\n */\nexport const selectKycPhase = (\n state: KycControllerState,\n): KycControllerState['phase'] => state.phase;\n\n/**\n * Selects the SumSub sub-flow state.\n *\n * @param state - The KycController state.\n * @returns The SumSub state.\n */\nexport const selectKycSumSub = (\n state: KycControllerState,\n): KycControllerState['sumsub'] => state.sumsub;\n\n/**\n * Creates a selector that returns whether KYC is required for a product.\n *\n * @param product - The consuming feature.\n * @returns A selector returning the cached requirement, or `undefined`.\n */\nexport const selectIsKycRequiredForProduct = (\n product: KycProduct,\n): ((state: KycControllerState) => boolean | undefined) =>\n createSelector(\n [selectKycRequiredByProduct],\n (map): boolean | undefined => map[product],\n );\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { KycControllerState } from "./KycController.cjs";
|
|
2
|
+
import type { KycProduct } from "./types.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* Selects the current flow phase.
|
|
5
|
+
*
|
|
6
|
+
* @param state - The KycController state.
|
|
7
|
+
* @returns The current phase.
|
|
8
|
+
*/
|
|
9
|
+
export declare const selectKycPhase: (state: KycControllerState) => KycControllerState['phase'];
|
|
10
|
+
/**
|
|
11
|
+
* Selects the SumSub sub-flow state.
|
|
12
|
+
*
|
|
13
|
+
* @param state - The KycController state.
|
|
14
|
+
* @returns The SumSub state.
|
|
15
|
+
*/
|
|
16
|
+
export declare const selectKycSumSub: (state: KycControllerState) => KycControllerState['sumsub'];
|
|
17
|
+
/**
|
|
18
|
+
* Creates a selector that returns whether KYC is required for a product.
|
|
19
|
+
*
|
|
20
|
+
* @param product - The consuming feature.
|
|
21
|
+
* @returns A selector returning the cached requirement, or `undefined`.
|
|
22
|
+
*/
|
|
23
|
+
export declare const selectIsKycRequiredForProduct: (product: KycProduct) => (state: KycControllerState) => boolean | undefined;
|
|
24
|
+
//# sourceMappingURL=selectors.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectors.d.cts","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,4BAAwB;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAgB;AAM1C;;;;;GAKG;AACH,eAAO,MAAM,cAAc,UAClB,kBAAkB,KACxB,kBAAkB,CAAC,OAAO,CAAgB,CAAC;AAE9C;;;;;GAKG;AACH,eAAO,MAAM,eAAe,UACnB,kBAAkB,KACxB,kBAAkB,CAAC,QAAQ,CAAiB,CAAC;AAEhD;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,YAC/B,UAAU,aACT,kBAAkB,KAAK,OAAO,GAAG,SAI1C,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { KycControllerState } from "./KycController.mjs";
|
|
2
|
+
import type { KycProduct } from "./types.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* Selects the current flow phase.
|
|
5
|
+
*
|
|
6
|
+
* @param state - The KycController state.
|
|
7
|
+
* @returns The current phase.
|
|
8
|
+
*/
|
|
9
|
+
export declare const selectKycPhase: (state: KycControllerState) => KycControllerState['phase'];
|
|
10
|
+
/**
|
|
11
|
+
* Selects the SumSub sub-flow state.
|
|
12
|
+
*
|
|
13
|
+
* @param state - The KycController state.
|
|
14
|
+
* @returns The SumSub state.
|
|
15
|
+
*/
|
|
16
|
+
export declare const selectKycSumSub: (state: KycControllerState) => KycControllerState['sumsub'];
|
|
17
|
+
/**
|
|
18
|
+
* Creates a selector that returns whether KYC is required for a product.
|
|
19
|
+
*
|
|
20
|
+
* @param product - The consuming feature.
|
|
21
|
+
* @returns A selector returning the cached requirement, or `undefined`.
|
|
22
|
+
*/
|
|
23
|
+
export declare const selectIsKycRequiredForProduct: (product: KycProduct) => (state: KycControllerState) => boolean | undefined;
|
|
24
|
+
//# sourceMappingURL=selectors.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectors.d.mts","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,4BAAwB;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAgB;AAM1C;;;;;GAKG;AACH,eAAO,MAAM,cAAc,UAClB,kBAAkB,KACxB,kBAAkB,CAAC,OAAO,CAAgB,CAAC;AAE9C;;;;;GAKG;AACH,eAAO,MAAM,eAAe,UACnB,kBAAkB,KACxB,kBAAkB,CAAC,QAAQ,CAAiB,CAAC;AAEhD;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B,YAC/B,UAAU,aACT,kBAAkB,KAAK,OAAO,GAAG,SAI1C,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createSelector } from "reselect";
|
|
2
|
+
const selectKycRequiredByProduct = (state) => state.kycRequiredByProduct;
|
|
3
|
+
/**
|
|
4
|
+
* Selects the current flow phase.
|
|
5
|
+
*
|
|
6
|
+
* @param state - The KycController state.
|
|
7
|
+
* @returns The current phase.
|
|
8
|
+
*/
|
|
9
|
+
export const selectKycPhase = (state) => state.phase;
|
|
10
|
+
/**
|
|
11
|
+
* Selects the SumSub sub-flow state.
|
|
12
|
+
*
|
|
13
|
+
* @param state - The KycController state.
|
|
14
|
+
* @returns The SumSub state.
|
|
15
|
+
*/
|
|
16
|
+
export const selectKycSumSub = (state) => state.sumsub;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a selector that returns whether KYC is required for a product.
|
|
19
|
+
*
|
|
20
|
+
* @param product - The consuming feature.
|
|
21
|
+
* @returns A selector returning the cached requirement, or `undefined`.
|
|
22
|
+
*/
|
|
23
|
+
export const selectIsKycRequiredForProduct = (product) => createSelector([selectKycRequiredByProduct], (map) => map[product]);
|
|
24
|
+
//# sourceMappingURL=selectors.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectors.mjs","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,iBAAiB;AAK1C,MAAM,0BAA0B,GAAG,CACjC,KAAyB,EACmB,EAAE,CAAC,KAAK,CAAC,oBAAoB,CAAC;AAE5E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,KAAyB,EACI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,KAAyB,EACK,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,OAAmB,EACmC,EAAE,CACxD,cAAc,CACZ,CAAC,0BAA0B,CAAC,EAC5B,CAAC,GAAG,EAAuB,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAC3C,CAAC","sourcesContent":["import { createSelector } from 'reselect';\n\nimport type { KycControllerState } from './KycController';\nimport type { KycProduct } from './types';\n\nconst selectKycRequiredByProduct = (\n state: KycControllerState,\n): KycControllerState['kycRequiredByProduct'] => state.kycRequiredByProduct;\n\n/**\n * Selects the current flow phase.\n *\n * @param state - The KycController state.\n * @returns The current phase.\n */\nexport const selectKycPhase = (\n state: KycControllerState,\n): KycControllerState['phase'] => state.phase;\n\n/**\n * Selects the SumSub sub-flow state.\n *\n * @param state - The KycController state.\n * @returns The SumSub state.\n */\nexport const selectKycSumSub = (\n state: KycControllerState,\n): KycControllerState['sumsub'] => state.sumsub;\n\n/**\n * Creates a selector that returns whether KYC is required for a product.\n *\n * @param product - The consuming feature.\n * @returns A selector returning the cached requirement, or `undefined`.\n */\nexport const selectIsKycRequiredForProduct = (\n product: KycProduct,\n): ((state: KycControllerState) => boolean | undefined) =>\n createSelector(\n [selectKycRequiredByProduct],\n (map): boolean | undefined => map[product],\n );\n"]}
|
package/dist/types.cjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shared types for the KYC controller and service.
|
|
4
|
+
*
|
|
5
|
+
* The KYC flow is vendor-backed (currently MoonPay for identity + SumSub for
|
|
6
|
+
* document verification) but the surface exposed to consumers (ramps, card) is
|
|
7
|
+
* intentionally vendor-neutral so a future vendor swap does not ripple out.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
//# sourceMappingURL=types.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG","sourcesContent":["/**\n * Shared types for the KYC controller and service.\n *\n * The KYC flow is vendor-backed (currently MoonPay for identity + SumSub for\n * document verification) but the surface exposed to consumers (ramps, card) is\n * intentionally vendor-neutral so a future vendor swap does not ripple out.\n */\n\n/**\n * A MetaMask feature that consumes KYC. Used to key the per-product\n * \"is KYC required\" cache so ramps and card can share one controller.\n */\nexport type KycProduct = 'ramps' | 'card';\n\n/**\n * Identity vendors supported behind the KYC surface.\n */\nexport type KycVendor = 'moonpay';\n\n/**\n * Phases of the end-to-end identity flow.\n *\n * - `idle` — nothing started.\n * - `terms` — waiting for the customer to accept the vendor terms.\n * - `session` — creating the vendor session.\n * - `check` — running the invisible connection-check frame.\n * - `auth` — running the visible authentication (OTP) frame.\n * - `form` — authenticated. When the flow is scoped to a product, the\n * KYC-required check runs automatically from here; otherwise the consumer\n * drives it manually via `checkKycRequired`.\n * - `submit` — submitting the KYC-required check.\n * - `done` — flow complete; see `kycRequiredByProduct` / `sumsub`. When KYC is\n * required, the document-verification sub-flow is launched automatically.\n * - `error` — flow halted; see `error`.\n */\nexport type KycPhase =\n | 'idle'\n | 'terms'\n | 'session'\n | 'check'\n | 'auth'\n | 'form'\n | 'submit'\n | 'done'\n | 'error';\n\n/**\n * Progress of the SumSub document-verification sub-flow.\n */\nexport type KycSumSubStatus =\n | 'idle'\n | 'creatingSession'\n | 'fetchingToken'\n | 'launching'\n | 'inProgress'\n | 'complete'\n | 'failed';\n\n/**\n * A single disclaimer/term the customer must accept before a session is\n * created.\n */\nexport type KycDisclaimer = {\n id: string;\n // Mirrors the vendor API response field, which is snake_case.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n display_name: string;\n url: string;\n};\n\n/**\n * Parameters passed to a platform SumSub launcher.\n */\nexport type KycSumSubLaunchParams = {\n /**\n * The applicant access token used to initialize the SumSub SDK.\n */\n applicantAccessToken: string;\n\n /**\n * Called by the SDK when the access token expires; must resolve with a fresh\n * applicant access token.\n */\n onTokenExpiration: () => Promise<string>;\n\n /**\n * Called when the SDK reports a status transition.\n */\n onStatusChange?: (prevStatus: string, newStatus: string) => void;\n\n /**\n * BCP-47 locale for the SDK UI.\n */\n locale?: string;\n\n /**\n * Enables SDK debug logging.\n */\n debug?: boolean;\n};\n\n/**\n * Platform adapter that launches the native/web SumSub SDK.\n *\n * The KYC controller is platform-agnostic and does not import any SDK; each\n * client (mobile / extension / web) injects an implementation of this\n * interface. The controller owns all orchestration (session creation, token\n * exchange, token refresh, state) and only delegates the actual SDK\n * presentation to `launch`.\n */\nexport type KycSumSubLauncher = {\n /**\n * Whether the underlying SDK is available in the current runtime (e.g. the\n * native module is linked). When `false`, `startSumSub` fails fast.\n */\n isAvailable(): boolean;\n\n /**\n * Presents the SumSub verification flow and resolves with the SDK result.\n */\n launch(params: KycSumSubLaunchParams): Promise<Record<string, unknown>>;\n};\n"]}
|
package/dist/types.d.cts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for the KYC controller and service.
|
|
3
|
+
*
|
|
4
|
+
* The KYC flow is vendor-backed (currently MoonPay for identity + SumSub for
|
|
5
|
+
* document verification) but the surface exposed to consumers (ramps, card) is
|
|
6
|
+
* intentionally vendor-neutral so a future vendor swap does not ripple out.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* A MetaMask feature that consumes KYC. Used to key the per-product
|
|
10
|
+
* "is KYC required" cache so ramps and card can share one controller.
|
|
11
|
+
*/
|
|
12
|
+
export type KycProduct = 'ramps' | 'card';
|
|
13
|
+
/**
|
|
14
|
+
* Identity vendors supported behind the KYC surface.
|
|
15
|
+
*/
|
|
16
|
+
export type KycVendor = 'moonpay';
|
|
17
|
+
/**
|
|
18
|
+
* Phases of the end-to-end identity flow.
|
|
19
|
+
*
|
|
20
|
+
* - `idle` — nothing started.
|
|
21
|
+
* - `terms` — waiting for the customer to accept the vendor terms.
|
|
22
|
+
* - `session` — creating the vendor session.
|
|
23
|
+
* - `check` — running the invisible connection-check frame.
|
|
24
|
+
* - `auth` — running the visible authentication (OTP) frame.
|
|
25
|
+
* - `form` — authenticated. When the flow is scoped to a product, the
|
|
26
|
+
* KYC-required check runs automatically from here; otherwise the consumer
|
|
27
|
+
* drives it manually via `checkKycRequired`.
|
|
28
|
+
* - `submit` — submitting the KYC-required check.
|
|
29
|
+
* - `done` — flow complete; see `kycRequiredByProduct` / `sumsub`. When KYC is
|
|
30
|
+
* required, the document-verification sub-flow is launched automatically.
|
|
31
|
+
* - `error` — flow halted; see `error`.
|
|
32
|
+
*/
|
|
33
|
+
export type KycPhase = 'idle' | 'terms' | 'session' | 'check' | 'auth' | 'form' | 'submit' | 'done' | 'error';
|
|
34
|
+
/**
|
|
35
|
+
* Progress of the SumSub document-verification sub-flow.
|
|
36
|
+
*/
|
|
37
|
+
export type KycSumSubStatus = 'idle' | 'creatingSession' | 'fetchingToken' | 'launching' | 'inProgress' | 'complete' | 'failed';
|
|
38
|
+
/**
|
|
39
|
+
* A single disclaimer/term the customer must accept before a session is
|
|
40
|
+
* created.
|
|
41
|
+
*/
|
|
42
|
+
export type KycDisclaimer = {
|
|
43
|
+
id: string;
|
|
44
|
+
display_name: string;
|
|
45
|
+
url: string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Parameters passed to a platform SumSub launcher.
|
|
49
|
+
*/
|
|
50
|
+
export type KycSumSubLaunchParams = {
|
|
51
|
+
/**
|
|
52
|
+
* The applicant access token used to initialize the SumSub SDK.
|
|
53
|
+
*/
|
|
54
|
+
applicantAccessToken: string;
|
|
55
|
+
/**
|
|
56
|
+
* Called by the SDK when the access token expires; must resolve with a fresh
|
|
57
|
+
* applicant access token.
|
|
58
|
+
*/
|
|
59
|
+
onTokenExpiration: () => Promise<string>;
|
|
60
|
+
/**
|
|
61
|
+
* Called when the SDK reports a status transition.
|
|
62
|
+
*/
|
|
63
|
+
onStatusChange?: (prevStatus: string, newStatus: string) => void;
|
|
64
|
+
/**
|
|
65
|
+
* BCP-47 locale for the SDK UI.
|
|
66
|
+
*/
|
|
67
|
+
locale?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Enables SDK debug logging.
|
|
70
|
+
*/
|
|
71
|
+
debug?: boolean;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Platform adapter that launches the native/web SumSub SDK.
|
|
75
|
+
*
|
|
76
|
+
* The KYC controller is platform-agnostic and does not import any SDK; each
|
|
77
|
+
* client (mobile / extension / web) injects an implementation of this
|
|
78
|
+
* interface. The controller owns all orchestration (session creation, token
|
|
79
|
+
* exchange, token refresh, state) and only delegates the actual SDK
|
|
80
|
+
* presentation to `launch`.
|
|
81
|
+
*/
|
|
82
|
+
export type KycSumSubLauncher = {
|
|
83
|
+
/**
|
|
84
|
+
* Whether the underlying SDK is available in the current runtime (e.g. the
|
|
85
|
+
* native module is linked). When `false`, `startSumSub` fails fast.
|
|
86
|
+
*/
|
|
87
|
+
isAvailable(): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Presents the SumSub verification flow and resolves with the SDK result.
|
|
90
|
+
*/
|
|
91
|
+
launch(params: KycSumSubLaunchParams): Promise<Record<string, unknown>>;
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,CAAC;AAE1C;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,SAAS,CAAC;AAElC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,QAAQ,GAChB,MAAM,GACN,OAAO,GACP,SAAS,GACT,OAAO,GACP,MAAM,GACN,MAAM,GACN,QAAQ,GACR,MAAM,GACN,OAAO,CAAC;AAEZ;;GAEG;AACH,MAAM,MAAM,eAAe,GACvB,MAAM,GACN,iBAAiB,GACjB,eAAe,GACf,WAAW,GACX,YAAY,GACZ,UAAU,GACV,QAAQ,CAAC;AAEb;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IAGX,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAE7B;;;OAGG;IACH,iBAAiB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAEzC;;OAEG;IACH,cAAc,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAEjE;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;OAGG;IACH,WAAW,IAAI,OAAO,CAAC;IAEvB;;OAEG;IACH,MAAM,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACzE,CAAC"}
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for the KYC controller and service.
|
|
3
|
+
*
|
|
4
|
+
* The KYC flow is vendor-backed (currently MoonPay for identity + SumSub for
|
|
5
|
+
* document verification) but the surface exposed to consumers (ramps, card) is
|
|
6
|
+
* intentionally vendor-neutral so a future vendor swap does not ripple out.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* A MetaMask feature that consumes KYC. Used to key the per-product
|
|
10
|
+
* "is KYC required" cache so ramps and card can share one controller.
|
|
11
|
+
*/
|
|
12
|
+
export type KycProduct = 'ramps' | 'card';
|
|
13
|
+
/**
|
|
14
|
+
* Identity vendors supported behind the KYC surface.
|
|
15
|
+
*/
|
|
16
|
+
export type KycVendor = 'moonpay';
|
|
17
|
+
/**
|
|
18
|
+
* Phases of the end-to-end identity flow.
|
|
19
|
+
*
|
|
20
|
+
* - `idle` — nothing started.
|
|
21
|
+
* - `terms` — waiting for the customer to accept the vendor terms.
|
|
22
|
+
* - `session` — creating the vendor session.
|
|
23
|
+
* - `check` — running the invisible connection-check frame.
|
|
24
|
+
* - `auth` — running the visible authentication (OTP) frame.
|
|
25
|
+
* - `form` — authenticated. When the flow is scoped to a product, the
|
|
26
|
+
* KYC-required check runs automatically from here; otherwise the consumer
|
|
27
|
+
* drives it manually via `checkKycRequired`.
|
|
28
|
+
* - `submit` — submitting the KYC-required check.
|
|
29
|
+
* - `done` — flow complete; see `kycRequiredByProduct` / `sumsub`. When KYC is
|
|
30
|
+
* required, the document-verification sub-flow is launched automatically.
|
|
31
|
+
* - `error` — flow halted; see `error`.
|
|
32
|
+
*/
|
|
33
|
+
export type KycPhase = 'idle' | 'terms' | 'session' | 'check' | 'auth' | 'form' | 'submit' | 'done' | 'error';
|
|
34
|
+
/**
|
|
35
|
+
* Progress of the SumSub document-verification sub-flow.
|
|
36
|
+
*/
|
|
37
|
+
export type KycSumSubStatus = 'idle' | 'creatingSession' | 'fetchingToken' | 'launching' | 'inProgress' | 'complete' | 'failed';
|
|
38
|
+
/**
|
|
39
|
+
* A single disclaimer/term the customer must accept before a session is
|
|
40
|
+
* created.
|
|
41
|
+
*/
|
|
42
|
+
export type KycDisclaimer = {
|
|
43
|
+
id: string;
|
|
44
|
+
display_name: string;
|
|
45
|
+
url: string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Parameters passed to a platform SumSub launcher.
|
|
49
|
+
*/
|
|
50
|
+
export type KycSumSubLaunchParams = {
|
|
51
|
+
/**
|
|
52
|
+
* The applicant access token used to initialize the SumSub SDK.
|
|
53
|
+
*/
|
|
54
|
+
applicantAccessToken: string;
|
|
55
|
+
/**
|
|
56
|
+
* Called by the SDK when the access token expires; must resolve with a fresh
|
|
57
|
+
* applicant access token.
|
|
58
|
+
*/
|
|
59
|
+
onTokenExpiration: () => Promise<string>;
|
|
60
|
+
/**
|
|
61
|
+
* Called when the SDK reports a status transition.
|
|
62
|
+
*/
|
|
63
|
+
onStatusChange?: (prevStatus: string, newStatus: string) => void;
|
|
64
|
+
/**
|
|
65
|
+
* BCP-47 locale for the SDK UI.
|
|
66
|
+
*/
|
|
67
|
+
locale?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Enables SDK debug logging.
|
|
70
|
+
*/
|
|
71
|
+
debug?: boolean;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Platform adapter that launches the native/web SumSub SDK.
|
|
75
|
+
*
|
|
76
|
+
* The KYC controller is platform-agnostic and does not import any SDK; each
|
|
77
|
+
* client (mobile / extension / web) injects an implementation of this
|
|
78
|
+
* interface. The controller owns all orchestration (session creation, token
|
|
79
|
+
* exchange, token refresh, state) and only delegates the actual SDK
|
|
80
|
+
* presentation to `launch`.
|
|
81
|
+
*/
|
|
82
|
+
export type KycSumSubLauncher = {
|
|
83
|
+
/**
|
|
84
|
+
* Whether the underlying SDK is available in the current runtime (e.g. the
|
|
85
|
+
* native module is linked). When `false`, `startSumSub` fails fast.
|
|
86
|
+
*/
|
|
87
|
+
isAvailable(): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Presents the SumSub verification flow and resolves with the SDK result.
|
|
90
|
+
*/
|
|
91
|
+
launch(params: KycSumSubLaunchParams): Promise<Record<string, unknown>>;
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,CAAC;AAE1C;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,SAAS,CAAC;AAElC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,QAAQ,GAChB,MAAM,GACN,OAAO,GACP,SAAS,GACT,OAAO,GACP,MAAM,GACN,MAAM,GACN,QAAQ,GACR,MAAM,GACN,OAAO,CAAC;AAEZ;;GAEG;AACH,MAAM,MAAM,eAAe,GACvB,MAAM,GACN,iBAAiB,GACjB,eAAe,GACf,WAAW,GACX,YAAY,GACZ,UAAU,GACV,QAAQ,CAAC;AAEb;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IAGX,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAE7B;;;OAGG;IACH,iBAAiB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAEzC;;OAEG;IACH,cAAc,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAEjE;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;OAGG;IACH,WAAW,IAAI,OAAO,CAAC;IAEvB;;OAEG;IACH,MAAM,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACzE,CAAC"}
|
package/dist/types.mjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for the KYC controller and service.
|
|
3
|
+
*
|
|
4
|
+
* The KYC flow is vendor-backed (currently MoonPay for identity + SumSub for
|
|
5
|
+
* document verification) but the surface exposed to consumers (ramps, card) is
|
|
6
|
+
* intentionally vendor-neutral so a future vendor swap does not ripple out.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=types.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG","sourcesContent":["/**\n * Shared types for the KYC controller and service.\n *\n * The KYC flow is vendor-backed (currently MoonPay for identity + SumSub for\n * document verification) but the surface exposed to consumers (ramps, card) is\n * intentionally vendor-neutral so a future vendor swap does not ripple out.\n */\n\n/**\n * A MetaMask feature that consumes KYC. Used to key the per-product\n * \"is KYC required\" cache so ramps and card can share one controller.\n */\nexport type KycProduct = 'ramps' | 'card';\n\n/**\n * Identity vendors supported behind the KYC surface.\n */\nexport type KycVendor = 'moonpay';\n\n/**\n * Phases of the end-to-end identity flow.\n *\n * - `idle` — nothing started.\n * - `terms` — waiting for the customer to accept the vendor terms.\n * - `session` — creating the vendor session.\n * - `check` — running the invisible connection-check frame.\n * - `auth` — running the visible authentication (OTP) frame.\n * - `form` — authenticated. When the flow is scoped to a product, the\n * KYC-required check runs automatically from here; otherwise the consumer\n * drives it manually via `checkKycRequired`.\n * - `submit` — submitting the KYC-required check.\n * - `done` — flow complete; see `kycRequiredByProduct` / `sumsub`. When KYC is\n * required, the document-verification sub-flow is launched automatically.\n * - `error` — flow halted; see `error`.\n */\nexport type KycPhase =\n | 'idle'\n | 'terms'\n | 'session'\n | 'check'\n | 'auth'\n | 'form'\n | 'submit'\n | 'done'\n | 'error';\n\n/**\n * Progress of the SumSub document-verification sub-flow.\n */\nexport type KycSumSubStatus =\n | 'idle'\n | 'creatingSession'\n | 'fetchingToken'\n | 'launching'\n | 'inProgress'\n | 'complete'\n | 'failed';\n\n/**\n * A single disclaimer/term the customer must accept before a session is\n * created.\n */\nexport type KycDisclaimer = {\n id: string;\n // Mirrors the vendor API response field, which is snake_case.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n display_name: string;\n url: string;\n};\n\n/**\n * Parameters passed to a platform SumSub launcher.\n */\nexport type KycSumSubLaunchParams = {\n /**\n * The applicant access token used to initialize the SumSub SDK.\n */\n applicantAccessToken: string;\n\n /**\n * Called by the SDK when the access token expires; must resolve with a fresh\n * applicant access token.\n */\n onTokenExpiration: () => Promise<string>;\n\n /**\n * Called when the SDK reports a status transition.\n */\n onStatusChange?: (prevStatus: string, newStatus: string) => void;\n\n /**\n * BCP-47 locale for the SDK UI.\n */\n locale?: string;\n\n /**\n * Enables SDK debug logging.\n */\n debug?: boolean;\n};\n\n/**\n * Platform adapter that launches the native/web SumSub SDK.\n *\n * The KYC controller is platform-agnostic and does not import any SDK; each\n * client (mobile / extension / web) injects an implementation of this\n * interface. The controller owns all orchestration (session creation, token\n * exchange, token refresh, state) and only delegates the actual SDK\n * presentation to `launch`.\n */\nexport type KycSumSubLauncher = {\n /**\n * Whether the underlying SDK is available in the current runtime (e.g. the\n * native module is linked). When `false`, `startSumSub` fails fast.\n */\n isAvailable(): boolean;\n\n /**\n * Presents the SumSub verification flow and resolves with the SDK result.\n */\n launch(params: KycSumSubLaunchParams): Promise<Record<string, unknown>>;\n};\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@metamask-previews/kyc-controller",
|
|
3
|
+
"version": "0.0.0-preview-11d78534e",
|
|
4
|
+
"description": "Shared KYC / identity verification controller used across MetaMask clients",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"Ethereum",
|
|
7
|
+
"MetaMask"
|
|
8
|
+
],
|
|
9
|
+
"homepage": "https://github.com/MetaMask/core/tree/main/packages/kyc-controller#readme",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/MetaMask/core/issues"
|
|
12
|
+
},
|
|
13
|
+
"license": "(MIT OR Apache-2.0)",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/MetaMask/core.git"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist/"
|
|
20
|
+
],
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"main": "./dist/index.cjs",
|
|
23
|
+
"types": "./dist/index.d.cts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"import": {
|
|
27
|
+
"types": "./dist/index.d.mts",
|
|
28
|
+
"default": "./dist/index.mjs"
|
|
29
|
+
},
|
|
30
|
+
"require": {
|
|
31
|
+
"types": "./dist/index.d.cts",
|
|
32
|
+
"default": "./dist/index.cjs"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"./package.json": "./package.json"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public",
|
|
39
|
+
"registry": "https://registry.npmjs.org/"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
|
|
43
|
+
"build:all": "ts-bridge --project tsconfig.build.json --verbose --clean",
|
|
44
|
+
"build:docs": "typedoc",
|
|
45
|
+
"build:watch": "chokidar 'src/**/*.ts' -c 'ts-bridge --project tsconfig.build.json --verbose --no-references' --initial",
|
|
46
|
+
"changelog:update": "../../scripts/update-changelog.sh @metamask/kyc-controller",
|
|
47
|
+
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/kyc-controller",
|
|
48
|
+
"lint:tsconfigs": "tsx ../../scripts/lint-tsconfigs/lint-tsconfigs.mts",
|
|
49
|
+
"lint:tsconfigs:fix": "tsx ../../scripts/lint-tsconfigs/lint-tsconfigs.mts --fix",
|
|
50
|
+
"messenger-action-types:check": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --check",
|
|
51
|
+
"messenger-action-types:generate": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --generate",
|
|
52
|
+
"since-latest-release": "../../scripts/since-latest-release.sh",
|
|
53
|
+
"test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
|
|
54
|
+
"test:clean": "NODE_OPTIONS=--experimental-vm-modules jest --clearCache",
|
|
55
|
+
"test:verbose": "NODE_OPTIONS=--experimental-vm-modules jest --verbose",
|
|
56
|
+
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
|
|
57
|
+
},
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"@metamask/base-controller": "^9.1.0",
|
|
60
|
+
"@metamask/controller-utils": "^12.3.0",
|
|
61
|
+
"@metamask/geolocation-controller": "^0.1.3",
|
|
62
|
+
"@metamask/messenger": "^2.0.0",
|
|
63
|
+
"@metamask/profile-sync-controller": "^28.3.0",
|
|
64
|
+
"@metamask/superstruct": "^3.1.0",
|
|
65
|
+
"@metamask/utils": "^11.11.0",
|
|
66
|
+
"@noble/ciphers": "^1.3.0",
|
|
67
|
+
"@noble/curves": "^1.9.2",
|
|
68
|
+
"@noble/hashes": "^1.8.0",
|
|
69
|
+
"@scure/base": "^1.2.6",
|
|
70
|
+
"reselect": "^5.1.1"
|
|
71
|
+
},
|
|
72
|
+
"devDependencies": {
|
|
73
|
+
"@metamask/auto-changelog": "^6.1.0",
|
|
74
|
+
"@ts-bridge/cli": "^0.6.4",
|
|
75
|
+
"@types/jest": "^29.5.14",
|
|
76
|
+
"chokidar-cli": "^3.0.0",
|
|
77
|
+
"deepmerge": "^4.2.2",
|
|
78
|
+
"jest": "^29.7.0",
|
|
79
|
+
"nock": "^13.3.1",
|
|
80
|
+
"ts-jest": "^29.2.5",
|
|
81
|
+
"tsx": "^4.20.5",
|
|
82
|
+
"typedoc": "^0.25.13",
|
|
83
|
+
"typedoc-plugin-missing-exports": "^2.0.0",
|
|
84
|
+
"typescript": "~5.3.3"
|
|
85
|
+
},
|
|
86
|
+
"engines": {
|
|
87
|
+
"node": "^18.18 || >=20"
|
|
88
|
+
}
|
|
89
|
+
}
|