@savers_app/react-native-sdk 1.1.0
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/LICENSE +20 -0
- package/README.md +508 -0
- package/lib/module/@types/@react-native-async-storage__async-storage.d.js +2 -0
- package/lib/module/@types/@react-native-async-storage__async-storage.d.js.map +1 -0
- package/lib/module/@types/@react-native-community__geolocation.d.js +2 -0
- package/lib/module/@types/@react-native-community__geolocation.d.js.map +1 -0
- package/lib/module/@types/react-native-aes-gcm-crypto.d.js +2 -0
- package/lib/module/@types/react-native-aes-gcm-crypto.d.js.map +1 -0
- package/lib/module/@types/react-native-device-info.d.js +2 -0
- package/lib/module/@types/react-native-device-info.d.js.map +1 -0
- package/lib/module/core/runtime.js +67 -0
- package/lib/module/core/runtime.js.map +1 -0
- package/lib/module/data/models/apiResponse.js +19 -0
- package/lib/module/data/models/apiResponse.js.map +1 -0
- package/lib/module/data/models/onboardingModel.js +67 -0
- package/lib/module/data/models/onboardingModel.js.map +1 -0
- package/lib/module/data/network/apiClient.js +109 -0
- package/lib/module/data/network/apiClient.js.map +1 -0
- package/lib/module/data/network/apiEndpoints.js +6 -0
- package/lib/module/data/network/apiEndpoints.js.map +1 -0
- package/lib/module/data/network/apiExceptionHandler.js +16 -0
- package/lib/module/data/network/apiExceptionHandler.js.map +1 -0
- package/lib/module/data/network/apiRepository.js +70 -0
- package/lib/module/data/network/apiRepository.js.map +1 -0
- package/lib/module/data/network/apiService.js +66 -0
- package/lib/module/data/network/apiService.js.map +1 -0
- package/lib/module/data/network/dataTypeUtils.js +77 -0
- package/lib/module/data/network/dataTypeUtils.js.map +1 -0
- package/lib/module/data/network/interceptors/authInterceptor.js +69 -0
- package/lib/module/data/network/interceptors/authInterceptor.js.map +1 -0
- package/lib/module/data/network/interceptors/errorInterceptor.js +15 -0
- package/lib/module/data/network/interceptors/errorInterceptor.js.map +1 -0
- package/lib/module/data/network/interceptors/loggingInterceptor.js +17 -0
- package/lib/module/data/network/interceptors/loggingInterceptor.js.map +1 -0
- package/lib/module/data/network/interceptors/networkInterceptor.js +22 -0
- package/lib/module/data/network/interceptors/networkInterceptor.js.map +1 -0
- package/lib/module/data/network/interceptors/retryInterceptor.js +22 -0
- package/lib/module/data/network/interceptors/retryInterceptor.js.map +1 -0
- package/lib/module/data/storage/asyncStorageManager.js +50 -0
- package/lib/module/data/storage/asyncStorageManager.js.map +1 -0
- package/lib/module/data/storage/deviceIdManager.js +45 -0
- package/lib/module/data/storage/deviceIdManager.js.map +1 -0
- package/lib/module/data/storage/keysManager.js +70 -0
- package/lib/module/data/storage/keysManager.js.map +1 -0
- package/lib/module/data/storage/locationManager.js +30 -0
- package/lib/module/data/storage/locationManager.js.map +1 -0
- package/lib/module/data/storage/sessionManager.js +12 -0
- package/lib/module/data/storage/sessionManager.js.map +1 -0
- package/lib/module/data/storage/storageKeys.js +7 -0
- package/lib/module/data/storage/storageKeys.js.map +1 -0
- package/lib/module/data/storage/storageManager.js +76 -0
- package/lib/module/data/storage/storageManager.js.map +1 -0
- package/lib/module/index.js +20 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/services/device/location.js +47 -0
- package/lib/module/services/device/location.js.map +1 -0
- package/lib/module/services/navigation/dialPad.js +29 -0
- package/lib/module/services/navigation/dialPad.js.map +1 -0
- package/lib/module/services/navigation/goBackNavigation.js +22 -0
- package/lib/module/services/navigation/goBackNavigation.js.map +1 -0
- package/lib/module/services/navigation/openBrowser.js +8 -0
- package/lib/module/services/navigation/openBrowser.js.map +1 -0
- package/lib/module/services/navigation/openMap.js +26 -0
- package/lib/module/services/navigation/openMap.js.map +1 -0
- package/lib/module/services/permissions/permissionManager.js +28 -0
- package/lib/module/services/permissions/permissionManager.js.map +1 -0
- package/lib/module/services/url/urlGenerator.js +90 -0
- package/lib/module/services/url/urlGenerator.js.map +1 -0
- package/lib/module/services/webview/messageHandler.js +69 -0
- package/lib/module/services/webview/messageHandler.js.map +1 -0
- package/lib/module/utils/dependencyManager.js +51 -0
- package/lib/module/utils/dependencyManager.js.map +1 -0
- package/lib/module/utils/encryption.js +43 -0
- package/lib/module/utils/encryption.js.map +1 -0
- package/lib/module/utils/errors.js +9 -0
- package/lib/module/utils/errors.js.map +1 -0
- package/lib/module/utils/logger.js +14 -0
- package/lib/module/utils/logger.js.map +1 -0
- package/lib/module/utils/platformManager.js +14 -0
- package/lib/module/utils/platformManager.js.map +1 -0
- package/lib/module/utils/validator.js +26 -0
- package/lib/module/utils/validator.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/core/runtime.d.ts +10 -0
- package/lib/typescript/src/core/runtime.d.ts.map +1 -0
- package/lib/typescript/src/data/models/apiResponse.d.ts +9 -0
- package/lib/typescript/src/data/models/apiResponse.d.ts.map +1 -0
- package/lib/typescript/src/data/models/onboardingModel.d.ts +24 -0
- package/lib/typescript/src/data/models/onboardingModel.d.ts.map +1 -0
- package/lib/typescript/src/data/network/apiClient.d.ts +17 -0
- package/lib/typescript/src/data/network/apiClient.d.ts.map +1 -0
- package/lib/typescript/src/data/network/apiEndpoints.d.ts +4 -0
- package/lib/typescript/src/data/network/apiEndpoints.d.ts.map +1 -0
- package/lib/typescript/src/data/network/apiExceptionHandler.d.ts +3 -0
- package/lib/typescript/src/data/network/apiExceptionHandler.d.ts.map +1 -0
- package/lib/typescript/src/data/network/apiRepository.d.ts +19 -0
- package/lib/typescript/src/data/network/apiRepository.d.ts.map +1 -0
- package/lib/typescript/src/data/network/apiService.d.ts +19 -0
- package/lib/typescript/src/data/network/apiService.d.ts.map +1 -0
- package/lib/typescript/src/data/network/dataTypeUtils.d.ts +10 -0
- package/lib/typescript/src/data/network/dataTypeUtils.d.ts.map +1 -0
- package/lib/typescript/src/data/network/interceptors/authInterceptor.d.ts +13 -0
- package/lib/typescript/src/data/network/interceptors/authInterceptor.d.ts.map +1 -0
- package/lib/typescript/src/data/network/interceptors/errorInterceptor.d.ts +4 -0
- package/lib/typescript/src/data/network/interceptors/errorInterceptor.d.ts.map +1 -0
- package/lib/typescript/src/data/network/interceptors/loggingInterceptor.d.ts +5 -0
- package/lib/typescript/src/data/network/interceptors/loggingInterceptor.d.ts.map +1 -0
- package/lib/typescript/src/data/network/interceptors/networkInterceptor.d.ts +4 -0
- package/lib/typescript/src/data/network/interceptors/networkInterceptor.d.ts.map +1 -0
- package/lib/typescript/src/data/network/interceptors/retryInterceptor.d.ts +7 -0
- package/lib/typescript/src/data/network/interceptors/retryInterceptor.d.ts.map +1 -0
- package/lib/typescript/src/data/storage/asyncStorageManager.d.ts +13 -0
- package/lib/typescript/src/data/storage/asyncStorageManager.d.ts.map +1 -0
- package/lib/typescript/src/data/storage/deviceIdManager.d.ts +2 -0
- package/lib/typescript/src/data/storage/deviceIdManager.d.ts.map +1 -0
- package/lib/typescript/src/data/storage/keysManager.d.ts +29 -0
- package/lib/typescript/src/data/storage/keysManager.d.ts.map +1 -0
- package/lib/typescript/src/data/storage/locationManager.d.ts +21 -0
- package/lib/typescript/src/data/storage/locationManager.d.ts.map +1 -0
- package/lib/typescript/src/data/storage/sessionManager.d.ts +3 -0
- package/lib/typescript/src/data/storage/sessionManager.d.ts.map +1 -0
- package/lib/typescript/src/data/storage/storageKeys.d.ts +5 -0
- package/lib/typescript/src/data/storage/storageKeys.d.ts.map +1 -0
- package/lib/typescript/src/data/storage/storageManager.d.ts +16 -0
- package/lib/typescript/src/data/storage/storageManager.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +18 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/services/device/location.d.ts +8 -0
- package/lib/typescript/src/services/device/location.d.ts.map +1 -0
- package/lib/typescript/src/services/navigation/dialPad.d.ts +3 -0
- package/lib/typescript/src/services/navigation/dialPad.d.ts.map +1 -0
- package/lib/typescript/src/services/navigation/goBackNavigation.d.ts +4 -0
- package/lib/typescript/src/services/navigation/goBackNavigation.d.ts.map +1 -0
- package/lib/typescript/src/services/navigation/openBrowser.d.ts +2 -0
- package/lib/typescript/src/services/navigation/openBrowser.d.ts.map +1 -0
- package/lib/typescript/src/services/navigation/openMap.d.ts +2 -0
- package/lib/typescript/src/services/navigation/openMap.d.ts.map +1 -0
- package/lib/typescript/src/services/permissions/permissionManager.d.ts +4 -0
- package/lib/typescript/src/services/permissions/permissionManager.d.ts.map +1 -0
- package/lib/typescript/src/services/url/urlGenerator.d.ts +43 -0
- package/lib/typescript/src/services/url/urlGenerator.d.ts.map +1 -0
- package/lib/typescript/src/services/webview/messageHandler.d.ts +2 -0
- package/lib/typescript/src/services/webview/messageHandler.d.ts.map +1 -0
- package/lib/typescript/src/utils/dependencyManager.d.ts +31 -0
- package/lib/typescript/src/utils/dependencyManager.d.ts.map +1 -0
- package/lib/typescript/src/utils/encryption.d.ts +5 -0
- package/lib/typescript/src/utils/encryption.d.ts.map +1 -0
- package/lib/typescript/src/utils/errors.d.ts +4 -0
- package/lib/typescript/src/utils/errors.d.ts.map +1 -0
- package/lib/typescript/src/utils/logger.d.ts +6 -0
- package/lib/typescript/src/utils/logger.d.ts.map +1 -0
- package/lib/typescript/src/utils/platformManager.d.ts +4 -0
- package/lib/typescript/src/utils/platformManager.d.ts.map +1 -0
- package/lib/typescript/src/utils/validator.d.ts +4 -0
- package/lib/typescript/src/utils/validator.d.ts.map +1 -0
- package/package.json +176 -0
- package/src/@types/@react-native-async-storage__async-storage.d.ts +7 -0
- package/src/@types/@react-native-community__geolocation.d.ts +18 -0
- package/src/@types/react-native-aes-gcm-crypto.d.ts +22 -0
- package/src/@types/react-native-device-info.d.ts +3 -0
- package/src/core/runtime.ts +80 -0
- package/src/data/models/apiResponse.ts +28 -0
- package/src/data/models/onboardingModel.ts +99 -0
- package/src/data/network/apiClient.ts +148 -0
- package/src/data/network/apiEndpoints.ts +3 -0
- package/src/data/network/apiExceptionHandler.ts +16 -0
- package/src/data/network/apiRepository.ts +106 -0
- package/src/data/network/apiService.ts +72 -0
- package/src/data/network/dataTypeUtils.ts +78 -0
- package/src/data/network/interceptors/authInterceptor.ts +77 -0
- package/src/data/network/interceptors/errorInterceptor.ts +13 -0
- package/src/data/network/interceptors/loggingInterceptor.ts +16 -0
- package/src/data/network/interceptors/networkInterceptor.ts +20 -0
- package/src/data/network/interceptors/retryInterceptor.ts +24 -0
- package/src/data/storage/asyncStorageManager.ts +56 -0
- package/src/data/storage/deviceIdManager.ts +46 -0
- package/src/data/storage/keysManager.ts +89 -0
- package/src/data/storage/locationManager.ts +39 -0
- package/src/data/storage/sessionManager.ts +11 -0
- package/src/data/storage/storageKeys.ts +4 -0
- package/src/data/storage/storageManager.ts +83 -0
- package/src/index.tsx +17 -0
- package/src/services/device/location.ts +51 -0
- package/src/services/navigation/dialPad.ts +39 -0
- package/src/services/navigation/goBackNavigation.ts +22 -0
- package/src/services/navigation/openBrowser.ts +6 -0
- package/src/services/navigation/openMap.ts +39 -0
- package/src/services/permissions/permissionManager.ts +33 -0
- package/src/services/url/urlGenerator.ts +132 -0
- package/src/services/webview/messageHandler.ts +48 -0
- package/src/utils/dependencyManager.ts +82 -0
- package/src/utils/encryption.ts +58 -0
- package/src/utils/errors.ts +6 -0
- package/src/utils/logger.ts +11 -0
- package/src/utils/platformManager.ts +14 -0
- package/src/utils/validator.ts +29 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Faisal Wahab
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
# Savers React Native SDK
|
|
2
|
+
|
|
3
|
+
React Native SDK that bridges host app features like maps, dialer, browser, device info, session storage, URL generation, navigation, and WebView event handling. It also includes a robust networking layer with interceptors.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
- Open native maps by coordinates with graceful browser fallback
|
|
7
|
+
- Dial pad invocation with optional number and direct call helper
|
|
8
|
+
- External browser navigation from the host app or from web content
|
|
9
|
+
- Close current screen via global navigationRef (React Navigation) using **END_SESSION**
|
|
10
|
+
- Device ID retrieval (via `react-native-device-info`)
|
|
11
|
+
- Optional device location retrieval and URL payload enrichment
|
|
12
|
+
- Session and keys management (API key, encryption key, program ref code, auth mode)
|
|
13
|
+
- URL generator to compose signed and encrypted Savers mobile URLs
|
|
14
|
+
- AES-GCM encryption for URL payload (AES-256-GCM)
|
|
15
|
+
- WebView message handler to trigger native actions from web (maps, dialer, browser, session id, end session)
|
|
16
|
+
- Configurable networking layer with interceptors (logging, network connectivity, auth, retry, error formatting)
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
- Install the library:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install @saversapp/react-native-sdk
|
|
23
|
+
# or
|
|
24
|
+
yarn add @saversapp/react-native-sdk
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
- Install required peer dependencies:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install @react-native-async-storage/async-storage \
|
|
31
|
+
@react-native-community/geolocation \
|
|
32
|
+
@react-native-community/netinfo \
|
|
33
|
+
@react-navigation/native \
|
|
34
|
+
react-native-device-info \
|
|
35
|
+
react-native-aes-gcm-crypto
|
|
36
|
+
# or
|
|
37
|
+
yarn add @react-native-async-storage/async-storage \
|
|
38
|
+
@react-native-community/geolocation \
|
|
39
|
+
@react-native-community/netinfo \
|
|
40
|
+
@react-navigation/native \
|
|
41
|
+
react-native-device-info \
|
|
42
|
+
react-native-aes-gcm-crypto
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
- Optional (for WebView-based messaging):
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install react-native-webview
|
|
49
|
+
# or
|
|
50
|
+
yarn add react-native-webview
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## iOS Setup
|
|
54
|
+
- Add dialer schemes to Info.plist:
|
|
55
|
+
|
|
56
|
+
```xml
|
|
57
|
+
<key>LSApplicationQueriesSchemes</key>
|
|
58
|
+
<array>
|
|
59
|
+
<string>tel</string>
|
|
60
|
+
<string>telprompt</string>
|
|
61
|
+
</array>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
- Permissions (add keys and descriptions in Info.plist):
|
|
65
|
+
- NSLocationWhenInUseUsageDescription
|
|
66
|
+
|
|
67
|
+
Example:
|
|
68
|
+
|
|
69
|
+
```xml
|
|
70
|
+
<key>NSLocationWhenInUseUsageDescription</key>
|
|
71
|
+
<string>Location access is required to provide location-based features.</string>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Ensure native pods are installed and linked for the peer dependencies.
|
|
75
|
+
|
|
76
|
+
## Android Setup
|
|
77
|
+
- Add permissions in AndroidManifest.xml:
|
|
78
|
+
|
|
79
|
+
```xml
|
|
80
|
+
<uses-permission android:name="android.permission.INTERNET" />
|
|
81
|
+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
|
82
|
+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
|
83
|
+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Link and configure the peer dependencies according to their documentation.
|
|
87
|
+
|
|
88
|
+
Requirements for AES-GCM:
|
|
89
|
+
- Android minSdkVersion must be 26 or higher (example app is configured to 26).
|
|
90
|
+
- iOS 13 or higher.
|
|
91
|
+
|
|
92
|
+
## Quick Start
|
|
93
|
+
|
|
94
|
+
### 1. Initialize the SDK
|
|
95
|
+
|
|
96
|
+
Before using any other APIs, initialize the SDK with keys you receive from Savers:
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
import { SaversAppSDK } from '@saversapp/react-native-sdk';
|
|
100
|
+
|
|
101
|
+
SaversAppSDK.initialized({
|
|
102
|
+
apiKey: 'YOUR_API_KEY',
|
|
103
|
+
encryptionKey: 'BASE64_256_BIT_ENCRYPTION_KEY',
|
|
104
|
+
pRefCode: 'YOUR_P_REF_CODE',
|
|
105
|
+
authMode: 'PHONE', // or 'EMAIL' | 'USERNAME'
|
|
106
|
+
});
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The SDK stores these values in memory (not in AsyncStorage), via an internal `keysManager`. You can later read them using:
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
import {
|
|
113
|
+
getApiKey,
|
|
114
|
+
getEncryptionKey,
|
|
115
|
+
getPRefCode,
|
|
116
|
+
getAuthMode,
|
|
117
|
+
} from '@saversapp/react-native-sdk';
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### 2. Generate URL
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
import { generateUrl } from '@saversapp/react-native-sdk';
|
|
124
|
+
|
|
125
|
+
const url = await generateUrl({
|
|
126
|
+
// Top-level UrlInput fields
|
|
127
|
+
authType: 'PHONE', // optional, defaults to 'PHONE' | also 'EMAIL' | 'USERNAME'
|
|
128
|
+
profile: {
|
|
129
|
+
// Mandatory fields
|
|
130
|
+
userId: 'USER_ID',
|
|
131
|
+
email: 'jane@example.com',
|
|
132
|
+
firstname: 'Jane',
|
|
133
|
+
lastname: 'Doe',
|
|
134
|
+
|
|
135
|
+
// Conditionally mandatory
|
|
136
|
+
phone: '+15555550100', // required when authType === 'PHONE'
|
|
137
|
+
username: 'jane.doe', // required when authType === 'USERNAME'
|
|
138
|
+
|
|
139
|
+
// Optional profile flags
|
|
140
|
+
pv: '1', // optional: '0' | '1'
|
|
141
|
+
ev: '1', // optional: '0' | '1'
|
|
142
|
+
|
|
143
|
+
// Other optional profile fields
|
|
144
|
+
dob: '1990-01-01',
|
|
145
|
+
city: 'San Francisco',
|
|
146
|
+
zipcode: '94103',
|
|
147
|
+
referrer_user_id: 'REFERRER_ID',
|
|
148
|
+
},
|
|
149
|
+
screen: {
|
|
150
|
+
// Optional screen; defaults to { name: 'Explore' } when omitted
|
|
151
|
+
name: 'Explore',
|
|
152
|
+
|
|
153
|
+
// attributes are optional in general, but mandatory when name === 'OfrDetails'
|
|
154
|
+
attributes: [{ key: 'offerId', value: '123' }],
|
|
155
|
+
},
|
|
156
|
+
// sessionId is optional; when omitted, the SDK uses its stored session id
|
|
157
|
+
// deviceInfo is optional; the SDK builds it internally using device id (and optional coordinates)
|
|
158
|
+
});
|
|
159
|
+
// returns https://m.saversapp.com/?pRefCode=...&qP=...
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Profile requirements:
|
|
163
|
+
- `userId` and `email` are mandatory
|
|
164
|
+
- `pv` and `ev` are optional (`'0'` or `'1'`)
|
|
165
|
+
- `phone` is mandatory when `authType` is `'PHONE'`
|
|
166
|
+
- `username` is mandatory when `authType` is `'USERNAME'`
|
|
167
|
+
|
|
168
|
+
Screen requirements:
|
|
169
|
+
- `screen.name` is optional, defaults to `'Explore'`
|
|
170
|
+
- When `screen.name === 'OfrDetails'`, `screen.attributes` **must** be provided and non-empty
|
|
171
|
+
|
|
172
|
+
Location / coordinates:
|
|
173
|
+
- If you use the location manager (see **Location & Coordinates** below) and set coordinates,
|
|
174
|
+
they are automatically included in the encrypted payload as `deviceInfo.location`.
|
|
175
|
+
- If no coordinates are set, the URL is still generated, and `location` is simply omitted.
|
|
176
|
+
|
|
177
|
+
Notes:
|
|
178
|
+
- The SDK requires `encryptionKey` and `pRefCode` to be initialized via `SaversAppSDK.initialized`; `generateUrl` will throw if either is missing.
|
|
179
|
+
- The `qP` payload is encrypted using AES-256-GCM. The encryption key must be a base64-encoded 32-byte (256-bit) value.
|
|
180
|
+
- The encrypted payload combines `iv`, `content`, and `tag` as `iv:content:tag` internally before being base64-encoded.
|
|
181
|
+
|
|
182
|
+
## Navigation (End Session)
|
|
183
|
+
|
|
184
|
+
The SDK can close the current screen without knowing the host app's navigation structure using a global `navigationRef`. This is useful for flows initiated from web content or deep links that need to programmatically exit back to the host app.
|
|
185
|
+
|
|
186
|
+
One-time host app setup:
|
|
187
|
+
|
|
188
|
+
```tsx
|
|
189
|
+
import { NavigationContainer } from '@react-navigation/native';
|
|
190
|
+
import { navigationRef } from '@saversapp/react-native-sdk';
|
|
191
|
+
|
|
192
|
+
export function App() {
|
|
193
|
+
return <NavigationContainer ref={navigationRef}>{/* ... */}</NavigationContainer>;
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
SDK API:
|
|
198
|
+
|
|
199
|
+
```ts
|
|
200
|
+
import { closeCurrentScreen, closeCurrentScreenSafe } from '@saversapp/react-native-sdk';
|
|
201
|
+
|
|
202
|
+
closeCurrentScreen(); // returns boolean
|
|
203
|
+
closeCurrentScreenSafe(); // Android-only fallback to exitApp if it can't goBack()
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## WebView Integration
|
|
207
|
+
|
|
208
|
+
Trigger native actions from web & bind `onMessage` to a `WebView`:
|
|
209
|
+
|
|
210
|
+
```ts
|
|
211
|
+
import { handleWebMessage } from '@saversapp/react-native-sdk';
|
|
212
|
+
import { WebView } from 'react-native-webview';
|
|
213
|
+
...
|
|
214
|
+
|
|
215
|
+
const onMessage = (e: any) => {
|
|
216
|
+
const raw = e?.nativeEvent?.data;
|
|
217
|
+
const postBack = (data: any) => {
|
|
218
|
+
// send data back to the webview as needed
|
|
219
|
+
};
|
|
220
|
+
handleWebMessage(raw, postBack);
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
<WebView
|
|
224
|
+
originWhitelist={['*']}
|
|
225
|
+
source={{ html }}
|
|
226
|
+
onMessage={onMessage}
|
|
227
|
+
/>;
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
Supported actions:
|
|
233
|
+
- `OPEN_MAP` `{ lat, lng, label }`
|
|
234
|
+
- `END_SESSION`
|
|
235
|
+
- `SHOW_DIAL_PAD` `{ number? }`
|
|
236
|
+
- `MERCHANT_PORTAL_REDIRECT` `{ url }`
|
|
237
|
+
- `SESSION_ID` `{ sessionId }`
|
|
238
|
+
|
|
239
|
+
Note: unified WebView helpers were removed. Use `handleWebMessage` directly with `react-native-webview`.
|
|
240
|
+
|
|
241
|
+
### Web Messaging (for Web Developers)
|
|
242
|
+
|
|
243
|
+
Your web page loaded in react-native-webview can trigger native features by posting a JSON message. Use:
|
|
244
|
+
|
|
245
|
+
```html
|
|
246
|
+
<script>
|
|
247
|
+
function sendNative(action, payload) {
|
|
248
|
+
const msg = JSON.stringify({ action, payload });
|
|
249
|
+
window.ReactNativeWebView?.postMessage(msg);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Examples:
|
|
253
|
+
// Open map
|
|
254
|
+
sendNative('OPEN_MAP', { lat: 37.7749, lng: -122.4194, label: 'San Francisco' });
|
|
255
|
+
|
|
256
|
+
// Dial pad
|
|
257
|
+
sendNative('SHOW_DIAL_PAD', { number: '+1234567890' });
|
|
258
|
+
|
|
259
|
+
// Open external browser
|
|
260
|
+
sendNative('MERCHANT_PORTAL_REDIRECT', { url: 'https://www.example.com' });
|
|
261
|
+
|
|
262
|
+
// Set session ID
|
|
263
|
+
sendNative('SESSION_ID', { sessionId: '123456789' });
|
|
264
|
+
|
|
265
|
+
// End session / close current screen (goBack if possible)
|
|
266
|
+
sendNative('END_SESSION');
|
|
267
|
+
|
|
268
|
+
// Receive postBack from native (optional)
|
|
269
|
+
document.addEventListener('message', function (e) {
|
|
270
|
+
try {
|
|
271
|
+
const data = JSON.parse(e.data);
|
|
272
|
+
console.log('Native postBack:', data);
|
|
273
|
+
// { ok: boolean, action: string, ...additional fields }
|
|
274
|
+
} catch (_) {}
|
|
275
|
+
});
|
|
276
|
+
</script>
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
Message schema:
|
|
280
|
+
- `action`: one of `OPEN_MAP`, `END_SESSION`, `SHOW_DIAL_PAD`, `MERCHANT_PORTAL_REDIRECT`, `SESSION_ID`
|
|
281
|
+
- `payload`: object with action-specific fields:
|
|
282
|
+
- `OPEN_MAP`: `{ lat: number, lng: number, label?: string }`
|
|
283
|
+
- `SHOW_DIAL_PAD`: `{ number?: string }`
|
|
284
|
+
- `MERCHANT_PORTAL_REDIRECT`: `{ url: string }`
|
|
285
|
+
- `SESSION_ID`: `{ sessionId: string }`
|
|
286
|
+
- `END_SESSION`: no payload required
|
|
287
|
+
|
|
288
|
+
## Device & Session Management
|
|
289
|
+
|
|
290
|
+
The SDK provides helpers for device id, session id, and keys:
|
|
291
|
+
|
|
292
|
+
```ts
|
|
293
|
+
import {
|
|
294
|
+
getDeviceId,
|
|
295
|
+
setSessionId,
|
|
296
|
+
getSessionId,
|
|
297
|
+
getApiKey,
|
|
298
|
+
getEncryptionKey,
|
|
299
|
+
getPRefCode,
|
|
300
|
+
getAuthMode,
|
|
301
|
+
} from '@saversapp/react-native-sdk';
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
- `getDeviceId()`: uses `react-native-device-info` to resolve a unique device id and caches it in memory and AsyncStorage.
|
|
305
|
+
- `setSessionId(sessionId)` / `getSessionId()`: store and retrieve a session identifier using AsyncStorage.
|
|
306
|
+
- `getApiKey()`, `getEncryptionKey()`, `getPRefCode()`, `getAuthMode()`: read values initialized via `SaversAppSDK.initialized`.
|
|
307
|
+
|
|
308
|
+
## Location & Coordinates
|
|
309
|
+
|
|
310
|
+
There are two ways to work with location:
|
|
311
|
+
|
|
312
|
+
1. **Device location service** (geolocation + permissions):
|
|
313
|
+
|
|
314
|
+
```ts
|
|
315
|
+
import { getDeviceLocation } from '@saversapp/react-native-sdk';
|
|
316
|
+
|
|
317
|
+
const loc = await getDeviceLocation();
|
|
318
|
+
// { lat, lng } or throws if unavailable / permission denied
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
This uses:
|
|
322
|
+
- `@react-native-community/geolocation`
|
|
323
|
+
- `ensureLocationPermission` (Android runtime permissions)
|
|
324
|
+
- `resolveNativeDependencies` to check if the native module is linked
|
|
325
|
+
|
|
326
|
+
2. **Manual coordinates for URL generation**:
|
|
327
|
+
|
|
328
|
+
```ts
|
|
329
|
+
import {
|
|
330
|
+
setLocationCoordinates,
|
|
331
|
+
getLocationCoordinates,
|
|
332
|
+
} from '@saversapp/react-native-sdk';
|
|
333
|
+
|
|
334
|
+
await setLocationCoordinates(37.7749, -122.4194);
|
|
335
|
+
const coords = await getLocationCoordinates(); // { lat, lng } | null
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
If coordinates are available, `generateUrl` automatically includes them in the encrypted payload as `deviceInfo.location`. If not, the URL is still generated without `location`.
|
|
339
|
+
|
|
340
|
+
## Maps, Dialer & Browser Helpers
|
|
341
|
+
|
|
342
|
+
```ts
|
|
343
|
+
import {
|
|
344
|
+
openMap,
|
|
345
|
+
openDialPad,
|
|
346
|
+
callPhone,
|
|
347
|
+
openBrowser,
|
|
348
|
+
} from '@saversapp/react-native-sdk';
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
- `openMap(lat, lng, label?)`: opens the native maps app if available, otherwise falls back to browser (Apple Maps / Google Maps).
|
|
352
|
+
- `openDialPad(number?)`: opens the dial pad; if a number is provided, it pre-fills the dialer.
|
|
353
|
+
- `callPhone(number)`: directly attempts to call the number; validates format and throws errors like `INVALID_PHONE_NUMBER` or `CALL_NOT_SUPPORTED`.
|
|
354
|
+
- `openBrowser(url)`: opens an external browser with the given URL.
|
|
355
|
+
|
|
356
|
+
## Networking (ApiService)
|
|
357
|
+
|
|
358
|
+
Use the `ApiService` to make network requests with unified error handling, caching, and interceptors.
|
|
359
|
+
|
|
360
|
+
### ApiService Overview
|
|
361
|
+
|
|
362
|
+
```ts
|
|
363
|
+
import { ApiService } from '@saversapp/react-native-sdk';
|
|
364
|
+
|
|
365
|
+
const apiService = new ApiService(); // defaults to production base URL
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
- `ApiService` uses:
|
|
369
|
+
- `ApiClient` (wraps `fetch` and applies interceptors)
|
|
370
|
+
- `ApiRepository` (adds caching strategies)
|
|
371
|
+
- `ApiEndpoints` (centralized endpoint paths)
|
|
372
|
+
- `ApiResponse<T>` model for response shape
|
|
373
|
+
|
|
374
|
+
### Onboarding Example
|
|
375
|
+
|
|
376
|
+
```ts
|
|
377
|
+
import { ApiService } from '@saversapp/react-native-sdk';
|
|
378
|
+
|
|
379
|
+
const apiService = new ApiService();
|
|
380
|
+
|
|
381
|
+
// Example: fetch onboarding data as an async generator
|
|
382
|
+
const fetchOnboarding = async () => {
|
|
383
|
+
try {
|
|
384
|
+
const generator = apiService.getOnBoarding();
|
|
385
|
+
for await (const response of generator) {
|
|
386
|
+
if (response.status) {
|
|
387
|
+
console.log('Data:', response.data);
|
|
388
|
+
} else {
|
|
389
|
+
console.error('Error:', response.message);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
} catch (error) {
|
|
393
|
+
console.error('Request failed:', error);
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
- Responses use the shape: `ApiResponse<T> = { data?: T | null; status?: boolean; message?: string; fromCache: boolean }`.
|
|
399
|
+
- `CacheStrategy` controls whether data comes from cache, network, or both.
|
|
400
|
+
|
|
401
|
+
Interceptors:
|
|
402
|
+
- `LoggingInterceptor`: logs requests and responses to the console.
|
|
403
|
+
- `NetworkInterceptor`: uses `@react-native-community/netinfo` to detect no-internet conditions and throws a unified error.
|
|
404
|
+
- `RetryInterceptor`: retries failed requests a configurable number of times.
|
|
405
|
+
- `ErrorInterceptor`: maps errors to user-friendly messages.
|
|
406
|
+
- `AuthInterceptor`: placeholder for attaching auth / user information to requests.
|
|
407
|
+
## Example App
|
|
408
|
+
|
|
409
|
+
This repository includes an example React Native app that demonstrates most of the SDK features end‑to‑end:
|
|
410
|
+
|
|
411
|
+
- SDK initialization (`SaversAppSDK.initialized`)
|
|
412
|
+
- Device id, keys, session id, and coordinates usage
|
|
413
|
+
- URL generation (`generateUrl`) and opening the resulting URL in a browser
|
|
414
|
+
- Navigation and end‑session flow via `navigationRef` and `END_SESSION`
|
|
415
|
+
- WebView actions (`OPEN_MAP`, `SHOW_DIAL_PAD`, `MERCHANT_PORTAL_REDIRECT`, `SESSION_ID`, `END_SESSION`)
|
|
416
|
+
- Networking with `ApiService.getOnBoarding()`
|
|
417
|
+
|
|
418
|
+
To run the example:
|
|
419
|
+
|
|
420
|
+
```bash
|
|
421
|
+
# Install dependencies (root + example workspace)
|
|
422
|
+
npm install
|
|
423
|
+
# or
|
|
424
|
+
yarn install
|
|
425
|
+
|
|
426
|
+
# Start the Metro bundler for the example app
|
|
427
|
+
yarn workspace @saversapp/react-native-sdk-example start
|
|
428
|
+
|
|
429
|
+
# Run the example app on a device / simulator (from the repo root)
|
|
430
|
+
yarn run:ios # uses scripts.run:ios from package.json
|
|
431
|
+
yarn run:android # uses scripts.run:android from package.json
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
## Development
|
|
435
|
+
|
|
436
|
+
Common scripts from the root library package (`package.json`):
|
|
437
|
+
|
|
438
|
+
```bash
|
|
439
|
+
# Lint, typecheck, test and build the library
|
|
440
|
+
npm run lint
|
|
441
|
+
npm run typecheck
|
|
442
|
+
npm run test
|
|
443
|
+
npm run prepare # builds the library via react-native-builder-bob
|
|
444
|
+
|
|
445
|
+
# or using yarn
|
|
446
|
+
yarn lint
|
|
447
|
+
yarn typecheck
|
|
448
|
+
yarn test
|
|
449
|
+
yarn prepare
|
|
450
|
+
|
|
451
|
+
# Helper scripts to run the example app from the root
|
|
452
|
+
yarn run:ios
|
|
453
|
+
yarn run:android
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
In the example app workspace (`@saversapp/react-native-sdk-example`), you can also run:
|
|
457
|
+
|
|
458
|
+
```bash
|
|
459
|
+
yarn --workspace @saversapp/react-native-sdk-example run lint
|
|
460
|
+
yarn --workspace @saversapp/react-native-sdk-example run test
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
## Publishing to npm
|
|
464
|
+
|
|
465
|
+
This package is configured to publish to the public npm registry and uses `release-it` for versioning and release automation (see `publishConfig` and `release-it` in `package.json`).
|
|
466
|
+
|
|
467
|
+
Basic flow to publish a new version:
|
|
468
|
+
|
|
469
|
+
```bash
|
|
470
|
+
# 1. Make sure you are logged in to npm
|
|
471
|
+
npm login
|
|
472
|
+
|
|
473
|
+
# 2. Ensure the code passes checks and is built
|
|
474
|
+
yarn lint
|
|
475
|
+
yarn typecheck
|
|
476
|
+
yarn test
|
|
477
|
+
yarn prepare
|
|
478
|
+
|
|
479
|
+
# 3. Run the release script from the repo root
|
|
480
|
+
# This will:
|
|
481
|
+
# - bump the version
|
|
482
|
+
# - create a git tag
|
|
483
|
+
# - publish to npm (using publishConfig.registry)
|
|
484
|
+
# - create a GitHub release
|
|
485
|
+
yarn release
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
If you prefer a fully manual publish flow, you can instead:
|
|
489
|
+
|
|
490
|
+
```bash
|
|
491
|
+
# Bump the version number in package.json (or use `npm version patch|minor|major`)
|
|
492
|
+
npm version patch
|
|
493
|
+
|
|
494
|
+
# Build the library
|
|
495
|
+
yarn prepare
|
|
496
|
+
|
|
497
|
+
# Publish to npm
|
|
498
|
+
npm publish
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
## Troubleshooting
|
|
502
|
+
- Ensure peer dependencies are installed and linked (AsyncStorage, Geolocation, NetInfo, DeviceInfo, WebView, React Navigation).
|
|
503
|
+
- On Android, grant runtime permissions for location when using geolocation.
|
|
504
|
+
- If `SaversAppSDK.initialized` logs missing modules, install the indicated packages.
|
|
505
|
+
- If AES‑GCM encryption fails, verify that `encryptionKey` is a base64‑encoded 32‑byte (256‑bit) value and that your Android/iOS versions meet the minimum requirements.
|
|
506
|
+
|
|
507
|
+
## License
|
|
508
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["@types/@react-native-async-storage__async-storage.d.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["@types/@react-native-community__geolocation.d.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["@types/react-native-aes-gcm-crypto.d.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["@types/react-native-device-info.d.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Utilities
|
|
4
|
+
import { logger } from "../utils/logger.js";
|
|
5
|
+
import { SDKRequirements } from "../utils/dependencyManager.js";
|
|
6
|
+
|
|
7
|
+
// Data / Storage
|
|
8
|
+
import { setApiKey, setEncryptionKey, setPRefCode, setAuthMode } from "../data/storage/keysManager.js";
|
|
9
|
+
import { getDeviceId } from "../data/storage/deviceIdManager.js";
|
|
10
|
+
|
|
11
|
+
// Services
|
|
12
|
+
// import { getDeviceLocation } from '../services/device/location';
|
|
13
|
+
|
|
14
|
+
export function initializeSDK(providedKeys) {
|
|
15
|
+
const keys = providedKeys;
|
|
16
|
+
const missing = [];
|
|
17
|
+
if (!keys.apiKey) missing.push('apiKey');
|
|
18
|
+
if (!keys.encryptionKey) missing.push('encryptionKey');
|
|
19
|
+
if (!keys.pRefCode) missing.push('pRefCode');
|
|
20
|
+
if (!keys.authMode) missing.push('authMode');
|
|
21
|
+
if (missing.length) {
|
|
22
|
+
const msg = `[SDK] Missing required keys: ${missing.join(', ')}`;
|
|
23
|
+
logger.warn(msg);
|
|
24
|
+
throw new Error(msg);
|
|
25
|
+
}
|
|
26
|
+
setApiKey(keys.apiKey);
|
|
27
|
+
setEncryptionKey(keys.encryptionKey);
|
|
28
|
+
setPRefCode(keys.pRefCode);
|
|
29
|
+
setAuthMode(keys.authMode);
|
|
30
|
+
getDeviceId().then(id => {
|
|
31
|
+
logger.info('[SDK] Device ID availability', {
|
|
32
|
+
deviceId: Boolean(id)
|
|
33
|
+
});
|
|
34
|
+
}).catch(() => {
|
|
35
|
+
logger.warn('[SDK] Device ID unavailable');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// getDeviceLocation()
|
|
39
|
+
// .then((loc) => {
|
|
40
|
+
// logger.info('[SDK] Device location availability', {
|
|
41
|
+
// location: Boolean(loc),
|
|
42
|
+
// });
|
|
43
|
+
// })
|
|
44
|
+
// .catch(() => {
|
|
45
|
+
// logger.warn('[SDK] Device location unavailable');
|
|
46
|
+
// });
|
|
47
|
+
|
|
48
|
+
const {
|
|
49
|
+
asyncStorage,
|
|
50
|
+
geolocation,
|
|
51
|
+
deviceInfo
|
|
52
|
+
} = SDKRequirements;
|
|
53
|
+
if (asyncStorage && geolocation && deviceInfo) return;
|
|
54
|
+
if (!asyncStorage) {
|
|
55
|
+
logger.warn('[SDK] Missing AsyncStorage. Install @react-native-async-storage/async-storage for session/device features.');
|
|
56
|
+
}
|
|
57
|
+
if (!geolocation) {
|
|
58
|
+
logger.warn('[SDK] Missing Geolocation. Install @react-native-community/geolocation for location features.');
|
|
59
|
+
}
|
|
60
|
+
if (!deviceInfo) {
|
|
61
|
+
logger.warn('[SDK] Missing DeviceInfo. Install react-native-device-info for device identification.');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export const SaversAppSDK = {
|
|
65
|
+
initialized: initializeSDK
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["logger","SDKRequirements","setApiKey","setEncryptionKey","setPRefCode","setAuthMode","getDeviceId","initializeSDK","providedKeys","keys","missing","apiKey","push","encryptionKey","pRefCode","authMode","length","msg","join","warn","Error","then","id","info","deviceId","Boolean","catch","asyncStorage","geolocation","deviceInfo","SaversAppSDK","initialized"],"sourceRoot":"../../../src","sources":["core/runtime.ts"],"mappings":";;AAAA;AACA,SAASA,MAAM,QAAQ,oBAAiB;AACxC,SAASC,eAAe,QAAQ,+BAA4B;;AAE5D;AACA,SACEC,SAAS,EACTC,gBAAgB,EAChBC,WAAW,EACXC,WAAW,QACN,gCAA6B;AACpC,SAASC,WAAW,QAAQ,oCAAiC;;AAE7D;AACA;;AAEA,OAAO,SAASC,aAAaA,CAACC,YAK7B,EAAE;EACD,MAAMC,IAAI,GAAGD,YAAY;EACzB,MAAME,OAAiB,GAAG,EAAE;EAC5B,IAAI,CAACD,IAAI,CAACE,MAAM,EAAED,OAAO,CAACE,IAAI,CAAC,QAAQ,CAAC;EACxC,IAAI,CAACH,IAAI,CAACI,aAAa,EAAEH,OAAO,CAACE,IAAI,CAAC,eAAe,CAAC;EACtD,IAAI,CAACH,IAAI,CAACK,QAAQ,EAAEJ,OAAO,CAACE,IAAI,CAAC,UAAU,CAAC;EAC5C,IAAI,CAACH,IAAI,CAACM,QAAQ,EAAEL,OAAO,CAACE,IAAI,CAAC,UAAU,CAAC;EAE5C,IAAIF,OAAO,CAACM,MAAM,EAAE;IAClB,MAAMC,GAAG,GAAG,gCAAgCP,OAAO,CAACQ,IAAI,CAAC,IAAI,CAAC,EAAE;IAChElB,MAAM,CAACmB,IAAI,CAACF,GAAG,CAAC;IAChB,MAAM,IAAIG,KAAK,CAACH,GAAG,CAAC;EACtB;EACAf,SAAS,CAACO,IAAI,CAACE,MAAM,CAAC;EACtBR,gBAAgB,CAACM,IAAI,CAACI,aAAa,CAAC;EACpCT,WAAW,CAACK,IAAI,CAACK,QAAQ,CAAC;EAC1BT,WAAW,CAACI,IAAI,CAACM,QAAQ,CAAC;EAE1BT,WAAW,CAAC,CAAC,CACVe,IAAI,CAAEC,EAAE,IAAK;IACZtB,MAAM,CAACuB,IAAI,CAAC,8BAA8B,EAAE;MAAEC,QAAQ,EAAEC,OAAO,CAACH,EAAE;IAAE,CAAC,CAAC;EACxE,CAAC,CAAC,CACDI,KAAK,CAAC,MAAM;IACX1B,MAAM,CAACmB,IAAI,CAAC,6BAA6B,CAAC;EAC5C,CAAC,CAAC;;EAEJ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA,MAAM;IAAEQ,YAAY;IAAEC,WAAW;IAAEC;EAAW,CAAC,GAAG5B,eAAe;EACjE,IAAI0B,YAAY,IAAIC,WAAW,IAAIC,UAAU,EAAE;EAC/C,IAAI,CAACF,YAAY,EAAE;IACjB3B,MAAM,CAACmB,IAAI,CACT,4GACF,CAAC;EACH;EACA,IAAI,CAACS,WAAW,EAAE;IAChB5B,MAAM,CAACmB,IAAI,CACT,+FACF,CAAC;EACH;EAEA,IAAI,CAACU,UAAU,EAAE;IACf7B,MAAM,CAACmB,IAAI,CACT,uFACF,CAAC;EACH;AACF;AAEA,OAAO,MAAMW,YAAY,GAAG;EAC1BC,WAAW,EAAExB;AACf,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export function apiError(message) {
|
|
4
|
+
return {
|
|
5
|
+
data: null,
|
|
6
|
+
status: false,
|
|
7
|
+
message: message ?? '',
|
|
8
|
+
fromCache: false
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export function apiSuccess(data, message, fromCache) {
|
|
12
|
+
return {
|
|
13
|
+
data,
|
|
14
|
+
status: true,
|
|
15
|
+
message: message ?? '',
|
|
16
|
+
fromCache: !!fromCache
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=apiResponse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["apiError","message","data","status","fromCache","apiSuccess"],"sourceRoot":"../../../../src","sources":["data/models/apiResponse.ts"],"mappings":";;AAOA,OAAO,SAASA,QAAQA,CAACC,OAAgB,EAAqB;EAC5D,OAAO;IACLC,IAAI,EAAE,IAAI;IACVC,MAAM,EAAE,KAAK;IACbF,OAAO,EAAEA,OAAO,IAAI,EAAE;IACtBG,SAAS,EAAE;EACb,CAAC;AACH;AAEA,OAAO,SAASC,UAAUA,CACxBH,IAAO,EACPD,OAAgB,EAChBG,SAAmB,EACH;EAChB,OAAO;IACLF,IAAI;IACJC,MAAM,EAAE,IAAI;IACZF,OAAO,EAAEA,OAAO,IAAI,EAAE;IACtBG,SAAS,EAAE,CAAC,CAACA;EACf,CAAC;AACH","ignoreList":[]}
|