vesant-sdk 1.7.2 → 1.8.0-dev.0a33430

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 +5 -3
  2. package/dist/{client-B3DCAHlg.d.ts → client-4oLoc31v.d.ts} +2 -2
  3. package/dist/{client-fy3trF2K.d.ts → client-BaUekQT8.d.ts} +32 -10
  4. package/dist/{client-D23KhWeh.d.mts → client-CJI8VO1i.d.mts} +2 -2
  5. package/dist/{client-BwXMQA2a.d.mts → client-XDEhh9VN.d.mts} +32 -10
  6. package/dist/compliance/index.d.mts +3 -3
  7. package/dist/compliance/index.d.ts +3 -3
  8. package/dist/compliance/index.js +59 -5
  9. package/dist/compliance/index.js.map +1 -1
  10. package/dist/compliance/index.mjs +59 -5
  11. package/dist/compliance/index.mjs.map +1 -1
  12. package/dist/decisions/index.js +1 -1
  13. package/dist/decisions/index.js.map +1 -1
  14. package/dist/decisions/index.mjs +1 -1
  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 +40 -2
  19. package/dist/geolocation/index.js.map +1 -1
  20. package/dist/geolocation/index.mjs +40 -2
  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 +118 -16
  27. package/dist/index.js.map +1 -1
  28. package/dist/index.mjs +116 -17
  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 +53 -12
  33. package/dist/kyc/core.js.map +1 -1
  34. package/dist/kyc/core.mjs +53 -13
  35. package/dist/kyc/core.mjs.map +1 -1
  36. package/dist/kyc/index.d.mts +172 -16
  37. package/dist/kyc/index.d.ts +172 -16
  38. package/dist/kyc/index.js +53 -12
  39. package/dist/kyc/index.js.map +1 -1
  40. package/dist/kyc/index.mjs +53 -13
  41. package/dist/kyc/index.mjs.map +1 -1
  42. package/dist/react.d.mts +29 -4
  43. package/dist/react.d.ts +29 -4
  44. package/dist/react.js +23 -11
  45. package/dist/react.js.map +1 -1
  46. package/dist/react.mjs +23 -11
  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 +19 -3
  51. package/dist/risk-profile/index.js.map +1 -1
  52. package/dist/risk-profile/index.mjs +19 -4
  53. package/dist/risk-profile/index.mjs.map +1 -1
  54. package/dist/scores/index.js +1 -1
  55. package/dist/scores/index.js.map +1 -1
  56. package/dist/scores/index.mjs +1 -1
  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 +1 -1
  61. package/dist/tax/index.js.map +1 -1
  62. package/dist/tax/index.mjs +1 -1
  63. package/dist/tax/index.mjs.map +1 -1
  64. package/dist/{types-UGyDl1fd.d.ts → types-1kI4SsKB.d.ts} +44 -1
  65. package/dist/{types-BOFaMQxI.d.mts → types-DfbnIaW_.d.mts} +44 -1
  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
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) {
@@ -3149,19 +3203,26 @@ var KycClient = class extends BaseClient {
3149
3203
  }, void 0, requestOptions);
3150
3204
  }
3151
3205
  /**
3152
- * Get a KYC request by ID
3206
+ * Get a KYC record by ID
3207
+ *
3208
+ * Works with your tenant API key. Each entry in `proofs` carries a
3209
+ * short-lived `link` for downloading that document, and `reference` holds
3210
+ * your own customer reference (the `forward_reference`).
3153
3211
  *
3154
- * @param id - KYC request ID
3155
- * @returns KYC request details including proofs and alerts
3212
+ * @param id - KYC record ID (the `kyc_id` returned by `requestKycSubmitLink`)
3213
+ * @returns KYC record including proofs (with download links) and alerts
3156
3214
  *
3157
3215
  * @example
3158
3216
  * ```typescript
3159
3217
  * const kyc = await client.getKycRequest("550e8400-e29b-41d4-a716-446655440000");
3160
3218
  * console.log(`Status: ${kyc.status}, ID Verified: ${kyc.id_verified}`);
3219
+ * kyc.proofs?.forEach(proof => console.log(`${proof.type}: ${proof.link}`));
3161
3220
  * ```
3162
3221
  */
