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.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
- if (["POST", "PUT", "PATCH"].includes(method)) {
390
- headers["Idempotency-Key"] = requestOptions?.idempotencyKey || generateUUID();
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, requestOptions);
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) {
@@ -2709,7 +2725,13 @@ var KycClient = class extends BaseClient {
2709
2725
  *
2710
2726
  * Generates a link that the user can visit to submit their KYC documents.
2711
2727
  *
2712
- * @param request - Request containing the user ID, optional redirect URL, and optional callback URL (receives POST requests)
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
2713
2735
  * @returns Response containing the redirect link and KYC ID
2714
2736
  *
2715
2737
  * @example
@@ -2717,19 +2739,27 @@ var KycClient = class extends BaseClient {
2717
2739
  * const result = await client.requestKycSubmitLink({
2718
2740
  * user_id: "user_123",
2719
2741
  * redirect_url: "https://merchant.com/kyc-complete", // optional
2720
- * 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
+ * }
2721
2751
  * });
2722
2752
  *
2723
2753
  * console.log(`Redirect user to: ${result.link}`);
2724
2754
  * console.log(`KYC ID: ${result.kyc_id}`);
2725
2755
  * ```
2726
2756
  */
2727
- async requestKycSubmitLink(request) {
2757
+ async requestKycSubmitLink(request, requestOptions) {
2728
2758
  return this.requestWithRetry("/api/v1/kyc/request", {
2729
2759
  method: "POST",
2730
2760
  body: JSON.stringify(request),
2731
2761
  headers: this.getUserHeaders()
2732
- });
2762
+ }, void 0, void 0, requestOptions);
2733
2763
  }
2734
2764
  /**
2735
2765
  * Create a Event-Based Face Verification session.
@@ -2762,12 +2792,12 @@ var KycClient = class extends BaseClient {
2762
2792
  *
2763
2793
  * @param request - Token from `createEventBasedFaceVerificationSession`, plus the base64 selfie.
2764
2794
  */
2765
- async submitEventBasedFaceVerificationSession(request) {
2795
+ async submitEventBasedFaceVerificationSession(request, requestOptions) {
2766
2796
  return this.request("/api/v1/kyc/face/submit", {
2767
2797
  method: "POST",
2768
2798
  body: JSON.stringify(request),
2769
2799
  headers: this.getUserHeaders()
2770
- });
2800
+ }, void 0, requestOptions);
2771
2801
  }
2772
2802
  /**
2773
2803
  * Look up the current state of a Event-Based Face Verification session by its
@@ -2883,12 +2913,12 @@ var KycClient = class extends BaseClient {
2883
2913
  * console.log(`Verification submitted: ${result.reference}`);
2884
2914
  * ```
2885
2915
  */
2886
- async submitVerification(request) {
2916
+ async submitVerification(request, requestOptions) {
2887
2917
  return this.requestWithRetry("/api/v1/kyc/submit", {
2888
2918
  method: "POST",
2889
2919
  body: JSON.stringify(request),
2890
2920
  headers: this.getUserHeaders()
2891
- });
2921
+ }, void 0, void 0, requestOptions);
2892
2922
  }
2893
2923
  /**
2894
2924
  * Get a KYC request by ID
@@ -3328,10 +3358,13 @@ var TaxClient = class extends BaseClient {
3328
3358
  { method: "POST" }
3329
3359
  );
3330
3360
  }
3331
- async checkTINStatus(customerID) {
3361
+ async checkTINStatus(customerID, requestOptions) {
3332
3362
  return this.requestWithRetry(
3333
3363
  `/api/v1/tax/customer-tax-profiles/${customerID}/check-tin`,
3334
- { method: "POST" }
3364
+ { method: "POST" },
3365
+ void 0,
3366
+ void 0,
3367
+ requestOptions
3335
3368
  );
3336
3369
  }
3337
3370
  async reRequestTaxForm(customerID, input) {