react-native-mytatva-rn-sdk 1.0.0 → 1.2.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.
Files changed (228) hide show
  1. package/android/app/build.gradle +5 -0
  2. package/android/build.gradle +5 -5
  3. package/android/gradle.properties +13 -5
  4. package/android/settings.gradle +9 -0
  5. package/android/src/main/AndroidManifest.xml +22 -1
  6. package/android/src/main/AndroidManifestNew.xml +59 -1
  7. package/android/src/main/java/com/{visitrnsdk/VisitRnSdkPackage.kt → mytatvarnsdk/MyTatvaRnSdkPackage.kt} +2 -2
  8. package/android/src/main/java/com/{visitrnsdk/VisitRnSdkViewManager.kt → mytatvarnsdk/MyTatvaRnSdkViewManager.kt} +1 -1
  9. package/lib/commonjs/BcaDeviceListSheet.js +286 -0
  10. package/lib/commonjs/BcaDeviceListSheet.js.map +1 -0
  11. package/lib/commonjs/MainWebView.js +68 -0
  12. package/lib/commonjs/MainWebView.js.map +1 -0
  13. package/lib/commonjs/ProgressWebView.js +547 -0
  14. package/lib/commonjs/ProgressWebView.js.map +1 -0
  15. package/lib/commonjs/Services.js +27 -1
  16. package/lib/commonjs/Services.js.map +1 -1
  17. package/lib/commonjs/Sheets.js +7 -0
  18. package/lib/commonjs/Sheets.js.map +1 -0
  19. package/lib/commonjs/api/auth.js +167 -0
  20. package/lib/commonjs/api/auth.js.map +1 -0
  21. package/lib/commonjs/api/base.js +224 -0
  22. package/lib/commonjs/api/base.js.map +1 -0
  23. package/lib/commonjs/api/index.js +12 -0
  24. package/lib/commonjs/api/index.js.map +1 -0
  25. package/lib/commonjs/assets/icons/achieve.svg +3 -0
  26. package/lib/commonjs/assets/icons/heart.svg +3 -0
  27. package/lib/commonjs/assets/icons/smartWatch.svg +3 -0
  28. package/lib/commonjs/constants/asyncstorage.js +29 -0
  29. package/lib/commonjs/constants/asyncstorage.js.map +1 -0
  30. package/lib/commonjs/constants/constants.js +1373 -0
  31. package/lib/commonjs/constants/constants.js.map +1 -0
  32. package/lib/commonjs/constants.js +12 -2
  33. package/lib/commonjs/constants.js.map +1 -1
  34. package/lib/commonjs/helpers/Matrics.js +49 -0
  35. package/lib/commonjs/helpers/Matrics.js.map +1 -0
  36. package/lib/commonjs/helpers/bluetoothPermissionHelper.js +114 -0
  37. package/lib/commonjs/helpers/bluetoothPermissionHelper.js.map +1 -0
  38. package/lib/commonjs/helpers/colors.js +304 -0
  39. package/lib/commonjs/helpers/colors.js.map +1 -0
  40. package/lib/commonjs/helpers/common.js +46 -0
  41. package/lib/commonjs/helpers/common.js.map +1 -0
  42. package/lib/commonjs/helpers/fonts.js +33 -0
  43. package/lib/commonjs/helpers/fonts.js.map +1 -0
  44. package/lib/commonjs/helpers/globalStyles.js +188 -0
  45. package/lib/commonjs/helpers/globalStyles.js.map +1 -0
  46. package/lib/commonjs/helpers/icons.js +16 -0
  47. package/lib/commonjs/helpers/icons.js.map +1 -0
  48. package/lib/commonjs/index.android.js +163 -414
  49. package/lib/commonjs/index.android.js.map +1 -1
  50. package/lib/commonjs/index.ios.js +138 -187
  51. package/lib/commonjs/index.ios.js.map +1 -1
  52. package/lib/commonjs/redux/Store.js +42 -0
  53. package/lib/commonjs/redux/Store.js.map +1 -0
  54. package/lib/commonjs/redux/hooks.js +8 -0
  55. package/lib/commonjs/redux/hooks.js.map +1 -0
  56. package/lib/commonjs/redux/sagas/AuthSaga.js +44 -0
  57. package/lib/commonjs/redux/sagas/AuthSaga.js.map +1 -0
  58. package/lib/commonjs/redux/sagas/index.js +15 -0
  59. package/lib/commonjs/redux/sagas/index.js.map +1 -0
  60. package/lib/commonjs/redux/slices/authSlice.js +80 -0
  61. package/lib/commonjs/redux/slices/authSlice.js.map +1 -0
  62. package/lib/commonjs/redux/slices/index.js +44 -0
  63. package/lib/commonjs/redux/slices/index.js.map +1 -0
  64. package/lib/commonjs/types/auth.js +2 -0
  65. package/lib/commonjs/types/auth.js.map +1 -0
  66. package/lib/commonjs/types/common.js +2 -0
  67. package/lib/commonjs/types/common.js.map +1 -0
  68. package/lib/commonjs/types/index.js +13 -0
  69. package/lib/commonjs/types/index.js.map +1 -0
  70. package/lib/module/BcaDeviceListSheet.js +277 -0
  71. package/lib/module/BcaDeviceListSheet.js.map +1 -0
  72. package/lib/module/MainWebView.js +61 -0
  73. package/lib/module/MainWebView.js.map +1 -0
  74. package/lib/module/ProgressWebView.js +536 -0
  75. package/lib/module/ProgressWebView.js.map +1 -0
  76. package/lib/module/Services.js +24 -0
  77. package/lib/module/Services.js.map +1 -1
  78. package/lib/module/Sheets.js +4 -0
  79. package/lib/module/Sheets.js.map +1 -0
  80. package/lib/module/api/auth.js +160 -0
  81. package/lib/module/api/auth.js.map +1 -0
  82. package/lib/module/api/base.js +212 -0
  83. package/lib/module/api/base.js.map +1 -0
  84. package/lib/module/api/index.js +5 -0
  85. package/lib/module/api/index.js.map +1 -0
  86. package/lib/module/assets/icons/achieve.svg +3 -0
  87. package/lib/module/assets/icons/heart.svg +3 -0
  88. package/lib/module/assets/icons/smartWatch.svg +3 -0
  89. package/lib/module/constants/asyncstorage.js +23 -0
  90. package/lib/module/constants/asyncstorage.js.map +1 -0
  91. package/lib/module/constants/constants.js +1367 -0
  92. package/lib/module/constants/constants.js.map +1 -0
  93. package/lib/module/constants.js +12 -2
  94. package/lib/module/constants.js.map +1 -1
  95. package/lib/module/helpers/Matrics.js +44 -0
  96. package/lib/module/helpers/Matrics.js.map +1 -0
  97. package/lib/module/helpers/bluetoothPermissionHelper.js +103 -0
  98. package/lib/module/helpers/bluetoothPermissionHelper.js.map +1 -0
  99. package/lib/module/helpers/colors.js +298 -0
  100. package/lib/module/helpers/colors.js.map +1 -0
  101. package/lib/module/helpers/common.js +34 -0
  102. package/lib/module/helpers/common.js.map +1 -0
  103. package/lib/module/helpers/fonts.js +27 -0
  104. package/lib/module/helpers/fonts.js.map +1 -0
  105. package/lib/module/helpers/globalStyles.js +181 -0
  106. package/lib/module/helpers/globalStyles.js.map +1 -0
  107. package/lib/module/helpers/icons.js +9 -0
  108. package/lib/module/helpers/icons.js.map +1 -0
  109. package/lib/module/index.android.js +165 -413
  110. package/lib/module/index.android.js.map +1 -1
  111. package/lib/module/index.ios.js +138 -187
  112. package/lib/module/index.ios.js.map +1 -1
  113. package/lib/module/redux/Store.js +34 -0
  114. package/lib/module/redux/Store.js.map +1 -0
  115. package/lib/module/redux/hooks.js +7 -0
  116. package/lib/module/redux/hooks.js.map +1 -0
  117. package/lib/module/redux/sagas/AuthSaga.js +34 -0
  118. package/lib/module/redux/sagas/AuthSaga.js.map +1 -0
  119. package/lib/module/redux/sagas/index.js +8 -0
  120. package/lib/module/redux/sagas/index.js.map +1 -0
  121. package/lib/module/redux/slices/authSlice.js +68 -0
  122. package/lib/module/redux/slices/authSlice.js.map +1 -0
  123. package/lib/module/redux/slices/index.js +24 -0
  124. package/lib/module/redux/slices/index.js.map +1 -0
  125. package/lib/module/types/auth.js +2 -0
  126. package/lib/module/types/auth.js.map +1 -0
  127. package/lib/module/types/common.js +2 -0
  128. package/lib/module/types/common.js.map +1 -0
  129. package/lib/module/types/index.js +4 -0
  130. package/lib/module/types/index.js.map +1 -0
  131. package/lib/typescript/BcaDeviceListSheet.d.ts +7 -0
  132. package/lib/typescript/BcaDeviceListSheet.d.ts.map +1 -0
  133. package/lib/typescript/MainWebView.d.ts +4 -0
  134. package/lib/typescript/MainWebView.d.ts.map +1 -0
  135. package/lib/typescript/ProgressWebView.d.ts +4 -0
  136. package/lib/typescript/ProgressWebView.d.ts.map +1 -0
  137. package/lib/typescript/Services.d.ts +5 -0
  138. package/lib/typescript/Services.d.ts.map +1 -0
  139. package/lib/typescript/Sheets.d.ts +2 -0
  140. package/lib/typescript/Sheets.d.ts.map +1 -0
  141. package/lib/typescript/api/auth.d.ts +33 -0
  142. package/lib/typescript/api/auth.d.ts.map +1 -0
  143. package/lib/typescript/api/base.d.ts +20 -0
  144. package/lib/typescript/api/base.d.ts.map +1 -0
  145. package/lib/typescript/api/index.d.ts +35 -0
  146. package/lib/typescript/api/index.d.ts.map +1 -0
  147. package/lib/typescript/constants/asyncstorage.d.ts +23 -0
  148. package/lib/typescript/constants/asyncstorage.d.ts.map +1 -0
  149. package/lib/typescript/constants/constants.d.ts +1081 -0
  150. package/lib/typescript/constants/constants.d.ts.map +1 -0
  151. package/lib/typescript/constants.d.ts +16 -0
  152. package/lib/typescript/constants.d.ts.map +1 -0
  153. package/lib/typescript/helpers/Matrics.d.ts +14 -0
  154. package/lib/typescript/helpers/Matrics.d.ts.map +1 -0
  155. package/lib/typescript/helpers/bluetoothPermissionHelper.d.ts +18 -0
  156. package/lib/typescript/helpers/bluetoothPermissionHelper.d.ts.map +1 -0
  157. package/lib/typescript/helpers/colors.d.ts +297 -0
  158. package/lib/typescript/helpers/colors.d.ts.map +1 -0
  159. package/lib/typescript/helpers/common.d.ts +8 -0
  160. package/lib/typescript/helpers/common.d.ts.map +1 -0
  161. package/lib/typescript/helpers/fonts.d.ts +23 -0
  162. package/lib/typescript/helpers/fonts.d.ts.map +1 -0
  163. package/lib/typescript/helpers/globalStyles.d.ts +176 -0
  164. package/lib/typescript/helpers/globalStyles.d.ts.map +1 -0
  165. package/lib/typescript/helpers/icons.d.ts +6 -0
  166. package/lib/typescript/helpers/icons.d.ts.map +1 -0
  167. package/lib/typescript/index.android.d.ts +30 -0
  168. package/lib/typescript/index.android.d.ts.map +1 -0
  169. package/lib/typescript/index.ios.d.ts +28 -0
  170. package/lib/typescript/index.ios.d.ts.map +1 -0
  171. package/lib/typescript/redux/Store.d.ts +13 -0
  172. package/lib/typescript/redux/Store.d.ts.map +1 -0
  173. package/lib/typescript/redux/hooks.d.ts +1 -0
  174. package/lib/typescript/redux/hooks.d.ts.map +1 -0
  175. package/lib/typescript/redux/sagas/AuthSaga.d.ts +3 -0
  176. package/lib/typescript/redux/sagas/AuthSaga.d.ts.map +1 -0
  177. package/lib/typescript/redux/sagas/index.d.ts +3 -0
  178. package/lib/typescript/redux/sagas/index.d.ts.map +1 -0
  179. package/lib/typescript/redux/slices/authSlice.d.ts +5 -0
  180. package/lib/typescript/redux/slices/authSlice.d.ts.map +1 -0
  181. package/lib/typescript/redux/slices/index.d.ts +6 -0
  182. package/lib/typescript/redux/slices/index.d.ts.map +1 -0
  183. package/lib/typescript/types/auth.d.ts +485 -0
  184. package/lib/typescript/types/auth.d.ts.map +1 -0
  185. package/lib/typescript/types/common.d.ts +19 -0
  186. package/lib/typescript/types/common.d.ts.map +1 -0
  187. package/lib/typescript/types/index.d.ts +4 -0
  188. package/lib/typescript/types/index.d.ts.map +1 -0
  189. package/package.json +38 -8
  190. package/src/BcaDeviceListSheet.tsx +331 -0
  191. package/src/MainWebView.tsx +67 -0
  192. package/src/ProgressWebView.tsx +602 -0
  193. package/src/Services.js +40 -0
  194. package/src/Sheets.js +4 -0
  195. package/src/api/auth.ts +156 -0
  196. package/src/api/base.ts +247 -0
  197. package/src/api/index.ts +5 -0
  198. package/src/assets/icons/achieve.svg +3 -0
  199. package/src/assets/icons/heart.svg +3 -0
  200. package/src/assets/icons/smartWatch.svg +3 -0
  201. package/src/constants/asyncstorage.ts +23 -0
  202. package/src/constants/constants.ts +1204 -0
  203. package/src/constants.ts +14 -0
  204. package/src/helpers/Matrics.ts +48 -0
  205. package/src/helpers/bluetoothPermissionHelper.ts +198 -0
  206. package/src/helpers/colors.ts +320 -0
  207. package/src/helpers/common.ts +46 -0
  208. package/src/helpers/fonts.ts +28 -0
  209. package/src/helpers/globalStyles.ts +179 -0
  210. package/src/helpers/icons.ts +11 -0
  211. package/src/index.android.js +164 -577
  212. package/src/index.ios.js +147 -215
  213. package/src/redux/Store.ts +36 -0
  214. package/src/redux/hooks.ts +6 -0
  215. package/src/redux/sagas/AuthSaga.ts +49 -0
  216. package/src/redux/sagas/index.ts +9 -0
  217. package/src/redux/slices/authSlice.ts +81 -0
  218. package/src/redux/slices/index.ts +29 -0
  219. package/src/types/auth.ts +533 -0
  220. package/src/types/common.ts +19 -0
  221. package/src/types/index.ts +8 -0
  222. package/lib/typescript/index.test.d.ts +0 -1
  223. package/lib/typescript/index.test.d.ts.map +0 -1
  224. package/src/constants.js +0 -4
  225. /package/ios/{VisitRnSdk.xcodeproj → MyTatvaRnSdk.xcodeproj}/project.pbxproj +0 -0
  226. /package/ios/{VisitRnSdkViewManager.h → MyTatvaRnSdkViewManager.h} +0 -0
  227. /package/ios/{VisitRnSdkViewManager.m → MyTatvaRnSdkViewManager.m} +0 -0
  228. /package/{react-native-visit-rn-sdk.podspec → react-native-mytatva-rn-sdk.podspec} +0 -0
