@passgage/sdk-react-native 1.0.4 → 1.0.6
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 +409 -147
- package/dist/index.d.mts +166 -424
- package/dist/index.d.ts +166 -424
- package/dist/index.js +933 -1197
- package/dist/index.mjs +868 -1132
- package/package.json +8 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from 'axios';
|
|
2
2
|
import React, { ReactNode } from 'react';
|
|
3
|
+
import * as zustand from 'zustand';
|
|
4
|
+
import { GeoError, GeoOptions } from 'react-native-geolocation-service';
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* Common types and interfaces used across the SDK
|
|
@@ -65,6 +67,14 @@ interface APIError extends Error {
|
|
|
65
67
|
status?: number;
|
|
66
68
|
response?: BaseResponse;
|
|
67
69
|
}
|
|
70
|
+
interface FlowResponseType {
|
|
71
|
+
success: boolean;
|
|
72
|
+
message: string;
|
|
73
|
+
error?: {
|
|
74
|
+
code: string;
|
|
75
|
+
details?: string;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
68
78
|
|
|
69
79
|
/**
|
|
70
80
|
* Device-related types and interfaces
|
|
@@ -104,6 +114,7 @@ interface QrDevice {
|
|
|
104
114
|
device_type?: string;
|
|
105
115
|
created_at: string;
|
|
106
116
|
updated_at: string;
|
|
117
|
+
is_iot: boolean;
|
|
107
118
|
}
|
|
108
119
|
interface DeviceAccessRequest {
|
|
109
120
|
userId?: string;
|
|
@@ -113,6 +124,12 @@ interface DeviceAccessRequest {
|
|
|
113
124
|
interface QrAccessResponse {
|
|
114
125
|
qr_ids: string[];
|
|
115
126
|
}
|
|
127
|
+
interface ReqCreateEntrance {
|
|
128
|
+
device_id: string;
|
|
129
|
+
created_at?: string;
|
|
130
|
+
entrance_type?: DeviceDirection;
|
|
131
|
+
service_id?: string;
|
|
132
|
+
}
|
|
116
133
|
|
|
117
134
|
/**
|
|
118
135
|
* Entrance-related types and interfaces
|
|
@@ -154,6 +171,7 @@ interface CreateEntranceRequest {
|
|
|
154
171
|
interface CreateEntranceFromQRRequest {
|
|
155
172
|
device_id: string;
|
|
156
173
|
created_at?: string;
|
|
174
|
+
entrance_type?: DeviceDirection;
|
|
157
175
|
service_id?: string;
|
|
158
176
|
}
|
|
159
177
|
interface EntranceQueryParams {
|
|
@@ -201,6 +219,16 @@ interface LoginCredentials {
|
|
|
201
219
|
login: string;
|
|
202
220
|
/** User password */
|
|
203
221
|
password: string;
|
|
222
|
+
rememberUser?: boolean;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Azure AD login credentials
|
|
226
|
+
*/
|
|
227
|
+
interface AzureLoginCredentials {
|
|
228
|
+
/** Azure AD id_token */
|
|
229
|
+
id_token: string;
|
|
230
|
+
/** Device type (android/ios) */
|
|
231
|
+
device_type?: 'android' | 'ios';
|
|
204
232
|
}
|
|
205
233
|
/**
|
|
206
234
|
* Token information
|
|
@@ -271,6 +299,12 @@ interface LoginRequest {
|
|
|
271
299
|
interface LoginResponse {
|
|
272
300
|
tokens: AuthTokens;
|
|
273
301
|
}
|
|
302
|
+
/**
|
|
303
|
+
* Azure AD login response data from API
|
|
304
|
+
*/
|
|
305
|
+
interface AzureLoginResponse {
|
|
306
|
+
tokens: AuthTokens;
|
|
307
|
+
}
|
|
274
308
|
/**
|
|
275
309
|
* Token refresh request payload
|
|
276
310
|
*/
|
|
@@ -407,7 +441,7 @@ declare class ApiClient {
|
|
|
407
441
|
/**
|
|
408
442
|
* Generic POST request
|
|
409
443
|
*/
|
|
410
|
-
post<T = unknown
|
|
444
|
+
post<T = unknown>(options: Omit<RequestOptions<T>, 'method'>): Promise<any>;
|
|
411
445
|
/**
|
|
412
446
|
* Generic PUT request
|
|
413
447
|
*/
|
|
@@ -431,6 +465,7 @@ declare function createApiClient(config: ApiClientConfig): ApiClient;
|
|
|
431
465
|
*/
|
|
432
466
|
declare const EP_LOGIN = "users/sign_in";
|
|
433
467
|
declare const EP_TOKEN = "token";
|
|
468
|
+
declare const EP_AZURE_AUTH = "auth/azure";
|
|
434
469
|
declare const EP_DEVICES = "devices";
|
|
435
470
|
declare const EP_QR_DEVICES = "devices/qr_devices";
|
|
436
471
|
declare const EP_QR_ACCESS = "qr_access/accessible_qrs";
|
|
@@ -444,6 +479,7 @@ declare const EP_TRIGGER_IOT = "iot/trigger";
|
|
|
444
479
|
declare const EP_USERS = "users";
|
|
445
480
|
declare const EP_ME = "users/lite_me";
|
|
446
481
|
|
|
482
|
+
declare const endpoints_EP_AZURE_AUTH: typeof EP_AZURE_AUTH;
|
|
447
483
|
declare const endpoints_EP_BRANCHES: typeof EP_BRANCHES;
|
|
448
484
|
declare const endpoints_EP_CREATE_QR: typeof EP_CREATE_QR;
|
|
449
485
|
declare const endpoints_EP_DEVICES: typeof EP_DEVICES;
|
|
@@ -459,7 +495,7 @@ declare const endpoints_EP_TOKEN: typeof EP_TOKEN;
|
|
|
459
495
|
declare const endpoints_EP_TRIGGER_IOT: typeof EP_TRIGGER_IOT;
|
|
460
496
|
declare const endpoints_EP_USERS: typeof EP_USERS;
|
|
461
497
|
declare namespace endpoints {
|
|
462
|
-
export { endpoints_EP_BRANCHES as EP_BRANCHES, endpoints_EP_CREATE_QR as EP_CREATE_QR, endpoints_EP_DEVICES as EP_DEVICES, endpoints_EP_ENTRANCES as EP_ENTRANCES, endpoints_EP_LOCATION_VERIFICATION as EP_LOCATION_VERIFICATION, endpoints_EP_LOGIN as EP_LOGIN, endpoints_EP_ME as EP_ME, endpoints_EP_NFC_CHECK as EP_NFC_CHECK, endpoints_EP_QR_ACCESS as EP_QR_ACCESS, endpoints_EP_QR_CHECK as EP_QR_CHECK, endpoints_EP_QR_DEVICES as EP_QR_DEVICES, endpoints_EP_TOKEN as EP_TOKEN, endpoints_EP_TRIGGER_IOT as EP_TRIGGER_IOT, endpoints_EP_USERS as EP_USERS };
|
|
498
|
+
export { endpoints_EP_AZURE_AUTH as EP_AZURE_AUTH, endpoints_EP_BRANCHES as EP_BRANCHES, endpoints_EP_CREATE_QR as EP_CREATE_QR, endpoints_EP_DEVICES as EP_DEVICES, endpoints_EP_ENTRANCES as EP_ENTRANCES, endpoints_EP_LOCATION_VERIFICATION as EP_LOCATION_VERIFICATION, endpoints_EP_LOGIN as EP_LOGIN, endpoints_EP_ME as EP_ME, endpoints_EP_NFC_CHECK as EP_NFC_CHECK, endpoints_EP_QR_ACCESS as EP_QR_ACCESS, endpoints_EP_QR_CHECK as EP_QR_CHECK, endpoints_EP_QR_DEVICES as EP_QR_DEVICES, endpoints_EP_TOKEN as EP_TOKEN, endpoints_EP_TRIGGER_IOT as EP_TRIGGER_IOT, endpoints_EP_USERS as EP_USERS };
|
|
463
499
|
}
|
|
464
500
|
|
|
465
501
|
/**
|
|
@@ -467,36 +503,13 @@ declare namespace endpoints {
|
|
|
467
503
|
*
|
|
468
504
|
* Handles user authentication, token management, and user information retrieval.
|
|
469
505
|
*/
|
|
506
|
+
declare module 'axios' {
|
|
507
|
+
interface AxiosRequestConfig {
|
|
508
|
+
skipAuth?: boolean;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
470
511
|
|
|
471
|
-
|
|
472
|
-
* Authentication Service
|
|
473
|
-
*
|
|
474
|
-
* Provides methods for user authentication and token management.
|
|
475
|
-
*
|
|
476
|
-
* @example
|
|
477
|
-
* ```typescript
|
|
478
|
-
* const authService = new AuthService(apiClient);
|
|
479
|
-
*
|
|
480
|
-
* // Login
|
|
481
|
-
* const result = await authService.login({
|
|
482
|
-
* login: 'user@example.com',
|
|
483
|
-
* password: 'password123'
|
|
484
|
-
* });
|
|
485
|
-
*
|
|
486
|
-
* if (result.success) {
|
|
487
|
-
* console.log('Logged in:', result.tokens);
|
|
488
|
-
* }
|
|
489
|
-
* ```
|
|
490
|
-
*/
|
|
491
|
-
declare class AuthService {
|
|
492
|
-
private apiClient;
|
|
493
|
-
private tokenStorage?;
|
|
494
|
-
constructor(apiClient: ApiClient);
|
|
495
|
-
/**
|
|
496
|
-
* Set token storage implementation
|
|
497
|
-
* This is used by platform-specific implementations (React Native, Android, iOS)
|
|
498
|
-
*/
|
|
499
|
-
setTokenStorage(storage: TokenStorage): void;
|
|
512
|
+
declare const AuthService: {
|
|
500
513
|
/**
|
|
501
514
|
* Login with credentials
|
|
502
515
|
*
|
|
@@ -517,7 +530,28 @@ declare class AuthService {
|
|
|
517
530
|
* }
|
|
518
531
|
* ```
|
|
519
532
|
*/
|
|
520
|
-
login(credentials: LoginCredentials)
|
|
533
|
+
login: (credentials: LoginCredentials) => Promise<LoginResult>;
|
|
534
|
+
/**
|
|
535
|
+
* Login with Azure AD token
|
|
536
|
+
*
|
|
537
|
+
* @param credentials - Azure AD login credentials (id_token and optional device_type)
|
|
538
|
+
* @returns Login result with tokens on success
|
|
539
|
+
*
|
|
540
|
+
* @example
|
|
541
|
+
* ```typescript
|
|
542
|
+
* const result = await authService.loginWithAzure({
|
|
543
|
+
* id_token: 'azure_id_token_here',
|
|
544
|
+
* device_type: 'ios'
|
|
545
|
+
* });
|
|
546
|
+
*
|
|
547
|
+
* if (result.success) {
|
|
548
|
+
* console.log('Access token:', result.tokens.access.token);
|
|
549
|
+
* } else {
|
|
550
|
+
* console.error('Azure login failed:', result.error);
|
|
551
|
+
* }
|
|
552
|
+
* ```
|
|
553
|
+
*/
|
|
554
|
+
loginWithAzure: (credentials: AzureLoginCredentials) => Promise<LoginResult>;
|
|
521
555
|
/**
|
|
522
556
|
* Refresh access token using refresh token
|
|
523
557
|
*
|
|
@@ -533,7 +567,7 @@ declare class AuthService {
|
|
|
533
567
|
* }
|
|
534
568
|
* ```
|
|
535
569
|
*/
|
|
536
|
-
refreshToken(refreshToken: string)
|
|
570
|
+
refreshToken: (refreshToken: string) => Promise<RefreshTokenResult>;
|
|
537
571
|
/**
|
|
538
572
|
* Get current user information
|
|
539
573
|
*
|
|
@@ -548,43 +582,14 @@ declare class AuthService {
|
|
|
548
582
|
* }
|
|
549
583
|
* ```
|
|
550
584
|
*/
|
|
551
|
-
getCurrentUser()
|
|
585
|
+
getCurrentUser: () => Promise<{
|
|
552
586
|
success: true;
|
|
553
587
|
user: User;
|
|
554
588
|
} | {
|
|
555
589
|
success: false;
|
|
556
590
|
error: string;
|
|
557
591
|
}>;
|
|
558
|
-
|
|
559
|
-
* Logout current user
|
|
560
|
-
* Clears tokens from storage and API client
|
|
561
|
-
*
|
|
562
|
-
* @example
|
|
563
|
-
* ```typescript
|
|
564
|
-
* await authService.logout();
|
|
565
|
-
* console.log('User logged out');
|
|
566
|
-
* ```
|
|
567
|
-
*/
|
|
568
|
-
logout(): Promise<void>;
|
|
569
|
-
/**
|
|
570
|
-
* Check if user is authenticated
|
|
571
|
-
*
|
|
572
|
-
* @returns True if user has valid tokens
|
|
573
|
-
*/
|
|
574
|
-
isAuthenticated(): Promise<boolean>;
|
|
575
|
-
/**
|
|
576
|
-
* Get stored tokens
|
|
577
|
-
*
|
|
578
|
-
* @returns Stored tokens or null
|
|
579
|
-
*/
|
|
580
|
-
getStoredTokens(): Promise<AuthTokens | null>;
|
|
581
|
-
/**
|
|
582
|
-
* Get stored user
|
|
583
|
-
*
|
|
584
|
-
* @returns Stored user or null
|
|
585
|
-
*/
|
|
586
|
-
getStoredUser(): Promise<User | null>;
|
|
587
|
-
}
|
|
592
|
+
};
|
|
588
593
|
|
|
589
594
|
/**
|
|
590
595
|
* QR Access Service
|
|
@@ -598,43 +603,19 @@ interface QRValidationOptions {
|
|
|
598
603
|
skipLocationCheck?: boolean;
|
|
599
604
|
skipRepetitiveCheck?: boolean;
|
|
600
605
|
}
|
|
601
|
-
interface QRValidationResult {
|
|
602
|
-
success: boolean;
|
|
603
|
-
message: string;
|
|
606
|
+
interface QRValidationResult extends FlowResponseType {
|
|
604
607
|
entrance?: Entrance;
|
|
605
|
-
error?: {
|
|
606
|
-
code: string;
|
|
607
|
-
details?: string;
|
|
608
|
-
};
|
|
609
608
|
}
|
|
610
|
-
declare
|
|
611
|
-
private apiClient;
|
|
612
|
-
constructor(apiClient: ApiClient);
|
|
613
|
-
/**
|
|
614
|
-
* Validate QR code format
|
|
615
|
-
*/
|
|
616
|
-
private validateQRFormat;
|
|
617
|
-
/**
|
|
618
|
-
* Check if location validation is required
|
|
619
|
-
*/
|
|
620
|
-
private shouldValidateLocation;
|
|
609
|
+
declare const QRAccessService: {
|
|
621
610
|
/**
|
|
622
|
-
*
|
|
623
|
-
*/
|
|
624
|
-
private validateLocation;
|
|
625
|
-
/**
|
|
626
|
-
* Validate QR code with full checks
|
|
611
|
+
* Trigger IoT device
|
|
627
612
|
*/
|
|
628
|
-
|
|
613
|
+
triggerIoTDevice: (deviceId: string, config?: AxiosRequestConfig) => Promise<BaseResponse<Entrance>>;
|
|
629
614
|
/**
|
|
630
615
|
* Create entrance from QR code
|
|
631
616
|
*/
|
|
632
|
-
createEntranceFromQR(request: CreateEntranceFromQRRequest)
|
|
633
|
-
|
|
634
|
-
* Trigger IoT device
|
|
635
|
-
*/
|
|
636
|
-
triggerIoTDevice(deviceId: string): Promise<BaseResponse>;
|
|
637
|
-
}
|
|
617
|
+
createEntranceFromQR: (request: CreateEntranceFromQRRequest) => Promise<BaseResponse<Entrance>>;
|
|
618
|
+
};
|
|
638
619
|
|
|
639
620
|
/**
|
|
640
621
|
* NFC Access Service
|
|
@@ -648,168 +629,71 @@ interface NFCValidationOptions {
|
|
|
648
629
|
skipLocationCheck?: boolean;
|
|
649
630
|
skipRepetitiveCheck?: boolean;
|
|
650
631
|
}
|
|
651
|
-
interface NFCValidationResult {
|
|
652
|
-
success: boolean;
|
|
653
|
-
message: string;
|
|
632
|
+
interface NFCValidationResult extends FlowResponseType {
|
|
654
633
|
entrance?: Entrance;
|
|
655
|
-
error?: {
|
|
656
|
-
code: string;
|
|
657
|
-
details?: string;
|
|
658
|
-
};
|
|
659
634
|
}
|
|
660
|
-
declare
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
/**
|
|
668
|
-
* Check if location validation is required
|
|
669
|
-
*/
|
|
670
|
-
private shouldValidateLocation;
|
|
671
|
-
/**
|
|
672
|
-
* Validate user location against device location
|
|
673
|
-
*/
|
|
674
|
-
private validateLocation;
|
|
635
|
+
declare const NfcAccessService: {
|
|
636
|
+
validateNFCFormat: (code: string) => boolean;
|
|
637
|
+
shouldValidateLocation: (device?: QrDevice) => boolean;
|
|
638
|
+
validateLocation: (device?: QrDevice, userLocation?: Coordinates) => {
|
|
639
|
+
valid: boolean;
|
|
640
|
+
distance?: number;
|
|
641
|
+
};
|
|
675
642
|
/**
|
|
676
643
|
* Validate NFC code with full checks
|
|
677
644
|
*/
|
|
678
645
|
validateNFC(options: NFCValidationOptions): Promise<NFCValidationResult>;
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
/**
|
|
682
|
-
* Check-In Service
|
|
683
|
-
* Handles GPS-based check-in to nearby branches
|
|
684
|
-
*/
|
|
685
|
-
|
|
686
|
-
interface CheckInOptions {
|
|
687
|
-
branchId: string;
|
|
688
|
-
entranceType: EntranceType;
|
|
689
|
-
userId: string;
|
|
690
|
-
userLocation?: Coordinates;
|
|
691
|
-
}
|
|
692
|
-
interface CheckInResult {
|
|
693
|
-
success: boolean;
|
|
694
|
-
message: string;
|
|
695
|
-
entrance?: Entrance;
|
|
696
|
-
error?: {
|
|
697
|
-
code: string;
|
|
698
|
-
details?: string;
|
|
699
|
-
};
|
|
700
|
-
}
|
|
701
|
-
declare class CheckInService {
|
|
702
|
-
private apiClient;
|
|
703
|
-
constructor(apiClient: ApiClient);
|
|
704
|
-
/**
|
|
705
|
-
* Get nearby branches based on user location
|
|
706
|
-
*/
|
|
707
|
-
getNearbyBranches(request: NearbyBranchesRequest): Promise<BaseResponse<Branch[]>>;
|
|
708
|
-
/**
|
|
709
|
-
* Check in to a branch
|
|
710
|
-
*/
|
|
711
|
-
checkIn(options: CheckInOptions): Promise<CheckInResult>;
|
|
712
|
-
/**
|
|
713
|
-
* Get branch by ID
|
|
714
|
-
*/
|
|
715
|
-
getBranchById(branchId: string): Promise<BaseResponse<Branch>>;
|
|
716
|
-
/**
|
|
717
|
-
* Get all branches (with pagination)
|
|
718
|
-
*/
|
|
719
|
-
getAllBranches(params?: {
|
|
720
|
-
page?: number;
|
|
721
|
-
per_page?: number;
|
|
722
|
-
}): Promise<BaseResponse<Branch[]>>;
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
/**
|
|
726
|
-
* Remote Work Service
|
|
727
|
-
* Handles remote work entry and exit logging
|
|
728
|
-
*/
|
|
729
|
-
|
|
730
|
-
interface RemoteWorkEntryOptions {
|
|
731
|
-
userId: string;
|
|
732
|
-
entranceType: EntranceType;
|
|
733
|
-
timestamp?: Date | string;
|
|
734
|
-
description?: string;
|
|
735
|
-
}
|
|
736
|
-
interface RemoteWorkResult {
|
|
737
|
-
success: boolean;
|
|
738
|
-
message: string;
|
|
739
|
-
entrance?: Entrance;
|
|
740
|
-
error?: {
|
|
741
|
-
code: string;
|
|
742
|
-
details?: string;
|
|
743
|
-
};
|
|
744
|
-
}
|
|
745
|
-
declare class RemoteWorkService {
|
|
746
|
-
private apiClient;
|
|
747
|
-
constructor(apiClient: ApiClient);
|
|
748
|
-
/**
|
|
749
|
-
* Log remote work entry or exit
|
|
750
|
-
*/
|
|
751
|
-
logRemoteWork(options: RemoteWorkEntryOptions): Promise<RemoteWorkResult>;
|
|
752
|
-
/**
|
|
753
|
-
* Log remote work entry
|
|
754
|
-
*/
|
|
755
|
-
logEntry(options: Omit<RemoteWorkEntryOptions, 'entranceType'>): Promise<RemoteWorkResult>;
|
|
756
|
-
/**
|
|
757
|
-
* Log remote work exit
|
|
758
|
-
*/
|
|
759
|
-
logExit(options: Omit<RemoteWorkEntryOptions, 'entranceType'>): Promise<RemoteWorkResult>;
|
|
760
|
-
}
|
|
646
|
+
};
|
|
761
647
|
|
|
762
648
|
/**
|
|
763
649
|
* Device Access Service
|
|
764
650
|
* Handles device access control and management
|
|
765
651
|
*/
|
|
766
652
|
|
|
767
|
-
declare
|
|
768
|
-
private apiClient;
|
|
769
|
-
constructor(apiClient: ApiClient);
|
|
653
|
+
declare const DeviceAccessService: {
|
|
770
654
|
/**
|
|
771
655
|
* Get all devices
|
|
772
656
|
*/
|
|
773
|
-
getDevices(params?: {
|
|
657
|
+
getDevices: (params?: {
|
|
774
658
|
page?: number;
|
|
775
659
|
per_page?: number;
|
|
776
|
-
})
|
|
660
|
+
}) => Promise<BaseResponse<Device[]>>;
|
|
777
661
|
/**
|
|
778
662
|
* Get all QR devices
|
|
779
663
|
*/
|
|
780
|
-
getQRDevices(params?: {
|
|
664
|
+
getQRDevices: (params?: {
|
|
781
665
|
page?: number;
|
|
782
666
|
per_page?: number;
|
|
783
|
-
})
|
|
667
|
+
}) => Promise<BaseResponse<QrDevice[]>>;
|
|
784
668
|
/**
|
|
785
669
|
* Get all QR devices with pagination support
|
|
786
670
|
*/
|
|
787
|
-
getAllQRDevices()
|
|
671
|
+
getAllQRDevices: () => Promise<QrDevice[]>;
|
|
788
672
|
/**
|
|
789
673
|
* Get accessible QR codes for current user
|
|
790
674
|
*/
|
|
791
|
-
getAccessibleQRs()
|
|
675
|
+
getAccessibleQRs: () => Promise<BaseResponse<QrAccessResponse>>;
|
|
792
676
|
/**
|
|
793
677
|
* Get user devices
|
|
794
678
|
*/
|
|
795
|
-
getUserDevices(request: DeviceAccessRequest)
|
|
679
|
+
getUserDevices: (request: DeviceAccessRequest) => Promise<BaseResponse<Device[]>>;
|
|
796
680
|
/**
|
|
797
681
|
* Get device by ID
|
|
798
682
|
*/
|
|
799
|
-
getDeviceById(deviceId: string)
|
|
683
|
+
getDeviceById: (deviceId: string) => Promise<BaseResponse<Device>>;
|
|
800
684
|
/**
|
|
801
685
|
* Check if user has access to a device
|
|
802
686
|
*/
|
|
803
|
-
checkDeviceAccess(deviceId: string)
|
|
687
|
+
checkDeviceAccess: (deviceId: string) => Promise<boolean>;
|
|
804
688
|
/**
|
|
805
689
|
* Find QR device by QR code ID
|
|
806
690
|
*/
|
|
807
|
-
findDeviceByQRCode(qrCodeId: string)
|
|
691
|
+
findDeviceByQRCode: (qrCodeId: string) => Promise<QrDevice | undefined>;
|
|
808
692
|
/**
|
|
809
693
|
* Find QR device by NFC code
|
|
810
694
|
*/
|
|
811
|
-
findDeviceByNFCCode(nfcCode: string)
|
|
812
|
-
}
|
|
695
|
+
findDeviceByNFCCode: (nfcCode: string) => Promise<QrDevice | undefined>;
|
|
696
|
+
};
|
|
813
697
|
|
|
814
698
|
/**
|
|
815
699
|
* Location Service
|
|
@@ -927,12 +811,14 @@ declare function validateCoordinates(coords?: Coordinates): boolean;
|
|
|
927
811
|
/**
|
|
928
812
|
* Validation utility functions
|
|
929
813
|
*/
|
|
814
|
+
|
|
930
815
|
/**
|
|
931
816
|
* Check if a code was recently read (within 15 seconds)
|
|
932
817
|
* @param code - Code to check
|
|
933
818
|
* @returns true if this is a new read, false if repetitive
|
|
934
819
|
*/
|
|
935
|
-
declare function checkRepetitiveRead(code
|
|
820
|
+
declare function checkRepetitiveRead(code?: string): boolean;
|
|
821
|
+
declare const addQrReadRecord: (code?: string) => void;
|
|
936
822
|
/**
|
|
937
823
|
* Clear all read records
|
|
938
824
|
*/
|
|
@@ -942,7 +828,7 @@ declare function clearReadRecords(): void;
|
|
|
942
828
|
* @param code - QR code to validate
|
|
943
829
|
* @returns true if valid
|
|
944
830
|
*/
|
|
945
|
-
declare function validateQRCode(code
|
|
831
|
+
declare function validateQRCode(code?: string): boolean;
|
|
946
832
|
/**
|
|
947
833
|
* Validate NFC code format
|
|
948
834
|
* @param code - NFC code to validate
|
|
@@ -955,6 +841,17 @@ declare function validateNFCCode(code: string): boolean;
|
|
|
955
841
|
* @returns true if valid UUID
|
|
956
842
|
*/
|
|
957
843
|
declare function validateDeviceId(id: string): boolean;
|
|
844
|
+
/**
|
|
845
|
+
* Check if location validation is required
|
|
846
|
+
*/
|
|
847
|
+
declare const shouldValidateLocation: (device: QrDevice) => boolean;
|
|
848
|
+
/**
|
|
849
|
+
* Validate user location against device location
|
|
850
|
+
*/
|
|
851
|
+
declare const validateLocation: (device: QrDevice, userLocation?: Coordinates) => {
|
|
852
|
+
valid: boolean;
|
|
853
|
+
distance?: number;
|
|
854
|
+
};
|
|
958
855
|
|
|
959
856
|
/**
|
|
960
857
|
* Date utility functions
|
|
@@ -995,250 +892,65 @@ declare function parseISO(isoString: string): Date;
|
|
|
995
892
|
* Main provider component for SDK configuration
|
|
996
893
|
*/
|
|
997
894
|
|
|
998
|
-
interface PassgageAccessConfig {
|
|
999
|
-
baseURL: string;
|
|
1000
|
-
token?: string;
|
|
1001
|
-
apiVersion?: string;
|
|
1002
|
-
timeout?: number;
|
|
1003
|
-
onUnauthorized?: () => void;
|
|
1004
|
-
onError?: (error: Error) => void;
|
|
1005
|
-
}
|
|
1006
|
-
interface PassgageAccessContextValue {
|
|
1007
|
-
apiClient: ApiClient;
|
|
1008
|
-
authService: AuthService;
|
|
1009
|
-
qrAccessService: QRAccessService;
|
|
1010
|
-
nfcAccessService: NFCAccessService;
|
|
1011
|
-
checkInService: CheckInService;
|
|
1012
|
-
remoteWorkService: RemoteWorkService;
|
|
1013
|
-
deviceAccessService: DeviceAccessService;
|
|
1014
|
-
locationService: LocationService;
|
|
1015
|
-
config: PassgageAccessConfig;
|
|
1016
|
-
setToken: (token: string | null) => void;
|
|
1017
|
-
clearToken: () => void;
|
|
1018
|
-
}
|
|
1019
895
|
interface PassgageAccessProviderProps {
|
|
1020
896
|
children: ReactNode;
|
|
1021
897
|
baseURL: string;
|
|
1022
|
-
|
|
898
|
+
msalToken: string;
|
|
1023
899
|
apiVersion?: string;
|
|
1024
900
|
timeout?: number;
|
|
1025
|
-
|
|
1026
|
-
|
|
901
|
+
rememberUser?: boolean;
|
|
902
|
+
onUnauthorized?: (error: Error) => void;
|
|
903
|
+
getLocationErrorCallback?: (error: any) => void;
|
|
904
|
+
locationPermissionErrorCallback?: (error: any) => void;
|
|
1027
905
|
}
|
|
1028
|
-
declare function PassgageAccessProvider(
|
|
1029
|
-
|
|
1030
|
-
* Hook to access Passgage SDK context
|
|
1031
|
-
*/
|
|
1032
|
-
declare function usePassgageAccess(): PassgageAccessContextValue;
|
|
1033
|
-
|
|
1034
|
-
/**
|
|
1035
|
-
* Authentication Hook
|
|
1036
|
-
*
|
|
1037
|
-
* Provides authentication functionality including login, logout, and user state management.
|
|
1038
|
-
*/
|
|
906
|
+
declare function PassgageAccessProvider(props: PassgageAccessProviderProps): React.JSX.Element;
|
|
907
|
+
declare const usePassgageAccessContext: () => PassgageAccessProviderProps;
|
|
1039
908
|
|
|
1040
|
-
interface
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
*/
|
|
1044
|
-
onLoginSuccess?: (user?: User) => void;
|
|
1045
|
-
/**
|
|
1046
|
-
* Callback called when login fails
|
|
1047
|
-
*/
|
|
1048
|
-
onLoginError?: (error: string) => void;
|
|
1049
|
-
/**
|
|
1050
|
-
* Callback called when logout is successful
|
|
1051
|
-
*/
|
|
1052
|
-
onLogoutSuccess?: () => void;
|
|
1053
|
-
/**
|
|
1054
|
-
* Automatically check for stored tokens on mount
|
|
1055
|
-
* @default true
|
|
1056
|
-
*/
|
|
1057
|
-
autoRestore?: boolean;
|
|
1058
|
-
}
|
|
1059
|
-
interface UsePassgageAuthReturn {
|
|
1060
|
-
/**
|
|
1061
|
-
* Login with credentials
|
|
1062
|
-
*/
|
|
1063
|
-
login: (credentials: LoginCredentials) => Promise<LoginResult>;
|
|
1064
|
-
/**
|
|
1065
|
-
* Logout current user
|
|
1066
|
-
*/
|
|
1067
|
-
logout: () => Promise<void>;
|
|
1068
|
-
/**
|
|
1069
|
-
* Refresh access token
|
|
1070
|
-
*/
|
|
1071
|
-
refreshToken: () => Promise<boolean>;
|
|
1072
|
-
/**
|
|
1073
|
-
* Whether user is authenticated
|
|
1074
|
-
*/
|
|
1075
|
-
isAuthenticated: boolean;
|
|
1076
|
-
/**
|
|
1077
|
-
* Current user information
|
|
1078
|
-
*/
|
|
1079
|
-
user: User | null;
|
|
1080
|
-
/**
|
|
1081
|
-
* Whether an auth operation is in progress
|
|
1082
|
-
*/
|
|
1083
|
-
isLoading: boolean;
|
|
1084
|
-
/**
|
|
1085
|
-
* Last error message
|
|
1086
|
-
*/
|
|
1087
|
-
error: string | null;
|
|
1088
|
-
/**
|
|
1089
|
-
* Clear error message
|
|
1090
|
-
*/
|
|
1091
|
-
clearError: () => void;
|
|
909
|
+
interface EnteranceFlowOptions {
|
|
910
|
+
skipLocationCheck?: boolean;
|
|
911
|
+
skipRepetitiveCheck?: boolean;
|
|
1092
912
|
}
|
|
1093
|
-
/**
|
|
1094
|
-
* Authentication hook
|
|
1095
|
-
*
|
|
1096
|
-
* @example
|
|
1097
|
-
* ```typescript
|
|
1098
|
-
* function LoginScreen() {
|
|
1099
|
-
* const { login, isLoading, error, isAuthenticated } = usePassgageAuth({
|
|
1100
|
-
* onLoginSuccess: (user) => {
|
|
1101
|
-
* console.log('Logged in:', user);
|
|
1102
|
-
* navigation.navigate('Home');
|
|
1103
|
-
* },
|
|
1104
|
-
* onLoginError: (error) => {
|
|
1105
|
-
* Alert.alert('Login Failed', error);
|
|
1106
|
-
* }
|
|
1107
|
-
* });
|
|
1108
|
-
*
|
|
1109
|
-
* const handleLogin = async () => {
|
|
1110
|
-
* await login({
|
|
1111
|
-
* login: 'user@example.com',
|
|
1112
|
-
* password: 'password123'
|
|
1113
|
-
* });
|
|
1114
|
-
* };
|
|
1115
|
-
*
|
|
1116
|
-
* if (isAuthenticated) {
|
|
1117
|
-
* return <Text>Already logged in!</Text>;
|
|
1118
|
-
* }
|
|
1119
|
-
*
|
|
1120
|
-
* return (
|
|
1121
|
-
* <View>
|
|
1122
|
-
* <Button
|
|
1123
|
-
* title="Login"
|
|
1124
|
-
* onPress={handleLogin}
|
|
1125
|
-
* disabled={isLoading}
|
|
1126
|
-
* />
|
|
1127
|
-
* {error && <Text>{error}</Text>}
|
|
1128
|
-
* </View>
|
|
1129
|
-
* );
|
|
1130
|
-
* }
|
|
1131
|
-
* ```
|
|
1132
|
-
*/
|
|
1133
|
-
declare function usePassgageAuth(options?: UsePassgageAuthOptions): UsePassgageAuthReturn;
|
|
1134
913
|
|
|
1135
914
|
/**
|
|
1136
915
|
* usePassgageQRScanner hook
|
|
1137
916
|
* QR code scanning with validation
|
|
1138
917
|
*/
|
|
1139
918
|
|
|
1140
|
-
interface
|
|
919
|
+
interface UsePassgageQRScanner {
|
|
920
|
+
options: EnteranceFlowOptions;
|
|
1141
921
|
onSuccess?: (entrance?: Entrance) => void;
|
|
1142
|
-
onError?: (error
|
|
1143
|
-
skipLocationCheck?: boolean;
|
|
1144
|
-
skipRepetitiveCheck?: boolean;
|
|
922
|
+
onError?: (error?: FlowResponseType) => void;
|
|
1145
923
|
}
|
|
1146
924
|
interface UsePassgageQRScannerReturn {
|
|
1147
925
|
scan: (qrCode: string, device?: QrDevice) => Promise<void>;
|
|
1148
926
|
isLoading: boolean;
|
|
1149
|
-
error:
|
|
927
|
+
error: FlowResponseType | null;
|
|
1150
928
|
}
|
|
1151
|
-
declare
|
|
929
|
+
declare const usePassgageQRScanner: (payload: UsePassgageQRScanner) => UsePassgageQRScannerReturn;
|
|
1152
930
|
|
|
1153
931
|
/**
|
|
1154
932
|
* usePassgageNFCScanner hook
|
|
1155
|
-
* NFC card
|
|
933
|
+
* NFC card isScanning with validation
|
|
1156
934
|
*/
|
|
1157
935
|
|
|
1158
936
|
interface UsePassgageNFCScannerOptions {
|
|
937
|
+
options: EnteranceFlowOptions;
|
|
1159
938
|
onSuccess?: (entrance?: Entrance) => void;
|
|
1160
939
|
onError?: (error: Error) => void;
|
|
1161
|
-
skipLocationCheck?: boolean;
|
|
1162
|
-
skipRepetitiveCheck?: boolean;
|
|
1163
|
-
autoStart?: boolean;
|
|
1164
940
|
}
|
|
1165
941
|
interface UsePassgageNFCScannerReturn {
|
|
942
|
+
nfcData?: string;
|
|
943
|
+
supportNFC?: boolean;
|
|
1166
944
|
startScanning: () => Promise<void>;
|
|
1167
945
|
stopScanning: () => Promise<void>;
|
|
1168
946
|
isScanning: boolean;
|
|
1169
947
|
error: Error | null;
|
|
1170
948
|
}
|
|
1171
|
-
declare function usePassgageNFCScanner(options?: UsePassgageNFCScannerOptions): UsePassgageNFCScannerReturn;
|
|
1172
|
-
|
|
1173
|
-
/**
|
|
1174
|
-
* usePassgageCheckIn hook
|
|
1175
|
-
* GPS-based check-in to nearby branches
|
|
1176
|
-
*/
|
|
1177
|
-
|
|
1178
|
-
interface UsePassgageCheckInOptions {
|
|
1179
|
-
radius?: number;
|
|
1180
|
-
}
|
|
1181
|
-
interface CheckInEntryParams {
|
|
1182
|
-
branchId: string;
|
|
1183
|
-
userId: string;
|
|
1184
|
-
}
|
|
1185
|
-
interface CheckInExitParams {
|
|
1186
|
-
branchId: string;
|
|
1187
|
-
userId: string;
|
|
1188
|
-
}
|
|
1189
|
-
interface GetNearbyBranchesParams {
|
|
1190
|
-
radius?: number;
|
|
1191
|
-
}
|
|
1192
|
-
interface UsePassgageCheckInReturn {
|
|
1193
|
-
getNearbyBranches: (params?: GetNearbyBranchesParams) => Promise<{
|
|
1194
|
-
success: boolean;
|
|
1195
|
-
data?: Branch[];
|
|
1196
|
-
error?: string;
|
|
1197
|
-
}>;
|
|
1198
|
-
checkInEntry: (params: CheckInEntryParams) => Promise<{
|
|
1199
|
-
success: boolean;
|
|
1200
|
-
data?: any;
|
|
1201
|
-
error?: string;
|
|
1202
|
-
}>;
|
|
1203
|
-
checkInExit: (params: CheckInExitParams) => Promise<{
|
|
1204
|
-
success: boolean;
|
|
1205
|
-
data?: any;
|
|
1206
|
-
error?: string;
|
|
1207
|
-
}>;
|
|
1208
|
-
isLoading: boolean;
|
|
1209
|
-
error: Error | null;
|
|
1210
|
-
}
|
|
1211
|
-
declare function usePassgageCheckIn(options?: UsePassgageCheckInOptions): UsePassgageCheckInReturn;
|
|
1212
|
-
|
|
1213
949
|
/**
|
|
1214
|
-
*
|
|
1215
|
-
* Remote work entry/exit logging
|
|
950
|
+
* Convert hex string to decimal
|
|
1216
951
|
*/
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
description?: string;
|
|
1220
|
-
timestamp?: Date | string;
|
|
1221
|
-
}
|
|
1222
|
-
interface RemoteWorkExitParams {
|
|
1223
|
-
userId: string;
|
|
1224
|
-
description?: string;
|
|
1225
|
-
timestamp?: Date | string;
|
|
1226
|
-
}
|
|
1227
|
-
interface UsePassgageRemoteWorkReturn {
|
|
1228
|
-
logEntry: (params: RemoteWorkEntryParams) => Promise<{
|
|
1229
|
-
success: boolean;
|
|
1230
|
-
data?: any;
|
|
1231
|
-
error?: string;
|
|
1232
|
-
}>;
|
|
1233
|
-
logExit: (params: RemoteWorkExitParams) => Promise<{
|
|
1234
|
-
success: boolean;
|
|
1235
|
-
data?: any;
|
|
1236
|
-
error?: string;
|
|
1237
|
-
}>;
|
|
1238
|
-
isLoading: boolean;
|
|
1239
|
-
error: Error | null;
|
|
1240
|
-
}
|
|
1241
|
-
declare function usePassgageRemoteWork(): UsePassgageRemoteWorkReturn;
|
|
952
|
+
declare const reversedHexToDec: (reversedHex: string) => string;
|
|
953
|
+
declare function usePassgageNFCScanner(payload: UsePassgageNFCScannerOptions): UsePassgageNFCScannerReturn;
|
|
1242
954
|
|
|
1243
955
|
/**
|
|
1244
956
|
* useLocation hook
|
|
@@ -1259,11 +971,41 @@ interface UseLocationReturn {
|
|
|
1259
971
|
}
|
|
1260
972
|
declare function useLocation(options?: UseLocationOptions): UseLocationReturn;
|
|
1261
973
|
|
|
974
|
+
interface AuthStoreType {
|
|
975
|
+
loading: boolean;
|
|
976
|
+
error: string | null;
|
|
977
|
+
authStatus: boolean;
|
|
978
|
+
user: User | null;
|
|
979
|
+
restoreAuth: () => void;
|
|
980
|
+
login: (credentials: LoginCredentials, resolve?: (user?: User) => void, reject?: (error: string) => void) => void;
|
|
981
|
+
loginWithAzure: (credentials: AzureLoginCredentials, resolve?: (user?: User) => void, reject?: (error: string) => void) => void;
|
|
982
|
+
logout: (resolve?: () => void) => Promise<void>;
|
|
983
|
+
}
|
|
984
|
+
declare const useAuthStore: zustand.UseBoundStore<zustand.StoreApi<AuthStoreType>>;
|
|
985
|
+
|
|
986
|
+
interface LocationStoreType {
|
|
987
|
+
location: Coordinates | null;
|
|
988
|
+
error: GeoError | null;
|
|
989
|
+
loading: boolean;
|
|
990
|
+
refreshLocation: (config?: GeoOptions) => void;
|
|
991
|
+
}
|
|
992
|
+
declare const locationStore: zustand.UseBoundStore<zustand.StoreApi<LocationStoreType>>;
|
|
993
|
+
|
|
994
|
+
interface QrStoreType {
|
|
995
|
+
loading: boolean;
|
|
996
|
+
error: string | null;
|
|
997
|
+
qrDevices: QrDevice[];
|
|
998
|
+
qrAccessDevices: string[];
|
|
999
|
+
handleQrAccess: () => void;
|
|
1000
|
+
fetchQrDevicesAndAccess: () => void;
|
|
1001
|
+
}
|
|
1002
|
+
declare const qrScannerStore: zustand.UseBoundStore<zustand.StoreApi<QrStoreType>>;
|
|
1003
|
+
|
|
1262
1004
|
/**
|
|
1263
1005
|
* Passgage Access SDK - React Native Package
|
|
1264
1006
|
* Complete SDK with core functionality and React Native integration
|
|
1265
1007
|
*/
|
|
1266
1008
|
|
|
1267
|
-
declare const SDK_VERSION = "1.0.
|
|
1009
|
+
declare const SDK_VERSION = "1.0.6";
|
|
1268
1010
|
|
|
1269
|
-
export { type APIError, ApiClient, type ApiClientConfig, AuthService, type AuthState, type AuthTokens, type
|
|
1011
|
+
export { type APIError, ApiClient, type ApiClientConfig, AuthService, type AuthState, type AuthTokens, type AzureLoginCredentials, type AzureLoginResponse, type BaseResponse, type Branch, type CompanyInfo, type Coordinates, type CreateEntranceFromQRRequest, type CreateEntranceRequest, type Device, type DeviceAccessRequest, DeviceAccessService, DeviceDirection, DeviceUsage, endpoints as Endpoints, type Entrance, type EntranceQueryParams, EntranceType, type FlowResponseType, LocationService, type LocationVerificationLog, type LoginCredentials, type LoginRequest, type LoginResponse, type LoginResult, type NFCValidationOptions, type NFCValidationResult, type NearbyBranchesRequest, NfcAccessService, type PaginationMeta, PassgageAccessProvider, type PassgageAccessProviderProps, QRAccessService, type QRValidationOptions, type QRValidationResult, type QrAccessResponse, type QrDevice, type RefreshTokenRequest, type RefreshTokenResponse, type RefreshTokenResult, type ReqCreateEntrance, type RequestOptions, SDK_VERSION, type TokenInfo, type TokenStorage, type UseLocationOptions, type UseLocationReturn, type UsePassgageNFCScannerOptions, type UsePassgageNFCScannerReturn, type UsePassgageQRScanner, type UsePassgageQRScannerReturn, type User, addQrReadRecord, calculateDistance, checkOnLocation, checkRepetitiveRead, clearReadRecords, createApiClient, formatDate, formatDateTime, formatISO, formatTime, locationStore, parseISO, qrScannerStore, reversedHexToDec, shouldValidateLocation, useAuthStore, useLocation, usePassgageAccessContext, usePassgageNFCScanner, usePassgageQRScanner, validateCoordinates, validateDeviceId, validateLocation, validateNFCCode, validateQRCode };
|