@abihealth/goapp-react-native 1.21.0 → 1.22.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/CHANGELOG.md +8 -0
- package/README.md +272 -2
- package/dist/common/api/partner.js +3 -1
- package/dist/common/api/sslPinning.d.ts +1 -0
- package/dist/common/api/sslPinning.js +61 -0
- package/dist/common/contexts/ConsultationContext.d.ts +2 -1
- package/dist/common/contexts/ConsultationContext.js +51 -34
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.22.0](https://github.com/abiglobalhealth/react-native-sdk/compare/goapp-react-native-v1.21.0...goapp-react-native-v1.22.0) (2025-04-23)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add caret to svg dependency ([#172](https://github.com/abiglobalhealth/react-native-sdk/issues/172)) ([79b08fc](https://github.com/abiglobalhealth/react-native-sdk/commit/79b08fc3761e6d5005208eb1b90b4b6a054bf206))
|
|
9
|
+
* add SSL pinning ([#173](https://github.com/abiglobalhealth/react-native-sdk/issues/173)) ([07cbd47](https://github.com/abiglobalhealth/react-native-sdk/commit/07cbd47ef327a7c836d2671485963936ca2cf5f0))
|
|
10
|
+
|
|
3
11
|
## [1.21.0](https://github.com/abiglobalhealth/react-native-sdk/compare/goapp-react-native-v1.20.3...goapp-react-native-v1.21.0) (2025-04-14)
|
|
4
12
|
|
|
5
13
|
|
package/README.md
CHANGED
|
@@ -1,3 +1,273 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Abi GoApp SDK Installation Guide
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This guide explains how to install the `@abihealth/goapp-react-native` SDK and its peer dependencies. Correct installation and configuration are needed to use the SDK's features.
|
|
4
|
+
|
|
5
|
+
## Installation Requirements
|
|
6
|
+
|
|
7
|
+
Install the main package (`@abihealth/goapp-react-native`) and these essential peer dependencies:
|
|
8
|
+
|
|
9
|
+
- **react-native-agora** ([npm](https://www.npmjs.com/package/react-native-agora)): For video calls
|
|
10
|
+
- **react-native-svg** ([npm](https://www.npmjs.com/package/react-native-svg)): For rendering SVGs
|
|
11
|
+
- **react-native-ssl-public-key-pinning** ([npm](https://www.npmjs.com/package/react-native-ssl-public-key-pinning)): For security
|
|
12
|
+
|
|
13
|
+
Follow the instructions for your environment (Bare React Native or Expo). Always consult the official docs for each dependency for detailed information.
|
|
14
|
+
|
|
15
|
+
## Expo Projects (Managed Workflow)
|
|
16
|
+
|
|
17
|
+
Use these steps for Expo managed workflow (requires a development build).
|
|
18
|
+
|
|
19
|
+
### 1. Install using expo install
|
|
20
|
+
|
|
21
|
+
This command helps install compatible versions:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npx expo install @abihealth/goapp-react-native react-native-agora react-native-svg react-native-ssl-public-key-pinning
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### 2. Configure Permissions and Plugins
|
|
28
|
+
|
|
29
|
+
Set up permissions and required Expo plugins in `app.json` or `app.config.js`:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"expo": {
|
|
34
|
+
"plugins": [
|
|
35
|
+
[
|
|
36
|
+
"react-native-agora",
|
|
37
|
+
{
|
|
38
|
+
"cameraPermission": "Allow $(PRODUCT_NAME) to access camera for video.",
|
|
39
|
+
"microphonePermission": "Allow $(PRODUCT_NAME) to access microphone for video."
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
],
|
|
43
|
+
"android": {
|
|
44
|
+
"permissions": ["android.permission.CAMERA", "android.permission.RECORD_AUDIO"]
|
|
45
|
+
},
|
|
46
|
+
"ios": {
|
|
47
|
+
"infoPlist": {
|
|
48
|
+
"NSCameraUsageDescription": "Allow $(PRODUCT_NAME) access for video calls.",
|
|
49
|
+
"NSMicrophoneUsageDescription": "Allow $(PRODUCT_NAME) access for video calls."
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
> **Important**: Plugin configurations may change. Always check official react-native-agora docs. Verify Expo compatibility for react-native-ssl-public-key-pinning.
|
|
57
|
+
|
|
58
|
+
### 3. Create a Development Build
|
|
59
|
+
|
|
60
|
+
Standard Expo Go is insufficient. Create a development build:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npx expo run:android
|
|
64
|
+
# or
|
|
65
|
+
npx expo run:ios
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Alternatively, use EAS Build:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
eas build --profile development --platform [android|ios]
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Install the build, then run your project:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npx expo start --dev-client
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Bare React Native Projects
|
|
81
|
+
|
|
82
|
+
Use these steps for standard bare React Native projects.
|
|
83
|
+
|
|
84
|
+
### 1. Install SDK and dependencies
|
|
85
|
+
|
|
86
|
+
Using npm:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
npm install @abihealth/goapp-react-native react-native-agora react-native-svg react-native-ssl-public-key-pinning
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Or using Yarn:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
yarn add @abihealth/goapp-react-native react-native-agora react-native-svg react-native-ssl-public-key-pinning
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### 2. Link native dependencies (React Native < 0.60)
|
|
99
|
+
|
|
100
|
+
If using RN < 0.60, you might need manual linking:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
npx react-native link react-native-agora react-native-svg react-native-ssl-public-key-pinning
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
> Note: Autolinking should work for RN >= 0.60 (iOS/Android). Verify if issues arise.
|
|
107
|
+
|
|
108
|
+
### 3. Install Pods (iOS)
|
|
109
|
+
|
|
110
|
+
Install CocoaPods dependencies:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
cd ios && pod install && cd ..
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### 4. Android Setup & Permissions
|
|
117
|
+
|
|
118
|
+
Add necessary permissions to `android/app/src/main/AndroidManifest.xml`:
|
|
119
|
+
|
|
120
|
+
```xml
|
|
121
|
+
<uses-permission android:name="android.permission.CAMERA" />
|
|
122
|
+
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Agora Specific: Ensure JitPack is in `android/build.gradle`:
|
|
126
|
+
|
|
127
|
+
```gradle
|
|
128
|
+
allprojects {
|
|
129
|
+
repositories {
|
|
130
|
+
// ... other repositories
|
|
131
|
+
maven { url 'https://www.jitpack.io' }
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### 5. iOS Setup & Permissions
|
|
137
|
+
|
|
138
|
+
Add privacy descriptions to `ios/<YourProjectName>/Info.plist`:
|
|
139
|
+
|
|
140
|
+
- **NSCameraUsageDescription**: Reason for camera access (e.g., "Enable video calls")
|
|
141
|
+
- **NSMicrophoneUsageDescription**: Reason for microphone access (e.g., "Enable audio in video calls")
|
|
142
|
+
|
|
143
|
+
## Post-Installation
|
|
144
|
+
|
|
145
|
+
After installing and configuring dependencies, import and use `@abihealth/goapp-react-native`. Remember `react-native-ssl-public-key-pinning` needs careful key/domain setup. Ensure your build environment (SDK/NDK versions, Xcode) is correct.
|
|
146
|
+
|
|
147
|
+
## Usage
|
|
148
|
+
|
|
149
|
+
Basic guide to integrating SDK components:
|
|
150
|
+
|
|
151
|
+
### 1. Import components and hooks
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
import { ConsultationsProvider, VideoConsultation, useConsultation } from '@abihealth/goapp-react-native'
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### 2. Wrap your app with ConsultationsProvider
|
|
158
|
+
|
|
159
|
+
Initializes SDK context with necessary configuration:
|
|
160
|
+
|
|
161
|
+
```jsx
|
|
162
|
+
// Example App.js
|
|
163
|
+
import React from 'react'
|
|
164
|
+
import { ConsultationsProvider } from '@abihealth/goapp-react-native'
|
|
165
|
+
import MainApp from './MainApp'
|
|
166
|
+
|
|
167
|
+
const user_access_token = 'YOUR_USER_ACCESS_TOKEN' // Get from your app logic
|
|
168
|
+
const region = 'YOUR_API_REGION' // Get from your app logic
|
|
169
|
+
// Optional props
|
|
170
|
+
const theme = {
|
|
171
|
+
/* Custom theme */
|
|
172
|
+
}
|
|
173
|
+
const components = {
|
|
174
|
+
/* Custom components */
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const App = () => {
|
|
178
|
+
const onError = (error) => {
|
|
179
|
+
console.error('SDK Error:', error)
|
|
180
|
+
/* Handle error */
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return (
|
|
184
|
+
<ConsultationsProvider
|
|
185
|
+
region={region}
|
|
186
|
+
token={user_access_token}
|
|
187
|
+
theme={theme} // Optional
|
|
188
|
+
components={components} // Optional
|
|
189
|
+
onError={onError} // Optional
|
|
190
|
+
>
|
|
191
|
+
{/* Other components */}
|
|
192
|
+
</ConsultationsProvider>
|
|
193
|
+
)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export default App
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
#### Provider Props:
|
|
200
|
+
|
|
201
|
+
- `region` (string, required): API region
|
|
202
|
+
- `token` (string, required): User authentication token
|
|
203
|
+
- `theme` (object, optional): Customize visual theme
|
|
204
|
+
- `components` (object, optional): Override default components
|
|
205
|
+
- `onError` (function, optional): Error callback
|
|
206
|
+
|
|
207
|
+
### 3. Use the VideoConsultation component
|
|
208
|
+
|
|
209
|
+
Renders the video consultation UI:
|
|
210
|
+
|
|
211
|
+
```jsx
|
|
212
|
+
// Example ConsultationScreen.js
|
|
213
|
+
import React from 'react'
|
|
214
|
+
import { View } from 'react-native'
|
|
215
|
+
import { VideoConsultation } from '@abihealth/goapp-react-native'
|
|
216
|
+
|
|
217
|
+
// Optional props
|
|
218
|
+
const options = {
|
|
219
|
+
/* Video call options */
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const ConsultationScreen = () => {
|
|
223
|
+
const eventHandlers = {
|
|
224
|
+
/* Callbacks for events */
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return <VideoConsultation options={options} eventHandlers={eventHandlers} />
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export default ConsultationScreen
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
#### VideoConsultation Props:
|
|
234
|
+
|
|
235
|
+
- `options` (object, optional): Video call appearance/behavior config
|
|
236
|
+
- `eventHandlers` (object, optional): Callbacks for video call events
|
|
237
|
+
|
|
238
|
+
### 4. Use the useConsultation hook
|
|
239
|
+
|
|
240
|
+
Access consultation state and control functions:
|
|
241
|
+
|
|
242
|
+
```jsx
|
|
243
|
+
// Example ConsultationControls.js
|
|
244
|
+
import React from 'react'
|
|
245
|
+
import { View, Button, Text } from 'react-native'
|
|
246
|
+
import { useConsultation } from '@abihealth/goapp-react-native'
|
|
247
|
+
|
|
248
|
+
const ConsultationControls = () => {
|
|
249
|
+
const { consultation, start, cancel } = useConsultation()
|
|
250
|
+
|
|
251
|
+
const handleStart = () => start(/* params if needed */)
|
|
252
|
+
const handleCancel = () => cancel(/* params if needed */)
|
|
253
|
+
|
|
254
|
+
return (
|
|
255
|
+
<View>
|
|
256
|
+
{consultation && <Text>Consultation Info: {/* Details */}</Text>}
|
|
257
|
+
<Button title="Start" onPress={handleStart} />
|
|
258
|
+
<Button title="Cancel" onPress={handleCancel} />
|
|
259
|
+
</View>
|
|
260
|
+
)
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export default ConsultationControls
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
#### useConsultation Hook returns:
|
|
267
|
+
|
|
268
|
+
- `consultation` (object | null): Current/last consultation info
|
|
269
|
+
- `start` (function): Initiates consultation
|
|
270
|
+
- `cancel` (function): Cancels consultation
|
|
271
|
+
- Other values may be available; check SDK docs
|
|
272
|
+
|
|
273
|
+
Always consult the specific `@abihealth/goapp-react-native` documentation for details on props, events, hooks, parameters, and advanced configuration.
|
|
@@ -6,5 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getPartnerInfo = void 0;
|
|
7
7
|
var axios_1 = __importDefault(require("axios"));
|
|
8
8
|
var PARTNER_URL = 'partner';
|
|
9
|
-
var getPartnerInfo = function () {
|
|
9
|
+
var getPartnerInfo = function () {
|
|
10
|
+
return axios_1.default.get(PARTNER_URL).then(function (response) { return response === null || response === void 0 ? void 0 : response.data; });
|
|
11
|
+
};
|
|
10
12
|
exports.getPartnerInfo = getPartnerInfo;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const initializeSslPinning: (disableSslPinning: boolean) => Promise<void>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.initializeSslPinning = void 0;
|
|
40
|
+
var react_native_ssl_public_key_pinning_1 = require("react-native-ssl-public-key-pinning");
|
|
41
|
+
var initializeSslPinning = function (disableSslPinning) { return __awaiter(void 0, void 0, void 0, function () {
|
|
42
|
+
return __generator(this, function (_a) {
|
|
43
|
+
switch (_a.label) {
|
|
44
|
+
case 0:
|
|
45
|
+
if (!disableSslPinning) return [3 /*break*/, 2];
|
|
46
|
+
return [4 /*yield*/, (0, react_native_ssl_public_key_pinning_1.disableSslPinning)()];
|
|
47
|
+
case 1:
|
|
48
|
+
_a.sent();
|
|
49
|
+
return [2 /*return*/, console.log('🔒🚫 SSL pinning disabled')];
|
|
50
|
+
case 2: return [4 /*yield*/, (0, react_native_ssl_public_key_pinning_1.initializeSslPinning)({
|
|
51
|
+
'ape1.sdk.abi.ai': {
|
|
52
|
+
publicKeyHashes: ['95kHJrJXD1L/WORHTc5rh99KvZ10Ipd9m7eW0JUsLnA=', 'b+nnCNzPN8D2jN0srTRwMXqLUjmnZODZ0k28NZFFrkc=']
|
|
53
|
+
}
|
|
54
|
+
})];
|
|
55
|
+
case 3:
|
|
56
|
+
_a.sent();
|
|
57
|
+
return [2 /*return*/, console.log('🔒 SSL pinning initialized')];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}); };
|
|
61
|
+
exports.initializeSslPinning = initializeSslPinning;
|
|
@@ -11,6 +11,7 @@ interface ConsultationProviderProps {
|
|
|
11
11
|
theme?: RecursivePartial<Theme>;
|
|
12
12
|
components?: (theme: Theme) => Components;
|
|
13
13
|
onError?: ErrorCallback;
|
|
14
|
+
disableSslPinning?: boolean;
|
|
14
15
|
}
|
|
15
16
|
export type ConsultationContextProps = ConsultationProviderProps & {
|
|
16
17
|
consultation: Consultation | null;
|
|
@@ -23,5 +24,5 @@ export type ConsultationContextProps = ConsultationProviderProps & {
|
|
|
23
24
|
initialised: boolean;
|
|
24
25
|
};
|
|
25
26
|
export declare const ConsultationContext: import("react").Context<ConsultationContextProps>;
|
|
26
|
-
export declare const ConsultationProvider: ({ children, token, region, theme, components, onError }: PropsWithChildren<ConsultationProviderProps>) => import("react").JSX.Element;
|
|
27
|
+
export declare const ConsultationProvider: ({ children, token, region, theme, components, onError, disableSslPinning }: PropsWithChildren<ConsultationProviderProps>) => import("react").JSX.Element;
|
|
27
28
|
export {};
|
|
@@ -42,6 +42,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
42
42
|
exports.ConsultationProvider = exports.ConsultationContext = void 0;
|
|
43
43
|
var config_1 = require("../api/config");
|
|
44
44
|
var partner_1 = require("../api/partner");
|
|
45
|
+
var sslPinning_1 = require("../api/sslPinning");
|
|
45
46
|
var user_1 = require("../api/user");
|
|
46
47
|
var websocket_1 = require("../api/websocket");
|
|
47
48
|
var i18n_1 = __importDefault(require("../locale/i18n"));
|
|
@@ -49,6 +50,7 @@ var theme_1 = require("../types/theme");
|
|
|
49
50
|
var axios_1 = require("axios");
|
|
50
51
|
var react_1 = require("react");
|
|
51
52
|
var react_i18next_1 = require("react-i18next");
|
|
53
|
+
var react_native_ssl_public_key_pinning_1 = require("react-native-ssl-public-key-pinning");
|
|
52
54
|
var ThemeContext_1 = require("./ThemeContext");
|
|
53
55
|
// eslint-disable-next-line react-refresh/only-export-components
|
|
54
56
|
exports.ConsultationContext = (0, react_1.createContext)({
|
|
@@ -66,73 +68,83 @@ exports.ConsultationContext = (0, react_1.createContext)({
|
|
|
66
68
|
initialised: false
|
|
67
69
|
});
|
|
68
70
|
var ConsultationProvider = function (_a) {
|
|
69
|
-
var children = _a.children, token = _a.token, region = _a.region, theme = _a.theme, components = _a.components, _b = _a.onError, onError = _b === void 0 ? function () { } : _b;
|
|
70
|
-
var
|
|
71
|
-
var
|
|
72
|
-
var
|
|
73
|
-
var
|
|
74
|
-
var
|
|
75
|
-
var
|
|
71
|
+
var children = _a.children, token = _a.token, region = _a.region, theme = _a.theme, components = _a.components, _b = _a.onError, onError = _b === void 0 ? function () { } : _b, _c = _a.disableSslPinning, disableSslPinning = _c === void 0 ? false : _c;
|
|
72
|
+
var _d = (0, react_1.useState)(null), consultation = _d[0], setConsultation = _d[1];
|
|
73
|
+
var _e = (0, react_1.useState)(null), userId = _e[0], setUserId = _e[1];
|
|
74
|
+
var _f = (0, react_1.useState)(null), user = _f[0], setUser = _f[1];
|
|
75
|
+
var _g = (0, react_1.useState)(null), websocket = _g[0], setWebsocket = _g[1];
|
|
76
|
+
var _h = (0, react_1.useState)(null), slug = _h[0], setSlug = _h[1];
|
|
77
|
+
var _j = (0, react_1.useState)(false), initialised = _j[0], setInitialised = _j[1];
|
|
76
78
|
var handleError = function (e) {
|
|
77
79
|
console.error('🚨 Error caught on handler', e);
|
|
78
80
|
onError(e);
|
|
79
81
|
};
|
|
80
82
|
var initialise = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
81
|
-
var partnerInfo,
|
|
83
|
+
var e_1, partnerInfo, e_2, userResponse, e_3, activeConsultation, e_4, ws, e_5;
|
|
82
84
|
return __generator(this, function (_a) {
|
|
83
85
|
switch (_a.label) {
|
|
84
86
|
case 0:
|
|
85
87
|
_a.trys.push([0, 2, , 3]);
|
|
86
|
-
return [4 /*yield*/, (0,
|
|
88
|
+
return [4 /*yield*/, (0, sslPinning_1.initializeSslPinning)(disableSslPinning)];
|
|
87
89
|
case 1:
|
|
88
|
-
|
|
89
|
-
setSlug(partnerInfo.slug);
|
|
90
|
+
_a.sent();
|
|
90
91
|
return [3 /*break*/, 3];
|
|
91
92
|
case 2:
|
|
92
93
|
e_1 = _a.sent();
|
|
93
|
-
console.error('Error
|
|
94
|
+
console.error('Error initializing SSL pinning', e_1);
|
|
94
95
|
throw e_1;
|
|
95
96
|
case 3:
|
|
96
97
|
_a.trys.push([3, 5, , 6]);
|
|
97
|
-
return [4 /*yield*/, (0,
|
|
98
|
+
return [4 /*yield*/, (0, partner_1.getPartnerInfo)()];
|
|
98
99
|
case 4:
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
partnerInfo = _a.sent();
|
|
101
|
+
setSlug(partnerInfo.slug);
|
|
101
102
|
return [3 /*break*/, 6];
|
|
102
103
|
case 5:
|
|
103
104
|
e_2 = _a.sent();
|
|
104
|
-
console.error('Error getting
|
|
105
|
+
console.error('Error getting partner info', e_2);
|
|
105
106
|
throw e_2;
|
|
106
107
|
case 6:
|
|
107
108
|
_a.trys.push([6, 8, , 9]);
|
|
108
|
-
return [4 /*yield*/, (0, user_1.
|
|
109
|
+
return [4 /*yield*/, (0, user_1.getUser)({ userId: userId })];
|
|
109
110
|
case 7:
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
setConsultation(activeConsultation === null || activeConsultation === void 0 ? void 0 : activeConsultation.consultation);
|
|
111
|
+
userResponse = _a.sent();
|
|
112
|
+
setUser(userResponse);
|
|
113
113
|
return [3 /*break*/, 9];
|
|
114
114
|
case 8:
|
|
115
115
|
e_3 = _a.sent();
|
|
116
|
-
|
|
116
|
+
console.error('Error getting user', e_3);
|
|
117
|
+
throw e_3;
|
|
118
|
+
case 9:
|
|
119
|
+
_a.trys.push([9, 11, , 12]);
|
|
120
|
+
return [4 /*yield*/, (0, user_1.getActiveConsultation)({ userId: userId })];
|
|
121
|
+
case 10:
|
|
122
|
+
activeConsultation = _a.sent();
|
|
123
|
+
console.log('⏮️ Active:', activeConsultation.consultation);
|
|
124
|
+
setConsultation(activeConsultation === null || activeConsultation === void 0 ? void 0 : activeConsultation.consultation);
|
|
125
|
+
return [3 /*break*/, 12];
|
|
126
|
+
case 11:
|
|
127
|
+
e_4 = _a.sent();
|
|
128
|
+
if ((0, axios_1.isAxiosError)(e_4) && e_4.status === 404) {
|
|
117
129
|
setConsultation(null);
|
|
118
130
|
}
|
|
119
131
|
else {
|
|
120
|
-
console.error('Error getting active consultation',
|
|
121
|
-
throw
|
|
132
|
+
console.error('Error getting active consultation', e_4);
|
|
133
|
+
throw e_4;
|
|
122
134
|
}
|
|
123
|
-
return [3 /*break*/,
|
|
124
|
-
case
|
|
125
|
-
_a.trys.push([
|
|
135
|
+
return [3 /*break*/, 12];
|
|
136
|
+
case 12:
|
|
137
|
+
_a.trys.push([12, 14, , 15]);
|
|
126
138
|
return [4 /*yield*/, (0, websocket_1.connectWebsocket)({ token: token, userId: userId, region: region })];
|
|
127
|
-
case
|
|
139
|
+
case 13:
|
|
128
140
|
ws = _a.sent();
|
|
129
141
|
setWebsocket(ws);
|
|
130
|
-
return [3 /*break*/,
|
|
131
|
-
case
|
|
132
|
-
|
|
133
|
-
console.error('Error connecting to websocket',
|
|
134
|
-
throw
|
|
135
|
-
case
|
|
142
|
+
return [3 /*break*/, 15];
|
|
143
|
+
case 14:
|
|
144
|
+
e_5 = _a.sent();
|
|
145
|
+
console.error('Error connecting to websocket', e_5);
|
|
146
|
+
throw e_5;
|
|
147
|
+
case 15: return [2 /*return*/];
|
|
136
148
|
}
|
|
137
149
|
});
|
|
138
150
|
}); };
|
|
@@ -145,7 +157,8 @@ var ConsultationProvider = function (_a) {
|
|
|
145
157
|
var method = config.method, url = config.url, data = config.data;
|
|
146
158
|
console.log({
|
|
147
159
|
service: 'API Rest',
|
|
148
|
-
message: "".concat(method === null || method === void 0 ? void 0 : method.toUpperCase(), " ").concat(url, " ").concat(data !== undefined ? "- body: ".concat(JSON.stringify(data)) : ' ')
|
|
160
|
+
message: "".concat(method === null || method === void 0 ? void 0 : method.toUpperCase(), " ").concat(url, " ").concat(data !== undefined ? "- body: ".concat(JSON.stringify(data)) : ' '),
|
|
161
|
+
headers: config.headers
|
|
149
162
|
});
|
|
150
163
|
return config;
|
|
151
164
|
});
|
|
@@ -190,6 +203,10 @@ var ConsultationProvider = function (_a) {
|
|
|
190
203
|
(0, websocket_1.connectWebsocket)({ token: token, userId: userId, region: region }).then(setWebsocket).catch(handleError);
|
|
191
204
|
};
|
|
192
205
|
}, [websocket]);
|
|
206
|
+
(0, react_1.useEffect)(function () {
|
|
207
|
+
var subscription = (0, react_native_ssl_public_key_pinning_1.addSslPinningErrorListener)(console.error);
|
|
208
|
+
return function () { return subscription.remove(); };
|
|
209
|
+
}, []);
|
|
193
210
|
var value = {
|
|
194
211
|
token: token,
|
|
195
212
|
region: region,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abihealth/goapp-react-native",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.22.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"react-native-bouncy-checkbox": "4.1.2",
|
|
24
24
|
"react-native-date-picker": "5.0.1",
|
|
25
25
|
"react-native-phone-input": "1.3.7",
|
|
26
|
-
"react-native-svg": "15.11.1",
|
|
26
|
+
"react-native-svg": "^15.11.1",
|
|
27
|
+
"react-native-ssl-public-key-pinning": "^1.2.5",
|
|
27
28
|
"zod": "3.24.1"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|