vesant-sdk 1.7.1-dev.afc5a32 → 1.7.1-dev.c2ac5a5

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 (42) hide show
  1. package/README.md +4 -0
  2. package/dist/{client-D23KhWeh.d.mts → client-5q4whhGu.d.mts} +1 -1
  3. package/dist/{client-fy3trF2K.d.ts → client-BaUekQT8.d.ts} +32 -10
  4. package/dist/{client-B3DCAHlg.d.ts → client-DUHC-68_.d.ts} +1 -1
  5. package/dist/{client-BwXMQA2a.d.mts → client-XDEhh9VN.d.mts} +32 -10
  6. package/dist/compliance/index.d.mts +2 -2
  7. package/dist/compliance/index.d.ts +2 -2
  8. package/dist/compliance/index.js +39 -1
  9. package/dist/compliance/index.js.map +1 -1
  10. package/dist/compliance/index.mjs +39 -1
  11. package/dist/compliance/index.mjs.map +1 -1
  12. package/dist/geolocation/index.d.mts +2 -2
  13. package/dist/geolocation/index.d.ts +2 -2
  14. package/dist/geolocation/index.js +39 -1
  15. package/dist/geolocation/index.js.map +1 -1
  16. package/dist/geolocation/index.mjs +39 -1
  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 +86 -23
  21. package/dist/index.js.map +1 -1
  22. package/dist/index.mjs +86 -23
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/kyc/core.d.mts +1 -1
  25. package/dist/kyc/core.d.ts +1 -1
  26. package/dist/kyc/core.js +47 -22
  27. package/dist/kyc/core.js.map +1 -1
  28. package/dist/kyc/core.mjs +47 -22
  29. package/dist/kyc/core.mjs.map +1 -1
  30. package/dist/kyc/index.d.mts +178 -39
  31. package/dist/kyc/index.d.ts +178 -39
  32. package/dist/kyc/index.js +47 -22
  33. package/dist/kyc/index.js.map +1 -1
  34. package/dist/kyc/index.mjs +47 -22
  35. package/dist/kyc/index.mjs.map +1 -1
  36. package/dist/react.d.mts +126 -48
  37. package/dist/react.d.ts +126 -48
  38. package/dist/react.js +131 -20
  39. package/dist/react.js.map +1 -1
  40. package/dist/react.mjs +129 -21
  41. package/dist/react.mjs.map +1 -1
  42. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -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.