@@ -0,0 +1,156 @@
1
+ import Ajax from './base';
2
+
3
+ const Auth = {
4
+ sendOtp: (data?: {payload?: object; headers?: object}) => {
5
+ const {payload, headers} = data || {};
6
+ const route = '/otp/send';
7
+ return Ajax.request(route, {
8
+ method: Ajax.POST,
9
+ priv: false,
10
+ isEncrypted: true,
11
+ payload,
12
+ headers,
13
+ });
14
+ },
15
+ verifyOtp: (data?: {payload?: object; headers?: object}) => {
16
+ const {payload, headers} = data || {};
17
+ const route = '/otp/verify';
18
+ return Ajax.request(route, {
19
+ method: Ajax.POST,
20
+ priv: false,
21
+ isEncrypted: true,
22
+ payload,
23
+ headers,
24
+ });
25
+ },
26
+ getOnboardingData: (payload?: object) => {
27
+ const route = '/patient/onbording_signup_data';
28
+ return Ajax.request(route, {
29
+ method: Ajax.POST,
30
+ priv: false,
31
+ payload,
32
+ });
33
+ },
34
+ loginSendOtp: (payload: object) => {
35
+ const route = '/patient/login_send_otp';
36
+ return Ajax.request(route, {
37
+ method: Ajax.POST,
38
+ priv: false,
39
+ payload,
40
+ });
41
+ },
42
+ sendSignUpOtp: (payload: object) => {
43
+ const route = '/patient/send_otp_signup';
44
+ return Ajax.request(route, {
45
+ method: Ajax.POST,
46
+ priv: false,
47
+ payload,
48
+ });
49
+ },
50
+ verifyOTPSignUp: (payload: object) => {
51
+ const route = '/patient/verify_otp_signup';
52
+ return Ajax.request(route, {
53
+ method: Ajax.POST,
54
+ priv: false,
55
+ payload,
56
+ });
57
+ },
58
+ verifyOTPLogin: (payload: object) => {
59
+ const route = '/patient/login_verify_otp';
60
+ return Ajax.request(route, {
61
+ method: Ajax.POST,
62
+ priv: false,
63
+ payload,
64
+ });
65
+ },
66
+ updateSignupStep: (payload: object) => {
67
+ const route = '/patient/update_signup_for';
68
+ return Ajax.request(route, {
69
+ method: Ajax.POST,
70
+ priv: true,
71
+ payload,
72
+ });
73
+ },
74
+ tempPatientSignUp: (payload: object) => {
75
+ const route = '/patient/register_temp_patient_profile';
76
+ return Ajax.request(route, {
77
+ method: Ajax.POST,
78
+ priv: true,
79
+ payload,
80
+ });
81
+ },
82
+ authenticateUser: (requestObj: {payload: object, environment: string}) => {
83
+ const payload = requestObj?.payload;
84
+ const environment = requestObj?.environment;
85
+ const route = '/patient/login_or_register_patient';
86
+ return Ajax.request(route, {
87
+ method: Ajax.POST,
88
+ priv: false,
89
+ payload,
90
+ environment: environment,
91
+ });
92
+ },
93
+
94
+ medicalConditionGroupList: (payload: object) => {
95
+ const route = '/patient/medical_condition_group_list';
96
+ return Ajax.request(route, {
97
+ method: Ajax.POST,
98
+ priv: false,
99
+ payload,
100
+ });
101
+ },
102
+
103
+ registerPatient: (data: {payload?: object; headers?: object}) => {
104
+ const {payload, headers} = data || {};
105
+ const route = '/patient/register';
106
+ return Ajax.request(route, {
107
+ method: Ajax.POST,
108
+ priv: false,
109
+ payload,
110
+ headers,
111
+ });
112
+ },
113
+
114
+ verifyDoctorCode: (payload: object) => {
115
+ const route = '/patient/verify_doctor_access_code';
116
+ return Ajax.request(route, {
117
+ method: Ajax.POST,
118
+ priv: true,
119
+ payload,
120
+ });
121
+ },
122
+
123
+ updateDeviceInfo: (payload: object) => {
124
+ const route = '/patient/update_device_info';
125
+ return Ajax.request(route, {
126
+ method: Ajax.POST,
127
+ priv: true,
128
+ payload,
129
+ });
130
+ },
131
+
132
+ getPatientDetails: (payload: object) => {
133
+ const route = '/patient/get_patient_details';
134
+ return Ajax.request(route, {
135
+ method: Ajax.POST,
136
+ priv: true,
137
+ payload,
138
+ });
139
+ },
140
+ getUserStatusApi: (payload: object) => {
141
+ const route = '/Patient/get_patient_source';
142
+ return Ajax.request(route, {
143
+ method: Ajax.POST,
144
+ priv: true,
145
+ payload,
146
+ });
147
+ },
148
+ getUserMetaInfo: (payload: any) => {
149
+ const route = `/patient/get_patient_meta_info?get_bca_readings=${payload?.get_bca_readings}`;
150
+ return Ajax.request(route, {
151
+ method: Ajax.GET,
152
+ priv: true,
153
+ });
154
+ },
155
+ };
156
+ export default Auth;
@@ -0,0 +1,247 @@
1
+ import {Alert, DeviceEventEmitter, Platform} from 'react-native';
2
+ import CRYPTO from 'crypto-js';
3
+ import DeviceInfo from 'react-native-device-info';
4
+ // import AsyncStorage from '@react-native-async-storage/async-storage';
5
+
6
+ // import ASYNC_STORAGE from '../constants/asyncstorage';
7
+ import {checkStringTypeOf} from '../helpers/common';
8
+ import constants from '../constants';
9
+
10
+ const POST = 'post';
11
+ const GET = 'get';
12
+ const PUT = 'put';
13
+ const PATCH = 'patch';
14
+ const DELETE = 'delete';
15
+ const DEFAULT_ERROR = 'Something went wrong, Please try again later';
16
+
17
+ let isHandlingSessionExpiration = false;
18
+ const SESSION_EXPIRATION_COOLDOWN = 1000; // 1 second cooldown
19
+
20
+ export const getEncryptedText = (data: any, environment: string) => {
21
+ var truncHexKey = CRYPTO.SHA256(environment.toUpperCase() === 'PROD' ? constants.PROD_ENC_KEY : constants.STAG_ENC_KEY ?? '')
22
+ .toString()
23
+ .substr(0, 32); // hex encode and truncate
24
+
25
+ var key = CRYPTO.enc.Utf8.parse(truncHexKey);
26
+
27
+ var iv = CRYPTO.enc.Utf8.parse(environment.toUpperCase() === 'PROD' ? constants.PROD_ENC_IV : constants.STAGE_ENC_IV ?? '');
28
+
29
+ var ciphertext = CRYPTO.AES.encrypt(JSON.stringify(data), key, {
30
+ iv: iv,
31
+ mode: CRYPTO.mode.CBC,
32
+ });
33
+
34
+ return ciphertext.toString();
35
+ };
36
+
37
+ export const getDecryptedData = (cipher: string, environment: string) => {
38
+ var truncHexKey = CRYPTO.SHA256(environment.toUpperCase() === 'PROD' ? constants.PROD_ENC_KEY : constants.STAG_ENC_KEY ?? '')
39
+ .toString()
40
+ .substr(0, 32); // hex encode and truncate
41
+
42
+ var key = CRYPTO.enc.Utf8.parse(truncHexKey);
43
+
44
+ var iv = CRYPTO.enc.Utf8.parse(environment.toUpperCase() === 'PROD' ? constants.PROD_ENC_IV : constants.STAGE_ENC_IV ?? '');
45
+
46
+ var decryptedData = CRYPTO.AES.decrypt(cipher, key, {
47
+ iv: iv,
48
+ mode: CRYPTO.mode.CBC,
49
+ });
50
+
51
+ return decryptedData.toString(CRYPTO.enc.Utf8);
52
+ };
53
+
54
+ export const getToken = async () => {
55
+ // try {
56
+ // const token = await AsyncStorage.getItem(ASYNC_STORAGE?.ACCESS_TOKEN);
57
+ // if (token !== null) {
58
+ // // token previously stored
59
+ // return token;
60
+ // }
61
+ // } catch (e) {
62
+ // throw new Error('Token not found or could not be retrieved');
63
+ // }
64
+ };
65
+
66
+ export const handleResponse = async (response: any, isEncrypted: boolean, environment: string) => {
67
+ const contentType = response.headers.get('Content-Type');
68
+
69
+ if (contentType) {
70
+ let resp: any = null;
71
+ if (contentType.indexOf('application/json') !== -1) {
72
+ resp = await response.json();
73
+ } else if (contentType && contentType.indexOf('text/html') !== -1) {
74
+ resp = await response.text();
75
+ }
76
+
77
+ if (!isEncrypted) return resp;
78
+
79
+ const parsed = await JSON.parse(getDecryptedData(resp, environment));
80
+ // const {Auth} = Store.getState();
81
+
82
+ if (Number(parsed?.code) == 1) {
83
+ return parsed;
84
+ } else if (parsed?.code == -1) {
85
+ DeviceEventEmitter.emit('session_expired');
86
+ return parsed;
87
+ } else {
88
+ return parsed;
89
+ }
90
+ } else {
91
+ return response.text();
92
+ }
93
+ };
94
+
95
+ const request: any = async (
96
+ route: string,
97
+ {
98
+ baseURL = constants.STAGE_BASE_URL,
99
+ environment = 'uat',
100
+ method = GET,
101
+ payload = null,
102
+ formData = null,
103
+ headers = {} as any,
104
+ json = true,
105
+ priv = true,
106
+ isEncrypted = true,
107
+ content_type = null,
108
+ isVisitEncrypted = false,
109
+ },
110
+ ) => {
111
+ baseURL = environment.toUpperCase() === 'PROD' ? constants.PROD_BASE_URL : constants.STAGE_BASE_URL
112
+ const activeVersion = DeviceInfo.getVersion(); // return "0.0.2"
113
+ const activeBuildNumber = DeviceInfo.getBuildNumber(); // return 2
114
+ const appVersion = `${Platform.OS} ${activeVersion}-${activeBuildNumber}`;
115
+
116
+ console.log("baseee urlss", baseURL)
117
+
118
+ let init = {
119
+ method: method,
120
+ headers: {
121
+ 'api-key': environment.toUpperCase() === 'PROD' ? constants.PROD_API_KEY : constants.STAGE_API_KEY,
122
+ userFrom: 'GoodFlip', // This has to be set to "PSP" incase of user is from PSP. This will be sent from register API.
123
+ source: 'GoodFlip',
124
+ appVersion: appVersion,
125
+ platform: 'app',
126
+ ...headers,
127
+ },
128
+ body: '',
129
+ };
130
+
131
+ // const {Auth} = Store.getState();
132
+
133
+ if (formData) {
134
+ init = {
135
+ ...init,
136
+ headers: {
137
+ ...init.headers,
138
+ 'content-type': 'multipart/form-data',
139
+ },
140
+ body: formData,
141
+ };
142
+ }
143
+
144
+ if (payload) {
145
+ init = {
146
+ ...init,
147
+ headers: {
148
+ ...init.headers,
149
+ },
150
+ body: getEncryptedText(payload, environment),
151
+ };
152
+ }
153
+ if (content_type) init.headers['Content-Type'] = content_type;
154
+
155
+ // if (priv && Auth.user.data?.token) {
156
+ // init.headers = {
157
+ // ...init.headers,
158
+ // token: Auth.user.data?.token,
159
+ // };
160
+ // }
161
+
162
+ return fetch(`${baseURL}${route}`, init)
163
+ .then(async res => {
164
+ if (res.status === 401) {
165
+ handleSessionExpired();
166
+ throw new Error('Unauthorized');
167
+ }
168
+
169
+ if (!json) {
170
+ return res;
171
+ }
172
+
173
+ res = await handleResponse(res, isVisitEncrypted ? false : isEncrypted, environment);
174
+ return res;
175
+ })
176
+ .catch(async error => {
177
+ // Remove decryption attempt on error as it may not be encrypted
178
+ if (error.message === 'Unauthorized') {
179
+ // Reject the promise for 401 errors
180
+ throw error;
181
+ }
182
+ throw error; // Re-throw other errors to be handled by the caller
183
+ });
184
+ };
185
+
186
+ const handleError = (error: any, msg = DEFAULT_ERROR) => {
187
+ let errMsg = msg;
188
+
189
+ // exception string error
190
+ if (typeof msg === 'string') {
191
+ Alert.alert('Alert', checkStringTypeOf(msg));
192
+ return {
193
+ status: error?.status || 500,
194
+ message: errMsg,
195
+ };
196
+ }
197
+
198
+ switch (error?.status) {
199
+ default:
200
+ errMsg = DEFAULT_ERROR;
201
+ }
202
+
203
+ Alert.alert('Alert', JSON.stringify(errMsg));
204
+ return {
205
+ status: error?.status,
206
+ message: errMsg,
207
+ };
208
+ };
209
+
210
+ const handleSessionExpired = () => {
211
+ if (isHandlingSessionExpiration) {
212
+ return {
213
+ code: -1,
214
+ message: 'Session expired',
215
+ };
216
+ }
217
+
218
+ isHandlingSessionExpiration = true;
219
+
220
+ // Use setTimeout to ensure state updates complete before navigation
221
+ setTimeout(() => {
222
+ DeviceEventEmitter.emit('session_expired');
223
+ }, 0);
224
+
225
+ // Reset the flag after cooldown period
226
+ setTimeout(() => {
227
+ isHandlingSessionExpiration = false;
228
+ }, SESSION_EXPIRATION_COOLDOWN);
229
+
230
+ return {
231
+ code: -1,
232
+ message: 'Session expired',
233
+ };
234
+ };
235
+
236
+
237
+ export default {
238
+ POST,
239
+ PUT,
240
+ PATCH,
241
+ GET,
242
+ DELETE,
243
+ request,
244
+ handleResponse,
245
+ handleError,
246
+ getToken,
247
+ };
@@ -0,0 +1,5 @@
1
+ import auth from './auth';
2
+
3
+ export default {
4
+ auth,
5
+ };
@@ -0,0 +1,3 @@
1
+ <svg width="12" height="15" viewBox="0 0 12 15" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M8.16873 0.833374C8.94092 0.833374 9.57683 1.41687 9.65961 2.167L10.5048 2.16671C11.1169 2.16671 11.6189 2.63811 11.6676 3.23769L11.6714 3.33337V5.33337C11.6714 6.48873 10.7671 7.43287 9.62772 7.49661L9.48753 7.50053C9.04232 8.894 7.82191 9.94105 6.33348 10.1345L6.33307 11.1667H7.50206C8.65742 11.1667 9.60156 12.071 9.6653 13.2104L9.66873 13.3334V13.6667C9.66873 13.9198 9.48063 14.129 9.23658 14.1621L9.16873 14.1667H2.50005C2.24692 14.1667 2.03772 13.9786 2.00461 13.7346L2.00005 13.6667V13.3334C2.00005 12.178 2.90435 11.2339 4.04377 11.1701L4.16671 11.1667H5.33307L5.3333 10.1343C3.84577 9.94011 2.62626 8.89337 2.18124 7.50053L2.16374 7.50004C0.96712 7.50004 -0.00292969 6.52999 -0.00292969 5.33337V3.33337C-0.00292969 2.68904 0.519405 2.16671 1.16374 2.16671L2.00917 2.167C2.09194 1.41687 2.72785 0.833374 3.50005 0.833374H8.16873ZM10.5048 3.16671H9.66873V6.48861C10.2021 6.41359 10.6197 5.97792 10.667 5.43614L10.6714 5.33337V3.33337C10.6714 3.25448 10.6166 3.18838 10.543 3.17111L10.5048 3.16671ZM2.00005 3.16671H1.16374C1.07169 3.16671 0.99707 3.24133 0.99707 3.33337V5.33337C0.99707 5.92215 1.43321 6.40906 2.00005 6.48865V3.16671Z"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="17" height="17" viewBox="0 0 17 17" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M9.04661 4.21978L8.49946 4.76812L7.95063 4.21928C6.55125 2.8199 4.28241 2.8199 2.88303 4.21928C1.48365 5.61866 1.48365 7.8875 2.88303 9.28688L8.14661 14.5505C8.34187 14.7457 8.65845 14.7457 8.85372 14.5505L14.1214 9.28591C15.5176 7.88189 15.52 5.61941 14.1204 4.21978C12.7185 2.81785 10.4485 2.81785 9.04661 4.21978Z"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="16" height="17" viewBox="0 0 16 17" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M6.33333 1.83325C5.59695 1.83325 5 2.43021 5 3.16659V4.02709C5.30881 3.90209 5.64637 3.83325 6 3.83325H10C10.3536 3.83325 10.6912 3.90209 11 4.02709V3.16659C11 2.43021 10.403 1.83325 9.66667 1.83325H6.33333ZM6 4.49992C4.89543 4.49992 4 5.39535 4 6.49992V10.4999C4 11.6045 4.89543 12.4999 6 12.4999H10C11.1046 12.4999 12 11.6045 12 10.4999V9.16659C12.3682 9.16659 12.6667 8.86811 12.6667 8.49992V7.83325C12.6667 7.46506 12.3682 7.16659 12 7.16659V6.49992C12 5.39535 11.1046 4.49992 10 4.49992H6ZM6 13.1666C5.64637 13.1666 5.30881 13.0977 5 12.9727V13.8332C5 14.5696 5.59695 15.1666 6.33333 15.1666H9.66667C10.403 15.1666 11 14.5696 11 13.8332V12.9727C10.6912 13.0977 10.3536 13.1666 10 13.1666H6Z"/>
3
+ </svg>
@@ -0,0 +1,23 @@
1
+ const ASYNC_STORAGE = {
2
+ APP_VERSION: 'APP_VERSION',
3
+ APP_BUILD_NUMBER: 'APP_BUILD_NUMBER',
4
+ ACCESS_CODE: 'access_code',
5
+ ACCESS_TOKEN: 'accessToken',
6
+ DEVICE_TOKEN: 'deviceToken',
7
+ LOCATION: 'location',
8
+ LOCATION_ASKED: 'locationAsked',
9
+ CARTITEMS: 'cartItems',
10
+ RECENT_SEARCH_RESULTS: 'recentSearchResults',
11
+ IS_VIVITRA_MODAL_HIDDEN: 'is_vivitra_modal_hidden',
12
+ IS_UPLOAD_DETAILS_INCOMPLETE: 'is_upload_details_incomplete',
13
+ DEEPLINK: 'deeplink',
14
+ CODEPUSH: 'codepush-version',
15
+ BILYPSA_JOURNEY: 'bilypsa_journey',
16
+ PROSTATE_CARE_JOURNEY: 'prostate_care_journey',
17
+ SYNC_DATE: 'sync_date',
18
+ LINK: 'link',
19
+ MEDICAL_CONDITION_GROUP_ID: 'medical_condition_group_id',
20
+ DEEP_LINK_URL: 'deep_link_url',
21
+ };
22
+ export default ASYNC_STORAGE;
23
+