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/kyc/core.mjs CHANGED
@@ -505,19 +505,20 @@ var BaseClient = class {
505
505
  * Handle error responses from API
506
506
  */
507
507
  handleErrorResponse(status, data, requestId) {
508
- const message = data.error || data.message || `HTTP ${status}`;
508
+ const structured = data.error && typeof data.error === "object" && !Array.isArray(data.error) ? data.error : void 0;
509
+ const message = typeof data.error === "string" && data.error || typeof structured?.message === "string" && structured.message || typeof data.message === "string" && data.message || `HTTP ${status}`;
509
510
  const createError = () => {
510
511
  switch (status) {
511
512
  case 400:
512
- return new VesantError(message, "BAD_REQUEST", 400);
513
+ return new VesantError(message, "BAD_REQUEST", 400, structured);
513
514
  case 401:
514
515
  return new AuthenticationError(message);
515
516
  case 403:
516
- return new VesantError(message, "FORBIDDEN", 403);
517
+ return new VesantError(message, "FORBIDDEN", 403, structured);
517
518
  case 404:
518
- return new VesantError(message, "NOT_FOUND", 404);
519
+ return new VesantError(message, "NOT_FOUND", 404, structured);
519
520
  case 409:
520
- return new VesantError(message, "DUPLICATE_PROFILE", 409);
521
+ return new VesantError(message, "DUPLICATE_PROFILE", 409, structured);
521
522
  case 429: {
522
523
  const retryAfter = data.retry_after || data.retryAfter;
523
524
  return new RateLimitError(retryAfter);
@@ -528,7 +529,7 @@ var BaseClient = class {
528
529
  case 504:
529
530
  return new ServiceUnavailableError(message);
530
531
  default:
531
- return new VesantError(message, "UNKNOWN_ERROR", status);
532
+ return new VesantError(message, "UNKNOWN_ERROR", status, structured);
532
533
  }
533
534
  };
534
535
  const error = createError();
@@ -911,74 +912,6 @@ var KycClient = class extends BaseClient {
911
912
  headers: this.getUserHeaders()
912
913
  });
913
914
  }
914
- /**
915
- * List KYC requests with filters and pagination
916
- *
917
- * @param filters - Optional filters (status, search, date range)
918
- * @param pagination - Optional pagination (page, page_size)
919
- * @returns Paginated list of KYC requests
920
- *
921
- * @example
922
- * ```typescript
923
- * const requests = await client.listKycRequests(
924
- * { status: "pending", search: "john" },
925
- * { page: 1, page_size: 20 }
926
- * );
927
- * console.log(`Found ${requests.total} pending requests`);
928
- * ```
929
- *
930
- * @remarks Console session only. This endpoint accepts a Vesant console
931
- * (dashboard login) token, not a tenant API key; called with an API key it
932
- * fails with `AuthenticationError` or a permission error.
933
- */
934
- async listKycRequests(filters, pagination) {
935
- const params = {};
936
- if (filters) {
937
- addFilterParam(params, "status", filters.status);
938
- addSimpleParams(params, filters, ["search", "fromDate", "toDate", "sortBy", "order"]);
939
- }
940
- if (pagination) {
941
- if (pagination.page) params.page = pagination.page;
942
- if (pagination.page_size) params.limit = pagination.page_size;
943
- }
944
- return this.request(
945
- `/api/v1/kyc/requests${this.buildQueryString(params)}`,
946
- { headers: this.getUserHeaders() }
947
- );
948
- }
949
- /**
950
- * Update KYC request status (accept/decline)
951
- *
952
- * @param request - Status update request with reference, status, and reason
953
- *
954
- * @example
955
- * ```typescript
956
- * // Accept a KYC request
957
- * await client.updateKycStatus({
958
- * reference: "kyc-ref-123",
959
- * status: "accepted",
960
- * reason: "All documents verified successfully"
961
- * });
962
- *
963
- * // Decline a KYC request
964
- * await client.updateKycStatus({
965
- * reference: "kyc-ref-456",
966
- * status: "declined",
967
- * reason: "Document expired"
968
- * });
969
- * ```
970
- *
971
- * @remarks Console session only. This endpoint accepts a Vesant console
972
- * (dashboard login) token, not a tenant API key; called with an API key it
973
- * fails with `AuthenticationError` or a permission error.
974
- */
975
- async updateKycStatus(request) {
976
- await this.request("/api/v1/kyc/status", {
977
- method: "PUT",
978
- body: JSON.stringify(request),
979
- headers: this.getUserHeaders()
980
- });
981
- }
982
915
  /**
983
916
  * Request additional documents from customer
984
917
  *
@@ -1027,53 +960,8 @@ var KycClient = class extends BaseClient {
1027
960
  return (kyc.proofs ?? []).filter((proof) => typeof proof.link === "string" && proof.link !== "").map((proof) => ({ id: proof.id, type: proof.type, url: proof.link }));
1028
961
  }
1029
962
  // ============================================================================
1030
- // KYC Overview & Statistics
1031
- // ============================================================================
1032
- /**
1033
- * Get KYC overview statistics
1034
- *
1035
- * @param fromDate - Optional start date (ISO 8601)
1036
- * @param toDate - Optional end date (ISO 8601)
1037
- * @returns KYC statistics including counts by status
1038
- *
1039
- * @example
1040
- * ```typescript
1041
- * const overview = await client.getOverview(
1042
- * "2024-01-01T00:00:00Z",
1043
- * "2024-12-31T23:59:59Z"
1044
- * );
1045
- * console.log(`Total: ${overview.total}, Pending: ${overview.pending}`);
1046
- * console.log(`Approved: ${overview.approved}, Rejected: ${overview.rejected}`);
1047
- * ```
1048
- *
1049
- * @remarks Console session only. This endpoint accepts a Vesant console
1050
- * (dashboard login) token, not a tenant API key; called with an API key it
1051
- * fails with `AuthenticationError` or a permission error.
1052
- */
1053
- async getOverview(fromDate, toDate) {
1054
- const params = {};
1055
- if (fromDate) params.fromDate = fromDate;
1056
- if (toDate) params.toDate = toDate;
1057
- return this.request(
1058
- `/api/v1/kyc/overview${this.buildQueryString(params)}`
1059
- );
1060
- }
1061
- // ============================================================================
1062
963
  // Alert Management
1063
964
  // ============================================================================
1064
- /**
1065
- * Get a KYC alert by ID
1066
- *
1067
- * @param alertId - Alert ID
1068
- * @returns Alert details
1069
- *
1070
- * @remarks Console session only. This endpoint accepts a Vesant console
1071
- * (dashboard login) token, not a tenant API key; called with an API key it
1072
- * fails with `AuthenticationError` or a permission error.
1073
- */
1074
- async getAlert(alertId) {
1075
- return this.request(`/api/v1/kyc/alerts/${alertId}`);
1076
- }
1077
965
  /**
1078
966
  * List KYC alerts with filters and pagination
1079
967
  *
@@ -1094,9 +982,8 @@ var KycClient = class extends BaseClient {
1094
982
  * console.log(`Found ${alerts.total} alerts`);
1095
983
  * ```
1096
984
  *
1097
- * @remarks Console session only. This endpoint accepts a Vesant console
1098
- * (dashboard login) token, not a tenant API key; called with an API key it
1099
- * fails with `AuthenticationError` or a permission error.
985
+ * @remarks Works with a tenant API key and returns the alerts raised for
986
+ * your tenant's customers.
1100
987
  */
1101
988
  async listAlerts(filters, pagination) {
1102
989
  const params = {};
@@ -1116,74 +1003,15 @@ var KycClient = class extends BaseClient {
1116
1003
  `/api/v1/kyc/alerts${this.buildQueryString(params)}`
1117
1004
  );
1118
1005
  }
1119
- /**
1120
- * Update a KYC alert
1121
- *
1122
- * @param alertId - Alert ID
1123
- * @param update - Fields to update (status, assigned_for, reason, alert_type)
1124
- *
1125
- * @example
1126
- * ```typescript
1127
- * // Assign an alert
1128
- * await client.updateAlert("alert_123", {
1129
- * assigned_for: "analyst_user_id",
1130
- * status: "in_progress"
1131
- * });
1132
- *
1133
- * // Resolve an alert
1134
- * await client.updateAlert("alert_123", {
1135
- * status: "resolved",
1136
- * reason: "Customer verified via phone call"
1137
- * });
1138
- *
1139
- * // Escalate an alert
1140
- * await client.updateAlert("alert_123", {
1141
- * status: "escalated",
1142
- * assigned_for: "manager_user_id",
1143
- * reason: "Requires senior review - suspicious documents"
1144
- * });
1145
- * ```
1146
- *
1147
- * @remarks Console session only. This endpoint accepts a Vesant console
1148
- * (dashboard login) token, not a tenant API key; called with an API key it
1149
- * fails with `AuthenticationError` or a permission error.
1150
- */
1151
- async updateAlert(alertId, update) {
1152
- await this.request(`/api/v1/kyc/alerts/${alertId}`, {
1153
- method: "PUT",
1154
- body: JSON.stringify(update),
1155
- headers: this.getUserHeaders()
1156
- });
1157
- }
1158
1006
  // ============================================================================
1159
1007
  // KYC Preferences
1160
1008
  // ============================================================================
1161
- /**
1162
- * Get KYC preferences for the tenant
1163
- *
1164
- * @returns KYC preferences configuration
1165
- *
1166
- * @example
1167
- * ```typescript
1168
- * const prefs = await client.getPreferences();
1169
- * console.log(`Face verification required: ${prefs.is_face_verification_required}`);
1170
- * console.log(`Required documents: ${prefs.required_document_count}`);
1171
- * ```
1172
- *
1173
- * @remarks Console session only. This endpoint accepts a Vesant console
1174
- * (dashboard login) token, not a tenant API key; called with an API key it
1175
- * fails with `AuthenticationError` or a permission error.
1176
- */
1177
- async getPreferences() {
1178
- return this.request("/api/v1/kyc/preferences");
1179
- }
1180
1009
  /**
1181
1010
  * Update KYC preferences for the tenant
1182
1011
  *
1183
1012
  * @deprecated KYC preferences are managed in the Vesant console; the
1184
1013
  * platform exposes no update operation to the SDK, so this call always
1185
- * fails. Use `getPreferences()` to read them. This method will be removed
1186
- * in a future release.
1014
+ * fails. This method will be removed in a future release.
1187
1015
  *
1188
1016
  * @param update - Fields to update
1189
1017
  * @returns Updated preferences