@@ -2921,19 +2959,27 @@ var KycClient = class extends BaseClient {
2921
2959
  *
2922
2960
  * Generates a link that the user can visit to submit their KYC documents.
2923
2961
  *
2962
+ * Pass the `trigger_event` that matches the user action so the tenant's
2963
+ * trigger preferences decide whether verification is required; inspect
2964
+ * `kyc_required` and `reason` on the response before redirecting.
2965
+ *
2924
2966
  * Optionally pass the customer's registered identity data as
2925
2967
  * `customer_data` (same shape as the geolocation `customer_data` block).
2926
2968
  * It seeds the customer's risk profile so document verification can
2927
2969
  * cross-check the submitted document against trusted reference data;
2928
2970
  * fields never overwrite data already on the profile.
2929
2971
  *
2930
- * @param request - Request containing the user ID, optional redirect URL, optional callback URL (receives POST requests), and optional customer identity data
2931
- * @returns Response containing the redirect link and KYC ID
2972
+ * The call is made once and is not retried: each request creates a new
2973
+ * KYC record and link, so a retry after a timeout would leave duplicates.
2974
+ *
2975
+ * @param request - Request containing the user ID, trigger event, optional redirect URL, optional callback URL (receives POST requests), and optional customer identity data
2976
+ * @returns Response containing the redirect link, KYC ID, `kyc_required`, `can_skip` and `reason`
2932
2977
  *
2933
2978
  * @example
2934
2979
  * ```typescript
2935
2980
  * const result = await client.requestKycSubmitLink({
2936
2981
  * user_id: "user_123",
2982
+ * trigger_event: "onboarding",
2937
2983
  * redirect_url: "https://merchant.com/kyc-complete", // optional
2938
2984
  * callback_url: "https://merchant.com/api/kyc-webhook", // optional - receives POST requests on status change
2939
2985
  * customer_data: { // optional - seeds the risk profile for document cross-checks
@@ -2946,16 +2992,17 @@ var KycClient = class extends BaseClient {
2946
2992
  * }
2947
2993
  * });
2948
2994
  *
2995
+ * if (!result.kyc_required) return proceed();
2949
2996
  * console.log(`Redirect user to: ${result.link}`);
2950
2997
  * console.log(`KYC ID: ${result.kyc_id}`);
2951
2998
  * ```
2952
2999
  */
2953
3000
  async requestKycSubmitLink(request, requestOptions) {
2954
- return this.requestWithRetry("/api/v1/kyc/request", {
3001
+ return this.request("/api/v1/kyc/request", {
2955
3002
  method: "POST",
2956
3003
  body: JSON.stringify(request),
2957
3004
  headers: this.getUserHeaders()
2958
- }, void 0, void 0, requestOptions);
3005
+ }, void 0, requestOptions);
2959
3006
  }
2960
3007
  /**
2961
3008
  * Create a Event-Based Face Verification session.
@@ -2977,9 +3024,9 @@ var KycClient = class extends BaseClient {
2977
3024
  /**
2978
3025
  * Submit a real-time face capture for an active Event-Based Face Verification session.
2979
3026
  *
2980
- * **Mobile-only.** The server rejects desktop User-Agents with HTTP
2981
- * 400 (`face capture must be completed on a mobile device`). Use the
2982
- * QR handoff from `createEventBasedFaceVerificationSession` for desktop callers.
3027
+ * Works from any device: the platform does not inspect the User-Agent.
3028
+ * `FaceCaptureModal` decides between direct capture and the QR handoff
3029
+ * on the client; custom UIs may submit from desktop or mobile alike.
2983
3030
  *
2984
3031
  * The `data` field on the response carries `retries_remaining`,
2985
3032
  * `retry_limit_exceeded`, and the reaction flags (`enforce_logout`,
@@ -3060,25 +3107,30 @@ var KycClient = class extends BaseClient {
3060
3107
  * Check KYC status for a user
3061
3108
  *
3062
3109
  * Returns the current KYC status:
3063
- * - "complete" → KYC verified, show "Continue to Login"
3064
- * - "processing" → Under review, show "Continue to Login"
3065
- * - "failed" / "declined" → Show error + retry option
3066
- * - "pending" / "in_progress" → Keep polling
3110
+ * - "accepted" / "review.pending" → verified (limited access while under review)
3111
+ * - "pending" → documents submitted, verification running: keep polling
3112
+ * - "awaiting_kyc" → nothing submitted yet; check `link_expired` before
3113
+ * re-surfacing or re-requesting the link. Never treat as in progress.
3114
+ * - "declined" → show `additional_data.declined_reasons` (fallback
3115
+ * `declined_reason`) with a retry option
3067
3116
  *
3068
- * @param request - Request containing user_id and token
3069
- * @returns Response with kyc_status and message (reason)
3117
+ * @param request - Request containing user_id and kyc_id
3118
+ * @returns Response with status, verification flags and, once terminal, the full record in `additional_data`
3070
3119
  *
3071
3120
  * @example
3072
3121
  * ```typescript
3073
3122
  * const result = await client.checkKycStatus({
3074
3123
  * user_id: "user_123",
3075
- * token: "auth_token_xyz"
3124
+ * kyc_id: "550e8400-e29b-41d4-a716-446655440000"
3076
3125
  * });
3077
3126
  *
3078
- * if (result.kyc_status === 'complete') {
3079
- * // Show "Continue to Login"
3080
- * } else if (result.kyc_status === 'failed' || result.kyc_status === 'declined') {
3127
+ * if (result.status === 'accepted' || result.status === 'review.pending') {
3128
+ * // Grant access
3129
+ * } else if (result.status === 'declined') {
3130
+ * const reasons = result.additional_data?.declined_reasons;
3081
3131
  * // Show error + retry option
3132
+ * } else if (result.status === 'awaiting_kyc') {
3133
+ * // Prompt to verify; request a new link when result.link_expired is true
3082
3134
  * } else {
3083
3135
  * // Keep polling
3084
3136
  * }
@@ -3100,7 +3152,9 @@ var KycClient = class extends BaseClient {
3100
3152
  /**
3101
3153
  * Submit a document verification request with OCR
3102
3154
  *
3103
- * Uses requestWithRetry() for automatic retry on transient failures.
3155
+ * The call is made once and is not retried: every submission is processed
3156
+ * and billed, and the platform does not replay this route from an
3157
+ * idempotency key. Retry explicitly if the request fails.
3104
3158
  *
3105
3159
  * @param request - Document verification request with documents and customer info
3106
3160
  * @returns Verification response with status and reference
@@ -3126,11 +3180,11 @@ var KycClient = class extends BaseClient {
3126
3180
  * ```
3127
3181
  */
3128
3182
  async submitVerification(request, requestOptions) {
3129
- return this.requestWithRetry("/api/v1/kyc/submit", {
3183
+ return this.request("/api/v1/kyc/submit", {
3130
3184
  method: "POST",
3131
3185
  body: JSON.stringify(request),
3132
3186
  headers: this.getUserHeaders()
3133
- }, void 0, void 0, requestOptions);
3187
+ }, void 0, requestOptions);
3134
3188
  }
3135
3189
  /**
3136
3190
  * Get a KYC request by ID
@@ -3187,14 +3241,14 @@ var KycClient = class extends BaseClient {
3187
3241
  * ```typescript
3188
3242
  * // Accept a KYC request
3189
3243
  * await client.updateKycStatus({
3190
- * reference: "shufti_ref_123",
3244
+ * reference: "kyc-ref-123",
3191
3245
  * status: "accepted",
3192
3246
  * reason: "All documents verified successfully"
3193
3247
  * });
3194
3248
  *
3195
3249
  * // Decline a KYC request
3196
3250
  * await client.updateKycStatus({
3197
- * reference: "shufti_ref_456",
3251
+ * reference: "kyc-ref-456",
3198
3252
  * status: "declined",
3199
3253
  * reason: "Document expired"
3200
3254
  * });
@@ -3210,6 +3264,10 @@ var KycClient = class extends BaseClient {
3210
3264
  /**
3211
3265
  * Request additional documents from customer
3212
3266
  *
3267
+ * @deprecated The platform does not expose this operation; the call always
3268
+ * fails. Request additional documents from the Vesant console instead.
3269
+ * This method will be removed in a future release.
3270
+ *
3213
3271
  * @param request - Request with KYC ID and document types needed
3214
3272
  *
3215
3273
  * @example
@@ -3382,6 +3440,11 @@ var KycClient = class extends BaseClient {
3382
3440
  /**
3383
3441
  * Update KYC preferences for the tenant
3384
3442
  *
3443
+ * @deprecated KYC preferences are managed in the Vesant console; the
3444
+ * 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.
3447
+ *
3385
3448
  * @param update - Fields to update
3386
3449
  * @returns Updated preferences
3387
3450
  *