vesant-sdk 1.8.0-dev.2b9e28d → 1.8.0-dev.2d679f1

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 (60) hide show
  1. package/README.md +2 -2
  2. package/dist/{client-DUHC-68_.d.ts → client-BPALLldd.d.ts} +1 -1
  3. package/dist/{client-5q4whhGu.d.mts → client-_OhkfnyJ.d.mts} +1 -1
  4. package/dist/compliance/index.d.mts +2 -2
  5. package/dist/compliance/index.d.ts +2 -2
  6. package/dist/compliance/index.js +26 -9
  7. package/dist/compliance/index.js.map +1 -1
  8. package/dist/compliance/index.mjs +26 -9
  9. package/dist/compliance/index.mjs.map +1 -1
  10. package/dist/decisions/index.js +7 -6
  11. package/dist/decisions/index.js.map +1 -1
  12. package/dist/decisions/index.mjs +7 -6
  13. package/dist/decisions/index.mjs.map +1 -1
  14. package/dist/geolocation/index.js +7 -6
  15. package/dist/geolocation/index.js.map +1 -1
  16. package/dist/geolocation/index.mjs +7 -6
  17. package/dist/geolocation/index.mjs.map +1 -1
  18. package/dist/index.d.mts +3 -3
  19. package/dist/index.d.ts +3 -3
  20. package/dist/index.js +57 -167
  21. package/dist/index.js.map +1 -1
  22. package/dist/index.mjs +55 -168
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/kyc/core.d.mts +2 -2
  25. package/dist/kyc/core.d.ts +2 -2
  26. package/dist/kyc/core.js +37 -164
  27. package/dist/kyc/core.js.map +1 -1
  28. package/dist/kyc/core.mjs +36 -165
  29. package/dist/kyc/core.mjs.map +1 -1
  30. package/dist/kyc/index.d.mts +218 -218
  31. package/dist/kyc/index.d.ts +218 -218
  32. package/dist/kyc/index.js +37 -164
  33. package/dist/kyc/index.js.map +1 -1
  34. package/dist/kyc/index.mjs +36 -165
  35. package/dist/kyc/index.mjs.map +1 -1
  36. package/dist/react.d.mts +16 -114
  37. package/dist/react.d.ts +16 -114
  38. package/dist/react.js +8 -186
  39. package/dist/react.js.map +1 -1
  40. package/dist/react.mjs +9 -184
  41. package/dist/react.mjs.map +1 -1
  42. package/dist/risk-profile/index.d.mts +16 -6
  43. package/dist/risk-profile/index.d.ts +16 -6
  44. package/dist/risk-profile/index.js +25 -8
  45. package/dist/risk-profile/index.js.map +1 -1
  46. package/dist/risk-profile/index.mjs +25 -9
  47. package/dist/risk-profile/index.mjs.map +1 -1
  48. package/dist/scores/index.js +7 -6
  49. package/dist/scores/index.js.map +1 -1
  50. package/dist/scores/index.mjs +7 -6
  51. package/dist/scores/index.mjs.map +1 -1
  52. package/dist/tax/index.d.mts +1 -1
  53. package/dist/tax/index.d.ts +1 -1
  54. package/dist/tax/index.js +7 -6
  55. package/dist/tax/index.js.map +1 -1
  56. package/dist/tax/index.mjs +7 -6
  57. package/dist/tax/index.mjs.map +1 -1
  58. package/dist/{types-BOFaMQxI.d.mts → types-DbvVph_0.d.mts} +45 -2
  59. package/dist/{types-UGyDl1fd.d.ts → types-qXamJr2q.d.ts} +45 -2
  60. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -631,19 +631,20 @@ var BaseClient = class {
631
631
  * Handle error responses from API
632
632
  */
633
633
  handleErrorResponse(status, data, requestId) {
634
- const message = data.error || data.message || `HTTP ${status}`;
634
+ const structured = data.error && typeof data.error === "object" && !Array.isArray(data.error) ? data.error : void 0;
635
+ const message = typeof data.error === "string" && data.error || typeof structured?.message === "string" && structured.message || typeof data.message === "string" && data.message || `HTTP ${status}`;
635
636
  const createError = () => {
636
637
  switch (status) {
637
638
  case 400:
638
- return new VesantError(message, "BAD_REQUEST", 400);
639
+ return new VesantError(message, "BAD_REQUEST", 400, structured);
639
640
  case 401:
640
641
  return new AuthenticationError(message);
641
642
  case 403:
642
- return new VesantError(message, "FORBIDDEN", 403);
643
+ return new VesantError(message, "FORBIDDEN", 403, structured);
643
644
  case 404:
644
- return new VesantError(message, "NOT_FOUND", 404);
645
+ return new VesantError(message, "NOT_FOUND", 404, structured);
645
646
  case 409:
646
- return new VesantError(message, "DUPLICATE_PROFILE", 409);
647
+ return new VesantError(message, "DUPLICATE_PROFILE", 409, structured);
647
648
  case 429: {
648
649
  const retryAfter = data.retry_after || data.retryAfter;
649
650
  return new RateLimitError(retryAfter);
@@ -654,7 +655,7 @@ var BaseClient = class {
654
655
  case 504:
655
656
  return new ServiceUnavailableError(message);
656
657
  default:
657
- return new VesantError(message, "UNKNOWN_ERROR", status);
658
+ return new VesantError(message, "UNKNOWN_ERROR", status, structured);
658
659
  }
659
660
  };
660
661
  const error = createError();
@@ -1657,17 +1658,27 @@ var RiskProfileClient = class extends BaseClient {
1657
1658
  /**
1658
1659
  * Update customer profile
1659
1660
  *
1661
+ * Omitted fields keep their stored values. When the tenant has the
1662
+ * **On Account Sensitive Action** KYC trigger enabled and the update changes
1663
+ * the customer's name, date of birth or residential address, Vesant applies
1664
+ * the other fields, holds the sensitive ones and answers `202` with a
1665
+ * {@link ProfileUpdateHeldResponse} instead of the profile. Narrow with
1666
+ * {@link isProfileUpdateHeld}, then request a `profile_change` submit link.
1667
+ *
1660
1668
  * @param profileId - Profile UUID
1661
1669
  * @param updates - Fields to update
1662
- * @returns Updated customer profile
1670
+ * @returns Updated customer profile, or the held change
1663
1671
  *
1664
1672
  * @example
1665
1673
  * ```typescript
1666
- * const updated = await client.updateProfile(profileId, {
1674
+ * const result = await client.updateProfile(profileId, {
1667
1675
  * location: 'New York, USA',
1668
1676
  * location_compliance: 'compliant',
1669
1677
  * last_recorded_activity: new Date().toISOString()
1670
1678
  * });
1679
+ * if (isProfileUpdateHeld(result)) {
1680
+ * // name / DOB / address held: start KYC with trigger_event 'profile_change'
1681
+ * }
1671
1682
  * ```
1672
1683
  */
1673
1684
  async updateProfile(profileId, updates, requestOptions) {
@@ -1707,6 +1718,11 @@ var RiskProfileClient = class extends BaseClient {
1707
1718
  }
1708
1719
  };
1709
1720
 
1721
+ // src/risk-profile/types.ts
1722
+ function isProfileUpdateHeld(result) {
1723
+ return typeof result === "object" && result !== null && result.status === "kyc_required" && result.kyc_required === true;
1724
+ }
1725
+
1710
1726
  // src/compliance/block-reasons.ts
1711
1727
  var sdkReasons = {
1712
1728
  // Jurisdiction
@@ -2237,11 +2253,12 @@ var ComplianceClient = class {
2237
2253
  if (profileResult) {
2238
2254
  profile = profileResult;
2239
2255
  if (!isBlocked && this.shouldUpdateProfile(profile, geoVerification.location.city)) {
2240
- profile = await this.riskClient.updateProfile(profile.id, {
2256
+ const updated = await this.riskClient.updateProfile(profile.id, {
2241
2257
  last_recorded_activity: (/* @__PURE__ */ new Date()).toISOString(),
2242
2258
  location: `${geoVerification.location.city}, ${geoVerification.location.country}`,
2243
2259
  location_compliance: geoVerification.is_compliant ? "compliant" : "non-compliant"
2244
2260
  }, requestOptions);
2261
+ profile = isProfileUpdateHeld(updated) ? updated.profile : updated;
2245
2262
  }
2246
2263
  } else {
2247
2264
  if (this.config.autoCreateProfiles && this.config.debug) {
@@ -3187,77 +3204,24 @@ var KycClient = class extends BaseClient {
3187
3204
  }, void 0, requestOptions);
3188
3205
  }
3189
3206
  /**
3190
- * Get a KYC request by ID
3207
+ * Get a KYC record by ID
3208
+ *
3209
+ * Works with your tenant API key. Each entry in `proofs` carries a
3210
+ * short-lived `link` for downloading that document, and `reference` holds
3211
+ * your own customer reference (the `forward_reference`).
3191
3212
  *
3192
- * @param id - KYC request ID
3193
- * @returns KYC request details including proofs and alerts
3213
+ * @param id - KYC record ID (the `kyc_id` returned by `requestKycSubmitLink`)
3214
+ * @returns KYC record including proofs (with download links) and alerts
3194
3215
  *
3195
3216
  * @example
3196
3217
  * ```typescript
3197
3218
  * const kyc = await client.getKycRequest("550e8400-e29b-41d4-a716-446655440000");
3198
3219
  * console.log(`Status: ${kyc.status}, ID Verified: ${kyc.id_verified}`);
3220
+ * kyc.proofs?.forEach(proof => console.log(`${proof.type}: ${proof.link}`));
3199
3221
  * ```
3200
3222
  */
3201
3223
  async getKycRequest(id) {
3202
- return this.request(`/api/v1/kyc/requests/${id}`);
3203
- }
3204
- /**
3205
- * List KYC requests with filters and pagination
3206
- *
3207
- * @param filters - Optional filters (status, search, date range)
3208
- * @param pagination - Optional pagination (page, page_size)
3209
- * @returns Paginated list of KYC requests
3210
- *
3211
- * @example
3212
- * ```typescript
3213
- * const requests = await client.listKycRequests(
3214
- * { status: "pending", search: "john" },
3215
- * { page: 1, page_size: 20 }
3216
- * );
3217
- * console.log(`Found ${requests.total} pending requests`);
3218
- * ```
3219
- */
3220
- async listKycRequests(filters, pagination) {
3221
- const params = {};
3222
- if (filters) {
3223
- addFilterParam(params, "status", filters.status);
3224
- addSimpleParams(params, filters, ["search", "fromDate", "toDate", "sortBy", "order"]);
3225
- }
3226
- if (pagination) {
3227
- if (pagination.page) params.page = pagination.page;
3228
- if (pagination.page_size) params.limit = pagination.page_size;
3229
- }
3230
- return this.request(
3231
- `/api/v1/kyc/requests${this.buildQueryString(params)}`,
3232
- { headers: this.getUserHeaders() }
3233
- );
3234
- }
3235
- /**
3236
- * Update KYC request status (accept/decline)
3237
- *
3238
- * @param request - Status update request with reference, status, and reason
3239
- *
3240
- * @example
3241
- * ```typescript
3242
- * // Accept a KYC request
3243
- * await client.updateKycStatus({
3244
- * reference: "kyc-ref-123",
3245
- * status: "accepted",
3246
- * reason: "All documents verified successfully"
3247
- * });
3248
- *
3249
- * // Decline a KYC request
3250
- * await client.updateKycStatus({
3251
- * reference: "kyc-ref-456",
3252
- * status: "declined",
3253
- * reason: "Document expired"
3254
- * });
3255
- * ```
3256
- */
3257
- async updateKycStatus(request) {
3258
- await this.request("/api/v1/kyc/status", {
3259
- method: "PUT",
3260
- body: JSON.stringify(request),
3224
+ return this.request(`/api/v1/kyc/${encodeURIComponent(id)}`, {
3261
3225
  headers: this.getUserHeaders()
3262
3226
  });
3263
3227
  }
@@ -3289,63 +3253,28 @@ var KycClient = class extends BaseClient {
3289
3253
  /**
3290
3254
  * Get downloadable URLs for KYC proofs/documents
3291
3255
  *
3292
- * @param kycId - KYC request ID
3293
- * @returns Array of proof download URLs with expiration
3256
+ * Derived from the `proofs` of `getKycRequest`: the platform attaches a
3257
+ * short-lived download link to every proof on the KYC record, so no
3258
+ * separate endpoint is needed. Proofs without a link are omitted.
3259
+ *
3260
+ * @param kycId - KYC record ID
3261
+ * @returns Array of proof download URLs
3294
3262
  *
3295
3263
  * @example
3296
3264
  * ```typescript
3297
3265
  * const proofs = await client.getProofDownloadURLs("550e8400-e29b-41d4-a716-446655440000");
3298
3266
  * proofs.forEach(proof => {
3299
- * console.log(`${proof.type}: ${proof.url} (expires: ${proof.expires_at})`);
3267
+ * console.log(`${proof.type}: ${proof.url}`);
3300
3268
  * });
3301
3269
  * ```
3302
3270
  */
3303
3271
  async getProofDownloadURLs(kycId) {
3304
- return this.request(
3305
- `/api/v1/kyc/proofs/${kycId}`,
3306
- { headers: this.getUserHeaders() }
3307
- );
3308
- }
3309
- // ============================================================================
3310
- // KYC Overview & Statistics
3311
- // ============================================================================
3312
- /**
3313
- * Get KYC overview statistics
3314
- *
3315
- * @param fromDate - Optional start date (ISO 8601)
3316
- * @param toDate - Optional end date (ISO 8601)
3317
- * @returns KYC statistics including counts by status
3318
- *
3319
- * @example
3320
- * ```typescript
3321
- * const overview = await client.getOverview(
3322
- * "2024-01-01T00:00:00Z",
3323
- * "2024-12-31T23:59:59Z"
3324
- * );
3325
- * console.log(`Total: ${overview.total}, Pending: ${overview.pending}`);
3326
- * console.log(`Approved: ${overview.approved}, Rejected: ${overview.rejected}`);
3327
- * ```
3328
- */
3329
- async getOverview(fromDate, toDate) {
3330
- const params = {};
3331
- if (fromDate) params.fromDate = fromDate;
3332
- if (toDate) params.toDate = toDate;
3333
- return this.request(
3334
- `/api/v1/kyc/overview${this.buildQueryString(params)}`
3335
- );
3272
+ const kyc = await this.getKycRequest(kycId);
3273
+ return (kyc.proofs ?? []).filter((proof) => typeof proof.link === "string" && proof.link !== "").map((proof) => ({ id: proof.id, type: proof.type, url: proof.link }));
3336
3274
  }
3337
3275
  // ============================================================================
3338
3276
  // Alert Management
3339
3277
  // ============================================================================
3340
- /**
3341
- * Get a KYC alert by ID
3342
- *
3343
- * @param alertId - Alert ID
3344
- * @returns Alert details
3345
- */
3346
- async getAlert(alertId) {
3347
- return this.request(`/api/v1/kyc/alerts/${alertId}`);
3348
- }
3349
3278
  /**
3350
3279
  * List KYC alerts with filters and pagination
3351
3280
  *
@@ -3365,6 +3294,9 @@ var KycClient = class extends BaseClient {
3365
3294
  * );
3366
3295
  * console.log(`Found ${alerts.total} alerts`);
3367
3296
  * ```
3297
+ *
3298
+ * @remarks Works with a tenant API key and returns the alerts raised for
3299
+ * your tenant's customers.
3368
3300
  */
3369
3301
  async listAlerts(filters, pagination) {
3370
3302
  const params = {};
@@ -3384,66 +3316,15 @@ var KycClient = class extends BaseClient {
3384
3316
  `/api/v1/kyc/alerts${this.buildQueryString(params)}`
3385
3317
  );
3386
3318
  }
3387
- /**
3388
- * Update a KYC alert
3389
- *
3390
- * @param alertId - Alert ID
3391
- * @param update - Fields to update (status, assigned_for, reason, alert_type)
3392
- *
3393
- * @example
3394
- * ```typescript
3395
- * // Assign an alert
3396
- * await client.updateAlert("alert_123", {
3397
- * assigned_for: "analyst_user_id",
3398
- * status: "in_progress"
3399
- * });
3400
- *
3401
- * // Resolve an alert
3402
- * await client.updateAlert("alert_123", {
3403
- * status: "resolved",
3404
- * reason: "Customer verified via phone call"
3405
- * });
3406
- *
3407
- * // Escalate an alert
3408
- * await client.updateAlert("alert_123", {
3409
- * status: "escalated",
3410
- * assigned_for: "manager_user_id",
3411
- * reason: "Requires senior review - suspicious documents"
3412
- * });
3413
- * ```
3414
- */
3415
- async updateAlert(alertId, update) {
3416
- await this.request(`/api/v1/kyc/alerts/${alertId}`, {
3417
- method: "PUT",
3418
- body: JSON.stringify(update),
3419
- headers: this.getUserHeaders()
3420
- });
3421
- }
3422
3319
  // ============================================================================
3423
3320
  // KYC Preferences
3424
3321
  // ============================================================================
3425
- /**
3426
- * Get KYC preferences for the tenant
3427
- *
3428
- * @returns KYC preferences configuration
3429
- *
3430
- * @example
3431
- * ```typescript
3432
- * const prefs = await client.getPreferences();
3433
- * console.log(`Face verification required: ${prefs.is_face_verification_required}`);
3434
- * console.log(`Required documents: ${prefs.required_document_count}`);
3435
- * ```
3436
- */
3437
- async getPreferences() {
3438
- return this.request("/api/v1/kyc/preferences");
3439
- }
3440
3322
  /**
3441
3323
  * Update KYC preferences for the tenant
3442
3324
  *
3443
3325
  * @deprecated KYC preferences are managed in the Vesant console; the
3444
3326
  * platform exposes no update operation to the SDK, so this call always
3445
- * fails. Use `getPreferences()` to read them. This method will be removed
3446
- * in a future release.
3327
+ * fails. This method will be removed in a future release.
3447
3328
  *
3448
3329
  * @param update - Fields to update
3449
3330
  * @returns Updated preferences
@@ -3606,6 +3487,12 @@ var KYC_DECLINED_DESCRIPTIONS = {
3606
3487
  function isKycDocumentExpiredCallbackEvent(value) {
3607
3488
  return typeof value === "object" && value !== null && value.event === "kyc_document_expired";
3608
3489
  }
3490
+ function isKycStatusCallbackEvent(value) {
3491
+ return typeof value === "object" && value !== null && value.event === "kyc";
3492
+ }
3493
+ function isProfileChangeCallbackEvent(value) {
3494
+ return typeof value === "object" && value !== null && value.event === "profile_change";
3495
+ }
3609
3496
 
3610
3497
  // src/tax/client.ts
3611
3498
  var TaxClient = class extends BaseClient {
@@ -3900,6 +3787,6 @@ function isAmlBlockCallbackEvent(value) {
3900
3787
  return typeof value === "object" && value !== null && value.event === "aml" && value.block === true;
3901
3788
  }
3902
3789
 
3903
- 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, noopLogger, paginate, probeGeolocationPermission, sdkReasons, verifyWebhookSignature };
3790
+ 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, isKycStatusCallbackEvent, isProfileChangeCallbackEvent, isProfileUpdateHeld, noopLogger, paginate, probeGeolocationPermission, sdkReasons, verifyWebhookSignature };
3904
3791
  //# sourceMappingURL=index.mjs.map
3905
3792
  //# sourceMappingURL=index.mjs.map