vesant-sdk 1.7.2 → 1.8.0-dev.153299b

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 (69) hide show
  1. package/dist/{client-B3DCAHlg.d.ts → client-4oLoc31v.d.ts} +2 -2
  2. package/dist/{client-fy3trF2K.d.ts → client-BaUekQT8.d.ts} +32 -10
  3. package/dist/{client-D23KhWeh.d.mts → client-CJI8VO1i.d.mts} +2 -2
  4. package/dist/{client-BwXMQA2a.d.mts → client-XDEhh9VN.d.mts} +32 -10
  5. package/dist/compliance/index.d.mts +3 -3
  6. package/dist/compliance/index.d.ts +3 -3
  7. package/dist/compliance/index.js +59 -5
  8. package/dist/compliance/index.js.map +1 -1
  9. package/dist/compliance/index.mjs +59 -5
  10. package/dist/compliance/index.mjs.map +1 -1
  11. package/dist/decisions/index.js +1 -1
  12. package/dist/decisions/index.js.map +1 -1
  13. package/dist/decisions/index.mjs +1 -1
  14. package/dist/decisions/index.mjs.map +1 -1
  15. package/dist/geolocation/index.d.mts +2 -2
  16. package/dist/geolocation/index.d.ts +2 -2
  17. package/dist/geolocation/index.js +40 -2
  18. package/dist/geolocation/index.js.map +1 -1
  19. package/dist/geolocation/index.mjs +40 -2
  20. package/dist/geolocation/index.mjs.map +1 -1
  21. package/dist/{index-DSDgS09k.d.ts → index-BosFSGan.d.ts} +57 -2
  22. package/dist/{index-C3zUKydT.d.mts → index-C49a7fg2.d.mts} +57 -2
  23. package/dist/index.d.mts +6 -6
  24. package/dist/index.d.ts +6 -6
  25. package/dist/index.js +70 -5
  26. package/dist/index.js.map +1 -1
  27. package/dist/index.mjs +68 -6
  28. package/dist/index.mjs.map +1 -1
  29. package/dist/kyc/core.d.mts +2 -2
  30. package/dist/kyc/core.d.ts +2 -2
  31. package/dist/kyc/core.js +5 -1
  32. package/dist/kyc/core.js.map +1 -1
  33. package/dist/kyc/core.mjs +5 -2
  34. package/dist/kyc/core.mjs.map +1 -1
  35. package/dist/kyc/index.d.mts +103 -4
  36. package/dist/kyc/index.d.ts +103 -4
  37. package/dist/kyc/index.js +5 -1
  38. package/dist/kyc/index.js.map +1 -1
  39. package/dist/kyc/index.mjs +5 -2
  40. package/dist/kyc/index.mjs.map +1 -1
  41. package/dist/react.d.mts +17 -4
  42. package/dist/react.d.ts +17 -4
  43. package/dist/react.js +23 -11
  44. package/dist/react.js.map +1 -1
  45. package/dist/react.mjs +23 -11
  46. package/dist/react.mjs.map +1 -1
  47. package/dist/risk-profile/index.d.mts +16 -6
  48. package/dist/risk-profile/index.d.ts +16 -6
  49. package/dist/risk-profile/index.js +19 -3
  50. package/dist/risk-profile/index.js.map +1 -1
  51. package/dist/risk-profile/index.mjs +19 -4
  52. package/dist/risk-profile/index.mjs.map +1 -1
  53. package/dist/scores/index.js +1 -1
  54. package/dist/scores/index.js.map +1 -1
  55. package/dist/scores/index.mjs +1 -1
  56. package/dist/scores/index.mjs.map +1 -1
  57. package/dist/tax/index.js +1 -1
  58. package/dist/tax/index.js.map +1 -1
  59. package/dist/tax/index.mjs +1 -1
  60. package/dist/tax/index.mjs.map +1 -1
  61. package/dist/{types-UGyDl1fd.d.ts → types-1kI4SsKB.d.ts} +44 -1
  62. package/dist/{types-BOFaMQxI.d.mts → types-DfbnIaW_.d.mts} +44 -1
  63. package/dist/webhooks/index.d.mts +1 -1
  64. package/dist/webhooks/index.d.ts +1 -1
  65. package/dist/webhooks/index.js +6 -0
  66. package/dist/webhooks/index.js.map +1 -1
  67. package/dist/webhooks/index.mjs +6 -1
  68. package/dist/webhooks/index.mjs.map +1 -1
  69. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -296,7 +296,7 @@ var noopLogger = {
296
296
  };
297
297
 
298
298
  // src/core/version.ts
