vesant-sdk 1.2.0 → 1.3.1
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-BWp5FI3x.d.ts → client-B6fUFAUM.d.mts} +2 -1
- package/dist/{client-BIfLMfuC.d.mts → client-DoczGA6L.d.ts} +2 -1
- package/dist/client-DzElM7u-.d.mts +238 -0
- package/dist/client-DzElM7u-.d.ts +238 -0
- package/dist/compliance/index.d.mts +5 -4
- package/dist/compliance/index.d.ts +5 -4
- package/dist/compliance/index.js +306 -98
- package/dist/compliance/index.js.map +1 -1
- package/dist/compliance/index.mjs +306 -98
- package/dist/compliance/index.mjs.map +1 -1
- package/dist/decisions/index.d.mts +100 -0
- package/dist/decisions/index.d.ts +100 -0
- package/dist/decisions/index.js +607 -0
- package/dist/decisions/index.js.map +1 -0
- package/dist/decisions/index.mjs +605 -0
- package/dist/decisions/index.mjs.map +1 -0
- package/dist/geolocation/index.d.mts +4 -3
- package/dist/geolocation/index.d.ts +4 -3
- package/dist/geolocation/index.js +306 -98
- package/dist/geolocation/index.js.map +1 -1
- package/dist/geolocation/index.mjs +306 -98
- package/dist/geolocation/index.mjs.map +1 -1
- package/dist/index.d.mts +15 -7
- package/dist/index.d.ts +15 -7
- package/dist/index.js +676 -90
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +667 -91
- package/dist/index.mjs.map +1 -1
- package/dist/kyc/core.d.mts +4 -3
- package/dist/kyc/core.d.ts +4 -3
- package/dist/kyc/core.js +284 -29
- package/dist/kyc/core.js.map +1 -1
- package/dist/kyc/core.mjs +284 -29
- package/dist/kyc/core.mjs.map +1 -1
- package/dist/kyc/index.d.mts +46 -3
- package/dist/kyc/index.d.ts +46 -3
- package/dist/kyc/index.js +284 -29
- package/dist/kyc/index.js.map +1 -1
- package/dist/kyc/index.mjs +284 -29
- package/dist/kyc/index.mjs.map +1 -1
- package/dist/react.d.mts +9 -5
- package/dist/react.d.ts +9 -5
- package/dist/react.js +422 -99
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +322 -4
- package/dist/react.mjs.map +1 -1
- package/dist/risk-profile/index.d.mts +4 -4
- package/dist/risk-profile/index.d.ts +4 -4
- package/dist/risk-profile/index.js +249 -29
- package/dist/risk-profile/index.js.map +1 -1
- package/dist/risk-profile/index.mjs +249 -29
- package/dist/risk-profile/index.mjs.map +1 -1
- package/dist/scores/index.d.mts +96 -0
- package/dist/scores/index.d.ts +96 -0
- package/dist/scores/index.js +594 -0
- package/dist/scores/index.js.map +1 -0
- package/dist/scores/index.mjs +591 -0
- package/dist/scores/index.mjs.map +1 -0
- package/dist/{types-DfHLp_tz.d.ts → types-DLC7Sfy5.d.ts} +1 -1
- package/dist/types-DZHongaK.d.mts +61 -0
- package/dist/types-DZHongaK.d.ts +61 -0
- package/dist/{types-DKCQN4C5.d.mts → types-jaLuzruy.d.mts} +1 -1
- package/dist/webhooks/index.d.mts +176 -0
- package/dist/webhooks/index.d.ts +176 -0
- package/dist/webhooks/index.js +193 -0
- package/dist/webhooks/index.js.map +1 -0
- package/dist/webhooks/index.mjs +188 -0
- package/dist/webhooks/index.mjs.map +1 -0
- package/package.json +25 -2
- package/dist/types-BpKxSXGF.d.mts +0 -177
- package/dist/types-BpKxSXGF.d.ts +0 -177
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { L as Logger, B as BaseClient, R as RequestOptions } from './client-DzElM7u-.mjs';
|
|
2
|
+
import { P as PaginationParams } from './types-DZHongaK.mjs';
|
|
2
3
|
|
|
3
4
|
interface DeviceFingerprintRequest {
|
|
4
5
|
device_id: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { L as Logger, B as BaseClient, R as RequestOptions } from './client-DzElM7u-.js';
|
|
2
|
+
import { P as PaginationParams } from './types-DZHongaK.js';
|
|
2
3
|
|
|
3
4
|
interface DeviceFingerprintRequest {
|
|
4
5
|
device_id: string;
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Circuit breaker pattern for resilient HTTP requests.
|
|
3
|
+
*
|
|
4
|
+
* States: closed (normal) -> open (failing) -> half-open (testing) -> closed
|
|
5
|
+
*/
|
|
6
|
+
type CircuitBreakerState = 'closed' | 'open' | 'half-open';
|
|
7
|
+
interface CircuitBreakerConfig {
|
|
8
|
+
/** Number of consecutive failures before opening the circuit (default: 5) */
|
|
9
|
+
failureThreshold?: number;
|
|
10
|
+
/** Time in ms to wait before transitioning from open to half-open (default: 30000) */
|
|
11
|
+
resetTimeout?: number;
|
|
12
|
+
/** Number of successes in half-open state before closing (default: 1) */
|
|
13
|
+
successThreshold?: number;
|
|
14
|
+
}
|
|
15
|
+
interface CircuitBreakerStatus {
|
|
16
|
+
state: CircuitBreakerState;
|
|
17
|
+
failures: number;
|
|
18
|
+
successes: number;
|
|
19
|
+
lastFailureTime: number | null;
|
|
20
|
+
nextRetryTime: number | null;
|
|
21
|
+
}
|
|
22
|
+
declare class CircuitBreaker {
|
|
23
|
+
private state;
|
|
24
|
+
private failures;
|
|
25
|
+
private successes;
|
|
26
|
+
private lastFailureTime;
|
|
27
|
+
private readonly failureThreshold;
|
|
28
|
+
private readonly resetTimeout;
|
|
29
|
+
private readonly successThreshold;
|
|
30
|
+
constructor(config?: CircuitBreakerConfig);
|
|
31
|
+
/**
|
|
32
|
+
* Check if a request can proceed through the circuit breaker.
|
|
33
|
+
*/
|
|
34
|
+
canExecute(): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Record a successful request.
|
|
37
|
+
*/
|
|
38
|
+
onSuccess(): void;
|
|
39
|
+
/**
|
|
40
|
+
* Record a failed request.
|
|
41
|
+
*/
|
|
42
|
+
onFailure(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Get current circuit breaker status.
|
|
45
|
+
*/
|
|
46
|
+
getStatus(): CircuitBreakerStatus;
|
|
47
|
+
/**
|
|
48
|
+
* Reset the circuit breaker to its initial closed state.
|
|
49
|
+
*/
|
|
50
|
+
reset(): void;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Configuration types for Vesant SDK clients
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
interface Logger {
|
|
58
|
+
debug(message: string, meta?: Record<string, unknown>): void;
|
|
59
|
+
info(message: string, meta?: Record<string, unknown>): void;
|
|
60
|
+
warn(message: string, meta?: Record<string, unknown>): void;
|
|
61
|
+
error(message: string, meta?: Record<string, unknown>): void;
|
|
62
|
+
}
|
|
63
|
+
interface RequestOptions {
|
|
64
|
+
signal?: AbortSignal;
|
|
65
|
+
/** Idempotency key for POST/PUT/PATCH requests */
|
|
66
|
+
idempotencyKey?: string;
|
|
67
|
+
}
|
|
68
|
+
interface RequestInterceptor {
|
|
69
|
+
/** Called before each request. Can modify headers or options. */
|
|
70
|
+
onRequest?: (url: string, options: RequestInit) => RequestInit | Promise<RequestInit>;
|
|
71
|
+
/** Called after a successful response. Can inspect or transform data. */
|
|
72
|
+
onResponse?: (url: string, data: unknown) => unknown | Promise<unknown>;
|
|
73
|
+
/** Called when a request fails. Can handle or re-throw. */
|
|
74
|
+
onError?: (url: string, error: Error) => void | Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
interface BaseClientConfig {
|
|
77
|
+
/** Base URL for the service */
|
|
78
|
+
baseURL: string;
|
|
79
|
+
/** Tenant ID for multi-tenancy */
|
|
80
|
+
tenantId: string;
|
|
81
|
+
/** Optional API key for authentication */
|
|
82
|
+
apiKey?: string;
|
|
83
|
+
/** Custom headers to include in all requests */
|
|
84
|
+
headers?: Record<string, string>;
|
|
85
|
+
/** Request timeout in milliseconds (default: 10000) */
|
|
86
|
+
timeout?: number;
|
|
87
|
+
/** Number of retry attempts (default: 3) */
|
|
88
|
+
retries?: number;
|
|
89
|
+
/** Enable debug logging (default: false) */
|
|
90
|
+
debug?: boolean;
|
|
91
|
+
/** Request/response interceptors */
|
|
92
|
+
interceptors?: RequestInterceptor[];
|
|
93
|
+
/** Custom logger instance */
|
|
94
|
+
logger?: Logger;
|
|
95
|
+
/** Environment mode (default: 'production') */
|
|
96
|
+
environment?: 'production' | 'sandbox';
|
|
97
|
+
/** Base URL to use in sandbox mode */
|
|
98
|
+
sandboxBaseURL?: string;
|
|
99
|
+
/** Circuit breaker configuration */
|
|
100
|
+
circuitBreaker?: CircuitBreakerConfig;
|
|
101
|
+
/** Enable rate limit header tracking (default: false) */
|
|
102
|
+
enableRateLimitTracking?: boolean;
|
|
103
|
+
}
|
|
104
|
+
interface CGSConfig {
|
|
105
|
+
/** Base URL for the Vesant API */
|
|
106
|
+
baseURL: string;
|
|
107
|
+
/** Tenant ID for multi-tenancy */
|
|
108
|
+
tenantId: string;
|
|
109
|
+
/** Optional API key for authentication */
|
|
110
|
+
apiKey?: string;
|
|
111
|
+
/** Custom headers to include in all requests */
|
|
112
|
+
headers?: Record<string, string>;
|
|
113
|
+
/** Request timeout in milliseconds (default: 10000) */
|
|
114
|
+
timeout?: number;
|
|
115
|
+
/** Number of retry attempts for failed requests (default: 3) */
|
|
116
|
+
retries?: number;
|
|
117
|
+
/** Enable debug logging (default: false) */
|
|
118
|
+
debug?: boolean;
|
|
119
|
+
/** Automatically create customer profiles on geolocation verification (default: true) */
|
|
120
|
+
autoCreateProfiles?: boolean;
|
|
121
|
+
/** Sync mode: 'async' uses events, 'sync' uses direct API calls (default: 'sync') */
|
|
122
|
+
syncMode?: 'async' | 'sync';
|
|
123
|
+
/** Request/response interceptors */
|
|
124
|
+
interceptors?: RequestInterceptor[];
|
|
125
|
+
/** Custom logger instance */
|
|
126
|
+
logger?: Logger;
|
|
127
|
+
/** Environment mode (default: 'production') */
|
|
128
|
+
environment?: 'production' | 'sandbox';
|
|
129
|
+
/** Base URL to use in sandbox mode */
|
|
130
|
+
sandboxBaseURL?: string;
|
|
131
|
+
/** Circuit breaker configuration */
|
|
132
|
+
circuitBreaker?: CircuitBreakerConfig;
|
|
133
|
+
/** Enable rate limit header tracking (default: false) */
|
|
134
|
+
enableRateLimitTracking?: boolean;
|
|
135
|
+
}
|
|
136
|
+
/** CGSConfig with core fields required, enterprise features remain optional */
|
|
137
|
+
type RequiredCGSConfig = Required<Pick<CGSConfig, 'baseURL' | 'tenantId' | 'apiKey' | 'headers' | 'timeout' | 'retries' | 'debug' | 'autoCreateProfiles' | 'syncMode' | 'interceptors' | 'logger'>> & Pick<CGSConfig, 'environment' | 'sandboxBaseURL' | 'circuitBreaker' | 'enableRateLimitTracking'>;
|
|
138
|
+
/** BaseClientConfig with core fields required, enterprise features remain optional */
|
|
139
|
+
type RequiredBaseClientConfig = Required<Pick<BaseClientConfig, 'baseURL' | 'tenantId' | 'apiKey' | 'headers' | 'timeout' | 'retries' | 'debug' | 'interceptors' | 'logger'>> & Pick<BaseClientConfig, 'environment' | 'sandboxBaseURL' | 'circuitBreaker' | 'enableRateLimitTracking'>;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Rate limit tracking from API response headers.
|
|
143
|
+
*
|
|
144
|
+
* Tracks X-RateLimit-* headers to enable pre-flight checks
|
|
145
|
+
* before making requests.
|
|
146
|
+
*/
|
|
147
|
+
interface RateLimitStatus {
|
|
148
|
+
/** Maximum requests allowed in the window */
|
|
149
|
+
limit: number | null;
|
|
150
|
+
/** Remaining requests in the current window */
|
|
151
|
+
remaining: number | null;
|
|
152
|
+
/** Unix timestamp (seconds) when the rate limit resets */
|
|
153
|
+
reset: number | null;
|
|
154
|
+
/** Seconds until the rate limit resets */
|
|
155
|
+
retryAfter: number | null;
|
|
156
|
+
}
|
|
157
|
+
declare class RateLimitTracker {
|
|
158
|
+
private limit;
|
|
159
|
+
private remaining;
|
|
160
|
+
private reset;
|
|
161
|
+
private retryAfter;
|
|
162
|
+
/**
|
|
163
|
+
* Extract rate limit information from response headers.
|
|
164
|
+
*/
|
|
165
|
+
updateFromHeaders(headers: Headers): void;
|
|
166
|
+
/**
|
|
167
|
+
* Check if the rate limit has been exceeded based on tracked headers.
|
|
168
|
+
*/
|
|
169
|
+
isLimitExceeded(): boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Get current rate limit status.
|
|
172
|
+
*/
|
|
173
|
+
getStatus(): RateLimitStatus;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Base HTTP client for all CGS SDK clients
|
|
178
|
+
*
|
|
179
|
+
* Provides common functionality:
|
|
180
|
+
* - Request/response handling
|
|
181
|
+
* - Error handling
|
|
182
|
+
* - Retry logic with exponential backoff
|
|
183
|
+
* - Timeout management
|
|
184
|
+
* - Debug logging
|
|
185
|
+
*/
|
|
186
|
+
|
|
187
|
+
declare abstract class BaseClient {
|
|
188
|
+
protected config: BaseClientConfig & {
|
|
189
|
+
timeout: number;
|
|
190
|
+
retries: number;
|
|
191
|
+
};
|
|
192
|
+
protected logger: Logger;
|
|
193
|
+
private interceptors;
|
|
194
|
+
private circuitBreaker;
|
|
195
|
+
private rateLimitTracker;
|
|
196
|
+
constructor(config: BaseClientConfig);
|
|
197
|
+
/**
|
|
198
|
+
* Make an HTTP request with timeout and error handling
|
|
199
|
+
*/
|
|
200
|
+
protected request<T>(endpoint: string, options?: RequestInit, serviceURL?: string, requestOptions?: RequestOptions): Promise<T>;
|
|
201
|
+
/**
|
|
202
|
+
* Make an HTTP request with retry logic
|
|
203
|
+
*/
|
|
204
|
+
protected requestWithRetry<T>(endpoint: string, options?: RequestInit, serviceURL?: string, retries?: number, requestOptions?: RequestOptions): Promise<T>;
|
|
205
|
+
/**
|
|
206
|
+
* Handle error responses from API
|
|
207
|
+
*/
|
|
208
|
+
protected handleErrorResponse(status: number, data: Record<string, unknown>, requestId?: string): never;
|
|
209
|
+
/**
|
|
210
|
+
* Build query string from parameters
|
|
211
|
+
*/
|
|
212
|
+
protected buildQueryString(params: Record<string, unknown>): string;
|
|
213
|
+
/**
|
|
214
|
+
* Update client configuration
|
|
215
|
+
*/
|
|
216
|
+
updateConfig(config: Partial<BaseClientConfig>): void;
|
|
217
|
+
/**
|
|
218
|
+
* Get current configuration (readonly)
|
|
219
|
+
*/
|
|
220
|
+
getConfig(): Readonly<BaseClientConfig>;
|
|
221
|
+
/**
|
|
222
|
+
* Get rate limit status from tracked response headers.
|
|
223
|
+
*/
|
|
224
|
+
getRateLimitStatus(): RateLimitStatus | null;
|
|
225
|
+
/**
|
|
226
|
+
* Get circuit breaker status.
|
|
227
|
+
*/
|
|
228
|
+
getCircuitBreakerStatus(): CircuitBreakerStatus | null;
|
|
229
|
+
/**
|
|
230
|
+
* Health check endpoint
|
|
231
|
+
*/
|
|
232
|
+
healthCheck(): Promise<{
|
|
233
|
+
status: string;
|
|
234
|
+
timestamp: string;
|
|
235
|
+
}>;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export { BaseClient as B, type CircuitBreakerConfig as C, type Logger as L, type RequestOptions as R, type RequestInterceptor as a, type BaseClientConfig as b, type CGSConfig as c, type RequiredCGSConfig as d, type RequiredBaseClientConfig as e, type CircuitBreakerState as f, type CircuitBreakerStatus as g, CircuitBreaker as h, type RateLimitStatus as i, RateLimitTracker as j };
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Circuit breaker pattern for resilient HTTP requests.
|
|
3
|
+
*
|
|
4
|
+
* States: closed (normal) -> open (failing) -> half-open (testing) -> closed
|
|
5
|
+
*/
|
|
6
|
+
type CircuitBreakerState = 'closed' | 'open' | 'half-open';
|
|
7
|
+
interface CircuitBreakerConfig {
|
|
8
|
+
/** Number of consecutive failures before opening the circuit (default: 5) */
|
|
9
|
+
failureThreshold?: number;
|
|
10
|
+
/** Time in ms to wait before transitioning from open to half-open (default: 30000) */
|
|
11
|
+
resetTimeout?: number;
|
|
12
|
+
/** Number of successes in half-open state before closing (default: 1) */
|
|
13
|
+
successThreshold?: number;
|
|
14
|
+
}
|
|
15
|
+
interface CircuitBreakerStatus {
|
|
16
|
+
state: CircuitBreakerState;
|
|
17
|
+
failures: number;
|
|
18
|
+
successes: number;
|
|
19
|
+
lastFailureTime: number | null;
|
|
20
|
+
nextRetryTime: number | null;
|
|
21
|
+
}
|
|
22
|
+
declare class CircuitBreaker {
|
|
23
|
+
private state;
|
|
24
|
+
private failures;
|
|
25
|
+
private successes;
|
|
26
|
+
private lastFailureTime;
|
|
27
|
+
private readonly failureThreshold;
|
|
28
|
+
private readonly resetTimeout;
|
|
29
|
+
private readonly successThreshold;
|
|
30
|
+
constructor(config?: CircuitBreakerConfig);
|
|
31
|
+
/**
|
|
32
|
+
* Check if a request can proceed through the circuit breaker.
|
|
33
|
+
*/
|
|
34
|
+
canExecute(): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Record a successful request.
|
|
37
|
+
*/
|
|
38
|
+
onSuccess(): void;
|
|
39
|
+
/**
|
|
40
|
+
* Record a failed request.
|
|
41
|
+
*/
|
|
42
|
+
onFailure(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Get current circuit breaker status.
|
|
45
|
+
*/
|
|
46
|
+
getStatus(): CircuitBreakerStatus;
|
|
47
|
+
/**
|
|
48
|
+
* Reset the circuit breaker to its initial closed state.
|
|
49
|
+
*/
|
|
50
|
+
reset(): void;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Configuration types for Vesant SDK clients
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
interface Logger {
|
|
58
|
+
debug(message: string, meta?: Record<string, unknown>): void;
|
|
59
|
+
info(message: string, meta?: Record<string, unknown>): void;
|
|
60
|
+
warn(message: string, meta?: Record<string, unknown>): void;
|
|
61
|
+
error(message: string, meta?: Record<string, unknown>): void;
|
|
62
|
+
}
|
|
63
|
+
interface RequestOptions {
|
|
64
|
+
signal?: AbortSignal;
|
|
65
|
+
/** Idempotency key for POST/PUT/PATCH requests */
|
|
66
|
+
idempotencyKey?: string;
|
|
67
|
+
}
|
|
68
|
+
interface RequestInterceptor {
|
|
69
|
+
/** Called before each request. Can modify headers or options. */
|
|
70
|
+
onRequest?: (url: string, options: RequestInit) => RequestInit | Promise<RequestInit>;
|
|
71
|
+
/** Called after a successful response. Can inspect or transform data. */
|
|
72
|
+
onResponse?: (url: string, data: unknown) => unknown | Promise<unknown>;
|
|
73
|
+
/** Called when a request fails. Can handle or re-throw. */
|
|
74
|
+
onError?: (url: string, error: Error) => void | Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
interface BaseClientConfig {
|
|
77
|
+
/** Base URL for the service */
|
|
78
|
+
baseURL: string;
|
|
79
|
+
/** Tenant ID for multi-tenancy */
|
|
80
|
+
tenantId: string;
|
|
81
|
+
/** Optional API key for authentication */
|
|
82
|
+
apiKey?: string;
|
|
83
|
+
/** Custom headers to include in all requests */
|
|
84
|
+
headers?: Record<string, string>;
|
|
85
|
+
/** Request timeout in milliseconds (default: 10000) */
|
|
86
|
+
timeout?: number;
|
|
87
|
+
/** Number of retry attempts (default: 3) */
|
|
88
|
+
retries?: number;
|
|
89
|
+
/** Enable debug logging (default: false) */
|
|
90
|
+
debug?: boolean;
|
|
91
|
+
/** Request/response interceptors */
|
|
92
|
+
interceptors?: RequestInterceptor[];
|
|
93
|
+
/** Custom logger instance */
|
|
94
|
+
logger?: Logger;
|
|
95
|
+
/** Environment mode (default: 'production') */
|
|
96
|
+
environment?: 'production' | 'sandbox';
|
|
97
|
+
/** Base URL to use in sandbox mode */
|
|
98
|
+
sandboxBaseURL?: string;
|
|
99
|
+
/** Circuit breaker configuration */
|
|
100
|
+
circuitBreaker?: CircuitBreakerConfig;
|
|
101
|
+
/** Enable rate limit header tracking (default: false) */
|
|
102
|
+
enableRateLimitTracking?: boolean;
|
|
103
|
+
}
|
|
104
|
+
interface CGSConfig {
|
|
105
|
+
/** Base URL for the Vesant API */
|
|
106
|
+
baseURL: string;
|
|
107
|
+
/** Tenant ID for multi-tenancy */
|
|
108
|
+
tenantId: string;
|
|
109
|
+
/** Optional API key for authentication */
|
|
110
|
+
apiKey?: string;
|
|
111
|
+
/** Custom headers to include in all requests */
|
|
112
|
+
headers?: Record<string, string>;
|
|
113
|
+
/** Request timeout in milliseconds (default: 10000) */
|
|
114
|
+
timeout?: number;
|
|
115
|
+
/** Number of retry attempts for failed requests (default: 3) */
|
|
116
|
+
retries?: number;
|
|
117
|
+
/** Enable debug logging (default: false) */
|
|
118
|
+
debug?: boolean;
|
|
119
|
+
/** Automatically create customer profiles on geolocation verification (default: true) */
|
|
120
|
+
autoCreateProfiles?: boolean;
|
|
121
|
+
/** Sync mode: 'async' uses events, 'sync' uses direct API calls (default: 'sync') */
|
|
122
|
+
syncMode?: 'async' | 'sync';
|
|
123
|
+
/** Request/response interceptors */
|
|
124
|
+
interceptors?: RequestInterceptor[];
|
|
125
|
+
/** Custom logger instance */
|
|
126
|
+
logger?: Logger;
|
|
127
|
+
/** Environment mode (default: 'production') */
|
|
128
|
+
environment?: 'production' | 'sandbox';
|
|
129
|
+
/** Base URL to use in sandbox mode */
|
|
130
|
+
sandboxBaseURL?: string;
|
|
131
|
+
/** Circuit breaker configuration */
|
|
132
|
+
circuitBreaker?: CircuitBreakerConfig;
|
|
133
|
+
/** Enable rate limit header tracking (default: false) */
|
|
134
|
+
enableRateLimitTracking?: boolean;
|
|
135
|
+
}
|
|
136
|
+
/** CGSConfig with core fields required, enterprise features remain optional */
|
|
137
|
+
type RequiredCGSConfig = Required<Pick<CGSConfig, 'baseURL' | 'tenantId' | 'apiKey' | 'headers' | 'timeout' | 'retries' | 'debug' | 'autoCreateProfiles' | 'syncMode' | 'interceptors' | 'logger'>> & Pick<CGSConfig, 'environment' | 'sandboxBaseURL' | 'circuitBreaker' | 'enableRateLimitTracking'>;
|
|
138
|
+
/** BaseClientConfig with core fields required, enterprise features remain optional */
|
|
139
|
+
type RequiredBaseClientConfig = Required<Pick<BaseClientConfig, 'baseURL' | 'tenantId' | 'apiKey' | 'headers' | 'timeout' | 'retries' | 'debug' | 'interceptors' | 'logger'>> & Pick<BaseClientConfig, 'environment' | 'sandboxBaseURL' | 'circuitBreaker' | 'enableRateLimitTracking'>;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Rate limit tracking from API response headers.
|
|
143
|
+
*
|
|
144
|
+
* Tracks X-RateLimit-* headers to enable pre-flight checks
|
|
145
|
+
* before making requests.
|
|
146
|
+
*/
|
|
147
|
+
interface RateLimitStatus {
|
|
148
|
+
/** Maximum requests allowed in the window */
|
|
149
|
+
limit: number | null;
|
|
150
|
+
/** Remaining requests in the current window */
|
|
151
|
+
remaining: number | null;
|
|
152
|
+
/** Unix timestamp (seconds) when the rate limit resets */
|
|
153
|
+
reset: number | null;
|
|
154
|
+
/** Seconds until the rate limit resets */
|
|
155
|
+
retryAfter: number | null;
|
|
156
|
+
}
|
|
157
|
+
declare class RateLimitTracker {
|
|
158
|
+
private limit;
|
|
159
|
+
private remaining;
|
|
160
|
+
private reset;
|
|
161
|
+
private retryAfter;
|
|
162
|
+
/**
|
|
163
|
+
* Extract rate limit information from response headers.
|
|
164
|
+
*/
|
|
165
|
+
updateFromHeaders(headers: Headers): void;
|
|
166
|
+
/**
|
|
167
|
+
* Check if the rate limit has been exceeded based on tracked headers.
|
|
168
|
+
*/
|
|
169
|
+
isLimitExceeded(): boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Get current rate limit status.
|
|
172
|
+
*/
|
|
173
|
+
getStatus(): RateLimitStatus;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Base HTTP client for all CGS SDK clients
|
|
178
|
+
*
|
|
179
|
+
* Provides common functionality:
|
|
180
|
+
* - Request/response handling
|
|
181
|
+
* - Error handling
|
|
182
|
+
* - Retry logic with exponential backoff
|
|
183
|
+
* - Timeout management
|
|
184
|
+
* - Debug logging
|
|
185
|
+
*/
|
|
186
|
+
|
|
187
|
+
declare abstract class BaseClient {
|
|
188
|
+
protected config: BaseClientConfig & {
|
|
189
|
+
timeout: number;
|
|
190
|
+
retries: number;
|
|
191
|
+
};
|
|
192
|
+
protected logger: Logger;
|
|
193
|
+
private interceptors;
|
|
194
|
+
private circuitBreaker;
|
|
195
|
+
private rateLimitTracker;
|
|
196
|
+
constructor(config: BaseClientConfig);
|
|
197
|
+
/**
|
|
198
|
+
* Make an HTTP request with timeout and error handling
|
|
199
|
+
*/
|
|
200
|
+
protected request<T>(endpoint: string, options?: RequestInit, serviceURL?: string, requestOptions?: RequestOptions): Promise<T>;
|
|
201
|
+
/**
|
|
202
|
+
* Make an HTTP request with retry logic
|
|
203
|
+
*/
|
|
204
|
+
protected requestWithRetry<T>(endpoint: string, options?: RequestInit, serviceURL?: string, retries?: number, requestOptions?: RequestOptions): Promise<T>;
|
|
205
|
+
/**
|
|
206
|
+
* Handle error responses from API
|
|
207
|
+
*/
|
|
208
|
+
protected handleErrorResponse(status: number, data: Record<string, unknown>, requestId?: string): never;
|
|
209
|
+
/**
|
|
210
|
+
* Build query string from parameters
|
|
211
|
+
*/
|
|
212
|
+
protected buildQueryString(params: Record<string, unknown>): string;
|
|
213
|
+
/**
|
|
214
|
+
* Update client configuration
|
|
215
|
+
*/
|
|
216
|
+
updateConfig(config: Partial<BaseClientConfig>): void;
|
|
217
|
+
/**
|
|
218
|
+
* Get current configuration (readonly)
|
|
219
|
+
*/
|
|
220
|
+
getConfig(): Readonly<BaseClientConfig>;
|
|
221
|
+
/**
|
|
222
|
+
* Get rate limit status from tracked response headers.
|
|
223
|
+
*/
|
|
224
|
+
getRateLimitStatus(): RateLimitStatus | null;
|
|
225
|
+
/**
|
|
226
|
+
* Get circuit breaker status.
|
|
227
|
+
*/
|
|
228
|
+
getCircuitBreakerStatus(): CircuitBreakerStatus | null;
|
|
229
|
+
/**
|
|
230
|
+
* Health check endpoint
|
|
231
|
+
*/
|
|
232
|
+
healthCheck(): Promise<{
|
|
233
|
+
status: string;
|
|
234
|
+
timestamp: string;
|
|
235
|
+
}>;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export { BaseClient as B, type CircuitBreakerConfig as C, type Logger as L, type RequestOptions as R, type RequestInterceptor as a, type BaseClientConfig as b, type CGSConfig as c, type RequiredCGSConfig as d, type RequiredBaseClientConfig as e, type CircuitBreakerState as f, type CircuitBreakerStatus as g, CircuitBreaker as h, type RateLimitStatus as i, RateLimitTracker as j };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { D as DeviceFingerprintRequest, L as LocationVerification, P as LocationRequest, G as GeolocationClient, S as LocationRequestFilters, T as LocationRequestListResponse } from '../client-
|
|
2
|
-
export { Q as CreateLocationRequestRequest, Y as LocationCaptureRequest, _ as LocationCaptureResponse, O as LocationRequestChannel, R as LocationRequestResult, N as LocationRequestStatus, Z as LocationShareInfo, W as ResendLocationRequestRequest } from '../client-
|
|
1
|
+
import { D as DeviceFingerprintRequest, L as LocationVerification, P as LocationRequest, G as GeolocationClient, S as LocationRequestFilters, T as LocationRequestListResponse } from '../client-B6fUFAUM.mjs';
|
|
2
|
+
export { Q as CreateLocationRequestRequest, Y as LocationCaptureRequest, _ as LocationCaptureResponse, O as LocationRequestChannel, R as LocationRequestResult, N as LocationRequestStatus, Z as LocationShareInfo, W as ResendLocationRequestRequest } from '../client-B6fUFAUM.mjs';
|
|
3
3
|
import { RiskProfileClient } from '../risk-profile/index.mjs';
|
|
4
|
-
import {
|
|
5
|
-
import { C as CustomerProfile } from '../types-
|
|
4
|
+
import { c as CGSConfig, R as RequestOptions } from '../client-DzElM7u-.mjs';
|
|
5
|
+
import { C as CustomerProfile } from '../types-jaLuzruy.mjs';
|
|
6
|
+
import { E as EntityType, P as PaginationParams } from '../types-DZHongaK.mjs';
|
|
6
7
|
|
|
7
8
|
interface RegistrationVerificationRequest {
|
|
8
9
|
customerId: string;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { D as DeviceFingerprintRequest, L as LocationVerification, P as LocationRequest, G as GeolocationClient, S as LocationRequestFilters, T as LocationRequestListResponse } from '../client-
|
|
2
|
-
export { Q as CreateLocationRequestRequest, Y as LocationCaptureRequest, _ as LocationCaptureResponse, O as LocationRequestChannel, R as LocationRequestResult, N as LocationRequestStatus, Z as LocationShareInfo, W as ResendLocationRequestRequest } from '../client-
|
|
1
|
+
import { D as DeviceFingerprintRequest, L as LocationVerification, P as LocationRequest, G as GeolocationClient, S as LocationRequestFilters, T as LocationRequestListResponse } from '../client-DoczGA6L.js';
|
|
2
|
+
export { Q as CreateLocationRequestRequest, Y as LocationCaptureRequest, _ as LocationCaptureResponse, O as LocationRequestChannel, R as LocationRequestResult, N as LocationRequestStatus, Z as LocationShareInfo, W as ResendLocationRequestRequest } from '../client-DoczGA6L.js';
|
|
3
3
|
import { RiskProfileClient } from '../risk-profile/index.js';
|
|
4
|
-
import {
|
|
5
|
-
import { C as CustomerProfile } from '../types-
|
|
4
|
+
import { c as CGSConfig, R as RequestOptions } from '../client-DzElM7u-.js';
|
|
5
|
+
import { C as CustomerProfile } from '../types-DLC7Sfy5.js';
|
|
6
|
+
import { E as EntityType, P as PaginationParams } from '../types-DZHongaK.js';
|
|
6
7
|
|
|
7
8
|
interface RegistrationVerificationRequest {
|
|
8
9
|
customerId: string;
|