vesant-sdk 1.8.0-dev.d4d3b0d → 1.8.0-dev.d8b25c5

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 (50) hide show
  1. package/README.md +1 -3
  2. package/dist/compliance/index.js +7 -6
  3. package/dist/compliance/index.js.map +1 -1
  4. package/dist/compliance/index.mjs +7 -6
  5. package/dist/compliance/index.mjs.map +1 -1
  6. package/dist/decisions/index.js +7 -6
  7. package/dist/decisions/index.js.map +1 -1
  8. package/dist/decisions/index.mjs +7 -6
  9. package/dist/decisions/index.mjs.map +1 -1
  10. package/dist/geolocation/index.js +7 -6
  11. package/dist/geolocation/index.js.map +1 -1
  12. package/dist/geolocation/index.mjs +7 -6
  13. package/dist/geolocation/index.mjs.map +1 -1
  14. package/dist/index.d.mts +1 -1
  15. package/dist/index.d.ts +1 -1
  16. package/dist/index.js +10 -182
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +10 -182
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/kyc/core.d.mts +1 -1
  21. package/dist/kyc/core.d.ts +1 -1
  22. package/dist/kyc/core.js +10 -182
  23. package/dist/kyc/core.js.map +1 -1
  24. package/dist/kyc/core.mjs +10 -182
  25. package/dist/kyc/core.mjs.map +1 -1
  26. package/dist/kyc/index.d.mts +4 -204
  27. package/dist/kyc/index.d.ts +4 -204
  28. package/dist/kyc/index.js +10 -182
  29. package/dist/kyc/index.js.map +1 -1
  30. package/dist/kyc/index.mjs +10 -182
  31. package/dist/kyc/index.mjs.map +1 -1
  32. package/dist/react.d.mts +4 -120
  33. package/dist/react.d.ts +4 -120
  34. package/dist/react.js +0 -185
  35. package/dist/react.js.map +1 -1
  36. package/dist/react.mjs +1 -183
  37. package/dist/react.mjs.map +1 -1
  38. package/dist/risk-profile/index.js +7 -6
  39. package/dist/risk-profile/index.js.map +1 -1
  40. package/dist/risk-profile/index.mjs +7 -6
  41. package/dist/risk-profile/index.mjs.map +1 -1
  42. package/dist/scores/index.js +7 -6
  43. package/dist/scores/index.js.map +1 -1
  44. package/dist/scores/index.mjs +7 -6
  45. package/dist/scores/index.mjs.map +1 -1
  46. package/dist/tax/index.js +7 -6
  47. package/dist/tax/index.js.map +1 -1
  48. package/dist/tax/index.mjs +7 -6
  49. package/dist/tax/index.mjs.map +1 -1
  50. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -633,19 +633,20 @@ var BaseClient = class {
633
633
  * Handle error responses from API
634
634
  */
635
635
  handleErrorResponse(status, data, requestId) {
636
- const message = data.error || data.message || `HTTP ${status}`;
636
+ const structured = data.error && typeof data.error === "object" && !Array.isArray(data.error) ? data.error : void 0;
637
+ const message = typeof data.error === "string" && data.error || typeof structured?.message === "string" && structured.message || typeof data.message === "string" && data.message || `HTTP ${status}`;
637
638
  const createError = () => {
638
639
  switch (status) {
639
640
  case 400:
640
- return new VesantError(message, "BAD_REQUEST", 400);
641
+ return new VesantError(message, "BAD_REQUEST", 400, structured);
641
642
  case 401:
642
643
  return new AuthenticationError(message);
643
644
  case 403:
644
- return new VesantError(message, "FORBIDDEN", 403);
645
+ return new VesantError(message, "FORBIDDEN", 403, structured);
645
646
  case 404:
646
- return new VesantError(message, "NOT_FOUND", 404);
647
+ return new VesantError(message, "NOT_FOUND", 404, structured);
647
648
  case 409:
648
- return new VesantError(message, "DUPLICATE_PROFILE", 409);
649
+ return new VesantError(message, "DUPLICATE_PROFILE", 409, structured);
649
650
  case 429: {
650
651
  const retryAfter = data.retry_after || data.retryAfter;
651
652
  return new RateLimitError(retryAfter);
@@ -656,7 +657,7 @@ var BaseClient = class {
656
657
  case 504:
657
658
  return new ServiceUnavailableError(message);
658
659
  default:
659
- return new VesantError(message, "UNKNOWN_ERROR", status);
660
+ return new VesantError(message, "UNKNOWN_ERROR", status, structured);
660
661
  }
661
662
  };
662
663
  const error = createError();
@@ -3226,74 +3227,6 @@ var KycClient = class extends BaseClient {
3226
3227
  headers: this.getUserHeaders()
3227
3228
  });
3228
3229
  }
3229
- /**
3230
- * List KYC requests with filters and pagination
3231
- *
3232
- * @param filters - Optional filters (status, search, date range)
3233
- * @param pagination - Optional pagination (page, page_size)
3234
- * @returns Paginated list of KYC requests
3235
- *
3236
- * @example
3237
- * ```typescript
3238
- * const requests = await client.listKycRequests(
3239
- * { status: "pending", search: "john" },
3240
- * { page: 1, page_size: 20 }
3241
- * );
3242
- * console.log(`Found ${requests.total} pending requests`);
3243
- * ```
3244
- *
3245
- * @remarks Console session only. This endpoint accepts a Vesant console
3246
- * (dashboard login) token, not a tenant API key; called with an API key it
3247
- * fails with `AuthenticationError` or a permission error.
3248
- */
3249
- async listKycRequests(filters, pagination) {
3250
- const params = {};
3251
- if (filters) {
3252
- addFilterParam(params, "status", filters.status);
3253
- addSimpleParams(params, filters, ["search", "fromDate", "toDate", "sortBy", "order"]);
3254
- }
3255
- if (pagination) {
3256
- if (pagination.page) params.page = pagination.page;
3257
- if (pagination.page_size) params.limit = pagination.page_size;
3258
- }
3259
- return this.request(
3260
- `/api/v1/kyc/requests${this.buildQueryString(params)}`,
3261
- { headers: this.getUserHeaders() }
3262
- );
3263
- }
3264
- /**
3265
- * Update KYC request status (accept/decline)
3266
- *
3267
- * @param request - Status update request with reference, status, and reason
3268
- *
3269
- * @example
3270
- * ```typescript
3271
- * // Accept a KYC request
3272
- * await client.updateKycStatus({
3273
- * reference: "kyc-ref-123",
3274
- * status: "accepted",
3275
- * reason: "All documents verified successfully"
3276
- * });
3277
- *
3278
- * // Decline a KYC request
3279
- * await client.updateKycStatus({
3280
- * reference: "kyc-ref-456",
3281
- * status: "declined",
3282
- * reason: "Document expired"
3283
- * });
3284
- * ```
3285
- *
3286
- * @remarks Console session only. This endpoint accepts a Vesant console
3287
- * (dashboard login) token, not a tenant API key; called with an API key it
3288
- * fails with `AuthenticationError` or a permission error.
3289
- */
3290
- async updateKycStatus(request) {
3291
- await this.request("/api/v1/kyc/status", {
3292
- method: "PUT",
3293
- body: JSON.stringify(request),
3294
- headers: this.getUserHeaders()
3295
- });
3296
- }
3297
3230
  /**
3298
3231
  * Request additional documents from customer
3299
3232
  *
@@ -3342,53 +3275,8 @@ var KycClient = class extends BaseClient {
3342
3275
  return (kyc.proofs ?? []).filter((proof) => typeof proof.link === "string" && proof.link !== "").map((proof) => ({ id: proof.id, type: proof.type, url: proof.link }));
3343
3276
  }
3344
3277
  // ============================================================================
3345
- // KYC Overview & Statistics
3346
- // ============================================================================
3347
- /**
3348
- * Get KYC overview statistics
3349
- *
3350
- * @param fromDate - Optional start date (ISO 8601)
3351
- * @param toDate - Optional end date (ISO 8601)
3352
- * @returns KYC statistics including counts by status
3353
- *
3354
- * @example
3355
- * ```typescript
3356
- * const overview = await client.getOverview(
3357
- * "2024-01-01T00:00:00Z",
3358
- * "2024-12-31T23:59:59Z"
3359
- * );
3360
- * console.log(`Total: ${overview.total}, Pending: ${overview.pending}`);
3361
- * console.log(`Approved: ${overview.approved}, Rejected: ${overview.rejected}`);
3362
- * ```
3363
- *
3364
- * @remarks Console session only. This endpoint accepts a Vesant console
3365
- * (dashboard login) token, not a tenant API key; called with an API key it
3366
- * fails with `AuthenticationError` or a permission error.
3367
- */
3368
- async getOverview(fromDate, toDate) {
3369
- const params = {};
3370
- if (fromDate) params.fromDate = fromDate;
3371
- if (toDate) params.toDate = toDate;
3372
- return this.request(
3373
- `/api/v1/kyc/overview${this.buildQueryString(params)}`
3374
- );
3375
- }
3376
- // ============================================================================
3377
3278
  // Alert Management
3378
3279
  // ============================================================================
3379
- /**
3380
- * Get a KYC alert by ID
3381
- *
3382
- * @param alertId - Alert ID
3383
- * @returns Alert details
3384
- *
3385
- * @remarks Console session only. This endpoint accepts a Vesant console
3386
- * (dashboard login) token, not a tenant API key; called with an API key it
3387
- * fails with `AuthenticationError` or a permission error.
3388
- */
3389
- async getAlert(alertId) {
3390
- return this.request(`/api/v1/kyc/alerts/${alertId}`);
3391
- }
3392
3280
  /**
3393
3281
  * List KYC alerts with filters and pagination
3394
3282
  *
@@ -3409,9 +3297,8 @@ var KycClient = class extends BaseClient {
3409
3297
  * console.log(`Found ${alerts.total} alerts`);
3410
3298
  * ```
3411
3299
  *
3412
- * @remarks Console session only. This endpoint accepts a Vesant console
3413
- * (dashboard login) token, not a tenant API key; called with an API key it
3414
- * fails with `AuthenticationError` or a permission error.
3300
+ * @remarks Works with a tenant API key and returns the alerts raised for
3301
+ * your tenant's customers.
3415
3302
  */
3416
3303
  async listAlerts(filters, pagination) {
3417
3304
  const params = {};
@@ -3431,74 +3318,15 @@ var KycClient = class extends BaseClient {
3431
3318
  `/api/v1/kyc/alerts${this.buildQueryString(params)}`
3432
3319
  );
3433
3320
  }
3434
- /**
3435
- * Update a KYC alert
3436
- *
3437
- * @param alertId - Alert ID
3438
- * @param update - Fields to update (status, assigned_for, reason, alert_type)
3439
- *
3440
- * @example
3441
- * ```typescript
3442
- * // Assign an alert
3443
- * await client.updateAlert("alert_123", {
3444
- * assigned_for: "analyst_user_id",
3445
- * status: "in_progress"
3446
- * });
3447
- *
3448
- * // Resolve an alert
3449
- * await client.updateAlert("alert_123", {
3450
- * status: "resolved",
3451
- * reason: "Customer verified via phone call"
3452
- * });
3453
- *
3454
- * // Escalate an alert
3455
- * await client.updateAlert("alert_123", {
3456
- * status: "escalated",
3457
- * assigned_for: "manager_user_id",
3458
- * reason: "Requires senior review - suspicious documents"
3459
- * });
3460
- * ```
3461
- *
3462
- * @remarks Console session only. This endpoint accepts a Vesant console
3463
- * (dashboard login) token, not a tenant API key; called with an API key it
3464
- * fails with `AuthenticationError` or a permission error.
3465
- */
3466
- async updateAlert(alertId, update) {
3467
- await this.request(`/api/v1/kyc/alerts/${alertId}`, {
3468
- method: "PUT",
3469
- body: JSON.stringify(update),
3470
- headers: this.getUserHeaders()
3471
- });
3472
- }
3473
3321
  // ============================================================================
3474
3322
  // KYC Preferences
3475
3323
  // ============================================================================
3476
- /**
3477
- * Get KYC preferences for the tenant
3478
- *
3479
- * @returns KYC preferences configuration
3480
- *
3481
- * @example
3482
- * ```typescript
3483
- * const prefs = await client.getPreferences();
3484
- * console.log(`Face verification required: ${prefs.is_face_verification_required}`);
3485
- * console.log(`Required documents: ${prefs.required_document_count}`);
3486
- * ```
3487
- *
3488
- * @remarks Console session only. This endpoint accepts a Vesant console
3489
- * (dashboard login) token, not a tenant API key; called with an API key it
3490
- * fails with `AuthenticationError` or a permission error.
3491
- */
3492
- async getPreferences() {
3493
- return this.request("/api/v1/kyc/preferences");
3494
- }
3495
3324
  /**
3496
3325
  * Update KYC preferences for the tenant
3497
3326
  *
3498
3327
  * @deprecated KYC preferences are managed in the Vesant console; the
3499
3328
  * platform exposes no update operation to the SDK, so this call always
3500
- * fails. Use `getPreferences()` to read them. This method will be removed
3501
- * in a future release.
3329
+ * fails. This method will be removed in a future release.
3502
3330
  *
3503
3331
  * @param update - Fields to update
3504
3332
  * @returns Updated preferences