299
- var SDK_VERSION = "1.7.2";
299
+ var SDK_VERSION = "1.8.0";
300
300
 
301
301
  // src/shared/browser-utils.ts
302
302
  function generateUUID() {
@@ -1102,6 +1102,7 @@ function isCipherTextExpired(cipherText) {
1102
1102
  }
1103
1103
 
1104
1104
  // src/geolocation/client.ts
1105
+ var DEFAULT_GPS_CONFIG_TTL_MS = 5 * 60 * 1e3;
1105
1106
  var GeolocationClient = class extends BaseClient {
1106
1107
  constructor(config) {
1107
1108
  const baseConfig = {
@@ -1117,6 +1118,8 @@ var GeolocationClient = class extends BaseClient {
1117
1118
  environment: config.environment
1118
1119
  };
1119
1120
  super(baseConfig);
1121
+ this.gpsConfigCache = null;
1122
+ this.gpsConfigTtlMs = config.gpsConfigTtlMs ?? DEFAULT_GPS_CONFIG_TTL_MS;
1120
1123
  }
1121
1124
  // ============================================================================
1122
1125
  // IP Verification & Compliance
@@ -1202,7 +1205,42 @@ var GeolocationClient = class extends BaseClient {
1202
1205
  * ```
1203
1206
  */
1204
1207
  async getGPSConfig(requestOptions) {
1205
- return this.requestWithRetry("/api/v1/geo/config", void 0, void 0, void 0, requestOptions);
1208
+ const cached = this.gpsConfigCache;
1209
+ if (cached && cached.expiresAt > Date.now()) {
1210
+ return cached.value;
1211
+ }
1212
+ return this.refreshGPSConfig(requestOptions);
1213
+ }
1214
+ /**
1215
+ * Re-read the tenant's GPS requirement configuration, ignoring any copy held
1216
+ * from an earlier read.
1217
+ *
1218
+ * These requirements are edited in the compliance console while your
1219
+ * application is running. `getGPSConfig` reuses a fetched copy for a short
1220
+ * period so a long-lived session does not call the API on every event; call
1221
+ * this when you need a change to take effect immediately — for example right
1222
+ * after an administrator saves new settings.
1223
+ *
1224
+ * @returns The current GPS requirement config per event type
1225
+ *
1226
+ * @example
1227
+ * ```typescript
1228
+ * const config = await client.refreshGPSConfig();
1229
+ * if (config.require_gps.login) {
1230
+ * // GPS is now required for login
1231
+ * }
1232
+ * ```
1233
+ */
1234
+ async refreshGPSConfig(requestOptions) {
1235
+ const value = await this.requestWithRetry(
1236
+ "/api/v1/geo/config",
1237
+ void 0,
1238
+ void 0,
1239
+ void 0,
1240
+ requestOptions
1241
+ );
1242
+ this.gpsConfigCache = { value, expiresAt: Date.now() + this.gpsConfigTtlMs };
1243
+ return value;
1206
1244
  }
1207
1245
  /**
1208
1246
  * Mint a short-lived, single-use device-signals nonce.
@@ -1619,17 +1657,27 @@ var RiskProfileClient = class extends BaseClient {
1619
1657
  /**
1620
1658
  * Update customer profile
1621
1659
  *
1660
+ * Omitted fields keep their stored values. When the tenant has the
1661
+ * **On Account Sensitive Action** KYC trigger enabled and the update changes
1662
+ * the customer's name, date of birth or residential address, Vesant applies
1663
+ * the other fields, holds the sensitive ones and answers `202` with a
1664
+ * {@link ProfileUpdateHeldResponse} instead of the profile. Narrow with
1665
+ * {@link isProfileUpdateHeld}, then request a `profile_change` submit link.
1666
+ *
1622
1667
  * @param profileId - Profile UUID
1623
1668
  * @param updates - Fields to update
1624
- * @returns Updated customer profile
1669
+ * @returns Updated customer profile, or the held change
1625
1670
  *
1626
1671
  * @example
1627
1672
  * ```typescript
1628
- * const updated = await client.updateProfile(profileId, {
1673
+ * const result = await client.updateProfile(profileId, {
1629
1674
  * location: 'New York, USA',
1630
1675
  * location_compliance: 'compliant',
1631
1676
  * last_recorded_activity: new Date().toISOString()
1632
1677
  * });
1678
+ * if (isProfileUpdateHeld(result)) {
1679
+ * // name / DOB / address held: start KYC with trigger_event 'profile_change'
1680
+ * }
1633
1681
  * ```
1634
1682
  */
1635
1683
  async updateProfile(profileId, updates, requestOptions) {
@@ -1669,6 +1717,11 @@ var RiskProfileClient = class extends BaseClient {
1669
1717
  }
1670
1718
  };
1671
1719
 
1720
+ // src/risk-profile/types.ts
1721
+ function isProfileUpdateHeld(result) {
1722
+ return typeof result === "object" && result !== null && result.status === "kyc_required" && result.kyc_required === true;
1723
+ }
1724
+
1672
1725
  // src/compliance/block-reasons.ts
1673
1726
  var sdkReasons = {
1674
1727
  // Jurisdiction
@@ -2199,11 +2252,12 @@ var ComplianceClient = class {
2199
2252
  if (profileResult) {
2200
2253
  profile = profileResult;
2201
2254
  if (!isBlocked && this.shouldUpdateProfile(profile, geoVerification.location.city)) {
2202
- profile = await this.riskClient.updateProfile(profile.id, {
2255
+ const updated = await this.riskClient.updateProfile(profile.id, {
2203
2256
  last_recorded_activity: (/* @__PURE__ */ new Date()).toISOString(),
2204
2257
  location: `${geoVerification.location.city}, ${geoVerification.location.country}`,
2205
2258
  location_compliance: geoVerification.is_compliant ? "compliant" : "non-compliant"
2206
2259
  }, requestOptions);
2260
+ profile = isProfileUpdateHeld(updated) ? updated.profile : updated;
2207
2261
  }
2208
2262
  } else {
2209
2263
  if (this.config.autoCreateProfiles && this.config.debug) {
@@ -3568,6 +3622,9 @@ var KYC_DECLINED_DESCRIPTIONS = {
3568
3622
  function isKycDocumentExpiredCallbackEvent(value) {
3569
3623
  return typeof value === "object" && value !== null && value.event === "kyc_document_expired";
3570
3624
  }
3625
+ function isProfileChangeCallbackEvent(value) {
3626
+ return typeof value === "object" && value !== null && value.event === "profile_change";
3627
+ }
3571
3628
 
3572
3629
  // src/tax/client.ts
3573
3630
  var TaxClient = class extends BaseClient {
@@ -3857,6 +3914,11 @@ function buildHandler(options) {
3857
3914
  return handler;
3858
3915
  }
3859
3916
 
3860
- export { AuthenticationError, BaseClient, CGSError, CircuitBreaker, CircuitBreakerOpenError, ComplianceBlockedError, ComplianceClient, ComplianceError, DEFAULT_CURRENCY_RATES, GeolocationClient, InMemoryDedupStore, KYC_DECLINED_DESCRIPTIONS, KycClient, NetworkError, RateLimitError, RateLimitTracker, RefreshingTokenProvider, RiskProfileClient, SDK_VERSION, ServiceUnavailableError, StaticApiKeyProvider, TaxClient, TimeoutError, ValidationError, VesantError, WebhookHandler, assessGpsIntegrity, collectAll, collectDeviceSignals, createConsoleLogger, createNextWebhookHandler, createWebhookMiddleware, decodeCipherText, generateCipherText, gpsIntegrityInputFromPosition, isCipherTextExpired, isKycDocumentExpiredCallbackEvent, noopLogger, paginate, probeGeolocationPermission, sdkReasons, verifyWebhookSignature };
3917
+ // src/webhooks/types.ts
3918
+ function isAmlBlockCallbackEvent(value) {
3919
+ return typeof value === "object" && value !== null && value.event === "aml" && value.block === true;
3920
+ }
3921
+
3922
+ export { AuthenticationError, BaseClient, CGSError, CircuitBreaker, CircuitBreakerOpenError, ComplianceBlockedError, ComplianceClient, ComplianceError, DEFAULT_CURRENCY_RATES, GeolocationClient, InMemoryDedupStore, KYC_DECLINED_DESCRIPTIONS, KycClient, NetworkError, RateLimitError, RateLimitTracker, RefreshingTokenProvider, RiskProfileClient, SDK_VERSION, ServiceUnavailableError, StaticApiKeyProvider, TaxClient, TimeoutError, ValidationError, VesantError, WebhookHandler, assessGpsIntegrity, collectAll, collectDeviceSignals, createConsoleLogger, createNextWebhookHandler, createWebhookMiddleware, decodeCipherText, generateCipherText, gpsIntegrityInputFromPosition, isAmlBlockCallbackEvent, isCipherTextExpired, isKycDocumentExpiredCallbackEvent, isProfileChangeCallbackEvent, isProfileUpdateHeld, noopLogger, paginate, probeGeolocationPermission, sdkReasons, verifyWebhookSignature };
3861
3923
  //# sourceMappingURL=index.mjs.map
3862
3924
  //# sourceMappingURL=index.mjs.map