@passgage/sdk-react-native 1.0.1 → 1.0.3

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/index.d.mts CHANGED
@@ -1,6 +1,994 @@
1
+ import { AxiosRequestConfig } from 'axios';
1
2
  import React, { ReactNode } from 'react';
2
- import { ApiClient, AuthService, QRAccessService, NFCAccessService, CheckInService, RemoteWorkService, DeviceAccessService, LocationService, User, LoginCredentials, LoginResult, Entrance, QrDevice, EntranceType, Branch, Coordinates } from '@passgage/sdk-core';
3
- export { BaseResponse, Branch, Coordinates, Device, Entrance, EntranceType, QrDevice } from '@passgage/sdk-core';
3
+
4
+ /**
5
+ * Common types and interfaces used across the SDK
6
+ */
7
+ interface BaseResponse<T = unknown> {
8
+ success: boolean;
9
+ status: number;
10
+ message: string;
11
+ data?: T;
12
+ meta?: PaginationMeta;
13
+ errors?: Record<string, string[]>;
14
+ }
15
+ interface PaginationMeta {
16
+ current_page: number;
17
+ total_pages: number;
18
+ total_count: number;
19
+ per_page: number;
20
+ }
21
+ interface Coordinates {
22
+ latitude: number;
23
+ longitude: number;
24
+ accuracy?: number;
25
+ altitude?: number;
26
+ altitudeAccuracy?: number;
27
+ heading?: number;
28
+ speed?: number;
29
+ }
30
+ interface LocationVerificationLog {
31
+ mobileLatitude: number;
32
+ mobileLongitude: number;
33
+ currentScreen: string;
34
+ qrLatitude: number;
35
+ qrLongitude: number;
36
+ message: string;
37
+ navigation_step: string;
38
+ errorCode: string;
39
+ additionalInfo: string;
40
+ qr: string;
41
+ accuracy?: number;
42
+ altitude?: number;
43
+ isGps: boolean;
44
+ deviceRange: number;
45
+ distance?: number;
46
+ reduxPosition?: string;
47
+ customData?: Record<string, unknown>;
48
+ }
49
+ declare enum EntranceType {
50
+ ENTRY = 0,
51
+ EXIT = 1
52
+ }
53
+ declare enum DeviceUsage {
54
+ PDKS = "pdks",
55
+ MEETING_ROOM = "meeting_room",
56
+ FOOD = "food"
57
+ }
58
+ declare enum DeviceDirection {
59
+ ENTRY = 0,
60
+ EXIT = 1,
61
+ BIDIRECTIONAL = 2
62
+ }
63
+ interface APIError extends Error {
64
+ code?: string;
65
+ status?: number;
66
+ response?: BaseResponse;
67
+ }
68
+
69
+ /**
70
+ * Device-related types and interfaces
71
+ */
72
+
73
+ interface Device {
74
+ id: string;
75
+ name: string;
76
+ description?: string;
77
+ ip?: string;
78
+ device_type?: string;
79
+ device_usage?: DeviceUsage;
80
+ direction?: DeviceDirection;
81
+ branch_id?: string;
82
+ company_id: string;
83
+ is_active: boolean;
84
+ is_remote_work?: boolean;
85
+ anti_passback_enabled?: boolean;
86
+ created_at: string;
87
+ updated_at: string;
88
+ }
89
+ interface QrDevice {
90
+ id: string;
91
+ qr_code_id: string;
92
+ nfc_code?: string;
93
+ name: string;
94
+ description?: string;
95
+ latitude?: number;
96
+ longitude?: number;
97
+ range?: number;
98
+ nfc_range?: number;
99
+ range_matter?: '0' | '1';
100
+ nfc_range_matter?: '0' | '1';
101
+ company_id: string;
102
+ branch_id?: string;
103
+ is_active: boolean;
104
+ device_type?: string;
105
+ created_at: string;
106
+ updated_at: string;
107
+ }
108
+ interface DeviceAccessRequest {
109
+ userId?: string;
110
+ page?: number;
111
+ per_page?: number;
112
+ }
113
+ interface QrAccessResponse {
114
+ qr_ids: string[];
115
+ }
116
+
117
+ /**
118
+ * Entrance-related types and interfaces
119
+ */
120
+
121
+ interface Entrance {
122
+ id: string;
123
+ user_id: string;
124
+ device_id: string;
125
+ branch_id?: string;
126
+ building_id?: string;
127
+ zone_id?: string;
128
+ company_id: string;
129
+ entrance_type: EntranceType;
130
+ description?: string;
131
+ is_manual_recording?: boolean;
132
+ is_remote_work?: boolean;
133
+ service_id?: string;
134
+ log_date?: string;
135
+ log_date_time?: string;
136
+ created_at: string;
137
+ updated_at: string;
138
+ }
139
+ interface CreateEntranceRequest {
140
+ user_id: string;
141
+ device_id?: string;
142
+ branch_id?: string;
143
+ building_id?: string;
144
+ zone_id?: string;
145
+ entrance_type: EntranceType;
146
+ description?: string;
147
+ is_manual_recording?: boolean;
148
+ is_remote_work?: boolean;
149
+ service_id?: string;
150
+ created_at?: string;
151
+ log_date?: string;
152
+ log_date_time?: string;
153
+ }
154
+ interface CreateEntranceFromQRRequest {
155
+ device_id: string;
156
+ created_at?: string;
157
+ service_id?: string;
158
+ }
159
+ interface EntranceQueryParams {
160
+ user_id?: string;
161
+ device_id?: string;
162
+ entrance_type?: EntranceType;
163
+ created_at_gteq?: string;
164
+ created_at_lteq?: string;
165
+ page?: number;
166
+ per_page?: number;
167
+ }
168
+
169
+ /**
170
+ * Branch-related types and interfaces
171
+ */
172
+ interface Branch {
173
+ id: string;
174
+ title: string;
175
+ name?: string;
176
+ address?: string;
177
+ city?: string;
178
+ country?: string;
179
+ latitude?: number;
180
+ longitude?: number;
181
+ distance?: number | null;
182
+ company_id: string;
183
+ is_active: boolean;
184
+ created_at: string;
185
+ updated_at: string;
186
+ }
187
+ interface NearbyBranchesRequest {
188
+ latitude: number;
189
+ longitude: number;
190
+ radius?: number;
191
+ }
192
+
193
+ /**
194
+ * Authentication Models
195
+ */
196
+ /**
197
+ * Login credentials
198
+ */
199
+ interface LoginCredentials {
200
+ /** Email or phone number */
201
+ login: string;
202
+ /** User password */
203
+ password: string;
204
+ }
205
+ /**
206
+ * Token information
207
+ */
208
+ interface TokenInfo {
209
+ /** JWT token string */
210
+ token: string;
211
+ /** Token expiration time (e.g., "30 days from now") */
212
+ expiresIn: string;
213
+ }
214
+ /**
215
+ * Authentication tokens (access and refresh)
216
+ */
217
+ interface AuthTokens {
218
+ /** Access token for API requests */
219
+ access: TokenInfo;
220
+ /** Refresh token for getting new access tokens */
221
+ refresh: TokenInfo;
222
+ }
223
+ /**
224
+ * Company information
225
+ */
226
+ interface CompanyInfo {
227
+ /** Company ID */
228
+ id: string;
229
+ /** Company name */
230
+ name: string;
231
+ }
232
+ /**
233
+ * User information
234
+ */
235
+ interface User {
236
+ /** User ID */
237
+ id: string;
238
+ /** User email */
239
+ email: string;
240
+ /** User first name */
241
+ firstName: string;
242
+ /** User last name */
243
+ lastName: string;
244
+ /** User's company */
245
+ company: CompanyInfo;
246
+ /** Full name (computed) */
247
+ fullName?: string;
248
+ /** User's phone number */
249
+ gsm?: string;
250
+ /** Avatar URL */
251
+ avatar?: string | null;
252
+ /** Job title */
253
+ jobTitle?: string | null;
254
+ /** Birth date */
255
+ birthDate?: string | null;
256
+ /** Card number */
257
+ cardNo?: string | null;
258
+ }
259
+ /**
260
+ * Login request payload
261
+ */
262
+ interface LoginRequest {
263
+ user: {
264
+ login: string;
265
+ password: string;
266
+ };
267
+ }
268
+ /**
269
+ * Login response data from API
270
+ */
271
+ interface LoginResponse {
272
+ tokens: AuthTokens;
273
+ }
274
+ /**
275
+ * Token refresh request payload
276
+ */
277
+ interface RefreshTokenRequest {
278
+ token?: string;
279
+ refresh_token?: string;
280
+ }
281
+ /**
282
+ * Token refresh response data from API
283
+ */
284
+ interface RefreshTokenResponse {
285
+ token?: string;
286
+ refresh_token?: string;
287
+ }
288
+ /**
289
+ * Login result (success or error)
290
+ */
291
+ type LoginResult = {
292
+ success: true;
293
+ tokens: AuthTokens;
294
+ user?: User;
295
+ } | {
296
+ success: false;
297
+ error: string;
298
+ code?: string;
299
+ };
300
+ /**
301
+ * Refresh token result (success or error)
302
+ */
303
+ type RefreshTokenResult = {
304
+ success: true;
305
+ tokens: AuthTokens;
306
+ } | {
307
+ success: false;
308
+ error: string;
309
+ code?: string;
310
+ };
311
+ /**
312
+ * Auth state
313
+ */
314
+ interface AuthState {
315
+ /** Whether user is authenticated */
316
+ isAuthenticated: boolean;
317
+ /** Current user information */
318
+ user: User | null;
319
+ /** Current access token */
320
+ accessToken: string | null;
321
+ /** Current refresh token */
322
+ refreshToken: string | null;
323
+ }
324
+ /**
325
+ * Token storage interface for platform-specific implementations
326
+ */
327
+ interface TokenStorage {
328
+ /**
329
+ * Save tokens to secure storage
330
+ */
331
+ saveTokens(tokens: AuthTokens): Promise<void>;
332
+ /**
333
+ * Get tokens from secure storage
334
+ */
335
+ getTokens(): Promise<AuthTokens | null>;
336
+ /**
337
+ * Clear tokens from secure storage
338
+ */
339
+ clearTokens(): Promise<void>;
340
+ /**
341
+ * Save user information
342
+ */
343
+ saveUser(user: User): Promise<void>;
344
+ /**
345
+ * Get user information
346
+ */
347
+ getUser(): Promise<User | null>;
348
+ /**
349
+ * Clear user information
350
+ */
351
+ clearUser(): Promise<void>;
352
+ }
353
+
354
+ /**
355
+ * API Client implementation using Axios
356
+ */
357
+
358
+ interface ApiClientConfig {
359
+ baseURL: string;
360
+ token?: string;
361
+ timeout?: number;
362
+ apiVersion?: string;
363
+ headers?: Record<string, string>;
364
+ onUnauthorized?: () => void;
365
+ onError?: (error: APIError) => void;
366
+ /**
367
+ * Callback to refresh token when 401 is received
368
+ * Should return new access token or null if refresh failed
369
+ */
370
+ onTokenRefreshNeeded?: () => Promise<string | null>;
371
+ }
372
+ interface RequestOptions<T = unknown> {
373
+ endpoint: string;
374
+ method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
375
+ data?: T;
376
+ params?: Record<string, unknown>;
377
+ headers?: Record<string, string>;
378
+ config?: AxiosRequestConfig;
379
+ skipAuth?: boolean;
380
+ }
381
+ declare class ApiClient {
382
+ private axiosInstance;
383
+ private config;
384
+ private isRefreshing;
385
+ private refreshQueue;
386
+ constructor(config: ApiClientConfig);
387
+ /**
388
+ * Setup request and response interceptors
389
+ */
390
+ private setupInterceptors;
391
+ /**
392
+ * Handle API errors
393
+ */
394
+ private handleError;
395
+ /**
396
+ * Update authorization token
397
+ */
398
+ setToken(token: string | null): void;
399
+ /**
400
+ * Remove authorization token
401
+ */
402
+ clearToken(): void;
403
+ /**
404
+ * Generic GET request
405
+ */
406
+ get<T = unknown>(options: Omit<RequestOptions, 'method' | 'data'>): Promise<BaseResponse<T>>;
407
+ /**
408
+ * Generic POST request
409
+ */
410
+ post<T = unknown, R = unknown>(options: Omit<RequestOptions<T>, 'method'>): Promise<BaseResponse<R>>;
411
+ /**
412
+ * Generic PUT request
413
+ */
414
+ put<T = unknown, R = unknown>(options: Omit<RequestOptions<T>, 'method'>): Promise<BaseResponse<R>>;
415
+ /**
416
+ * Generic PATCH request
417
+ */
418
+ patch<T = unknown, R = unknown>(options: Omit<RequestOptions<T>, 'method'>): Promise<BaseResponse<R>>;
419
+ /**
420
+ * Generic DELETE request
421
+ */
422
+ delete<T = unknown>(options: Omit<RequestOptions, 'method' | 'data'>): Promise<BaseResponse<T>>;
423
+ }
424
+ /**
425
+ * Factory function to create API client instance
426
+ */
427
+ declare function createApiClient(config: ApiClientConfig): ApiClient;
428
+
429
+ /**
430
+ * API endpoint constants
431
+ */
432
+ declare const EP_LOGIN = "users/sign_in";
433
+ declare const EP_TOKEN = "token";
434
+ declare const EP_DEVICES = "devices";
435
+ declare const EP_QR_DEVICES = "devices/qr_devices";
436
+ declare const EP_QR_ACCESS = "qr_access/accessible_qrs";
437
+ declare const EP_QR_CHECK = "qr_check";
438
+ declare const EP_NFC_CHECK = "nfc_check";
439
+ declare const EP_ENTRANCES = "entrances";
440
+ declare const EP_CREATE_QR = "entrances/create_from_qr";
441
+ declare const EP_BRANCHES = "branches";
442
+ declare const EP_LOCATION_VERIFICATION = "location_verification_logs";
443
+ declare const EP_TRIGGER_IOT = "iot/trigger";
444
+ declare const EP_USERS = "users";
445
+ declare const EP_ME = "users/lite_me";
446
+
447
+ declare const endpoints_EP_BRANCHES: typeof EP_BRANCHES;
448
+ declare const endpoints_EP_CREATE_QR: typeof EP_CREATE_QR;
449
+ declare const endpoints_EP_DEVICES: typeof EP_DEVICES;
450
+ declare const endpoints_EP_ENTRANCES: typeof EP_ENTRANCES;
451
+ declare const endpoints_EP_LOCATION_VERIFICATION: typeof EP_LOCATION_VERIFICATION;
452
+ declare const endpoints_EP_LOGIN: typeof EP_LOGIN;
453
+ declare const endpoints_EP_ME: typeof EP_ME;
454
+ declare const endpoints_EP_NFC_CHECK: typeof EP_NFC_CHECK;
455
+ declare const endpoints_EP_QR_ACCESS: typeof EP_QR_ACCESS;
456
+ declare const endpoints_EP_QR_CHECK: typeof EP_QR_CHECK;
457
+ declare const endpoints_EP_QR_DEVICES: typeof EP_QR_DEVICES;
458
+ declare const endpoints_EP_TOKEN: typeof EP_TOKEN;
459
+ declare const endpoints_EP_TRIGGER_IOT: typeof EP_TRIGGER_IOT;
460
+ declare const endpoints_EP_USERS: typeof EP_USERS;
461
+ 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 };
463
+ }
464
+
465
+ /**
466
+ * Authentication Service
467
+ *
468
+ * Handles user authentication, token management, and user information retrieval.
469
+ */
470
+
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;
500
+ /**
501
+ * Login with credentials
502
+ *
503
+ * @param credentials - User login credentials (email/phone and password)
504
+ * @returns Login result with tokens on success
505
+ *
506
+ * @example
507
+ * ```typescript
508
+ * const result = await authService.login({
509
+ * login: 'user@example.com',
510
+ * password: 'password123'
511
+ * });
512
+ *
513
+ * if (result.success) {
514
+ * console.log('Access token:', result.tokens.access.token);
515
+ * } else {
516
+ * console.error('Login failed:', result.error);
517
+ * }
518
+ * ```
519
+ */
520
+ login(credentials: LoginCredentials): Promise<LoginResult>;
521
+ /**
522
+ * Refresh access token using refresh token
523
+ *
524
+ * @param refreshToken - The refresh token
525
+ * @returns Refresh result with new tokens on success
526
+ *
527
+ * @example
528
+ * ```typescript
529
+ * const result = await authService.refreshToken('refresh_token_here');
530
+ *
531
+ * if (result.success) {
532
+ * console.log('New access token:', result.tokens.access.token);
533
+ * }
534
+ * ```
535
+ */
536
+ refreshToken(refreshToken: string): Promise<RefreshTokenResult>;
537
+ /**
538
+ * Get current user information
539
+ *
540
+ * @returns Result with user information
541
+ *
542
+ * @example
543
+ * ```typescript
544
+ * const result = await authService.getCurrentUser();
545
+ *
546
+ * if (result.success) {
547
+ * console.log('User name:', result.user.fullName);
548
+ * }
549
+ * ```
550
+ */
551
+ getCurrentUser(): Promise<{
552
+ success: true;
553
+ user: User;
554
+ } | {
555
+ success: false;
556
+ error: string;
557
+ }>;
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
+ }
588
+
589
+ /**
590
+ * QR Access Service
591
+ * Handles QR code validation and entrance creation
592
+ */
593
+
594
+ interface QRValidationOptions {
595
+ qrCode: string;
596
+ device: QrDevice;
597
+ userLocation?: Coordinates;
598
+ skipLocationCheck?: boolean;
599
+ skipRepetitiveCheck?: boolean;
600
+ }
601
+ interface QRValidationResult {
602
+ success: boolean;
603
+ message: string;
604
+ entrance?: Entrance;
605
+ error?: {
606
+ code: string;
607
+ details?: string;
608
+ };
609
+ }
610
+ declare class QRAccessService {
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;
621
+ /**
622
+ * Validate user location against device location
623
+ */
624
+ private validateLocation;
625
+ /**
626
+ * Validate QR code with full checks
627
+ */
628
+ validateQR(options: QRValidationOptions): Promise<QRValidationResult>;
629
+ /**
630
+ * Create entrance from QR code
631
+ */
632
+ createEntranceFromQR(request: CreateEntranceFromQRRequest): Promise<BaseResponse<Entrance>>;
633
+ /**
634
+ * Trigger IoT device
635
+ */
636
+ triggerIoTDevice(deviceId: string): Promise<BaseResponse>;
637
+ }
638
+
639
+ /**
640
+ * NFC Access Service
641
+ * Handles NFC code validation and entrance creation
642
+ */
643
+
644
+ interface NFCValidationOptions {
645
+ nfcCode: string;
646
+ device: QrDevice;
647
+ userLocation?: Coordinates;
648
+ skipLocationCheck?: boolean;
649
+ skipRepetitiveCheck?: boolean;
650
+ }
651
+ interface NFCValidationResult {
652
+ success: boolean;
653
+ message: string;
654
+ entrance?: Entrance;
655
+ error?: {
656
+ code: string;
657
+ details?: string;
658
+ };
659
+ }
660
+ declare class NFCAccessService {
661
+ private apiClient;
662
+ constructor(apiClient: ApiClient);
663
+ /**
664
+ * Validate NFC code format
665
+ */
666
+ private validateNFCFormat;
667
+ /**
668
+ * Check if location validation is required
669
+ */
670
+ private shouldValidateLocation;
671
+ /**
672
+ * Validate user location against device location
673
+ */
674
+ private validateLocation;
675
+ /**
676
+ * Validate NFC code with full checks
677
+ */
678
+ 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
+ }
761
+
762
+ /**
763
+ * Device Access Service
764
+ * Handles device access control and management
765
+ */
766
+
767
+ declare class DeviceAccessService {
768
+ private apiClient;
769
+ constructor(apiClient: ApiClient);
770
+ /**
771
+ * Get all devices
772
+ */
773
+ getDevices(params?: {
774
+ page?: number;
775
+ per_page?: number;
776
+ }): Promise<BaseResponse<Device[]>>;
777
+ /**
778
+ * Get all QR devices
779
+ */
780
+ getQRDevices(params?: {
781
+ page?: number;
782
+ per_page?: number;
783
+ }): Promise<BaseResponse<QrDevice[]>>;
784
+ /**
785
+ * Get all QR devices with pagination support
786
+ */
787
+ getAllQRDevices(): Promise<QrDevice[]>;
788
+ /**
789
+ * Get accessible QR codes for current user
790
+ */
791
+ getAccessibleQRs(): Promise<BaseResponse<QrAccessResponse>>;
792
+ /**
793
+ * Get user devices
794
+ */
795
+ getUserDevices(request: DeviceAccessRequest): Promise<BaseResponse<Device[]>>;
796
+ /**
797
+ * Get device by ID
798
+ */
799
+ getDeviceById(deviceId: string): Promise<BaseResponse<Device>>;
800
+ /**
801
+ * Check if user has access to a device
802
+ */
803
+ checkDeviceAccess(deviceId: string): Promise<boolean>;
804
+ /**
805
+ * Find QR device by QR code ID
806
+ */
807
+ findDeviceByQRCode(qrCodeId: string): Promise<QrDevice | undefined>;
808
+ /**
809
+ * Find QR device by NFC code
810
+ */
811
+ findDeviceByNFCCode(nfcCode: string): Promise<QrDevice | undefined>;
812
+ }
813
+
814
+ /**
815
+ * Location Service
816
+ * Handles location verification and logging
817
+ */
818
+
819
+ declare class LocationService {
820
+ private apiClient;
821
+ constructor(apiClient: ApiClient);
822
+ /**
823
+ * Log location verification
824
+ */
825
+ logLocationVerification(log: LocationVerificationLog): Promise<BaseResponse>;
826
+ /**
827
+ * Create location verification log for QR scan
828
+ */
829
+ logQRScan(params: {
830
+ mobileLocation: {
831
+ latitude: number;
832
+ longitude: number;
833
+ accuracy?: number;
834
+ altitude?: number;
835
+ };
836
+ qrLocation?: {
837
+ latitude: number;
838
+ longitude: number;
839
+ };
840
+ currentScreen: string;
841
+ qrCode: string;
842
+ errorCode: string;
843
+ message: string;
844
+ distance?: number;
845
+ deviceRange?: number;
846
+ additionalInfo?: string;
847
+ customData?: Record<string, unknown>;
848
+ }): Promise<BaseResponse>;
849
+ /**
850
+ * Create location verification log for NFC scan
851
+ */
852
+ logNFCScan(params: {
853
+ mobileLocation: {
854
+ latitude: number;
855
+ longitude: number;
856
+ accuracy?: number;
857
+ altitude?: number;
858
+ };
859
+ nfcLocation?: {
860
+ latitude: number;
861
+ longitude: number;
862
+ };
863
+ currentScreen: string;
864
+ nfcCode: string;
865
+ errorCode: string;
866
+ message: string;
867
+ distance?: number;
868
+ deviceRange?: number;
869
+ additionalInfo?: string;
870
+ customData?: Record<string, unknown>;
871
+ }): Promise<BaseResponse>;
872
+ /**
873
+ * Create location verification log for check-in
874
+ */
875
+ logCheckIn(params: {
876
+ mobileLocation: {
877
+ latitude: number;
878
+ longitude: number;
879
+ accuracy?: number;
880
+ altitude?: number;
881
+ };
882
+ branchLocation?: {
883
+ latitude: number;
884
+ longitude: number;
885
+ };
886
+ currentScreen: string;
887
+ errorCode: string;
888
+ message: string;
889
+ distance?: number;
890
+ additionalInfo?: string;
891
+ customData?: Record<string, unknown>;
892
+ }): Promise<BaseResponse>;
893
+ }
894
+
895
+ /**
896
+ * Location utility functions
897
+ */
898
+
899
+ /**
900
+ * Calculate distance between two coordinates using Haversine formula
901
+ * @param lat1 - Latitude of first point
902
+ * @param lon1 - Longitude of first point
903
+ * @param lat2 - Latitude of second point
904
+ * @param lon2 - Longitude of second point
905
+ * @returns Distance in meters
906
+ */
907
+ declare function calculateDistance(lat1: number, lon1: number, lat2: number, lon2: number): number;
908
+ /**
909
+ * Check if user is within allowed range of a location
910
+ * @param targetLat - Target location latitude
911
+ * @param targetLon - Target location longitude
912
+ * @param allowedRange - Allowed range in meters
913
+ * @param userPosition - User's current position
914
+ * @returns Object with ok status and distance
915
+ */
916
+ declare function checkOnLocation(targetLat: number, targetLon: number, allowedRange: number, userPosition?: Coordinates): {
917
+ ok: boolean;
918
+ distance?: number;
919
+ };
920
+ /**
921
+ * Validate coordinates
922
+ * @param coords - Coordinates to validate
923
+ * @returns true if coordinates are valid
924
+ */
925
+ declare function validateCoordinates(coords?: Coordinates): boolean;
926
+
927
+ /**
928
+ * Validation utility functions
929
+ */
930
+ /**
931
+ * Check if a code was recently read (within 15 seconds)
932
+ * @param code - Code to check
933
+ * @returns true if this is a new read, false if repetitive
934
+ */
935
+ declare function checkRepetitiveRead(code: string): boolean;
936
+ /**
937
+ * Clear all read records
938
+ */
939
+ declare function clearReadRecords(): void;
940
+ /**
941
+ * Validate QR code format
942
+ * @param code - QR code to validate
943
+ * @returns true if valid
944
+ */
945
+ declare function validateQRCode(code: string): boolean;
946
+ /**
947
+ * Validate NFC code format
948
+ * @param code - NFC code to validate
949
+ * @returns true if valid
950
+ */
951
+ declare function validateNFCCode(code: string): boolean;
952
+ /**
953
+ * Validate device ID format (UUID)
954
+ * @param id - Device ID to validate
955
+ * @returns true if valid UUID
956
+ */
957
+ declare function validateDeviceId(id: string): boolean;
958
+
959
+ /**
960
+ * Date utility functions
961
+ */
962
+ /**
963
+ * Format date to ISO string
964
+ * @param date - Date to format
965
+ * @returns ISO string
966
+ */
967
+ declare function formatISO(date?: Date): string;
968
+ /**
969
+ * Format date for API (YYYY-MM-DD)
970
+ * @param date - Date to format
971
+ * @returns Formatted date string
972
+ */
973
+ declare function formatDate(date?: Date): string;
974
+ /**
975
+ * Format time for API (HH:mm)
976
+ * @param date - Date to format
977
+ * @returns Formatted time string
978
+ */
979
+ declare function formatTime(date?: Date): string;
980
+ /**
981
+ * Format datetime for API (YYYY-MM-DD HH:mm:ss)
982
+ * @param date - Date to format
983
+ * @returns Formatted datetime string
984
+ */
985
+ declare function formatDateTime(date?: Date): string;
986
+ /**
987
+ * Parse ISO date string to Date object
988
+ * @param isoString - ISO date string
989
+ * @returns Date object
990
+ */
991
+ declare function parseISO(isoString: string): Date;
4
992
 
