vesant-sdk 1.7.0-dev.c2e85f3 → 1.7.0-dev.c349626
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/dist/{client-DF7hlMEz.d.ts → client-0NOPDnT0.d.ts} +16 -26
- package/dist/{client-DrjgZoH_.d.mts → client-CvWNRwwg.d.mts} +16 -26
- package/dist/{client-B0qhE2kr.d.mts → client-Dps40EtF.d.mts} +2 -2
- package/dist/{client-DtH2RLuy.d.ts → client-SMxqod4j.d.ts} +2 -2
- package/dist/{client-BolQlL5e.d.mts → client-q9fN8Hhf.d.mts} +103 -1
- package/dist/{client-BolQlL5e.d.ts → client-q9fN8Hhf.d.ts} +103 -1
- package/dist/compliance/index.d.mts +3 -3
- package/dist/compliance/index.d.ts +3 -3
- package/dist/compliance/index.js +126 -18
- package/dist/compliance/index.js.map +1 -1
- package/dist/compliance/index.mjs +126 -18
- package/dist/compliance/index.mjs.map +1 -1
- package/dist/decisions/index.d.mts +1 -1
- package/dist/decisions/index.d.ts +1 -1
- package/dist/decisions/index.js +61 -6
- package/dist/decisions/index.js.map +1 -1
- package/dist/decisions/index.mjs +61 -6
- package/dist/decisions/index.mjs.map +1 -1
- package/dist/geolocation/index.d.mts +59 -4
- package/dist/geolocation/index.d.ts +59 -4
- package/dist/geolocation/index.js +129 -18
- package/dist/geolocation/index.js.map +1 -1
- package/dist/geolocation/index.mjs +127 -19
- package/dist/geolocation/index.mjs.map +1 -1
- package/dist/index-CPOrMRaH.d.ts +264 -0
- package/dist/index-CimDmgZb.d.mts +264 -0
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +286 -49
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +281 -50
- package/dist/index.mjs.map +1 -1
- package/dist/kyc/core.d.mts +2 -2
- package/dist/kyc/core.d.ts +2 -2
- package/dist/kyc/core.js +83 -14
- package/dist/kyc/core.js.map +1 -1
- package/dist/kyc/core.mjs +83 -14
- package/dist/kyc/core.mjs.map +1 -1
- package/dist/kyc/index.d.mts +56 -8
- package/dist/kyc/index.d.ts +56 -8
- package/dist/kyc/index.js +83 -14
- package/dist/kyc/index.js.map +1 -1
- package/dist/kyc/index.mjs +83 -14
- package/dist/kyc/index.mjs.map +1 -1
- package/dist/react.d.mts +7 -3
- package/dist/react.d.ts +7 -3
- package/dist/react.js +68 -4
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +68 -4
- package/dist/react.mjs.map +1 -1
- package/dist/risk-profile/index.d.mts +1 -1
- package/dist/risk-profile/index.d.ts +1 -1
- package/dist/risk-profile/index.js +61 -6
- package/dist/risk-profile/index.js.map +1 -1
- package/dist/risk-profile/index.mjs +61 -6
- package/dist/risk-profile/index.mjs.map +1 -1
- package/dist/scores/index.d.mts +1 -1
- package/dist/scores/index.d.ts +1 -1
- package/dist/scores/index.js +61 -6
- package/dist/scores/index.js.map +1 -1
- package/dist/scores/index.mjs +61 -6
- package/dist/scores/index.mjs.map +1 -1
- package/dist/tax/index.d.mts +2 -2
- package/dist/tax/index.d.ts +2 -2
- package/dist/tax/index.js +66 -8
- package/dist/tax/index.js.map +1 -1
- package/dist/tax/index.mjs +66 -8
- package/dist/tax/index.mjs.map +1 -1
- package/dist/webhooks/index.d.mts +2 -189
- package/dist/webhooks/index.d.ts +2 -189
- package/dist/webhooks/index.js +85 -21
- package/dist/webhooks/index.js.map +1 -1
- package/dist/webhooks/index.mjs +85 -22
- package/dist/webhooks/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/kyc/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { P as ProfileFilters, b as ProfileListResponse, C as CustomerProfile, a as CreateProfileRequest } from '../types-BOFaMQxI.mjs';
|
|
2
2
|
import { c as Reason, R as RiskLevel, P as PaginationParams } from '../types-CBQRNL-l.mjs';
|
|
3
|
-
import { B as BaseClient } from '../client-
|
|
3
|
+
import { B as BaseClient, R as RequestOptions } from '../client-q9fN8Hhf.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* TypeScript type definitions for Vesant KYC Service API
|
|
@@ -327,6 +327,40 @@ interface RequestKycSubmitLinkRequest {
|
|
|
327
327
|
* Omitted or unknown values default to KYC required with no skip.
|
|
328
328
|
*/
|
|
329
329
|
trigger_event?: string;
|
|
330
|
+
/**
|
|
331
|
+
* Registered customer identity data (optional). Seeds the customer's risk
|
|
332
|
+
* profile so document verification can cross-check the submitted document
|
|
333
|
+
* against trusted reference data (name/DOB match, address verification).
|
|
334
|
+
* Fields never overwrite data already on the profile.
|
|
335
|
+
*/
|
|
336
|
+
customer_data?: KycCustomerData;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Customer identity data supplied by your platform on a submit-link request.
|
|
340
|
+
* Mirrors the geolocation `customer_data` contract. Every field is optional
|
|
341
|
+
* and never overwrites data already on the customer's risk profile.
|
|
342
|
+
*/
|
|
343
|
+
interface KycCustomerData {
|
|
344
|
+
/**
|
|
345
|
+
* Customer's registered full name. Used to match the OCR-extracted name
|
|
346
|
+
* on the submitted document.
|
|
347
|
+
*/
|
|
348
|
+
full_name?: string;
|
|
349
|
+
/**
|
|
350
|
+
* Customer's registered date of birth. ISO 8601 date ("1999-06-02") or an
|
|
351
|
+
* RFC 3339 timestamp ("1986-09-06T18:30:00.000+00:00", as produced by
|
|
352
|
+
* `Date.prototype.toISOString()`) — for timestamps the date portion is
|
|
353
|
+
* used. Used for DOB matching against the submitted document.
|
|
354
|
+
*/
|
|
355
|
+
date_of_birth?: string;
|
|
356
|
+
/** Customer's email address */
|
|
357
|
+
email?: string;
|
|
358
|
+
/** Customer's phone number */
|
|
359
|
+
phone?: string;
|
|
360
|
+
/** Customer's residential address. Used for address verification. */
|
|
361
|
+
address?: string;
|
|
362
|
+
/** Customer's country of residence */
|
|
363
|
+
country?: string;
|
|
330
364
|
}
|
|
331
365
|
/**
|
|
332
366
|
* Trigger events that can request Event-Based Face Verification.
|
|
@@ -686,7 +720,7 @@ interface UseKycPreferencesResult extends BaseHookState {
|
|
|
686
720
|
*/
|
|
687
721
|
declare class KycClient extends BaseClient {
|
|
688
722
|
private userId?;
|
|
689
|
-
private riskProfileBaseURL?;
|
|
723
|
+
private readonly riskProfileBaseURL?;
|
|
690
724
|
constructor(config: KycClientConfig);
|
|
691
725
|
/**
|
|
692
726
|
* Set the user ID for operations requiring user context
|
|
@@ -705,7 +739,13 @@ declare class KycClient extends BaseClient {
|
|
|
705
739
|
*
|
|
706
740
|
* Generates a link that the user can visit to submit their KYC documents.
|
|
707
741
|
*
|
|
708
|
-
*
|
|
742
|
+
* Optionally pass the customer's registered identity data as
|
|
743
|
+
* `customer_data` (same shape as the geolocation `customer_data` block).
|
|
744
|
+
* It seeds the customer's risk profile so document verification can
|
|
745
|
+
* cross-check the submitted document against trusted reference data;
|
|
746
|
+
* fields never overwrite data already on the profile.
|
|
747
|
+
*
|
|
748
|
+
* @param request - Request containing the user ID, optional redirect URL, optional callback URL (receives POST requests), and optional customer identity data
|
|
709
749
|
* @returns Response containing the redirect link and KYC ID
|
|
710
750
|
*
|
|
711
751
|
* @example
|
|
@@ -713,14 +753,22 @@ declare class KycClient extends BaseClient {
|
|
|
713
753
|
* const result = await client.requestKycSubmitLink({
|
|
714
754
|
* user_id: "user_123",
|
|
715
755
|
* redirect_url: "https://merchant.com/kyc-complete", // optional
|
|
716
|
-
* callback_url: "https://merchant.com/api/kyc-webhook" // optional - receives POST requests on status change
|
|
756
|
+
* callback_url: "https://merchant.com/api/kyc-webhook", // optional - receives POST requests on status change
|
|
757
|
+
* customer_data: { // optional - seeds the risk profile for document cross-checks
|
|
758
|
+
* full_name: "John Doe",
|
|
759
|
+
* date_of_birth: "1999-06-02", // ISO 8601
|
|
760
|
+
* email: "john@example.com",
|
|
761
|
+
* phone: "+94771234567",
|
|
762
|
+
* address: "12 Main St, Colombo", // used for address verification
|
|
763
|
+
* country: "LK"
|
|
764
|
+
* }
|
|
717
765
|
* });
|
|
718
766
|
*
|
|
719
767
|
* console.log(`Redirect user to: ${result.link}`);
|
|
720
768
|
* console.log(`KYC ID: ${result.kyc_id}`);
|
|
721
769
|
* ```
|
|
722
770
|
*/
|
|
723
|
-
requestKycSubmitLink(request: RequestKycSubmitLinkRequest): Promise<RequestKycSubmitLinkResponse>;
|
|
771
|
+
requestKycSubmitLink(request: RequestKycSubmitLinkRequest, requestOptions?: RequestOptions): Promise<RequestKycSubmitLinkResponse>;
|
|
724
772
|
/**
|
|
725
773
|
* Create a Event-Based Face Verification session.
|
|
726
774
|
*
|
|
@@ -746,7 +794,7 @@ declare class KycClient extends BaseClient {
|
|
|
746
794
|
*
|
|
747
795
|
* @param request - Token from `createEventBasedFaceVerificationSession`, plus the base64 selfie.
|
|
748
796
|
*/
|
|
749
|
-
submitEventBasedFaceVerificationSession(request: SubmitEventBasedFaceVerificationSessionRequest): Promise<EventBasedFaceVerificationCallback>;
|
|
797
|
+
submitEventBasedFaceVerificationSession(request: SubmitEventBasedFaceVerificationSessionRequest, requestOptions?: RequestOptions): Promise<EventBasedFaceVerificationCallback>;
|
|
750
798
|
/**
|
|
751
799
|
* Look up the current state of a Event-Based Face Verification session by its
|
|
752
800
|
* session token. Useful for desktop pollers waiting on the mobile handoff.
|
|
@@ -835,7 +883,7 @@ declare class KycClient extends BaseClient {
|
|
|
835
883
|
* console.log(`Verification submitted: ${result.reference}`);
|
|
836
884
|
* ```
|
|
837
885
|
*/
|
|
838
|
-
submitVerification(request: DocumentVerificationRequest): Promise<DocumentVerificationResponse>;
|
|
886
|
+
submitVerification(request: DocumentVerificationRequest, requestOptions?: RequestOptions): Promise<DocumentVerificationResponse>;
|
|
839
887
|
/**
|
|
840
888
|
* Get a KYC request by ID
|
|
841
889
|
*
|
|
@@ -1098,4 +1146,4 @@ declare class KycClient extends BaseClient {
|
|
|
1098
1146
|
createCustomerProfile(profile: CreateProfileRequest): Promise<CustomerProfile>;
|
|
1099
1147
|
}
|
|
1100
1148
|
|
|
1101
|
-
export { type CheckKycStatusRequest, type CheckKycStatusResponse, CreateProfileRequest as CreateCustomerProfileRequest, type CreateEventBasedFaceVerificationSessionRequest, type CreateEventBasedFaceVerificationSessionResponse, CustomerProfile, ProfileFilters as CustomerProfileFilters, ProfileListResponse as CustomerProfileListResponse, type DocumentType, type DocumentVerificationRequest, type DocumentVerificationResponse, type EventBasedFaceVerificationCallback, type EventBasedFaceVerificationDeviceType, type EventBasedFaceVerificationEvent, type EventBasedFaceVerificationFrequencyTrigger, type EventBasedFaceVerificationReactionResult, type EventBasedFaceVerificationReactions, type EventBasedFaceVerificationThresholdTrigger, type EventBasedFaceVerificationTriggers, type FaceProof, KYC_DECLINED_DESCRIPTIONS, type KycAlert, type KycAlertFilters, type KycAlertListResponse, type KycAlertStatus, type KycAlertType, KycClient, type KycClientConfig, type KycCustomerProfile, type KycDeclinedCode, type KycHandoffSession, type KycOverview, type KycPagination, type KycPreferences, type KycRequest, type KycRequestFilters, type KycRequestListResponse, type KycStatus, type Name, PaginationParams, type Proof, type ProofDownloadURL, type ProofType, type RequestAdditionalDocumentsRequest, type RequestKycSubmitLinkRequest, type RequestKycSubmitLinkResponse, RiskLevel, type SubmitEventBasedFaceVerificationSessionRequest, type SubmittedDocument, type SupportedDocumentType, type UpdateKycAlertRequest, type UpdateKycPreferencesRequest, type UpdateKycStatusRequest, type UseKycAlertsOptions, type UseKycAlertsResult, type UseKycOverviewOptions, type UseKycOverviewResult, type UseKycPreferencesResult, type UseKycRequestsOptions, type UseKycRequestsResult, type UseKycSubmissionOptions, type UseKycSubmissionResult };
|
|
1149
|
+
export { type CheckKycStatusRequest, type CheckKycStatusResponse, CreateProfileRequest as CreateCustomerProfileRequest, type CreateEventBasedFaceVerificationSessionRequest, type CreateEventBasedFaceVerificationSessionResponse, CustomerProfile, ProfileFilters as CustomerProfileFilters, ProfileListResponse as CustomerProfileListResponse, type DocumentType, type DocumentVerificationRequest, type DocumentVerificationResponse, type EventBasedFaceVerificationCallback, type EventBasedFaceVerificationDeviceType, type EventBasedFaceVerificationEvent, type EventBasedFaceVerificationFrequencyTrigger, type EventBasedFaceVerificationReactionResult, type EventBasedFaceVerificationReactions, type EventBasedFaceVerificationThresholdTrigger, type EventBasedFaceVerificationTriggers, type FaceProof, KYC_DECLINED_DESCRIPTIONS, type KycAlert, type KycAlertFilters, type KycAlertListResponse, type KycAlertStatus, type KycAlertType, KycClient, type KycClientConfig, type KycCustomerData, type KycCustomerProfile, type KycDeclinedCode, type KycHandoffSession, type KycOverview, type KycPagination, type KycPreferences, type KycRequest, type KycRequestFilters, type KycRequestListResponse, type KycStatus, type Name, PaginationParams, type Proof, type ProofDownloadURL, type ProofType, type RequestAdditionalDocumentsRequest, type RequestKycSubmitLinkRequest, type RequestKycSubmitLinkResponse, RiskLevel, type SubmitEventBasedFaceVerificationSessionRequest, type SubmittedDocument, type SupportedDocumentType, type UpdateKycAlertRequest, type UpdateKycPreferencesRequest, type UpdateKycStatusRequest, type UseKycAlertsOptions, type UseKycAlertsResult, type UseKycOverviewOptions, type UseKycOverviewResult, type UseKycPreferencesResult, type UseKycRequestsOptions, type UseKycRequestsResult, type UseKycSubmissionOptions, type UseKycSubmissionResult };
|
package/dist/kyc/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { P as ProfileFilters, b as ProfileListResponse, C as CustomerProfile, a as CreateProfileRequest } from '../types-UGyDl1fd.js';
|
|
2
2
|
import { c as Reason, R as RiskLevel, P as PaginationParams } from '../types-CBQRNL-l.js';
|
|
3
|
-
import { B as BaseClient } from '../client-
|
|
3
|
+
import { B as BaseClient, R as RequestOptions } from '../client-q9fN8Hhf.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* TypeScript type definitions for Vesant KYC Service API
|
|
@@ -327,6 +327,40 @@ interface RequestKycSubmitLinkRequest {
|
|
|
327
327
|
* Omitted or unknown values default to KYC required with no skip.
|
|
328
328
|
*/
|
|
329
329
|
trigger_event?: string;
|
|
330
|
+
/**
|
|
331
|
+
* Registered customer identity data (optional). Seeds the customer's risk
|
|
332
|
+
* profile so document verification can cross-check the submitted document
|
|
333
|
+
* against trusted reference data (name/DOB match, address verification).
|
|
334
|
+
* Fields never overwrite data already on the profile.
|
|
335
|
+
*/
|
|
336
|
+
customer_data?: KycCustomerData;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Customer identity data supplied by your platform on a submit-link request.
|
|
340
|
+
* Mirrors the geolocation `customer_data` contract. Every field is optional
|
|
341
|
+
* and never overwrites data already on the customer's risk profile.
|
|
342
|
+
*/
|
|
343
|
+
interface KycCustomerData {
|
|
344
|
+
/**
|
|
345
|
+
* Customer's registered full name. Used to match the OCR-extracted name
|
|
346
|
+
* on the submitted document.
|
|
347
|
+
*/
|
|
348
|
+
full_name?: string;
|
|
349
|
+
/**
|
|
350
|
+
* Customer's registered date of birth. ISO 8601 date ("1999-06-02") or an
|
|
351
|
+
* RFC 3339 timestamp ("1986-09-06T18:30:00.000+00:00", as produced by
|
|
352
|
+
* `Date.prototype.toISOString()`) — for timestamps the date portion is
|
|
353
|
+
* used. Used for DOB matching against the submitted document.
|
|
354
|
+
*/
|
|
355
|
+
date_of_birth?: string;
|
|
356
|
+
/** Customer's email address */
|
|
357
|
+
email?: string;
|
|
358
|
+
/** Customer's phone number */
|
|
359
|
+
phone?: string;
|
|
360
|
+
/** Customer's residential address. Used for address verification. */
|
|
361
|
+
address?: string;
|
|
362
|
+
/** Customer's country of residence */
|
|
363
|
+
country?: string;
|
|
330
364
|
}
|
|
331
365
|
/**
|
|
332
366
|
* Trigger events that can request Event-Based Face Verification.
|
|
@@ -686,7 +720,7 @@ interface UseKycPreferencesResult extends BaseHookState {
|
|
|
686
720
|
*/
|
|
687
721
|
declare class KycClient extends BaseClient {
|
|
688
722
|
private userId?;
|
|
689
|
-
private riskProfileBaseURL?;
|
|
723
|
+
private readonly riskProfileBaseURL?;
|
|
690
724
|
constructor(config: KycClientConfig);
|
|
691
725
|
/**
|
|
692
726
|
* Set the user ID for operations requiring user context
|
|
@@ -705,7 +739,13 @@ declare class KycClient extends BaseClient {
|
|
|
705
739
|
*
|
|
706
740
|
* Generates a link that the user can visit to submit their KYC documents.
|
|
707
741
|
*
|
|
708
|
-
*
|
|
742
|
+
* Optionally pass the customer's registered identity data as
|
|
743
|
+
* `customer_data` (same shape as the geolocation `customer_data` block).
|
|
744
|
+
* It seeds the customer's risk profile so document verification can
|
|
745
|
+
* cross-check the submitted document against trusted reference data;
|
|
746
|
+
* fields never overwrite data already on the profile.
|
|
747
|
+
*
|
|
748
|
+
* @param request - Request containing the user ID, optional redirect URL, optional callback URL (receives POST requests), and optional customer identity data
|
|
709
749
|
* @returns Response containing the redirect link and KYC ID
|
|
710
750
|
*
|
|
711
751
|
* @example
|
|
@@ -713,14 +753,22 @@ declare class KycClient extends BaseClient {
|
|
|
713
753
|
* const result = await client.requestKycSubmitLink({
|
|
714
754
|
* user_id: "user_123",
|
|
715
755
|
* redirect_url: "https://merchant.com/kyc-complete", // optional
|
|
716
|
-
* callback_url: "https://merchant.com/api/kyc-webhook" // optional - receives POST requests on status change
|
|
756
|
+
* callback_url: "https://merchant.com/api/kyc-webhook", // optional - receives POST requests on status change
|
|
757
|
+
* customer_data: { // optional - seeds the risk profile for document cross-checks
|
|
758
|
+
* full_name: "John Doe",
|
|
759
|
+
* date_of_birth: "1999-06-02", // ISO 8601
|
|
760
|
+
* email: "john@example.com",
|
|
761
|
+
* phone: "+94771234567",
|
|
762
|
+
* address: "12 Main St, Colombo", // used for address verification
|
|
763
|
+
* country: "LK"
|
|
764
|
+
* }
|
|
717
765
|
* });
|
|
718
766
|
*
|
|
719
767
|
* console.log(`Redirect user to: ${result.link}`);
|
|
720
768
|
* console.log(`KYC ID: ${result.kyc_id}`);
|
|
721
769
|
* ```
|
|
722
770
|
*/
|
|
723
|
-
requestKycSubmitLink(request: RequestKycSubmitLinkRequest): Promise<RequestKycSubmitLinkResponse>;
|
|
771
|
+
requestKycSubmitLink(request: RequestKycSubmitLinkRequest, requestOptions?: RequestOptions): Promise<RequestKycSubmitLinkResponse>;
|
|
724
772
|
/**
|
|
725
773
|
* Create a Event-Based Face Verification session.
|
|
726
774
|
*
|
|
@@ -746,7 +794,7 @@ declare class KycClient extends BaseClient {
|
|
|
746
794
|
*
|
|
747
795
|
* @param request - Token from `createEventBasedFaceVerificationSession`, plus the base64 selfie.
|
|
748
796
|
*/
|
|
749
|
-
submitEventBasedFaceVerificationSession(request: SubmitEventBasedFaceVerificationSessionRequest): Promise<EventBasedFaceVerificationCallback>;
|
|
797
|
+
submitEventBasedFaceVerificationSession(request: SubmitEventBasedFaceVerificationSessionRequest, requestOptions?: RequestOptions): Promise<EventBasedFaceVerificationCallback>;
|
|
750
798
|
/**
|
|
751
799
|
* Look up the current state of a Event-Based Face Verification session by its
|
|
752
800
|
* session token. Useful for desktop pollers waiting on the mobile handoff.
|
|
@@ -835,7 +883,7 @@ declare class KycClient extends BaseClient {
|
|
|
835
883
|
* console.log(`Verification submitted: ${result.reference}`);
|
|
836
884
|
* ```
|
|
837
885
|
*/
|
|
838
|
-
submitVerification(request: DocumentVerificationRequest): Promise<DocumentVerificationResponse>;
|
|
886
|
+
submitVerification(request: DocumentVerificationRequest, requestOptions?: RequestOptions): Promise<DocumentVerificationResponse>;
|
|
839
887
|
/**
|
|
840
888
|
* Get a KYC request by ID
|
|
841
889
|
*
|
|
@@ -1098,4 +1146,4 @@ declare class KycClient extends BaseClient {
|
|
|
1098
1146
|
createCustomerProfile(profile: CreateProfileRequest): Promise<CustomerProfile>;
|
|
1099
1147
|
}
|
|
1100
1148
|
|
|
1101
|
-
export { type CheckKycStatusRequest, type CheckKycStatusResponse, CreateProfileRequest as CreateCustomerProfileRequest, type CreateEventBasedFaceVerificationSessionRequest, type CreateEventBasedFaceVerificationSessionResponse, CustomerProfile, ProfileFilters as CustomerProfileFilters, ProfileListResponse as CustomerProfileListResponse, type DocumentType, type DocumentVerificationRequest, type DocumentVerificationResponse, type EventBasedFaceVerificationCallback, type EventBasedFaceVerificationDeviceType, type EventBasedFaceVerificationEvent, type EventBasedFaceVerificationFrequencyTrigger, type EventBasedFaceVerificationReactionResult, type EventBasedFaceVerificationReactions, type EventBasedFaceVerificationThresholdTrigger, type EventBasedFaceVerificationTriggers, type FaceProof, KYC_DECLINED_DESCRIPTIONS, type KycAlert, type KycAlertFilters, type KycAlertListResponse, type KycAlertStatus, type KycAlertType, KycClient, type KycClientConfig, type KycCustomerProfile, type KycDeclinedCode, type KycHandoffSession, type KycOverview, type KycPagination, type KycPreferences, type KycRequest, type KycRequestFilters, type KycRequestListResponse, type KycStatus, type Name, PaginationParams, type Proof, type ProofDownloadURL, type ProofType, type RequestAdditionalDocumentsRequest, type RequestKycSubmitLinkRequest, type RequestKycSubmitLinkResponse, RiskLevel, type SubmitEventBasedFaceVerificationSessionRequest, type SubmittedDocument, type SupportedDocumentType, type UpdateKycAlertRequest, type UpdateKycPreferencesRequest, type UpdateKycStatusRequest, type UseKycAlertsOptions, type UseKycAlertsResult, type UseKycOverviewOptions, type UseKycOverviewResult, type UseKycPreferencesResult, type UseKycRequestsOptions, type UseKycRequestsResult, type UseKycSubmissionOptions, type UseKycSubmissionResult };
|
|
1149
|
+
export { type CheckKycStatusRequest, type CheckKycStatusResponse, CreateProfileRequest as CreateCustomerProfileRequest, type CreateEventBasedFaceVerificationSessionRequest, type CreateEventBasedFaceVerificationSessionResponse, CustomerProfile, ProfileFilters as CustomerProfileFilters, ProfileListResponse as CustomerProfileListResponse, type DocumentType, type DocumentVerificationRequest, type DocumentVerificationResponse, type EventBasedFaceVerificationCallback, type EventBasedFaceVerificationDeviceType, type EventBasedFaceVerificationEvent, type EventBasedFaceVerificationFrequencyTrigger, type EventBasedFaceVerificationReactionResult, type EventBasedFaceVerificationReactions, type EventBasedFaceVerificationThresholdTrigger, type EventBasedFaceVerificationTriggers, type FaceProof, KYC_DECLINED_DESCRIPTIONS, type KycAlert, type KycAlertFilters, type KycAlertListResponse, type KycAlertStatus, type KycAlertType, KycClient, type KycClientConfig, type KycCustomerData, type KycCustomerProfile, type KycDeclinedCode, type KycHandoffSession, type KycOverview, type KycPagination, type KycPreferences, type KycRequest, type KycRequestFilters, type KycRequestListResponse, type KycStatus, type Name, PaginationParams, type Proof, type ProofDownloadURL, type ProofType, type RequestAdditionalDocumentsRequest, type RequestKycSubmitLinkRequest, type RequestKycSubmitLinkResponse, RiskLevel, type SubmitEventBasedFaceVerificationSessionRequest, type SubmittedDocument, type SupportedDocumentType, type UpdateKycAlertRequest, type UpdateKycPreferencesRequest, type UpdateKycStatusRequest, type UseKycAlertsOptions, type UseKycAlertsResult, type UseKycOverviewOptions, type UseKycOverviewResult, type UseKycPreferencesResult, type UseKycRequestsOptions, type UseKycRequestsResult, type UseKycSubmissionOptions, type UseKycSubmissionResult };
|
package/dist/kyc/index.js
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
// src/core/auth.ts
|
|
4
|
+
var StaticApiKeyProvider = class {
|
|
5
|
+
constructor(apiKey) {
|
|
6
|
+
this.apiKey = apiKey;
|
|
7
|
+
}
|
|
8
|
+
async getCredential() {
|
|
9
|
+
return this.apiKey ? { scheme: "Bearer", token: this.apiKey } : null;
|
|
10
|
+
}
|
|
11
|
+
canRefresh() {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
3
16
|
// src/core/errors.ts
|
|
4
17
|
var VesantError = class _VesantError extends Error {
|
|
5
18
|
constructor(message, code, statusCode, details) {
|
|
@@ -264,6 +277,7 @@ var BaseClient = class {
|
|
|
264
277
|
interceptors: this.interceptors,
|
|
265
278
|
logger: this.logger
|
|
266
279
|
};
|
|
280
|
+
this.authProvider = config.authProvider ?? (apiKey ? new StaticApiKeyProvider(apiKey) : void 0);
|
|
267
281
|
if (config.circuitBreaker) {
|
|
268
282
|
this.circuitBreaker = new CircuitBreaker(config.circuitBreaker);
|
|
269
283
|
}
|
|
@@ -271,6 +285,19 @@ var BaseClient = class {
|
|
|
271
285
|
this.rateLimitTracker = new RateLimitTracker();
|
|
272
286
|
}
|
|
273
287
|
}
|
|
288
|
+
/**
|
|
289
|
+
* Resolve the Idempotency-Key for a request. Mutating methods (POST/PUT/PATCH)
|
|
290
|
+
* get the caller-supplied key or a freshly minted UUID; non-mutating methods get
|
|
291
|
+
* none. requestWithRetry resolves this once and injects it so every retry reuses
|
|
292
|
+
* one key (letting the server dedup replays); a direct request() resolves per call.
|
|
293
|
+
*/
|
|
294
|
+
resolveIdempotencyKey(method, requestOptions) {
|
|
295
|
+
const isMutating = ["POST", "PUT", "PATCH"].includes((method || "GET").toUpperCase());
|
|
296
|
+
if (!isMutating) {
|
|
297
|
+
return void 0;
|
|
298
|
+
}
|
|
299
|
+
return requestOptions?.idempotencyKey ?? generateUUID();
|
|
300
|
+
}
|
|
274
301
|
/**
|
|
275
302
|
* Make an HTTP request with timeout and error handling
|
|
276
303
|
*/
|
|
@@ -296,15 +323,20 @@ var BaseClient = class {
|
|
|
296
323
|
...this.config.headers,
|
|
297
324
|
...options.headers || {}
|
|
298
325
|
};
|
|
299
|
-
|
|
300
|
-
|
|
326
|
+
const credential = await this.authProvider?.getCredential({
|
|
327
|
+
tenantId: this.config.tenantId,
|
|
328
|
+
requestId
|
|
329
|
+
});
|
|
330
|
+
if (credential) {
|
|
331
|
+
headers["Authorization"] = `${credential.scheme ?? "Bearer"} ${credential.token}`;
|
|
301
332
|
}
|
|
302
333
|
if (this.config.environment === "sandbox") {
|
|
303
334
|
headers["X-Sandbox"] = "true";
|
|
304
335
|
}
|
|
305
336
|
const method = (options.method || "GET").toUpperCase();
|
|
306
|
-
|
|
307
|
-
|
|
337
|
+
const idempotencyKey = this.resolveIdempotencyKey(method, requestOptions);
|
|
338
|
+
if (idempotencyKey) {
|
|
339
|
+
headers["Idempotency-Key"] = idempotencyKey;
|
|
308
340
|
}
|
|
309
341
|
const controller = new AbortController();
|
|
310
342
|
const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
|
|
@@ -325,10 +357,28 @@ var BaseClient = class {
|
|
|
325
357
|
if (this.config.debug) {
|
|
326
358
|
this.logger.debug(`${finalOptions.method || "GET"} ${endpoint}`);
|
|
327
359
|
}
|
|
328
|
-
|
|
360
|
+
let response = await fetch(url, {
|
|
329
361
|
...finalOptions,
|
|
330
362
|
signal: controller.signal
|
|
331
363
|
});
|
|
364
|
+
if (response.status === 401 && this.authProvider?.canRefresh?.()) {
|
|
365
|
+
const refreshed = await this.authProvider.getCredential({
|
|
366
|
+
tenantId: this.config.tenantId,
|
|
367
|
+
requestId,
|
|
368
|
+
forceRefresh: true
|
|
369
|
+
});
|
|
370
|
+
if (refreshed) {
|
|
371
|
+
this.config.onCredentialRotated?.({ reason: "unauthorized" });
|
|
372
|
+
finalOptions = {
|
|
373
|
+
...finalOptions,
|
|
374
|
+
headers: {
|
|
375
|
+
...finalOptions.headers,
|
|
376
|
+
Authorization: `${refreshed.scheme ?? "Bearer"} ${refreshed.token}`
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
response = await fetch(url, { ...finalOptions, signal: controller.signal });
|
|
380
|
+
}
|
|
381
|
+
}
|
|
332
382
|
clearTimeout(timeoutId);
|
|
333
383
|
if (this.rateLimitTracker) {
|
|
334
384
|
this.rateLimitTracker.updateFromHeaders(response.headers);
|
|
@@ -417,9 +467,11 @@ var BaseClient = class {
|
|
|
417
467
|
*/
|
|
418
468
|
async requestWithRetry(endpoint, options = {}, serviceURL, retries = this.config.retries, requestOptions) {
|
|
419
469
|
let lastError;
|
|
470
|
+
const idempotencyKey = this.resolveIdempotencyKey(options.method || "GET", requestOptions);
|
|
471
|
+
const attemptOptions = idempotencyKey ? { ...requestOptions, idempotencyKey } : requestOptions;
|
|
420
472
|
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
421
473
|
try {
|
|
422
|
-
return await this.request(endpoint, options, serviceURL,
|
|
474
|
+
return await this.request(endpoint, options, serviceURL, attemptOptions);
|
|
423
475
|
} catch (error) {
|
|
424
476
|
lastError = error instanceof Error ? error : new Error("Unknown error");
|
|
425
477
|
if (requestOptions?.signal?.aborted) {
|
|
@@ -516,6 +568,9 @@ var BaseClient = class {
|
|
|
516
568
|
if (config.interceptors) {
|
|
517
569
|
this.interceptors = config.interceptors;
|
|
518
570
|
}
|
|
571
|
+
if (config.authProvider !== void 0 || config.apiKey !== void 0) {
|
|
572
|
+
this.authProvider = this.config.authProvider ?? (this.config.apiKey ? new StaticApiKeyProvider(this.config.apiKey) : void 0);
|
|
573
|
+
}
|
|
519
574
|
}
|
|
520
575
|
/**
|
|
521
576
|
* Get current configuration (readonly)
|
|
@@ -603,7 +658,13 @@ var KycClient = class extends BaseClient {
|
|
|
603
658
|
*
|
|
604
659
|
* Generates a link that the user can visit to submit their KYC documents.
|
|
605
660
|
*
|
|
606
|
-
*
|
|
661
|
+
* Optionally pass the customer's registered identity data as
|
|
662
|
+
* `customer_data` (same shape as the geolocation `customer_data` block).
|
|
663
|
+
* It seeds the customer's risk profile so document verification can
|
|
664
|
+
* cross-check the submitted document against trusted reference data;
|
|
665
|
+
* fields never overwrite data already on the profile.
|
|
666
|
+
*
|
|
667
|
+
* @param request - Request containing the user ID, optional redirect URL, optional callback URL (receives POST requests), and optional customer identity data
|
|
607
668
|
* @returns Response containing the redirect link and KYC ID
|
|
608
669
|
*
|
|
609
670
|
* @example
|
|
@@ -611,19 +672,27 @@ var KycClient = class extends BaseClient {
|
|
|
611
672
|
* const result = await client.requestKycSubmitLink({
|
|
612
673
|
* user_id: "user_123",
|
|
613
674
|
* redirect_url: "https://merchant.com/kyc-complete", // optional
|
|
614
|
-
* callback_url: "https://merchant.com/api/kyc-webhook" // optional - receives POST requests on status change
|
|
675
|
+
* callback_url: "https://merchant.com/api/kyc-webhook", // optional - receives POST requests on status change
|
|
676
|
+
* customer_data: { // optional - seeds the risk profile for document cross-checks
|
|
677
|
+
* full_name: "John Doe",
|
|
678
|
+
* date_of_birth: "1999-06-02", // ISO 8601
|
|
679
|
+
* email: "john@example.com",
|
|
680
|
+
* phone: "+94771234567",
|
|
681
|
+
* address: "12 Main St, Colombo", // used for address verification
|
|
682
|
+
* country: "LK"
|
|
683
|
+
* }
|
|
615
684
|
* });
|
|
616
685
|
*
|
|
617
686
|
* console.log(`Redirect user to: ${result.link}`);
|
|
618
687
|
* console.log(`KYC ID: ${result.kyc_id}`);
|
|
619
688
|
* ```
|
|
620
689
|
*/
|
|
621
|
-
async requestKycSubmitLink(request) {
|
|
690
|
+
async requestKycSubmitLink(request, requestOptions) {
|
|
622
691
|
return this.requestWithRetry("/api/v1/kyc/request", {
|
|
623
692
|
method: "POST",
|
|
624
693
|
body: JSON.stringify(request),
|
|
625
694
|
headers: this.getUserHeaders()
|
|
626
|
-
});
|
|
695
|
+
}, void 0, void 0, requestOptions);
|
|
627
696
|
}
|
|
628
697
|
/**
|
|
629
698
|
* Create a Event-Based Face Verification session.
|
|
@@ -656,12 +725,12 @@ var KycClient = class extends BaseClient {
|
|
|
656
725
|
*
|
|
657
726
|
* @param request - Token from `createEventBasedFaceVerificationSession`, plus the base64 selfie.
|
|
658
727
|
*/
|
|
659
|
-
async submitEventBasedFaceVerificationSession(request) {
|
|
728
|
+
async submitEventBasedFaceVerificationSession(request, requestOptions) {
|
|
660
729
|
return this.request("/api/v1/kyc/face/submit", {
|
|
661
730
|
method: "POST",
|
|
662
731
|
body: JSON.stringify(request),
|
|
663
732
|
headers: this.getUserHeaders()
|
|
664
|
-
});
|
|
733
|
+
}, void 0, requestOptions);
|
|
665
734
|
}
|
|
666
735
|
/**
|
|
667
736
|
* Look up the current state of a Event-Based Face Verification session by its
|
|
@@ -777,12 +846,12 @@ var KycClient = class extends BaseClient {
|
|
|
777
846
|
* console.log(`Verification submitted: ${result.reference}`);
|
|
778
847
|
* ```
|
|
779
848
|
*/
|
|
780
|
-
async submitVerification(request) {
|
|
849
|
+
async submitVerification(request, requestOptions) {
|
|
781
850
|
return this.requestWithRetry("/api/v1/kyc/submit", {
|
|
782
851
|
method: "POST",
|
|
783
852
|
body: JSON.stringify(request),
|
|
784
853
|
headers: this.getUserHeaders()
|
|
785
|
-
});
|
|
854
|
+
}, void 0, void 0, requestOptions);
|
|
786
855
|
}
|
|
787
856
|
/**
|
|
788
857
|
* Get a KYC request by ID
|