vesant-sdk 1.7.0-dev.c2e85f3 → 1.7.0-dev.d4f9718

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.
Files changed (63) hide show
  1. package/dist/{client-BolQlL5e.d.mts → client-6sSaxufk.d.mts} +7 -0
  2. package/dist/{client-BolQlL5e.d.ts → client-6sSaxufk.d.ts} +7 -0
  3. package/dist/{client-DF7hlMEz.d.ts → client-B32yBt1b.d.ts} +1 -1
  4. package/dist/{client-DrjgZoH_.d.mts → client-BqPVh5jH.d.mts} +1 -1
  5. package/dist/{client-B0qhE2kr.d.mts → client-CHPEgasE.d.mts} +2 -2
  6. package/dist/{client-DtH2RLuy.d.ts → client-pKE_gii_.d.ts} +2 -2
  7. package/dist/compliance/index.d.mts +3 -3
  8. package/dist/compliance/index.d.ts +3 -3
  9. package/dist/compliance/index.js +19 -3
  10. package/dist/compliance/index.js.map +1 -1
  11. package/dist/compliance/index.mjs +19 -3
  12. package/dist/compliance/index.mjs.map +1 -1
  13. package/dist/decisions/index.d.mts +1 -1
  14. package/dist/decisions/index.d.ts +1 -1
  15. package/dist/decisions/index.js +19 -3
  16. package/dist/decisions/index.js.map +1 -1
  17. package/dist/decisions/index.mjs +19 -3
  18. package/dist/decisions/index.mjs.map +1 -1
  19. package/dist/geolocation/index.d.mts +3 -3
  20. package/dist/geolocation/index.d.ts +3 -3
  21. package/dist/geolocation/index.js +19 -3
  22. package/dist/geolocation/index.js.map +1 -1
  23. package/dist/geolocation/index.mjs +19 -3
  24. package/dist/geolocation/index.mjs.map +1 -1
  25. package/dist/index.d.mts +5 -5
  26. package/dist/index.d.ts +5 -5
  27. package/dist/index.js +46 -13
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.mjs +46 -13
  30. package/dist/index.mjs.map +1 -1
  31. package/dist/kyc/core.d.mts +2 -2
  32. package/dist/kyc/core.d.ts +2 -2
  33. package/dist/kyc/core.js +41 -11
  34. package/dist/kyc/core.js.map +1 -1
  35. package/dist/kyc/core.mjs +41 -11
  36. package/dist/kyc/core.mjs.map +1 -1
  37. package/dist/kyc/index.d.mts +56 -8
  38. package/dist/kyc/index.d.ts +56 -8
  39. package/dist/kyc/index.js +41 -11
  40. package/dist/kyc/index.js.map +1 -1
  41. package/dist/kyc/index.mjs +41 -11
  42. package/dist/kyc/index.mjs.map +1 -1
  43. package/dist/react.d.mts +3 -3
  44. package/dist/react.d.ts +3 -3
  45. package/dist/risk-profile/index.d.mts +1 -1
  46. package/dist/risk-profile/index.d.ts +1 -1
  47. package/dist/risk-profile/index.js +19 -3
  48. package/dist/risk-profile/index.js.map +1 -1
  49. package/dist/risk-profile/index.mjs +19 -3
  50. package/dist/risk-profile/index.mjs.map +1 -1
  51. package/dist/scores/index.d.mts +1 -1
  52. package/dist/scores/index.d.ts +1 -1
  53. package/dist/scores/index.js +19 -3
  54. package/dist/scores/index.js.map +1 -1
  55. package/dist/scores/index.mjs +19 -3
  56. package/dist/scores/index.mjs.map +1 -1
  57. package/dist/tax/index.d.mts +2 -2
  58. package/dist/tax/index.d.ts +2 -2
  59. package/dist/tax/index.js +24 -5
  60. package/dist/tax/index.js.map +1 -1
  61. package/dist/tax/index.mjs +24 -5
  62. package/dist/tax/index.mjs.map +1 -1
  63. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -352,6 +352,19 @@ var BaseClient = class {
352
352
  this.rateLimitTracker = new RateLimitTracker();
353
353
  }
354
354
  }
355
+ /**
356
+ * Resolve the Idempotency-Key for a request. Mutating methods (POST/PUT/PATCH)
357
+ * get the caller-supplied key or a freshly minted UUID; non-mutating methods get
358
+ * none. requestWithRetry resolves this once and injects it so every retry reuses
359
+ * one key (letting the server dedup replays); a direct request() resolves per call.
360
+ */
361
+ resolveIdempotencyKey(method, requestOptions) {
362
+ const isMutating = ["POST", "PUT", "PATCH"].includes((method || "GET").toUpperCase());
363
+ if (!isMutating) {
364
+ return void 0;
365
+ }
366
+ return requestOptions?.idempotencyKey ?? generateUUID();
367
+ }
355
368
  /**
356
369
  * Make an HTTP request with timeout and error handling
357
370
  */
@@ -384,8 +397,9 @@ var BaseClient = class {
384
397
  headers["X-Sandbox"] = "true";
385
398
  }
386
399
  const method = (options.method || "GET").toUpperCase();
