vesant-sdk 1.0.4

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 (50) hide show
  1. package/README.md +247 -0
  2. package/dist/client-CA9Wr_qb.d.ts +1108 -0
  3. package/dist/client-DMNkESa0.d.mts +1108 -0
  4. package/dist/compliance/index.d.mts +543 -0
  5. package/dist/compliance/index.d.ts +543 -0
  6. package/dist/compliance/index.js +2133 -0
  7. package/dist/compliance/index.js.map +1 -0
  8. package/dist/compliance/index.mjs +2130 -0
  9. package/dist/compliance/index.mjs.map +1 -0
  10. package/dist/geolocation/index.d.mts +73 -0
  11. package/dist/geolocation/index.d.ts +73 -0
  12. package/dist/geolocation/index.js +1100 -0
  13. package/dist/geolocation/index.js.map +1 -0
  14. package/dist/geolocation/index.mjs +1094 -0
  15. package/dist/geolocation/index.mjs.map +1 -0
  16. package/dist/index.d.mts +50 -0
  17. package/dist/index.d.ts +50 -0
  18. package/dist/index.js +2968 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/index.mjs +2948 -0
  21. package/dist/index.mjs.map +1 -0
  22. package/dist/kyc/core.d.mts +3 -0
  23. package/dist/kyc/core.d.ts +3 -0
  24. package/dist/kyc/core.js +773 -0
  25. package/dist/kyc/core.js.map +1 -0
  26. package/dist/kyc/core.mjs +771 -0
  27. package/dist/kyc/core.mjs.map +1 -0
  28. package/dist/kyc/index.d.mts +734 -0
  29. package/dist/kyc/index.d.ts +734 -0
  30. package/dist/kyc/index.js +773 -0
  31. package/dist/kyc/index.js.map +1 -0
  32. package/dist/kyc/index.mjs +771 -0
  33. package/dist/kyc/index.mjs.map +1 -0
  34. package/dist/react.d.mts +487 -0
  35. package/dist/react.d.ts +487 -0
  36. package/dist/react.js +1122 -0
  37. package/dist/react.js.map +1 -0
  38. package/dist/react.mjs +1102 -0
  39. package/dist/react.mjs.map +1 -0
  40. package/dist/risk-profile/index.d.mts +228 -0
  41. package/dist/risk-profile/index.d.ts +228 -0
  42. package/dist/risk-profile/index.js +548 -0
  43. package/dist/risk-profile/index.js.map +1 -0
  44. package/dist/risk-profile/index.mjs +546 -0
  45. package/dist/risk-profile/index.mjs.map +1 -0
  46. package/dist/types-Bnsnejor.d.mts +150 -0
  47. package/dist/types-Bnsnejor.d.ts +150 -0
  48. package/dist/types-CFupjwi8.d.ts +213 -0
  49. package/dist/types-CqOLbaXk.d.mts +213 -0
  50. package/package.json +94 -0
