vesant-sdk 1.7.0-dev.ab7ff29 → 1.7.0-dev.b2c9ecf
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-BolQlL5e.d.mts → client-6sSaxufk.d.mts} +7 -0
- package/dist/{client-BolQlL5e.d.ts → client-6sSaxufk.d.ts} +7 -0
- package/dist/{client-DoMSYMMR.d.ts → client-B32yBt1b.d.ts} +14 -1
- package/dist/{client-DMIRx7Tu.d.mts → client-BqPVh5jH.d.mts} +14 -1
- package/dist/{client-ZNdnpWe7.d.mts → client-CHPEgasE.d.mts} +2 -2
- package/dist/{client-C3DCmGe9.d.ts → client-pKE_gii_.d.ts} +2 -2
- package/dist/compliance/index.d.mts +3 -3
- package/dist/compliance/index.d.ts +3 -3
- package/dist/compliance/index.js +19 -6
- package/dist/compliance/index.js.map +1 -1
- package/dist/compliance/index.mjs +19 -6
- 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 +19 -3
- package/dist/decisions/index.js.map +1 -1
- package/dist/decisions/index.mjs +19 -3
- package/dist/decisions/index.mjs.map +1 -1
- package/dist/geolocation/index.d.mts +3 -3
- package/dist/geolocation/index.d.ts +3 -3
- package/dist/geolocation/index.js +19 -3
- package/dist/geolocation/index.js.map +1 -1
- package/dist/geolocation/index.mjs +19 -3
- package/dist/geolocation/index.mjs.map +1 -1
- package/dist/index.d.mts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +54 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +54 -21
- 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 +45 -15
- package/dist/kyc/core.js.map +1 -1
- package/dist/kyc/core.mjs +45 -15
- package/dist/kyc/core.mjs.map +1 -1
- package/dist/kyc/index.d.mts +110 -13
- package/dist/kyc/index.d.ts +110 -13
- package/dist/kyc/index.js +45 -15
- package/dist/kyc/index.js.map +1 -1
- package/dist/kyc/index.mjs +45 -15
- package/dist/kyc/index.mjs.map +1 -1
- package/dist/react.d.mts +5 -3
- package/dist/react.d.ts +5 -3
- package/dist/react.js +112 -73
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +112 -73
- 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 +19 -3
- package/dist/risk-profile/index.js.map +1 -1
- package/dist/risk-profile/index.mjs +19 -3
- 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 +19 -3
- package/dist/scores/index.js.map +1 -1
- package/dist/scores/index.mjs +19 -3
- package/dist/scores/index.mjs.map +1 -1
- package/dist/tax/index.d.mts +20 -3
- package/dist/tax/index.d.ts +20 -3
- package/dist/tax/index.js +28 -6
- package/dist/tax/index.js.map +1 -1
- package/dist/tax/index.mjs +28 -6
- package/dist/tax/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/kyc/core.mjs
CHANGED
|
@@ -269,6 +269,19 @@ var BaseClient = class {
|
|
|
269
269
|
this.rateLimitTracker = new RateLimitTracker();
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
|
+
/**
|
|
273
|
+
* Resolve the Idempotency-Key for a request. Mutating methods (POST/PUT/PATCH)
|
|
274
|
+
* get the caller-supplied key or a freshly minted UUID; non-mutating methods get
|
|
275
|
+
* none. requestWithRetry resolves this once and injects it so every retry reuses
|
|
276
|
+
* one key (letting the server dedup replays); a direct request() resolves per call.
|
|
277
|
+
*/
|
|
278
|
+
resolveIdempotencyKey(method, requestOptions) {
|
|
279
|
+
const isMutating = ["POST", "PUT", "PATCH"].includes((method || "GET").toUpperCase());
|
|
280
|
+
if (!isMutating) {
|
|
281
|
+
return void 0;
|
|
282
|
+
}
|
|
283
|
+
return requestOptions?.idempotencyKey ?? generateUUID();
|
|
284
|
+
}
|
|
272
285
|
/**
|
|
273
286
|
* Make an HTTP request with timeout and error handling
|
|
274
287
|
*/
|
|
@@ -301,8 +314,9 @@ var BaseClient = class {
|
|
|
301
314
|
headers["X-Sandbox"] = "true";
|
|
302
315
|
}
|
|
303
316
|
const method = (options.method || "GET").toUpperCase();
|
|
304
|
-
|
|
305
|
-
|
|
317
|
+
const idempotencyKey = this.resolveIdempotencyKey(method, requestOptions);
|
|
318
|
+
if (idempotencyKey) {
|
|
319
|
+
headers["Idempotency-Key"] = idempotencyKey;
|
|
306
320
|
}
|
|
307
321
|
const controller = new AbortController();
|
|
308
322
|
const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
|
|
@@ -415,9 +429,11 @@ var BaseClient = class {
|
|
|
415
429
|
*/
|
|
416
430
|
async requestWithRetry(endpoint, options = {}, serviceURL, retries = this.config.retries, requestOptions) {
|
|
417
431
|
let lastError;
|
|
432
|
+
const idempotencyKey = this.resolveIdempotencyKey(options.method || "GET", requestOptions);
|
|
433
|
+
const attemptOptions = idempotencyKey ? { ...requestOptions, idempotencyKey } : requestOptions;
|
|
418
434
|
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
419
435
|
try {
|
|
420
|
-
return await this.request(endpoint, options, serviceURL,
|
|
436
|
+
return await this.request(endpoint, options, serviceURL, attemptOptions);
|
|
421
437
|
} catch (error) {
|
|
422
438
|
lastError = error instanceof Error ? error : new Error("Unknown error");
|
|
423
439
|
if (requestOptions?.signal?.aborted) {
|
|
@@ -601,7 +617,13 @@ var KycClient = class extends BaseClient {
|
|
|
601
617
|
*
|
|
602
618
|
* Generates a link that the user can visit to submit their KYC documents.
|
|
603
619
|
*
|
|
604
|
-
*
|
|
620
|
+
* Optionally pass the customer's registered identity data as
|
|
621
|
+
* `customer_data` (same shape as the geolocation `customer_data` block).
|
|
622
|
+
* It seeds the customer's risk profile so document verification can
|
|
623
|
+
* cross-check the submitted document against trusted reference data;
|
|
624
|
+
* fields never overwrite data already on the profile.
|
|
625
|
+
*
|
|
626
|
+
* @param request - Request containing the user ID, optional redirect URL, optional callback URL (receives POST requests), and optional customer identity data
|
|
605
627
|
* @returns Response containing the redirect link and KYC ID
|
|
606
628
|
*
|
|
607
629
|
* @example
|
|
@@ -609,19 +631,27 @@ var KycClient = class extends BaseClient {
|
|
|
609
631
|
* const result = await client.requestKycSubmitLink({
|
|
610
632
|
* user_id: "user_123",
|
|
611
633
|
* redirect_url: "https://merchant.com/kyc-complete", // optional
|
|
612
|
-
* callback_url: "https://merchant.com/api/kyc-webhook" // optional - receives POST requests on status change
|
|
634
|
+
* callback_url: "https://merchant.com/api/kyc-webhook", // optional - receives POST requests on status change
|
|
635
|
+
* customer_data: { // optional - seeds the risk profile for document cross-checks
|
|
636
|
+
* full_name: "John Doe",
|
|
637
|
+
* date_of_birth: "1999-06-02", // ISO 8601
|
|
638
|
+
* email: "john@example.com",
|
|
639
|
+
* phone: "+94771234567",
|
|
640
|
+
* address: "12 Main St, Colombo", // used for address verification
|
|
641
|
+
* country: "LK"
|
|
642
|
+
* }
|
|
613
643
|
* });
|
|
614
644
|
*
|
|
615
645
|
* console.log(`Redirect user to: ${result.link}`);
|
|
616
646
|
* console.log(`KYC ID: ${result.kyc_id}`);
|
|
617
647
|
* ```
|
|
618
648
|
*/
|
|
619
|
-
async requestKycSubmitLink(request) {
|
|
649
|
+
async requestKycSubmitLink(request, requestOptions) {
|
|
620
650
|
return this.requestWithRetry("/api/v1/kyc/request", {
|
|
621
651
|
method: "POST",
|
|
622
652
|
body: JSON.stringify(request),
|
|
623
653
|
headers: this.getUserHeaders()
|
|
624
|
-
});
|
|
654
|
+
}, void 0, void 0, requestOptions);
|
|
625
655
|
}
|
|
626
656
|
/**
|
|
627
657
|
* Create a Event-Based Face Verification session.
|
|
@@ -654,12 +684,12 @@ var KycClient = class extends BaseClient {
|
|
|
654
684
|
*
|
|
655
685
|
* @param request - Token from `createEventBasedFaceVerificationSession`, plus the base64 selfie.
|
|
656
686
|
*/
|
|
657
|
-
async submitEventBasedFaceVerificationSession(request) {
|
|
687
|
+
async submitEventBasedFaceVerificationSession(request, requestOptions) {
|
|
658
688
|
return this.request("/api/v1/kyc/face/submit", {
|
|
659
689
|
method: "POST",
|
|
660
690
|
body: JSON.stringify(request),
|
|
661
691
|
headers: this.getUserHeaders()
|
|
662
|
-
});
|
|
692
|
+
}, void 0, requestOptions);
|
|
663
693
|
}
|
|
664
694
|
/**
|
|
665
695
|
* Look up the current state of a Event-Based Face Verification session by its
|
|
@@ -758,7 +788,7 @@ var KycClient = class extends BaseClient {
|
|
|
758
788
|
* @example
|
|
759
789
|
* ```typescript
|
|
760
790
|
* const result = await client.submitVerification({
|
|
761
|
-
* reference: "
|
|
791
|
+
* reference: "4d2aff34-ab86-422d-992e-50b1234a5b67",
|
|
762
792
|
* email: "customer@example.com",
|
|
763
793
|
* country: "US",
|
|
764
794
|
* document: {
|
|
@@ -775,12 +805,12 @@ var KycClient = class extends BaseClient {
|
|
|
775
805
|
* console.log(`Verification submitted: ${result.reference}`);
|
|
776
806
|
* ```
|
|
777
807
|
*/
|
|
778
|
-
async submitVerification(request) {
|
|
808
|
+
async submitVerification(request, requestOptions) {
|
|
779
809
|
return this.requestWithRetry("/api/v1/kyc/submit", {
|
|
780
810
|
method: "POST",
|
|
781
811
|
body: JSON.stringify(request),
|
|
782
812
|
headers: this.getUserHeaders()
|
|
783
|
-
});
|
|
813
|
+
}, void 0, void 0, requestOptions);
|
|
784
814
|
}
|
|
785
815
|
/**
|
|
786
816
|
* Get a KYC request by ID
|
|
@@ -790,7 +820,7 @@ var KycClient = class extends BaseClient {
|
|
|
790
820
|
*
|
|
791
821
|
* @example
|
|
792
822
|
* ```typescript
|
|
793
|
-
* const kyc = await client.getKycRequest("
|
|
823
|
+
* const kyc = await client.getKycRequest("550e8400-e29b-41d4-a716-446655440000");
|
|
794
824
|
* console.log(`Status: ${kyc.status}, ID Verified: ${kyc.id_verified}`);
|
|
795
825
|
* ```
|
|
796
826
|
*/
|
|
@@ -865,7 +895,7 @@ var KycClient = class extends BaseClient {
|
|
|
865
895
|
* @example
|
|
866
896
|
* ```typescript
|
|
867
897
|
* await client.requestAdditionalDocuments({
|
|
868
|
-
* id: "
|
|
898
|
+
* id: "550e8400-e29b-41d4-a716-446655440000",
|
|
869
899
|
* document_types: ["address", "document_two"],
|
|
870
900
|
* message: "Please provide proof of address and secondary ID"
|
|
871
901
|
* });
|
|
@@ -886,7 +916,7 @@ var KycClient = class extends BaseClient {
|
|
|
886
916
|
*
|
|
887
917
|
* @example
|
|
888
918
|
* ```typescript
|
|
889
|
-
* const proofs = await client.getProofDownloadURLs("
|
|
919
|
+
* const proofs = await client.getProofDownloadURLs("550e8400-e29b-41d4-a716-446655440000");
|
|
890
920
|
* proofs.forEach(proof => {
|
|
891
921
|
* console.log(`${proof.type}: ${proof.url} (expires: ${proof.expires_at})`);
|
|
892
922
|
* });
|