@metamask-previews/kyc-controller 0.7.0-preview-44b7ded21 → 0.8.0-preview-2750df1dc
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 +20 -1
- package/dist/KycController-method-action-types.d.ts +13 -9
- package/dist/KycController-method-action-types.d.ts.map +1 -1
- package/dist/KycController-method-action-types.js.map +1 -1
- package/dist/KycController.d.ts +13 -9
- package/dist/KycController.d.ts.map +1 -1
- package/dist/KycController.js +121 -48
- package/dist/KycController.js.map +1 -1
- package/dist/KycService-method-action-types.d.ts +21 -1
- package/dist/KycService-method-action-types.d.ts.map +1 -1
- package/dist/KycService-method-action-types.js.map +1 -1
- package/dist/KycService.d.ts +27 -0
- package/dist/KycService.d.ts.map +1 -1
- package/dist/KycService.js +28 -0
- package/dist/KycService.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/sessionDisclaimers.d.ts +1 -9
- package/dist/sessionDisclaimers.d.ts.map +1 -1
- package/dist/sessionDisclaimers.js +0 -12
- package/dist/sessionDisclaimers.js.map +1 -1
- package/dist/types.d.ts +48 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +53 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/dist/KycService.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KycService.js","sourceRoot":"","sources":["../src/KycService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAO9D,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAKvD,OAAO,EACL,KAAK,EACL,MAAM,EACN,OAAO,EACP,QAAQ,EACR,MAAM,EACN,WAAW,EACX,IAAI,GACL,MAAM,uBAAuB,CAAC;AAI/B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;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H,MAAM,SAAS,GAAY,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;gBACjD,IAAI,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;oBAC/C,MAAM,MAAM,GAAG,SAAoC,CAAC;oBACpD,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;wBACvC,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC;oBAC1B,CAAC;yBAAM,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;wBAC5C,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC;oBACxB,CAAC;gBACH,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,4DAA4D;YAC9D,CAAC;YACD,MAAM,IAAI,SAAS,CACjB,QAAQ,CAAC,MAAM,EACf,aAAa,GAAG,CAAC,QAAQ,EAAE,yBAAyB,QAAQ,CAAC,MAAM,IACjE,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC,EAC3B,EAAE,CACH,CAAC;QACJ,CAAC;QAED,wDAAwD;QACxD,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAS,CAAC;IACzC,CAAC;CACF","sourcesContent":["import { BaseDataService } from '@metamask/base-data-service';\nimport type {\n DataServiceCacheUpdatedEvent,\n DataServiceGranularCacheUpdatedEvent,\n DataServiceInvalidateQueriesAction,\n} from '@metamask/base-data-service';\nimport type { CreateServicePolicyOptions } from '@metamask/controller-utils';\nimport { HttpError } from '@metamask/controller-utils';\nimport type { GeolocationControllerGetGeolocationAction } from '@metamask/geolocation-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type { AuthenticationControllerGetBearerTokenAction } from '@metamask/profile-sync-controller/auth';\nimport type { Infer, Struct } from '@metamask/superstruct';\nimport {\n array,\n assert,\n boolean,\n optional,\n string,\n StructError,\n type,\n} from '@metamask/superstruct';\nimport type { Json } from '@metamask/utils';\nimport type { QueryClientConfig } from '@tanstack/query-core';\n\nimport { alpha2ToAlpha3 } from './countryCodes.js';\nimport type { KycServiceMethodActions } from './KycService-method-action-types.js';\nimport type {\n KycConsentRecord,\n KycDisclaimer,\n KycDisclaimersCatalog,\n KycSessionDisclaimers,\n KycSessionStatus,\n KycVendor,\n KycVendorSigning,\n} from './types.js';\nimport { UKYC_JWKS_PATH } from './ukyc/constants.js';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link KycService}, used to namespace the service's actions.\n */\nexport const serviceName = 'KycService';\n\n// === MESSENGER ===\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'getGeoCountry',\n 'fetchVendorDisclaimers',\n 'createMoonpaySession',\n 'createVendorCustomer',\n 'submitVendorDisclaimers',\n 'fetchSessionDisclaimersByCountry',\n 'fetchSessionDisclaimersBySessionId',\n 'submitSessionDisclaimers',\n 'fetchIdosEnclaveJwks',\n 'fetchIdosRelayJwks',\n 'createUkycSession',\n 'setAuthorizations',\n 'createJourney',\n 'getSessionStatus',\n 'getSessionStatusForVendor',\n] as const;\n\n/**\n * Invalidates cached queries serviced by {@link KycService}.\n */\nexport type KycServiceInvalidateQueriesAction =\n DataServiceInvalidateQueriesAction<typeof serviceName>;\n\n/**\n * Actions that {@link KycService} exposes to other consumers.\n */\nexport type KycServiceActions =\n | KycServiceMethodActions\n | KycServiceInvalidateQueriesAction;\n\n/**\n * Actions from other messengers that {@link KycService} calls.\n */\ntype AllowedActions =\n | AuthenticationControllerGetBearerTokenAction\n | GeolocationControllerGetGeolocationAction;\n\n/**\n * Published when {@link KycService}'s cache is updated.\n */\nexport type KycServiceCacheUpdatedEvent = DataServiceCacheUpdatedEvent<\n typeof serviceName\n>;\n\n/**\n * Published when a single key within {@link KycService}'s cache is updated.\n */\nexport type KycServiceGranularCacheUpdatedEvent =\n DataServiceGranularCacheUpdatedEvent<typeof serviceName>;\n\n/**\n * Events that {@link KycService} exposes to other consumers.\n */\nexport type KycServiceEvents =\n | KycServiceCacheUpdatedEvent\n | KycServiceGranularCacheUpdatedEvent;\n\n/**\n * Events from other messengers that {@link KycService} subscribes to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger restricted to actions and events accessed by\n * {@link KycService}.\n */\nexport type KycServiceMessenger = Messenger<\n typeof serviceName,\n KycServiceActions | AllowedActions,\n KycServiceEvents | AllowedEvents\n>;\n\n/**\n * Options for constructing a {@link KycService}.\n */\nexport type KycServiceOptions = {\n messenger: KycServiceMessenger;\n /**\n * A function used to make HTTP requests. Defaults to the runtime's native\n * `fetch`, so consumers do not need to inject one on platforms where `fetch`\n * is available globally (browser, React Native, Node 18+).\n */\n fetch?: typeof fetch;\n /**\n * Mandatory value that sets the base url to KYC api\n */\n baseUrl: string;\n /**\n * Base URL of the idOS enclave, from which the JWKS used to\n * verify the `encryptionDataKey` schema's `jwtChain` is fetched.\n */\n idosEnclaveBaseUrl?: string;\n /**\n * Base URL of the idOS relay, from which the JWKS used to verify the\n * `ukycCapabilityToken` schema's `jwtChain` is fetched.\n */\n idosRelayBaseUrl?: string;\n /**\n * Shared configuration applied to all queries exposed by the service (e.g. a\n * default `staleTime`/`gcTime`). Each data service gets its own\n * `QueryClient`.\n */\n queryClientConfig?: QueryClientConfig;\n policyOptions?: CreateServicePolicyOptions;\n};\n\n// === API RESPONSE SCHEMAS ===\n\nconst DisclaimerStruct = type({\n id: string(),\n display_name: string(),\n url: string(),\n});\nconst DisclaimersResponseStruct = array(DisclaimerStruct);\n\nconst VendorSigningStruct = type({\n id: string(),\n customer_id: string(),\n content_id: optional(string()),\n});\nconst VendorSigningsResponseStruct = array(VendorSigningStruct);\n\nconst CreateSessionResponseStruct = type({ sessionToken: string() });\n\n// The session server's public key, in JWK-like form, returned inside an\n// encryption schema from `POST /sessions`. `x` is the base64url public key\n// used to wrap a secret for that schema.\nconst ServerPublicKeyStruct = type({\n kty: string(),\n crv: string(),\n x: string(),\n kid: optional(string()),\n alg: optional(string()),\n use: optional(string()),\n});\n\nconst EncryptionSchemaStruct = type({\n serverPublicKey: ServerPublicKeyStruct,\n jwtChain: string(),\n});\nexport type EncryptionSchema = Infer<typeof EncryptionSchemaStruct>;\n\n// A single Ed25519 (OKP) JWK. `type` (not `object`) keeps optional/extra JWK\n// fields (`use`, `alg`) from failing validation.\nconst JwkStruct = type({\n kty: string(),\n crv: string(),\n x: string(),\n kid: string(),\n});\nconst JwksResponseStruct = type({ keys: array(JwkStruct) });\nexport type JwksResponse = Infer<typeof JwksResponseStruct>;\n\nconst UkycSessionResponseStruct = type({\n sessionId: string(),\n // Per-secret wrapping material so the client can seal the\n // `data_encryption_key` and the `ukyc_capability_token` independently.\n encryptionDataKey: EncryptionSchemaStruct,\n ukycCapabilityToken: EncryptionSchemaStruct,\n});\nexport type UkycSessionResponse = Infer<typeof UkycSessionResponseStruct>;\n\nconst ApplicantAccessTokenResponseStruct = type({\n status: string(),\n applicantAccessToken: string(),\n});\nexport type ApplicantAccessTokenResponse = Infer<\n typeof ApplicantAccessTokenResponseStruct\n>;\n\nconst SessionStatusResponseStruct = type({\n id: string(),\n finalStatus: string(),\n statusMessage: optional(string()),\n externalUserId: string(),\n kycStatus: string(),\n vendor: string(),\n vendorStatus: string(),\n consentStatus: optional(string()),\n idOSStatus: optional(string()),\n});\n\n// Vendor customer subset — `type` (not `object`) keeps extra vendor fields from\n// failing validation while still requiring the fields the controller needs.\nconst VendorCustomerResponseStruct = type({\n id: string(),\n email: string(),\n status: string(),\n});\nexport type VendorCustomerResponse = Infer<typeof VendorCustomerResponseStruct>;\n\nconst CatalogDocumentFields = {\n key: string(),\n version: string(),\n title: string(),\n url: string(),\n} as const;\n\nconst CatalogDocumentStruct = type(CatalogDocumentFields);\n\n// Session documents also report whether that version was already consented to.\nconst ConsentDocumentStruct = type({\n ...CatalogDocumentFields,\n consented: boolean(),\n});\n\n/**\n * Global catalog from `GET /disclaimers` (no per-document `consented` flag and\n * no credential-reuse flag).\n */\nconst GlobalDisclaimersResponseStruct = type({\n idOS: array(CatalogDocumentStruct),\n kycProvider: array(CatalogDocumentStruct),\n});\n\n/** Session catalog from `GET`/`POST /sessions/{id}/disclaimers`. */\nconst SessionDisclaimersResponseStruct = type({\n idOS: array(ConsentDocumentStruct),\n kycProvider: array(ConsentDocumentStruct),\n credentialReusabilityConsentGiven: boolean(),\n});\n\n// === PARAM TYPES ===\n\nexport type CreateMoonpaySessionParams = {\n email: string;\n termsAcceptedAt: string;\n disclaimerIds: string[];\n};\n\nexport type CreateVendorCustomerParams = {\n vendor: KycVendor;\n email: string;\n};\n\nexport type SubmitVendorDisclaimersParams = {\n /** Identity vendor whose T&Cs were accepted (currently `iron`). */\n vendor: KycVendor;\n /** Disclaimer ids from {@link KycService.fetchVendorDisclaimers}. */\n disclaimerIds: string[];\n};\n\nexport type FetchSessionDisclaimersByCountryParams = {\n /** ISO 3166-1 alpha-3 country code for `GET /disclaimers?country=`. */\n country: string;\n};\n\nexport type FetchSessionDisclaimersBySessionIdParams = {\n /** UKYC session id from {@link KycService.createUkycSession}. */\n sessionId: string;\n};\n\nexport type SubmitSessionDisclaimersParams = {\n /** UKYC session id from {@link KycService.createUkycSession}. */\n sessionId: string;\n /** Consents to the idOS legal documents (`key`/`version` from the catalog). */\n idOS: KycConsentRecord[];\n /**\n * Consents to the KYC provider (SumSub) legal documents (`key`/`version`\n * from the catalog).\n */\n kycProvider: KycConsentRecord[];\n /** Consent to reuse the user's existing idOS credentials. */\n credentialReusabilityConsentGiven: boolean;\n};\n\nexport type CreateUkycSessionParams = {\n /**\n * The client's per-session X25519 public key (unpadded base64url). Generated\n * with the matching private key used later to wrap authorizations, so the\n * session server can open those boxes.\n */\n sessionClientPublicKey: string;\n /**\n * Country of residence in ISO 3166-1 alpha-3 format (e.g. `USA`, `GBR`).\n */\n residenceCountry: string;\n /**\n * Identity vendor for the UKYC session. Defaults to `moonpay` for the\n * existing Check/Auth flow. Pass a non-MoonPay vendor (e.g. `iron`) for\n * the consents path (no MoonPay metadata required).\n */\n vendor?: KycVendor;\n /**\n * Vendor-specific metadata. Required for MoonPay (`moonPayAccessToken` /\n * `moonPayUserId`); optional / omitted for other vendors.\n */\n vendorMetadata?: Record<string, unknown>;\n /**\n * AAL2 authentication token sent as the `Authorization` bearer value for\n * `POST /sessions`. Other KYC requests continue to use the wallet bearer\n * token.\n */\n aal2Token: string;\n};\n\n/**\n * Encrypted capability authorization payload (base64url nonce + ciphertext)\n * accepted by `POST /sessions/:sessionId/authorizations`. Produced by\n * `wrapEncryptionKey` for both the `data_encryption_key` and the\n * `ukyc_capability_token`.\n */\nexport type CapabilityAuthorization = {\n nonce: string;\n data: string;\n};\n\nexport type SetAuthorizationsParams = {\n sessionId: string;\n wrappedEncryptionDataKey: CapabilityAuthorization;\n wrappedUkycCapabilityToken: CapabilityAuthorization;\n};\n\nexport type GetSessionStatusParams = {\n sessionId: string;\n};\n\n// === SERVICE DEFINITION ===\n\n/**\n * `KycService` communicates with the Universal KYC (UKYC) backend to drive the\n * identity + document-verification flow. It is stateless and platform-agnostic:\n * HTTP is performed through the runtime's native `fetch` (or an injected\n * `fetch` when provided), and the auth bearer token and geolocation come from\n * other controllers via the messenger.\n *\n * HTTP endpoints call `#requestJson` (via the injected or native `fetch`).\n */\nexport class KycService extends BaseDataService<\n typeof serviceName,\n KycServiceMessenger\n> {\n readonly #fetch: typeof fetch;\n\n readonly #baseUrl: string;\n\n readonly #idosEnclaveBaseUrl: string;\n\n readonly #idosRelayBaseUrl: string;\n\n /**\n * Constructs a new KycService.\n *\n * @param options - The constructor options.\n * @param options.messenger - The messenger suited for this service.\n * @param options.fetch - A function used to make HTTP requests. Defaults to\n * the runtime's native `fetch`.\n * @param options.baseUrl - Base URL of the KYC API\n * @param options.idosEnclaveBaseUrl - Base URL of the idOS enclave, from\n * which the JWKS used to verify the `encryptionDataKey` schema's `jwtChain`\n * is fetched.\n * @param options.idosRelayBaseUrl - Base URL of the idOS relay, from which\n * the JWKS used to verify the `ukycCapabilityToken` schema's `jwtChain` is\n * fetched.\n * @param options.queryClientConfig - Shared configuration for all queries\n * exposed by the service.\n * @param options.policyOptions - Options for the request service policy.\n */\n constructor({\n messenger,\n fetch: fetchFunction,\n baseUrl,\n idosEnclaveBaseUrl,\n idosRelayBaseUrl,\n queryClientConfig = {},\n policyOptions = {},\n }: KycServiceOptions) {\n super({\n name: serviceName,\n messenger,\n queryClientConfig,\n policyOptions,\n });\n // Fall back to the runtime's native `fetch`, bound to `globalThis` so it\n // can be invoked as a method of this instance without an illegal-invocation\n // error on platforms that check the receiver.\n if (fetchFunction) {\n this.#fetch = fetchFunction;\n } else if (typeof globalThis.fetch === 'function') {\n this.#fetch = globalThis.fetch.bind(globalThis);\n } else {\n throw new Error(\n 'KycService: fetch is not available globally and was not provided in options. Please inject a fetch implementation.',\n );\n }\n if (!baseUrl) {\n throw new Error('KycService: baseUrl is required');\n }\n this.#baseUrl = baseUrl;\n this.#idosEnclaveBaseUrl = idosEnclaveBaseUrl ?? '';\n this.#idosRelayBaseUrl = idosRelayBaseUrl ?? '';\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Resolves the customer's country from the geolocation source and converts it\n * to an ISO 3166-1 alpha-3 code.\n *\n * @returns The alpha-3 country code.\n * @throws If the country cannot be determined or mapped.\n */\n async getGeoCountry(): Promise<string> {\n const location = await this.messenger.call(\n 'GeolocationController:getGeolocation',\n );\n // Guard nullish/empty geolocation with the documented domain error rather\n // than letting `assert(location, string())` surface a superstruct\n // assertion error (which would change how the failure reads in\n // `vendorError`).\n const alpha2 =\n typeof location === 'string' ? location.split('-')[0].toUpperCase() : '';\n if (!alpha2 || alpha2 === 'UNKNOWN') {\n throw new Error(\n `Unable to determine country from geolocation (got \"${String(\n location,\n )}\").`,\n );\n }\n const alpha3 = alpha2ToAlpha3(alpha2);\n if (!alpha3) {\n throw new Error(\n `Unable to map country code \"${alpha2}\" to an ISO 3166-1 alpha-3 code.`,\n );\n }\n return alpha3;\n }\n\n /**\n * Fetches the disclaimers the customer must accept before a session is\n * created.\n *\n * @param params - The parameters.\n * @param params.vendor - Identity vendor. Defaults to `moonpay`.\n * @param params.country - ISO 3166-1 alpha-3 country code.\n * @returns The disclaimers.\n */\n async fetchVendorDisclaimers({\n vendor = 'moonpay',\n country,\n }: {\n vendor?: KycVendor;\n country: string;\n }): Promise<KycDisclaimer[]> {\n const url = new URL(`/vendors/${vendor}/disclaimers`, this.#baseUrl);\n url.searchParams.set('country', country);\n const data = await this.#requestJson(url, { method: 'GET' });\n return this.#validateResponse(\n data,\n DisclaimersResponseStruct,\n 'disclaimers',\n );\n }\n\n /**\n * Creates a MoonPay vendor session via the UKYC backend.\n *\n * @param params - The session parameters.\n * @returns The created session token.\n */\n async createMoonpaySession(\n params: CreateMoonpaySessionParams,\n ): Promise<Infer<typeof CreateSessionResponseStruct>> {\n const url = new URL('/vendors/moonpay/sessions', this.#baseUrl);\n const data = await this.#requestJson(url, {\n method: 'POST',\n body: JSON.stringify(params),\n });\n return this.#validateResponse(\n data,\n CreateSessionResponseStruct,\n 'sessions',\n );\n }\n\n /**\n * Creates (or resumes) an empty-shell customer for the authenticated\n * canonical user on the given identity vendor. Must run before showing\n * vendor T&C so the customer exists and resume logic can key off vendor\n * status.\n *\n * @param params - The parameters.\n * @param params.vendor - Identity vendor (e.g. `iron` for Money/VBA).\n * @param params.email - Email associated with the customer.\n * @returns The vendor customer record (subset validated for controller use).\n */\n async createVendorCustomer(\n params: CreateVendorCustomerParams,\n ): Promise<VendorCustomerResponse> {\n const url = new URL(`/vendors/${params.vendor}/customers`, this.#baseUrl);\n const data = await this.#requestJson(url, {\n method: 'POST',\n body: JSON.stringify({ email: params.email }),\n });\n return this.#validateResponse(\n data,\n VendorCustomerResponseStruct,\n 'vendor customers',\n );\n }\n\n /**\n * Records vendor T&C acceptance (`POST /vendors/{vendor}/disclaimers`).\n * For Iron this creates content signings from the disclaimer ids the\n * customer accepted. Session-scoped idOS / KYC-provider consents are\n * recorded separately via {@link submitSessionDisclaimers}. Retries re-POST\n * the same ids, matching the legacy `POST /consents` signing step.\n *\n * @param params - The parameters.\n * @param params.vendor - Identity vendor (e.g. `iron`).\n * @param params.disclaimerIds - Accepted vendor T&C ids.\n * @returns The vendor signing records.\n */\n async submitVendorDisclaimers(\n params: SubmitVendorDisclaimersParams,\n ): Promise<KycVendorSigning[]> {\n const url = new URL(\n `/vendors/${encodeURIComponent(params.vendor)}/disclaimers`,\n this.#baseUrl,\n );\n const data = await this.#requestJson(url, {\n method: 'POST',\n body: JSON.stringify({ disclaimerIds: params.disclaimerIds }),\n });\n return this.#validateResponse(\n data,\n VendorSigningsResponseStruct,\n 'vendor disclaimers',\n );\n }\n\n /**\n * Fetches the global idOS + KYC-provider disclaimer catalog\n * (`GET /disclaimers?country=`). Carries no consent state — per-document\n * `consented` flags and `credentialReusabilityConsentGiven` are\n * session-scoped via {@link fetchSessionDisclaimersBySessionId}. Vendor T&Cs continue to\n * come from {@link fetchVendorDisclaimers}.\n *\n * @param params - The parameters.\n * @param params.country - ISO 3166-1 alpha-3 country code.\n * @returns The catalog documents.\n */\n async fetchSessionDisclaimersByCountry({\n country,\n }: FetchSessionDisclaimersByCountryParams): Promise<KycDisclaimersCatalog> {\n if (country.length !== 3) {\n throw new Error(\n `KycService.fetchSessionDisclaimersByCountry: country must be an ISO 3166-1 alpha-3 code (received \"${country}\").`,\n );\n }\n\n const url = new URL('/disclaimers', this.#baseUrl);\n url.searchParams.set('country', country);\n const data = await this.#requestJson(url, { method: 'GET' });\n return this.#validateResponse(\n data,\n GlobalDisclaimersResponseStruct,\n 'disclaimers',\n );\n }\n\n /**\n * Fetches the session-scoped idOS + KYC-provider disclaimer catalog\n * (`GET /sessions/{sessionId}/disclaimers`), including per-session\n * `consented` flags and `credentialReusabilityConsentGiven`. For the\n * pre-session global catalog use {@link fetchSessionDisclaimersByCountry}.\n * Vendor T&Cs continue to come from {@link fetchVendorDisclaimers}.\n *\n * @param params - The parameters.\n * @param params.sessionId - The UKYC session id.\n * @returns The catalog, including which documents are already consented.\n */\n async fetchSessionDisclaimersBySessionId({\n sessionId,\n }: FetchSessionDisclaimersBySessionIdParams): Promise<KycSessionDisclaimers> {\n const url = new URL(\n `/sessions/${encodeURIComponent(sessionId)}/disclaimers`,\n this.#baseUrl,\n );\n const data = await this.#requestJson(url, { method: 'GET' });\n return this.#validateResponse(\n data,\n SessionDisclaimersResponseStruct,\n 'session disclaimers',\n );\n }\n\n /**\n * Records idOS + KYC-provider consents for a UKYC session\n * (`POST /sessions/{sessionId}/disclaimers`). `key`/`version` pairs must\n * match the current catalog from {@link fetchSessionDisclaimersBySessionId}. A 409\n * means those document versions were already recorded for the session.\n *\n * @param params - The consent parameters.\n * @returns The updated catalog after recording.\n */\n async submitSessionDisclaimers(\n params: SubmitSessionDisclaimersParams,\n ): Promise<KycSessionDisclaimers> {\n const url = new URL(\n `/sessions/${encodeURIComponent(params.sessionId)}/disclaimers`,\n this.#baseUrl,\n );\n const data = await this.#requestJson(url, {\n method: 'POST',\n body: JSON.stringify({\n idOS: params.idOS,\n kycProvider: params.kycProvider,\n credentialReusabilityConsentGiven:\n params.credentialReusabilityConsentGiven,\n }),\n });\n return this.#validateResponse(\n data,\n SessionDisclaimersResponseStruct,\n 'session disclaimers',\n );\n }\n\n /**\n * Fetches a well-known JWKS from `baseUrl`.\n *\n * @param baseUrl - Host base URL that serves `/.well-known/jwks.json`.\n * @param responseLabel - Label used in malformed-response errors.\n * @param missingConfigMessage - Error thrown when `baseUrl` is empty.\n * @returns The JWKS keys.\n */\n async #fetchWellKnownJwks(\n baseUrl: string,\n responseLabel: string,\n missingConfigMessage: string,\n ): Promise<JwksResponse> {\n if (!baseUrl) {\n throw new Error(missingConfigMessage);\n }\n const url = new URL(UKYC_JWKS_PATH, baseUrl);\n const data = await this.#requestJson(\n url,\n { method: 'GET' },\n { authenticated: false },\n );\n return this.#validateResponse(data, JwksResponseStruct, responseLabel);\n }\n\n /**\n * Fetches the idOS enclave JWKS used to verify the\n * `encryptionDataKey` schema's `jwtChain` from\n * {@link KycService.createUkycSession}.\n *\n * This is an unauthenticated request to a well-known path on the idOS enclave\n * host, distinct from the UKYC base URL.\n *\n * @returns The JWKS keys.\n */\n async fetchIdosEnclaveJwks(): Promise<JwksResponse> {\n return this.#fetchWellKnownJwks(\n this.#idosEnclaveBaseUrl,\n 'idOS enclave JWKS',\n 'KycService: idosEnclaveBaseUrl is not configured; cannot fetch JWKS to verify the encryptionDataKey schema.',\n );\n }\n\n /**\n * Fetches the idOS relay JWKS used to verify the `ukycCapabilityToken`\n * schema's `jwtChain` from {@link KycService.createUkycSession}.\n *\n * This is an unauthenticated request to a well-known path on the idOS relay\n * host, distinct from both the UKYC base URL and the idOS enclave.\n *\n * @returns The JWKS keys.\n */\n async fetchIdosRelayJwks(): Promise<JwksResponse> {\n return this.#fetchWellKnownJwks(\n this.#idosRelayBaseUrl,\n 'idOS relay JWKS',\n 'KycService: idosRelayBaseUrl is not configured; cannot fetch JWKS to verify the ukycCapabilityToken schema.',\n );\n }\n\n /**\n * Creates a UKYC session for the SumSub document-verification sub-flow.\n *\n * The client registers its per-session X25519 public key so the server can\n * later open boxes sealed with the matching private key, and supplies the\n * customer's ISO 3166-1 alpha-3 country of residence. The response\n * carries per-secret encryption schemas (`encryptionDataKey` and\n * `ukycCapabilityToken`) so the client can wrap the `data_encryption_key` and\n * the read-only `ukyc_capability_token` and submit them via\n * {@link KycService.setAuthorizations}.\n *\n * Session creation is authenticated with `params.aal2Token` as the\n * `Authorization` bearer value, instead of the wallet bearer token.\n *\n * @param params - The session parameters.\n * @param params.aal2Token - AAL2 authentication token used as the\n * Authorization bearer value.\n * @returns The UKYC session id and encryption schemas.\n */\n async createUkycSession(\n params: CreateUkycSessionParams,\n ): Promise<UkycSessionResponse> {\n if (!params.aal2Token) {\n throw new Error(\n 'KycService.createUkycSession: aal2Token is required to authenticate session creation.',\n );\n }\n\n const url = new URL('/sessions', this.#baseUrl);\n const data = await this.#requestJson(\n url,\n {\n method: 'POST',\n body: JSON.stringify({\n vendorId: params.vendor ?? 'moonpay',\n vendorUserId: 'mockedId',\n jwtToken: 'mock-jwt-token', // TODO: Remove this from the kyc-api\n sessionClientPublicKey: params.sessionClientPublicKey,\n residenceCountry: params.residenceCountry,\n vendorMetadata: params.vendorMetadata ?? {},\n }),\n },\n { bearerToken: params.aal2Token },\n );\n return this.#validateResponse(\n data,\n UkycSessionResponseStruct,\n 'UKYC sessions',\n );\n }\n\n /**\n * Submits the wrapped `data_encryption_key` and wrapped\n * `ukyc_capability_token` for a UKYC session. Both secrets are sealed with\n * `wrapEncryptionKey` against the encryption schemas returned by\n * {@link KycService.createUkycSession}.\n *\n * @param params - The wrapped authorizations.\n * @returns The session status after the authorizations are applied.\n */\n async setAuthorizations(\n params: SetAuthorizationsParams,\n ): Promise<KycSessionStatus> {\n const url = new URL(\n `/sessions/${encodeURIComponent(params.sessionId)}/authorizations`,\n this.#baseUrl,\n );\n const data = await this.#requestJson(url, {\n method: 'POST',\n body: JSON.stringify({\n wrappedEncryptionDataKey: params.wrappedEncryptionDataKey,\n wrappedUkycCapabilityToken: params.wrappedUkycCapabilityToken,\n }),\n });\n return this.#validateResponse(\n data,\n SessionStatusResponseStruct,\n 'authorizations',\n );\n }\n\n /**\n * Creates (or refreshes) the SumSub verification journey for a UKYC session,\n * returning the applicant access token used to launch the SDK.\n *\n * @param sessionId - The UKYC session id from `createUkycSession`.\n * @returns The applicant access token and status.\n */\n async createJourney(\n sessionId: string,\n ): Promise<ApplicantAccessTokenResponse> {\n const url = new URL(\n `/sessions/${encodeURIComponent(sessionId)}/journey`,\n this.#baseUrl,\n );\n const data = await this.#requestJson(url, { method: 'POST' });\n return this.#validateResponse(\n data,\n ApplicantAccessTokenResponseStruct,\n 'journey',\n );\n }\n\n /**\n * Fetches the current status of a UKYC session. Polled after the SumSub SDK\n * completes to determine the final verification decision.\n *\n * @param params - The parameters.\n * @param params.sessionId - The UKYC session id.\n * @returns The session status.\n */\n async getSessionStatus(\n params: GetSessionStatusParams,\n ): Promise<KycSessionStatus> {\n const url = new URL(\n `/sessions/${encodeURIComponent(params.sessionId)}/status`,\n this.#baseUrl,\n );\n const data = await this.#requestJson(url, { method: 'GET' });\n return this.#validateResponse(\n data,\n SessionStatusResponseStruct,\n 'session status',\n );\n }\n\n /**\n * Fetches the latest UKYC session status for an identity vendor\n * (`GET /sessions/latest/status/{vendor}`).\n *\n * @param vendor - Identity vendor whose latest session should be queried.\n * @returns The session status, or `null` when no latest session exists.\n */\n async getSessionStatusForVendor(\n vendor: KycVendor,\n ): Promise<KycSessionStatus | null> {\n const url = new URL(\n `/sessions/latest/status/${encodeURIComponent(vendor)}`,\n this.#baseUrl,\n );\n try {\n const data = await this.#requestJson(url, { method: 'GET' });\n if (data === null) {\n return null;\n }\n return this.#validateResponse(\n data,\n SessionStatusResponseStruct,\n 'latest session status',\n );\n } catch (error) {\n if (error instanceof HttpError && error.httpStatus === 404) {\n return null;\n }\n throw error;\n }\n }\n\n /**\n * Validates a parsed API response against a superstruct schema, throwing a\n * descriptive error when the response does not match.\n *\n * Unlike a bare `Struct.is` check, this surfaces exactly which field was\n * missing or had the wrong type, which is essential for diagnosing shape\n * mismatches between the client and the live API.\n *\n * @param data - The parsed response body.\n * @param struct - The superstruct schema the body is expected to satisfy.\n * @param apiName - A human-readable name of the API, used in the error message.\n * @returns The validated, typed response.\n * @throws If `data` does not match `struct`.\n */\n #validateResponse<Type, Schema>(\n data: unknown,\n struct: Struct<Type, Schema>,\n apiName: string,\n ): Type {\n try {\n assert(data, struct);\n return data;\n } catch (error) {\n const detail =\n error instanceof StructError\n ? `${error.message} (received: ${JSON.stringify(data)})`\n : // `assert` only ever throws `StructError` for the plain structs used\n // here, so this is a defensive fallback that is not exercised.\n /* istanbul ignore next */\n String(error);\n throw new Error(\n `Malformed response received from ${apiName} API: ${detail}`,\n );\n }\n }\n\n /**\n * Performs a single JSON request via `fetch`.\n *\n * Requests are authenticated with the wallet bearer token by default; pass\n * `{ authenticated: false }` for calls to services that do not expect it\n * (e.g. the idOS enclave or idOS relay JWKS endpoints). Pass `bearerToken`\n * to send that value instead of the wallet bearer token.\n *\n * @param url - The request URL.\n * @param init - The request init (method, body).\n * @param options - Request options.\n * @param options.authenticated - Whether to attach the bearer token. Defaults\n * to `true`.\n * @param options.bearerToken - Authorization bearer value. When omitted, the\n * wallet bearer token from `AuthenticationController:getBearerToken` is used.\n * @returns The parsed JSON response.\n */\n async #requestJson(\n url: URL,\n init: RequestInit,\n options: { authenticated?: boolean; bearerToken?: string } = {},\n ): Promise<Json> {\n const { authenticated = true, bearerToken } = options;\n\n const headers: Record<string, string> = {};\n\n // Only advertise a JSON body when one is actually sent; bodyless requests\n // (e.g. `createJourney`) must not carry a `Content-Type`.\n if (init.body !== undefined && init.body !== null) {\n headers['Content-Type'] = 'application/json';\n }\n\n if (authenticated) {\n const resolvedBearerToken =\n bearerToken ??\n (await this.messenger.call('AuthenticationController:getBearerToken'));\n if (!resolvedBearerToken) {\n throw new Error(\n 'Unable to obtain an authentication bearer token — is the wallet signed in?',\n );\n }\n assert(resolvedBearerToken, string());\n headers.Authorization = `Bearer ${resolvedBearerToken}`;\n }\n\n const response = await this.#fetch(url.toString(), {\n ...init,\n headers,\n });\n if (!response.ok) {\n let detail = '';\n try {\n const errorBody: unknown = await response.json();\n if (errorBody && typeof errorBody === 'object') {\n const record = errorBody as Record<string, unknown>;\n if (typeof record.message === 'string') {\n detail = record.message;\n } else if (typeof record.error === 'string') {\n detail = record.error;\n }\n }\n } catch {\n // Ignore body parse failures; status alone is still useful.\n }\n throw new HttpError(\n response.status,\n `Fetching '${url.toString()}' failed with status '${response.status}'${\n detail ? `: ${detail}` : ''\n }`,\n );\n }\n\n // DELETE (and similar) endpoints return 204 No Content.\n if (response.status === 204) {\n return null;\n }\n\n return (await response.json()) as Json;\n }\n}\n"]}
|
|
1
|
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AAC;wBAC5C,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC;oBACxB,CAAC;gBACH,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,4DAA4D;YAC9D,CAAC;YACD,MAAM,IAAI,SAAS,CACjB,QAAQ,CAAC,MAAM,EACf,aAAa,GAAG,CAAC,QAAQ,EAAE,yBAAyB,QAAQ,CAAC,MAAM,IACjE,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC,EAC3B,EAAE,CACH,CAAC;QACJ,CAAC;QAED,wDAAwD;QACxD,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAS,CAAC;IACzC,CAAC;CACF","sourcesContent":["import { BaseDataService } from '@metamask/base-data-service';\nimport type {\n DataServiceCacheUpdatedEvent,\n DataServiceGranularCacheUpdatedEvent,\n DataServiceInvalidateQueriesAction,\n} from '@metamask/base-data-service';\nimport type { CreateServicePolicyOptions } from '@metamask/controller-utils';\nimport { HttpError } from '@metamask/controller-utils';\nimport type { GeolocationControllerGetGeolocationAction } from '@metamask/geolocation-controller';\nimport type { Messenger } from '@metamask/messenger';\nimport type { AuthenticationControllerGetBearerTokenAction } from '@metamask/profile-sync-controller/auth';\nimport type { Infer, Struct } from '@metamask/superstruct';\nimport {\n array,\n assert,\n boolean,\n optional,\n string,\n StructError,\n type,\n} from '@metamask/superstruct';\nimport type { Json } from '@metamask/utils';\nimport type { QueryClientConfig } from '@tanstack/query-core';\n\nimport { alpha2ToAlpha3 } from './countryCodes.js';\nimport type { KycServiceMethodActions } from './KycService-method-action-types.js';\nimport type {\n KycConsentRecord,\n KycDisclaimer,\n KycDisclaimersCatalog,\n KycSessionDisclaimers,\n KycSessionStatus,\n KycVendor,\n KycVendorSigning,\n} from './types.js';\nimport { UKYC_JWKS_PATH } from './ukyc/constants.js';\n\n// === GENERAL ===\n\n/**\n * The name of the {@link KycService}, used to namespace the service's actions.\n */\nexport const serviceName = 'KycService';\n\n// === MESSENGER ===\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'getGeoCountry',\n 'fetchVendorDisclaimers',\n 'createMoonpaySession',\n 'createVendorCustomer',\n 'submitVendorDisclaimers',\n 'fetchSessionDisclaimersByCountry',\n 'fetchSessionDisclaimersBySessionId',\n 'submitSessionDisclaimers',\n 'fetchIdosEnclaveJwks',\n 'fetchIdosRelayJwks',\n 'createUkycSession',\n 'resetWrappingKeys',\n 'setAuthorizations',\n 'createJourney',\n 'getSessionStatus',\n 'getSessionStatusForVendor',\n] as const;\n\n/**\n * Invalidates cached queries serviced by {@link KycService}.\n */\nexport type KycServiceInvalidateQueriesAction =\n DataServiceInvalidateQueriesAction<typeof serviceName>;\n\n/**\n * Actions that {@link KycService} exposes to other consumers.\n */\nexport type KycServiceActions =\n | KycServiceMethodActions\n | KycServiceInvalidateQueriesAction;\n\n/**\n * Actions from other messengers that {@link KycService} calls.\n */\ntype AllowedActions =\n | AuthenticationControllerGetBearerTokenAction\n | GeolocationControllerGetGeolocationAction;\n\n/**\n * Published when {@link KycService}'s cache is updated.\n */\nexport type KycServiceCacheUpdatedEvent = DataServiceCacheUpdatedEvent<\n typeof serviceName\n>;\n\n/**\n * Published when a single key within {@link KycService}'s cache is updated.\n */\nexport type KycServiceGranularCacheUpdatedEvent =\n DataServiceGranularCacheUpdatedEvent<typeof serviceName>;\n\n/**\n * Events that {@link KycService} exposes to other consumers.\n */\nexport type KycServiceEvents =\n | KycServiceCacheUpdatedEvent\n | KycServiceGranularCacheUpdatedEvent;\n\n/**\n * Events from other messengers that {@link KycService} subscribes to.\n */\ntype AllowedEvents = never;\n\n/**\n * The messenger restricted to actions and events accessed by\n * {@link KycService}.\n */\nexport type KycServiceMessenger = Messenger<\n typeof serviceName,\n KycServiceActions | AllowedActions,\n KycServiceEvents | AllowedEvents\n>;\n\n/**\n * Options for constructing a {@link KycService}.\n */\nexport type KycServiceOptions = {\n messenger: KycServiceMessenger;\n /**\n * A function used to make HTTP requests. Defaults to the runtime's native\n * `fetch`, so consumers do not need to inject one on platforms where `fetch`\n * is available globally (browser, React Native, Node 18+).\n */\n fetch?: typeof fetch;\n /**\n * Mandatory value that sets the base url to KYC api\n */\n baseUrl: string;\n /**\n * Base URL of the idOS enclave, from which the JWKS used to\n * verify the `encryptionDataKey` schema's `jwtChain` is fetched.\n */\n idosEnclaveBaseUrl?: string;\n /**\n * Base URL of the idOS relay, from which the JWKS used to verify the\n * `ukycCapabilityToken` schema's `jwtChain` is fetched.\n */\n idosRelayBaseUrl?: string;\n /**\n * Shared configuration applied to all queries exposed by the service (e.g. a\n * default `staleTime`/`gcTime`). Each data service gets its own\n * `QueryClient`.\n */\n queryClientConfig?: QueryClientConfig;\n policyOptions?: CreateServicePolicyOptions;\n};\n\n// === API RESPONSE SCHEMAS ===\n\nconst DisclaimerStruct = type({\n id: string(),\n display_name: string(),\n url: string(),\n});\nconst DisclaimersResponseStruct = array(DisclaimerStruct);\n\nconst VendorSigningStruct = type({\n id: string(),\n customer_id: string(),\n content_id: optional(string()),\n});\nconst VendorSigningsResponseStruct = array(VendorSigningStruct);\n\nconst CreateSessionResponseStruct = type({ sessionToken: string() });\n\n// The session server's public key, in JWK-like form, returned inside an\n// encryption schema from `POST /sessions`. `x` is the base64url public key\n// used to wrap a secret for that schema.\nconst ServerPublicKeyStruct = type({\n kty: string(),\n crv: string(),\n x: string(),\n kid: optional(string()),\n alg: optional(string()),\n use: optional(string()),\n});\n\nconst EncryptionSchemaStruct = type({\n serverPublicKey: ServerPublicKeyStruct,\n jwtChain: string(),\n});\nexport type EncryptionSchema = Infer<typeof EncryptionSchemaStruct>;\n\n// A single Ed25519 (OKP) JWK. `type` (not `object`) keeps optional/extra JWK\n// fields (`use`, `alg`) from failing validation.\nconst JwkStruct = type({\n kty: string(),\n crv: string(),\n x: string(),\n kid: string(),\n});\nconst JwksResponseStruct = type({ keys: array(JwkStruct) });\nexport type JwksResponse = Infer<typeof JwksResponseStruct>;\n\nconst UkycSessionResponseStruct = type({\n sessionId: string(),\n // Per-secret wrapping material so the client can seal the\n // `data_encryption_key` and the `ukyc_capability_token` independently.\n encryptionDataKey: EncryptionSchemaStruct,\n ukycCapabilityToken: EncryptionSchemaStruct,\n});\nexport type UkycSessionResponse = Infer<typeof UkycSessionResponseStruct>;\n\nconst ApplicantAccessTokenResponseStruct = type({\n status: string(),\n applicantAccessToken: string(),\n});\nexport type ApplicantAccessTokenResponse = Infer<\n typeof ApplicantAccessTokenResponseStruct\n>;\n\nconst SessionStatusResponseStruct = type({\n id: string(),\n finalStatus: string(),\n statusMessage: optional(string()),\n externalUserId: string(),\n kycStatus: string(),\n vendor: string(),\n vendorStatus: string(),\n consentStatus: optional(string()),\n idOSStatus: optional(string()),\n capabilityAuthorizationStatus: optional(string()),\n});\n\n// Vendor customer subset — `type` (not `object`) keeps extra vendor fields from\n// failing validation while still requiring the fields the controller needs.\nconst VendorCustomerResponseStruct = type({\n id: string(),\n email: string(),\n status: string(),\n});\nexport type VendorCustomerResponse = Infer<typeof VendorCustomerResponseStruct>;\n\nconst CatalogDocumentFields = {\n key: string(),\n version: string(),\n title: string(),\n url: string(),\n} as const;\n\nconst CatalogDocumentStruct = type(CatalogDocumentFields);\n\n// Session documents also report whether that version was already consented to.\nconst ConsentDocumentStruct = type({\n ...CatalogDocumentFields,\n consented: boolean(),\n});\n\n/**\n * Global catalog from `GET /disclaimers` (no per-document `consented` flag and\n * no credential-reuse flag).\n */\nconst GlobalDisclaimersResponseStruct = type({\n idOS: array(CatalogDocumentStruct),\n kycProvider: array(CatalogDocumentStruct),\n});\n\n/** Session catalog from `GET`/`POST /sessions/{id}/disclaimers`. */\nconst SessionDisclaimersResponseStruct = type({\n idOS: array(ConsentDocumentStruct),\n kycProvider: array(ConsentDocumentStruct),\n credentialReusabilityConsentGiven: boolean(),\n});\n\n// === PARAM TYPES ===\n\nexport type CreateMoonpaySessionParams = {\n email: string;\n termsAcceptedAt: string;\n disclaimerIds: string[];\n};\n\nexport type CreateVendorCustomerParams = {\n vendor: KycVendor;\n email: string;\n};\n\nexport type SubmitVendorDisclaimersParams = {\n /** Identity vendor whose T&Cs were accepted (currently `iron`). */\n vendor: KycVendor;\n /** Disclaimer ids from {@link KycService.fetchVendorDisclaimers}. */\n disclaimerIds: string[];\n};\n\nexport type FetchSessionDisclaimersByCountryParams = {\n /** ISO 3166-1 alpha-3 country code for `GET /disclaimers?country=`. */\n country: string;\n};\n\nexport type FetchSessionDisclaimersBySessionIdParams = {\n /** UKYC session id from {@link KycService.createUkycSession}. */\n sessionId: string;\n};\n\nexport type SubmitSessionDisclaimersParams = {\n /** UKYC session id from {@link KycService.createUkycSession}. */\n sessionId: string;\n /** Consents to the idOS legal documents (`key`/`version` from the catalog). */\n idOS: KycConsentRecord[];\n /**\n * Consents to the KYC provider (SumSub) legal documents (`key`/`version`\n * from the catalog).\n */\n kycProvider: KycConsentRecord[];\n /** Consent to reuse the user's existing idOS credentials. */\n credentialReusabilityConsentGiven: boolean;\n};\n\nexport type CreateUkycSessionParams = {\n /**\n * The client's per-session X25519 public key (unpadded base64url). Generated\n * with the matching private key used later to wrap authorizations, so the\n * session server can open those boxes.\n */\n sessionClientPublicKey: string;\n /**\n * Country of residence in ISO 3166-1 alpha-3 format (e.g. `USA`, `GBR`).\n */\n residenceCountry: string;\n /**\n * Identity vendor for the UKYC session. Defaults to `moonpay` for the\n * existing Check/Auth flow. Pass a non-MoonPay vendor (e.g. `iron`) for\n * the consents path (no MoonPay metadata required).\n */\n vendor?: KycVendor;\n /**\n * Vendor-specific metadata. Required for MoonPay (`moonPayAccessToken` /\n * `moonPayUserId`); optional / omitted for other vendors.\n */\n vendorMetadata?: Record<string, unknown>;\n /**\n * AAL2 authentication token sent as the `Authorization` bearer value for\n * `POST /sessions`. Other KYC requests continue to use the wallet bearer\n * token.\n */\n aal2Token: string;\n};\n\n/**\n * Encrypted capability authorization payload (base64url nonce + ciphertext)\n * accepted by `POST /sessions/:sessionId/authorizations`. Produced by\n * `wrapEncryptionKey` for both the `data_encryption_key` and the\n * `ukyc_capability_token`.\n */\nexport type CapabilityAuthorization = {\n nonce: string;\n data: string;\n};\n\nexport type SetAuthorizationsParams = {\n sessionId: string;\n wrappedEncryptionDataKey: CapabilityAuthorization;\n wrappedUkycCapabilityToken: CapabilityAuthorization;\n};\n\nexport type GetSessionStatusParams = {\n sessionId: string;\n};\n\nexport type ResetWrappingKeysParams = {\n /** UKYC session id whose wrapping keys should be reissued. */\n sessionId: string;\n /**\n * The client's per-session X25519 public key (unpadded base64url). Generated\n * with the matching private key used to wrap the refreshed authorizations,\n * so the session server can open those boxes.\n */\n sessionClientPublicKey: string;\n};\n\n// === SERVICE DEFINITION ===\n\n/**\n * `KycService` communicates with the Universal KYC (UKYC) backend to drive the\n * identity + document-verification flow. It is stateless and platform-agnostic:\n * HTTP is performed through the runtime's native `fetch` (or an injected\n * `fetch` when provided), and the auth bearer token and geolocation come from\n * other controllers via the messenger.\n *\n * HTTP endpoints call `#requestJson` (via the injected or native `fetch`).\n */\nexport class KycService extends BaseDataService<\n typeof serviceName,\n KycServiceMessenger\n> {\n readonly #fetch: typeof fetch;\n\n readonly #baseUrl: string;\n\n readonly #idosEnclaveBaseUrl: string;\n\n readonly #idosRelayBaseUrl: string;\n\n /**\n * Constructs a new KycService.\n *\n * @param options - The constructor options.\n * @param options.messenger - The messenger suited for this service.\n * @param options.fetch - A function used to make HTTP requests. Defaults to\n * the runtime's native `fetch`.\n * @param options.baseUrl - Base URL of the KYC API\n * @param options.idosEnclaveBaseUrl - Base URL of the idOS enclave, from\n * which the JWKS used to verify the `encryptionDataKey` schema's `jwtChain`\n * is fetched.\n * @param options.idosRelayBaseUrl - Base URL of the idOS relay, from which\n * the JWKS used to verify the `ukycCapabilityToken` schema's `jwtChain` is\n * fetched.\n * @param options.queryClientConfig - Shared configuration for all queries\n * exposed by the service.\n * @param options.policyOptions - Options for the request service policy.\n */\n constructor({\n messenger,\n fetch: fetchFunction,\n baseUrl,\n idosEnclaveBaseUrl,\n idosRelayBaseUrl,\n queryClientConfig = {},\n policyOptions = {},\n }: KycServiceOptions) {\n super({\n name: serviceName,\n messenger,\n queryClientConfig,\n policyOptions,\n });\n // Fall back to the runtime's native `fetch`, bound to `globalThis` so it\n // can be invoked as a method of this instance without an illegal-invocation\n // error on platforms that check the receiver.\n if (fetchFunction) {\n this.#fetch = fetchFunction;\n } else if (typeof globalThis.fetch === 'function') {\n this.#fetch = globalThis.fetch.bind(globalThis);\n } else {\n throw new Error(\n 'KycService: fetch is not available globally and was not provided in options. Please inject a fetch implementation.',\n );\n }\n if (!baseUrl) {\n throw new Error('KycService: baseUrl is required');\n }\n this.#baseUrl = baseUrl;\n this.#idosEnclaveBaseUrl = idosEnclaveBaseUrl ?? '';\n this.#idosRelayBaseUrl = idosRelayBaseUrl ?? '';\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Resolves the customer's country from the geolocation source and converts it\n * to an ISO 3166-1 alpha-3 code.\n *\n * @returns The alpha-3 country code.\n * @throws If the country cannot be determined or mapped.\n */\n async getGeoCountry(): Promise<string> {\n const location = await this.messenger.call(\n 'GeolocationController:getGeolocation',\n );\n // Guard nullish/empty geolocation with the documented domain error rather\n // than letting `assert(location, string())` surface a superstruct\n // assertion error (which would change how the failure reads in\n // `vendorError`).\n const alpha2 =\n typeof location === 'string' ? location.split('-')[0].toUpperCase() : '';\n if (!alpha2 || alpha2 === 'UNKNOWN') {\n throw new Error(\n `Unable to determine country from geolocation (got \"${String(\n location,\n )}\").`,\n );\n }\n const alpha3 = alpha2ToAlpha3(alpha2);\n if (!alpha3) {\n throw new Error(\n `Unable to map country code \"${alpha2}\" to an ISO 3166-1 alpha-3 code.`,\n );\n }\n return alpha3;\n }\n\n /**\n * Fetches the disclaimers the customer must accept before a session is\n * created.\n *\n * @param params - The parameters.\n * @param params.vendor - Identity vendor. Defaults to `moonpay`.\n * @param params.country - ISO 3166-1 alpha-3 country code.\n * @returns The disclaimers.\n */\n async fetchVendorDisclaimers({\n vendor = 'moonpay',\n country,\n }: {\n vendor?: KycVendor;\n country: string;\n }): Promise<KycDisclaimer[]> {\n const url = new URL(`/vendors/${vendor}/disclaimers`, this.#baseUrl);\n url.searchParams.set('country', country);\n const data = await this.#requestJson(url, { method: 'GET' });\n return this.#validateResponse(\n data,\n DisclaimersResponseStruct,\n 'disclaimers',\n );\n }\n\n /**\n * Creates a MoonPay vendor session via the UKYC backend.\n *\n * @param params - The session parameters.\n * @returns The created session token.\n */\n async createMoonpaySession(\n params: CreateMoonpaySessionParams,\n ): Promise<Infer<typeof CreateSessionResponseStruct>> {\n const url = new URL('/vendors/moonpay/sessions', this.#baseUrl);\n const data = await this.#requestJson(url, {\n method: 'POST',\n body: JSON.stringify(params),\n });\n return this.#validateResponse(\n data,\n CreateSessionResponseStruct,\n 'sessions',\n );\n }\n\n /**\n * Creates (or resumes) an empty-shell customer for the authenticated\n * canonical user on the given identity vendor. Must run before showing\n * vendor T&C so the customer exists and resume logic can key off vendor\n * status.\n *\n * @param params - The parameters.\n * @param params.vendor - Identity vendor (e.g. `iron` for Money/VBA).\n * @param params.email - Email associated with the customer.\n * @returns The vendor customer record (subset validated for controller use).\n */\n async createVendorCustomer(\n params: CreateVendorCustomerParams,\n ): Promise<VendorCustomerResponse> {\n const url = new URL(`/vendors/${params.vendor}/customers`, this.#baseUrl);\n const data = await this.#requestJson(url, {\n method: 'POST',\n body: JSON.stringify({ email: params.email }),\n });\n return this.#validateResponse(\n data,\n VendorCustomerResponseStruct,\n 'vendor customers',\n );\n }\n\n /**\n * Records vendor T&C acceptance (`POST /vendors/{vendor}/disclaimers`).\n * For Iron this creates content signings from the disclaimer ids the\n * customer accepted. Session-scoped idOS / KYC-provider consents are\n * recorded separately via {@link submitSessionDisclaimers}. Retries re-POST\n * the same ids, matching the legacy `POST /consents` signing step.\n *\n * @param params - The parameters.\n * @param params.vendor - Identity vendor (e.g. `iron`).\n * @param params.disclaimerIds - Accepted vendor T&C ids.\n * @returns The vendor signing records.\n */\n async submitVendorDisclaimers(\n params: SubmitVendorDisclaimersParams,\n ): Promise<KycVendorSigning[]> {\n const url = new URL(\n `/vendors/${encodeURIComponent(params.vendor)}/disclaimers`,\n this.#baseUrl,\n );\n const data = await this.#requestJson(url, {\n method: 'POST',\n body: JSON.stringify({ disclaimerIds: params.disclaimerIds }),\n });\n return this.#validateResponse(\n data,\n VendorSigningsResponseStruct,\n 'vendor disclaimers',\n );\n }\n\n /**\n * Fetches the global idOS + KYC-provider disclaimer catalog\n * (`GET /disclaimers?country=`). Carries no consent state — per-document\n * `consented` flags and `credentialReusabilityConsentGiven` are\n * session-scoped via {@link fetchSessionDisclaimersBySessionId}. Vendor T&Cs continue to\n * come from {@link fetchVendorDisclaimers}.\n *\n * @param params - The parameters.\n * @param params.country - ISO 3166-1 alpha-3 country code.\n * @returns The catalog documents.\n */\n async fetchSessionDisclaimersByCountry({\n country,\n }: FetchSessionDisclaimersByCountryParams): Promise<KycDisclaimersCatalog> {\n if (country.length !== 3) {\n throw new Error(\n `KycService.fetchSessionDisclaimersByCountry: country must be an ISO 3166-1 alpha-3 code (received \"${country}\").`,\n );\n }\n\n const url = new URL('/disclaimers', this.#baseUrl);\n url.searchParams.set('country', country);\n const data = await this.#requestJson(url, { method: 'GET' });\n return this.#validateResponse(\n data,\n GlobalDisclaimersResponseStruct,\n 'disclaimers',\n );\n }\n\n /**\n * Fetches the session-scoped idOS + KYC-provider disclaimer catalog\n * (`GET /sessions/{sessionId}/disclaimers`), including per-session\n * `consented` flags and `credentialReusabilityConsentGiven`. For the\n * pre-session global catalog use {@link fetchSessionDisclaimersByCountry}.\n * Vendor T&Cs continue to come from {@link fetchVendorDisclaimers}.\n *\n * @param params - The parameters.\n * @param params.sessionId - The UKYC session id.\n * @returns The catalog, including which documents are already consented.\n */\n async fetchSessionDisclaimersBySessionId({\n sessionId,\n }: FetchSessionDisclaimersBySessionIdParams): Promise<KycSessionDisclaimers> {\n const url = new URL(\n `/sessions/${encodeURIComponent(sessionId)}/disclaimers`,\n this.#baseUrl,\n );\n const data = await this.#requestJson(url, { method: 'GET' });\n return this.#validateResponse(\n data,\n SessionDisclaimersResponseStruct,\n 'session disclaimers',\n );\n }\n\n /**\n * Records idOS + KYC-provider consents for a UKYC session\n * (`POST /sessions/{sessionId}/disclaimers`). `key`/`version` pairs must\n * match the current catalog from {@link fetchSessionDisclaimersBySessionId}. A 409\n * means those document versions were already recorded for the session.\n *\n * @param params - The consent parameters.\n * @returns The updated catalog after recording.\n */\n async submitSessionDisclaimers(\n params: SubmitSessionDisclaimersParams,\n ): Promise<KycSessionDisclaimers> {\n const url = new URL(\n `/sessions/${encodeURIComponent(params.sessionId)}/disclaimers`,\n this.#baseUrl,\n );\n const data = await this.#requestJson(url, {\n method: 'POST',\n body: JSON.stringify({\n idOS: params.idOS,\n kycProvider: params.kycProvider,\n credentialReusabilityConsentGiven:\n params.credentialReusabilityConsentGiven,\n }),\n });\n return this.#validateResponse(\n data,\n SessionDisclaimersResponseStruct,\n 'session disclaimers',\n );\n }\n\n /**\n * Fetches a well-known JWKS from `baseUrl`.\n *\n * @param baseUrl - Host base URL that serves `/.well-known/jwks.json`.\n * @param responseLabel - Label used in malformed-response errors.\n * @param missingConfigMessage - Error thrown when `baseUrl` is empty.\n * @returns The JWKS keys.\n */\n async #fetchWellKnownJwks(\n baseUrl: string,\n responseLabel: string,\n missingConfigMessage: string,\n ): Promise<JwksResponse> {\n if (!baseUrl) {\n throw new Error(missingConfigMessage);\n }\n const url = new URL(UKYC_JWKS_PATH, baseUrl);\n const data = await this.#requestJson(\n url,\n { method: 'GET' },\n { authenticated: false },\n );\n return this.#validateResponse(data, JwksResponseStruct, responseLabel);\n }\n\n /**\n * Fetches the idOS enclave JWKS used to verify the\n * `encryptionDataKey` schema's `jwtChain` from\n * {@link KycService.createUkycSession}.\n *\n * This is an unauthenticated request to a well-known path on the idOS enclave\n * host, distinct from the UKYC base URL.\n *\n * @returns The JWKS keys.\n */\n async fetchIdosEnclaveJwks(): Promise<JwksResponse> {\n return this.#fetchWellKnownJwks(\n this.#idosEnclaveBaseUrl,\n 'idOS enclave JWKS',\n 'KycService: idosEnclaveBaseUrl is not configured; cannot fetch JWKS to verify the encryptionDataKey schema.',\n );\n }\n\n /**\n * Fetches the idOS relay JWKS used to verify the `ukycCapabilityToken`\n * schema's `jwtChain` from {@link KycService.createUkycSession}.\n *\n * This is an unauthenticated request to a well-known path on the idOS relay\n * host, distinct from both the UKYC base URL and the idOS enclave.\n *\n * @returns The JWKS keys.\n */\n async fetchIdosRelayJwks(): Promise<JwksResponse> {\n return this.#fetchWellKnownJwks(\n this.#idosRelayBaseUrl,\n 'idOS relay JWKS',\n 'KycService: idosRelayBaseUrl is not configured; cannot fetch JWKS to verify the ukycCapabilityToken schema.',\n );\n }\n\n /**\n * Creates a UKYC session for the SumSub document-verification sub-flow.\n *\n * The client registers its per-session X25519 public key so the server can\n * later open boxes sealed with the matching private key, and supplies the\n * customer's ISO 3166-1 alpha-3 country of residence. The response\n * carries per-secret encryption schemas (`encryptionDataKey` and\n * `ukycCapabilityToken`) so the client can wrap the `data_encryption_key` and\n * the read-only `ukyc_capability_token` and submit them via\n * {@link KycService.setAuthorizations}.\n *\n * Session creation is authenticated with `params.aal2Token` as the\n * `Authorization` bearer value, instead of the wallet bearer token.\n *\n * @param params - The session parameters.\n * @param params.aal2Token - AAL2 authentication token used as the\n * Authorization bearer value.\n * @returns The UKYC session id and encryption schemas.\n */\n async createUkycSession(\n params: CreateUkycSessionParams,\n ): Promise<UkycSessionResponse> {\n if (!params.aal2Token) {\n throw new Error(\n 'KycService.createUkycSession: aal2Token is required to authenticate session creation.',\n );\n }\n\n const url = new URL('/sessions', this.#baseUrl);\n const data = await this.#requestJson(\n url,\n {\n method: 'POST',\n body: JSON.stringify({\n vendorId: params.vendor ?? 'moonpay',\n vendorUserId: 'mockedId',\n jwtToken: 'mock-jwt-token', // TODO: Remove this from the kyc-api\n sessionClientPublicKey: params.sessionClientPublicKey,\n residenceCountry: params.residenceCountry,\n vendorMetadata: params.vendorMetadata ?? {},\n }),\n },\n { bearerToken: params.aal2Token },\n );\n return this.#validateResponse(\n data,\n UkycSessionResponseStruct,\n 'UKYC sessions',\n );\n }\n\n /**\n * Reissues wrapping keys for an existing UKYC session\n * (`POST /sessions/{sessionId}/wrapping-keys`).\n *\n * The client registers a new per-session X25519 public key so the server can\n * open boxes sealed with the matching private key. The response matches\n * {@link KycService.createUkycSession}: a session id plus per-secret\n * encryption schemas (`encryptionDataKey` and `ukycCapabilityToken`) used to\n * wrap and submit authorizations.\n *\n * @param params - The session whose wrapping keys should be reset.\n * @param params.sessionId - UKYC session id.\n * @param params.sessionClientPublicKey - Per-session X25519 public key\n * (unpadded base64url) registered on the session.\n * @returns The session id and fresh encryption schemas.\n */\n async resetWrappingKeys(\n params: ResetWrappingKeysParams,\n ): Promise<UkycSessionResponse> {\n const url = new URL(\n `/sessions/${encodeURIComponent(params.sessionId)}/wrapping-keys`,\n this.#baseUrl,\n );\n const data = await this.#requestJson(url, {\n method: 'POST',\n body: JSON.stringify({\n sessionClientPublicKey: params.sessionClientPublicKey,\n }),\n });\n return this.#validateResponse(\n data,\n UkycSessionResponseStruct,\n 'wrapping keys',\n );\n }\n\n /**\n * Submits the wrapped `data_encryption_key` and wrapped\n * `ukyc_capability_token` for a UKYC session. Both secrets are sealed with\n * `wrapEncryptionKey` against the encryption schemas returned by\n * {@link KycService.createUkycSession}.\n *\n * @param params - The wrapped authorizations.\n * @returns The session status after the authorizations are applied.\n */\n async setAuthorizations(\n params: SetAuthorizationsParams,\n ): Promise<KycSessionStatus> {\n const url = new URL(\n `/sessions/${encodeURIComponent(params.sessionId)}/authorizations`,\n this.#baseUrl,\n );\n const data = await this.#requestJson(url, {\n method: 'POST',\n body: JSON.stringify({\n wrappedEncryptionDataKey: params.wrappedEncryptionDataKey,\n wrappedUkycCapabilityToken: params.wrappedUkycCapabilityToken,\n }),\n });\n return this.#validateResponse(\n data,\n SessionStatusResponseStruct,\n 'authorizations',\n );\n }\n\n /**\n * Creates (or refreshes) the SumSub verification journey for a UKYC session,\n * returning the applicant access token used to launch the SDK.\n *\n * @param sessionId - The UKYC session id from `createUkycSession`.\n * @returns The applicant access token and status.\n */\n async createJourney(\n sessionId: string,\n ): Promise<ApplicantAccessTokenResponse> {\n const url = new URL(\n `/sessions/${encodeURIComponent(sessionId)}/journey`,\n this.#baseUrl,\n );\n const data = await this.#requestJson(url, { method: 'POST' });\n return this.#validateResponse(\n data,\n ApplicantAccessTokenResponseStruct,\n 'journey',\n );\n }\n\n /**\n * Fetches the current status of a UKYC session. Polled after the SumSub SDK\n * completes to determine the final verification decision.\n *\n * @param params - The parameters.\n * @param params.sessionId - The UKYC session id.\n * @returns The session status.\n */\n async getSessionStatus(\n params: GetSessionStatusParams,\n ): Promise<KycSessionStatus> {\n const url = new URL(\n `/sessions/${encodeURIComponent(params.sessionId)}/status`,\n this.#baseUrl,\n );\n const data = await this.#requestJson(url, { method: 'GET' });\n return this.#validateResponse(\n data,\n SessionStatusResponseStruct,\n 'session status',\n );\n }\n\n /**\n * Fetches the latest UKYC session status for an identity vendor\n * (`GET /sessions/latest/status/{vendor}`).\n *\n * @param vendor - Identity vendor whose latest session should be queried.\n * @returns The session status, or `null` when no latest session exists.\n */\n async getSessionStatusForVendor(\n vendor: KycVendor,\n ): Promise<KycSessionStatus | null> {\n const url = new URL(\n `/sessions/latest/status/${encodeURIComponent(vendor)}`,\n this.#baseUrl,\n );\n try {\n const data = await this.#requestJson(url, { method: 'GET' });\n if (data === null) {\n return null;\n }\n return this.#validateResponse(\n data,\n SessionStatusResponseStruct,\n 'latest session status',\n );\n } catch (error) {\n if (error instanceof HttpError && error.httpStatus === 404) {\n return null;\n }\n throw error;\n }\n }\n\n /**\n * Validates a parsed API response against a superstruct schema, throwing a\n * descriptive error when the response does not match.\n *\n * Unlike a bare `Struct.is` check, this surfaces exactly which field was\n * missing or had the wrong type, which is essential for diagnosing shape\n * mismatches between the client and the live API.\n *\n * @param data - The parsed response body.\n * @param struct - The superstruct schema the body is expected to satisfy.\n * @param apiName - A human-readable name of the API, used in the error message.\n * @returns The validated, typed response.\n * @throws If `data` does not match `struct`.\n */\n #validateResponse<Type, Schema>(\n data: unknown,\n struct: Struct<Type, Schema>,\n apiName: string,\n ): Type {\n try {\n assert(data, struct);\n return data;\n } catch (error) {\n const detail =\n error instanceof StructError\n ? `${error.message} (received: ${JSON.stringify(data)})`\n : // `assert` only ever throws `StructError` for the plain structs used\n // here, so this is a defensive fallback that is not exercised.\n /* istanbul ignore next */\n String(error);\n throw new Error(\n `Malformed response received from ${apiName} API: ${detail}`,\n );\n }\n }\n\n /**\n * Performs a single JSON request via `fetch`.\n *\n * Requests are authenticated with the wallet bearer token by default; pass\n * `{ authenticated: false }` for calls to services that do not expect it\n * (e.g. the idOS enclave or idOS relay JWKS endpoints). Pass `bearerToken`\n * to send that value instead of the wallet bearer token.\n *\n * @param url - The request URL.\n * @param init - The request init (method, body).\n * @param options - Request options.\n * @param options.authenticated - Whether to attach the bearer token. Defaults\n * to `true`.\n * @param options.bearerToken - Authorization bearer value. When omitted, the\n * wallet bearer token from `AuthenticationController:getBearerToken` is used.\n * @returns The parsed JSON response.\n */\n async #requestJson(\n url: URL,\n init: RequestInit,\n options: { authenticated?: boolean; bearerToken?: string } = {},\n ): Promise<Json> {\n const { authenticated = true, bearerToken } = options;\n\n const headers: Record<string, string> = {};\n\n // Only advertise a JSON body when one is actually sent; bodyless requests\n // (e.g. `createJourney`) must not carry a `Content-Type`.\n if (init.body !== undefined && init.body !== null) {\n headers['Content-Type'] = 'application/json';\n }\n\n if (authenticated) {\n const resolvedBearerToken =\n bearerToken ??\n (await this.messenger.call('AuthenticationController:getBearerToken'));\n if (!resolvedBearerToken) {\n throw new Error(\n 'Unable to obtain an authentication bearer token — is the wallet signed in?',\n );\n }\n assert(resolvedBearerToken, string());\n headers.Authorization = `Bearer ${resolvedBearerToken}`;\n }\n\n const response = await this.#fetch(url.toString(), {\n ...init,\n headers,\n });\n if (!response.ok) {\n let detail = '';\n try {\n const errorBody: unknown = await response.json();\n if (errorBody && typeof errorBody === 'object') {\n const record = errorBody as Record<string, unknown>;\n if (typeof record.message === 'string') {\n detail = record.message;\n } else if (typeof record.error === 'string') {\n detail = record.error;\n }\n }\n } catch {\n // Ignore body parse failures; status alone is still useful.\n }\n throw new HttpError(\n response.status,\n `Fetching '${url.toString()}' failed with status '${response.status}'${\n detail ? `: ${detail}` : ''\n }`,\n );\n }\n\n // DELETE (and similar) endpoints return 204 No Content.\n if (response.status === 204) {\n return null;\n }\n\n return (await response.json()) as Json;\n }\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,13 +2,15 @@ export { KycController, getDefaultKycControllerState, getDefaultKycProviderDiscl
|
|
|
2
2
|
export type { KycControllerActions, KycControllerEvents, KycControllerGetStateAction, KycControllerMessenger, KycControllerOptions, KycControllerState, KycControllerStateChangeEvent, FetchSessionDisclaimersParams, KycProviderFlowStatus, } from './KycController.js';
|
|
3
3
|
export type { KycControllerClearStateAction, KycControllerFetchSessionDisclaimersAction, KycControllerFetchVendorDisclaimersAction, KycControllerGetProviderFlowStatusAction, KycControllerGetSessionStatusForVendorAction, KycControllerHasCompletedSessionDisclaimersAction, KycControllerHasCompletedVendorDisclaimersAction, KycControllerLaunchProviderFlowAction, KycControllerRecordSessionDisclaimersAction, KycControllerRecordVendorDisclaimersAction, KycControllerFetchSessionStatusOnceAction, KycControllerReadSessionStatusAction, KycControllerRefreshSessionStatusAction, KycControllerResetAction, KycControllerStartSessionAction, KycControllerStartSessionStatusPollingAction, } from './KycController-method-action-types.js';
|
|
4
4
|
export { KycService, serviceName } from './KycService.js';
|
|
5
|
-
export type { ApplicantAccessTokenResponse, CapabilityAuthorization, CreateVendorCustomerParams, CreateMoonpaySessionParams, CreateUkycSessionParams, EncryptionSchema, FetchSessionDisclaimersByCountryParams, FetchSessionDisclaimersBySessionIdParams, GetSessionStatusParams, VendorCustomerResponse, JwksResponse, KycServiceActions, KycServiceCacheUpdatedEvent, KycServiceEvents, KycServiceGranularCacheUpdatedEvent, KycServiceInvalidateQueriesAction, KycServiceMessenger, KycServiceOptions, SetAuthorizationsParams, SubmitSessionDisclaimersParams, SubmitVendorDisclaimersParams, UkycSessionResponse, } from './KycService.js';
|
|
6
|
-
export type { KycServiceCreateVendorCustomerAction, KycServiceCreateJourneyAction, KycServiceCreateMoonpaySessionAction, KycServiceCreateUkycSessionAction, KycServiceFetchIdosEnclaveJwksAction, KycServiceFetchIdosRelayJwksAction, KycServiceFetchSessionDisclaimersByCountryAction, KycServiceFetchSessionDisclaimersBySessionIdAction, KycServiceFetchVendorDisclaimersAction, KycServiceGetGeoCountryAction, KycServiceGetSessionStatusAction, KycServiceGetSessionStatusForVendorAction, KycServiceSetAuthorizationsAction, KycServiceSubmitSessionDisclaimersAction, KycServiceSubmitVendorDisclaimersAction, } from './KycService-method-action-types.js';
|
|
5
|
+
export type { ApplicantAccessTokenResponse, CapabilityAuthorization, CreateVendorCustomerParams, CreateMoonpaySessionParams, CreateUkycSessionParams, EncryptionSchema, FetchSessionDisclaimersByCountryParams, FetchSessionDisclaimersBySessionIdParams, GetSessionStatusParams, ResetWrappingKeysParams, VendorCustomerResponse, JwksResponse, KycServiceActions, KycServiceCacheUpdatedEvent, KycServiceEvents, KycServiceGranularCacheUpdatedEvent, KycServiceInvalidateQueriesAction, KycServiceMessenger, KycServiceOptions, SetAuthorizationsParams, SubmitSessionDisclaimersParams, SubmitVendorDisclaimersParams, UkycSessionResponse, } from './KycService.js';
|
|
6
|
+
export type { KycServiceCreateVendorCustomerAction, KycServiceCreateJourneyAction, KycServiceCreateMoonpaySessionAction, KycServiceCreateUkycSessionAction, KycServiceFetchIdosEnclaveJwksAction, KycServiceFetchIdosRelayJwksAction, KycServiceFetchSessionDisclaimersByCountryAction, KycServiceFetchSessionDisclaimersBySessionIdAction, KycServiceFetchVendorDisclaimersAction, KycServiceGetGeoCountryAction, KycServiceGetSessionStatusAction, KycServiceGetSessionStatusForVendorAction, KycServiceResetWrappingKeysAction, KycServiceSetAuthorizationsAction, KycServiceSubmitSessionDisclaimersAction, KycServiceSubmitVendorDisclaimersAction, } from './KycService-method-action-types.js';
|
|
7
7
|
export { selectKycSessionStatus, selectKycVendor } from './selectors.js';
|
|
8
8
|
export { alpha2ToAlpha3, ALPHA2_TO_ALPHA3 } from './countryCodes.js';
|
|
9
9
|
export { decryptCredentials, generateKeyPair } from './crypto.js';
|
|
10
10
|
export type { DecryptedCredentials, DecryptResult, EncryptedCredentialsEnvelope, X25519KeyPair, } from './crypto.js';
|
|
11
|
+
export { KYC_STATUSES, TERMINAL_SESSION_STATUSES } from './types.js';
|
|
11
12
|
export type { KycCatalogDocument, KycConsentDocument, KycConsentRecord, KycDisclaimer, KycDisclaimersCatalog, KycPhase, KycProduct, KycProviderDisclaimersAccepted, KycSessionDisclaimers, KycSessionStatus, KycVendor, KycIronVendorDisclaimersAccepted, KycMoonpayVendorDisclaimersAccepted, KycVendorDisclaimersAccepted, KycVendorSigning, } from './types.js';
|
|
13
|
+
export { FINAL_STATUSES_TO_SKIP_AUTH_REFRESH, CAPABILITY_AUTHORIZATION_STATUSES, CAPABILITY_AUTHORIZATION_STATUSES_TO_REFRESH, needsCapabilityAuthorizationRefresh, FINAL_STATUSES_TO_STOP_POLLING, } from './types.js';
|
|
12
14
|
export type { KycSumSubLaunchParams, KycSumSubLauncher, KycSumSubSdkStatus, KycSumSubStatus, } from './providers/sumsub.js';
|
|
13
15
|
export { UKYC_CAPABILITY_AUTH_SCHEME, UKYC_KWIL_AUDIENCE, UKYC_STORAGE_ACCESS_TOKEN_AUDIENCE, UKYC_STORAGE_ACCESS_TOKEN_AUDIENCES, UKYC_STORAGE_ACCESS_TOKEN_VERSION, } from './ukyc/constants.js';
|
|
14
16
|
export { deriveClientMaterial, encodeClientMaterial, } from './ukyc/deriveClientMaterial.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,4BAA4B,EAC5B,wCAAwC,EACxC,sCAAsC,EACtC,0BAA0B,EAC1B,cAAc,GACf,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,2BAA2B,EAC3B,sBAAsB,EACtB,oBAAoB,EACpB,kBAAkB,EAClB,6BAA6B,EAC7B,6BAA6B,EAC7B,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,6BAA6B,EAC7B,0CAA0C,EAC1C,yCAAyC,EACzC,wCAAwC,EACxC,4CAA4C,EAC5C,iDAAiD,EACjD,gDAAgD,EAChD,qCAAqC,EACrC,2CAA2C,EAC3C,0CAA0C,EAC1C,yCAAyC,EACzC,oCAAoC,EACpC,uCAAuC,EACvC,wBAAwB,EACxB,+BAA+B,EAC/B,4CAA4C,GAC7C,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC1D,YAAY,EACV,4BAA4B,EAC5B,uBAAuB,EACvB,0BAA0B,EAC1B,0BAA0B,EAC1B,uBAAuB,EACvB,gBAAgB,EAChB,sCAAsC,EACtC,wCAAwC,EACxC,sBAAsB,EACtB,sBAAsB,EACtB,YAAY,EACZ,iBAAiB,EACjB,2BAA2B,EAC3B,gBAAgB,EAChB,mCAAmC,EACnC,iCAAiC,EACjC,mBAAmB,EACnB,iBAAiB,EACjB,uBAAuB,EACvB,8BAA8B,EAC9B,6BAA6B,EAC7B,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,oCAAoC,EACpC,6BAA6B,EAC7B,oCAAoC,EACpC,iCAAiC,EACjC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M,qBAAqB,CAAC;AAC7B,OAAO,EACL,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,gCAAgC,CAAC;AACxC,YAAY,EACV,yBAAyB,EACzB,kBAAkB,GACnB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,iCAAiC,EACjC,sBAAsB,GACvB,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACV,4BAA4B,EAC5B,sBAAsB,EACtB,6BAA6B,EAC7B,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,YAAY,EACV,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,kCAAkC,CAAC;AAC1C,YAAY,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,8 @@ export { KycService, serviceName } from './KycService.js';
|
|
|
3
3
|
export { selectKycSessionStatus, selectKycVendor } from './selectors.js';
|
|
4
4
|
export { alpha2ToAlpha3, ALPHA2_TO_ALPHA3 } from './countryCodes.js';
|
|
5
5
|
export { decryptCredentials, generateKeyPair } from './crypto.js';
|
|
6
|
+
export { KYC_STATUSES, TERMINAL_SESSION_STATUSES } from './types.js';
|
|
7
|
+
export { FINAL_STATUSES_TO_SKIP_AUTH_REFRESH, CAPABILITY_AUTHORIZATION_STATUSES, CAPABILITY_AUTHORIZATION_STATUSES_TO_REFRESH, needsCapabilityAuthorizationRefresh, FINAL_STATUSES_TO_STOP_POLLING, } from './types.js';
|
|
6
8
|
// UKYC storage-access-token utilities. Exported so a signed capability token can
|
|
7
9
|
// be minted for testing UKYC Storage (see `mintUkycTestToken`).
|
|
8
10
|
export { UKYC_CAPABILITY_AUTH_SCHEME, UKYC_KWIL_AUDIENCE, UKYC_STORAGE_ACCESS_TOKEN_AUDIENCE, UKYC_STORAGE_ACCESS_TOKEN_AUDIENCES, UKYC_STORAGE_ACCESS_TOKEN_VERSION, } from './ukyc/constants.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,4BAA4B,EAC5B,wCAAwC,EACxC,sCAAsC,EACtC,0BAA0B,EAC1B,cAAc,GACf,MAAM,oBAAoB,CAAC;AA+B5B,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,4BAA4B,EAC5B,wCAAwC,EACxC,sCAAsC,EACtC,0BAA0B,EAC1B,cAAc,GACf,MAAM,oBAAoB,CAAC;AA+B5B,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AA6C1D,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEzE,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAQlE,OAAO,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAkBrE,OAAO,EACL,mCAAmC,EACnC,iCAAiC,EACjC,4CAA4C,EAC5C,mCAAmC,EACnC,8BAA8B,GAC/B,MAAM,YAAY,CAAC;AAQpB,iFAAiF;AACjF,gEAAgE;AAChE,OAAO,EACL,2BAA2B,EAC3B,kBAAkB,EAClB,kCAAkC,EAClC,mCAAmC,EACnC,iCAAiC,GAClC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,gCAAgC,CAAC;AAKxC,OAAO,EACL,iCAAiC,EACjC,sBAAsB,GACvB,MAAM,8BAA8B,CAAC;AAQtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAMxD,OAAO,EACL,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,kCAAkC,CAAC","sourcesContent":["export {\n KycController,\n getDefaultKycControllerState,\n getDefaultKycProviderDisclaimersAccepted,\n getDefaultKycVendorDisclaimersAccepted,\n KYC_PROVIDER_FLOW_STATUSES,\n controllerName,\n} from './KycController.js';\nexport type {\n KycControllerActions,\n KycControllerEvents,\n KycControllerGetStateAction,\n KycControllerMessenger,\n KycControllerOptions,\n KycControllerState,\n KycControllerStateChangeEvent,\n FetchSessionDisclaimersParams,\n KycProviderFlowStatus,\n} from './KycController.js';\nexport type {\n KycControllerClearStateAction,\n KycControllerFetchSessionDisclaimersAction,\n KycControllerFetchVendorDisclaimersAction,\n KycControllerGetProviderFlowStatusAction,\n KycControllerGetSessionStatusForVendorAction,\n KycControllerHasCompletedSessionDisclaimersAction,\n KycControllerHasCompletedVendorDisclaimersAction,\n KycControllerLaunchProviderFlowAction,\n KycControllerRecordSessionDisclaimersAction,\n KycControllerRecordVendorDisclaimersAction,\n KycControllerFetchSessionStatusOnceAction,\n KycControllerReadSessionStatusAction,\n KycControllerRefreshSessionStatusAction,\n KycControllerResetAction,\n KycControllerStartSessionAction,\n KycControllerStartSessionStatusPollingAction,\n} from './KycController-method-action-types.js';\n\nexport { KycService, serviceName } from './KycService.js';\nexport type {\n ApplicantAccessTokenResponse,\n CapabilityAuthorization,\n CreateVendorCustomerParams,\n CreateMoonpaySessionParams,\n CreateUkycSessionParams,\n EncryptionSchema,\n FetchSessionDisclaimersByCountryParams,\n FetchSessionDisclaimersBySessionIdParams,\n GetSessionStatusParams,\n ResetWrappingKeysParams,\n VendorCustomerResponse,\n JwksResponse,\n KycServiceActions,\n KycServiceCacheUpdatedEvent,\n KycServiceEvents,\n KycServiceGranularCacheUpdatedEvent,\n KycServiceInvalidateQueriesAction,\n KycServiceMessenger,\n KycServiceOptions,\n SetAuthorizationsParams,\n SubmitSessionDisclaimersParams,\n SubmitVendorDisclaimersParams,\n UkycSessionResponse,\n} from './KycService.js';\nexport type {\n KycServiceCreateVendorCustomerAction,\n KycServiceCreateJourneyAction,\n KycServiceCreateMoonpaySessionAction,\n KycServiceCreateUkycSessionAction,\n KycServiceFetchIdosEnclaveJwksAction,\n KycServiceFetchIdosRelayJwksAction,\n KycServiceFetchSessionDisclaimersByCountryAction,\n KycServiceFetchSessionDisclaimersBySessionIdAction,\n KycServiceFetchVendorDisclaimersAction,\n KycServiceGetGeoCountryAction,\n KycServiceGetSessionStatusAction,\n KycServiceGetSessionStatusForVendorAction,\n KycServiceResetWrappingKeysAction,\n KycServiceSetAuthorizationsAction,\n KycServiceSubmitSessionDisclaimersAction,\n KycServiceSubmitVendorDisclaimersAction,\n} from './KycService-method-action-types.js';\n\nexport { selectKycSessionStatus, selectKycVendor } from './selectors.js';\n\nexport { alpha2ToAlpha3, ALPHA2_TO_ALPHA3 } from './countryCodes.js';\nexport { decryptCredentials, generateKeyPair } from './crypto.js';\nexport type {\n DecryptedCredentials,\n DecryptResult,\n EncryptedCredentialsEnvelope,\n X25519KeyPair,\n} from './crypto.js';\n\nexport { KYC_STATUSES, TERMINAL_SESSION_STATUSES } from './types.js';\nexport type {\n KycCatalogDocument,\n KycConsentDocument,\n KycConsentRecord,\n KycDisclaimer,\n KycDisclaimersCatalog,\n KycPhase,\n KycProduct,\n KycProviderDisclaimersAccepted,\n KycSessionDisclaimers,\n KycSessionStatus,\n KycVendor,\n KycIronVendorDisclaimersAccepted,\n KycMoonpayVendorDisclaimersAccepted,\n KycVendorDisclaimersAccepted,\n KycVendorSigning,\n} from './types.js';\nexport {\n FINAL_STATUSES_TO_SKIP_AUTH_REFRESH,\n CAPABILITY_AUTHORIZATION_STATUSES,\n CAPABILITY_AUTHORIZATION_STATUSES_TO_REFRESH,\n needsCapabilityAuthorizationRefresh,\n FINAL_STATUSES_TO_STOP_POLLING,\n} from './types.js';\nexport type {\n KycSumSubLaunchParams,\n KycSumSubLauncher,\n KycSumSubSdkStatus,\n KycSumSubStatus,\n} from './providers/sumsub.js';\n\n// UKYC storage-access-token utilities. Exported so a signed capability token can\n// be minted for testing UKYC Storage (see `mintUkycTestToken`).\nexport {\n UKYC_CAPABILITY_AUTH_SCHEME,\n UKYC_KWIL_AUDIENCE,\n UKYC_STORAGE_ACCESS_TOKEN_AUDIENCE,\n UKYC_STORAGE_ACCESS_TOKEN_AUDIENCES,\n UKYC_STORAGE_ACCESS_TOKEN_VERSION,\n} from './ukyc/constants.js';\nexport {\n deriveClientMaterial,\n encodeClientMaterial,\n} from './ukyc/deriveClientMaterial.js';\nexport type {\n EncodedUkycClientMaterial,\n UkycClientMaterial,\n} from './ukyc/deriveClientMaterial.js';\nexport {\n encodeStorageAccessTokenForHeader,\n signStorageAccessToken,\n} from './ukyc/storageAccessToken.js';\nexport type {\n SignStorageAccessTokenParams,\n UkycStorageAccessToken,\n UkycStorageAccessTokenPayload,\n UkycStorageOperation,\n UkycTokenPresenter,\n} from './ukyc/storageAccessToken.js';\nexport { mintUkycTestToken } from './ukyc/testToken.js';\nexport type {\n MintedUkycTestToken,\n MintUkycTestTokenParams,\n} from './ukyc/testToken.js';\n\nexport {\n clearMoonPaySession,\n MoonPayFrameHandler,\n} from './vendors/MoonPayFrameHandler.js';\nexport type { MoonPayFrameHandlerOptions } from './vendors/MoonPayFrameHandler.js';\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { KycConsentDocument, KycConsentRecord
|
|
1
|
+
import type { KycConsentDocument, KycConsentRecord } from './types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Maps accepted disclaimer records onto unconsented catalog documents.
|
|
4
4
|
*
|
|
@@ -7,12 +7,4 @@ import type { KycConsentDocument, KycConsentRecord, KycSessionDisclaimers } from
|
|
|
7
7
|
* @returns Consent records to POST, omitting already-consented documents.
|
|
8
8
|
*/
|
|
9
9
|
export declare function consentRecordsFromAcceptedList(documents: KycConsentDocument[], accepted: KycConsentRecord[]): KycConsentRecord[];
|
|
10
|
-
/**
|
|
11
|
-
* Returns whether every session catalog document is consented and credential
|
|
12
|
-
* reuse was accepted.
|
|
13
|
-
*
|
|
14
|
-
* @param disclaimers - Session-scoped disclaimer catalog.
|
|
15
|
-
* @returns Whether all documents are consented and reuse consent is given.
|
|
16
|
-
*/
|
|
17
|
-
export declare function areSessionDisclaimersCompleted(disclaimers: KycSessionDisclaimers): boolean;
|
|
18
10
|
//# sourceMappingURL=sessionDisclaimers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessionDisclaimers.d.ts","sourceRoot":"","sources":["../src/sessionDisclaimers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"sessionDisclaimers.d.ts","sourceRoot":"","sources":["../src/sessionDisclaimers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEvE;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,kBAAkB,EAAE,EAC/B,QAAQ,EAAE,gBAAgB,EAAE,GAC3B,gBAAgB,EAAE,CAcpB"}
|
|
@@ -15,16 +15,4 @@ export function consentRecordsFromAcceptedList(documents, accepted) {
|
|
|
15
15
|
acceptedKeys.has(`${document.key}:${document.version}`))
|
|
16
16
|
.map(({ key, version }) => ({ key, version }));
|
|
17
17
|
}
|
|
18
|
-
/**
|
|
19
|
-
* Returns whether every session catalog document is consented and credential
|
|
20
|
-
* reuse was accepted.
|
|
21
|
-
*
|
|
22
|
-
* @param disclaimers - Session-scoped disclaimer catalog.
|
|
23
|
-
* @returns Whether all documents are consented and reuse consent is given.
|
|
24
|
-
*/
|
|
25
|
-
export function areSessionDisclaimersCompleted(disclaimers) {
|
|
26
|
-
return (disclaimers.credentialReusabilityConsentGiven &&
|
|
27
|
-
disclaimers.idOS.every((document) => document.consented) &&
|
|
28
|
-
disclaimers.kycProvider.every((document) => document.consented));
|
|
29
|
-
}
|
|
30
18
|
//# sourceMappingURL=sessionDisclaimers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessionDisclaimers.js","sourceRoot":"","sources":["../src/sessionDisclaimers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sessionDisclaimers.js","sourceRoot":"","sources":["../src/sessionDisclaimers.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,UAAU,8BAA8B,CAC5C,SAA+B,EAC/B,QAA4B;IAE5B,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,YAAY,GAAG,IAAI,GAAG,CAC1B,QAAQ,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC,CAC5D,CAAC;IACF,OAAO,SAAS;SACb,MAAM,CACL,CAAC,QAAQ,EAAE,EAAE,CACX,CAAC,QAAQ,CAAC,SAAS;QACnB,YAAY,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,GAAG,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC,CAC1D;SACA,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;AACnD,CAAC","sourcesContent":["import type { KycConsentDocument, KycConsentRecord } from './types.js';\n\n/**\n * Maps accepted disclaimer records onto unconsented catalog documents.\n *\n * @param documents - Catalog documents for one consent category.\n * @param accepted - Accepted `{ key, version }` records from the caller.\n * @returns Consent records to POST, omitting already-consented documents.\n */\nexport function consentRecordsFromAcceptedList(\n documents: KycConsentDocument[],\n accepted: KycConsentRecord[],\n): KycConsentRecord[] {\n if (accepted.length === 0) {\n return [];\n }\n const acceptedKeys = new Set(\n accepted.map((record) => `${record.key}:${record.version}`),\n );\n return documents\n .filter(\n (document) =>\n !document.consented &&\n acceptedKeys.has(`${document.key}:${document.version}`),\n )\n .map(({ key, version }) => ({ key, version }));\n}\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -54,7 +54,41 @@ export declare const KYC_STATUSES: {
|
|
|
54
54
|
/**
|
|
55
55
|
* `finalStatus` values that end session-status polling.
|
|
56
56
|
*/
|
|
57
|
+
export declare const FINAL_STATUSES_TO_STOP_POLLING: ReadonlySet<string>;
|
|
58
|
+
/**
|
|
59
|
+
* Terminal `finalStatus` values (`approved`, `rejected`, `retry`).
|
|
60
|
+
* Same set as {@link FINAL_STATUSES_TO_STOP_POLLING}, exported under the
|
|
61
|
+
* name consumers import from the package entry point.
|
|
62
|
+
*/
|
|
57
63
|
export declare const TERMINAL_SESSION_STATUSES: ReadonlySet<string>;
|
|
64
|
+
/**
|
|
65
|
+
* Capability-authorization status values returned on {@link KycSessionStatus}.
|
|
66
|
+
*
|
|
67
|
+
* - `new` — no capability token has been submitted yet.
|
|
68
|
+
* - `pending` — a capability token was submitted and is still being processed.
|
|
69
|
+
* - `stored` — the capability token is stored and valid.
|
|
70
|
+
* - `expired` — the stored capability token has expired.
|
|
71
|
+
* - `wiped` — the capability authorization was wiped and must not be resubmitted
|
|
72
|
+
* by this client flow.
|
|
73
|
+
*/
|
|
74
|
+
export declare const CAPABILITY_AUTHORIZATION_STATUSES: {
|
|
75
|
+
readonly new: 'new';
|
|
76
|
+
readonly pending: 'pending';
|
|
77
|
+
readonly stored: 'stored';
|
|
78
|
+
readonly expired: 'expired';
|
|
79
|
+
readonly wiped: 'wiped';
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Capability-authorization statuses that require submitting a capability
|
|
83
|
+
* authorization token (`new` or `expired`).
|
|
84
|
+
*/
|
|
85
|
+
export declare const CAPABILITY_AUTHORIZATION_STATUSES_TO_REFRESH: ReadonlySet<string>;
|
|
86
|
+
/**
|
|
87
|
+
* `finalStatus` values for which capability authorization must not be
|
|
88
|
+
* refreshed. Once KYC has a finished decision, the capability token is no
|
|
89
|
+
* longer needed.
|
|
90
|
+
*/
|
|
91
|
+
export declare const FINAL_STATUSES_TO_SKIP_AUTH_REFRESH: ReadonlySet<string>;
|
|
58
92
|
/**
|
|
59
93
|
* The status of a UKYC session, returned by the `GET /sessions/{id}/status`
|
|
60
94
|
* endpoint and polled after the SumSub SDK completes to determine the final
|
|
@@ -64,9 +98,9 @@ export type KycSessionStatus = {
|
|
|
64
98
|
/** UKYC session id. */
|
|
65
99
|
id: string;
|
|
66
100
|
/**
|
|
67
|
-
* The overall status of the session.
|
|
68
|
-
* `
|
|
69
|
-
*
|
|
101
|
+
* The overall status of the session. Values in `TERMINAL_SESSION_STATUSES`
|
|
102
|
+
* (`approved`, `rejected`, `retry`) are finished decisions; any other value
|
|
103
|
+
* (e.g. `pending`) means the vendor is still processing.
|
|
70
104
|
*/
|
|
71
105
|
finalStatus: string;
|
|
72
106
|
/** Optional human-readable message describing the status. */
|
|
@@ -82,7 +116,18 @@ export type KycSessionStatus = {
|
|
|
82
116
|
/** The consent status of the session. */
|
|
83
117
|
consentStatus?: string;
|
|
84
118
|
idOSStatus?: string;
|
|
119
|
+
/** The capability-authorization status of the session. */
|
|
120
|
+
capabilityAuthorizationStatus?: string;
|
|
85
121
|
};
|
|
122
|
+
/**
|
|
123
|
+
* Whether the session's capability authorization should be submitted (or
|
|
124
|
+
* refreshed). Skips finished KYC decisions (`approved` / `rejected`) and
|
|
125
|
+
* submits only when the API reports `new` or `expired`.
|
|
126
|
+
*
|
|
127
|
+
* @param sessionStatus - The current UKYC session status.
|
|
128
|
+
* @returns Whether capability authorization should be submitted.
|
|
129
|
+
*/
|
|
130
|
+
export declare function needsCapabilityAuthorizationRefresh(sessionStatus: KycSessionStatus): boolean;
|
|
86
131
|
/**
|
|
87
132
|
* A single disclaimer/term the customer must accept before a vendor session is
|
|
88
133
|
* created (`GET /vendors/{vendor}/disclaimers`).
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;AAE3C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,QAAQ,GAChB,MAAM,GACN,OAAO,GACP,SAAS,GACT,OAAO,GACP,MAAM,GACN,MAAM,GACN,QAAQ,GACR,MAAM,GACN,OAAO,CAAC;AAEZ;;;;;GAKG;AACH,eAAO,MAAM,YAAY;aACvB,QAAQ,EAAE,UAAU;aACpB,QAAQ,EAAE,UAAU;aACpB,KAAK,EAAE,OAAO;aACd,GAAG,EAAE,KAAK;aACV,OAAO,EAAE,SAAS;CACV,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;AAE3C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,QAAQ,GAChB,MAAM,GACN,OAAO,GACP,SAAS,GACT,OAAO,GACP,MAAM,GACN,MAAM,GACN,QAAQ,GACR,MAAM,GACN,OAAO,CAAC;AAEZ;;;;;GAKG;AACH,eAAO,MAAM,YAAY;aACvB,QAAQ,EAAE,UAAU;aACpB,QAAQ,EAAE,UAAU;aACpB,KAAK,E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;IAClC,4BAA4B;IAC5B,IAAI,EAAE,kBAAkB,EAAE,CAAC;IAC3B,6CAA6C;IAC7C,WAAW,EAAE,kBAAkB,EAAE,CAAC;CACnC,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,4BAA4B;IAC5B,IAAI,EAAE,kBAAkB,EAAE,CAAC;IAC3B,6CAA6C;IAC7C,WAAW,EAAE,kBAAkB,EAAE,CAAC;IAClC,qEAAqE;IACrE,iCAAiC,EAAE,OAAO,CAAC;CAC5C,CAAC"}
|
package/dist/types.js
CHANGED
|
@@ -21,9 +21,61 @@ export const KYC_STATUSES = {
|
|
|
21
21
|
/**
|
|
22
22
|
* `finalStatus` values that end session-status polling.
|
|
23
23
|
*/
|
|
24
|
-
export const
|
|
24
|
+
export const FINAL_STATUSES_TO_STOP_POLLING = new Set([
|
|
25
25
|
KYC_STATUSES.approved,
|
|
26
26
|
KYC_STATUSES.rejected,
|
|
27
27
|
KYC_STATUSES.retry,
|
|
28
28
|
]);
|
|
29
|
+
/**
|
|
30
|
+
* Terminal `finalStatus` values (`approved`, `rejected`, `retry`).
|
|
31
|
+
* Same set as {@link FINAL_STATUSES_TO_STOP_POLLING}, exported under the
|
|
32
|
+
* name consumers import from the package entry point.
|
|
33
|
+
*/
|
|
34
|
+
export const TERMINAL_SESSION_STATUSES = FINAL_STATUSES_TO_STOP_POLLING;
|
|
35
|
+
/**
|
|
36
|
+
* Capability-authorization status values returned on {@link KycSessionStatus}.
|
|
37
|
+
*
|
|
38
|
+
* - `new` — no capability token has been submitted yet.
|
|
39
|
+
* - `pending` — a capability token was submitted and is still being processed.
|
|
40
|
+
* - `stored` — the capability token is stored and valid.
|
|
41
|
+
* - `expired` — the stored capability token has expired.
|
|
42
|
+
* - `wiped` — the capability authorization was wiped and must not be resubmitted
|
|
43
|
+
* by this client flow.
|
|
44
|
+
*/
|
|
45
|
+
export const CAPABILITY_AUTHORIZATION_STATUSES = {
|
|
46
|
+
new: 'new',
|
|
47
|
+
pending: 'pending',
|
|
48
|
+
stored: 'stored',
|
|
49
|
+
expired: 'expired',
|
|
50
|
+
wiped: 'wiped',
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Capability-authorization statuses that require submitting a capability
|
|
54
|
+
* authorization token (`new` or `expired`).
|
|
55
|
+
*/
|
|
56
|
+
export const CAPABILITY_AUTHORIZATION_STATUSES_TO_REFRESH = new Set([
|
|
57
|
+
CAPABILITY_AUTHORIZATION_STATUSES.new,
|
|
58
|
+
CAPABILITY_AUTHORIZATION_STATUSES.expired,
|
|
59
|
+
]);
|
|
60
|
+
/**
|
|
61
|
+
* `finalStatus` values for which capability authorization must not be
|
|
62
|
+
* refreshed. Once KYC has a finished decision, the capability token is no
|
|
63
|
+
* longer needed.
|
|
64
|
+
*/
|
|
65
|
+
export const FINAL_STATUSES_TO_SKIP_AUTH_REFRESH = new Set([KYC_STATUSES.approved, KYC_STATUSES.rejected]);
|
|
66
|
+
/**
|
|
67
|
+
* Whether the session's capability authorization should be submitted (or
|
|
68
|
+
* refreshed). Skips finished KYC decisions (`approved` / `rejected`) and
|
|
69
|
+
* submits only when the API reports `new` or `expired`.
|
|
70
|
+
*
|
|
71
|
+
* @param sessionStatus - The current UKYC session status.
|
|
72
|
+
* @returns Whether capability authorization should be submitted.
|
|
73
|
+
*/
|
|
74
|
+
export function needsCapabilityAuthorizationRefresh(sessionStatus) {
|
|
75
|
+
if (FINAL_STATUSES_TO_SKIP_AUTH_REFRESH.has(sessionStatus.finalStatus)) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
return (sessionStatus.capabilityAuthorizationStatus !== undefined &&
|
|
79
|
+
CAPABILITY_AUTHORIZATION_STATUSES_TO_REFRESH.has(sessionStatus.capabilityAuthorizationStatus));
|
|
80
|
+
}
|
|
29
81
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA+CH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;IACpB,KAAK,EAAE,OAAO;IACd,GAAG,EAAE,KAAK;IACV,OAAO,EAAE,SAAS;CACV,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAwB,IAAI,GAAG,CAAC;IACpE,YAAY,CAAC,QAAQ;IACrB,YAAY,CAAC,QAAQ;IACrB,YAAY,CAAC,KAAK;CACnB,CAAC,CAAC","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, card, and money can share one controller.\n */\nexport type KycProduct = 'ramps' | 'card' | 'money';\n\n/**\n * Identity vendors supported behind the KYC surface.\n *\n * - `moonpay` — MoonPay Check/Auth frames + SumSub documents.\n * - `iron` — Iron-only Money/VBA path: empty-shell customer → consents →\n * SumSub, with no MoonPay Check/Auth frames.\n */\nexport type KycVendor = 'moonpay' | 'iron';\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 (MoonPay) or creating the UKYC\n * session and recording session-scoped disclaimers (non-MoonPay vendors).\n * - `check` — running the invisible connection-check frame (MoonPay only).\n * - `auth` — running the visible authentication (OTP) frame (MoonPay only).\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`. Consents-path vendors skip\n * this phase.\n * - `submit` — submitting the KYC-required check / launching SumSub.\n * - `done` — flow complete; see `kycRequiredByProduct` / `sumsub` /\n * `userStatus`. When KYC is required, the document-verification sub-flow is\n * 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 * UKYC status values. `kycStatus` (the relay-side decision) and `finalStatus`\n * (the vendor-side outcome) draw from the same vocabulary, so they are defined\n * once here and composed into the sets/checks below rather than repeated as\n * literals.\n */\nexport const KYC_STATUSES = {\n approved: 'approved',\n rejected: 'rejected',\n retry: 'retry',\n new: 'new',\n pending: 'pending',\n} as const;\n\n/**\n * `finalStatus` values that end session-status polling.\n */\nexport const TERMINAL_SESSION_STATUSES: ReadonlySet<string> = new Set([\n KYC_STATUSES.approved,\n KYC_STATUSES.rejected,\n KYC_STATUSES.retry,\n]);\n\n/**\n * The status of a UKYC session, returned by the `GET /sessions/{id}/status`\n * endpoint and polled after the SumSub SDK completes to determine the final\n * verification decision.\n */\nexport type KycSessionStatus = {\n /** UKYC session id. */\n id: string;\n /**\n * The overall status of the session. Terminal values (e.g. `approved`,\n * `completed`, `rejected`, `failed`, `blocked`) are finished decisions; any\n * other value (e.g. `pending`) means the vendor is still processing.\n */\n finalStatus: string;\n /** Optional human-readable message describing the status. */\n statusMessage?: string;\n /** The vendor-agnostic external user id associated with the session. */\n externalUserId: string;\n /** The KYC decision status. */\n kycStatus: string;\n /** The identity vendor that handled the session. */\n vendor: string;\n /** The vendor-specific status. */\n vendorStatus: string;\n /** The consent status of the session. */\n consentStatus?: string;\n idOSStatus?: string;\n};\n\n/**\n * A single disclaimer/term the customer must accept before a vendor session is\n * created (`GET /vendors/{vendor}/disclaimers`).\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 * A vendor T&C signing returned by `POST /vendors/{vendor}/disclaimers`.\n */\nexport type KycVendorSigning = {\n /** Iron signing id. */\n id: string;\n // Mirrors the vendor API response field, which is snake_case.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n customer_id: string;\n // Mirrors the vendor API response field, which is snake_case.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n content_id?: string;\n};\n\n/**\n * A legal document in the global idOS / KYC-provider catalog\n * (`GET /disclaimers`). Carries no consent state, which only exists within a\n * session.\n */\nexport type KycCatalogDocument = {\n /** Stable identifier of the legal document. */\n key: string;\n /** Version of the document currently in force. */\n version: string;\n /** Human-readable document title. */\n title: string;\n /** URL the document body is hosted at. */\n url: string;\n};\n\n/**\n * A legal document in the session-scoped idOS / KYC-provider catalog\n * (`GET`/`POST /sessions/{sessionId}/disclaimers`).\n */\nexport type KycConsentDocument = KycCatalogDocument & {\n /** Whether the document version has already been consented to. */\n consented: boolean;\n};\n\n/**\n * A consent record posted for a catalog document. `key` and `version` must\n * match the current session catalog.\n */\nexport type KycConsentRecord = {\n key: string;\n version: string;\n};\n\n/**\n * MoonPay vendor T&C1 acceptance persisted under\n * {@link KycVendorDisclaimersAccepted.moonpay}.\n */\nexport type KycMoonpayVendorDisclaimersAccepted = {\n /** ISO-8601 timestamp of terms acceptance for MoonPay. */\n termsAcceptedAt: string;\n};\n\n/**\n * Iron vendor T&C1 acceptance persisted under\n * {@link KycVendorDisclaimersAccepted.iron}.\n */\nexport type KycIronVendorDisclaimersAccepted = {\n /** IDs of Iron vendor disclaimers the customer accepted. */\n disclaimerIds: string[];\n};\n\n/**\n * Persisted KYC-provider disclaimer acceptance (T&C2) with a fixed `sumsub`\n * key.\n */\nexport type KycProviderDisclaimersAccepted = {\n sumsub: KycConsentRecord[] | null;\n};\n\n/**\n * Persisted vendor-disclaimer acceptance with fixed `moonpay` and `iron` keys.\n */\nexport type KycVendorDisclaimersAccepted = {\n moonpay: KycMoonpayVendorDisclaimersAccepted | null;\n iron: KycIronVendorDisclaimersAccepted | null;\n};\n\n/**\n * idOS / KYC-provider disclaimer catalog returned by\n * `GET /disclaimers?country=` (no session — no credential-reuse consent state).\n */\nexport type KycDisclaimersCatalog = {\n /** idOS legal documents. */\n idOS: KycCatalogDocument[];\n /** KYC provider (SumSub) legal documents. */\n kycProvider: KycCatalogDocument[];\n};\n\n/**\n * Session-scoped disclaimer catalog returned by\n * `GET`/`POST /sessions/{sessionId}/disclaimers`. Documents additionally report\n * whether that version was already consented to for the session.\n */\nexport type KycSessionDisclaimers = {\n /** idOS legal documents. */\n idOS: KycConsentDocument[];\n /** KYC provider (SumSub) legal documents. */\n kycProvider: KycConsentDocument[];\n /** Whether the user consented to reuse existing idOS credentials. */\n credentialReusabilityConsentGiven: boolean;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA+CH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;IACpB,KAAK,EAAE,OAAO;IACd,GAAG,EAAE,KAAK;IACV,OAAO,EAAE,SAAS;CACV,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAwB,IAAI,GAAG,CAAC;IACzE,YAAY,CAAC,QAAQ;IACrB,YAAY,CAAC,QAAQ;IACrB,YAAY,CAAC,KAAK;CACnB,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,yBAAyB,GACpC,8BAA8B,CAAC;AAEjC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG;IAC/C,GAAG,EAAE,KAAK;IACV,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;CACN,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,4CAA4C,GACvD,IAAI,GAAG,CAAC;IACN,iCAAiC,CAAC,GAAG;IACrC,iCAAiC,CAAC,OAAO;CAC1C,CAAC,CAAC;AAEL;;;;GAIG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAwB,IAAI,GAAG,CAC7E,CAAC,YAAY,CAAC,QAAQ,EAAE,YAAY,CAAC,QAAQ,CAAC,CAC/C,CAAC;AAiCF;;;;;;;GAOG;AACH,MAAM,UAAU,mCAAmC,CACjD,aAA+B;IAE/B,IAAI,mCAAmC,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,CAAC,EAAE,CAAC;QACvE,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,CACL,aAAa,CAAC,6BAA6B,KAAK,SAAS;QACzD,4CAA4C,CAAC,GAAG,CAC9C,aAAa,CAAC,6BAA6B,CAC5C,CACF,CAAC;AACJ,CAAC","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, card, and money can share one controller.\n */\nexport type KycProduct = 'ramps' | 'card' | 'money';\n\n/**\n * Identity vendors supported behind the KYC surface.\n *\n * - `moonpay` — MoonPay Check/Auth frames + SumSub documents.\n * - `iron` — Iron-only Money/VBA path: empty-shell customer → consents →\n * SumSub, with no MoonPay Check/Auth frames.\n */\nexport type KycVendor = 'moonpay' | 'iron';\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 (MoonPay) or creating the UKYC\n * session and recording session-scoped disclaimers (non-MoonPay vendors).\n * - `check` — running the invisible connection-check frame (MoonPay only).\n * - `auth` — running the visible authentication (OTP) frame (MoonPay only).\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`. Consents-path vendors skip\n * this phase.\n * - `submit` — submitting the KYC-required check / launching SumSub.\n * - `done` — flow complete; see `kycRequiredByProduct` / `sumsub` /\n * `userStatus`. When KYC is required, the document-verification sub-flow is\n * 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 * UKYC status values. `kycStatus` (the relay-side decision) and `finalStatus`\n * (the vendor-side outcome) draw from the same vocabulary, so they are defined\n * once here and composed into the sets/checks below rather than repeated as\n * literals.\n */\nexport const KYC_STATUSES = {\n approved: 'approved',\n rejected: 'rejected',\n retry: 'retry',\n new: 'new',\n pending: 'pending',\n} as const;\n\n/**\n * `finalStatus` values that end session-status polling.\n */\nexport const FINAL_STATUSES_TO_STOP_POLLING: ReadonlySet<string> = new Set([\n KYC_STATUSES.approved,\n KYC_STATUSES.rejected,\n KYC_STATUSES.retry,\n]);\n\n/**\n * Terminal `finalStatus` values (`approved`, `rejected`, `retry`).\n * Same set as {@link FINAL_STATUSES_TO_STOP_POLLING}, exported under the\n * name consumers import from the package entry point.\n */\nexport const TERMINAL_SESSION_STATUSES: ReadonlySet<string> =\n FINAL_STATUSES_TO_STOP_POLLING;\n\n/**\n * Capability-authorization status values returned on {@link KycSessionStatus}.\n *\n * - `new` — no capability token has been submitted yet.\n * - `pending` — a capability token was submitted and is still being processed.\n * - `stored` — the capability token is stored and valid.\n * - `expired` — the stored capability token has expired.\n * - `wiped` — the capability authorization was wiped and must not be resubmitted\n * by this client flow.\n */\nexport const CAPABILITY_AUTHORIZATION_STATUSES = {\n new: 'new',\n pending: 'pending',\n stored: 'stored',\n expired: 'expired',\n wiped: 'wiped',\n} as const;\n\n/**\n * Capability-authorization statuses that require submitting a capability\n * authorization token (`new` or `expired`).\n */\nexport const CAPABILITY_AUTHORIZATION_STATUSES_TO_REFRESH: ReadonlySet<string> =\n new Set([\n CAPABILITY_AUTHORIZATION_STATUSES.new,\n CAPABILITY_AUTHORIZATION_STATUSES.expired,\n ]);\n\n/**\n * `finalStatus` values for which capability authorization must not be\n * refreshed. Once KYC has a finished decision, the capability token is no\n * longer needed.\n */\nexport const FINAL_STATUSES_TO_SKIP_AUTH_REFRESH: ReadonlySet<string> = new Set(\n [KYC_STATUSES.approved, KYC_STATUSES.rejected],\n);\n\n/**\n * The status of a UKYC session, returned by the `GET /sessions/{id}/status`\n * endpoint and polled after the SumSub SDK completes to determine the final\n * verification decision.\n */\nexport type KycSessionStatus = {\n /** UKYC session id. */\n id: string;\n /**\n * The overall status of the session. Values in `TERMINAL_SESSION_STATUSES`\n * (`approved`, `rejected`, `retry`) are finished decisions; any other value\n * (e.g. `pending`) means the vendor is still processing.\n */\n finalStatus: string;\n /** Optional human-readable message describing the status. */\n statusMessage?: string;\n /** The vendor-agnostic external user id associated with the session. */\n externalUserId: string;\n /** The KYC decision status. */\n kycStatus: string;\n /** The identity vendor that handled the session. */\n vendor: string;\n /** The vendor-specific status. */\n vendorStatus: string;\n /** The consent status of the session. */\n consentStatus?: string;\n idOSStatus?: string;\n /** The capability-authorization status of the session. */\n capabilityAuthorizationStatus?: string;\n};\n\n/**\n * Whether the session's capability authorization should be submitted (or\n * refreshed). Skips finished KYC decisions (`approved` / `rejected`) and\n * submits only when the API reports `new` or `expired`.\n *\n * @param sessionStatus - The current UKYC session status.\n * @returns Whether capability authorization should be submitted.\n */\nexport function needsCapabilityAuthorizationRefresh(\n sessionStatus: KycSessionStatus,\n): boolean {\n if (FINAL_STATUSES_TO_SKIP_AUTH_REFRESH.has(sessionStatus.finalStatus)) {\n return false;\n }\n return (\n sessionStatus.capabilityAuthorizationStatus !== undefined &&\n CAPABILITY_AUTHORIZATION_STATUSES_TO_REFRESH.has(\n sessionStatus.capabilityAuthorizationStatus,\n )\n );\n}\n\n/**\n * A single disclaimer/term the customer must accept before a vendor session is\n * created (`GET /vendors/{vendor}/disclaimers`).\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 * A vendor T&C signing returned by `POST /vendors/{vendor}/disclaimers`.\n */\nexport type KycVendorSigning = {\n /** Iron signing id. */\n id: string;\n // Mirrors the vendor API response field, which is snake_case.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n customer_id: string;\n // Mirrors the vendor API response field, which is snake_case.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n content_id?: string;\n};\n\n/**\n * A legal document in the global idOS / KYC-provider catalog\n * (`GET /disclaimers`). Carries no consent state, which only exists within a\n * session.\n */\nexport type KycCatalogDocument = {\n /** Stable identifier of the legal document. */\n key: string;\n /** Version of the document currently in force. */\n version: string;\n /** Human-readable document title. */\n title: string;\n /** URL the document body is hosted at. */\n url: string;\n};\n\n/**\n * A legal document in the session-scoped idOS / KYC-provider catalog\n * (`GET`/`POST /sessions/{sessionId}/disclaimers`).\n */\nexport type KycConsentDocument = KycCatalogDocument & {\n /** Whether the document version has already been consented to. */\n consented: boolean;\n};\n\n/**\n * A consent record posted for a catalog document. `key` and `version` must\n * match the current session catalog.\n */\nexport type KycConsentRecord = {\n key: string;\n version: string;\n};\n\n/**\n * MoonPay vendor T&C1 acceptance persisted under\n * {@link KycVendorDisclaimersAccepted.moonpay}.\n */\nexport type KycMoonpayVendorDisclaimersAccepted = {\n /** ISO-8601 timestamp of terms acceptance for MoonPay. */\n termsAcceptedAt: string;\n};\n\n/**\n * Iron vendor T&C1 acceptance persisted under\n * {@link KycVendorDisclaimersAccepted.iron}.\n */\nexport type KycIronVendorDisclaimersAccepted = {\n /** IDs of Iron vendor disclaimers the customer accepted. */\n disclaimerIds: string[];\n};\n\n/**\n * Persisted KYC-provider disclaimer acceptance (T&C2) with a fixed `sumsub`\n * key.\n */\nexport type KycProviderDisclaimersAccepted = {\n sumsub: KycConsentRecord[] | null;\n};\n\n/**\n * Persisted vendor-disclaimer acceptance with fixed `moonpay` and `iron` keys.\n */\nexport type KycVendorDisclaimersAccepted = {\n moonpay: KycMoonpayVendorDisclaimersAccepted | null;\n iron: KycIronVendorDisclaimersAccepted | null;\n};\n\n/**\n * idOS / KYC-provider disclaimer catalog returned by\n * `GET /disclaimers?country=` (no session — no credential-reuse consent state).\n */\nexport type KycDisclaimersCatalog = {\n /** idOS legal documents. */\n idOS: KycCatalogDocument[];\n /** KYC provider (SumSub) legal documents. */\n kycProvider: KycCatalogDocument[];\n};\n\n/**\n * Session-scoped disclaimer catalog returned by\n * `GET`/`POST /sessions/{sessionId}/disclaimers`. Documents additionally report\n * whether that version was already consented to for the session.\n */\nexport type KycSessionDisclaimers = {\n /** idOS legal documents. */\n idOS: KycConsentDocument[];\n /** KYC provider (SumSub) legal documents. */\n kycProvider: KycConsentDocument[];\n /** Whether the user consented to reuse existing idOS credentials. */\n credentialReusabilityConsentGiven: boolean;\n};\n"]}
|
package/package.json
CHANGED