cgs-compliance-sdk 2.0.7 → 2.0.8
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-CPBy8d1H.d.mts → client-BGI23PLG.d.mts} +282 -17
- package/dist/{client-BIRcQF2C.d.ts → client-CBy3JJSM.d.ts} +282 -17
- package/dist/compliance/index.d.mts +322 -11
- package/dist/compliance/index.d.ts +322 -11
- package/dist/compliance/index.js +796 -248
- package/dist/compliance/index.js.map +1 -1
- package/dist/compliance/index.mjs +796 -248
- package/dist/compliance/index.mjs.map +1 -1
- package/dist/geolocation/index.d.mts +100 -4
- package/dist/geolocation/index.d.ts +100 -4
- package/dist/geolocation/index.js +541 -36
- package/dist/geolocation/index.js.map +1 -1
- package/dist/geolocation/index.mjs +540 -37
- 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 +881 -93
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +880 -94
- package/dist/index.mjs.map +1 -1
- package/dist/risk-profile/index.d.mts +435 -2
- package/dist/risk-profile/index.d.ts +435 -2
- package/dist/types-DxnfRzF_.d.mts +150 -0
- package/dist/types-DxnfRzF_.d.ts +150 -0
- package/package.json +1 -1
- package/dist/index-BQPX1yNM.d.ts +0 -524
- package/dist/index-CzElZ3T6.d.mts +0 -524
- package/dist/types-mQdu71xf.d.mts +0 -61
- package/dist/types-mQdu71xf.d.ts +0 -61
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as PaginationParams } from './types-
|
|
1
|
+
import { P as PaginationParams, B as BaseClient } from './types-DxnfRzF_.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* TypeScript type definitions for CGS Geolocation Service API
|
|
@@ -328,21 +328,214 @@ interface UseAlertsResult {
|
|
|
328
328
|
/** Refresh alerts */
|
|
329
329
|
refresh: () => Promise<void>;
|
|
330
330
|
}
|
|
331
|
+
type LocationRequestStatus = 'pending' | 'sent' | 'completed' | 'expired' | 'cancelled' | 'failed';
|
|
332
|
+
type LocationRequestChannel = 'sms' | 'email' | 'push';
|
|
333
|
+
interface LocationRequest {
|
|
334
|
+
id: string;
|
|
335
|
+
tenant_id: string;
|
|
336
|
+
user_id: string;
|
|
337
|
+
requested_by: string;
|
|
338
|
+
channel: LocationRequestChannel;
|
|
339
|
+
status: LocationRequestStatus;
|
|
340
|
+
reason?: string;
|
|
341
|
+
token_expires_at: string;
|
|
342
|
+
latitude?: number;
|
|
343
|
+
longitude?: number;
|
|
344
|
+
accuracy?: number;
|
|
345
|
+
country?: string;
|
|
346
|
+
country_iso?: string;
|
|
347
|
+
city?: string;
|
|
348
|
+
region?: string;
|
|
349
|
+
formatted_address?: string;
|
|
350
|
+
position_source?: string;
|
|
351
|
+
notification_sent_at?: string;
|
|
352
|
+
responded_at?: string;
|
|
353
|
+
viewed_at?: string;
|
|
354
|
+
created_at: string;
|
|
355
|
+
updated_at: string;
|
|
356
|
+
}
|
|
357
|
+
interface CreateLocationRequestRequest {
|
|
358
|
+
/** Customer user ID to request location from */
|
|
359
|
+
user_id: string;
|
|
360
|
+
/** Notification channel to use */
|
|
361
|
+
channel: LocationRequestChannel;
|
|
362
|
+
/** Reason for requesting location (for compliance/audit) */
|
|
363
|
+
reason?: string;
|
|
364
|
+
/** Customer email (required for email channel) */
|
|
365
|
+
email?: string;
|
|
366
|
+
/** Customer phone (required for SMS channel) */
|
|
367
|
+
phone?: string;
|
|
368
|
+
/** Custom expiry time in hours (default: 24) */
|
|
369
|
+
expiry_hours?: number;
|
|
370
|
+
}
|
|
371
|
+
interface LocationRequestResult {
|
|
372
|
+
request: LocationRequest;
|
|
373
|
+
share_link: string;
|
|
374
|
+
token_expiry: string;
|
|
375
|
+
}
|
|
376
|
+
interface LocationRequestFilters {
|
|
377
|
+
status?: LocationRequestStatus;
|
|
378
|
+
user_id?: string;
|
|
379
|
+
requested_by?: string;
|
|
380
|
+
channel?: LocationRequestChannel;
|
|
381
|
+
date_from?: string;
|
|
382
|
+
date_to?: string;
|
|
383
|
+
}
|
|
384
|
+
interface LocationRequestListResponse {
|
|
385
|
+
requests: LocationRequest[];
|
|
386
|
+
total: number;
|
|
387
|
+
page: number;
|
|
388
|
+
limit: number;
|
|
389
|
+
total_pages: number;
|
|
390
|
+
}
|
|
391
|
+
interface ResendLocationRequestRequest {
|
|
392
|
+
email?: string;
|
|
393
|
+
phone?: string;
|
|
394
|
+
}
|
|
395
|
+
interface WiFiNetwork {
|
|
396
|
+
/** MAC address (BSSID) */
|
|
397
|
+
macAddress: string;
|
|
398
|
+
/** Signal strength in dBm (negative number) */
|
|
399
|
+
signalStrength?: number;
|
|
400
|
+
/** WiFi channel */
|
|
401
|
+
channel?: number;
|
|
402
|
+
/** Network name (optional) */
|
|
403
|
+
ssid?: string;
|
|
404
|
+
}
|
|
405
|
+
interface LocationCaptureRequest {
|
|
406
|
+
/** GPS latitude (if available) */
|
|
407
|
+
latitude?: number;
|
|
408
|
+
/** GPS longitude (if available) */
|
|
409
|
+
longitude?: number;
|
|
410
|
+
/** GPS accuracy in meters */
|
|
411
|
+
accuracy?: number;
|
|
412
|
+
/** WiFi networks for positioning (if GPS not available) */
|
|
413
|
+
wifi_networks?: WiFiNetwork[];
|
|
414
|
+
/** User agent string */
|
|
415
|
+
user_agent?: string;
|
|
416
|
+
/** Device metadata */
|
|
417
|
+
device_info?: {
|
|
418
|
+
platform?: string;
|
|
419
|
+
browser?: string;
|
|
420
|
+
browser_version?: string;
|
|
421
|
+
os?: string;
|
|
422
|
+
os_version?: string;
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
interface LocationShareInfo {
|
|
426
|
+
request_id: string;
|
|
427
|
+
tenant_id: string;
|
|
428
|
+
reason?: string;
|
|
429
|
+
expires_at: string;
|
|
430
|
+
status: string;
|
|
431
|
+
is_expired: boolean;
|
|
432
|
+
is_completed: boolean;
|
|
433
|
+
requires_wifi: boolean;
|
|
434
|
+
}
|
|
435
|
+
interface LocationCaptureResponse {
|
|
436
|
+
success: boolean;
|
|
437
|
+
status: string;
|
|
438
|
+
position_source?: string;
|
|
439
|
+
latitude?: number;
|
|
440
|
+
longitude?: number;
|
|
441
|
+
accuracy?: number;
|
|
442
|
+
}
|
|
443
|
+
interface UseLocationRequestsOptions {
|
|
444
|
+
/** Auto-fetch location requests on mount */
|
|
445
|
+
autoFetch?: boolean;
|
|
446
|
+
/** Initial filters */
|
|
447
|
+
filters?: LocationRequestFilters;
|
|
448
|
+
/** Pagination settings */
|
|
449
|
+
pagination?: PaginationParams;
|
|
450
|
+
/** Poll interval in milliseconds (0 = no polling) */
|
|
451
|
+
pollInterval?: number;
|
|
452
|
+
}
|
|
453
|
+
interface UseLocationRequestsResult {
|
|
454
|
+
/** List of location requests */
|
|
455
|
+
requests: LocationRequest[];
|
|
456
|
+
/** Total count */
|
|
457
|
+
total: number;
|
|
458
|
+
/** Current page */
|
|
459
|
+
page: number;
|
|
460
|
+
/** Total pages */
|
|
461
|
+
totalPages: number;
|
|
462
|
+
/** Loading state */
|
|
463
|
+
loading: boolean;
|
|
464
|
+
/** Error state */
|
|
465
|
+
error: Error | null;
|
|
466
|
+
/** Fetch location requests with filters */
|
|
467
|
+
fetchRequests: (filters?: LocationRequestFilters, pagination?: PaginationParams) => Promise<void>;
|
|
468
|
+
/** Create a new location request */
|
|
469
|
+
createRequest: (request: CreateLocationRequestRequest) => Promise<LocationRequestResult>;
|
|
470
|
+
/** Get a specific location request by ID */
|
|
471
|
+
getRequest: (requestId: string) => Promise<LocationRequest>;
|
|
472
|
+
/** Cancel a pending location request */
|
|
473
|
+
cancelRequest: (requestId: string) => Promise<void>;
|
|
474
|
+
/** Resend notification for a location request */
|
|
475
|
+
resendRequest: (requestId: string, contact: {
|
|
476
|
+
email?: string;
|
|
477
|
+
phone?: string;
|
|
478
|
+
}) => Promise<void>;
|
|
479
|
+
/** Refresh location requests */
|
|
480
|
+
refresh: () => Promise<void>;
|
|
481
|
+
}
|
|
482
|
+
interface UseLocationCaptureOptions {
|
|
483
|
+
/** Token from share link */
|
|
484
|
+
token: string;
|
|
485
|
+
/** Auto-fetch share info on mount */
|
|
486
|
+
autoFetch?: boolean;
|
|
487
|
+
/** Auto-request GPS permission on mount */
|
|
488
|
+
autoRequestGPS?: boolean;
|
|
489
|
+
/** Collect WiFi data as fallback (requires explicit permission) */
|
|
490
|
+
collectWiFi?: boolean;
|
|
491
|
+
}
|
|
492
|
+
interface UseLocationCaptureResult {
|
|
493
|
+
/** Location share info */
|
|
494
|
+
shareInfo: LocationShareInfo | null;
|
|
495
|
+
/** Capture response after submission */
|
|
496
|
+
captureResponse: LocationCaptureResponse | null;
|
|
497
|
+
/** Loading state */
|
|
498
|
+
loading: boolean;
|
|
499
|
+
/** Submitting state (during capture) */
|
|
500
|
+
submitting: boolean;
|
|
501
|
+
/** Error state */
|
|
502
|
+
error: Error | null;
|
|
503
|
+
/** Whether the request is expired */
|
|
504
|
+
isExpired: boolean;
|
|
505
|
+
/** Whether the request is already completed */
|
|
506
|
+
isCompleted: boolean;
|
|
507
|
+
/** Fetch share info */
|
|
508
|
+
fetchShareInfo: () => Promise<LocationShareInfo>;
|
|
509
|
+
/** Submit location capture */
|
|
510
|
+
submitLocation: (capture: LocationCaptureRequest) => Promise<LocationCaptureResponse>;
|
|
511
|
+
/** Request GPS and auto-submit location */
|
|
512
|
+
captureAndSubmitGPS: () => Promise<LocationCaptureResponse>;
|
|
513
|
+
}
|
|
331
514
|
|
|
332
515
|
/**
|
|
333
516
|
* GeolocationClient - TypeScript SDK for CGS Geolocation & Compliance Service
|
|
334
517
|
*
|
|
335
518
|
* Provides type-safe methods to interact with the geolocation service API.
|
|
519
|
+
* Extends BaseClient for consistent retry logic, timeout handling, and error management.
|
|
336
520
|
*/
|
|
337
521
|
|
|
338
|
-
|
|
339
|
-
|
|
522
|
+
/**
|
|
523
|
+
* GeolocationClient extends BaseClient for:
|
|
524
|
+
* - Consistent retry logic with exponential backoff
|
|
525
|
+
* - Unified error handling (CGSError, NetworkError, TimeoutError, etc.)
|
|
526
|
+
* - Automatic timeout management
|
|
527
|
+
* - Debug logging
|
|
528
|
+
*
|
|
529
|
+
* All geolocation verification calls use requestWithRetry() to handle
|
|
530
|
+
* transient failures gracefully.
|
|
531
|
+
*/
|
|
532
|
+
declare class GeolocationClient extends BaseClient {
|
|
340
533
|
constructor(config: GeolocationClientConfig);
|
|
341
|
-
private request;
|
|
342
|
-
private buildQueryString;
|
|
343
534
|
/**
|
|
344
535
|
* Verify an IP address and check compliance
|
|
345
536
|
*
|
|
537
|
+
* Uses requestWithRetry() for automatic retry on transient failures.
|
|
538
|
+
*
|
|
346
539
|
* @param request - Verification request with IP, user ID, event type, and optional device fingerprint
|
|
347
540
|
* @returns Location verification result with risk assessment
|
|
348
541
|
*
|
|
@@ -596,24 +789,96 @@ declare class GeolocationClient {
|
|
|
596
789
|
*/
|
|
597
790
|
updateDeviceTrust(deviceId: string, action: 'trust' | 'untrust'): Promise<void>;
|
|
598
791
|
/**
|
|
599
|
-
*
|
|
792
|
+
* Create a location request to get customer's live location
|
|
793
|
+
*
|
|
794
|
+
* @param request - Location request details
|
|
795
|
+
* @returns Location request result with share link
|
|
600
796
|
*
|
|
601
|
-
* @
|
|
797
|
+
* @example
|
|
798
|
+
* ```typescript
|
|
799
|
+
* const result = await client.createLocationRequest({
|
|
800
|
+
* user_id: "customer_123",
|
|
801
|
+
* channel: "sms",
|
|
802
|
+
* phone: "+1234567890",
|
|
803
|
+
* reason: "Verification for high-value transaction"
|
|
804
|
+
* });
|
|
805
|
+
*
|
|
806
|
+
* console.log(`Share link sent: ${result.share_link}`);
|
|
807
|
+
* console.log(`Expires at: ${result.token_expiry}`);
|
|
808
|
+
* ```
|
|
602
809
|
*/
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
810
|
+
createLocationRequest(request: CreateLocationRequestRequest): Promise<LocationRequestResult>;
|
|
811
|
+
/**
|
|
812
|
+
* Get a location request by ID
|
|
813
|
+
*
|
|
814
|
+
* @param requestId - Location request ID
|
|
815
|
+
* @returns Location request details
|
|
816
|
+
*/
|
|
817
|
+
getLocationRequest(requestId: string): Promise<LocationRequest>;
|
|
818
|
+
/**
|
|
819
|
+
* List location requests with filters and pagination
|
|
820
|
+
*
|
|
821
|
+
* @param filters - Optional filters
|
|
822
|
+
* @param pagination - Optional pagination
|
|
823
|
+
* @returns Paginated list of location requests
|
|
824
|
+
*
|
|
825
|
+
* @example
|
|
826
|
+
* ```typescript
|
|
827
|
+
* const requests = await client.listLocationRequests(
|
|
828
|
+
* { status: "completed", user_id: "customer_123" },
|
|
829
|
+
* { page: 1, limit: 20 }
|
|
830
|
+
* );
|
|
831
|
+
* ```
|
|
832
|
+
*/
|
|
833
|
+
listLocationRequests(filters?: LocationRequestFilters, pagination?: PaginationParams): Promise<LocationRequestListResponse>;
|
|
607
834
|
/**
|
|
608
|
-
*
|
|
835
|
+
* Cancel a pending location request
|
|
609
836
|
*
|
|
610
|
-
* @param
|
|
837
|
+
* @param requestId - Location request ID
|
|
611
838
|
*/
|
|
612
|
-
|
|
839
|
+
cancelLocationRequest(requestId: string): Promise<void>;
|
|
613
840
|
/**
|
|
614
|
-
*
|
|
841
|
+
* Resend notification for a location request
|
|
842
|
+
*
|
|
843
|
+
* @param requestId - Location request ID
|
|
844
|
+
* @param contact - Email or phone to send to
|
|
845
|
+
*/
|
|
846
|
+
resendLocationRequest(requestId: string, contact: ResendLocationRequestRequest): Promise<void>;
|
|
847
|
+
/**
|
|
848
|
+
* Get location share info (customer-facing)
|
|
849
|
+
* This is called from the customer's device to get request details
|
|
850
|
+
*
|
|
851
|
+
* @param token - Secure token from share link
|
|
852
|
+
* @returns Location share info
|
|
853
|
+
*/
|
|
854
|
+
getLocationShareInfo(token: string): Promise<LocationShareInfo>;
|
|
855
|
+
/**
|
|
856
|
+
* Submit location capture (customer-facing)
|
|
857
|
+
* This is called from the customer's device to submit their location
|
|
858
|
+
*
|
|
859
|
+
* @param token - Secure token from share link
|
|
860
|
+
* @param capture - Location capture data (GPS or WiFi)
|
|
861
|
+
* @returns Capture response
|
|
862
|
+
*
|
|
863
|
+
* @example
|
|
864
|
+
* ```typescript
|
|
865
|
+
* // Using GPS (preferred)
|
|
866
|
+
* const result = await client.captureLocation(token, {
|
|
867
|
+
* latitude: 37.7749,
|
|
868
|
+
* longitude: -122.4194,
|
|
869
|
+
* accuracy: 10
|
|
870
|
+
* });
|
|
871
|
+
*
|
|
872
|
+
* // Using WiFi positioning (fallback)
|
|
873
|
+
* const result = await client.captureLocation(token, {
|
|
874
|
+
* wifi_networks: [
|
|
875
|
+
* { macAddress: "00:11:22:33:44:55", signalStrength: -50 },
|
|
876
|
+
* { macAddress: "AA:BB:CC:DD:EE:FF", signalStrength: -70 }
|
|
877
|
+
* ]
|
|
878
|
+
* });
|
|
879
|
+
* ```
|
|
615
880
|
*/
|
|
616
|
-
|
|
881
|
+
captureLocation(token: string, capture: LocationCaptureRequest): Promise<LocationCaptureResponse>;
|
|
617
882
|
}
|
|
618
883
|
|
|
619
|
-
export { type AlertStatus as A, type ComplianceCheckResponse as C, type DeviceFingerprintRequest as D, GeolocationClient as G, type JurisdictionConfig as J, type LocationVerification as L, type UpdateJurisdictionRequest as U, type VerifyIPRequest as V, type GeoIPResult as a, type GeofenceEvaluation as b, type DeviceFingerprint as c, type DeviceTrustResult as d, type AlertSeverity as e, type AlertType as f, type GeolocationAlert as g, type AlertFilters as h, type AlertListResponse as i, type DashboardMetrics as j, type CreateJurisdictionRequest as k, type GeofenceRuleType as l, type GeofenceAction as m, type GeofenceRule as n, type CreateGeofenceRuleRequest as o, type UpdateGeofenceRuleRequest as p, type UpdateDeviceTrustRequest as q, type GeolocationRecord as r, type APIError as s, type GeolocationClientConfig as t, type UseGeolocationOptions as u, type UseGeolocationResult as v, type UseAlertsOptions as w, type UseAlertsResult as x };
|
|
884
|
+
export { type AlertStatus as A, type LocationRequest as B, type ComplianceCheckResponse as C, type DeviceFingerprintRequest as D, type CreateLocationRequestRequest as E, type LocationRequestResult as F, GeolocationClient as G, type LocationRequestFilters as H, type LocationRequestListResponse as I, type JurisdictionConfig as J, type LocationCaptureRequest as K, type LocationVerification as L, type LocationShareInfo as M, type LocationCaptureResponse as N, type UseLocationRequestsOptions as O, type UseLocationRequestsResult as P, type UseLocationCaptureOptions as Q, type ResendLocationRequestRequest as R, type UseLocationCaptureResult as S, type UpdateJurisdictionRequest as U, type VerifyIPRequest as V, type WiFiNetwork as W, type GeoIPResult as a, type GeofenceEvaluation as b, type DeviceFingerprint as c, type DeviceTrustResult as d, type AlertSeverity as e, type AlertType as f, type GeolocationAlert as g, type AlertFilters as h, type AlertListResponse as i, type DashboardMetrics as j, type CreateJurisdictionRequest as k, type GeofenceRuleType as l, type GeofenceAction as m, type GeofenceRule as n, type CreateGeofenceRuleRequest as o, type UpdateGeofenceRuleRequest as p, type UpdateDeviceTrustRequest as q, type GeolocationRecord as r, type APIError as s, type GeolocationClientConfig as t, type UseGeolocationOptions as u, type UseGeolocationResult as v, type UseAlertsOptions as w, type UseAlertsResult as x, type LocationRequestStatus as y, type LocationRequestChannel as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as PaginationParams } from './types-
|
|
1
|
+
import { P as PaginationParams, B as BaseClient } from './types-DxnfRzF_.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* TypeScript type definitions for CGS Geolocation Service API
|
|
@@ -328,21 +328,214 @@ interface UseAlertsResult {
|
|
|
328
328
|
/** Refresh alerts */
|
|
329
329
|
refresh: () => Promise<void>;
|
|
330
330
|
}
|
|
331
|
+
type LocationRequestStatus = 'pending' | 'sent' | 'completed' | 'expired' | 'cancelled' | 'failed';
|
|
332
|
+
type LocationRequestChannel = 'sms' | 'email' | 'push';
|
|
333
|
+
interface LocationRequest {
|
|
334
|
+
id: string;
|
|
335
|
+
tenant_id: string;
|
|
336
|
+
user_id: string;
|
|
337
|
+
requested_by: string;
|
|
338
|
+
channel: LocationRequestChannel;
|
|
339
|
+
status: LocationRequestStatus;
|
|
340
|
+
reason?: string;
|
|
341
|
+
token_expires_at: string;
|
|
342
|
+
latitude?: number;
|
|
343
|
+
longitude?: number;
|
|
344
|
+
accuracy?: number;
|
|
345
|
+
country?: string;
|
|
346
|
+
country_iso?: string;
|
|
347
|
+
city?: string;
|
|
348
|
+
region?: string;
|
|
349
|
+
formatted_address?: string;
|
|
350
|
+
position_source?: string;
|
|
351
|
+
notification_sent_at?: string;
|
|
352
|
+
responded_at?: string;
|
|
353
|
+
viewed_at?: string;
|
|
354
|
+
created_at: string;
|
|
355
|
+
updated_at: string;
|
|
356
|
+
}
|
|
357
|
+
interface CreateLocationRequestRequest {
|
|
358
|
+
/** Customer user ID to request location from */
|
|
359
|
+
user_id: string;
|
|
360
|
+
/** Notification channel to use */
|
|
361
|
+
channel: LocationRequestChannel;
|
|
362
|
+
/** Reason for requesting location (for compliance/audit) */
|
|
363
|
+
reason?: string;
|
|
364
|
+
/** Customer email (required for email channel) */
|
|
365
|
+
email?: string;
|
|
366
|
+
/** Customer phone (required for SMS channel) */
|
|
367
|
+
phone?: string;
|
|
368
|
+
/** Custom expiry time in hours (default: 24) */
|
|
369
|
+
expiry_hours?: number;
|
|
370
|
+
}
|
|
371
|
+
interface LocationRequestResult {
|
|
372
|
+
request: LocationRequest;
|
|
373
|
+
share_link: string;
|
|
374
|
+
token_expiry: string;
|
|
375
|
+
}
|
|
376
|
+
interface LocationRequestFilters {
|
|
377
|
+
status?: LocationRequestStatus;
|
|
378
|
+
user_id?: string;
|
|
379
|
+
requested_by?: string;
|
|
380
|
+
channel?: LocationRequestChannel;
|
|
381
|
+
date_from?: string;
|
|
382
|
+
date_to?: string;
|
|
383
|
+
}
|
|
384
|
+
interface LocationRequestListResponse {
|
|
385
|
+
requests: LocationRequest[];
|
|
386
|
+
total: number;
|
|
387
|
+
page: number;
|
|
388
|
+
limit: number;
|
|
389
|
+
total_pages: number;
|
|
390
|
+
}
|
|
391
|
+
interface ResendLocationRequestRequest {
|
|
392
|
+
email?: string;
|
|
393
|
+
phone?: string;
|
|
394
|
+
}
|
|
395
|
+
interface WiFiNetwork {
|
|
396
|
+
/** MAC address (BSSID) */
|
|
397
|
+
macAddress: string;
|
|
398
|
+
/** Signal strength in dBm (negative number) */
|
|
399
|
+
signalStrength?: number;
|
|
400
|
+
/** WiFi channel */
|
|
401
|
+
channel?: number;
|
|
402
|
+
/** Network name (optional) */
|
|
403
|
+
ssid?: string;
|
|
404
|
+
}
|
|
405
|
+
interface LocationCaptureRequest {
|
|
406
|
+
/** GPS latitude (if available) */
|
|
407
|
+
latitude?: number;
|
|
408
|
+
/** GPS longitude (if available) */
|
|
409
|
+
longitude?: number;
|
|
410
|
+
/** GPS accuracy in meters */
|
|
411
|
+
accuracy?: number;
|
|
412
|
+
/** WiFi networks for positioning (if GPS not available) */
|
|
413
|
+
wifi_networks?: WiFiNetwork[];
|
|
414
|
+
/** User agent string */
|
|
415
|
+
user_agent?: string;
|
|
416
|
+
/** Device metadata */
|
|
417
|
+
device_info?: {
|
|
418
|
+
platform?: string;
|
|
419
|
+
browser?: string;
|
|
420
|
+
browser_version?: string;
|
|
421
|
+
os?: string;
|
|
422
|
+
os_version?: string;
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
interface LocationShareInfo {
|
|
426
|
+
request_id: string;
|
|
427
|
+
tenant_id: string;
|
|
428
|
+
reason?: string;
|
|
429
|
+
expires_at: string;
|
|
430
|
+
status: string;
|
|
431
|
+
is_expired: boolean;
|
|
432
|
+
is_completed: boolean;
|
|
433
|
+
requires_wifi: boolean;
|
|
434
|
+
}
|
|
435
|
+
interface LocationCaptureResponse {
|
|
436
|
+
success: boolean;
|
|
437
|
+
status: string;
|
|
438
|
+
position_source?: string;
|
|
439
|
+
latitude?: number;
|
|
440
|
+
longitude?: number;
|
|
441
|
+
accuracy?: number;
|
|
442
|
+
}
|
|
443
|
+
interface UseLocationRequestsOptions {
|
|
444
|
+
/** Auto-fetch location requests on mount */
|
|
445
|
+
autoFetch?: boolean;
|
|
446
|
+
/** Initial filters */
|
|
447
|
+
filters?: LocationRequestFilters;
|
|
448
|
+
/** Pagination settings */
|
|
449
|
+
pagination?: PaginationParams;
|
|
450
|
+
/** Poll interval in milliseconds (0 = no polling) */
|
|
451
|
+
pollInterval?: number;
|
|
452
|
+
}
|
|
453
|
+
interface UseLocationRequestsResult {
|
|
454
|
+
/** List of location requests */
|
|
455
|
+
requests: LocationRequest[];
|
|
456
|
+
/** Total count */
|
|
457
|
+
total: number;
|
|
458
|
+
/** Current page */
|
|
459
|
+
page: number;
|
|
460
|
+
/** Total pages */
|
|
461
|
+
totalPages: number;
|
|
462
|
+
/** Loading state */
|
|
463
|
+
loading: boolean;
|
|
464
|
+
/** Error state */
|
|
465
|
+
error: Error | null;
|
|
466
|
+
/** Fetch location requests with filters */
|
|
467
|
+
fetchRequests: (filters?: LocationRequestFilters, pagination?: PaginationParams) => Promise<void>;
|
|
468
|
+
/** Create a new location request */
|
|
469
|
+
createRequest: (request: CreateLocationRequestRequest) => Promise<LocationRequestResult>;
|
|
470
|
+
/** Get a specific location request by ID */
|
|
471
|
+
getRequest: (requestId: string) => Promise<LocationRequest>;
|
|
472
|
+
/** Cancel a pending location request */
|
|
473
|
+
cancelRequest: (requestId: string) => Promise<void>;
|
|
474
|
+
/** Resend notification for a location request */
|
|
475
|
+
resendRequest: (requestId: string, contact: {
|
|
476
|
+
email?: string;
|
|
477
|
+
phone?: string;
|
|
478
|
+
}) => Promise<void>;
|
|
479
|
+
/** Refresh location requests */
|
|
480
|
+
refresh: () => Promise<void>;
|
|
481
|
+
}
|
|
482
|
+
interface UseLocationCaptureOptions {
|
|
483
|
+
/** Token from share link */
|
|
484
|
+
token: string;
|
|
485
|
+
/** Auto-fetch share info on mount */
|
|
486
|
+
autoFetch?: boolean;
|
|
487
|
+
/** Auto-request GPS permission on mount */
|
|
488
|
+
autoRequestGPS?: boolean;
|
|
489
|
+
/** Collect WiFi data as fallback (requires explicit permission) */
|
|
490
|
+
collectWiFi?: boolean;
|
|
491
|
+
}
|
|
492
|
+
interface UseLocationCaptureResult {
|
|
493
|
+
/** Location share info */
|
|
494
|
+
shareInfo: LocationShareInfo | null;
|
|
495
|
+
/** Capture response after submission */
|
|
496
|
+
captureResponse: LocationCaptureResponse | null;
|
|
497
|
+
/** Loading state */
|
|
498
|
+
loading: boolean;
|
|
499
|
+
/** Submitting state (during capture) */
|
|
500
|
+
submitting: boolean;
|
|
501
|
+
/** Error state */
|
|
502
|
+
error: Error | null;
|
|
503
|
+
/** Whether the request is expired */
|
|
504
|
+
isExpired: boolean;
|
|
505
|
+
/** Whether the request is already completed */
|
|
506
|
+
isCompleted: boolean;
|
|
507
|
+
/** Fetch share info */
|
|
508
|
+
fetchShareInfo: () => Promise<LocationShareInfo>;
|
|
509
|
+
/** Submit location capture */
|
|
510
|
+
submitLocation: (capture: LocationCaptureRequest) => Promise<LocationCaptureResponse>;
|
|
511
|
+
/** Request GPS and auto-submit location */
|
|
512
|
+
captureAndSubmitGPS: () => Promise<LocationCaptureResponse>;
|
|
513
|
+
}
|
|
331
514
|
|
|
332
515
|
/**
|
|
333
516
|
* GeolocationClient - TypeScript SDK for CGS Geolocation & Compliance Service
|
|
334
517
|
*
|
|
335
518
|
* Provides type-safe methods to interact with the geolocation service API.
|
|
519
|
+
* Extends BaseClient for consistent retry logic, timeout handling, and error management.
|
|
336
520
|
*/
|
|
337
521
|
|
|
338
|
-
|
|
339
|
-
|
|
522
|
+
/**
|
|
523
|
+
* GeolocationClient extends BaseClient for:
|
|
524
|
+
* - Consistent retry logic with exponential backoff
|
|
525
|
+
* - Unified error handling (CGSError, NetworkError, TimeoutError, etc.)
|
|
526
|
+
* - Automatic timeout management
|
|
527
|
+
* - Debug logging
|
|
528
|
+
*
|
|
529
|
+
* All geolocation verification calls use requestWithRetry() to handle
|
|
530
|
+
* transient failures gracefully.
|
|
531
|
+
*/
|
|
532
|
+
declare class GeolocationClient extends BaseClient {
|
|
340
533
|
constructor(config: GeolocationClientConfig);
|
|
341
|
-
private request;
|
|
342
|
-
private buildQueryString;
|
|
343
534
|
/**
|
|
344
535
|
* Verify an IP address and check compliance
|
|
345
536
|
*
|
|
537
|
+
* Uses requestWithRetry() for automatic retry on transient failures.
|
|
538
|
+
*
|
|
346
539
|
* @param request - Verification request with IP, user ID, event type, and optional device fingerprint
|
|
347
540
|
* @returns Location verification result with risk assessment
|
|
348
541
|
*
|
|
@@ -596,24 +789,96 @@ declare class GeolocationClient {
|
|
|
596
789
|
*/
|
|
597
790
|
updateDeviceTrust(deviceId: string, action: 'trust' | 'untrust'): Promise<void>;
|
|
598
791
|
/**
|
|
599
|
-
*
|
|
792
|
+
* Create a location request to get customer's live location
|
|
793
|
+
*
|
|
794
|
+
* @param request - Location request details
|
|
795
|
+
* @returns Location request result with share link
|
|
600
796
|
*
|
|
601
|
-
* @
|
|
797
|
+
* @example
|
|
798
|
+
* ```typescript
|
|
799
|
+
* const result = await client.createLocationRequest({
|
|
800
|
+
* user_id: "customer_123",
|
|
801
|
+
* channel: "sms",
|
|
802
|
+
* phone: "+1234567890",
|
|
803
|
+
* reason: "Verification for high-value transaction"
|
|
804
|
+
* });
|
|
805
|
+
*
|
|
806
|
+
* console.log(`Share link sent: ${result.share_link}`);
|
|
807
|
+
* console.log(`Expires at: ${result.token_expiry}`);
|
|
808
|
+
* ```
|
|
602
809
|
*/
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
810
|
+
createLocationRequest(request: CreateLocationRequestRequest): Promise<LocationRequestResult>;
|
|
811
|
+
/**
|
|
812
|
+
* Get a location request by ID
|
|
813
|
+
*
|
|
814
|
+
* @param requestId - Location request ID
|
|
815
|
+
* @returns Location request details
|
|
816
|
+
*/
|
|
817
|
+
getLocationRequest(requestId: string): Promise<LocationRequest>;
|
|
818
|
+
/**
|
|
819
|
+
* List location requests with filters and pagination
|
|
820
|
+
*
|
|
821
|
+
* @param filters - Optional filters
|
|
822
|
+
* @param pagination - Optional pagination
|
|
823
|
+
* @returns Paginated list of location requests
|
|
824
|
+
*
|
|
825
|
+
* @example
|
|
826
|
+
* ```typescript
|
|
827
|
+
* const requests = await client.listLocationRequests(
|
|
828
|
+
* { status: "completed", user_id: "customer_123" },
|
|
829
|
+
* { page: 1, limit: 20 }
|
|
830
|
+
* );
|
|
831
|
+
* ```
|
|
832
|
+
*/
|
|
833
|
+
listLocationRequests(filters?: LocationRequestFilters, pagination?: PaginationParams): Promise<LocationRequestListResponse>;
|
|
607
834
|
/**
|
|
608
|
-
*
|
|
835
|
+
* Cancel a pending location request
|
|
609
836
|
*
|
|
610
|
-
* @param
|
|
837
|
+
* @param requestId - Location request ID
|
|
611
838
|
*/
|
|
612
|
-
|
|
839
|
+
cancelLocationRequest(requestId: string): Promise<void>;
|
|
613
840
|
/**
|
|
614
|
-
*
|
|
841
|
+
* Resend notification for a location request
|
|
842
|
+
*
|
|
843
|
+
* @param requestId - Location request ID
|
|
844
|
+
* @param contact - Email or phone to send to
|
|
845
|
+
*/
|
|
846
|
+
resendLocationRequest(requestId: string, contact: ResendLocationRequestRequest): Promise<void>;
|
|
847
|
+
/**
|
|
848
|
+
* Get location share info (customer-facing)
|
|
849
|
+
* This is called from the customer's device to get request details
|
|
850
|
+
*
|
|
851
|
+
* @param token - Secure token from share link
|
|
852
|
+
* @returns Location share info
|
|
853
|
+
*/
|
|
854
|
+
getLocationShareInfo(token: string): Promise<LocationShareInfo>;
|
|
855
|
+
/**
|
|
856
|
+
* Submit location capture (customer-facing)
|
|
857
|
+
* This is called from the customer's device to submit their location
|
|
858
|
+
*
|
|
859
|
+
* @param token - Secure token from share link
|
|
860
|
+
* @param capture - Location capture data (GPS or WiFi)
|
|
861
|
+
* @returns Capture response
|
|
862
|
+
*
|
|
863
|
+
* @example
|
|
864
|
+
* ```typescript
|
|
865
|
+
* // Using GPS (preferred)
|
|
866
|
+
* const result = await client.captureLocation(token, {
|
|
867
|
+
* latitude: 37.7749,
|
|
868
|
+
* longitude: -122.4194,
|
|
869
|
+
* accuracy: 10
|
|
870
|
+
* });
|
|
871
|
+
*
|
|
872
|
+
* // Using WiFi positioning (fallback)
|
|
873
|
+
* const result = await client.captureLocation(token, {
|
|
874
|
+
* wifi_networks: [
|
|
875
|
+
* { macAddress: "00:11:22:33:44:55", signalStrength: -50 },
|
|
876
|
+
* { macAddress: "AA:BB:CC:DD:EE:FF", signalStrength: -70 }
|
|
877
|
+
* ]
|
|
878
|
+
* });
|
|
879
|
+
* ```
|
|
615
880
|
*/
|
|
616
|
-
|
|
881
|
+
captureLocation(token: string, capture: LocationCaptureRequest): Promise<LocationCaptureResponse>;
|
|
617
882
|
}
|
|
618
883
|
|
|
619
|
-
export { type AlertStatus as A, type ComplianceCheckResponse as C, type DeviceFingerprintRequest as D, GeolocationClient as G, type JurisdictionConfig as J, type LocationVerification as L, type UpdateJurisdictionRequest as U, type VerifyIPRequest as V, type GeoIPResult as a, type GeofenceEvaluation as b, type DeviceFingerprint as c, type DeviceTrustResult as d, type AlertSeverity as e, type AlertType as f, type GeolocationAlert as g, type AlertFilters as h, type AlertListResponse as i, type DashboardMetrics as j, type CreateJurisdictionRequest as k, type GeofenceRuleType as l, type GeofenceAction as m, type GeofenceRule as n, type CreateGeofenceRuleRequest as o, type UpdateGeofenceRuleRequest as p, type UpdateDeviceTrustRequest as q, type GeolocationRecord as r, type APIError as s, type GeolocationClientConfig as t, type UseGeolocationOptions as u, type UseGeolocationResult as v, type UseAlertsOptions as w, type UseAlertsResult as x };
|
|
884
|
+
export { type AlertStatus as A, type LocationRequest as B, type ComplianceCheckResponse as C, type DeviceFingerprintRequest as D, type CreateLocationRequestRequest as E, type LocationRequestResult as F, GeolocationClient as G, type LocationRequestFilters as H, type LocationRequestListResponse as I, type JurisdictionConfig as J, type LocationCaptureRequest as K, type LocationVerification as L, type LocationShareInfo as M, type LocationCaptureResponse as N, type UseLocationRequestsOptions as O, type UseLocationRequestsResult as P, type UseLocationCaptureOptions as Q, type ResendLocationRequestRequest as R, type UseLocationCaptureResult as S, type UpdateJurisdictionRequest as U, type VerifyIPRequest as V, type WiFiNetwork as W, type GeoIPResult as a, type GeofenceEvaluation as b, type DeviceFingerprint as c, type DeviceTrustResult as d, type AlertSeverity as e, type AlertType as f, type GeolocationAlert as g, type AlertFilters as h, type AlertListResponse as i, type DashboardMetrics as j, type CreateJurisdictionRequest as k, type GeofenceRuleType as l, type GeofenceAction as m, type GeofenceRule as n, type CreateGeofenceRuleRequest as o, type UpdateGeofenceRuleRequest as p, type UpdateDeviceTrustRequest as q, type GeolocationRecord as r, type APIError as s, type GeolocationClientConfig as t, type UseGeolocationOptions as u, type UseGeolocationResult as v, type UseAlertsOptions as w, type UseAlertsResult as x, type LocationRequestStatus as y, type LocationRequestChannel as z };
|