3163
3222
  async getKycRequest(id) {
3164
- return this.request(`/api/v1/kyc/requests/${id}`);
3223
+ return this.request(`/api/v1/kyc/${encodeURIComponent(id)}`, {
3224
+ headers: this.getUserHeaders()
3225
+ });
3165
3226
  }
3166
3227
  /**
3167
3228
  * List KYC requests with filters and pagination
@@ -3178,6 +3239,10 @@ var KycClient = class extends BaseClient {
3178
3239
  * );
3179
3240
  * console.log(`Found ${requests.total} pending requests`);
3180
3241
  * ```
3242
+ *
3243
+ * @remarks Console session only. This endpoint accepts a Vesant console
3244
+ * (dashboard login) token, not a tenant API key; called with an API key it
3245
+ * fails with `AuthenticationError` or a permission error.
3181
3246
  */
3182
3247
  async listKycRequests(filters, pagination) {
3183
3248
  const params = {};
@@ -3215,6 +3280,10 @@ var KycClient = class extends BaseClient {
3215
3280
  * reason: "Document expired"
3216
3281
  * });
3217
3282
  * ```
3283
+ *
3284
+ * @remarks Console session only. This endpoint accepts a Vesant console
3285
+ * (dashboard login) token, not a tenant API key; called with an API key it
3286
+ * fails with `AuthenticationError` or a permission error.
3218
3287
  */
3219
3288
  async updateKycStatus(request) {
3220
3289
  await this.request("/api/v1/kyc/status", {
@@ -3251,22 +3320,24 @@ var KycClient = class extends BaseClient {
3251
3320
  /**
3252
3321
  * Get downloadable URLs for KYC proofs/documents
3253
3322
  *
3254
- * @param kycId - KYC request ID
3255
- * @returns Array of proof download URLs with expiration
3323
+ * Derived from the `proofs` of `getKycRequest`: the platform attaches a
3324
+ * short-lived download link to every proof on the KYC record, so no
3325
+ * separate endpoint is needed. Proofs without a link are omitted.
3326
+ *
3327
+ * @param kycId - KYC record ID
3328
+ * @returns Array of proof download URLs
3256
3329
  *
3257
3330
  * @example
3258
3331
  * ```typescript
3259
3332
  * const proofs = await client.getProofDownloadURLs("550e8400-e29b-41d4-a716-446655440000");
3260
3333
  * proofs.forEach(proof => {
3261
- * console.log(`${proof.type}: ${proof.url} (expires: ${proof.expires_at})`);
3334
+ * console.log(`${proof.type}: ${proof.url}`);
3262
3335
  * });
3263
3336
  * ```
3264
3337
  */
3265
3338
  async getProofDownloadURLs(kycId) {
3266
- return this.request(
3267
- `/api/v1/kyc/proofs/${kycId}`,
3268
- { headers: this.getUserHeaders() }
3269
- );
3339
+ const kyc = await this.getKycRequest(kycId);
3340
+ return (kyc.proofs ?? []).filter((proof) => typeof proof.link === "string" && proof.link !== "").map((proof) => ({ id: proof.id, type: proof.type, url: proof.link }));
3270
3341
  }
3271
3342
  // ============================================================================
3272
3343
  // KYC Overview & Statistics
@@ -3287,6 +3358,10 @@ var KycClient = class extends BaseClient {
3287
3358
  * console.log(`Total: ${overview.total}, Pending: ${overview.pending}`);
3288
3359
  * console.log(`Approved: ${overview.approved}, Rejected: ${overview.rejected}`);
3289
3360
  * ```
