vesant-sdk 1.0.8 → 1.1.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.
- package/README.md +149 -29
- package/dist/client-B7YzKVEm.d.mts +52 -0
- package/dist/client-BaNLT2Df.d.ts +52 -0
- package/dist/client-VKJg2GGT.d.mts +253 -0
- package/dist/client-hXdrPhA4.d.ts +253 -0
- package/dist/compliance/index.d.mts +21 -159
- package/dist/compliance/index.d.ts +21 -159
- package/dist/compliance/index.js +336 -842
- package/dist/compliance/index.js.map +1 -1
- package/dist/compliance/index.mjs +336 -842
- package/dist/compliance/index.mjs.map +1 -1
- package/dist/geolocation/index.d.mts +7 -25
- package/dist/geolocation/index.d.ts +7 -25
- package/dist/geolocation/index.js +222 -406
- package/dist/geolocation/index.js.map +1 -1
- package/dist/geolocation/index.mjs +223 -406
- package/dist/geolocation/index.mjs.map +1 -1
- package/dist/index.d.mts +18 -7
- package/dist/index.d.ts +18 -7
- package/dist/index.js +445 -952
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +443 -952
- package/dist/index.mjs.map +1 -1
- package/dist/kyc/core.d.mts +3 -2
- package/dist/kyc/core.d.ts +3 -2
- package/dist/kyc/core.js +118 -36
- package/dist/kyc/core.js.map +1 -1
- package/dist/kyc/core.mjs +118 -36
- package/dist/kyc/core.mjs.map +1 -1
- package/dist/kyc/index.d.mts +3 -2
- package/dist/kyc/index.d.ts +3 -2
- package/dist/kyc/index.js +118 -36
- package/dist/kyc/index.js.map +1 -1
- package/dist/kyc/index.mjs +118 -36
- package/dist/kyc/index.mjs.map +1 -1
- package/dist/react.d.mts +174 -149
- package/dist/react.d.ts +174 -149
- package/dist/react.js +544 -481
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +542 -481
- package/dist/react.mjs.map +1 -1
- package/dist/risk-profile/index.d.mts +12 -146
- package/dist/risk-profile/index.d.ts +12 -146
- package/dist/risk-profile/index.js +137 -255
- package/dist/risk-profile/index.js.map +1 -1
- package/dist/risk-profile/index.mjs +137 -255
- package/dist/risk-profile/index.mjs.map +1 -1
- package/dist/{types-CFupjwi8.d.ts → types-BF8mYH2W.d.ts} +1 -1
- package/dist/{types-CqOLbaXk.d.mts → types-BQTkTvNp.d.mts} +1 -1
- package/dist/{types-Bnsnejor.d.mts → types-DBGM-bFB.d.mts} +26 -48
- package/dist/{types-Bnsnejor.d.ts → types-DBGM-bFB.d.ts} +26 -48
- package/dist/{client-D0xQUtlw.d.ts → types-DGbuL8c0.d.mts} +32 -457
- package/dist/{client-C2JxOxLE.d.mts → types-DgNbBnEH.d.ts} +32 -457
- package/package.json +11 -7
package/README.md
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
# Vesant Compliance SDK
|
|
2
2
|
|
|
3
|
-
> TypeScript SDK for Vesant Compliance Platform - Geolocation Verification, Risk Profiling, and Compliance Orchestration
|
|
3
|
+
> TypeScript SDK for Vesant Compliance Platform - Geolocation Verification, Risk Profiling, KYC, and Compliance Orchestration
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
7
|
- **Geolocation Compliance** - IP verification, VPN/proxy detection, jurisdiction checks, device fingerprinting
|
|
8
|
-
- **
|
|
8
|
+
- **CipherText** - Encrypted device/location data collection with GPS auto-detection
|
|
9
|
+
- **Risk Profiling** - Customer risk profile creation and management
|
|
10
|
+
- **KYC** - Document verification, submission links, and status tracking
|
|
9
11
|
- **Compliance Orchestration** - Unified registration, login, and transaction verification
|
|
10
|
-
- **
|
|
12
|
+
- **Live Location Requests** - Request and capture GPS location from customers via SMS/email
|
|
13
|
+
- **React Hooks** - Ready-to-use hooks for all compliance workflows
|
|
14
|
+
- **Interceptors** - Request/response interceptors for logging, auth, and custom logic
|
|
15
|
+
- **AbortController** - Cancel in-flight requests
|
|
16
|
+
- **Structured Logging** - Pluggable logger interface
|
|
11
17
|
- **Tree-Shakeable** - Import only what you need
|
|
12
18
|
- **Type-Safe** - Full TypeScript support with detailed type definitions
|
|
13
19
|
|
|
@@ -31,7 +37,7 @@ import { ComplianceClient } from 'vesant-sdk';
|
|
|
31
37
|
const sdk = new ComplianceClient({
|
|
32
38
|
baseURL: process.env.VESANT_API_URL,
|
|
33
39
|
tenantId: process.env.VESANT_TENANT_ID,
|
|
34
|
-
apiKey: process.env.VESANT_API_KEY
|
|
40
|
+
apiKey: process.env.VESANT_API_KEY,
|
|
35
41
|
});
|
|
36
42
|
```
|
|
37
43
|
|
|
@@ -46,14 +52,13 @@ const result = await sdk.verifyAtRegistration({
|
|
|
46
52
|
deviceFingerprint: {
|
|
47
53
|
device_id: deviceId,
|
|
48
54
|
user_agent: req.headers['user-agent'],
|
|
49
|
-
platform: 'web'
|
|
50
|
-
}
|
|
55
|
+
platform: 'web',
|
|
56
|
+
},
|
|
51
57
|
});
|
|
52
58
|
|
|
53
59
|
if (result.allowed) {
|
|
54
60
|
console.log('Registration approved');
|
|
55
61
|
console.log('Customer profile:', result.profile);
|
|
56
|
-
console.log('Risk category:', result.profile.risk_category);
|
|
57
62
|
|
|
58
63
|
if (result.requiresKYC) {
|
|
59
64
|
// Redirect to KYC flow
|
|
@@ -69,7 +74,7 @@ if (result.allowed) {
|
|
|
69
74
|
const result = await sdk.verifyAtLogin({
|
|
70
75
|
customerId: 'CUST-12345',
|
|
71
76
|
ipAddress: req.ip,
|
|
72
|
-
deviceFingerprint: getDeviceFingerprint()
|
|
77
|
+
deviceFingerprint: getDeviceFingerprint(),
|
|
73
78
|
});
|
|
74
79
|
|
|
75
80
|
if (result.allowed) {
|
|
@@ -91,7 +96,7 @@ const result = await sdk.verifyAtTransaction({
|
|
|
91
96
|
ipAddress: req.ip,
|
|
92
97
|
amount: 5000,
|
|
93
98
|
currency: 'USD',
|
|
94
|
-
transactionType: 'withdrawal'
|
|
99
|
+
transactionType: 'withdrawal',
|
|
95
100
|
});
|
|
96
101
|
|
|
97
102
|
if (result.allowed) {
|
|
@@ -103,6 +108,37 @@ if (result.allowed) {
|
|
|
103
108
|
}
|
|
104
109
|
```
|
|
105
110
|
|
|
111
|
+
### CipherText (Client-Side Device Fingerprinting)
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
import { generateCipherText } from 'vesant-sdk/geolocation';
|
|
115
|
+
|
|
116
|
+
// Collect device fingerprint + optional GPS on the client
|
|
117
|
+
const result = await generateCipherText({
|
|
118
|
+
reason: 'login',
|
|
119
|
+
requestLocation: true,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// Send to your backend
|
|
123
|
+
await fetch('/api/login', {
|
|
124
|
+
body: JSON.stringify({ email, password, cipherText: result.cipherText }),
|
|
125
|
+
});
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Live Location Requests
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
// Request a customer's live GPS location via SMS
|
|
132
|
+
const result = await sdk.requestCustomerLocation({
|
|
133
|
+
customerId: 'CUST-12345',
|
|
134
|
+
channel: 'sms',
|
|
135
|
+
phone: '+1234567890',
|
|
136
|
+
reason: 'Transaction verification',
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
console.log('Share link sent:', result.shareLink);
|
|
140
|
+
```
|
|
141
|
+
|
|
106
142
|
## Module-Specific Imports
|
|
107
143
|
|
|
108
144
|
Import only what you need to reduce bundle size:
|
|
@@ -115,13 +151,13 @@ import { GeolocationClient } from 'vesant-sdk/geolocation';
|
|
|
115
151
|
const geoClient = new GeolocationClient({
|
|
116
152
|
baseURL: process.env.VESANT_API_URL,
|
|
117
153
|
tenantId: process.env.VESANT_TENANT_ID,
|
|
118
|
-
apiKey: process.env.VESANT_API_KEY
|
|
154
|
+
apiKey: process.env.VESANT_API_KEY,
|
|
119
155
|
});
|
|
120
156
|
|
|
121
157
|
const verification = await geoClient.verifyIP({
|
|
122
158
|
ip_address: '8.8.8.8',
|
|
123
159
|
user_id: 'user-123',
|
|
124
|
-
event_type: 'login'
|
|
160
|
+
event_type: 'login',
|
|
125
161
|
});
|
|
126
162
|
|
|
127
163
|
console.log('Country:', verification.location.country_iso);
|
|
@@ -137,7 +173,7 @@ import { RiskProfileClient } from 'vesant-sdk/risk-profile';
|
|
|
137
173
|
const riskClient = new RiskProfileClient({
|
|
138
174
|
baseURL: process.env.VESANT_API_URL,
|
|
139
175
|
tenantId: process.env.VESANT_TENANT_ID,
|
|
140
|
-
apiKey: process.env.VESANT_API_KEY
|
|
176
|
+
apiKey: process.env.VESANT_API_KEY,
|
|
141
177
|
});
|
|
142
178
|
|
|
143
179
|
const profile = await riskClient.getProfile('CUST-12345');
|
|
@@ -145,10 +181,33 @@ console.log('Risk score:', profile.risk_score);
|
|
|
145
181
|
console.log('Risk category:', profile.risk_category);
|
|
146
182
|
```
|
|
147
183
|
|
|
184
|
+
### KYC Only
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
import { KycClient } from 'vesant-sdk/kyc';
|
|
188
|
+
|
|
189
|
+
const kycClient = new KycClient({
|
|
190
|
+
baseURL: process.env.VESANT_API_URL,
|
|
191
|
+
tenantId: process.env.VESANT_TENANT_ID,
|
|
192
|
+
apiKey: process.env.VESANT_API_KEY,
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
const { link, kyc_id } = await kycClient.requestKycSubmitLink({
|
|
196
|
+
user_id: 'user-123',
|
|
197
|
+
redirect_url: 'https://yourapp.com/kyc-complete',
|
|
198
|
+
});
|
|
199
|
+
```
|
|
200
|
+
|
|
148
201
|
## React Hooks
|
|
149
202
|
|
|
150
203
|
```typescript
|
|
151
|
-
import {
|
|
204
|
+
import {
|
|
205
|
+
useRegistration,
|
|
206
|
+
useLoginVerification,
|
|
207
|
+
useTransactionVerification,
|
|
208
|
+
useCipherText,
|
|
209
|
+
useCustomerProfile,
|
|
210
|
+
} from 'vesant-sdk/react';
|
|
152
211
|
|
|
153
212
|
function RegistrationForm() {
|
|
154
213
|
const { verifyRegistration, loading, error } = useRegistration(sdk, {
|
|
@@ -158,7 +217,7 @@ function RegistrationForm() {
|
|
|
158
217
|
},
|
|
159
218
|
onBlocked: (result) => {
|
|
160
219
|
alert(`Registration blocked: ${result.blockReasons.join(', ')}`);
|
|
161
|
-
}
|
|
220
|
+
},
|
|
162
221
|
});
|
|
163
222
|
|
|
164
223
|
const handleSubmit = async (formData) => {
|
|
@@ -166,7 +225,7 @@ function RegistrationForm() {
|
|
|
166
225
|
customerId: formData.customerId,
|
|
167
226
|
fullName: formData.fullName,
|
|
168
227
|
emailAddress: formData.email,
|
|
169
|
-
ipAddress: await getClientIP()
|
|
228
|
+
ipAddress: await getClientIP(),
|
|
170
229
|
});
|
|
171
230
|
};
|
|
172
231
|
|
|
@@ -182,16 +241,58 @@ function RegistrationForm() {
|
|
|
182
241
|
}
|
|
183
242
|
```
|
|
184
243
|
|
|
244
|
+
## Interceptors
|
|
245
|
+
|
|
246
|
+
```typescript
|
|
247
|
+
const sdk = new ComplianceClient({
|
|
248
|
+
baseURL: process.env.VESANT_API_URL,
|
|
249
|
+
tenantId: process.env.VESANT_TENANT_ID,
|
|
250
|
+
apiKey: process.env.VESANT_API_KEY,
|
|
251
|
+
interceptors: [
|
|
252
|
+
{
|
|
253
|
+
onRequest: (url, options) => {
|
|
254
|
+
console.log(`[SDK] ${options.method || 'GET'} ${url}`);
|
|
255
|
+
return options;
|
|
256
|
+
},
|
|
257
|
+
onResponse: (url, data) => {
|
|
258
|
+
console.log(`[SDK] Response from ${url}`);
|
|
259
|
+
return data;
|
|
260
|
+
},
|
|
261
|
+
onError: (url, error) => {
|
|
262
|
+
console.error(`[SDK] Error from ${url}:`, error.message);
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
],
|
|
266
|
+
});
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## AbortController
|
|
270
|
+
|
|
271
|
+
```typescript
|
|
272
|
+
const controller = new AbortController();
|
|
273
|
+
|
|
274
|
+
// Cancel after 5 seconds
|
|
275
|
+
setTimeout(() => controller.abort(), 5000);
|
|
276
|
+
|
|
277
|
+
const result = await sdk.verifyAtLogin(
|
|
278
|
+
{ customerId: 'CUST-12345', ipAddress: req.ip },
|
|
279
|
+
{ signal: controller.signal }
|
|
280
|
+
);
|
|
281
|
+
```
|
|
282
|
+
|
|
185
283
|
## Configuration
|
|
186
284
|
|
|
187
285
|
```typescript
|
|
188
286
|
interface ComplianceClientConfig {
|
|
189
|
-
baseURL: string;
|
|
190
|
-
tenantId: string;
|
|
191
|
-
apiKey
|
|
192
|
-
timeout?: number;
|
|
193
|
-
retries?: number;
|
|
194
|
-
debug?: boolean;
|
|
287
|
+
baseURL: string; // Vesant API Gateway URL
|
|
288
|
+
tenantId: string; // Your tenant ID
|
|
289
|
+
apiKey?: string; // Your API key
|
|
290
|
+
timeout?: number; // Request timeout in ms (default: 10000)
|
|
291
|
+
retries?: number; // Retry attempts (default: 3)
|
|
292
|
+
debug?: boolean; // Enable debug logging (default: false)
|
|
293
|
+
autoCreateProfiles?: boolean; // Auto-create risk profiles (default: true)
|
|
294
|
+
interceptors?: Interceptor[]; // Request/response interceptors
|
|
295
|
+
logger?: Logger; // Custom logger instance
|
|
195
296
|
}
|
|
196
297
|
```
|
|
197
298
|
|
|
@@ -204,39 +305,58 @@ interface ComplianceClientConfig {
|
|
|
204
305
|
| `verifyAtRegistration(request)` | Verify new user registration |
|
|
205
306
|
| `verifyAtLogin(request)` | Verify user login |
|
|
206
307
|
| `verifyAtTransaction(request)` | Verify financial transaction |
|
|
308
|
+
| `verifyEvent(request)` | Generic event verification |
|
|
207
309
|
| `requestCustomerLocation(input)` | Request live GPS location from customer |
|
|
208
310
|
| `getLocationRequest(requestId)` | Get location request status |
|
|
311
|
+
| `listLocationRequests(filters)` | List location requests |
|
|
312
|
+
| `cancelLocationRequest(requestId)` | Cancel a pending location request |
|
|
313
|
+
| `updateCurrencyRates(rates)` | Update exchange rates for transaction risk |
|
|
209
314
|
|
|
210
315
|
### GeolocationClient
|
|
211
316
|
|
|
212
317
|
| Method | Description |
|
|
213
318
|
|--------|-------------|
|
|
214
319
|
| `verifyIP(request)` | Verify IP address and check compliance |
|
|
320
|
+
| `checkCompliance(countryISO)` | Check jurisdiction compliance |
|
|
215
321
|
| `validateCipherText(cipherText, userId, eventType)` | Validate device fingerprint |
|
|
216
|
-
| `
|
|
217
|
-
| `
|
|
322
|
+
| `validateAndVerify(cipherText, ip, userId, eventType)` | Combined cipherText + IP verification |
|
|
323
|
+
| `getGPSConfig()` | Get GPS requirement config per event type |
|
|
324
|
+
| `createLocationRequest(request)` | Create a live location request |
|
|
325
|
+
| `captureLocation(token, capture)` | Submit location capture (customer-facing) |
|
|
218
326
|
|
|
219
327
|
### RiskProfileClient
|
|
220
328
|
|
|
221
329
|
| Method | Description |
|
|
222
330
|
|--------|-------------|
|
|
223
331
|
| `createProfile(request)` | Create customer risk profile |
|
|
224
|
-
| `getProfile(customerId)` | Get profile by customer ID |
|
|
332
|
+
| `getProfile(customerId)` | Get profile by customer ID (exact match) |
|
|
225
333
|
| `updateProfile(profileId, updates)` | Update customer profile |
|
|
226
|
-
| `
|
|
334
|
+
| `getOrCreateProfile(customerId, request)` | Idempotent get-or-create |
|
|
335
|
+
|
|
336
|
+
### KycClient
|
|
337
|
+
|
|
338
|
+
| Method | Description |
|
|
339
|
+
|--------|-------------|
|
|
340
|
+
| `requestKycSubmitLink(request)` | Generate a KYC submission link |
|
|
341
|
+
| `checkKycStatus(request)` | Check KYC verification status |
|
|
342
|
+
| `submitVerification(request)` | Submit document verification |
|
|
343
|
+
| `listKycRequests(filters)` | List KYC requests |
|
|
344
|
+
| `getPreferences()` | Get KYC preferences |
|
|
345
|
+
| `listAlerts(filters)` | List KYC alerts |
|
|
227
346
|
|
|
228
347
|
## Documentation
|
|
229
348
|
|
|
230
349
|
For detailed documentation, see the [docs](./docs) directory:
|
|
231
350
|
|
|
232
|
-
- [Installation](./docs/getting-started/installation.md)
|
|
233
351
|
- [Quick Start](./docs/getting-started/quick-start.md)
|
|
234
352
|
- [Configuration](./docs/getting-started/configuration.md)
|
|
353
|
+
- [Authentication](./docs/getting-started/authentication.md)
|
|
235
354
|
- [Registration Flow](./docs/guides/registration.md)
|
|
236
|
-
- [Login Flow](./docs/guides/login.md)
|
|
237
355
|
- [Transaction Verification](./docs/guides/transactions.md)
|
|
356
|
+
- [Next.js Integration](./docs/guides/nextjs.md)
|
|
238
357
|
- [React Hooks](./docs/react-hooks/overview.md)
|
|
239
|
-
- [Error Handling](./docs/advanced/
|
|
358
|
+
- [Error Handling & Types](./docs/advanced/types.md)
|
|
359
|
+
- [Security](./docs/advanced/security.md)
|
|
240
360
|
|
|
241
361
|
## License
|
|
242
362
|
|
|
@@ -244,4 +364,4 @@ MIT
|
|
|
244
364
|
|
|
245
365
|
## Support
|
|
246
366
|
|
|
247
|
-
For support, contact your Vesant account representative
|
|
367
|
+
For support, contact your Vesant account representative.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { a as RequiredBaseClientConfig, L as Logger, B as BaseClientConfig, R as RequestOptions } from './types-DBGM-bFB.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Base HTTP client for all CGS SDK clients
|
|
5
|
+
*
|
|
6
|
+
* Provides common functionality:
|
|
7
|
+
* - Request/response handling
|
|
8
|
+
* - Error handling
|
|
9
|
+
* - Retry logic with exponential backoff
|
|
10
|
+
* - Timeout management
|
|
11
|
+
* - Debug logging
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
declare abstract class BaseClient {
|
|
15
|
+
protected config: RequiredBaseClientConfig;
|
|
16
|
+
protected logger: Logger;
|
|
17
|
+
private interceptors;
|
|
18
|
+
constructor(config: BaseClientConfig);
|
|
19
|
+
/**
|
|
20
|
+
* Make an HTTP request with timeout and error handling
|
|
21
|
+
*/
|
|
22
|
+
protected request<T>(endpoint: string, options?: RequestInit, serviceURL?: string, requestOptions?: RequestOptions): Promise<T>;
|
|
23
|
+
/**
|
|
24
|
+
* Make an HTTP request with retry logic
|
|
25
|
+
*/
|
|
26
|
+
protected requestWithRetry<T>(endpoint: string, options?: RequestInit, serviceURL?: string, retries?: number, requestOptions?: RequestOptions): Promise<T>;
|
|
27
|
+
/**
|
|
28
|
+
* Handle error responses from API
|
|
29
|
+
*/
|
|
30
|
+
protected handleErrorResponse(status: number, data: Record<string, unknown>): never;
|
|
31
|
+
/**
|
|
32
|
+
* Build query string from parameters
|
|
33
|
+
*/
|
|
34
|
+
protected buildQueryString(params: Record<string, unknown>): string;
|
|
35
|
+
/**
|
|
36
|
+
* Update client configuration
|
|
37
|
+
*/
|
|
38
|
+
updateConfig(config: Partial<BaseClientConfig>): void;
|
|
39
|
+
/**
|
|
40
|
+
* Get current configuration (readonly)
|
|
41
|
+
*/
|
|
42
|
+
getConfig(): Readonly<BaseClientConfig>;
|
|
43
|
+
/**
|
|
44
|
+
* Health check endpoint
|
|
45
|
+
*/
|
|
46
|
+
healthCheck(): Promise<{
|
|
47
|
+
status: string;
|
|
48
|
+
timestamp: string;
|
|
49
|
+
}>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { BaseClient as B };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { a as RequiredBaseClientConfig, L as Logger, B as BaseClientConfig, R as RequestOptions } from './types-DBGM-bFB.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Base HTTP client for all CGS SDK clients
|
|
5
|
+
*
|
|
6
|
+
* Provides common functionality:
|
|
7
|
+
* - Request/response handling
|
|
8
|
+
* - Error handling
|
|
9
|
+
* - Retry logic with exponential backoff
|
|
10
|
+
* - Timeout management
|
|
11
|
+
* - Debug logging
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
declare abstract class BaseClient {
|
|
15
|
+
protected config: RequiredBaseClientConfig;
|
|
16
|
+
protected logger: Logger;
|
|
17
|
+
private interceptors;
|
|
18
|
+
constructor(config: BaseClientConfig);
|
|
19
|
+
/**
|
|
20
|
+
* Make an HTTP request with timeout and error handling
|
|
21
|
+
*/
|
|
22
|
+
protected request<T>(endpoint: string, options?: RequestInit, serviceURL?: string, requestOptions?: RequestOptions): Promise<T>;
|
|
23
|
+
/**
|
|
24
|
+
* Make an HTTP request with retry logic
|
|
25
|
+
*/
|
|
26
|
+
protected requestWithRetry<T>(endpoint: string, options?: RequestInit, serviceURL?: string, retries?: number, requestOptions?: RequestOptions): Promise<T>;
|
|
27
|
+
/**
|
|
28
|
+
* Handle error responses from API
|
|
29
|
+
*/
|
|
30
|
+
protected handleErrorResponse(status: number, data: Record<string, unknown>): never;
|
|
31
|
+
/**
|
|
32
|
+
* Build query string from parameters
|
|
33
|
+
*/
|
|
34
|
+
protected buildQueryString(params: Record<string, unknown>): string;
|
|
35
|
+
/**
|
|
36
|
+
* Update client configuration
|
|
37
|
+
*/
|
|
38
|
+
updateConfig(config: Partial<BaseClientConfig>): void;
|
|
39
|
+
/**
|
|
40
|
+
* Get current configuration (readonly)
|
|
41
|
+
*/
|
|
42
|
+
getConfig(): Readonly<BaseClientConfig>;
|
|
43
|
+
/**
|
|
44
|
+
* Health check endpoint
|
|
45
|
+
*/
|
|
46
|
+
healthCheck(): Promise<{
|
|
47
|
+
status: string;
|
|
48
|
+
timestamp: string;
|
|
49
|
+
}>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { BaseClient as B };
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { B as BaseClient } from './client-B7YzKVEm.mjs';
|
|
2
|
+
import { R as RequestOptions, P as PaginationParams } from './types-DBGM-bFB.mjs';
|
|
3
|
+
import { G as GeolocationClientConfig, V as VerifyIPRequest, L as LocationVerification, C as ComplianceCheckResponse, a as GeolocationConfigResponse, b as CipherTextReason, c as CipherTextCustomerData, d as ValidateCipherTextResponse, e as CreateLocationRequestRequest, f as LocationRequestResult, g as LocationRequest, h as LocationRequestFilters, i as LocationRequestListResponse, R as ResendLocationRequestRequest, j as LocationShareInfo, k as LocationCaptureRequest, l as LocationCaptureResponse } from './types-DGbuL8c0.mjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* GeolocationClient - TypeScript SDK for CGS Geolocation & Compliance Service
|
|
7
|
+
*
|
|
8
|
+
* Provides type-safe methods to interact with the geolocation service API.
|
|
9
|
+
* Extends BaseClient for consistent retry logic, timeout handling, and error management.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* GeolocationClient extends BaseClient for:
|
|
14
|
+
* - Consistent retry logic with exponential backoff
|
|
15
|
+
* - Unified error handling (CGSError, NetworkError, TimeoutError, etc.)
|
|
16
|
+
* - Automatic timeout management
|
|
17
|
+
* - Debug logging
|
|
18
|
+
*
|
|
19
|
+
* All geolocation verification calls use requestWithRetry() to handle
|
|
20
|
+
* transient failures gracefully.
|
|
21
|
+
*/
|
|
22
|
+
declare class GeolocationClient extends BaseClient {
|
|
23
|
+
constructor(config: GeolocationClientConfig);
|
|
24
|
+
/**
|
|
25
|
+
* Verify an IP address and check compliance
|
|
26
|
+
*
|
|
27
|
+
* Uses requestWithRetry() for automatic retry on transient failures.
|
|
28
|
+
*
|
|
29
|
+
* @param request - Verification request with IP, user ID, event type, and optional device fingerprint
|
|
30
|
+
* @returns Location verification result with risk assessment
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const result = await client.verifyIP({
|
|
35
|
+
* ip_address: "8.8.8.8",
|
|
36
|
+
* user_id: "user_123",
|
|
37
|
+
* event_type: "login",
|
|
38
|
+
* device_fingerprint: {
|
|
39
|
+
* device_id: "device_abc",
|
|
40
|
+
* user_agent: navigator.userAgent,
|
|
41
|
+
* platform: "web"
|
|
42
|
+
* }
|
|
43
|
+
* });
|
|
44
|
+
*
|
|
45
|
+
* if (result.is_blocked) {
|
|
46
|
+
* console.log("Access blocked:", result.risk_reasons);
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
verifyIP(request: VerifyIPRequest, requestOptions?: RequestOptions): Promise<LocationVerification>;
|
|
51
|
+
/**
|
|
52
|
+
* Check compliance for a specific country
|
|
53
|
+
*
|
|
54
|
+
* @param countryISO - ISO 3166-1 alpha-2 country code (e.g., "US", "GB")
|
|
55
|
+
* @returns Jurisdiction configuration and compliance status
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const compliance = await client.checkCompliance("KP"); // North Korea
|
|
60
|
+
* if (!compliance.is_compliant) {
|
|
61
|
+
* console.log("Country is not allowed:", compliance.jurisdiction?.status);
|
|
62
|
+
* }
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
checkCompliance(countryISO: string, requestOptions?: RequestOptions): Promise<ComplianceCheckResponse>;
|
|
66
|
+
/**
|
|
67
|
+
* Get the tenant's GPS requirement configuration
|
|
68
|
+
*
|
|
69
|
+
* Returns which event types require GPS location to be collected.
|
|
70
|
+
* Use this to auto-enable GPS collection in generateCipherText when required.
|
|
71
|
+
*
|
|
72
|
+
* @returns GPS requirement config per event type
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* const config = await client.getGPSConfig();
|
|
77
|
+
* if (config.require_gps.login) {
|
|
78
|
+
* // GPS is required for login — auto-enable location
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
getGPSConfig(requestOptions?: RequestOptions): Promise<GeolocationConfigResponse>;
|
|
83
|
+
/**
|
|
84
|
+
* Validate a cipherText generated by the frontend SDK
|
|
85
|
+
*
|
|
86
|
+
* The cipherText contains encrypted device fingerprint and optional location data.
|
|
87
|
+
* This method decrypts and validates the data, returning device info, location,
|
|
88
|
+
* and risk assessment.
|
|
89
|
+
*
|
|
90
|
+
* @param cipherText - The encrypted cipherText string from generateCipherText()
|
|
91
|
+
* @param userId - User ID associated with this verification
|
|
92
|
+
* @param eventType - Reason for verification (login, registration, etc.)
|
|
93
|
+
* @param expectedIP - Optional expected IP address for additional validation
|
|
94
|
+
* @param customerData - Optional customer data for risk profile creation (used when user is blocked)
|
|
95
|
+
* @returns Validation result with device info, location, and risk assessment
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* // Validate cipherText during registration with customer data
|
|
100
|
+
* const result = await client.validateCipherText(
|
|
101
|
+
* cipherText,
|
|
102
|
+
* "user_123",
|
|
103
|
+
* "registration",
|
|
104
|
+
* clientIP,
|
|
105
|
+
* {
|
|
106
|
+
* full_name: "John Doe",
|
|
107
|
+
* email: "john@example.com",
|
|
108
|
+
* country: "US",
|
|
109
|
+
* state: "CA"
|
|
110
|
+
* }
|
|
111
|
+
* );
|
|
112
|
+
*
|
|
113
|
+
* if (!result.valid) {
|
|
114
|
+
* console.log("CipherText validation failed:", result.errors);
|
|
115
|
+
* return;
|
|
116
|
+
* }
|
|
117
|
+
*
|
|
118
|
+
* if (result.risk.is_blocked) {
|
|
119
|
+
* console.log("Access blocked:", result.risk.block_reasons);
|
|
120
|
+
* // A risk profile with full customer data has been created for the alert
|
|
121
|
+
* }
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
validateCipherText(cipherText: string, userId: string, eventType: CipherTextReason, expectedIP?: string, customerData?: CipherTextCustomerData, requestOptions?: RequestOptions): Promise<ValidateCipherTextResponse>;
|
|
125
|
+
/**
|
|
126
|
+
* Validate cipherText and verify IP in a single call
|
|
127
|
+
*
|
|
128
|
+
* Combines cipherText validation with IP verification for complete
|
|
129
|
+
* location and device verification in one request.
|
|
130
|
+
*
|
|
131
|
+
* @param cipherText - The encrypted cipherText string
|
|
132
|
+
* @param ipAddress - Client IP address
|
|
133
|
+
* @param userId - User ID
|
|
134
|
+
* @param eventType - Event type (login, registration, etc.)
|
|
135
|
+
* @returns Combined validation and verification result
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```typescript
|
|
139
|
+
* const result = await client.validateAndVerify(
|
|
140
|
+
* cipherText,
|
|
141
|
+
* clientIP,
|
|
142
|
+
* "user_123",
|
|
143
|
+
* "registration"
|
|
144
|
+
* );
|
|
145
|
+
*
|
|
146
|
+
* if (!result.ciphertext_valid) {
|
|
147
|
+
* throw new Error("Device verification failed");
|
|
148
|
+
* }
|
|
149
|
+
*
|
|
150
|
+
* if (result.location.is_blocked) {
|
|
151
|
+
* throw new Error("Location not allowed");
|
|
152
|
+
* }
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
validateAndVerify(cipherText: string, ipAddress: string, userId: string, eventType: CipherTextReason, requestOptions?: RequestOptions): Promise<{
|
|
156
|
+
ciphertext_valid: boolean;
|
|
157
|
+
ciphertext_result: ValidateCipherTextResponse;
|
|
158
|
+
location: LocationVerification;
|
|
159
|
+
}>;
|
|
160
|
+
/**
|
|
161
|
+
* Create a location request to get customer's live location
|
|
162
|
+
*
|
|
163
|
+
* @param request - Location request details
|
|
164
|
+
* @returns Location request result with share link
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```typescript
|
|
168
|
+
* const result = await client.createLocationRequest({
|
|
169
|
+
* user_id: "customer_123",
|
|
170
|
+
* channel: "sms",
|
|
171
|
+
* phone: "+1234567890",
|
|
172
|
+
* reason: "Verification for high-value transaction"
|
|
173
|
+
* });
|
|
174
|
+
*
|
|
175
|
+
* console.log(`Share link sent: ${result.share_link}`);
|
|
176
|
+
* console.log(`Expires at: ${result.token_expiry}`);
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
createLocationRequest(request: CreateLocationRequestRequest, requestOptions?: RequestOptions): Promise<LocationRequestResult>;
|
|
180
|
+
/**
|
|
181
|
+
* Get a location request by ID
|
|
182
|
+
*
|
|
183
|
+
* @param requestId - Location request ID
|
|
184
|
+
* @returns Location request details
|
|
185
|
+
*/
|
|
186
|
+
getLocationRequest(requestId: string, requestOptions?: RequestOptions): Promise<LocationRequest>;
|
|
187
|
+
/**
|
|
188
|
+
* List location requests with filters and pagination
|
|
189
|
+
*
|
|
190
|
+
* @param filters - Optional filters
|
|
191
|
+
* @param pagination - Optional pagination
|
|
192
|
+
* @returns Paginated list of location requests
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```typescript
|
|
196
|
+
* const requests = await client.listLocationRequests(
|
|
197
|
+
* { status: "completed", user_id: "customer_123" },
|
|
198
|
+
* { page: 1, limit: 20 }
|
|
199
|
+
* );
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
listLocationRequests(filters?: LocationRequestFilters, pagination?: PaginationParams, requestOptions?: RequestOptions): Promise<LocationRequestListResponse>;
|
|
203
|
+
/**
|
|
204
|
+
* Cancel a pending location request
|
|
205
|
+
*
|
|
206
|
+
* @param requestId - Location request ID
|
|
207
|
+
*/
|
|
208
|
+
cancelLocationRequest(requestId: string, requestOptions?: RequestOptions): Promise<void>;
|
|
209
|
+
/**
|
|
210
|
+
* Resend notification for a location request
|
|
211
|
+
*
|
|
212
|
+
* @param requestId - Location request ID
|
|
213
|
+
* @param contact - Email or phone to send to
|
|
214
|
+
*/
|
|
215
|
+
resendLocationRequest(requestId: string, contact: ResendLocationRequestRequest, requestOptions?: RequestOptions): Promise<void>;
|
|
216
|
+
/**
|
|
217
|
+
* Get location share info (customer-facing)
|
|
218
|
+
* This is called from the customer's device to get request details
|
|
219
|
+
*
|
|
220
|
+
* @param token - Secure token from share link
|
|
221
|
+
* @returns Location share info
|
|
222
|
+
*/
|
|
223
|
+
getLocationShareInfo(token: string, requestOptions?: RequestOptions): Promise<LocationShareInfo>;
|
|
224
|
+
/**
|
|
225
|
+
* Submit location capture (customer-facing)
|
|
226
|
+
* This is called from the customer's device to submit their location
|
|
227
|
+
*
|
|
228
|
+
* @param token - Secure token from share link
|
|
229
|
+
* @param capture - Location capture data (GPS or WiFi)
|
|
230
|
+
* @returns Capture response
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* ```typescript
|
|
234
|
+
* // Using GPS (preferred)
|
|
235
|
+
* const result = await client.captureLocation(token, {
|
|
236
|
+
* latitude: 37.7749,
|
|
237
|
+
* longitude: -122.4194,
|
|
238
|
+
* accuracy: 10
|
|
239
|
+
* });
|
|
240
|
+
*
|
|
241
|
+
* // Using WiFi positioning (fallback)
|
|
242
|
+
* const result = await client.captureLocation(token, {
|
|
243
|
+
* wifi_networks: [
|
|
244
|
+
* { macAddress: "00:11:22:33:44:55", signalStrength: -50 },
|
|
245
|
+
* { macAddress: "AA:BB:CC:DD:EE:FF", signalStrength: -70 }
|
|
246
|
+
* ]
|
|
247
|
+
* });
|
|
248
|
+
* ```
|
|
249
|
+
*/
|
|
250
|
+
captureLocation(token: string, capture: LocationCaptureRequest, requestOptions?: RequestOptions): Promise<LocationCaptureResponse>;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export { GeolocationClient as G };
|