@@ -0,0 +1,487 @@
1
+ import { G as GeolocationClient, E as UseGeolocationOptions, F as UseGeolocationResult, H as UseAlertsOptions, I as UseAlertsResult, q as DashboardMetrics, Z as UseLocationRequestsOptions, _ as UseLocationRequestsResult, $ as UseLocationCaptureOptions, a0 as UseLocationCaptureResult, D as DeviceFingerprintRequest } from './client-CA9Wr_qb.js';
2
+ export { useCipherText } from './geolocation/index.js';
3
+ import { KycClient, UseKycSubmissionOptions, UseKycSubmissionResult, UseKycRequestsOptions, UseKycRequestsResult, UseKycAlertsOptions, UseKycAlertsResult, UseKycOverviewOptions, UseKycOverviewResult, UseKycPreferencesResult } from './kyc/index.js';
4
+ import './types-Bnsnejor.js';
5
+ import './types-CFupjwi8.js';
6
+
7
+ /**
8
+ * React Hooks for CGS Geolocation SDK
9
+ *
10
+ * Provides convenient React hooks for using the geolocation service in Next.js applications.
11
+ */
12
+
13
+ /**
14
+ * React hook for IP verification and compliance checking
15
+ *
16
+ * @param client - GeolocationClient instance
17
+ * @param options - Hook options
18
+ * @returns Geolocation verification state and methods
19
+ *
20
+ * @example
21
+ * ```tsx
22
+ * function LoginPage() {
23
+ * const { verification, loading, error, verifyIP } = useGeolocation(client, {
24
+ * autoVerify: true,
25
+ * eventType: "login",
26
+ * includeDeviceFingerprint: true
27
+ * });
28
+ *
29
+ * useEffect(() => {
30
+ * if (verification?.is_blocked) {
31
+ * alert("Access blocked: " + verification.risk_reasons.join(", "));
32
+ * }
33
+ * }, [verification]);
34
+ *
35
+ * return <div>Risk Level: {verification?.risk_level}</div>;
36
+ * }
37
+ * ```
38
+ */
39
+ declare function useGeolocation(client: GeolocationClient, options?: UseGeolocationOptions): UseGeolocationResult;
40
+ /**
41
+ * React hook for alert management
42
+ *
43
+ * @param client - GeolocationClient instance
44
+ * @param options - Hook options
45
+ * @returns Alert state and management methods
46
+ *
47
+ * @example
48
+ * ```tsx
49
+ * function AlertDashboard() {
50
+ * const {
51
+ * alerts,
52
+ * total,
53
+ * loading,
54
+ * fetchAlerts,
55
+ * updateStatus,
56
+ * resolveAlert
57
+ * } = useAlerts(client, {
58
+ * autoFetch: true,
59
+ * filters: { status: "active", severity: "critical" },
60
+ * pollInterval: 30000 // Poll every 30 seconds
61
+ * });
62
+ *
63
+ * return (
64
+ * <div>
65
+ * <h2>{total} Alerts</h2>
66
+ * {alerts.map(alert => (
67
+ * <AlertCard
68
+ * key={alert.id}
69
+ * alert={alert}
70
+ * onResolve={() => resolveAlert(alert.id, "resolved", "Fixed")}
71
+ * />
72
+ * ))}
73
+ * </div>
74
+ * );
75
+ * }
76
+ * ```
77
+ */
78
+ declare function useAlerts(client: GeolocationClient, options?: UseAlertsOptions): UseAlertsResult;
79
+ /**
80
+ * React hook for dashboard metrics
81
+ *
82
+ * @param client - GeolocationClient instance
83
+ * @param timeRangeHours - Time range in hours (default: 24)
84
+ * @param autoFetch - Auto-fetch metrics on mount (default: true)
85
+ * @returns Dashboard metrics state
86
+ *
87
+ * @example
88
+ * ```tsx
89
+ * function Dashboard() {
90
+ * const { metrics, loading, refresh } = useDashboardMetrics(client, 168); // Last 7 days
91
+ *
92
+ * if (loading) return <Spinner />;
93
+ *
94
+ * return (
95
+ * <div>
96
+ * <h2>Dashboard</h2>
97
+ * <MetricCard label="Total Alerts" value={metrics.total_alerts} />
98
+ * <MetricCard label="Critical" value={metrics.critical_alerts} />
99
+ * <MetricCard label="Active" value={metrics.active_alerts} />
100
+ * </div>
101
+ * );
102
+ * }
103
+ * ```
104
+ */
105
+ declare function useDashboardMetrics(client: GeolocationClient, timeRangeHours?: number, autoFetch?: boolean): {
106
+ metrics: DashboardMetrics | null;
107
+ loading: boolean;
108
+ error: Error | null;
109
+ refresh: () => Promise<void>;
110
+ };
111
+ /**
112
+ * Get browser information
113
+ */
114
+ declare function getBrowserInfo(): {
115
+ browser?: string;
116
+ browser_version?: string;
117
+ os?: string;
118
+ };
119
+ /**
120
+ * Create a complete device fingerprint for the current browser
121
+ */
122
+ declare function createDeviceFingerprint(): DeviceFingerprintRequest;
123
+ /**
124
+ * React hook for managing location requests (admin/compliance officer)
125
+ *
126
+ * @param client - GeolocationClient instance
127
+ * @param options - Hook options
128
+ * @returns Location request state and management methods
129
+ *
130
+ * @example
131
+ * ```tsx
132
+ * function LocationRequestDashboard() {
133
+ * const {
134
+ * requests,
135
+ * total,
136
+ * loading,
137
+ * createRequest,
138
+ * cancelRequest,
139
+ * refresh
140
+ * } = useLocationRequests(client, {
141
+ * autoFetch: true,
142
+ * filters: { status: 'pending' },
143
+ * pollInterval: 30000
144
+ * });
145
+ *
146
+ * const handleCreate = async () => {
147
+ * const result = await createRequest({
148
+ * user_id: 'customer_123',
149
+ * channel: 'sms',
150
+ * phone: '+1234567890',
151
+ * reason: 'Transaction verification'
152
+ * });
153
+ * console.log('Share link:', result.share_link);
154
+ * };
155
+ *
156
+ * return (
157
+ * <div>
158
+ * <h2>{total} Location Requests</h2>
159
+ * <button onClick={handleCreate}>Create Request</button>
160
+ * {requests.map(req => (
161
+ * <LocationRequestCard
162
+ * key={req.id}
163
+ * request={req}
164
+ * onCancel={() => cancelRequest(req.id)}
165
+ * />
166
+ * ))}
167
+ * </div>
168
+ * );
169
+ * }
170
+ * ```
171
+ */
172
+ declare function useLocationRequests(client: GeolocationClient, options?: UseLocationRequestsOptions): UseLocationRequestsResult;
173
+ /**
174
+ * React hook for location capture (customer-facing)
175
+ *
176
+ * Use this hook in the customer's browser to capture and submit their location.
177
+ * The token is obtained from the share link sent via SMS/email.
178
+ *
179
+ * @param client - GeolocationClient instance
180
+ * @param options - Hook options with token
181
+ * @returns Location capture state and methods
182
+ *
183
+ * @example
184
+ * ```tsx
185
+ * function LocationSharePage({ token }: { token: string }) {
186
+ * const {
187
+ * shareInfo,
188
+ * loading,
189
+ * submitting,
190
+ * error,
191
+ * isExpired,
192
+ * isCompleted,
193
+ * captureAndSubmitGPS
194
+ * } = useLocationCapture(client, {
195
+ * token,
196
+ * autoFetch: true
197
+ * });
198
+ *
199
+ * if (loading) return <Spinner />;
200
+ * if (isExpired) return <ExpiredMessage />;
201
+ * if (isCompleted) return <ThankYouMessage />;
202
+ *
203
+ * return (
204
+ * <div>
205
+ * <p>Reason: {shareInfo?.reason}</p>
206
+ * <button
207
+ * onClick={captureAndSubmitGPS}
208
+ * disabled={submitting}
209
+ * >
210
+ * {submitting ? 'Submitting...' : 'Share My Location'}
211
+ * </button>
212
+ * {error && <ErrorMessage error={error} />}
213
+ * </div>
214
+ * );
215
+ * }
216
+ * ```
217
+ */
218
+ declare function useLocationCapture(client: GeolocationClient, options: UseLocationCaptureOptions): UseLocationCaptureResult;
219
+
220
+ /**
221
+ * React Hooks for CGS KYC SDK
222
+ *
223
+ * Provides convenient React hooks for using the KYC service in Next.js applications.
224
+ */
225
+
226
+ /**
227
+ * React hook for submitting KYC document verification
228
+ *
229
+ * @param client - KycClient instance
230
+ * @param options - Hook options
231
+ * @returns KYC submission state and methods
232
+ *
233
+ * @example
234
+ * ```tsx
235
+ * function KycForm() {
236
+ * const { submit, submission, loading, error, reset } = useKycSubmission(client, {
237
+ * onComplete: (result) => {
238
+ * console.log("Verification submitted:", result.reference);
239
+ * },
240
+ * onError: (err) => {
241
+ * console.error("Submission failed:", err.message);
242
+ * }
243
+ * });
244
+ *
245
+ * const handleSubmit = async (formData: FormData) => {
246
+ * await submit({
247
+ * reference: formData.get("customerId"),
248
+ * email: formData.get("email"),
249
+ * document: {
250
+ * proof: formData.get("documentImage"),
251
+ * selected_type: ["id_card", "passport"]
252
+ * }
253
+ * });
254
+ * };
255
+ *
256
+ * return (
257
+ * <form onSubmit={handleSubmit}>
258
+ * {loading && <Spinner />}
259
+ * {error && <ErrorMessage>{error.message}</ErrorMessage>}
260
+ * {submission && <SuccessMessage>Submitted: {submission.reference}</SuccessMessage>}
261
+ * </form>
262
+ * );
263
+ * }
264
+ * ```
265
+ */
266
+ declare function useKycSubmission(client: KycClient, options?: UseKycSubmissionOptions): UseKycSubmissionResult;
267
+ /**
268
+ * React hook for managing KYC requests
269
+ *
270
+ * @param client - KycClient instance
271
+ * @param options - Hook options
272
+ * @returns KYC requests state and management methods
273
+ *
274
+ * @example
275
+ * ```tsx
276
+ * function KycDashboard() {
277
+ * const {
278
+ * requests,
279
+ * total,
280
+ * loading,
281
+ * fetchRequests,
282
+ * updateStatus
283
+ * } = useKycRequests(client, {
284
+ * autoFetch: true,
285
+ * filters: { status: "pending" },
286
+ * pagination: { page: 1, page_size: 20 }
287
+ * });
288
+ *
289
+ * return (
290
+ * <div>
291
+ * <h2>{total} Pending KYC Requests</h2>
292
+ * {requests.map(req => (
293
+ * <KycCard
294
+ * key={req.id}
295
+ * request={req}
296
+ * onApprove={() => updateStatus(req.reference, "accepted", "Verified")}
297
+ * onReject={() => updateStatus(req.reference, "declined", "Invalid document")}
298
+ * />
299
+ * ))}
300
+ * </div>
301
+ * );
302
+ * }
303
+ * ```
304
+ */
305
+ declare function useKycRequests(client: KycClient, options?: UseKycRequestsOptions): UseKycRequestsResult;
306
+ /**
307
+ * React hook for managing KYC alerts
308
+ *
309
+ * @param client - KycClient instance
310
+ * @param options - Hook options
311
+ * @returns KYC alerts state and management methods
312
+ *
313
+ * @example
314
+ * ```tsx
315
+ * function AlertsPanel() {
316
+ * const {
317
+ * alerts,
318
+ * total,
319
+ * loading,
320
+ * fetchAlerts,
321
+ * updateAlert
322
+ * } = useKycAlerts(client, {
323
+ * autoFetch: true,
324
+ * filters: { status: ["pending", "in_progress"], risk: "critical" },
325
+ * pollInterval: 30000
326
+ * });
327
+ *
328
+ * return (
329
+ * <div>
330
+ * <h2>{total} Critical Alerts</h2>
331
+ * {alerts.map(alert => (
332
+ * <AlertCard
333
+ * key={alert.id}
334
+ * alert={alert}
335
+ * onAssign={(userId) => updateAlert(alert.id, { assigned_for: userId, status: "in_progress" })}
336
+ * onResolve={() => updateAlert(alert.id, { status: "resolved", reason: "Verified" })}
337
+ * />
338
+ * ))}
339
+ * </div>
340
+ * );
341
+ * }
342
+ * ```
343
+ */
344
+ declare function useKycAlerts(client: KycClient, options?: UseKycAlertsOptions): UseKycAlertsResult;
345
+ /**
346
+ * React hook for KYC overview statistics
347
+ *
348
+ * @param client - KycClient instance
349
+ * @param options - Hook options
350
+ * @returns KYC overview state
351
+ *
352
+ * @example
353
+ * ```tsx
354
+ * function KycStats() {
355
+ * const { overview, loading, refresh } = useKycOverview(client, {
356
+ * autoFetch: true,
357
+ * fromDate: "2024-01-01T00:00:00Z",
358
+ * toDate: "2024-12-31T23:59:59Z"
359
+ * });
360
+ *
361
+ * if (loading) return <Spinner />;
362
+ *
363
+ * return (
364
+ * <div>
365
+ * <StatCard label="Total" value={overview?.total} />
366
+ * <StatCard label="Pending" value={overview?.pending} />
367
+ * <StatCard label="Approved" value={overview?.approved} />
368
+ * <StatCard label="Rejected" value={overview?.rejected} />
369
+ * <StatCard label="High Risk" value={overview?.high_risk} />
370
+ * </div>
371
+ * );
372
+ * }
373
+ * ```
374
+ */
375
+ declare function useKycOverview(client: KycClient, options?: UseKycOverviewOptions): UseKycOverviewResult;
376
+ /**
377
+ * React hook for managing KYC preferences
378
+ *
379
+ * @param client - KycClient instance
380
+ * @param autoFetch - Auto-fetch preferences on mount (default: true)
381
+ * @returns KYC preferences state and methods
382
+ *
383
+ * @example
384
+ * ```tsx
385
+ * function PreferencesForm() {
386
+ * const { preferences, loading, updatePreferences, refresh } = useKycPreferences(client);
387
+ *
388
+ * const handleUpdate = async (e: FormEvent) => {
389
+ * e.preventDefault();
390
+ * await updatePreferences({
391
+ * is_face_verification_required: true,
392
+ * required_document_count: 2
393
+ * });
394
+ * };
395
+ *
396
+ * if (loading) return <Spinner />;
397
+ *
398
+ * return (
399
+ * <form onSubmit={handleUpdate}>
400
+ * <Checkbox
401
+ * label="Require Face Verification"
402
+ * checked={preferences?.is_face_verification_required}
403
+ * />
404
+ * <NumberInput
405
+ * label="Required Documents"
406
+ * value={preferences?.required_document_count}
407
+ * />
408
+ * <Button type="submit">Save</Button>
409
+ * </form>
410
+ * );
411
+ * }
412
+ * ```
413
+ */
414
+ declare function useKycPreferences(client: KycClient, autoFetch?: boolean): UseKycPreferencesResult;
415
+ /**
416
+ * Convert a File to base64 string for document upload
417
+ *
418
+ * @param file - File object from input or drag-drop
419
+ * @returns Base64 encoded string
420
+ *
421
+ * @example
422
+ * ```typescript
423
+ * const handleFileSelect = async (e: ChangeEvent<HTMLInputElement>) => {
424
+ * const file = e.target.files?.[0];
425
+ * if (file) {
426
+ * const base64 = await fileToBase64(file);
427
+ * setDocumentProof(base64);
428
+ * }
429
+ * };
430
+ * ```
431
+ */
432
+ declare function fileToBase64(file: File): Promise<string>;
433
+ /**
434
+ * Validate file type for document upload
435
+ *
436
+ * @param file - File object to validate
437
+ * @param allowedTypes - Array of allowed MIME types
438
+ * @returns boolean indicating if file type is valid
439
+ *
440
+ * @example
441
+ * ```typescript
442
+ * const validTypes = ['image/jpeg', 'image/png', 'application/pdf'];
443
+ * if (!isValidFileType(file, validTypes)) {
444
+ * alert('Invalid file type. Please upload a JPG, PNG, or PDF.');
445
+ * }
446
+ * ```
447
+ */
448
+ declare function isValidFileType(file: File, allowedTypes?: string[]): boolean;
449
+ /**
450
+ * Validate file size for document upload
451
+ *
452
+ * @param file - File object to validate
453
+ * @param maxSizeBytes - Maximum file size in bytes (default: 10MB)
454
+ * @returns boolean indicating if file size is valid
455
+ *
456
+ * @example
457
+ * ```typescript
458
+ * const maxSize = 5 * 1024 * 1024; // 5MB
459
+ * if (!isValidFileSize(file, maxSize)) {
460
+ * alert('File too large. Maximum size is 5MB.');
461
+ * }
462
+ * ```
463
+ */
464
+ declare function isValidFileSize(file: File, maxSizeBytes?: number): boolean;
465
+ /**
466
+ * Format KYC status for display
467
+ *
468
+ * @param status - KYC status
469
+ * @returns Human-readable status string
470
+ */
471
+ declare function formatKycStatus(status: string): string;
472
+ /**
473
+ * Get status color for UI display
474
+ *
475
+ * @param status - KYC status
476
+ * @returns CSS color class or hex color
477
+ */
478
+ declare function getStatusColor(status: string): string;
479
+ /**
480
+ * Get risk level color for UI display
481
+ *
482
+ * @param risk - Risk level
483
+ * @returns CSS color class or hex color
484
+ */
485
+ declare function getRiskColor(risk: string): string;
486
+
487
+ export { UseAlertsOptions, UseAlertsResult, UseGeolocationOptions, UseGeolocationResult, UseKycAlertsOptions, UseKycAlertsResult, UseKycOverviewOptions, UseKycOverviewResult, UseKycPreferencesResult, UseKycRequestsOptions, UseKycRequestsResult, UseKycSubmissionOptions, UseKycSubmissionResult, UseLocationCaptureOptions, UseLocationCaptureResult, UseLocationRequestsOptions, UseLocationRequestsResult, createDeviceFingerprint, fileToBase64, formatKycStatus, getBrowserInfo, getRiskColor, getStatusColor, isValidFileSize, isValidFileType, useAlerts, useDashboardMetrics, useGeolocation, useKycAlerts, useKycOverview, useKycPreferences, useKycRequests, useKycSubmission, useLocationCapture, useLocationRequests };