@savers_app/react-native-sandbox-sdk 1.2.6 → 1.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -151
- package/lib/module/core/runtime.js +14 -0
- package/lib/module/core/runtime.js.map +1 -1
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/services/url/urlGenerator.js +20 -6
- package/lib/module/services/url/urlGenerator.js.map +1 -1
- package/lib/module/services/webview/DualWebViewBridgeController.js +267 -0
- package/lib/module/services/webview/DualWebViewBridgeController.js.map +1 -0
- package/lib/module/services/webview/dualWebViewBridge.types.js +19 -0
- package/lib/module/services/webview/dualWebViewBridge.types.js.map +1 -0
- package/lib/module/utils/config.js +2 -0
- package/lib/module/utils/config.js.map +1 -1
- package/lib/typescript/src/core/runtime.d.ts +4 -0
- package/lib/typescript/src/core/runtime.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/services/url/urlGenerator.d.ts +0 -1
- package/lib/typescript/src/services/url/urlGenerator.d.ts.map +1 -1
- package/lib/typescript/src/services/webview/DualWebViewBridgeController.d.ts +15 -0
- package/lib/typescript/src/services/webview/DualWebViewBridgeController.d.ts.map +1 -0
- package/lib/typescript/src/services/webview/dualWebViewBridge.types.d.ts +20 -0
- package/lib/typescript/src/services/webview/dualWebViewBridge.types.d.ts.map +1 -0
- package/lib/typescript/src/utils/config.d.ts.map +1 -1
- package/package.json +17 -9
- package/src/core/runtime.ts +21 -0
- package/src/index.tsx +2 -0
- package/src/services/url/urlGenerator.ts +18 -7
- package/src/services/webview/DualWebViewBridgeController.tsx +330 -0
- package/src/services/webview/dualWebViewBridge.types.ts +32 -0
- package/src/utils/config.ts +1 -0
- package/lib/module/services/device/location.js +0 -47
- package/lib/module/services/device/location.js.map +0 -1
- package/lib/typescript/src/services/device/location.d.ts +0 -8
- package/lib/typescript/src/services/device/location.d.ts.map +0 -1
- package/src/services/device/location.ts +0 -51
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Savers React Native SDK
|
|
2
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
|
|
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.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
- Open native maps by coordinates with graceful browser fallback
|
|
@@ -8,7 +8,7 @@ React Native SDK that bridges host app features like maps, dialer, browser, devi
|
|
|
8
8
|
- External browser navigation from the host app or from web content
|
|
9
9
|
- Close current screen via global `navigationRef` (React Navigation) using **END_SESSION**
|
|
10
10
|
- Device ID retrieval (via `react-native-device-info`)
|
|
11
|
-
- Optional
|
|
11
|
+
- Optional coordinates enrichment for URL payload
|
|
12
12
|
- Session and keys management (API key, encryption key, program ref code, auth mode)
|
|
13
13
|
- URL generator to compose signed and encrypted Savers mobile URLs
|
|
14
14
|
- AES-GCM encryption for URL payload (AES-256-GCM)
|
|
@@ -19,23 +19,21 @@ React Native SDK that bridges host app features like maps, dialer, browser, devi
|
|
|
19
19
|
- Install the library:
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
|
-
npm install @savers_app/react-native-sdk
|
|
22
|
+
npm install @savers_app/react-native-sandbox-sdk
|
|
23
23
|
# or
|
|
24
|
-
yarn add @savers_app/react-native-sdk
|
|
24
|
+
yarn add @savers_app/react-native-sandbox-sdk
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
- Install required peer dependencies:
|
|
28
28
|
|
|
29
29
|
```bash
|
|
30
30
|
npm install @react-native-async-storage/async-storage \
|
|
31
|
-
@react-native-community/geolocation \
|
|
32
31
|
@react-native-community/netinfo \
|
|
33
32
|
@react-navigation/native \
|
|
34
33
|
react-native-device-info \
|
|
35
34
|
react-native-aes-gcm-crypto
|
|
36
35
|
# or
|
|
37
36
|
yarn add @react-native-async-storage/async-storage \
|
|
38
|
-
@react-native-community/geolocation \
|
|
39
37
|
@react-native-community/netinfo \
|
|
40
38
|
@react-navigation/native \
|
|
41
39
|
react-native-device-info \
|
|
@@ -61,16 +59,6 @@ yarn add react-native-webview
|
|
|
61
59
|
</array>
|
|
62
60
|
```
|
|
63
61
|
|
|
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
62
|
Ensure native pods are installed and linked for the peer dependencies.
|
|
75
63
|
|
|
76
64
|
## Android Setup
|
|
@@ -79,8 +67,6 @@ Ensure native pods are installed and linked for the peer dependencies.
|
|
|
79
67
|
```xml
|
|
80
68
|
<uses-permission android:name="android.permission.INTERNET" />
|
|
81
69
|
<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
70
|
```
|
|
85
71
|
|
|
86
72
|
Link and configure the peer dependencies according to their documentation.
|
|
@@ -96,13 +82,14 @@ Requirements for AES-GCM:
|
|
|
96
82
|
Before using any other APIs, initialize the SDK with keys you receive from Savers:
|
|
97
83
|
|
|
98
84
|
```ts
|
|
99
|
-
import { SaversAppSDK } from '@savers_app/react-native-sdk';
|
|
85
|
+
import { SaversAppSDK } from '@savers_app/react-native-sandbox-sdk';
|
|
100
86
|
|
|
101
87
|
SaversAppSDK.initialized({
|
|
102
88
|
apiKey: 'YOUR_API_KEY',
|
|
103
89
|
encryptionKey: 'BASE64_256_BIT_ENCRYPTION_KEY',
|
|
104
90
|
pRefCode: 'PROGRAM_REF_CODE',
|
|
105
|
-
authMode: 'CUSTOMER_SIGN_IN_UP_MODE' // 'EMAIL' | 'PHONE'
|
|
91
|
+
authMode: 'CUSTOMER_SIGN_IN_UP_MODE', // 'EMAIL' | 'PHONE'
|
|
92
|
+
environment: 'PROD', // optional: 'SANDBOX' (https://testm.saversapp.com) | 'PROD' (https://m.saversapp.com) for generateUrl
|
|
106
93
|
});
|
|
107
94
|
```
|
|
108
95
|
|
|
@@ -114,13 +101,13 @@ import {
|
|
|
114
101
|
getEncryptionKey,
|
|
115
102
|
getPRefCode,
|
|
116
103
|
getAuthMode,
|
|
117
|
-
} from '@savers_app/react-native-sdk';
|
|
104
|
+
} from '@savers_app/react-native-sandbox-sdk';
|
|
118
105
|
```
|
|
119
106
|
|
|
120
107
|
### 2. Generate URL
|
|
121
108
|
|
|
122
109
|
```ts
|
|
123
|
-
import { generateUrl } from '@savers_app/react-native-sdk';
|
|
110
|
+
import { generateUrl } from '@savers_app/react-native-sandbox-sdk';
|
|
124
111
|
|
|
125
112
|
const url = await generateUrl({
|
|
126
113
|
// Top-level UrlInput fields
|
|
@@ -155,39 +142,8 @@ const url = await generateUrl({
|
|
|
155
142
|
},
|
|
156
143
|
// sessionId is optional; when omitted, the SDK uses its stored session id
|
|
157
144
|
// deviceInfo is optional; the SDK builds it internally using device id (and optional coordinates)
|
|
158
|
-
nonce: '<NONCE_TOKEN>',
|
|
159
|
-
});
|
|
160
|
-
// returns https://m.saversapp.com/?pRefCode=...&qP=...
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
Fetch nonce and call generateUrl:
|
|
164
|
-
|
|
165
|
-
```ts
|
|
166
|
-
import { ApiService, generateUrl } from '@savers_app/react-native-sdk';
|
|
167
|
-
|
|
168
|
-
const generator = new ApiService().getNonce({
|
|
169
|
-
extUserId: '12345',
|
|
170
|
-
partnerCode: 'abcde',
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
const { value } = await generator.next();
|
|
174
|
-
if (value?.error) throw new Error(value.error);
|
|
175
|
-
if (!value?.token) throw new Error('Nonce not received');
|
|
176
|
-
|
|
177
|
-
const url = await generateUrl({
|
|
178
|
-
authType: 'PHONE',
|
|
179
|
-
profile: {
|
|
180
|
-
userId: 'USER_ID',
|
|
181
|
-
email: 'jane@example.com',
|
|
182
|
-
firstname: 'Jane',
|
|
183
|
-
lastname: 'Doe',
|
|
184
|
-
phone: '+15555550100',
|
|
185
|
-
pv: '1',
|
|
186
|
-
ev: '1',
|
|
187
|
-
},
|
|
188
|
-
screen: { name: 'Explore', attributes: [{ key: 'offerId', value: '123' }] },
|
|
189
|
-
nonce: value.token,
|
|
190
145
|
});
|
|
146
|
+
// returns https://m.saversapp.com/... or https://testm.saversapp.com/... depending on `environment` in init (default follows build-time config)
|
|
191
147
|
```
|
|
192
148
|
|
|
193
149
|
Profile requirements:
|
|
@@ -196,7 +152,7 @@ Profile requirements:
|
|
|
196
152
|
- `phone` is mandatory when `authType` is `'PHONE'`
|
|
197
153
|
- `username` is mandatory when `authType` is `'USERNAME'`
|
|
198
154
|
Nonce requirement:
|
|
199
|
-
-
|
|
155
|
+
- The SDK resolves a nonce automatically using `profile.userId` and your `pRefCode`; no manual action is required.
|
|
200
156
|
|
|
201
157
|
Screen requirements:
|
|
202
158
|
- `screen.name` is optional, defaults to `'Explore'`
|
|
@@ -220,7 +176,7 @@ One-time host app setup using a global `navigationRef`:
|
|
|
220
176
|
|
|
221
177
|
```tsx
|
|
222
178
|
import { NavigationContainer, createNavigationContainerRef } from '@react-navigation/native';
|
|
223
|
-
import { SaversAppSDK } from '@savers_app/react-native-sdk';
|
|
179
|
+
import { SaversAppSDK } from '@savers_app/react-native-sandbox-sdk';
|
|
224
180
|
|
|
225
181
|
export const navigationRef = createNavigationContainerRef();
|
|
226
182
|
|
|
@@ -232,6 +188,7 @@ export function App() {
|
|
|
232
188
|
pRefCode: 'PROGRAM_REF_CODE',
|
|
233
189
|
authMode: 'EMAIL', // or 'PHONE'
|
|
234
190
|
navigationRef, // pass the ref to the SDK
|
|
191
|
+
environment: 'PROD', // optional: 'SANDBOX' | 'PROD' for generateUrl hosted origin
|
|
235
192
|
});
|
|
236
193
|
|
|
237
194
|
return <NavigationContainer ref={navigationRef}>{/* your navigators */}</NavigationContainer>;
|
|
@@ -241,7 +198,7 @@ export function App() {
|
|
|
241
198
|
SDK API:
|
|
242
199
|
|
|
243
200
|
```ts
|
|
244
|
-
import { closeCurrentScreen, closeCurrentScreenSafe } from '@savers_app/react-native-sdk';
|
|
201
|
+
import { closeCurrentScreen, closeCurrentScreenSafe } from '@savers_app/react-native-sandbox-sdk';
|
|
245
202
|
|
|
246
203
|
closeCurrentScreen(); // returns boolean
|
|
247
204
|
closeCurrentScreenSafe(); // Android-only fallback to exitApp if it can't goBack()
|
|
@@ -256,7 +213,7 @@ Notes:
|
|
|
256
213
|
Trigger native actions from web & bind `onMessage` to a `WebView`:
|
|
257
214
|
|
|
258
215
|
```ts
|
|
259
|
-
import { handleWebMessage } from '@savers_app/react-native-sdk';
|
|
216
|
+
import { handleWebMessage } from '@savers_app/react-native-sandbox-sdk';
|
|
260
217
|
import { WebView } from 'react-native-webview';
|
|
261
218
|
...
|
|
262
219
|
|
|
@@ -346,7 +303,7 @@ import {
|
|
|
346
303
|
getEncryptionKey,
|
|
347
304
|
getPRefCode,
|
|
348
305
|
getAuthMode,
|
|
349
|
-
} from '@savers_app/react-native-sdk';
|
|
306
|
+
} from '@savers_app/react-native-sandbox-sdk';
|
|
350
307
|
```
|
|
351
308
|
|
|
352
309
|
- `getDeviceId()`: uses `react-native-device-info` to resolve a unique device id and caches it in memory and AsyncStorage.
|
|
@@ -355,29 +312,10 @@ import {
|
|
|
355
312
|
|
|
356
313
|
## Location & Coordinates
|
|
357
314
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
1. **Device location service** (geolocation + permissions):
|
|
361
|
-
|
|
362
|
-
```ts
|
|
363
|
-
import { getDeviceLocation } from '@savers_app/react-native-sdk';
|
|
364
|
-
|
|
365
|
-
const loc = await getDeviceLocation();
|
|
366
|
-
// { lat, lng } or throws if unavailable / permission denied
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
This uses:
|
|
370
|
-
- `@react-native-community/geolocation`
|
|
371
|
-
- `ensureLocationPermission` (Android runtime permissions)
|
|
372
|
-
- `resolveNativeDependencies` to check if the native module is linked
|
|
373
|
-
|
|
374
|
-
2. **Manual coordinates for URL generation**:
|
|
315
|
+
Manual coordinates for URL generation:
|
|
375
316
|
|
|
376
317
|
```ts
|
|
377
|
-
import {
|
|
378
|
-
setLocationCoordinates,
|
|
379
|
-
getLocationCoordinates,
|
|
380
|
-
} from '@savers_app/react-native-sdk';
|
|
318
|
+
import { setLocationCoordinates, getLocationCoordinates } from '@savers_app/react-native-sandbox-sdk';
|
|
381
319
|
|
|
382
320
|
await setLocationCoordinates(37.7749, -122.4194);
|
|
383
321
|
const coords = await getLocationCoordinates(); // { lat, lng } | null
|
|
@@ -393,7 +331,7 @@ import {
|
|
|
393
331
|
openDialPad,
|
|
394
332
|
callPhone,
|
|
395
333
|
openBrowser,
|
|
396
|
-
} from '@savers_app/react-native-sdk';
|
|
334
|
+
} from '@savers_app/react-native-sandbox-sdk';
|
|
397
335
|
```
|
|
398
336
|
|
|
399
337
|
- `openMap(lat, lng, label?)`: opens the native maps app if available, otherwise falls back to browser (Apple Maps / Google Maps).
|
|
@@ -408,7 +346,7 @@ Use the `ApiService` to make network requests with unified error handling, cachi
|
|
|
408
346
|
### ApiService Overview
|
|
409
347
|
|
|
410
348
|
```ts
|
|
411
|
-
import { ApiService } from '@savers_app/react-native-sdk';
|
|
349
|
+
import { ApiService } from '@savers_app/react-native-sandbox-sdk';
|
|
412
350
|
|
|
413
351
|
const apiService = new ApiService(); // defaults to production base URL
|
|
414
352
|
```
|
|
@@ -422,7 +360,7 @@ const apiService = new ApiService(); // defaults to production base URL
|
|
|
422
360
|
### Onboarding Example
|
|
423
361
|
|
|
424
362
|
```ts
|
|
425
|
-
import { ApiService } from '@savers_app/react-native-sdk';
|
|
363
|
+
import { ApiService } from '@savers_app/react-native-sandbox-sdk';
|
|
426
364
|
|
|
427
365
|
const apiService = new ApiService();
|
|
428
366
|
|
|
@@ -479,76 +417,9 @@ yarn run:ios # uses scripts.run:ios from package.json
|
|
|
479
417
|
yarn run:android # uses scripts.run:android from package.json
|
|
480
418
|
```
|
|
481
419
|
|
|
482
|
-
## Development
|
|
483
|
-
|
|
484
|
-
Common scripts from the root library package (`package.json`):
|
|
485
|
-
|
|
486
|
-
```bash
|
|
487
|
-
# Lint, typecheck, test and build the library
|
|
488
|
-
npm run lint
|
|
489
|
-
npm run typecheck
|
|
490
|
-
npm run test
|
|
491
|
-
npm run prepare # builds the library via react-native-builder-bob
|
|
492
|
-
|
|
493
|
-
# or using yarn
|
|
494
|
-
yarn lint
|
|
495
|
-
yarn typecheck
|
|
496
|
-
yarn test
|
|
497
|
-
yarn prepare
|
|
498
|
-
|
|
499
|
-
# Helper scripts to run the example app from the root
|
|
500
|
-
yarn run:ios
|
|
501
|
-
yarn run:android
|
|
502
|
-
```
|
|
503
|
-
|
|
504
|
-
In the example app workspace (`@saversapp/react-native-sdk-example`), you can also run:
|
|
505
|
-
|
|
506
|
-
```bash
|
|
507
|
-
yarn --workspace @saversapp/react-native-sdk-example run lint
|
|
508
|
-
yarn --workspace @saversapp/react-native-sdk-example run test
|
|
509
|
-
```
|
|
510
|
-
|
|
511
|
-
## Publishing to npm
|
|
512
|
-
|
|
513
|
-
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`).
|
|
514
|
-
|
|
515
|
-
Basic flow to publish a new version:
|
|
516
|
-
|
|
517
|
-
```bash
|
|
518
|
-
# 1. Make sure you are logged in to npm
|
|
519
|
-
npm login
|
|
520
|
-
|
|
521
|
-
# 2. Ensure the code passes checks and is built
|
|
522
|
-
yarn lint
|
|
523
|
-
yarn typecheck
|
|
524
|
-
yarn test
|
|
525
|
-
yarn prepare
|
|
526
|
-
|
|
527
|
-
# 3. Run the release script from the repo root
|
|
528
|
-
# This will:
|
|
529
|
-
# - bump the version
|
|
530
|
-
# - create a git tag
|
|
531
|
-
# - publish to npm (using publishConfig.registry)
|
|
532
|
-
# - create a GitHub release
|
|
533
|
-
yarn release
|
|
534
|
-
```
|
|
535
|
-
|
|
536
|
-
If you prefer a fully manual publish flow, you can instead:
|
|
537
|
-
|
|
538
|
-
```bash
|
|
539
|
-
# Bump the version number in package.json (or use `npm version patch|minor|major`)
|
|
540
|
-
npm version patch
|
|
541
|
-
|
|
542
|
-
# Build the library
|
|
543
|
-
yarn prepare
|
|
544
|
-
|
|
545
|
-
# Publish to npm
|
|
546
|
-
npm publish
|
|
547
|
-
```
|
|
548
420
|
|
|
549
421
|
## Troubleshooting
|
|
550
|
-
- Ensure peer dependencies are installed and linked (AsyncStorage,
|
|
551
|
-
- On Android, grant runtime permissions for location when using geolocation.
|
|
422
|
+
- Ensure peer dependencies are installed and linked (AsyncStorage, NetInfo, DeviceInfo, WebView, React Navigation).
|
|
552
423
|
- If `SaversAppSDK.initialized` logs missing modules, install the indicated packages.
|
|
553
424
|
- 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.
|
|
554
425
|
|
|
@@ -9,9 +9,14 @@ import { setApiKey, setEncryptionKey, setPRefCode, setAuthMode } from "../data/s
|
|
|
9
9
|
import { getDeviceId } from "../data/storage/deviceIdManager.js";
|
|
10
10
|
import { setReactRef } from "../data/storage/reactRefManager.js";
|
|
11
11
|
|
|
12
|
+
// Hosted app base URL (test vs production merchant web)
|
|
13
|
+
import { setEnvironment } from "../utils/config.js";
|
|
14
|
+
|
|
12
15
|
// Services
|
|
13
16
|
// import { getDeviceLocation } from '../services/device/location';
|
|
14
17
|
|
|
18
|
+
/** Controls which hosted merchant web origin `generateUrl` uses. */
|
|
19
|
+
|
|
15
20
|
export function initializeSDK(providedKeys) {
|
|
16
21
|
const keys = providedKeys;
|
|
17
22
|
const missing = [];
|
|
@@ -25,6 +30,15 @@ export function initializeSDK(providedKeys) {
|
|
|
25
30
|
logger.warn(msg);
|
|
26
31
|
throw new Error(msg);
|
|
27
32
|
}
|
|
33
|
+
if (keys.environment !== undefined) {
|
|
34
|
+
if (keys.environment !== 'SANDBOX' && keys.environment !== 'PROD') {
|
|
35
|
+
throw new Error(`[SDK] Invalid environment: ${String(keys.environment)}. Use 'SANDBOX' or 'PROD'.`);
|
|
36
|
+
}
|
|
37
|
+
setEnvironment(keys.environment === 'SANDBOX' ? 'sandbox' : 'production');
|
|
38
|
+
logger.info('[SDK] Hosted app environment', {
|
|
39
|
+
environment: keys.environment
|
|
40
|
+
});
|
|
41
|
+
}
|
|
28
42
|
setApiKey(keys.apiKey);
|
|
29
43
|
setEncryptionKey(keys.encryptionKey);
|
|
30
44
|
setPRefCode(keys.pRefCode);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["logger","SDKRequirements","setApiKey","setEncryptionKey","setPRefCode","setAuthMode","getDeviceId","setReactRef","initializeSDK","providedKeys","keys","missing","apiKey","push","encryptionKey","pRefCode","authMode","navigationRef","length","msg","join","warn","Error","
|
|
1
|
+
{"version":3,"names":["logger","SDKRequirements","setApiKey","setEncryptionKey","setPRefCode","setAuthMode","getDeviceId","setReactRef","setEnvironment","initializeSDK","providedKeys","keys","missing","apiKey","push","encryptionKey","pRefCode","authMode","navigationRef","length","msg","join","warn","Error","environment","undefined","String","info","then","id","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;AAC7D,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B,SAAS,CAACS,IAAI,CAACE,MAAM,CAAC;EACtBV,gBAAgB,CAACQ,IAAI,CAACI,aAAa,CAAC;EACpCX,WAAW,CAACO,IAAI,CAACK,QAAQ,CAAC;EAC1BX,WAAW,CAACM,IAAI,CAACM,QAAQ,CAAC;EAC1BV,WAAW,CAACI,IAAI,CAACO,aAAa,CAAC;EAE/BZ,WAAW,CAAC,CAAC,CACVsB,IAAI,CAAEC,EAAE,IAAK;IACZ7B,MAAM,CAAC2B,IAAI,CAAC,8BAA8B,EAAE;MAAEG,QAAQ,EAAEC,OAAO,CAACF,EAAE;IAAE,CAAC,CAAC;EACxE,CAAC,CAAC,CACDG,KAAK,CAAC,MAAM;IACXhC,MAAM,CAACsB,IAAI,CAAC,6BAA6B,CAAC;EAC5C,CAAC,CAAC;;EAEJ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;EAEA,MAAM;IAAEW,YAAY;IAAEC,WAAW;IAAEC;EAAW,CAAC,GAAGlC,eAAe;EACjE,IAAIgC,YAAY,IAAIC,WAAW,IAAIC,UAAU,EAAE;EAC/C,IAAI,CAACF,YAAY,EAAE;IACjBjC,MAAM,CAACsB,IAAI,CACT,4GACF,CAAC;EACH;EACA,IAAI,CAACY,WAAW,EAAE;IAChBlC,MAAM,CAACsB,IAAI,CACT,+FACF,CAAC;EACH;EAEA,IAAI,CAACa,UAAU,EAAE;IACfnC,MAAM,CAACsB,IAAI,CACT,uFACF,CAAC;EACH;AACF;AAEA,OAAO,MAAMc,YAAY,GAAG;EAC1BC,WAAW,EAAE5B;AACf,CAAC","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -8,6 +8,8 @@ export * from "./utils/errors.js";
|
|
|
8
8
|
export * from "./utils/logger.js";
|
|
9
9
|
export * from "./utils/validator.js";
|
|
10
10
|
export * from "./services/webview/messageHandler.js";
|
|
11
|
+
export * from "./services/webview/DualWebViewBridgeController.js";
|
|
12
|
+
export * from "./services/webview/dualWebViewBridge.types.js";
|
|
11
13
|
export * from "./data/storage/deviceIdManager.js";
|
|
12
14
|
export * from "./services/navigation/dialPad.js";
|
|
13
15
|
export * from "./services/navigation/openBrowser.js";
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,cAAc,kCAA+B;AAC7C,cAAc,2CAAwC;AACtD,cAAc,6CAA0C;AACxD,cAAc,4BAAyB;AACvC,cAAc,mBAAgB;AAC9B,cAAc,mBAAgB;AAC9B,cAAc,sBAAmB;AACjC,cAAc,sCAAmC;AACjD,cAAc,mCAAgC;AAC9C,cAAc,kCAA+B;AAC7C,cAAc,sCAAmC;AACjD,cAAc,kCAA+B;AAC7C,cAAc,gCAA6B;AAC3C,cAAc,8BAA2B;AACzC,cAAc,mBAAgB;AAC9B,cAAc,+BAA4B;AAC1C,cAAc,mCAAgC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,cAAc,kCAA+B;AAC7C,cAAc,2CAAwC;AACtD,cAAc,6CAA0C;AACxD,cAAc,4BAAyB;AACvC,cAAc,mBAAgB;AAC9B,cAAc,mBAAgB;AAC9B,cAAc,sBAAmB;AACjC,cAAc,sCAAmC;AACjD,cAAc,mDAAgD;AAC9D,cAAc,+CAA4C;AAC1D,cAAc,mCAAgC;AAC9C,cAAc,kCAA+B;AAC7C,cAAc,sCAAmC;AACjD,cAAc,kCAA+B;AAC7C,cAAc,gCAA6B;AAC3C,cAAc,8BAA2B;AACzC,cAAc,mBAAgB;AAC9B,cAAc,+BAA4B;AAC1C,cAAc,mCAAgC","ignoreList":[]}
|
|
@@ -10,13 +10,13 @@ import { getSessionId } from "../../data/storage/sessionManager.js";
|
|
|
10
10
|
import { getLocationCoordinates } from "../../data/storage/locationManager.js";
|
|
11
11
|
import { getEncryptionKey, getPRefCode } from "../../data/storage/keysManager.js";
|
|
12
12
|
import { getBaseUrl } from "../../utils/config.js";
|
|
13
|
+
import { ApiService } from "../../data/network/apiService.js";
|
|
13
14
|
export function validateInput(input) {
|
|
14
15
|
const errors = [];
|
|
15
16
|
const auth = input.authType ?? 'PHONE';
|
|
16
17
|
if (!input.profile) errors.push('profile is mandatory');
|
|
17
18
|
if (!input.profile?.userId) errors.push('userId is mandatory');
|
|
18
19
|
if (!input.profile?.email) errors.push('email is mandatory');
|
|
19
|
-
if (!input.nonce) errors.push('nonce is mandatory');
|
|
20
20
|
const pv = input.profile?.pv;
|
|
21
21
|
const ev = input.profile?.ev;
|
|
22
22
|
if (typeof pv !== 'undefined' && pv !== '0' && pv !== '1') {
|
|
@@ -48,6 +48,24 @@ export async function generateUrl(input) {
|
|
|
48
48
|
const deviceId = await getDeviceId();
|
|
49
49
|
const storedLocation = await getLocationCoordinates();
|
|
50
50
|
const sessionId = await getSessionId();
|
|
51
|
+
const programCode = await getPRefCode();
|
|
52
|
+
if (!programCode || programCode === '-') {
|
|
53
|
+
throw new SDKError('pRefCode is mandatory. Initialize SDK with pRefCode.');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// get nonce -- start
|
|
57
|
+
const generator = new ApiService().getNonce({
|
|
58
|
+
extUserId: input.profile?.userId ?? '',
|
|
59
|
+
partnerCode: programCode
|
|
60
|
+
});
|
|
61
|
+
const {
|
|
62
|
+
value
|
|
63
|
+
} = await generator.next();
|
|
64
|
+
if (value?.error) throw new SDKError(String(value.error));
|
|
65
|
+
if (!value?.token) throw new SDKError('Nonce not received');
|
|
66
|
+
const resolvedNonce = value.token;
|
|
67
|
+
// get nonce -- end
|
|
68
|
+
|
|
51
69
|
const deviceInfo = storedLocation != null ? {
|
|
52
70
|
dId: deviceId,
|
|
53
71
|
location: storedLocation
|
|
@@ -60,7 +78,7 @@ export async function generateUrl(input) {
|
|
|
60
78
|
authType: input.authType ?? 'PHONE',
|
|
61
79
|
sessionId: sessionId ?? '',
|
|
62
80
|
deviceInfo,
|
|
63
|
-
nonce:
|
|
81
|
+
nonce: resolvedNonce
|
|
64
82
|
};
|
|
65
83
|
const validation = validateInput({
|
|
66
84
|
...normalized,
|
|
@@ -85,10 +103,6 @@ export async function generateUrl(input) {
|
|
|
85
103
|
throw new SDKError('Encryption key is mandatory. Initialize SDK with encryptionKey.');
|
|
86
104
|
}
|
|
87
105
|
const encoded = await aesEncrypt(json, key);
|
|
88
|
-
const programCode = await getPRefCode();
|
|
89
|
-
if (!programCode || programCode === '-') {
|
|
90
|
-
throw new SDKError('pRefCode is mandatory. Initialize SDK with pRefCode.');
|
|
91
|
-
}
|
|
92
106
|
return `${getBaseUrl()}?pRefCode=${encodeURIComponent(programCode)}&qP=${encodeURIComponent(encoded)}`;
|
|
93
107
|
}
|
|
94
108
|
//# sourceMappingURL=urlGenerator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SDKError","aesEncrypt","getDeviceId","getSessionId","getLocationCoordinates","getEncryptionKey","getPRefCode","getBaseUrl","validateInput","input","errors","auth","authType","profile","push","userId","email","
|
|
1
|
+
{"version":3,"names":["SDKError","aesEncrypt","getDeviceId","getSessionId","getLocationCoordinates","getEncryptionKey","getPRefCode","getBaseUrl","ApiService","validateInput","input","errors","auth","authType","profile","push","userId","email","pv","ev","username","phone","screenName","screen","name","attrs","attributes","length","ok","generateUrl","deviceId","storedLocation","sessionId","programCode","generator","getNonce","extUserId","partnerCode","value","next","error","String","token","resolvedNonce","deviceInfo","dId","location","normalized","nonce","validation","join","payload","json","JSON","stringify","key","encoded","encodeURIComponent"],"sourceRoot":"../../../../src","sources":["services/url/urlGenerator.ts"],"mappings":";;AAAA;AACA,SAASA,QAAQ,QAAQ,uBAAoB;AAC7C,SAASC,UAAU,QAAQ,2BAAwB;;AAEnD;AACA,SAASC,WAAW,QAAQ,uCAAoC;AAChE,SAASC,YAAY,QAAQ,sCAAmC;AAChE,SAASC,sBAAsB,QAAQ,uCAAoC;AAC3E,SAASC,gBAAgB,EAAEC,WA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