vesant-sdk 1.1.1 → 1.3.0

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 (71) hide show
  1. package/dist/{client-i5QtnFIa.d.ts → client-B6fUFAUM.d.mts} +26 -1
  2. package/dist/{client-BfeDYmrZ.d.mts → client-DoczGA6L.d.ts} +26 -1
  3. package/dist/client-DzElM7u-.d.mts +238 -0
  4. package/dist/client-DzElM7u-.d.ts +238 -0
  5. package/dist/compliance/index.d.mts +5 -4
  6. package/dist/compliance/index.d.ts +5 -4
  7. package/dist/compliance/index.js +522 -30
  8. package/dist/compliance/index.js.map +1 -1
  9. package/dist/compliance/index.mjs +522 -30
  10. package/dist/compliance/index.mjs.map +1 -1
  11. package/dist/decisions/index.d.mts +100 -0
  12. package/dist/decisions/index.d.ts +100 -0
  13. package/dist/decisions/index.js +607 -0
  14. package/dist/decisions/index.js.map +1 -0
  15. package/dist/decisions/index.mjs +605 -0
  16. package/dist/decisions/index.mjs.map +1 -0
  17. package/dist/geolocation/index.d.mts +4 -3
  18. package/dist/geolocation/index.d.ts +4 -3
  19. package/dist/geolocation/index.js +546 -278
  20. package/dist/geolocation/index.js.map +1 -1
  21. package/dist/geolocation/index.mjs +546 -278
  22. package/dist/geolocation/index.mjs.map +1 -1
  23. package/dist/index.d.mts +14 -6
  24. package/dist/index.d.ts +14 -6
  25. package/dist/index.js +946 -335
  26. package/dist/index.js.map +1 -1
  27. package/dist/index.mjs +937 -336
  28. package/dist/index.mjs.map +1 -1
  29. package/dist/kyc/core.d.mts +3 -2
  30. package/dist/kyc/core.d.ts +3 -2
  31. package/dist/kyc/core.js +249 -29
  32. package/dist/kyc/core.js.map +1 -1
  33. package/dist/kyc/core.mjs +249 -29
  34. package/dist/kyc/core.mjs.map +1 -1
  35. package/dist/kyc/index.d.mts +3 -2
  36. package/dist/kyc/index.d.ts +3 -2
  37. package/dist/kyc/index.js +249 -29
  38. package/dist/kyc/index.js.map +1 -1
  39. package/dist/kyc/index.mjs +249 -29
  40. package/dist/kyc/index.mjs.map +1 -1
  41. package/dist/react.d.mts +4 -3
  42. package/dist/react.d.ts +4 -3
  43. package/dist/react.js +29 -3
  44. package/dist/react.js.map +1 -1
  45. package/dist/react.mjs +29 -3
  46. package/dist/react.mjs.map +1 -1
  47. package/dist/risk-profile/index.d.mts +4 -4
  48. package/dist/risk-profile/index.d.ts +4 -4
  49. package/dist/risk-profile/index.js +249 -29
  50. package/dist/risk-profile/index.js.map +1 -1
  51. package/dist/risk-profile/index.mjs +249 -29
  52. package/dist/risk-profile/index.mjs.map +1 -1
  53. package/dist/scores/index.d.mts +96 -0
  54. package/dist/scores/index.d.ts +96 -0
  55. package/dist/scores/index.js +594 -0
  56. package/dist/scores/index.js.map +1 -0
  57. package/dist/scores/index.mjs +591 -0
  58. package/dist/scores/index.mjs.map +1 -0
  59. package/dist/{types-DfHLp_tz.d.ts → types-DLC7Sfy5.d.ts} +1 -1
  60. package/dist/types-DZHongaK.d.mts +61 -0
  61. package/dist/types-DZHongaK.d.ts +61 -0
  62. package/dist/{types-DKCQN4C5.d.mts → types-jaLuzruy.d.mts} +1 -1
  63. package/dist/webhooks/index.d.mts +176 -0
  64. package/dist/webhooks/index.d.ts +176 -0
  65. package/dist/webhooks/index.js +193 -0
  66. package/dist/webhooks/index.js.map +1 -0
  67. package/dist/webhooks/index.mjs +188 -0
  68. package/dist/webhooks/index.mjs.map +1 -0
  69. package/package.json +16 -1
  70. package/dist/types-BpKxSXGF.d.mts +0 -177
  71. package/dist/types-BpKxSXGF.d.ts +0 -177
