vesant-sdk 1.7.2-dev.617dd44 → 1.7.2

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.
package/dist/index.mjs CHANGED
@@ -2921,19 +2921,27 @@ var KycClient = class extends BaseClient {
2921
2921
  *
2922
2922
  * Generates a link that the user can visit to submit their KYC documents.
2923
2923
  *
2924
+ * Pass the `trigger_event` that matches the user action so the tenant's
2925
+ * trigger preferences decide whether verification is required; inspect
2926
+ * `kyc_required` and `reason` on the response before redirecting.
2927
+ *
2924
2928
  * Optionally pass the customer's registered identity data as
2925
2929
  * `customer_data` (same shape as the geolocation `customer_data` block).
2926
2930
  * It seeds the customer's risk profile so document verification can
2927
2931
  * cross-check the submitted document against trusted reference data;
2928
2932
  * fields never overwrite data already on the profile.
2929
2933
  *
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
2934
+ * The call is made once and is not retried: each request creates a new
2935
+ * KYC record and link, so a retry after a timeout would leave duplicates.
2936
+ *
2937
+ * @param request - Request containing the user ID, trigger event, optional redirect URL, optional callback URL (receives POST requests), and optional customer identity data
2938
+ * @returns Response containing the redirect link, KYC ID, `kyc_required`, `can_skip` and `reason`
2932
2939
  *
2933
2940
  * @example
2934
2941
  * ```typescript
2935
2942
  * const result = await client.requestKycSubmitLink({
2936
2943
  * user_id: "user_123",
2944
+ * trigger_event: "onboarding",
2937
2945
  * redirect_url: "https://merchant.com/kyc-complete", // optional
2938
2946
  * callback_url: "https://merchant.com/api/kyc-webhook", // optional - receives POST requests on status change
2939
2947
  * customer_data: { // optional - seeds the risk profile for document cross-checks
@@ -2946,25 +2954,25 @@ var KycClient = class extends BaseClient {
2946
2954
  * }
2947
2955
  * });
2948
2956
  *
2957
+ * if (!result.kyc_required) return proceed();
2949
2958
  * console.log(`Redirect user to: ${result.link}`);
2950
2959
  * console.log(`KYC ID: ${result.kyc_id}`);
2951
2960
  * ```
2952
2961
  */
2953
2962
  async requestKycSubmitLink(request, requestOptions) {
2954
- return this.requestWithRetry("/api/v1/kyc/request", {
2963
+ return this.request("/api/v1/kyc/request", {
2955
2964
  method: "POST",
2956
2965
  body: JSON.stringify(request),
2957
2966
  headers: this.getUserHeaders()
2958
- }, void 0, void 0, requestOptions);
2967
+ }, void 0, requestOptions);
2959
2968
  }
2960
2969
  /**
2961
2970
  * Create a Event-Based Face Verification session.
2962
2971
  *
2963
2972
  * 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.
2973
+ * - `is_required === false` → skip face verification; `reason` explains why.
2974
+ * - `verification_url` presentembed the hosted journey and poll status.
2975
+ * - `verification_url` absent → use the local camera / QR fallback.
2968
2976
  *
2969
2977
  * @param request - Reference, customer_id, event, amount (for threshold events), optional URLs.
2970
2978
  */
@@ -2978,9 +2986,9 @@ var KycClient = class extends BaseClient {
2978
2986
  /**
2979
2987
  * Submit a real-time face capture for an active Event-Based Face Verification session.
2980
2988
  *
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.
2989
+ * Works from any device: the platform does not inspect the User-Agent.
2990
+ * `FaceCaptureModal` decides between direct capture and the QR handoff
2991
+ * on the client; custom UIs may submit from desktop or mobile alike.
2984
2992
  *
2985
2993
  * The `data` field on the response carries `retries_remaining`,
2986
2994
  * `retry_limit_exceeded`, and the reaction flags (`enforce_logout`,
@@ -3011,11 +3019,28 @@ var KycClient = class extends BaseClient {
3011
3019
  headers: this.getUserHeaders()
3012
3020
  });
3013
3021
  }
3022
+ /**
3023
+ * Mint a fresh hosted verification journey for the next attempt on an
3024
+ * active session whose previous hosted-journey attempt was declined.
3025
+ * Only valid while the session is active and attempts remain; the
3026
+ * response carries the new `verification_url` to embed. Used internally
3027
+ * by `FaceCaptureModal`'s Try Again flow in hosted-journey mode.
3028
+ *
3029
+ * @param token - The session token returned by `createEventBasedFaceVerificationSession`.
3030
+ */
3031
+ async retryEventBasedFaceVerificationJourney(token) {
3032
+ return this.request("/api/v1/kyc/face/onsite/journey", {
3033
+ method: "POST",
3034
+ body: JSON.stringify({ token }),
3035
+ headers: this.getUserHeaders()
3036
+ });
3037
+ }
3014
3038
  /**
3015
3039
  * 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.
3040
+ * store as normal KYC (`kyc:session:<token>`, 15-minute TTL). The
3041
+ * Event-Based Face Verification database session still expires after
3042
+ * 10 minutes. Desktop callers poll `mobile_connected` to detect when a
3043
+ * mobile device has scanned the QR and attached.
3019
3044
  *
3020
3045
  * @param token - The session token returned by `createEventBasedFaceVerificationSession`.
3021
3046
  */
@@ -3044,25 +3069,30 @@ var KycClient = class extends BaseClient {
3044
3069
  * Check KYC status for a user
3045
3070
  *
3046
3071
  * 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
3072
+ * - "accepted" / "review.pending" → verified (limited access while under review)
3073
+ * - "pending" → documents submitted, verification running: keep polling
3074
+ * - "awaiting_kyc" nothing submitted yet; check `link_expired` before
3075
+ * re-surfacing or re-requesting the link. Never treat as in progress.
3076
+ * - "declined" → show `additional_data.declined_reasons` (fallback
3077
+ * `declined_reason`) with a retry option
3051
3078
  *
3052
- * @param request - Request containing user_id and token
3053
- * @returns Response with kyc_status and message (reason)
3079
+ * @param request - Request containing user_id and kyc_id
3080
+ * @returns Response with status, verification flags and, once terminal, the full record in `additional_data`
3054
3081
  *
3055
3082
  * @example
3056
3083
  * ```typescript
3057
3084
  * const result = await client.checkKycStatus({
3058
3085
  * user_id: "user_123",
3059
- * token: "auth_token_xyz"
3086
+ * kyc_id: "550e8400-e29b-41d4-a716-446655440000"
3060
3087
  * });
3061
3088
  *
3062
- * if (result.kyc_status === 'complete') {
3063
- * // Show "Continue to Login"
3064
- * } else if (result.kyc_status === 'failed' || result.kyc_status === 'declined') {
3089
+ * if (result.status === 'accepted' || result.status === 'review.pending') {
3090
+ * // Grant access
3091
+ * } else if (result.status === 'declined') {
3092
+ * const reasons = result.additional_data?.declined_reasons;
3065
3093
  * // Show error + retry option
3094
+ * } else if (result.status === 'awaiting_kyc') {
3095
+ * // Prompt to verify; request a new link when result.link_expired is true
3066
3096
  * } else {
3067
3097
  * // Keep polling
3068
3098
  * }
@@ -3084,7 +3114,9 @@ var KycClient = class extends BaseClient {
3084
3114
  /**
3085
3115
  * Submit a document verification request with OCR
3086
3116
  *
3087
- * Uses requestWithRetry() for automatic retry on transient failures.
3117
+ * The call is made once and is not retried: every submission is processed
3118
+ * and billed, and the platform does not replay this route from an
3119
+ * idempotency key. Retry explicitly if the request fails.
3088
3120
  *
3089
3121
  * @param request - Document verification request with documents and customer info
3090
3122
  * @returns Verification response with status and reference
@@ -3110,11 +3142,11 @@ var KycClient = class extends BaseClient {
3110
3142
  * ```
3111
3143
  */
3112
3144
  async submitVerification(request, requestOptions) {
3113
- return this.requestWithRetry("/api/v1/kyc/submit", {
3145
+ return this.request("/api/v1/kyc/submit", {
3114
3146
  method: "POST",
3115
3147
  body: JSON.stringify(request),
3116
3148
  headers: this.getUserHeaders()
3117
- }, void 0, void 0, requestOptions);
3149
+ }, void 0, requestOptions);
3118
3150
  }
3119
3151
  /**
3120
3152
  * Get a KYC request by ID
@@ -3171,14 +3203,14 @@ var KycClient = class extends BaseClient {
3171
3203
  * ```typescript
3172
3204
  * // Accept a KYC request
3173
3205
  * await client.updateKycStatus({
3174
- * reference: "shufti_ref_123",
3206
+ * reference: "kyc-ref-123",
3175
3207
  * status: "accepted",
3176
3208
  * reason: "All documents verified successfully"
3177
3209
  * });
3178
3210
  *
3179
3211
  * // Decline a KYC request
3180
3212
  * await client.updateKycStatus({
3181
- * reference: "shufti_ref_456",
3213
+ * reference: "kyc-ref-456",
3182
3214
  * status: "declined",
3183
3215
  * reason: "Document expired"
3184
3216
  * });
@@ -3194,6 +3226,10 @@ var KycClient = class extends BaseClient {
3194
3226
  /**
3195
3227
  * Request additional documents from customer
3196
3228
  *
3229
+ * @deprecated The platform does not expose this operation; the call always
3230
+ * fails. Request additional documents from the Vesant console instead.
3231
+ * This method will be removed in a future release.
3232
+ *
3197
3233
  * @param request - Request with KYC ID and document types needed
3198
3234
  *
3199
3235
  * @example
@@ -3366,6 +3402,11 @@ var KycClient = class extends BaseClient {
3366
3402
  /**
3367
3403
  * Update KYC preferences for the tenant
3368
3404
  *
3405
+ * @deprecated KYC preferences are managed in the Vesant console; the
3406
+ * platform exposes no update operation to the SDK, so this call always
3407
+ * fails. Use `getPreferences()` to read them. This method will be removed
3408
+ * in a future release.
3409
+ *
3369
3410
  * @param update - Fields to update
3370
3411
  * @returns Updated preferences
3371
3412
  *
@@ -3524,6 +3565,9 @@ var KYC_DECLINED_DESCRIPTIONS = {
3524
3565
  KYC_PROVIDER_REJECTED: "Identity verification was rejected by the verification provider",
3525
3566
  KYC_DECLINED: "Identity verification was declined"
3526
3567
  };
3568
+ function isKycDocumentExpiredCallbackEvent(value) {
3569
+ return typeof value === "object" && value !== null && value.event === "kyc_document_expired";
3570
+ }
3527
3571
 
3528
3572
  // src/tax/client.ts
3529
3573
  var TaxClient = class extends BaseClient {
@@ -3813,6 +3857,6 @@ function buildHandler(options) {
3813
3857
  return handler;
3814
3858
  }
3815
3859
 
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 };
3860
+ 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
3861
  //# sourceMappingURL=index.mjs.map
3818
3862
  //# sourceMappingURL=index.mjs.map