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
@@ -227,7 +227,7 @@ function createConsoleLogger() {
227
227
  }
228
228
 
229
229
  // src/core/version.ts
230
- var SDK_VERSION = "1.7.2";
230
+ var SDK_VERSION = "1.8.0";
231
231
 
232
232
  // src/shared/browser-utils.ts
233
233
  function generateUUID() {
@@ -562,19 +562,20 @@ var BaseClient = class {
562
562
  * Handle error responses from API
563
563
  */
564
564
  handleErrorResponse(status, data, requestId) {
565
- const message = data.error || data.message || `HTTP ${status}`;
565
+ const structured = data.error && typeof data.error === "object" && !Array.isArray(data.error) ? data.error : void 0;
566
+ const message = typeof data.error === "string" && data.error || typeof structured?.message === "string" && structured.message || typeof data.message === "string" && data.message || `HTTP ${status}`;
566
567
  const createError = () => {
567
568
  switch (status) {
568
569
  case 400:
569
- return new VesantError(message, "BAD_REQUEST", 400);
570
+ return new VesantError(message, "BAD_REQUEST", 400, structured);
570
571
  case 401:
571
572
  return new AuthenticationError(message);
572
573
  case 403:
573
- return new VesantError(message, "FORBIDDEN", 403);
574
+ return new VesantError(message, "FORBIDDEN", 403, structured);
574
575
  case 404:
575
- return new VesantError(message, "NOT_FOUND", 404);
576
+ return new VesantError(message, "NOT_FOUND", 404, structured);
576
577
  case 409:
577
- return new VesantError(message, "DUPLICATE_PROFILE", 409);
578
+ return new VesantError(message, "DUPLICATE_PROFILE", 409, structured);
578
579
  case 429: {
579
580
  const retryAfter = data.retry_after || data.retryAfter;
580
581
  return new RateLimitError(retryAfter);
@@ -585,7 +586,7 @@ var BaseClient = class {
585
586
  case 504:
586
587
  return new ServiceUnavailableError(message);
587
588
  default:
588
- return new VesantError(message, "UNKNOWN_ERROR", status);
589
+ return new VesantError(message, "UNKNOWN_ERROR", status, structured);
589
590
  }
590
591
  };
591
592
  const error = createError();
@@ -910,6 +911,7 @@ function isCipherTextExpired(cipherText) {
910
911
  }
911
912
 
912
913
  // src/geolocation/client.ts
914
+ var DEFAULT_GPS_CONFIG_TTL_MS = 5 * 60 * 1e3;
913
915
  var GeolocationClient = class extends BaseClient {
914
916
  constructor(config) {
915
917
  const baseConfig = {
@@ -925,6 +927,8 @@ var GeolocationClient = class extends BaseClient {
925
927
  environment: config.environment
926
928
  };
927
929
  super(baseConfig);
930
+ this.gpsConfigCache = null;
931
+ this.gpsConfigTtlMs = config.gpsConfigTtlMs ?? DEFAULT_GPS_CONFIG_TTL_MS;
928
932
  }
929
933
  // ============================================================================
930
934
  // IP Verification & Compliance
@@ -1010,7 +1014,42 @@ var GeolocationClient = class extends BaseClient {
1010
1014
  * ```
1011
1015
  */
1012
1016
  async getGPSConfig(requestOptions) {
1013
- return this.requestWithRetry("/api/v1/geo/config", void 0, void 0, void 0, requestOptions);
1017
+ const cached = this.gpsConfigCache;
1018
+ if (cached && cached.expiresAt > Date.now()) {
1019
+ return cached.value;
1020
+ }
1021
+ return this.refreshGPSConfig(requestOptions);
1022
+ }
1023
+ /**
1024
+ * Re-read the tenant's GPS requirement configuration, ignoring any copy held
1025
+ * from an earlier read.
1026
+ *
1027
+ * These requirements are edited in the compliance console while your
1028
+ * application is running. `getGPSConfig` reuses a fetched copy for a short
1029
+ * period so a long-lived session does not call the API on every event; call
1030
+ * this when you need a change to take effect immediately — for example right
1031
+ * after an administrator saves new settings.
1032
+ *
1033
+ * @returns The current GPS requirement config per event type
1034
+ *
1035
+ * @example
1036
+ * ```typescript
1037
+ * const config = await client.refreshGPSConfig();
1038
+ * if (config.require_gps.login) {
1039
+ * // GPS is now required for login
1040
+ * }
1041
+ * ```
1042
+ */
1043
+ async refreshGPSConfig(requestOptions) {
1044
+ const value = await this.requestWithRetry(
1045
+ "/api/v1/geo/config",
1046
+ void 0,
1047
+ void 0,
1048
+ void 0,
1049
+ requestOptions
1050
+ );
1051
+ this.gpsConfigCache = { value, expiresAt: Date.now() + this.gpsConfigTtlMs };
1052
+ return value;
1014
1053
  }
1015
1054
  /**
1016
1055
  * Mint a short-lived, single-use device-signals nonce.