5
993
  /**
6
994
  * Passgage Access Provider
@@ -145,82 +1133,112 @@ interface UsePassgageAuthReturn {
145
1133
  declare function usePassgageAuth(options?: UsePassgageAuthOptions): UsePassgageAuthReturn;
146
1134
 
147
1135
  /**
148
- * useQRScanner hook
1136
+ * usePassgageQRScanner hook
149
1137
  * QR code scanning with validation
150
1138
  */
151
1139
 
152
- interface UseQRScannerOptions {
1140
+ interface UsePassgageQRScannerOptions {
153
1141
  onSuccess?: (entrance?: Entrance) => void;
154
1142
  onError?: (error: Error) => void;
155
1143
  skipLocationCheck?: boolean;
156
1144
  skipRepetitiveCheck?: boolean;
157
1145
  }
158
- interface UseQRScannerReturn {
1146
+ interface UsePassgageQRScannerReturn {
159
1147
  scan: (qrCode: string, device?: QrDevice) => Promise<void>;
160
1148
  isLoading: boolean;
161
1149
  error: Error | null;
162
1150
  }
163
- declare function useQRScanner(options?: UseQRScannerOptions): UseQRScannerReturn;
1151
+ declare function usePassgageQRScanner(options?: UsePassgageQRScannerOptions): UsePassgageQRScannerReturn;
164
1152
 
165
1153
  /**
166
- * useNFCScanner hook
1154
+ * usePassgageNFCScanner hook
167
1155
  * NFC card scanning with validation
168
1156
  */
169
1157
 
170
- interface UseNFCScannerOptions {
1158
+ interface UsePassgageNFCScannerOptions {
171
1159
  onSuccess?: (entrance?: Entrance) => void;
172
1160
  onError?: (error: Error) => void;
173
1161
  skipLocationCheck?: boolean;
174
1162
  skipRepetitiveCheck?: boolean;
175
1163
  autoStart?: boolean;
176
1164
  }
177
- interface UseNFCScannerReturn {
1165
+ interface UsePassgageNFCScannerReturn {
178
1166
  startScanning: () => Promise<void>;
179
1167
  stopScanning: () => Promise<void>;
180
1168
  isScanning: boolean;
181
1169
  error: Error | null;
182
1170
  }
183
- declare function useNFCScanner(options?: UseNFCScannerOptions): UseNFCScannerReturn;
1171
+ declare function usePassgageNFCScanner(options?: UsePassgageNFCScannerOptions): UsePassgageNFCScannerReturn;
184
1172
 
185
1173
  /**
186
- * useCheckIn hook
1174
+ * usePassgageCheckIn hook
187
1175
  * GPS-based check-in to nearby branches
188
1176
  */
189
1177
 
190
- interface UseCheckInOptions {
1178
+ interface UsePassgageCheckInOptions {
191
1179
  radius?: number;
192
- autoFetch?: boolean;
193
1180
  }
194
- interface CheckInParams {
1181
+ interface CheckInEntryParams {
195
1182
  branchId: string;
196
- entranceType: EntranceType;
1183
+ userId: string;
1184
+ }
1185
+ interface CheckInExitParams {
1186
+ branchId: string;
1187
+ userId: string;
1188
+ }
1189
+ interface GetNearbyBranchesParams {
1190
+ radius?: number;
197
1191
  }
198
- interface UseCheckInReturn {
199
- nearbyBranches: Branch[];
200
- fetchNearbyBranches: () => Promise<void>;
201
- checkIn: (params: CheckInParams) => Promise<Entrance | undefined>;
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
+ }>;
202
1208
  isLoading: boolean;
203
1209
  error: Error | null;
204
1210
  }
205
- declare function useCheckIn(options?: UseCheckInOptions): UseCheckInReturn;
1211
+ declare function usePassgageCheckIn(options?: UsePassgageCheckInOptions): UsePassgageCheckInReturn;
206
1212
 
207
1213
  /**
208
- * useRemoteWork hook
1214
+ * usePassgageRemoteWork hook
209
1215
  * Remote work entry/exit logging
210
1216
  */
211
-
212
- interface RemoteWorkOptions {
1217
+ interface RemoteWorkEntryParams {
1218
+ userId: string;
1219
+ description?: string;
213
1220
  timestamp?: Date | string;
1221
+ }
1222
+ interface RemoteWorkExitParams {
1223
+ userId: string;
214
1224
  description?: string;
1225
+ timestamp?: Date | string;
215
1226
  }
216
- interface UseRemoteWorkReturn {
217
- logEntry: (options?: RemoteWorkOptions) => Promise<Entrance | undefined>;
218
- logExit: (options?: RemoteWorkOptions) => Promise<Entrance | undefined>;
219
- logRemoteWork: (entranceType: EntranceType, options?: RemoteWorkOptions) => Promise<Entrance | undefined>;
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
+ }>;
220
1238
  isLoading: boolean;
221
1239
  error: Error | null;
222
1240
  }
223
- declare function useRemoteWork(): UseRemoteWorkReturn;
1241
+ declare function usePassgageRemoteWork(): UsePassgageRemoteWorkReturn;
224
1242
 
225
1243
  /**
226
1244
  * useLocation hook
@@ -243,9 +1261,9 @@ declare function useLocation(options?: UseLocationOptions): UseLocationReturn;
243
1261
 
244
1262
  /**
245
1263
  * Passgage Access SDK - React Native Package
246
- * React Native wrapper with components and hooks
1264
+ * Complete SDK with core functionality and React Native integration
247
1265
  */
248
1266
 
249
- declare const SDK_VERSION = "1.0.0";
1267
+ declare const SDK_VERSION = "1.0.3";
250
1268
 
251
- export { type CheckInParams, type PassgageAccessConfig, type PassgageAccessContextValue, PassgageAccessProvider, type PassgageAccessProviderProps, type RemoteWorkOptions, SDK_VERSION, type UseCheckInOptions, type UseCheckInReturn, type UseLocationOptions, type UseLocationReturn, type UseNFCScannerOptions, type UseNFCScannerReturn, type UsePassgageAuthOptions, type UsePassgageAuthReturn, type UseQRScannerOptions, type UseQRScannerReturn, type UseRemoteWorkReturn, useCheckIn, useLocation, useNFCScanner, usePassgageAccess, usePassgageAuth, useQRScanner, useRemoteWork };
1269
+ export { type APIError, ApiClient, type ApiClientConfig, AuthService, type AuthState, type AuthTokens, type BaseResponse, type Branch, type CheckInEntryParams, type CheckInExitParams, type CheckInOptions, type CheckInResult, CheckInService, type CompanyInfo, type Coordinates, type CreateEntranceFromQRRequest, type CreateEntranceRequest, type Device, type DeviceAccessRequest, DeviceAccessService, DeviceDirection, DeviceUsage, endpoints as Endpoints, type Entrance, type EntranceQueryParams, EntranceType, type GetNearbyBranchesParams, LocationService, type LocationVerificationLog, type LoginCredentials, type LoginRequest, type LoginResponse, type LoginResult, NFCAccessService, type NFCValidationOptions, type NFCValidationResult, type NearbyBranchesRequest, type PaginationMeta, type PassgageAccessConfig, type PassgageAccessContextValue, PassgageAccessProvider, type PassgageAccessProviderProps, QRAccessService, type QRValidationOptions, type QRValidationResult, type QrAccessResponse, type QrDevice, type RefreshTokenRequest, type RefreshTokenResponse, type RefreshTokenResult, type RemoteWorkEntryOptions, type RemoteWorkEntryParams, type RemoteWorkExitParams, type RemoteWorkResult, RemoteWorkService, type RequestOptions, SDK_VERSION, type TokenInfo, type TokenStorage, type UseLocationOptions, type UseLocationReturn, type UsePassgageAuthOptions, type UsePassgageAuthReturn, type UsePassgageCheckInOptions, type UsePassgageCheckInReturn, type UsePassgageNFCScannerOptions, type UsePassgageNFCScannerReturn, type UsePassgageQRScannerOptions, type UsePassgageQRScannerReturn, type UsePassgageRemoteWorkReturn, type User, calculateDistance, checkOnLocation, checkRepetitiveRead, clearReadRecords, createApiClient, formatDate, formatDateTime, formatISO, formatTime, parseISO, useLocation, usePassgageAccess, usePassgageAuth, usePassgageCheckIn, usePassgageNFCScanner, usePassgageQRScanner, usePassgageRemoteWork, validateCoordinates, validateDeviceId, validateNFCCode, validateQRCode };