vesant-sdk 1.7.2 → 1.8.0-dev.00f6233

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 (72) hide show
  1. package/README.md +3 -3
  2. package/dist/{client-B3DCAHlg.d.ts → client-BPALLldd.d.ts} +2 -2
  3. package/dist/{client-fy3trF2K.d.ts → client-BaUekQT8.d.ts} +32 -10
  4. package/dist/{client-BwXMQA2a.d.mts → client-XDEhh9VN.d.mts} +32 -10
  5. package/dist/{client-D23KhWeh.d.mts → client-_OhkfnyJ.d.mts} +2 -2
  6. package/dist/compliance/index.d.mts +3 -3
  7. package/dist/compliance/index.d.ts +3 -3
  8. package/dist/compliance/index.js +66 -11
  9. package/dist/compliance/index.js.map +1 -1
  10. package/dist/compliance/index.mjs +66 -11
  11. package/dist/compliance/index.mjs.map +1 -1
  12. package/dist/decisions/index.js +8 -7
  13. package/dist/decisions/index.js.map +1 -1
  14. package/dist/decisions/index.mjs +8 -7
  15. package/dist/decisions/index.mjs.map +1 -1
  16. package/dist/geolocation/index.d.mts +2 -2
  17. package/dist/geolocation/index.d.ts +2 -2
  18. package/dist/geolocation/index.js +47 -8
  19. package/dist/geolocation/index.js.map +1 -1
  20. package/dist/geolocation/index.mjs +47 -8
  21. package/dist/geolocation/index.mjs.map +1 -1
  22. package/dist/{index-DSDgS09k.d.ts → index-BosFSGan.d.ts} +57 -2
  23. package/dist/{index-C3zUKydT.d.mts → index-C49a7fg2.d.mts} +57 -2
  24. package/dist/index.d.mts +6 -6
  25. package/dist/index.d.ts +6 -6
  26. package/dist/index.js +104 -169
  27. package/dist/index.js.map +1 -1
  28. package/dist/index.mjs +101 -170
  29. package/dist/index.mjs.map +1 -1
  30. package/dist/kyc/core.d.mts +2 -2
  31. package/dist/kyc/core.d.ts +2 -2
  32. package/dist/kyc/core.js +39 -165
  33. package/dist/kyc/core.js.map +1 -1
  34. package/dist/kyc/core.mjs +38 -166
  35. package/dist/kyc/core.mjs.map +1 -1
  36. package/dist/kyc/index.d.mts +219 -218
  37. package/dist/kyc/index.d.ts +219 -218
  38. package/dist/kyc/index.js +39 -165
  39. package/dist/kyc/index.js.map +1 -1
  40. package/dist/kyc/index.mjs +38 -166
  41. package/dist/kyc/index.mjs.map +1 -1
  42. package/dist/react.d.mts +24 -115
  43. package/dist/react.d.ts +24 -115
  44. package/dist/react.js +23 -196
  45. package/dist/react.js.map +1 -1
  46. package/dist/react.mjs +24 -194
  47. package/dist/react.mjs.map +1 -1
  48. package/dist/risk-profile/index.d.mts +16 -6
  49. package/dist/risk-profile/index.d.ts +16 -6
  50. package/dist/risk-profile/index.js +26 -9
  51. package/dist/risk-profile/index.js.map +1 -1
  52. package/dist/risk-profile/index.mjs +26 -10
  53. package/dist/risk-profile/index.mjs.map +1 -1
  54. package/dist/scores/index.js +8 -7
  55. package/dist/scores/index.js.map +1 -1
  56. package/dist/scores/index.mjs +8 -7
  57. package/dist/scores/index.mjs.map +1 -1
  58. package/dist/tax/index.d.mts +1 -1
  59. package/dist/tax/index.d.ts +1 -1
  60. package/dist/tax/index.js +8 -7
  61. package/dist/tax/index.js.map +1 -1
  62. package/dist/tax/index.mjs +8 -7
  63. package/dist/tax/index.mjs.map +1 -1
  64. package/dist/{types-BOFaMQxI.d.mts → types-DbvVph_0.d.mts} +45 -2
  65. package/dist/{types-UGyDl1fd.d.ts → types-qXamJr2q.d.ts} +45 -2
  66. package/dist/webhooks/index.d.mts +1 -1
  67. package/dist/webhooks/index.d.ts +1 -1
  68. package/dist/webhooks/index.js +6 -0
  69. package/dist/webhooks/index.js.map +1 -1
  70. package/dist/webhooks/index.mjs +6 -1
  71. package/dist/webhooks/index.mjs.map +1 -1
  72. package/package.json +1 -1
