vesant-sdk 1.7.0-dev.ac305d8 → 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 +51 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -30
- 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 +3 -26
- package/dist/tax/index.d.ts +3 -26
- package/dist/tax/index.js +25 -15
- package/dist/tax/index.js.map +1 -1
- package/dist/tax/index.mjs +25 -15
- package/dist/tax/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -354,6 +354,19 @@ var BaseClient = class {
|
|
|
354
354
|
this.rateLimitTracker = new RateLimitTracker();
|
|
355
355
|
}
|
|
356
356
|
}
|
|
357
|
+
/**
|
|
358
|
+
* Resolve the Idempotency-Key for a request. Mutating methods (POST/PUT/PATCH)
|
|
359
|
+
* get the caller-supplied key or a freshly minted UUID; non-mutating methods get
|
|
360
|
+
* none. requestWithRetry resolves this once and injects it so every retry reuses
|
|
361
|
+
* one key (letting the server dedup replays); a direct request() resolves per call.
|
|
362
|
+
*/
|
|
363
|
+
resolveIdempotencyKey(method, requestOptions) {
|
|
364
|
+
const isMutating = ["POST", "PUT", "PATCH"].includes((method || "GET").toUpperCase());
|
|
365
|
+
if (!isMutating) {
|
|
366
|
+
return void 0;
|
|
367
|
+
}
|
|
368
|
+
return requestOptions?.idempotencyKey ?? generateUUID();
|
|
369
|
+
}
|
|
357
370
|
/**
|
|
358
371
|
* Make an HTTP request with timeout and error handling
|
|
359
372
|
*/
|
|
@@ -386,8 +399,9 @@ var BaseClient = class {
|
|
|
386
399
|
headers["X-Sandbox"] = "true";
|
|
387
400
|
}
|
|
388
401
|
const method = (options.method || "GET").toUpperCase();
|
|
389
|
-
|
|
390
|
-
|
|
402
|
+
const idempotencyKey = this.resolveIdempotencyKey(method, requestOptions);
|
|
403
|
+
if (idempotencyKey) {
|
|
404
|
+
headers["Idempotency-Key"] = idempotencyKey;
|
|
391
405
|
}
|
|
392
406
|
const controller = new AbortController();
|
|
393
407
|
const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
|
|
@@ -500,9 +514,11 @@ var BaseClient = class {
|
|
|
500
514
|
*/
|
|
501
515
|
async requestWithRetry(endpoint, options = {}, serviceURL, retries = this.config.retries, requestOptions) {
|
|
502
516
|
let lastError;
|
|
517
|
+
const idempotencyKey = this.resolveIdempotencyKey(options.method || "GET", requestOptions);
|
|
518
|
+
const attemptOptions = idempotencyKey ? { ...requestOptions, idempotencyKey } : requestOptions;
|
|
503
519
|
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
504
520
|
try {
|
|
505
|
-
return await this.request(endpoint, options, serviceURL,
|
|
521
|
+
return await this.request(endpoint, options, serviceURL, attemptOptions);
|
|
506
522
|
} catch (error) {
|
|
507
523
|
lastError = error instanceof Error ? error : new Error("Unknown error");
|
|
508
524
|
if (requestOptions?.signal?.aborted) {
|
|
@@ -1800,9 +1816,6 @@ var ComplianceClient = class {
|
|
|
1800
1816
|
if (cipherTextResult.risk?.is_blocked) {
|
|
1801
1817
|
blockReasons.push(...cipherTextResult.risk.block_reasons_structured ?? []);
|
|
1802
1818
|
}
|
|
1803
|
-
if (cipherTextResult.risk?.location_mismatch) {
|
|
1804
|
-
blockReasons.push(sdkReasons.gpsIPMismatch());
|
|
1805
|
-
}
|
|
1806
1819
|
}
|
|
1807
1820
|
if (geoVerification.gps_required && !cipherTextResult) {
|
|
1808
1821
|
blockReasons.push(sdkReasons.gpsRequired());
|
|
@@ -2712,7 +2725,13 @@ var KycClient = class extends BaseClient {
|
|
|
2712
2725
|
*
|
|
2713
2726
|
* Generates a link that the user can visit to submit their KYC documents.
|
|
2714
2727
|
*
|
|
2715
|
-
*
|
|
2728
|
+
* Optionally pass the customer's registered identity data as
|
|
2729
|
+
* `customer_data` (same shape as the geolocation `customer_data` block).
|
|
2730
|
+
* It seeds the customer's risk profile so document verification can
|
|
2731
|
+
* cross-check the submitted document against trusted reference data;
|
|
2732
|
+
* fields never overwrite data already on the profile.
|
|
2733
|
+
*
|
|
2734
|
+
* @param request - Request containing the user ID, optional redirect URL, optional callback URL (receives POST requests), and optional customer identity data
|
|
2716
2735
|
* @returns Response containing the redirect link and KYC ID
|
|
2717
2736
|
*
|
|
2718
2737
|
* @example
|
|
@@ -2720,19 +2739,27 @@ var KycClient = class extends BaseClient {
|
|
|
2720
2739
|
* const result = await client.requestKycSubmitLink({
|
|
2721
2740
|
* user_id: "user_123",
|
|
2722
2741
|
* redirect_url: "https://merchant.com/kyc-complete", // optional
|
|
2723
|
-
* callback_url: "https://merchant.com/api/kyc-webhook" // optional - receives POST requests on status change
|
|
2742
|
+
* callback_url: "https://merchant.com/api/kyc-webhook", // optional - receives POST requests on status change
|
|
2743
|
+
* customer_data: { // optional - seeds the risk profile for document cross-checks
|
|
2744
|
+
* full_name: "John Doe",
|
|
2745
|
+
* date_of_birth: "1999-06-02", // ISO 8601
|
|
2746
|
+
* email: "john@example.com",
|
|
2747
|
+
* phone: "+94771234567",
|
|
2748
|
+
* address: "12 Main St, Colombo", // used for address verification
|
|
2749
|
+
* country: "LK"
|
|
2750
|
+
* }
|
|
2724
2751
|
* });
|
|
2725
2752
|
*
|
|
2726
2753
|
* console.log(`Redirect user to: ${result.link}`);
|
|
2727
2754
|
* console.log(`KYC ID: ${result.kyc_id}`);
|
|
2728
2755
|
* ```
|
|
2729
2756
|
*/
|
|
2730
|
-
async requestKycSubmitLink(request) {
|
|
2757
|
+
async requestKycSubmitLink(request, requestOptions) {
|
|
2731
2758
|
return this.requestWithRetry("/api/v1/kyc/request", {
|
|
2732
2759
|
method: "POST",
|
|
2733
2760
|
body: JSON.stringify(request),
|
|
2734
2761
|
headers: this.getUserHeaders()
|
|
2735
|
-
});
|
|
2762
|
+
}, void 0, void 0, requestOptions);
|
|
2736
2763
|
}
|
|
2737
2764
|
/**
|
|
2738
2765
|
* Create a Event-Based Face Verification session.
|
|
@@ -2765,12 +2792,12 @@ var KycClient = class extends BaseClient {
|
|
|
2765
2792
|
*
|
|
2766
2793
|
* @param request - Token from `createEventBasedFaceVerificationSession`, plus the base64 selfie.
|
|
2767
2794
|
*/
|
|
2768
|
-
async submitEventBasedFaceVerificationSession(request) {
|
|
2795
|
+
async submitEventBasedFaceVerificationSession(request, requestOptions) {
|
|
2769
2796
|
return this.request("/api/v1/kyc/face/submit", {
|
|
2770
2797
|
method: "POST",
|
|
2771
2798
|
body: JSON.stringify(request),
|
|
2772
2799
|
headers: this.getUserHeaders()
|
|
2773
|
-
});
|
|
2800
|
+
}, void 0, requestOptions);
|
|
2774
2801
|
}
|
|
2775
2802
|
/**
|
|
2776
2803
|
* Look up the current state of a Event-Based Face Verification session by its
|
|
@@ -2869,7 +2896,7 @@ var KycClient = class extends BaseClient {
|
|
|
2869
2896
|
* @example
|
|
2870
2897
|
* ```typescript
|
|
2871
2898
|
* const result = await client.submitVerification({
|
|
2872
|
-
* reference: "
|
|
2899
|
+
* reference: "4d2aff34-ab86-422d-992e-50b1234a5b67",
|
|
2873
2900
|
* email: "customer@example.com",
|
|
2874
2901
|
* country: "US",
|
|
2875
2902
|
* document: {
|
|
@@ -2886,12 +2913,12 @@ var KycClient = class extends BaseClient {
|
|
|
2886
2913
|
* console.log(`Verification submitted: ${result.reference}`);
|
|
2887
2914
|
* ```
|
|
2888
2915
|
*/
|
|
2889
|
-
async submitVerification(request) {
|
|
2916
|
+
async submitVerification(request, requestOptions) {
|
|
2890
2917
|
return this.requestWithRetry("/api/v1/kyc/submit", {
|
|
2891
2918
|
method: "POST",
|
|
2892
2919
|
body: JSON.stringify(request),
|
|
2893
2920
|
headers: this.getUserHeaders()
|
|
2894
|
-
});
|
|
2921
|
+
}, void 0, void 0, requestOptions);
|
|
2895
2922
|
}
|
|
2896
2923
|
/**
|
|
2897
2924
|
* Get a KYC request by ID
|
|
@@ -2901,7 +2928,7 @@ var KycClient = class extends BaseClient {
|
|
|
2901
2928
|
*
|
|
2902
2929
|
* @example
|
|
2903
2930
|
* ```typescript
|
|
2904
|
-
* const kyc = await client.getKycRequest("
|
|
2931
|
+
* const kyc = await client.getKycRequest("550e8400-e29b-41d4-a716-446655440000");
|
|
2905
2932
|
* console.log(`Status: ${kyc.status}, ID Verified: ${kyc.id_verified}`);
|
|
2906
2933
|
* ```
|
|
2907
2934
|
*/
|
|
@@ -2976,7 +3003,7 @@ var KycClient = class extends BaseClient {
|
|
|
2976
3003
|
* @example
|
|
2977
3004
|
* ```typescript
|
|
2978
3005
|
* await client.requestAdditionalDocuments({
|
|
2979
|
-
* id: "
|
|
3006
|
+
* id: "550e8400-e29b-41d4-a716-446655440000",
|
|
2980
3007
|
* document_types: ["address", "document_two"],
|
|
2981
3008
|
* message: "Please provide proof of address and secondary ID"
|
|
2982
3009
|
* });
|
|
@@ -2997,7 +3024,7 @@ var KycClient = class extends BaseClient {
|
|
|
2997
3024
|
*
|
|
2998
3025
|
* @example
|
|
2999
3026
|
* ```typescript
|
|
3000
|
-
* const proofs = await client.getProofDownloadURLs("
|
|
3027
|
+
* const proofs = await client.getProofDownloadURLs("550e8400-e29b-41d4-a716-446655440000");
|
|
3001
3028
|
* proofs.forEach(proof => {
|
|
3002
3029
|
* console.log(`${proof.type}: ${proof.url} (expires: ${proof.expires_at})`);
|
|
3003
3030
|
* });
|
|
@@ -3331,19 +3358,13 @@ var TaxClient = class extends BaseClient {
|
|
|
3331
3358
|
{ method: "POST" }
|
|
3332
3359
|
);
|
|
3333
3360
|
}
|
|
3334
|
-
async
|
|
3335
|
-
return this.request(
|
|
3336
|
-
"/api/v1/tax/customer-tax-profiles/request-form-with-profile",
|
|
3337
|
-
{
|
|
3338
|
-
method: "POST",
|
|
3339
|
-
body: JSON.stringify(input)
|
|
3340
|
-
}
|
|
3341
|
-
);
|
|
3342
|
-
}
|
|
3343
|
-
async checkTINStatus(customerID) {
|
|
3361
|
+
async checkTINStatus(customerID, requestOptions) {
|
|
3344
3362
|
return this.requestWithRetry(
|
|
3345
3363
|
`/api/v1/tax/customer-tax-profiles/${customerID}/check-tin`,
|
|
3346
|
-
{ method: "POST" }
|
|
3364
|
+
{ method: "POST" },
|
|
3365
|
+
void 0,
|
|
3366
|
+
void 0,
|
|
3367
|
+
requestOptions
|
|
3347
3368
|
);
|
|
3348
3369
|
}
|
|
3349
3370
|
async reRequestTaxForm(customerID, input) {
|
|
@@ -3366,7 +3387,7 @@ var TaxClient = class extends BaseClient {
|
|
|
3366
3387
|
}
|
|
3367
3388
|
async getCustomerDocuments(customerID) {
|
|
3368
3389
|
return this.request(
|
|
3369
|
-
`/api/v1/
|
|
3390
|
+
`/api/v1/tm/customer-tax-profiles/${customerID}/documents`
|
|
3370
3391
|
);
|
|
3371
3392
|
}
|
|
3372
3393
|
async downloadTaxForm(customerID, requestOptions) {
|