@@ -1,4 +1,5 @@
1
- import { b as Logger, P as PaginationParams, B as BaseClient, R as RequestOptions } from './types-BpKxSXGF.js';
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;
@@ -73,6 +74,10 @@ type CipherTextReason = 'registration' | 'login' | 'transaction' | 'interval_che
73
74
  interface CipherTextOptions {
74
75
  /** Reason for collection (required) */
75
76
  reason: CipherTextReason;
77
+ /** Public signing key (pk_) for HMAC signing (produces v02 signed cipherText) */
78
+ signingKey?: string;
79
+ /** @deprecated Use signingKey instead. API key for HMAC signing (backward compat) */
80
+ apiKey?: string;
76
81
  /** Request GPS location (default: false) */
77
82
  requestLocation?: boolean;
78
83
  /** GPS timeout in milliseconds (default: 10000) */
@@ -449,6 +454,8 @@ interface GeolocationConfigResponse {
449
454
  registration: boolean;
450
455
  transaction: boolean;
451
456
  };
457
+ /** Public signing key (pk_) for client-side HMAC signing */
458
+ signing_key?: string;
452
459
  }
453
460
  interface GeolocationClientConfig {
454
461
  /** Base URL of the API Gateway (e.g., "https://api.example.com") */
@@ -736,6 +743,7 @@ interface UseLocationCaptureResult {
736
743
  * transient failures gracefully.
737
744
  */
738
745
  declare class GeolocationClient extends BaseClient {
746
+ private cachedSigningKey?;
739
747
  constructor(config: GeolocationClientConfig);
740
748
  /**
741
749
  * Verify an IP address and check compliance
@@ -964,6 +972,23 @@ declare class GeolocationClient extends BaseClient {
964
972
  * ```
965
973
  */
966
974
  captureLocation(token: string, capture: LocationCaptureRequest, requestOptions?: RequestOptions): Promise<LocationCaptureResponse>;
975
+ /**
976
+ * Generate a signed cipherText containing device and location data.
977
+ *
978
+ * Automatically passes the client's API key for HMAC signing (v02 format).
979
+ * If no API key is configured, falls back to unsigned v01 format.
980
+ *
981
+ * @param options - Options for cipherText generation
982
+ * @param gpsConfig - Optional GPS config (from getGPSConfig)
983
+ * @returns CipherText result with the signed string
984
+ *
985
+ * @example
986
+ * ```typescript
987
+ * const result = await client.generateCipherText({ reason: 'login' });
988
+ * console.log(result.cipherText); // v02 signed cipherText
989
+ * ```
990
+ */
991
+ generateCipherText(options: Omit<CipherTextOptions, 'apiKey' | 'signingKey'>, gpsConfig?: GeolocationConfigResponse): Promise<CipherTextResult>;
967
992
  }
968
993
 
969
994
  export { type UseLocationRequestsOptions as $, type AlertStatus as A, type APIError as B, type CipherTextPayload as C, type DeviceFingerprintRequest as D, type GeolocationConfigResponse as E, type GeolocationClientConfig as F, GeolocationClient as G, type UseGeolocationOptions as H, type UseGeolocationResult as I, type JurisdictionConfig as J, type UseAlertsOptions as K, type LocationVerification as L, type UseAlertsResult as M, type LocationRequestStatus as N, type LocationRequestChannel as O, type LocationRequest as P, type CreateLocationRequestRequest as Q, type LocationRequestResult as R, type LocationRequestFilters as S, type LocationRequestListResponse as T, type UpdateJurisdictionRequest as U, type ValidateCipherTextRequest as V, type ResendLocationRequestRequest as W, type WiFiNetwork as X, type LocationCaptureRequest as Y, type LocationShareInfo as Z, type LocationCaptureResponse as _, type CipherTextReason as a, type UseLocationRequestsResult as a0, type UseLocationCaptureOptions as a1, type UseLocationCaptureResult as a2, type CipherTextOptions as b, type CipherTextResult as c, type DecryptedCipherText as d, type CipherTextCustomerData as e, type ValidateCipherTextResponse as f, type VerifyIPRequest as g, type GeoIPResult as h, type GeofenceEvaluation as i, type DeviceFingerprint as j, type DeviceTrustResult as k, type ComplianceCheckResponse as l, type AlertSeverity as m, type AlertType as n, type GeolocationAlert as o, type AlertFilters as p, type AlertListResponse as q, type DashboardMetrics as r, type CreateJurisdictionRequest as s, type GeofenceRuleType as t, type GeofenceAction as u, type GeofenceRule as v, type CreateGeofenceRuleRequest as w, type UpdateGeofenceRuleRequest as x, type UpdateDeviceTrustRequest as y, type GeolocationRecord as z };
@@ -1,4 +1,5 @@
1
- import { b as Logger, P as PaginationParams, B as BaseClient, R as RequestOptions } from './types-BpKxSXGF.mjs';
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;
@@ -73,6 +74,10 @@ type CipherTextReason = 'registration' | 'login' | 'transaction' | 'interval_che
73
74
  interface CipherTextOptions {
74
75
  /** Reason for collection (required) */
75
76
  reason: CipherTextReason;
77
+ /** Public signing key (pk_) for HMAC signing (produces v02 signed cipherText) */
78
+ signingKey?: string;
79
+ /** @deprecated Use signingKey instead. API key for HMAC signing (backward compat) */
80
+ apiKey?: string;
76
81
  /** Request GPS location (default: false) */
77
82
  requestLocation?: boolean;
78
83
  /** GPS timeout in milliseconds (default: 10000) */
@@ -449,6 +454,8 @@ interface GeolocationConfigResponse {
449
454
  registration: boolean;
450
455
  transaction: boolean;
451
456
  };
457
+ /** Public signing key (pk_) for client-side HMAC signing */
458
+ signing_key?: string;
452
459
  }
453
460
  interface GeolocationClientConfig {
454
461
  /** Base URL of the API Gateway (e.g., "https://api.example.com") */
@@ -736,6 +743,7 @@ interface UseLocationCaptureResult {
736
743
  * transient failures gracefully.
737
744
  */
738
745
  declare class GeolocationClient extends BaseClient {
746
+ private cachedSigningKey?;
739
747
  constructor(config: GeolocationClientConfig);
740
748
  /**
741
749
  * Verify an IP address and check compliance
@@ -964,6 +972,23 @@ declare class GeolocationClient extends BaseClient {
964
972
  * ```
965
973
  */
966
974
  captureLocation(token: string, capture: LocationCaptureRequest, requestOptions?: RequestOptions): Promise<LocationCaptureResponse>;
975
+ /**
976
+ * Generate a signed cipherText containing device and location data.
977
+ *
978
+ * Automatically passes the client's API key for HMAC signing (v02 format).
979
+ * If no API key is configured, falls back to unsigned v01 format.
980
+ *
981
+ * @param options - Options for cipherText generation
982
+ * @param gpsConfig - Optional GPS config (from getGPSConfig)
983
+ * @returns CipherText result with the signed string
984
+ *
985
+ * @example
986
+ * ```typescript
987
+ * const result = await client.generateCipherText({ reason: 'login' });
988
+ * console.log(result.cipherText); // v02 signed cipherText
989
+ * ```
990
+ */
991
+ generateCipherText(options: Omit<CipherTextOptions, 'apiKey' | 'signingKey'>, gpsConfig?: GeolocationConfigResponse): Promise<CipherTextResult>;
967
992
  }
968
993
 
969
994
  export { type UseLocationRequestsOptions as $, type AlertStatus as A, type APIError as B, type CipherTextPayload as C, type DeviceFingerprintRequest as D, type GeolocationConfigResponse as E, type GeolocationClientConfig as F, GeolocationClient as G, type UseGeolocationOptions as H, type UseGeolocationResult as I, type JurisdictionConfig as J, type UseAlertsOptions as K, type LocationVerification as L, type UseAlertsResult as M, type LocationRequestStatus as N, type LocationRequestChannel as O, type LocationRequest as P, type CreateLocationRequestRequest as Q, type LocationRequestResult as R, type LocationRequestFilters as S, type LocationRequestListResponse as T, type UpdateJurisdictionRequest as U, type ValidateCipherTextRequest as V, type ResendLocationRequestRequest as W, type WiFiNetwork as X, type LocationCaptureRequest as Y, type LocationShareInfo as Z, type LocationCaptureResponse as _, type CipherTextReason as a, type UseLocationRequestsResult as a0, type UseLocationCaptureOptions as a1, type UseLocationCaptureResult as a2, type CipherTextOptions as b, type CipherTextResult as c, type DecryptedCipherText as d, type CipherTextCustomerData as e, type ValidateCipherTextResponse as f, type VerifyIPRequest as g, type GeoIPResult as h, type GeofenceEvaluation as i, type DeviceFingerprint as j, type DeviceTrustResult as k, type ComplianceCheckResponse as l, type AlertSeverity as m, type AlertType as n, type GeolocationAlert as o, type AlertFilters as p, type AlertListResponse as q, type DashboardMetrics as r, type CreateJurisdictionRequest as s, type GeofenceRuleType as t, type GeofenceAction as u, type GeofenceRule as v, type CreateGeofenceRuleRequest as w, type UpdateGeofenceRuleRequest as x, type UpdateDeviceTrustRequest as y, type GeolocationRecord as z };
@@ -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-BfeDYmrZ.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-BfeDYmrZ.mjs';
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 { E as EntityType, e as CGSConfig, R as RequestOptions, P as PaginationParams } from '../types-BpKxSXGF.mjs';
5
- import { C as CustomerProfile } from '../types-DKCQN4C5.mjs';
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-i5QtnFIa.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-i5QtnFIa.js';
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 { E as EntityType, e as CGSConfig, R as RequestOptions, P as PaginationParams } from '../types-BpKxSXGF.js';
5
- import { C as CustomerProfile } from '../types-DfHLp_tz.js';
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;