@@ -310,7 +310,7 @@ function createConsoleLogger() {
310
310
  }
311
311
 
312
312
  // src/core/version.ts
313
- var SDK_VERSION = "1.7.2";
313
+ var SDK_VERSION = "1.8.0";
314
314
 
315
315
  // src/shared/browser-utils.ts
316
316
  function generateUUID() {
@@ -645,19 +645,20 @@ var BaseClient = class {
645
645
  * Handle error responses from API
646
646
  */
647
647
  handleErrorResponse(status, data, requestId) {
648
- const message = data.error || data.message || `HTTP ${status}`;
648
+ const structured = data.error && typeof data.error === "object" && !Array.isArray(data.error) ? data.error : void 0;
649
+ const message = typeof data.error === "string" && data.error || typeof structured?.message === "string" && structured.message || typeof data.message === "string" && data.message || `HTTP ${status}`;
649
650
  const createError = () => {
650
651
  switch (status) {
651
652
  case 400:
652
- return new VesantError(message, "BAD_REQUEST", 400);
653
+ return new VesantError(message, "BAD_REQUEST", 400, structured);
653
654
  case 401:
654
655
  return new AuthenticationError(message);
655
656
  case 403:
656
- return new VesantError(message, "FORBIDDEN", 403);
657
+ return new VesantError(message, "FORBIDDEN", 403, structured);
657
658
  case 404:
658
- return new VesantError(message, "NOT_FOUND", 404);
659
+ return new VesantError(message, "NOT_FOUND", 404, structured);
659
660
  case 409:
660
- return new VesantError(message, "DUPLICATE_PROFILE", 409);
661
+ return new VesantError(message, "DUPLICATE_PROFILE", 409, structured);
661
662
  case 429: {
662
663
  const retryAfter = data.retry_after || data.retryAfter;
663
664
  return new RateLimitError(retryAfter);
@@ -668,7 +669,7 @@ var BaseClient = class {
668
669
  case 504:
669
670
  return new ServiceUnavailableError(message);
670
671
  default:
671
- return new VesantError(message, "UNKNOWN_ERROR", status);
672
+ return new VesantError(message, "UNKNOWN_ERROR", status, structured);
672
673
  }
673
674
  };
674
675
  const error = createError();
@@ -967,6 +968,7 @@ async function generateCipherText(options, config) {
967
968
  }
968
969
 
969
970
  // src/geolocation/client.ts
971
+ var DEFAULT_GPS_CONFIG_TTL_MS = 5 * 60 * 1e3;
970
972
  var GeolocationClient = class extends BaseClient {
971
973
  constructor(config) {
972
974
  const baseConfig = {
@@ -982,6 +984,8 @@ var GeolocationClient = class extends BaseClient {
982
984
  environment: config.environment
983
985
  };
984
986
  super(baseConfig);
987
+ this.gpsConfigCache = null;
988
+ this.gpsConfigTtlMs = config.gpsConfigTtlMs ?? DEFAULT_GPS_CONFIG_TTL_MS;
985
989
  }
986
990
  // ============================================================================
987
991
  // IP Verification & Compliance
@@ -1067,7 +1071,42 @@ var GeolocationClient = class extends BaseClient {
1067
1071
  * ```
1068
1072
  */
1069
1073
  async getGPSConfig(requestOptions) {
1070
- return this.requestWithRetry("/api/v1/geo/config", void 0, void 0, void 0, requestOptions);
1074
+ const cached = this.gpsConfigCache;
1075
+ if (cached && cached.expiresAt > Date.now()) {
1076
+ return cached.value;
1077
+ }
1078
+ return this.refreshGPSConfig(requestOptions);
1079
+ }
1080
+ /**
1081
+ * Re-read the tenant's GPS requirement configuration, ignoring any copy held
1082
+ * from an earlier read.
1083
+ *
1084
+ * These requirements are edited in the compliance console while your
1085
+ * application is running. `getGPSConfig` reuses a fetched copy for a short
1086
+ * period so a long-lived session does not call the API on every event; call
1087
+ * this when you need a change to take effect immediately — for example right
1088
+ * after an administrator saves new settings.
1089
+ *
1090
+ * @returns The current GPS requirement config per event type
1091
+ *
1092
+ * @example
1093
+ * ```typescript
1094
+ * const config = await client.refreshGPSConfig();
1095
+ * if (config.require_gps.login) {
1096
+ * // GPS is now required for login
1097
+ * }
1098
+ * ```
1099
+ */
1100
+ async refreshGPSConfig(requestOptions) {
1101
+ const value = await this.requestWithRetry(
1102
+ "/api/v1/geo/config",
1103
+ void 0,
1104
+ void 0,
1105
+ void 0,
1106
+ requestOptions
1107
+ );
1108
+ this.gpsConfigCache = { value, expiresAt: Date.now() + this.gpsConfigTtlMs };
1109
+ return value;
1071
1110
  }
1072
1111
  /**
1073
1112
  * Mint a short-lived, single-use device-signals nonce.
@@ -1484,17 +1523,27 @@ var RiskProfileClient = class extends BaseClient {
1484
1523
  /**
1485
1524
  * Update customer profile
1486
1525
  *
1526
+ * Omitted fields keep their stored values. When the tenant has the
1527
+ * **On Account Sensitive Action** KYC trigger enabled and the update changes
1528
+ * the customer's name, date of birth or residential address, Vesant applies
1529
+ * the other fields, holds the sensitive ones and answers `202` with a
1530
+ * {@link ProfileUpdateHeldResponse} instead of the profile. Narrow with
1531
+ * {@link isProfileUpdateHeld}, then request a `profile_change` submit link.
1532
+ *
1487
1533
  * @param profileId - Profile UUID
1488
1534
  * @param updates - Fields to update
1489
- * @returns Updated customer profile
1535
+ * @returns Updated customer profile, or the held change
1490
1536
  *
1491
1537
  * @example
1492
1538
  * ```typescript
1493
- * const updated = await client.updateProfile(profileId, {
1539
+ * const result = await client.updateProfile(profileId, {
1494
1540
  * location: 'New York, USA',
1495
1541
  * location_compliance: 'compliant',
1496
1542
  * last_recorded_activity: new Date().toISOString()
1497
1543
  * });
1544
+ * if (isProfileUpdateHeld(result)) {
1545
+ * // name / DOB / address held: start KYC with trigger_event 'profile_change'
1546
+ * }
1498
1547
  * ```
1499
1548
  */
1500
1549
  async updateProfile(profileId, updates, requestOptions) {
@@ -1534,6 +1583,11 @@ var RiskProfileClient = class extends BaseClient {
1534
1583
  }
1535
1584
  };
1536
1585
 
1586
+ // src/risk-profile/types.ts
1587
+ function isProfileUpdateHeld(result) {
1588
+ return typeof result === "object" && result !== null && result.status === "kyc_required" && result.kyc_required === true;
1589
+ }
1590
+
1537
1591
  // src/compliance/types.ts
1538
1592
  var DEFAULT_CURRENCY_RATES = {
1539
1593
  USD: 1,
@@ -1989,11 +2043,12 @@ var ComplianceClient = class {
1989
2043
  if (profileResult) {
1990
2044
  profile = profileResult;
1991
2045
  if (!isBlocked && this.shouldUpdateProfile(profile, geoVerification.location.city)) {
1992
- profile = await this.riskClient.updateProfile(profile.id, {
2046
+ const updated = await this.riskClient.updateProfile(profile.id, {
1993
2047
  last_recorded_activity: (/* @__PURE__ */ new Date()).toISOString(),
1994
2048
  location: `${geoVerification.location.city}, ${geoVerification.location.country}`,
1995
2049
  location_compliance: geoVerification.is_compliant ? "compliant" : "non-compliant"
1996
2050
  }, requestOptions);
2051
+ profile = isProfileUpdateHeld(updated) ? updated.profile : updated;
1997
2052
  }
1998
2053
  } else {
1999
2054
  if (this.config.autoCreateProfiles && this.config.debug) {