vesant-sdk 1.7.2-dev.617dd44 → 1.7.2-dev.846d9c3

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 +113 -30
  21. package/dist/index.js.map +1 -1
  22. package/dist/index.mjs +113 -31
  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 +74 -29
  27. package/dist/kyc/core.js.map +1 -1
  28. package/dist/kyc/core.mjs +74 -30
  29. package/dist/kyc/core.mjs.map +1 -1
  30. package/dist/kyc/index.d.mts +334 -65
  31. package/dist/kyc/index.d.ts +334 -65
  32. package/dist/kyc/index.js +74 -29
  33. package/dist/kyc/index.js.map +1 -1
  34. package/dist/kyc/index.mjs +74 -30
  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 +257 -35
  39. package/dist/react.js.map +1 -1
  40. package/dist/react.mjs +255 -36
  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,25 +2992,25 @@ 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.
2962
3009
  *
2963
3010
  * Inspect the response before showing UI:
2964
- * - `is_required === false` → skip face capture; `reason` explains why.
2965
- * - `device_type === 'desktop'` render `qr_payload` as a QR; the
2966
- * mobile device picks up the session via the connect endpoint.
2967
- * - `device_type === 'mobile'` → open the face capture modal directly.
3011
+ * - `is_required === false` → skip face verification; `reason` explains why.
3012
+ * - `verification_url` presentembed the hosted journey and poll status.
3013
+ * - `verification_url` absent → use the local camera / QR fallback.
2968
3014
  *
2969
3015
  * @param request - Reference, customer_id, event, amount (for threshold events), optional URLs.
2970
3016
  */