3361
+ *
3362
+ * @remarks Console session only. This endpoint accepts a Vesant console
3363
+ * (dashboard login) token, not a tenant API key; called with an API key it
3364
+ * fails with `AuthenticationError` or a permission error.
3290
3365
  */
3291
3366
  async getOverview(fromDate, toDate) {
3292
3367
  const params = {};
@@ -3304,6 +3379,10 @@ var KycClient = class extends BaseClient {
3304
3379
  *
3305
3380
  * @param alertId - Alert ID
3306
3381
  * @returns Alert details
3382
+ *
3383
+ * @remarks Console session only. This endpoint accepts a Vesant console
3384
+ * (dashboard login) token, not a tenant API key; called with an API key it
3385
+ * fails with `AuthenticationError` or a permission error.
3307
3386
  */
3308
3387
  async getAlert(alertId) {
3309
3388
  return this.request(`/api/v1/kyc/alerts/${alertId}`);
@@ -3327,6 +3406,10 @@ var KycClient = class extends BaseClient {
3327
3406
  * );
3328
3407
  * console.log(`Found ${alerts.total} alerts`);
3329
3408
  * ```
3409
+ *
3410
+ * @remarks Console session only. This endpoint accepts a Vesant console
3411
+ * (dashboard login) token, not a tenant API key; called with an API key it
3412
+ * fails with `AuthenticationError` or a permission error.
3330
3413
  */
3331
3414
  async listAlerts(filters, pagination) {
3332
3415
  const params = {};
@@ -3373,6 +3456,10 @@ var KycClient = class extends BaseClient {
3373
3456
  * reason: "Requires senior review - suspicious documents"
3374
3457
  * });
3375
3458
  * ```
3459
+ *
3460
+ * @remarks Console session only. This endpoint accepts a Vesant console
3461
+ * (dashboard login) token, not a tenant API key; called with an API key it
3462
+ * fails with `AuthenticationError` or a permission error.
3376
3463
  */
3377
3464
  async updateAlert(alertId, update) {
3378
3465
  await this.request(`/api/v1/kyc/alerts/${alertId}`, {
@@ -3395,6 +3482,10 @@ var KycClient = class extends BaseClient {
3395
3482
  * console.log(`Face verification required: ${prefs.is_face_verification_required}`);
3396
3483
  * console.log(`Required documents: ${prefs.required_document_count}`);
3397
3484
  * ```
3485
+ *
3486
+ * @remarks Console session only. This endpoint accepts a Vesant console
3487
+ * (dashboard login) token, not a tenant API key; called with an API key it
3488
+ * fails with `AuthenticationError` or a permission error.
3398
3489
  */
3399
3490
  async getPreferences() {
3400
3491
  return this.request("/api/v1/kyc/preferences");
@@ -3568,6 +3659,9 @@ var KYC_DECLINED_DESCRIPTIONS = {
3568
3659
  function isKycDocumentExpiredCallbackEvent(value) {
3569
3660
  return typeof value === "object" && value !== null && value.event === "kyc_document_expired";
3570
3661
  }
3662
+ function isProfileChangeCallbackEvent(value) {
3663
+ return typeof value === "object" && value !== null && value.event === "profile_change";
3664
+ }
3571
3665
 
3572
3666
  // src/tax/client.ts
3573
3667
  var TaxClient = class extends BaseClient {
@@ -3857,6 +3951,11 @@ function buildHandler(options) {
3857
3951
  return handler;
3858
3952
  }
3859
3953
 
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 };
3954
+ // src/webhooks/types.ts
3955
+ function isAmlBlockCallbackEvent(value) {
3956
+ return typeof value === "object" && value !== null && value.event === "aml" && value.block === true;
3957
+ }
3958
+
3959
+ 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
3960
  //# sourceMappingURL=index.mjs.map
3862
3961
  //# sourceMappingURL=index.mjs.map