vesant-sdk 1.7.0-dev.5305eb7 → 1.7.0-dev.6f300f7
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-C3DCmGe9.d.ts → client-749WqhDT.d.ts} +2 -2
- package/dist/{client-DMIRx7Tu.d.mts → client-BG8KtVMc.d.mts} +14 -1
- package/dist/{client-ZNdnpWe7.d.mts → client-CRZea-eJ.d.mts} +2 -2
- package/dist/{client-DoMSYMMR.d.ts → client-D9JZgN3X.d.ts} +14 -1
- 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 +61 -9
- package/dist/compliance/index.js.map +1 -1
- package/dist/compliance/index.mjs +61 -9
- 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 +61 -6
- package/dist/decisions/index.js.map +1 -1
- package/dist/decisions/index.mjs +61 -6
- package/dist/decisions/index.mjs.map +1 -1
- package/dist/geolocation/index.d.mts +3 -3
- package/dist/geolocation/index.d.ts +3 -3
- package/dist/geolocation/index.js +61 -6
- package/dist/geolocation/index.js.map +1 -1
- package/dist/geolocation/index.mjs +61 -6
- package/dist/geolocation/index.mjs.map +1 -1
- package/dist/index.d.mts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +137 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +136 -24
- package/dist/index.mjs.map +1 -1
- package/dist/kyc/core.d.mts +2 -2
- package/dist/kyc/core.d.ts +2 -2
- package/dist/kyc/core.js +87 -18
- package/dist/kyc/core.js.map +1 -1
- package/dist/kyc/core.mjs +87 -18
- package/dist/kyc/core.mjs.map +1 -1
- package/dist/kyc/index.d.mts +90 -13
- package/dist/kyc/index.d.ts +90 -13
- package/dist/kyc/index.js +87 -18
- package/dist/kyc/index.js.map +1 -1
- package/dist/kyc/index.mjs +87 -18
- package/dist/kyc/index.mjs.map +1 -1
- package/dist/react.d.mts +5 -3
- package/dist/react.d.ts +5 -3
- package/dist/react.js +112 -73
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +112 -73
- 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 +61 -6
- package/dist/risk-profile/index.js.map +1 -1
- package/dist/risk-profile/index.mjs +61 -6
- 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 +61 -6
- package/dist/scores/index.js.map +1 -1
- package/dist/scores/index.mjs +61 -6
- 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 +66 -8
- package/dist/tax/index.js.map +1 -1
- package/dist/tax/index.mjs +66 -8
- package/dist/tax/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as DeviceFingerprintRequest, L as LocationVerification, V as ValidateCipherTextResponse, a as LocationRequest, G as GeolocationClient, b as LocationRequestFilters, c as LocationRequestListResponse } from './client-
|
|
1
|
+
import { D as DeviceFingerprintRequest, L as LocationVerification, V as ValidateCipherTextResponse, a as LocationRequest, G as GeolocationClient, b as LocationRequestFilters, c as LocationRequestListResponse } from './client-D9JZgN3X.js';
|
|
2
2
|
import { RiskProfileClient } from './risk-profile/index.js';
|
|
3
|
-
import { V as VesantConfig, R as RequestOptions } from './client-
|
|
3
|
+
import { V as VesantConfig, R as RequestOptions } from './client-q9fN8Hhf.js';
|
|
4
4
|
import { C as CustomerProfile } from './types-UGyDl1fd.js';
|
|
5
5
|
import { E as EntityType, B as BlockReason, P as PaginationParams } from './types-CBQRNL-l.js';
|
|
6
6
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { L as Logger, B as BaseClient, R as RequestOptions } from './client-
|
|
1
|
+
import { L as Logger, B as BaseClient, R as RequestOptions } from './client-q9fN8Hhf.mjs';
|
|
2
2
|
import { B as BlockReason, P as PaginationParams } from './types-CBQRNL-l.mjs';
|
|
3
3
|
|
|
4
4
|
interface DeviceFingerprintRequest {
|
|
@@ -212,6 +212,19 @@ interface ValidateCipherTextResponse {
|
|
|
212
212
|
geofence_evaluation?: GeofenceEvaluation;
|
|
213
213
|
record_id?: string;
|
|
214
214
|
gps_required?: boolean;
|
|
215
|
+
/**
|
|
216
|
+
* IP-derived location the GPS coordinates were cross-validated against.
|
|
217
|
+
* `location` carries the GPS-derived city when GPS was provided, so this is
|
|
218
|
+
* what explains a gps_ip_location_mismatch risk factor.
|
|
219
|
+
*/
|
|
220
|
+
ip_location?: {
|
|
221
|
+
country?: string;
|
|
222
|
+
country_iso?: string;
|
|
223
|
+
city?: string;
|
|
224
|
+
region?: string;
|
|
225
|
+
latitude: number;
|
|
226
|
+
longitude: number;
|
|
227
|
+
};
|
|
215
228
|
}
|
|
216
229
|
interface VerifyIPRequest {
|
|
217
230
|
ip_address: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as DeviceFingerprintRequest, L as LocationVerification, V as ValidateCipherTextResponse, a as LocationRequest, G as GeolocationClient, b as LocationRequestFilters, c as LocationRequestListResponse } from './client-
|
|
1
|
+
import { D as DeviceFingerprintRequest, L as LocationVerification, V as ValidateCipherTextResponse, a as LocationRequest, G as GeolocationClient, b as LocationRequestFilters, c as LocationRequestListResponse } from './client-BG8KtVMc.mjs';
|
|
2
2
|
import { RiskProfileClient } from './risk-profile/index.mjs';
|
|
3
|
-
import { V as VesantConfig, R as RequestOptions } from './client-
|
|
3
|
+
import { V as VesantConfig, R as RequestOptions } from './client-q9fN8Hhf.mjs';
|
|
4
4
|
import { C as CustomerProfile } from './types-BOFaMQxI.mjs';
|
|
5
5
|
import { E as EntityType, B as BlockReason, P as PaginationParams } from './types-CBQRNL-l.mjs';
|
|
6
6
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { L as Logger, B as BaseClient, R as RequestOptions } from './client-
|
|
1
|
+
import { L as Logger, B as BaseClient, R as RequestOptions } from './client-q9fN8Hhf.js';
|
|
2
2
|
import { B as BlockReason, P as PaginationParams } from './types-CBQRNL-l.js';
|
|
3
3
|
|
|
4
4
|
interface DeviceFingerprintRequest {
|
|
@@ -212,6 +212,19 @@ interface ValidateCipherTextResponse {
|
|
|
212
212
|
geofence_evaluation?: GeofenceEvaluation;
|
|
213
213
|
record_id?: string;
|
|
214
214
|
gps_required?: boolean;
|
|
215
|
+
/**
|
|
216
|
+
* IP-derived location the GPS coordinates were cross-validated against.
|
|
217
|
+
* `location` carries the GPS-derived city when GPS was provided, so this is
|
|
218
|
+
* what explains a gps_ip_location_mismatch risk factor.
|
|
219
|
+
*/
|
|
220
|
+
ip_location?: {
|
|
221
|
+
country?: string;
|
|
222
|
+
country_iso?: string;
|
|
223
|
+
city?: string;
|
|
224
|
+
region?: string;
|
|
225
|
+
latitude: number;
|
|
226
|
+
longitude: number;
|
|
227
|
+
};
|
|
215
228
|
}
|
|
216
229
|
interface VerifyIPRequest {
|
|
217
230
|
ip_address: string;
|
|
@@ -50,6 +50,80 @@ declare class CircuitBreaker {
|
|
|
50
50
|
reset(): void;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Pluggable authentication for BaseClient.
|
|
55
|
+
*
|
|
56
|
+
* A TokenProvider supplies the credential used for the Authorization header on
|
|
57
|
+
* every request, resolved per-request (async) so callers can source short-lived
|
|
58
|
+
* or rotating credentials (OAuth2 client-credentials, STS, Vault / Secrets
|
|
59
|
+
* Manager) instead of a single static API key. The default StaticApiKeyProvider
|
|
60
|
+
* preserves the original `apiKey` behavior with zero change for existing callers.
|
|
61
|
+
*/
|
|
62
|
+
interface AuthCredential {
|
|
63
|
+
/** Authorization scheme (e.g. 'Bearer'); defaults to 'Bearer' when omitted. */
|
|
64
|
+
scheme?: string;
|
|
65
|
+
/** The credential value (bearer token / API key). */
|
|
66
|
+
token: string;
|
|
67
|
+
}
|
|
68
|
+
interface TokenProviderContext {
|
|
69
|
+
tenantId: string;
|
|
70
|
+
requestId: string;
|
|
71
|
+
/** When true, bypass any cache and obtain a fresh credential (e.g. after a 401). */
|
|
72
|
+
forceRefresh?: boolean;
|
|
73
|
+
}
|
|
74
|
+
interface TokenProvider {
|
|
75
|
+
/** Resolve the credential for a request, or null to send no Authorization header. */
|
|
76
|
+
getCredential(ctx: TokenProviderContext): Promise<AuthCredential | null>;
|
|
77
|
+
/** Whether this provider can obtain a fresh credential on demand (drives 401 retry). */
|
|
78
|
+
canRefresh?(): boolean;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Default provider: wraps a static API key. Returns null when the key is empty
|
|
82
|
+
* so the client sends no Authorization header, matching the pre-provider behavior.
|
|
83
|
+
*/
|
|
84
|
+
declare class StaticApiKeyProvider implements TokenProvider {
|
|
85
|
+
private readonly apiKey;
|
|
86
|
+
constructor(apiKey: string);
|
|
87
|
+
getCredential(): Promise<AuthCredential | null>;
|
|
88
|
+
canRefresh(): boolean;
|
|
89
|
+
}
|
|
90
|
+
interface CachedToken {
|
|
91
|
+
token: string;
|
|
92
|
+
expiresAt?: number;
|
|
93
|
+
}
|
|
94
|
+
interface RefreshingTokenProviderOptions {
|
|
95
|
+
/** Fetches a fresh token. `expiresAt` is epoch milliseconds (optional). */
|
|
96
|
+
fetchToken: () => Promise<CachedToken>;
|
|
97
|
+
/** Refresh this many ms before expiry (default: 30_000). */
|
|
98
|
+
skewMs?: number;
|
|
99
|
+
/** Authorization scheme to emit (default: 'Bearer'). */
|
|
100
|
+
scheme?: string;
|
|
101
|
+
/** Observe each successful (re)fetch — for logging / metrics. */
|
|
102
|
+
onRotate?: (meta: {
|
|
103
|
+
expiresAt?: number;
|
|
104
|
+
}) => void;
|
|
105
|
+
/** Injectable clock (default: Date.now). */
|
|
106
|
+
now?: () => number;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Caches a fetched token and refreshes it when it is within the skew window of
|
|
110
|
+
* expiry or when `forceRefresh` is requested. Concurrent refreshes are de-duped
|
|
111
|
+
* into a single in-flight fetch.
|
|
112
|
+
*/
|
|
113
|
+
declare class RefreshingTokenProvider implements TokenProvider {
|
|
114
|
+
private readonly opts;
|
|
115
|
+
private cached;
|
|
116
|
+
private inFlight;
|
|
117
|
+
private readonly skewMs;
|
|
118
|
+
private readonly scheme;
|
|
119
|
+
private readonly now;
|
|
120
|
+
constructor(opts: RefreshingTokenProviderOptions);
|
|
121
|
+
canRefresh(): boolean;
|
|
122
|
+
getCredential(ctx?: TokenProviderContext): Promise<AuthCredential | null>;
|
|
123
|
+
private isExpiring;
|
|
124
|
+
private refresh;
|
|
125
|
+
}
|
|
126
|
+
|
|
53
127
|
/**
|
|
54
128
|
* Configuration types for Vesant SDK clients
|
|
55
129
|
*/
|
|
@@ -82,6 +156,16 @@ interface BaseClientConfig {
|
|
|
82
156
|
tenantId: string;
|
|
83
157
|
/** Optional API key for authentication */
|
|
84
158
|
apiKey?: string;
|
|
159
|
+
/**
|
|
160
|
+
* Pluggable auth token provider. When set, it supplies the Authorization
|
|
161
|
+
* credential per-request (overriding `apiKey`), enabling OAuth2 / STS / rotating
|
|
162
|
+
* secrets and single-shot 401 re-auth. Defaults to a static-apiKey provider.
|
|
163
|
+
*/
|
|
164
|
+
authProvider?: TokenProvider;
|
|
165
|
+
/** Observe credential rotation triggered by a 401 re-auth (logging / metrics). */
|
|
166
|
+
onCredentialRotated?: (meta: {
|
|
167
|
+
reason: string;
|
|
168
|
+
}) => void;
|
|
85
169
|
/** Custom headers to include in all requests */
|
|
86
170
|
headers?: Record<string, string>;
|
|
87
171
|
/** Request timeout in milliseconds (default: 10000) */
|
|
@@ -108,6 +192,16 @@ interface VesantConfig {
|
|
|
108
192
|
tenantId: string;
|
|
109
193
|
/** Optional API key for authentication */
|
|
110
194
|
apiKey?: string;
|
|
195
|
+
/**
|
|
196
|
+
* Pluggable auth token provider. When set, it supplies the Authorization
|
|
197
|
+
* credential per-request (overriding `apiKey`), enabling OAuth2 / STS / rotating
|
|
198
|
+
* secrets and single-shot 401 re-auth. Defaults to a static-apiKey provider.
|
|
199
|
+
*/
|
|
200
|
+
authProvider?: TokenProvider;
|
|
201
|
+
/** Observe credential rotation triggered by a 401 re-auth (logging / metrics). */
|
|
202
|
+
onCredentialRotated?: (meta: {
|
|
203
|
+
reason: string;
|
|
204
|
+
}) => void;
|
|
111
205
|
/** Custom headers to include in all requests */
|
|
112
206
|
headers?: Record<string, string>;
|
|
113
207
|
/** Request timeout in milliseconds (default: 10000) */
|
|
@@ -195,7 +289,15 @@ declare abstract class BaseClient {
|
|
|
195
289
|
private interceptors;
|
|
196
290
|
private circuitBreaker;
|
|
197
291
|
private rateLimitTracker;
|
|
292
|
+
private authProvider;
|
|
198
293
|
constructor(config: BaseClientConfig);
|
|
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
|
+
private resolveIdempotencyKey;
|
|
199
301
|
/**
|
|
200
302
|
* Make an HTTP request with timeout and error handling
|
|
201
303
|
*/
|
|
@@ -237,4 +339,4 @@ declare abstract class BaseClient {
|
|
|
237
339
|
}>;
|
|
238
340
|
}
|
|
239
341
|
|
|
240
|
-
export { BaseClient as B, type CGSConfig as C, type Logger as L, type RequestOptions as R, type VesantConfig as V, type BaseClientConfig as a, CircuitBreaker as b, type CircuitBreakerConfig as c, type CircuitBreakerState as d, type CircuitBreakerStatus as e, type RateLimitStatus as f, RateLimitTracker as g, type RequestInterceptor as
|
|
342
|
+
export { type AuthCredential as A, BaseClient as B, type CGSConfig as C, type Logger as L, type RequestOptions as R, StaticApiKeyProvider as S, type TokenProvider as T, type VesantConfig as V, type BaseClientConfig as a, CircuitBreaker as b, type CircuitBreakerConfig as c, type CircuitBreakerState as d, type CircuitBreakerStatus as e, type RateLimitStatus as f, RateLimitTracker as g, RefreshingTokenProvider as h, type RefreshingTokenProviderOptions as i, type RequestInterceptor as j, type RequiredBaseClientConfig as k, type RequiredCGSConfig as l, type RequiredVesantConfig as m, type TokenProviderContext as n };
|
|
@@ -50,6 +50,80 @@ declare class CircuitBreaker {
|
|
|
50
50
|
reset(): void;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Pluggable authentication for BaseClient.
|
|
55
|
+
*
|
|
56
|
+
* A TokenProvider supplies the credential used for the Authorization header on
|
|
57
|
+
* every request, resolved per-request (async) so callers can source short-lived
|
|
58
|
+
* or rotating credentials (OAuth2 client-credentials, STS, Vault / Secrets
|
|
59
|
+
* Manager) instead of a single static API key. The default StaticApiKeyProvider
|
|
60
|
+
* preserves the original `apiKey` behavior with zero change for existing callers.
|
|
61
|
+
*/
|
|
62
|
+
interface AuthCredential {
|
|
63
|
+
/** Authorization scheme (e.g. 'Bearer'); defaults to 'Bearer' when omitted. */
|
|
64
|
+
scheme?: string;
|
|
65
|
+
/** The credential value (bearer token / API key). */
|
|
66
|
+
token: string;
|
|
67
|
+
}
|
|
68
|
+
interface TokenProviderContext {
|
|
69
|
+
tenantId: string;
|
|
70
|
+
requestId: string;
|
|
71
|
+
/** When true, bypass any cache and obtain a fresh credential (e.g. after a 401). */
|
|
72
|
+
forceRefresh?: boolean;
|
|
73
|
+
}
|
|
74
|
+
interface TokenProvider {
|
|
75
|
+
/** Resolve the credential for a request, or null to send no Authorization header. */
|
|
76
|
+
getCredential(ctx: TokenProviderContext): Promise<AuthCredential | null>;
|
|
77
|
+
/** Whether this provider can obtain a fresh credential on demand (drives 401 retry). */
|
|
78
|
+
canRefresh?(): boolean;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Default provider: wraps a static API key. Returns null when the key is empty
|
|
82
|
+
* so the client sends no Authorization header, matching the pre-provider behavior.
|
|
83
|
+
*/
|
|
84
|
+
declare class StaticApiKeyProvider implements TokenProvider {
|
|
85
|
+
private readonly apiKey;
|
|
86
|
+
constructor(apiKey: string);
|
|
87
|
+
getCredential(): Promise<AuthCredential | null>;
|
|
88
|
+
canRefresh(): boolean;
|
|
89
|
+
}
|
|
90
|
+
interface CachedToken {
|
|
91
|
+
token: string;
|
|
92
|
+
expiresAt?: number;
|
|
93
|
+
}
|
|
94
|
+
interface RefreshingTokenProviderOptions {
|
|
95
|
+
/** Fetches a fresh token. `expiresAt` is epoch milliseconds (optional). */
|
|
96
|
+
fetchToken: () => Promise<CachedToken>;
|
|
97
|
+
/** Refresh this many ms before expiry (default: 30_000). */
|
|
98
|
+
skewMs?: number;
|
|
99
|
+
/** Authorization scheme to emit (default: 'Bearer'). */
|
|
100
|
+
scheme?: string;
|
|
101
|
+
/** Observe each successful (re)fetch — for logging / metrics. */
|
|
102
|
+
onRotate?: (meta: {
|
|
103
|
+
expiresAt?: number;
|
|
104
|
+
}) => void;
|
|
105
|
+
/** Injectable clock (default: Date.now). */
|
|
106
|
+
now?: () => number;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Caches a fetched token and refreshes it when it is within the skew window of
|
|
110
|
+
* expiry or when `forceRefresh` is requested. Concurrent refreshes are de-duped
|
|
111
|
+
* into a single in-flight fetch.
|
|
112
|
+
*/
|
|
113
|
+
declare class RefreshingTokenProvider implements TokenProvider {
|
|
114
|
+
private readonly opts;
|
|
115
|
+
private cached;
|
|
116
|
+
private inFlight;
|
|
117
|
+
private readonly skewMs;
|
|
118
|
+
private readonly scheme;
|
|
119
|
+
private readonly now;
|
|
120
|
+
constructor(opts: RefreshingTokenProviderOptions);
|
|
121
|
+
canRefresh(): boolean;
|
|
122
|
+
getCredential(ctx?: TokenProviderContext): Promise<AuthCredential | null>;
|
|
123
|
+
private isExpiring;
|
|
124
|
+
private refresh;
|
|
125
|
+
}
|
|
126
|
+
|
|
53
127
|
/**
|
|
54
128
|
* Configuration types for Vesant SDK clients
|
|
55
129
|
*/
|
|
@@ -82,6 +156,16 @@ interface BaseClientConfig {
|
|
|
82
156
|
tenantId: string;
|
|
83
157
|
/** Optional API key for authentication */
|
|
84
158
|
apiKey?: string;
|
|
159
|
+
/**
|
|
160
|
+
* Pluggable auth token provider. When set, it supplies the Authorization
|
|
161
|
+
* credential per-request (overriding `apiKey`), enabling OAuth2 / STS / rotating
|
|
162
|
+
* secrets and single-shot 401 re-auth. Defaults to a static-apiKey provider.
|
|
163
|
+
*/
|
|
164
|
+
authProvider?: TokenProvider;
|
|
165
|
+
/** Observe credential rotation triggered by a 401 re-auth (logging / metrics). */
|
|
166
|
+
onCredentialRotated?: (meta: {
|
|
167
|
+
reason: string;
|
|
168
|
+
}) => void;
|
|
85
169
|
/** Custom headers to include in all requests */
|
|
86
170
|
headers?: Record<string, string>;
|
|
87
171
|
/** Request timeout in milliseconds (default: 10000) */
|
|
@@ -108,6 +192,16 @@ interface VesantConfig {
|
|
|
108
192
|
tenantId: string;
|
|
109
193
|
/** Optional API key for authentication */
|
|
110
194
|
apiKey?: string;
|
|
195
|
+
/**
|
|
196
|
+
* Pluggable auth token provider. When set, it supplies the Authorization
|
|
197
|
+
* credential per-request (overriding `apiKey`), enabling OAuth2 / STS / rotating
|
|
198
|
+
* secrets and single-shot 401 re-auth. Defaults to a static-apiKey provider.
|
|
199
|
+
*/
|
|
200
|
+
authProvider?: TokenProvider;
|
|
201
|
+
/** Observe credential rotation triggered by a 401 re-auth (logging / metrics). */
|
|
202
|
+
onCredentialRotated?: (meta: {
|
|
203
|
+
reason: string;
|
|
204
|
+
}) => void;
|
|
111
205
|
/** Custom headers to include in all requests */
|
|
112
206
|
headers?: Record<string, string>;
|
|
113
207
|
/** Request timeout in milliseconds (default: 10000) */
|
|
@@ -195,7 +289,15 @@ declare abstract class BaseClient {
|
|
|
195
289
|
private interceptors;
|
|
196
290
|
private circuitBreaker;
|
|
197
291
|
private rateLimitTracker;
|
|
292
|
+
private authProvider;
|
|
198
293
|
constructor(config: BaseClientConfig);
|
|
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
|
+
private resolveIdempotencyKey;
|
|
199
301
|
/**
|
|
200
302
|
* Make an HTTP request with timeout and error handling
|
|
201
303
|
*/
|
|
@@ -237,4 +339,4 @@ declare abstract class BaseClient {
|
|
|
237
339
|
}>;
|
|
238
340
|
}
|
|
239
341
|
|
|
240
|
-
export { BaseClient as B, type CGSConfig as C, type Logger as L, type RequestOptions as R, type VesantConfig as V, type BaseClientConfig as a, CircuitBreaker as b, type CircuitBreakerConfig as c, type CircuitBreakerState as d, type CircuitBreakerStatus as e, type RateLimitStatus as f, RateLimitTracker as g, type RequestInterceptor as
|
|
342
|
+
export { type AuthCredential as A, BaseClient as B, type CGSConfig as C, type Logger as L, type RequestOptions as R, StaticApiKeyProvider as S, type TokenProvider as T, type VesantConfig as V, type BaseClientConfig as a, CircuitBreaker as b, type CircuitBreakerConfig as c, type CircuitBreakerState as d, type CircuitBreakerStatus as e, type RateLimitStatus as f, RateLimitTracker as g, RefreshingTokenProvider as h, type RefreshingTokenProviderOptions as i, type RequestInterceptor as j, type RequiredBaseClientConfig as k, type RequiredCGSConfig as l, type RequiredVesantConfig as m, type TokenProviderContext as n };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { B as BlockReason } from '../types-CBQRNL-l.mjs';
|
|
2
|
-
export { C as ComplianceClient, a as ComplianceLocationRequestInput, b as ComplianceLocationRequestResult, c as CurrencyRates, D as DEFAULT_CURRENCY_RATES, E as EventVerificationRequest, d as EventVerificationResponse, L as LoginVerificationRequest, e as LoginVerificationResponse, R as RegistrationVerificationRequest, f as RegistrationVerificationResponse, T as TransactionRiskResult, g as TransactionVerificationRequest, h as TransactionVerificationResponse } from '../client-
|
|
3
|
-
export { p as CreateLocationRequestRequest, H as LocationCaptureRequest, I as LocationCaptureResponse, a as LocationRequest, K as LocationRequestChannel, b as LocationRequestFilters, c as LocationRequestListResponse, M as LocationRequestResult, N as LocationRequestStatus, O as LocationShareInfo, R as ResendLocationRequestRequest } from '../client-
|
|
2
|
+
export { C as ComplianceClient, a as ComplianceLocationRequestInput, b as ComplianceLocationRequestResult, c as CurrencyRates, D as DEFAULT_CURRENCY_RATES, E as EventVerificationRequest, d as EventVerificationResponse, L as LoginVerificationRequest, e as LoginVerificationResponse, R as RegistrationVerificationRequest, f as RegistrationVerificationResponse, T as TransactionRiskResult, g as TransactionVerificationRequest, h as TransactionVerificationResponse } from '../client-CRZea-eJ.mjs';
|
|
3
|
+
export { p as CreateLocationRequestRequest, H as LocationCaptureRequest, I as LocationCaptureResponse, a as LocationRequest, K as LocationRequestChannel, b as LocationRequestFilters, c as LocationRequestListResponse, M as LocationRequestResult, N as LocationRequestStatus, O as LocationShareInfo, R as ResendLocationRequestRequest } from '../client-BG8KtVMc.mjs';
|
|
4
4
|
import '../risk-profile/index.mjs';
|
|
5
|
-
import '../client-
|
|
5
|
+
import '../client-q9fN8Hhf.mjs';
|
|
6
6
|
import '../types-BOFaMQxI.mjs';
|
|
7
7
|
|
|
8
8
|
declare const sdkReasons: {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { B as BlockReason } from '../types-CBQRNL-l.js';
|
|
2
|
-
export { C as ComplianceClient, a as ComplianceLocationRequestInput, b as ComplianceLocationRequestResult, c as CurrencyRates, D as DEFAULT_CURRENCY_RATES, E as EventVerificationRequest, d as EventVerificationResponse, L as LoginVerificationRequest, e as LoginVerificationResponse, R as RegistrationVerificationRequest, f as RegistrationVerificationResponse, T as TransactionRiskResult, g as TransactionVerificationRequest, h as TransactionVerificationResponse } from '../client-
|
|
3
|
-
export { p as CreateLocationRequestRequest, H as LocationCaptureRequest, I as LocationCaptureResponse, a as LocationRequest, K as LocationRequestChannel, b as LocationRequestFilters, c as LocationRequestListResponse, M as LocationRequestResult, N as LocationRequestStatus, O as LocationShareInfo, R as ResendLocationRequestRequest } from '../client-
|
|
2
|
+
export { C as ComplianceClient, a as ComplianceLocationRequestInput, b as ComplianceLocationRequestResult, c as CurrencyRates, D as DEFAULT_CURRENCY_RATES, E as EventVerificationRequest, d as EventVerificationResponse, L as LoginVerificationRequest, e as LoginVerificationResponse, R as RegistrationVerificationRequest, f as RegistrationVerificationResponse, T as TransactionRiskResult, g as TransactionVerificationRequest, h as TransactionVerificationResponse } from '../client-749WqhDT.js';
|
|
3
|
+
export { p as CreateLocationRequestRequest, H as LocationCaptureRequest, I as LocationCaptureResponse, a as LocationRequest, K as LocationRequestChannel, b as LocationRequestFilters, c as LocationRequestListResponse, M as LocationRequestResult, N as LocationRequestStatus, O as LocationShareInfo, R as ResendLocationRequestRequest } from '../client-D9JZgN3X.js';
|
|
4
4
|
import '../risk-profile/index.js';
|
|
5
|
-
import '../client-
|
|
5
|
+
import '../client-q9fN8Hhf.js';
|
|
6
6
|
import '../types-UGyDl1fd.js';
|
|
7
7
|
|
|
8
8
|
declare const sdkReasons: {
|
package/dist/compliance/index.js
CHANGED
|
@@ -75,6 +75,19 @@ var sdkReasons = {
|
|
|
75
75
|
})
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
+
// src/core/auth.ts
|
|
79
|
+
var StaticApiKeyProvider = class {
|
|
80
|
+
constructor(apiKey) {
|
|
81
|
+
this.apiKey = apiKey;
|
|
82
|
+
}
|
|
83
|
+
async getCredential() {
|
|
84
|
+
return this.apiKey ? { scheme: "Bearer", token: this.apiKey } : null;
|
|
85
|
+
}
|
|
86
|
+
canRefresh() {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
78
91
|
// src/core/errors.ts
|
|
79
92
|
var VesantError = class _VesantError extends Error {
|
|
80
93
|
constructor(message, code, statusCode, details) {
|
|
@@ -404,6 +417,7 @@ var BaseClient = class {
|
|
|
404
417
|
interceptors: this.interceptors,
|
|
405
418
|
logger: this.logger
|
|
406
419
|
};
|
|
420
|
+
this.authProvider = config.authProvider ?? (apiKey ? new StaticApiKeyProvider(apiKey) : void 0);
|
|
407
421
|
if (config.circuitBreaker) {
|
|
408
422
|
this.circuitBreaker = new CircuitBreaker(config.circuitBreaker);
|
|
409
423
|
}
|
|
@@ -411,6 +425,19 @@ var BaseClient = class {
|
|
|
411
425
|
this.rateLimitTracker = new RateLimitTracker();
|
|
412
426
|
}
|
|
413
427
|
}
|
|
428
|
+
/**
|
|
429
|
+
* Resolve the Idempotency-Key for a request. Mutating methods (POST/PUT/PATCH)
|
|
430
|
+
* get the caller-supplied key or a freshly minted UUID; non-mutating methods get
|
|
431
|
+
* none. requestWithRetry resolves this once and injects it so every retry reuses
|
|
432
|
+
* one key (letting the server dedup replays); a direct request() resolves per call.
|
|
433
|
+
*/
|
|
434
|
+
resolveIdempotencyKey(method, requestOptions) {
|
|
435
|
+
const isMutating = ["POST", "PUT", "PATCH"].includes((method || "GET").toUpperCase());
|
|
436
|
+
if (!isMutating) {
|
|
437
|
+
return void 0;
|
|
438
|
+
}
|
|
439
|
+
return requestOptions?.idempotencyKey ?? generateUUID();
|
|
440
|
+
}
|
|
414
441
|
/**
|
|
415
442
|
* Make an HTTP request with timeout and error handling
|
|
416
443
|
*/
|
|
@@ -436,15 +463,20 @@ var BaseClient = class {
|
|
|
436
463
|
...this.config.headers,
|
|
437
464
|
...options.headers || {}
|
|
438
465
|
};
|
|
439
|
-
|
|
440
|
-
|
|
466
|
+
const credential = await this.authProvider?.getCredential({
|
|
467
|
+
tenantId: this.config.tenantId,
|
|
468
|
+
requestId
|
|
469
|
+
});
|
|
470
|
+
if (credential) {
|
|
471
|
+
headers["Authorization"] = `${credential.scheme ?? "Bearer"} ${credential.token}`;
|
|
441
472
|
}
|
|
442
473
|
if (this.config.environment === "sandbox") {
|
|
443
474
|
headers["X-Sandbox"] = "true";
|
|
444
475
|
}
|
|
445
476
|
const method = (options.method || "GET").toUpperCase();
|
|
446
|
-
|
|
447
|
-
|
|
477
|
+
const idempotencyKey = this.resolveIdempotencyKey(method, requestOptions);
|
|
478
|
+
if (idempotencyKey) {
|
|
479
|
+
headers["Idempotency-Key"] = idempotencyKey;
|
|
448
480
|
}
|
|
449
481
|
const controller = new AbortController();
|
|
450
482
|
const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
|
|
@@ -465,10 +497,28 @@ var BaseClient = class {
|
|
|
465
497
|
if (this.config.debug) {
|
|
466
498
|
this.logger.debug(`${finalOptions.method || "GET"} ${endpoint}`);
|
|
467
499
|
}
|
|
468
|
-
|
|
500
|
+
let response = await fetch(url, {
|
|
469
501
|
...finalOptions,
|
|
470
502
|
signal: controller.signal
|
|
471
503
|
});
|
|
504
|
+
if (response.status === 401 && this.authProvider?.canRefresh?.()) {
|
|
505
|
+
const refreshed = await this.authProvider.getCredential({
|
|
506
|
+
tenantId: this.config.tenantId,
|
|
507
|
+
requestId,
|
|
508
|
+
forceRefresh: true
|
|
509
|
+
});
|
|
510
|
+
if (refreshed) {
|
|
511
|
+
this.config.onCredentialRotated?.({ reason: "unauthorized" });
|
|
512
|
+
finalOptions = {
|
|
513
|
+
...finalOptions,
|
|
514
|
+
headers: {
|
|
515
|
+
...finalOptions.headers,
|
|
516
|
+
Authorization: `${refreshed.scheme ?? "Bearer"} ${refreshed.token}`
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
response = await fetch(url, { ...finalOptions, signal: controller.signal });
|
|
520
|
+
}
|
|
521
|
+
}
|
|
472
522
|
clearTimeout(timeoutId);
|
|
473
523
|
if (this.rateLimitTracker) {
|
|
474
524
|
this.rateLimitTracker.updateFromHeaders(response.headers);
|
|
@@ -557,9 +607,11 @@ var BaseClient = class {
|
|
|
557
607
|
*/
|
|
558
608
|
async requestWithRetry(endpoint, options = {}, serviceURL, retries = this.config.retries, requestOptions) {
|
|
559
609
|
let lastError;
|
|
610
|
+
const idempotencyKey = this.resolveIdempotencyKey(options.method || "GET", requestOptions);
|
|
611
|
+
const attemptOptions = idempotencyKey ? { ...requestOptions, idempotencyKey } : requestOptions;
|
|
560
612
|
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
561
613
|
try {
|
|
562
|
-
return await this.request(endpoint, options, serviceURL,
|
|
614
|
+
return await this.request(endpoint, options, serviceURL, attemptOptions);
|
|
563
615
|
} catch (error) {
|
|
564
616
|
lastError = error instanceof Error ? error : new Error("Unknown error");
|
|
565
617
|
if (requestOptions?.signal?.aborted) {
|
|
@@ -656,6 +708,9 @@ var BaseClient = class {
|
|
|
656
708
|
if (config.interceptors) {
|
|
657
709
|
this.interceptors = config.interceptors;
|
|
658
710
|
}
|
|
711
|
+
if (config.authProvider !== void 0 || config.apiKey !== void 0) {
|
|
712
|
+
this.authProvider = this.config.authProvider ?? (this.config.apiKey ? new StaticApiKeyProvider(this.config.apiKey) : void 0);
|
|
713
|
+
}
|
|
659
714
|
}
|
|
660
715
|
/**
|
|
661
716
|
* Get current configuration (readonly)
|
|
@@ -1714,9 +1769,6 @@ var ComplianceClient = class {
|
|
|
1714
1769
|
if (cipherTextResult.risk?.is_blocked) {
|
|
1715
1770
|
blockReasons.push(...cipherTextResult.risk.block_reasons_structured ?? []);
|
|
1716
1771
|
}
|
|
1717
|
-
if (cipherTextResult.risk?.location_mismatch) {
|
|
1718
|
-
blockReasons.push(sdkReasons.gpsIPMismatch());
|
|
1719
|
-
}
|
|
1720
1772
|
}
|
|
1721
1773
|
if (geoVerification.gps_required && !cipherTextResult) {
|
|
1722
1774
|
blockReasons.push(sdkReasons.gpsRequired());
|