387
- if (["POST", "PUT", "PATCH"].includes(method)) {
388
- headers["Idempotency-Key"] = requestOptions?.idempotencyKey || generateUUID();
400
+ const idempotencyKey = this.resolveIdempotencyKey(method, requestOptions);
401
+ if (idempotencyKey) {
402
+ headers["Idempotency-Key"] = idempotencyKey;
389
403
  }
390
404
  const controller = new AbortController();
391
405
  const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
@@ -498,9 +512,11 @@ var BaseClient = class {
498
512
  */
499
513
  async requestWithRetry(endpoint, options = {}, serviceURL, retries = this.config.retries, requestOptions) {
500
514
  let lastError;
515
+ const idempotencyKey = this.resolveIdempotencyKey(options.method || "GET", requestOptions);
516
+ const attemptOptions = idempotencyKey ? { ...requestOptions, idempotencyKey } : requestOptions;
501
517
  for (let attempt = 0; attempt <= retries; attempt++) {
502
518
  try {
503
- return await this.request(endpoint, options, serviceURL, requestOptions);
519
+ return await this.request(endpoint, options, serviceURL, attemptOptions);
504
520
  } catch (error) {
505
521
  lastError = error instanceof Error ? error : new Error("Unknown error");
506
522
  if (requestOptions?.signal?.aborted) {
@@ -2707,7 +2723,13 @@ var KycClient = class extends BaseClient {
2707
2723
  *
2708
2724
  * Generates a link that the user can visit to submit their KYC documents.
2709
2725
  *
2710
- * @param request - Request containing the user ID, optional redirect URL, and optional callback URL (receives POST requests)
2726
+ * Optionally pass the customer's registered identity data as
2727
+ * `customer_data` (same shape as the geolocation `customer_data` block).
2728
+ * It seeds the customer's risk profile so document verification can
2729
+ * cross-check the submitted document against trusted reference data;
2730
+ * fields never overwrite data already on the profile.
2731
+ *
2732
+ * @param request - Request containing the user ID, optional redirect URL, optional callback URL (receives POST requests), and optional customer identity data
2711
2733
  * @returns Response containing the redirect link and KYC ID
2712
2734
  *
2713
2735
  * @example
@@ -2715,19 +2737,27 @@ var KycClient = class extends BaseClient {
2715
2737
  * const result = await client.requestKycSubmitLink({
2716
2738
  * user_id: "user_123",
2717
2739
  * redirect_url: "https://merchant.com/kyc-complete", // optional
2718
- * callback_url: "https://merchant.com/api/kyc-webhook" // optional - receives POST requests on status change
2740
+ * callback_url: "https://merchant.com/api/kyc-webhook", // optional - receives POST requests on status change
2741
+ * customer_data: { // optional - seeds the risk profile for document cross-checks
2742
+ * full_name: "John Doe",
2743
+ * date_of_birth: "1999-06-02", // ISO 8601
2744
+ * email: "john@example.com",
2745
+ * phone: "+94771234567",
2746
+ * address: "12 Main St, Colombo", // used for address verification
2747
+ * country: "LK"
2748
+ * }
2719
2749
  * });
2720
2750
  *
2721
2751
  * console.log(`Redirect user to: ${result.link}`);
2722
2752
  * console.log(`KYC ID: ${result.kyc_id}`);
2723
2753
  * ```
2724
2754
  */
2725
- async requestKycSubmitLink(request) {
2755
+ async requestKycSubmitLink(request, requestOptions) {
2726
2756
  return this.requestWithRetry("/api/v1/kyc/request", {
2727
2757
  method: "POST",
2728
2758
  body: JSON.stringify(request),
2729
2759
  headers: this.getUserHeaders()
2730
- });
2760
+ }, void 0, void 0, requestOptions);
2731
2761
  }
2732
2762
  /**
2733
2763
  * Create a Event-Based Face Verification session.
@@ -2760,12 +2790,12 @@ var KycClient = class extends BaseClient {
2760
2790
  *
2761
2791
  * @param request - Token from `createEventBasedFaceVerificationSession`, plus the base64 selfie.
2762
2792
  */
2763
- async submitEventBasedFaceVerificationSession(request) {
2793
+ async submitEventBasedFaceVerificationSession(request, requestOptions) {
2764
2794
  return this.request("/api/v1/kyc/face/submit", {
2765
2795
  method: "POST",
2766
2796
  body: JSON.stringify(request),
2767
2797
  headers: this.getUserHeaders()
2768
- });
2798
+ }, void 0, requestOptions);
2769
2799
  }
2770
2800
  /**
2771
2801
  * Look up the current state of a Event-Based Face Verification session by its
@@ -2881,12 +2911,12 @@ var KycClient = class extends BaseClient {
2881
2911
  * console.log(`Verification submitted: ${result.reference}`);
2882
2912
  * ```
2883
2913
  */
2884
- async submitVerification(request) {
2914
+ async submitVerification(request, requestOptions) {
2885
2915
  return this.requestWithRetry("/api/v1/kyc/submit", {
2886
2916
  method: "POST",
2887
2917
  body: JSON.stringify(request),
2888
2918
  headers: this.getUserHeaders()
2889
- });
2919
+ }, void 0, void 0, requestOptions);
2890
2920
  }
2891
2921
  /**
2892
2922
  * Get a KYC request by ID
@@ -3326,10 +3356,13 @@ var TaxClient = class extends BaseClient {
3326
3356
  { method: "POST" }
3327
3357
  );
3328
3358
  }
3329
- async checkTINStatus(customerID) {
3359
+ async checkTINStatus(customerID, requestOptions) {
3330
3360
  return this.requestWithRetry(
3331
3361
  `/api/v1/tax/customer-tax-profiles/${customerID}/check-tin`,
3332
- { method: "POST" }
3362
+ { method: "POST" },
3363
+ void 0,
3364
+ void 0,
3365
+ requestOptions
3333
3366
  );
3334
3367
  }
3335
3368
  async reRequestTaxForm(customerID, input) {