vesant-sdk 1.7.0 → 1.7.1-dev.096c933
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/{client-DtH2RLuy.d.ts → client-B3DCAHlg.d.ts} +2 -2
- package/dist/{client-DrjgZoH_.d.mts → client-BwXMQA2a.d.mts} +64 -42
- package/dist/{client-B0qhE2kr.d.mts → client-D23KhWeh.d.mts} +2 -2
- package/dist/{client-DF7hlMEz.d.ts → client-fy3trF2K.d.ts} +64 -42
- package/dist/{client-BolQlL5e.d.mts → client-q9fN8Hhf.d.mts} +103 -1
- package/dist/{client-BolQlL5e.d.ts → client-q9fN8Hhf.d.ts} +103 -1
- package/dist/compliance/index.d.mts +3 -3
- package/dist/compliance/index.d.ts +3 -3
- package/dist/compliance/index.js +181 -91
- package/dist/compliance/index.js.map +1 -1
- package/dist/compliance/index.mjs +181 -91
- package/dist/compliance/index.mjs.map +1 -1
- package/dist/decisions/index.d.mts +1 -1
- package/dist/decisions/index.d.ts +1 -1
- package/dist/decisions/index.js +69 -8
- package/dist/decisions/index.js.map +1 -1
- package/dist/decisions/index.mjs +69 -8
- package/dist/decisions/index.mjs.map +1 -1
- package/dist/geolocation/index.d.mts +68 -7
- package/dist/geolocation/index.d.ts +68 -7
- package/dist/geolocation/index.js +186 -91
- package/dist/geolocation/index.js.map +1 -1
- package/dist/geolocation/index.mjs +183 -92
- package/dist/geolocation/index.mjs.map +1 -1
- package/dist/index-C3zUKydT.d.mts +264 -0
- package/dist/index-DSDgS09k.d.ts +264 -0
- package/dist/index.d.mts +26 -9
- package/dist/index.d.ts +26 -9
- package/dist/index.js +354 -120
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +346 -121
- package/dist/index.mjs.map +1 -1
- package/dist/kyc/core.d.mts +1 -1
- package/dist/kyc/core.d.ts +1 -1
- package/dist/kyc/core.js +75 -14
- package/dist/kyc/core.js.map +1 -1
- package/dist/kyc/core.mjs +75 -14
- package/dist/kyc/core.mjs.map +1 -1
- package/dist/kyc/index.d.mts +24 -11
- package/dist/kyc/index.d.ts +24 -11
- package/dist/kyc/index.js +75 -14
- package/dist/kyc/index.js.map +1 -1
- package/dist/kyc/index.mjs +75 -14
- package/dist/kyc/index.mjs.map +1 -1
- package/dist/react.d.mts +7 -3
- package/dist/react.d.ts +7 -3
- package/dist/react.js +73 -33
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +73 -33
- package/dist/react.mjs.map +1 -1
- package/dist/risk-profile/index.d.mts +1 -1
- package/dist/risk-profile/index.d.ts +1 -1
- package/dist/risk-profile/index.js +69 -8
- package/dist/risk-profile/index.js.map +1 -1
- package/dist/risk-profile/index.mjs +69 -8
- package/dist/risk-profile/index.mjs.map +1 -1
- package/dist/scores/index.d.mts +1 -1
- package/dist/scores/index.d.ts +1 -1
- package/dist/scores/index.js +69 -8
- package/dist/scores/index.js.map +1 -1
- package/dist/scores/index.mjs +69 -8
- package/dist/scores/index.mjs.map +1 -1
- package/dist/tax/index.d.mts +2 -2
- package/dist/tax/index.d.ts +2 -2
- package/dist/tax/index.js +74 -10
- package/dist/tax/index.js.map +1 -1
- package/dist/tax/index.mjs +74 -10
- package/dist/tax/index.mjs.map +1 -1
- package/dist/webhooks/index.d.mts +2 -189
- package/dist/webhooks/index.d.ts +2 -189
- package/dist/webhooks/index.js +85 -21
- package/dist/webhooks/index.js.map +1 -1
- package/dist/webhooks/index.mjs +85 -22
- package/dist/webhooks/index.mjs.map +1 -1
- package/package.json +4 -1
package/dist/kyc/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { P as ProfileFilters, b as ProfileListResponse, C as CustomerProfile, a as CreateProfileRequest } from '../types-BOFaMQxI.mjs';
|
|
2
2
|
import { c as Reason, R as RiskLevel, P as PaginationParams } from '../types-CBQRNL-l.mjs';
|
|
3
|
-
import { B as BaseClient } from '../client-
|
|
3
|
+
import { B as BaseClient, R as RequestOptions } from '../client-q9fN8Hhf.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* TypeScript type definitions for Vesant KYC Service API
|
|
@@ -11,7 +11,11 @@ import { B as BaseClient } from '../client-BolQlL5e.mjs';
|
|
|
11
11
|
* - services/kyc-service/internal/handler/
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
type KycStatus =
|
|
14
|
+
type KycStatus =
|
|
15
|
+
/** Submit link issued but the customer has not submitted documents yet — not "in progress". */
|
|
16
|
+
'awaiting_kyc'
|
|
17
|
+
/** Documents submitted, verification in progress. */
|
|
18
|
+
| 'pending' | 'accepted' | 'declined' | 'review.pending' | 'unknown';
|
|
15
19
|
type KycDeclinedCode = 'KYC_DOCUMENT_EXPIRED' | 'KYC_DOCUMENT_INVALID' | 'KYC_FACE_MISMATCH' | 'KYC_AGE_REQUIREMENT' | 'KYC_DUPLICATE_IDENTITY' | 'KYC_ADDRESS_MISMATCH' | 'KYC_NAME_MISMATCH' | 'KYC_PROVIDER_REJECTED' | 'KYC_DECLINED';
|
|
16
20
|
declare const KYC_DECLINED_DESCRIPTIONS: Record<KycDeclinedCode, string>;
|
|
17
21
|
type KycAlertStatus = 'pending' | 'in_progress' | 'resolved' | 'closed' | 'escalated';
|
|
@@ -539,17 +543,22 @@ interface KycHandoffSession {
|
|
|
539
543
|
is_submitted: boolean;
|
|
540
544
|
}
|
|
541
545
|
interface CheckKycStatusRequest {
|
|
542
|
-
/**
|
|
546
|
+
/** Customer identifier. Sent for context only — the lookup is by kyc_id. */
|
|
543
547
|
user_id: string;
|
|
544
|
-
/**
|
|
548
|
+
/** The KYC request ID returned by requestKycSubmitLink; drives the status lookup. */
|
|
545
549
|
kyc_id: string;
|
|
546
550
|
}
|
|
547
551
|
/**
|
|
548
552
|
* Response from checkKycStatus. Always returns the same shape.
|
|
549
553
|
*
|
|
550
|
-
* `additional_data` is `null` when `status
|
|
551
|
-
*
|
|
552
|
-
*
|
|
554
|
+
* `additional_data` is `null` when `status` is `'awaiting_kyc'` or `'pending'`.
|
|
555
|
+
* Otherwise it contains the full KYC record including document details,
|
|
556
|
+
* proofs, and the customer's risk profile.
|
|
557
|
+
*
|
|
558
|
+
* `status === 'awaiting_kyc'` means the submit link was issued but the
|
|
559
|
+
* customer has not submitted documents — treat it as "not started", never as
|
|
560
|
+
* "in progress". Check `link_expired`: `false` → re-surface the existing
|
|
561
|
+
* link; `true` → request a fresh one via `requestKycSubmitLink`.
|
|
553
562
|
*/
|
|
554
563
|
interface CheckKycStatusResponse {
|
|
555
564
|
id: string;
|
|
@@ -578,8 +587,12 @@ interface CheckKycStatusResponse {
|
|
|
578
587
|
is_address_verification_required: boolean;
|
|
579
588
|
is_age_verification_required: boolean;
|
|
580
589
|
created_at: string;
|
|
581
|
-
/** Full KYC record with document details, proofs, and risk profile. Null when status is 'pending'. */
|
|
590
|
+
/** Full KYC record with document details, proofs, and risk profile. Null when status is 'awaiting_kyc' or 'pending'. */
|
|
582
591
|
additional_data: KycRequest | null;
|
|
592
|
+
/** Present when status is 'awaiting_kyc': whether the submit link has expired (request a new one when true). */
|
|
593
|
+
link_expired?: boolean;
|
|
594
|
+
/** Present when status is 'awaiting_kyc': the submit link's expiry time (RFC 3339). */
|
|
595
|
+
link_expires_at?: string;
|
|
583
596
|
}
|
|
584
597
|
interface RequestAdditionalDocumentsRequest {
|
|
585
598
|
/** KYC request ID */
|
|
@@ -768,7 +781,7 @@ declare class KycClient extends BaseClient {
|
|
|
768
781
|
* console.log(`KYC ID: ${result.kyc_id}`);
|
|
769
782
|
* ```
|
|
770
783
|
*/
|
|
771
|
-
requestKycSubmitLink(request: RequestKycSubmitLinkRequest): Promise<RequestKycSubmitLinkResponse>;
|
|
784
|
+
requestKycSubmitLink(request: RequestKycSubmitLinkRequest, requestOptions?: RequestOptions): Promise<RequestKycSubmitLinkResponse>;
|
|
772
785
|
/**
|
|
773
786
|
* Create a Event-Based Face Verification session.
|
|
774
787
|
*
|
|
@@ -794,7 +807,7 @@ declare class KycClient extends BaseClient {
|
|
|
794
807
|
*
|
|
795
808
|
* @param request - Token from `createEventBasedFaceVerificationSession`, plus the base64 selfie.
|
|
796
809
|
*/
|
|
797
|
-
submitEventBasedFaceVerificationSession(request: SubmitEventBasedFaceVerificationSessionRequest): Promise<EventBasedFaceVerificationCallback>;
|
|
810
|
+
submitEventBasedFaceVerificationSession(request: SubmitEventBasedFaceVerificationSessionRequest, requestOptions?: RequestOptions): Promise<EventBasedFaceVerificationCallback>;
|
|
798
811
|
/**
|
|
799
812
|
* Look up the current state of a Event-Based Face Verification session by its
|
|
800
813
|
* session token. Useful for desktop pollers waiting on the mobile handoff.
|
|
@@ -883,7 +896,7 @@ declare class KycClient extends BaseClient {
|
|
|
883
896
|
* console.log(`Verification submitted: ${result.reference}`);
|
|
884
897
|
* ```
|
|
885
898
|
*/
|
|
886
|
-
submitVerification(request: DocumentVerificationRequest): Promise<DocumentVerificationResponse>;
|
|
899
|
+
submitVerification(request: DocumentVerificationRequest, requestOptions?: RequestOptions): Promise<DocumentVerificationResponse>;
|
|
887
900
|
/**
|
|
888
901
|
* Get a KYC request by ID
|
|
889
902
|
*
|
package/dist/kyc/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { P as ProfileFilters, b as ProfileListResponse, C as CustomerProfile, a as CreateProfileRequest } from '../types-UGyDl1fd.js';
|
|
2
2
|
import { c as Reason, R as RiskLevel, P as PaginationParams } from '../types-CBQRNL-l.js';
|
|
3
|
-
import { B as BaseClient } from '../client-
|
|
3
|
+
import { B as BaseClient, R as RequestOptions } from '../client-q9fN8Hhf.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* TypeScript type definitions for Vesant KYC Service API
|
|
@@ -11,7 +11,11 @@ import { B as BaseClient } from '../client-BolQlL5e.js';
|
|
|
11
11
|
* - services/kyc-service/internal/handler/
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
type KycStatus =
|
|
14
|
+
type KycStatus =
|
|
15
|
+
/** Submit link issued but the customer has not submitted documents yet — not "in progress". */
|
|
16
|
+
'awaiting_kyc'
|
|
17
|
+
/** Documents submitted, verification in progress. */
|
|
18
|
+
| 'pending' | 'accepted' | 'declined' | 'review.pending' | 'unknown';
|
|
15
19
|
type KycDeclinedCode = 'KYC_DOCUMENT_EXPIRED' | 'KYC_DOCUMENT_INVALID' | 'KYC_FACE_MISMATCH' | 'KYC_AGE_REQUIREMENT' | 'KYC_DUPLICATE_IDENTITY' | 'KYC_ADDRESS_MISMATCH' | 'KYC_NAME_MISMATCH' | 'KYC_PROVIDER_REJECTED' | 'KYC_DECLINED';
|
|
16
20
|
declare const KYC_DECLINED_DESCRIPTIONS: Record<KycDeclinedCode, string>;
|
|
17
21
|
type KycAlertStatus = 'pending' | 'in_progress' | 'resolved' | 'closed' | 'escalated';
|
|
@@ -539,17 +543,22 @@ interface KycHandoffSession {
|
|
|
539
543
|
is_submitted: boolean;
|
|
540
544
|
}
|
|
541
545
|
interface CheckKycStatusRequest {
|
|
542
|
-
/**
|
|
546
|
+
/** Customer identifier. Sent for context only — the lookup is by kyc_id. */
|
|
543
547
|
user_id: string;
|
|
544
|
-
/**
|
|
548
|
+
/** The KYC request ID returned by requestKycSubmitLink; drives the status lookup. */
|
|
545
549
|
kyc_id: string;
|
|
546
550
|
}
|
|
547
551
|
/**
|
|
548
552
|
* Response from checkKycStatus. Always returns the same shape.
|
|
549
553
|
*
|
|
550
|
-
* `additional_data` is `null` when `status
|
|
551
|
-
*
|
|
552
|
-
*
|
|
554
|
+
* `additional_data` is `null` when `status` is `'awaiting_kyc'` or `'pending'`.
|
|
555
|
+
* Otherwise it contains the full KYC record including document details,
|
|
556
|
+
* proofs, and the customer's risk profile.
|
|
557
|
+
*
|
|
558
|
+
* `status === 'awaiting_kyc'` means the submit link was issued but the
|
|
559
|
+
* customer has not submitted documents — treat it as "not started", never as
|
|
560
|
+
* "in progress". Check `link_expired`: `false` → re-surface the existing
|
|
561
|
+
* link; `true` → request a fresh one via `requestKycSubmitLink`.
|
|
553
562
|
*/
|
|
554
563
|
interface CheckKycStatusResponse {
|
|
555
564
|
id: string;
|
|
@@ -578,8 +587,12 @@ interface CheckKycStatusResponse {
|
|
|
578
587
|
is_address_verification_required: boolean;
|
|
579
588
|
is_age_verification_required: boolean;
|
|
580
589
|
created_at: string;
|
|
581
|
-
/** Full KYC record with document details, proofs, and risk profile. Null when status is 'pending'. */
|
|
590
|
+
/** Full KYC record with document details, proofs, and risk profile. Null when status is 'awaiting_kyc' or 'pending'. */
|
|
582
591
|
additional_data: KycRequest | null;
|
|
592
|
+
/** Present when status is 'awaiting_kyc': whether the submit link has expired (request a new one when true). */
|
|
593
|
+
link_expired?: boolean;
|
|
594
|
+
/** Present when status is 'awaiting_kyc': the submit link's expiry time (RFC 3339). */
|
|
595
|
+
link_expires_at?: string;
|
|
583
596
|
}
|
|
584
597
|
interface RequestAdditionalDocumentsRequest {
|
|
585
598
|
/** KYC request ID */
|
|
@@ -768,7 +781,7 @@ declare class KycClient extends BaseClient {
|
|
|
768
781
|
* console.log(`KYC ID: ${result.kyc_id}`);
|
|
769
782
|
* ```
|
|
770
783
|
*/
|
|
771
|
-
requestKycSubmitLink(request: RequestKycSubmitLinkRequest): Promise<RequestKycSubmitLinkResponse>;
|
|
784
|
+
requestKycSubmitLink(request: RequestKycSubmitLinkRequest, requestOptions?: RequestOptions): Promise<RequestKycSubmitLinkResponse>;
|
|
772
785
|
/**
|
|
773
786
|
* Create a Event-Based Face Verification session.
|
|
774
787
|
*
|
|
@@ -794,7 +807,7 @@ declare class KycClient extends BaseClient {
|
|
|
794
807
|
*
|
|
795
808
|
* @param request - Token from `createEventBasedFaceVerificationSession`, plus the base64 selfie.
|
|
796
809
|
*/
|
|
797
|
-
submitEventBasedFaceVerificationSession(request: SubmitEventBasedFaceVerificationSessionRequest): Promise<EventBasedFaceVerificationCallback>;
|
|
810
|
+
submitEventBasedFaceVerificationSession(request: SubmitEventBasedFaceVerificationSessionRequest, requestOptions?: RequestOptions): Promise<EventBasedFaceVerificationCallback>;
|
|
798
811
|
/**
|
|
799
812
|
* Look up the current state of a Event-Based Face Verification session by its
|
|
800
813
|
* session token. Useful for desktop pollers waiting on the mobile handoff.
|
|
@@ -883,7 +896,7 @@ declare class KycClient extends BaseClient {
|
|
|
883
896
|
* console.log(`Verification submitted: ${result.reference}`);
|
|
884
897
|
* ```
|
|
885
898
|
*/
|
|
886
|
-
submitVerification(request: DocumentVerificationRequest): Promise<DocumentVerificationResponse>;
|
|
899
|
+
submitVerification(request: DocumentVerificationRequest, requestOptions?: RequestOptions): Promise<DocumentVerificationResponse>;
|
|
887
900
|
/**
|
|
888
901
|
* Get a KYC request by ID
|
|
889
902
|
*
|
package/dist/kyc/index.js
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
// src/core/auth.ts
|
|
4
|
+
var StaticApiKeyProvider = class {
|
|
5
|
+
constructor(apiKey) {
|
|
6
|
+
this.apiKey = apiKey;
|
|
7
|
+
}
|
|
8
|
+
async getCredential() {
|
|
9
|
+
return this.apiKey ? { scheme: "Bearer", token: this.apiKey } : null;
|
|
10
|
+
}
|
|
11
|
+
canRefresh() {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
3
16
|
// src/core/errors.ts
|
|
4
17
|
var VesantError = class _VesantError extends Error {
|
|
5
18
|
constructor(message, code, statusCode, details) {
|
|
@@ -216,7 +229,7 @@ function createConsoleLogger() {
|
|
|
216
229
|
}
|
|
217
230
|
|
|
218
231
|
// src/core/version.ts
|
|
219
|
-
var SDK_VERSION = "1.7.
|
|
232
|
+
var SDK_VERSION = "1.7.1";
|
|
220
233
|
|
|
221
234
|
// src/shared/browser-utils.ts
|
|
222
235
|
function generateUUID() {
|
|
@@ -241,6 +254,12 @@ var BaseClient = class {
|
|
|
241
254
|
if (!config.tenantId?.trim()) {
|
|
242
255
|
throw new ValidationError("tenantId is required and must be a non-empty string", ["tenantId"]);
|
|
243
256
|
}
|
|
257
|
+
if (typeof fetch === "undefined") {
|
|
258
|
+
throw new VesantError(
|
|
259
|
+
"The Vesant SDK requires a global fetch (Node.js >= 18). Upgrade Node or provide a fetch polyfill.",
|
|
260
|
+
"RUNTIME_UNSUPPORTED"
|
|
261
|
+
);
|
|
262
|
+
}
|
|
244
263
|
this.interceptors = config.interceptors || [];
|
|
245
264
|
this.logger = config.logger || createConsoleLogger();
|
|
246
265
|
let environment = config.environment;
|
|
@@ -259,11 +278,12 @@ var BaseClient = class {
|
|
|
259
278
|
environment,
|
|
260
279
|
headers: config.headers || {},
|
|
261
280
|
timeout: config.timeout || 1e4,
|
|
262
|
-
retries: config.retries
|
|
281
|
+
retries: config.retries ?? 3,
|
|
263
282
|
debug: config.debug || false,
|
|
264
283
|
interceptors: this.interceptors,
|
|
265
284
|
logger: this.logger
|
|
266
285
|
};
|
|
286
|
+
this.authProvider = config.authProvider ?? (apiKey ? new StaticApiKeyProvider(apiKey) : void 0);
|
|
267
287
|
if (config.circuitBreaker) {
|
|
268
288
|
this.circuitBreaker = new CircuitBreaker(config.circuitBreaker);
|
|
269
289
|
}
|
|
@@ -271,6 +291,19 @@ var BaseClient = class {
|
|
|
271
291
|
this.rateLimitTracker = new RateLimitTracker();
|
|
272
292
|
}
|
|
273
293
|
}
|
|
294
|
+
/**
|
|
295
|
+
* Resolve the Idempotency-Key for a request. Mutating methods (POST/PUT/PATCH)
|
|
296
|
+
* get the caller-supplied key or a freshly minted UUID; non-mutating methods get
|
|
297
|
+
* none. requestWithRetry resolves this once and injects it so every retry reuses
|
|
298
|
+
* one key (letting the server dedup replays); a direct request() resolves per call.
|
|
299
|
+
*/
|
|
300
|
+
resolveIdempotencyKey(method, requestOptions) {
|
|
301
|
+
const isMutating = ["POST", "PUT", "PATCH"].includes((method || "GET").toUpperCase());
|
|
302
|
+
if (!isMutating) {
|
|
303
|
+
return void 0;
|
|
304
|
+
}
|
|
305
|
+
return requestOptions?.idempotencyKey ?? generateUUID();
|
|
306
|
+
}
|
|
274
307
|
/**
|
|
275
308
|
* Make an HTTP request with timeout and error handling
|
|
276
309
|
*/
|
|
@@ -296,15 +329,20 @@ var BaseClient = class {
|
|
|
296
329
|
...this.config.headers,
|
|
297
330
|
...options.headers || {}
|
|
298
331
|
};
|
|
299
|
-
|
|
300
|
-
|
|
332
|
+
const credential = await this.authProvider?.getCredential({
|
|
333
|
+
tenantId: this.config.tenantId,
|
|
334
|
+
requestId
|
|
335
|
+
});
|
|
336
|
+
if (credential) {
|
|
337
|
+
headers["Authorization"] = `${credential.scheme ?? "Bearer"} ${credential.token}`;
|
|
301
338
|
}
|
|
302
339
|
if (this.config.environment === "sandbox") {
|
|
303
340
|
headers["X-Sandbox"] = "true";
|
|
304
341
|
}
|
|
305
342
|
const method = (options.method || "GET").toUpperCase();
|
|
306
|
-
|
|
307
|
-
|
|
343
|
+
const idempotencyKey = this.resolveIdempotencyKey(method, requestOptions);
|
|
344
|
+
if (idempotencyKey) {
|
|
345
|
+
headers["Idempotency-Key"] = idempotencyKey;
|
|
308
346
|
}
|
|
309
347
|
const controller = new AbortController();
|
|
310
348
|
const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
|
|
@@ -325,10 +363,28 @@ var BaseClient = class {
|
|
|
325
363
|
if (this.config.debug) {
|
|
326
364
|
this.logger.debug(`${finalOptions.method || "GET"} ${endpoint}`);
|
|
327
365
|
}
|
|
328
|
-
|
|
366
|
+
let response = await fetch(url, {
|
|
329
367
|
...finalOptions,
|
|
330
368
|
signal: controller.signal
|
|
331
369
|
});
|
|
370
|
+
if (response.status === 401 && this.authProvider?.canRefresh?.()) {
|
|
371
|
+
const refreshed = await this.authProvider.getCredential({
|
|
372
|
+
tenantId: this.config.tenantId,
|
|
373
|
+
requestId,
|
|
374
|
+
forceRefresh: true
|
|
375
|
+
});
|
|
376
|
+
if (refreshed) {
|
|
377
|
+
this.config.onCredentialRotated?.({ reason: "unauthorized" });
|
|
378
|
+
finalOptions = {
|
|
379
|
+
...finalOptions,
|
|
380
|
+
headers: {
|
|
381
|
+
...finalOptions.headers,
|
|
382
|
+
Authorization: `${refreshed.scheme ?? "Bearer"} ${refreshed.token}`
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
response = await fetch(url, { ...finalOptions, signal: controller.signal });
|
|
386
|
+
}
|
|
387
|
+
}
|
|
332
388
|
clearTimeout(timeoutId);
|
|
333
389
|
if (this.rateLimitTracker) {
|
|
334
390
|
this.rateLimitTracker.updateFromHeaders(response.headers);
|
|
@@ -417,9 +473,11 @@ var BaseClient = class {
|
|
|
417
473
|
*/
|
|
418
474
|
async requestWithRetry(endpoint, options = {}, serviceURL, retries = this.config.retries, requestOptions) {
|
|
419
475
|
let lastError;
|
|
476
|
+
const idempotencyKey = this.resolveIdempotencyKey(options.method || "GET", requestOptions);
|
|
477
|
+
const attemptOptions = idempotencyKey ? { ...requestOptions, idempotencyKey } : requestOptions;
|
|
420
478
|
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
421
479
|
try {
|
|
422
|
-
return await this.request(endpoint, options, serviceURL,
|
|
480
|
+
return await this.request(endpoint, options, serviceURL, attemptOptions);
|
|
423
481
|
} catch (error) {
|
|
424
482
|
lastError = error instanceof Error ? error : new Error("Unknown error");
|
|
425
483
|
if (requestOptions?.signal?.aborted) {
|
|
@@ -516,6 +574,9 @@ var BaseClient = class {
|
|
|
516
574
|
if (config.interceptors) {
|
|
517
575
|
this.interceptors = config.interceptors;
|
|
518
576
|
}
|
|
577
|
+
if (config.authProvider !== void 0 || config.apiKey !== void 0) {
|
|
578
|
+
this.authProvider = this.config.authProvider ?? (this.config.apiKey ? new StaticApiKeyProvider(this.config.apiKey) : void 0);
|
|
579
|
+
}
|
|
519
580
|
}
|
|
520
581
|
/**
|
|
521
582
|
* Get current configuration (readonly)
|
|
@@ -632,12 +693,12 @@ var KycClient = class extends BaseClient {
|
|
|
632
693
|
* console.log(`KYC ID: ${result.kyc_id}`);
|
|
633
694
|
* ```
|
|
634
695
|
*/
|
|
635
|
-
async requestKycSubmitLink(request) {
|
|
696
|
+
async requestKycSubmitLink(request, requestOptions) {
|
|
636
697
|
return this.requestWithRetry("/api/v1/kyc/request", {
|
|
637
698
|
method: "POST",
|
|
638
699
|
body: JSON.stringify(request),
|
|
639
700
|
headers: this.getUserHeaders()
|
|
640
|
-
});
|
|
701
|
+
}, void 0, void 0, requestOptions);
|
|
641
702
|
}
|
|
642
703
|
/**
|
|
643
704
|
* Create a Event-Based Face Verification session.
|
|
@@ -670,12 +731,12 @@ var KycClient = class extends BaseClient {
|
|
|
670
731
|
*
|
|
671
732
|
* @param request - Token from `createEventBasedFaceVerificationSession`, plus the base64 selfie.
|
|
672
733
|
*/
|
|
673
|
-
async submitEventBasedFaceVerificationSession(request) {
|
|
734
|
+
async submitEventBasedFaceVerificationSession(request, requestOptions) {
|
|
674
735
|
return this.request("/api/v1/kyc/face/submit", {
|
|
675
736
|
method: "POST",
|
|
676
737
|
body: JSON.stringify(request),
|
|
677
738
|
headers: this.getUserHeaders()
|
|
678
|
-
});
|
|
739
|
+
}, void 0, requestOptions);
|
|
679
740
|
}
|
|
680
741
|
/**
|
|
681
742
|
* Look up the current state of a Event-Based Face Verification session by its
|
|
@@ -791,12 +852,12 @@ var KycClient = class extends BaseClient {
|
|
|
791
852
|
* console.log(`Verification submitted: ${result.reference}`);
|
|
792
853
|
* ```
|
|
793
854
|
*/
|
|
794
|
-
async submitVerification(request) {
|
|
855
|
+
async submitVerification(request, requestOptions) {
|
|
795
856
|
return this.requestWithRetry("/api/v1/kyc/submit", {
|
|
796
857
|
method: "POST",
|
|
797
858
|
body: JSON.stringify(request),
|
|
798
859
|
headers: this.getUserHeaders()
|
|
799
|
-
});
|
|
860
|
+
}, void 0, void 0, requestOptions);
|
|
800
861
|
}
|
|
801
862
|
/**
|
|
802
863
|
* Get a KYC request by ID
|