vesant-sdk 1.0.8 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +149 -29
- package/dist/{client-D0xQUtlw.d.ts → client-BfeDYmrZ.d.mts} +60 -237
- package/dist/{client-C2JxOxLE.d.mts → client-i5QtnFIa.d.ts} +60 -237
- package/dist/compliance/index.d.mts +25 -158
- package/dist/compliance/index.d.ts +25 -158
- package/dist/compliance/index.js +347 -842
- package/dist/compliance/index.js.map +1 -1
- package/dist/compliance/index.mjs +347 -842
- package/dist/compliance/index.mjs.map +1 -1
- package/dist/geolocation/index.d.mts +5 -25
- package/dist/geolocation/index.d.ts +5 -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 +16 -7
- package/dist/index.d.ts +16 -7
- package/dist/index.js +444 -940
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +442 -940
- 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 +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 +2 -2
- package/dist/kyc/index.d.ts +2 -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 +172 -149
- package/dist/react.d.ts +172 -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 +11 -146
- package/dist/risk-profile/index.d.ts +11 -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-Bnsnejor.d.mts → types-BpKxSXGF.d.mts} +31 -4
- package/dist/{types-Bnsnejor.d.ts → types-BpKxSXGF.d.ts} +31 -4
- package/dist/{types-CqOLbaXk.d.mts → types-DKCQN4C5.d.mts} +1 -1
- package/dist/{types-CFupjwi8.d.ts → types-DfHLp_tz.d.ts} +1 -1
- 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.
|