@@ -2978,9 +3024,9 @@ var KycClient = class extends BaseClient {
2978
3024
  /**
2979
3025
  * Submit a real-time face capture for an active Event-Based Face Verification session.
2980
3026
  *
2981
- * **Mobile-only.** The server rejects desktop User-Agents with HTTP
2982
- * 400 (`face capture must be completed on a mobile device`). Use the
2983
- * 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.
2984
3030
  *
2985
3031
  * The `data` field on the response carries `retries_remaining`,
2986
3032
  * `retry_limit_exceeded`, and the reaction flags (`enforce_logout`,
@@ -3011,11 +3057,28 @@ var KycClient = class extends BaseClient {
3011
3057
  headers: this.getUserHeaders()
3012
3058
  });
3013
3059
  }
3060
+ /**
3061
+ * Mint a fresh hosted verification journey for the next attempt on an
3062
+ * active session whose previous hosted-journey attempt was declined.
3063
+ * Only valid while the session is active and attempts remain; the
3064
+ * response carries the new `verification_url` to embed. Used internally
3065
+ * by `FaceCaptureModal`'s Try Again flow in hosted-journey mode.
3066
+ *
3067
+ * @param token - The session token returned by `createEventBasedFaceVerificationSession`.
3068
+ */
3069
+ async retryEventBasedFaceVerificationJourney(token) {
3070
+ return this.request("/api/v1/kyc/face/onsite/journey", {
3071
+ method: "POST",
3072
+ body: JSON.stringify({ token }),
3073
+ headers: this.getUserHeaders()
3074
+ });
3075
+ }
3014
3076
  /**
3015
3077
  * Fetch the Redis-backed handoff session for a token. Same backing
3016
- * store as normal KYC (`kyc:session:<token>`, 15-minute TTL). Desktop
3017
- * callers poll `mobile_connected` to detect when a mobile device has
3018
- * scanned the QR and attached.
3078
+ * store as normal KYC (`kyc:session:<token>`, 15-minute TTL). The
3079
+ * Event-Based Face Verification database session still expires after
3080
+ * 10 minutes. Desktop callers poll `mobile_connected` to detect when a
3081
+ * mobile device has scanned the QR and attached.
3019
3082
  *
3020
3083
  * @param token - The session token returned by `createEventBasedFaceVerificationSession`.
3021
3084
  */
@@ -3044,25 +3107,30 @@ var KycClient = class extends BaseClient {
3044
3107
  * Check KYC status for a user
3045
3108
  *
3046
3109
  * Returns the current KYC status:
3047
- * - "complete" → KYC verified, show "Continue to Login"
3048
- * - "processing" → Under review, show "Continue to Login"
3049
- * - "failed" / "declined" Show error + retry option
3050
- * - "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
3051
3116
  *
3052
- * @param request - Request containing user_id and token
3053
- * @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`
3054
3119
  *
3055
3120
  * @example
3056
3121
  * ```typescript
3057
3122
  * const result = await client.checkKycStatus({
3058
3123
  * user_id: "user_123",
3059
- * token: "auth_token_xyz"
3124
+ * kyc_id: "550e8400-e29b-41d4-a716-446655440000"
3060
3125
  * });
3061
3126
  *
3062
- * if (result.kyc_status === 'complete') {
3063
- * // Show "Continue to Login"
3064
- * } 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;
3065
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
3066
3134
  * } else {
3067
3135
  * // Keep polling
3068
3136
  * }
@@ -3084,7 +3152,9 @@ var KycClient = class extends BaseClient {
3084
3152
  /**
3085
3153
  * Submit a document verification request with OCR
3086
3154
  *
3087
- * 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.
3088
3158
  *
3089
3159
  * @param request - Document verification request with documents and customer info
3090
3160
  * @returns Verification response with status and reference
@@ -3110,11 +3180,11 @@ var KycClient = class extends BaseClient {
3110
3180
  * ```
3111
3181
  */
3112
3182
  async submitVerification(request, requestOptions) {
3113
- return this.requestWithRetry("/api/v1/kyc/submit", {
3183
+ return this.request("/api/v1/kyc/submit", {
3114
3184
  method: "POST",
3115
3185
  body: JSON.stringify(request),
3116
3186
  headers: this.getUserHeaders()
3117
- }, void 0, void 0, requestOptions);
3187
+ }, void 0, requestOptions);
3118
3188
  }
3119
3189
  /**
3120
3190
  * Get a KYC request by ID
@@ -3171,14 +3241,14 @@ var KycClient = class extends BaseClient {
3171
3241
  * ```typescript
3172
3242
  * // Accept a KYC request
3173
3243
  * await client.updateKycStatus({
3174
- * reference: "shufti_ref_123",
3244
+ * reference: "kyc-ref-123",
3175
3245
  * status: "accepted",
3176
3246
  * reason: "All documents verified successfully"
3177
3247
  * });
3178
3248
  *
3179
3249
  * // Decline a KYC request
3180
3250
  * await client.updateKycStatus({
3181
- * reference: "shufti_ref_456",
3251
+ * reference: "kyc-ref-456",
3182
3252
  * status: "declined",
3183
3253
  * reason: "Document expired"
3184
3254
  * });
@@ -3194,6 +3264,10 @@ var KycClient = class extends BaseClient {
3194
3264
  /**
3195
3265
  * Request additional documents from customer
3196
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
+ *
3197
3271
  * @param request - Request with KYC ID and document types needed
3198
3272
  *
3199
3273
  * @example
@@ -3366,6 +3440,11 @@ var KycClient = class extends BaseClient {
3366
3440
  /**
3367
3441
  * Update KYC preferences for the tenant
3368
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
+ *
3369
3448
  * @param update - Fields to update
3370
3449
  * @returns Updated preferences
3371
3450
  *
@@ -3524,6 +3603,9 @@ var KYC_DECLINED_DESCRIPTIONS = {
3524
3603
  KYC_PROVIDER_REJECTED: "Identity verification was rejected by the verification provider",
3525
3604
  KYC_DECLINED: "Identity verification was declined"
3526
3605
  };
3606
+ function isKycDocumentExpiredCallbackEvent(value) {
3607
+ return typeof value === "object" && value !== null && value.event === "kyc_document_expired";
3608
+ }
3527
3609
 
3528
3610
  // src/tax/client.ts
3529
3611
  var TaxClient = class extends BaseClient {
@@ -3813,6 +3895,6 @@ function buildHandler(options) {
3813
3895
  return handler;
3814
3896
  }
3815
3897
 
3816
- 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, noopLogger, paginate, probeGeolocationPermission, sdkReasons, verifyWebhookSignature };
3898
+ 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 };
3817
3899
  //# sourceMappingURL=index.mjs.map
3818
3900
  //# sourceMappingURL=index.mjs.map