react-native-okhi 1.2.31 → 1.2.32-beta.2

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 (151) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +34 -4
  3. package/ReactNativeOkhi.podspec +21 -0
  4. package/android/build.gradle +38 -99
  5. package/android/gradle.properties +3 -3
  6. package/android/src/main/AndroidManifest.xml +1 -3
  7. package/android/src/main/java/com/okhi/OkhiModule.kt +336 -0
  8. package/android/src/main/java/com/okhi/OkhiPackage.kt +33 -0
  9. package/ios/OkHiWrapper.swift +348 -0
  10. package/ios/Okhi.h +5 -0
  11. package/ios/Okhi.mm +170 -0
  12. package/lib/commonjs/NativeOkhi.js +9 -0
  13. package/lib/commonjs/NativeOkhi.js.map +1 -0
  14. package/lib/commonjs/index.js +234 -28
  15. package/lib/commonjs/index.js.map +1 -1
  16. package/lib/commonjs/package.json +1 -0
  17. package/lib/commonjs/types.js.map +1 -0
  18. package/lib/module/NativeOkhi.js +5 -0
  19. package/lib/module/NativeOkhi.js.map +1 -0
  20. package/lib/module/index.js +221 -3
  21. package/lib/module/index.js.map +1 -1
  22. package/lib/module/package.json +1 -0
  23. package/lib/module/types.js +2 -0
  24. package/lib/module/types.js.map +1 -0
  25. package/lib/typescript/commonjs/package.json +1 -0
  26. package/lib/typescript/commonjs/src/NativeOkhi.d.ts +25 -0
  27. package/lib/typescript/commonjs/src/NativeOkhi.d.ts.map +1 -0
  28. package/lib/typescript/commonjs/src/index.d.ts +22 -0
  29. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  30. package/lib/typescript/commonjs/src/types.d.ts +81 -0
  31. package/lib/typescript/commonjs/src/types.d.ts.map +1 -0
  32. package/lib/typescript/module/package.json +1 -0
  33. package/lib/typescript/module/src/NativeOkhi.d.ts +25 -0
  34. package/lib/typescript/module/src/NativeOkhi.d.ts.map +1 -0
  35. package/lib/typescript/module/src/index.d.ts +22 -0
  36. package/lib/typescript/module/src/index.d.ts.map +1 -0
  37. package/lib/typescript/module/src/types.d.ts +81 -0
  38. package/lib/typescript/module/src/types.d.ts.map +1 -0
  39. package/package.json +91 -112
  40. package/src/NativeOkhi.ts +68 -0
  41. package/src/index.tsx +271 -3
  42. package/src/types.ts +90 -0
  43. package/android/src/main/java/com/reactnativeokhi/OkhiModule.java +0 -389
  44. package/android/src/main/java/com/reactnativeokhi/OkhiPackage.java +0 -28
  45. package/ios/OkHiExtension.swift +0 -27
  46. package/ios/OkHiStruct.swift +0 -29
  47. package/ios/Okhi-Bridging-Header.h +0 -3
  48. package/ios/Okhi.m +0 -62
  49. package/ios/Okhi.swift +0 -325
  50. package/ios/Okhi.xcodeproj/project.pbxproj +0 -283
  51. package/lib/commonjs/OkCollect/Helpers.js +0 -40
  52. package/lib/commonjs/OkCollect/Helpers.js.map +0 -1
  53. package/lib/commonjs/OkCollect/OkHiLocationManager.js +0 -305
  54. package/lib/commonjs/OkCollect/OkHiLocationManager.js.map +0 -1
  55. package/lib/commonjs/OkCollect/Spinner.js +0 -27
  56. package/lib/commonjs/OkCollect/Spinner.js.map +0 -1
  57. package/lib/commonjs/OkCollect/Util.js +0 -226
  58. package/lib/commonjs/OkCollect/Util.js.map +0 -1
  59. package/lib/commonjs/OkCollect/app.json +0 -4
  60. package/lib/commonjs/OkCollect/index.js +0 -47
  61. package/lib/commonjs/OkCollect/index.js.map +0 -1
  62. package/lib/commonjs/OkCollect/types.js +0 -6
  63. package/lib/commonjs/OkCollect/types.js.map +0 -1
  64. package/lib/commonjs/OkCore/Helpers.js +0 -386
  65. package/lib/commonjs/OkCore/Helpers.js.map +0 -1
  66. package/lib/commonjs/OkCore/OkHiException.js +0 -96
  67. package/lib/commonjs/OkCore/OkHiException.js.map +0 -1
  68. package/lib/commonjs/OkCore/OkHiMode.js +0 -14
  69. package/lib/commonjs/OkCore/OkHiMode.js.map +0 -1
  70. package/lib/commonjs/OkCore/_helpers.js +0 -41
  71. package/lib/commonjs/OkCore/_helpers.js.map +0 -1
  72. package/lib/commonjs/OkCore/_types.js +0 -2
  73. package/lib/commonjs/OkCore/_types.js.map +0 -1
  74. package/lib/commonjs/OkCore/index.js +0 -119
  75. package/lib/commonjs/OkCore/index.js.map +0 -1
  76. package/lib/commonjs/OkCore/types.js +0 -6
  77. package/lib/commonjs/OkCore/types.js.map +0 -1
  78. package/lib/commonjs/OkHiNativeModule/index.js +0 -19
  79. package/lib/commonjs/OkHiNativeModule/index.js.map +0 -1
  80. package/lib/commonjs/OkVerify/index.js +0 -211
  81. package/lib/commonjs/OkVerify/index.js.map +0 -1
  82. package/lib/commonjs/OkVerify/types.js.map +0 -1
  83. package/lib/module/OkCollect/Helpers.js +0 -34
  84. package/lib/module/OkCollect/Helpers.js.map +0 -1
  85. package/lib/module/OkCollect/OkHiLocationManager.js +0 -298
  86. package/lib/module/OkCollect/OkHiLocationManager.js.map +0 -1
  87. package/lib/module/OkCollect/Spinner.js +0 -20
  88. package/lib/module/OkCollect/Spinner.js.map +0 -1
  89. package/lib/module/OkCollect/Util.js +0 -214
  90. package/lib/module/OkCollect/Util.js.map +0 -1
  91. package/lib/module/OkCollect/app.json +0 -4
  92. package/lib/module/OkCollect/index.js +0 -4
  93. package/lib/module/OkCollect/index.js.map +0 -1
  94. package/lib/module/OkCollect/types.js +0 -2
  95. package/lib/module/OkCollect/types.js.map +0 -1
  96. package/lib/module/OkCore/Helpers.js +0 -363
  97. package/lib/module/OkCore/Helpers.js.map +0 -1
  98. package/lib/module/OkCore/OkHiException.js +0 -89
  99. package/lib/module/OkCore/OkHiException.js.map +0 -1
  100. package/lib/module/OkCore/OkHiMode.js +0 -8
  101. package/lib/module/OkCore/OkHiMode.js.map +0 -1
  102. package/lib/module/OkCore/_helpers.js +0 -34
  103. package/lib/module/OkCore/_helpers.js.map +0 -1
  104. package/lib/module/OkCore/_types.js +0 -2
  105. package/lib/module/OkCore/_types.js.map +0 -1
  106. package/lib/module/OkCore/index.js +0 -65
  107. package/lib/module/OkCore/index.js.map +0 -1
  108. package/lib/module/OkCore/types.js +0 -2
  109. package/lib/module/OkCore/types.js.map +0 -1
  110. package/lib/module/OkHiNativeModule/index.js +0 -13
  111. package/lib/module/OkHiNativeModule/index.js.map +0 -1
  112. package/lib/module/OkVerify/index.js +0 -195
  113. package/lib/module/OkVerify/index.js.map +0 -1
  114. package/lib/module/OkVerify/types.js +0 -2
  115. package/lib/module/OkVerify/types.js.map +0 -1
  116. package/lib/typescript/OkCollect/Helpers.d.ts +0 -9
  117. package/lib/typescript/OkCollect/OkHiLocationManager.d.ts +0 -7
  118. package/lib/typescript/OkCollect/Spinner.d.ts +0 -5
  119. package/lib/typescript/OkCollect/Util.d.ts +0 -31
  120. package/lib/typescript/OkCollect/index.d.ts +0 -3
  121. package/lib/typescript/OkCollect/types.d.ts +0 -139
  122. package/lib/typescript/OkCore/Helpers.d.ts +0 -95
  123. package/lib/typescript/OkCore/OkHiException.d.ts +0 -81
  124. package/lib/typescript/OkCore/OkHiMode.d.ts +0 -7
  125. package/lib/typescript/OkCore/_helpers.d.ts +0 -3
  126. package/lib/typescript/OkCore/_types.d.ts +0 -38
  127. package/lib/typescript/OkCore/index.d.ts +0 -17
  128. package/lib/typescript/OkCore/types.d.ts +0 -203
  129. package/lib/typescript/OkHiNativeModule/index.d.ts +0 -48
  130. package/lib/typescript/OkVerify/index.d.ts +0 -65
  131. package/lib/typescript/OkVerify/types.d.ts +0 -0
  132. package/lib/typescript/index.d.ts +0 -3
  133. package/react-native-okhi.podspec +0 -35
  134. package/src/OkCollect/Helpers.ts +0 -53
  135. package/src/OkCollect/OkHiLocationManager.tsx +0 -391
  136. package/src/OkCollect/Spinner.tsx +0 -18
  137. package/src/OkCollect/Util.ts +0 -270
  138. package/src/OkCollect/app.json +0 -4
  139. package/src/OkCollect/index.ts +0 -3
  140. package/src/OkCollect/types.ts +0 -154
  141. package/src/OkCore/Helpers.ts +0 -477
  142. package/src/OkCore/OkHiException.ts +0 -93
  143. package/src/OkCore/OkHiMode.ts +0 -7
  144. package/src/OkCore/_helpers.ts +0 -47
  145. package/src/OkCore/_types.ts +0 -37
  146. package/src/OkCore/index.ts +0 -87
  147. package/src/OkCore/types.ts +0 -235
  148. package/src/OkHiNativeModule/index.ts +0 -92
  149. package/src/OkVerify/index.ts +0 -259
  150. package/src/OkVerify/types.ts +0 -0
  151. /package/lib/commonjs/{OkVerify/types.js → types.js} +0 -0
@@ -1,259 +0,0 @@
1
- import { Platform } from 'react-native';
2
- import {
3
- isBackgroundLocationPermissionGranted,
4
- isGooglePlayServicesAvailable,
5
- isLocationServicesEnabled,
6
- requestBackgroundLocationPermission,
7
- requestEnableGooglePlayServices,
8
- requestEnableLocationServices,
9
- requestLocationPermission,
10
- isLocationPermissionGranted,
11
- } from '../OkCore/Helpers';
12
- import { errorHandler, isValidPlatform } from '../OkCore/_helpers';
13
- import { OkHiNativeModule } from '../OkHiNativeModule';
14
- import type { OkCollectSuccessResponse } from '../OkCollect/types';
15
- import { OkHiException } from '../OkCore/OkHiException';
16
- import type { UsageType } from '../OkCore';
17
- /**
18
- * Starts verification for a particular address
19
- * @param {string} phoneNumber A users phone number
20
- * @param {string} locationId An OkHi location identifier obtained after successfull creation of addresses.
21
- * @param {number} lat The latitude of the created address
22
- * @param {number} lon The longitude of the created address
23
- * @param usageTypes - Optional. An array of verification types that specifies the mode of verification.
24
- * Can include "physical" and/or "digital" as valid values.
25
- * @returns {Promise<string>} A promise that resolves to a string value of the location identifier
26
- */
27
- export const start = (
28
- token: string,
29
- phoneNumber: string,
30
- okhiUserId: string,
31
- locationId: string,
32
- lat: number,
33
- lon: number,
34
- usageTypes?: UsageType
35
- ) => {
36
- return isValidPlatform(() => {
37
- const utypes: UsageType = Array.isArray(usageTypes)
38
- ? usageTypes
39
- : ['digital_verification'];
40
- return OkHiNativeModule.startAddressVerification(
41
- token,
42
- phoneNumber,
43
- okhiUserId,
44
- locationId,
45
- lat,
46
- lon,
47
- utypes
48
- );
49
- });
50
- };
51
-
52
- /**
53
- * Starts verification for a particular address using the response object returned by OkCollect
54
- * @param {Object} response Response returned by OkCollect
55
- * @returns {Promise<string>} A promise that resolves to a string value of the location identifier
56
- */
57
- export const startVerification = (
58
- response: OkCollectSuccessResponse
59
- ): Promise<string> => {
60
- return new Promise(async (resolve, reject) => {
61
- try {
62
- const { location, user } = response;
63
- if (!user.token || !user.id) {
64
- throw new OkHiException({
65
- code: OkHiException.UNAUTHORIZED_CODE,
66
- message: OkHiException.UNAUTHORIZED_MESSAGE,
67
- });
68
- }
69
- if (!location.id) {
70
- throw new OkHiException({
71
- code: OkHiException.BAD_REQUEST_CODE,
72
- message: 'Missing location id from response',
73
- });
74
- }
75
- const usageTypes: UsageType = Array.isArray(response.location.usageTypes)
76
- ? response.location.usageTypes
77
- : ['digital_verification'];
78
- const result = await OkHiNativeModule.startAddressVerification(
79
- user.token,
80
- user.phone,
81
- user.id,
82
- location.id,
83
- location.lat,
84
- location.lon,
85
- usageTypes
86
- );
87
- resolve(result);
88
- } catch (error) {
89
- reject(error);
90
- }
91
- });
92
- };
93
-
94
- /**
95
- * Stops verification for a particular address using a user's phonenumber and OkHi location identifier
96
- * @param {string} phoneNumber The user's phone number
97
- * @param {string} locationId An OkHi location identifier obtained after successfull creation of addresses.
98
- * @returns {Promise<string>} A promise that resolves to a string value of the location identifier
99
- */
100
- export const stopVerification = (phoneNumber: string, locationId: string) => {
101
- return isValidPlatform(() =>
102
- OkHiNativeModule.stopAddressVerification(phoneNumber, locationId)
103
- );
104
- };
105
-
106
- /**
107
- * Android Only - Starts a foreground service that speeds up rate of verification
108
- * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has started successfully
109
- */
110
- export const startForegroundService = () => {
111
- return isValidPlatform(
112
- () => errorHandler(OkHiNativeModule.startForegroundService),
113
- 'android'
114
- );
115
- };
116
-
117
- /**
118
- * Android Only - Stops previously started foreground services
119
- * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has stopped successfully
120
- */
121
- export const stopForegroundService = () => {
122
- return isValidPlatform(OkHiNativeModule.stopForegroundService, 'android');
123
- };
124
-
125
- /**
126
- * Android Only - Checks if the foreground service is running
127
- * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service is running
128
- */
129
- export const isForegroundServiceRunning = () => {
130
- return isValidPlatform(
131
- OkHiNativeModule.isForegroundServiceRunning,
132
- 'android'
133
- );
134
- };
135
-
136
- /**
137
- * Checks whether all necessary permissions and services are available in order to start the address verification process
138
- * @param {Object} configuration Object that determines whether or not to request these permissions and services from the user
139
- * @param {boolean} configuration.requestServices Flag that determines whether to request the services from the user
140
- * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether or not all conditions are met to start the address verification process
141
- */
142
- export const canStartVerification = (configuration?: {
143
- requestServices?: boolean;
144
- }): Promise<boolean> => {
145
- return new Promise(async (resolve, reject) => {
146
- const requestServices = configuration && configuration.requestServices;
147
- const locationServicesStatus = await isLocationServicesEnabled();
148
- const googlePlayServices =
149
- Platform.OS === 'android' ? await isGooglePlayServicesAvailable() : true;
150
- const backgroundLocationPerm =
151
- await isBackgroundLocationPermissionGranted();
152
- const whenInUseLocationPerm = await isLocationPermissionGranted();
153
- if (!requestServices) {
154
- resolve(
155
- locationServicesStatus && googlePlayServices && backgroundLocationPerm
156
- );
157
- return;
158
- }
159
- if (Platform.OS === 'ios') {
160
- if (!locationServicesStatus) {
161
- reject(
162
- new OkHiException({
163
- code: OkHiException.SERVICE_UNAVAILABLE_CODE,
164
- message: 'Location services is unavailable',
165
- })
166
- );
167
- return;
168
- }
169
- if (backgroundLocationPerm) {
170
- resolve(true);
171
- return;
172
- }
173
- if (whenInUseLocationPerm && !backgroundLocationPerm) {
174
- resolve(false);
175
- return;
176
- }
177
- const iosPerm = await requestBackgroundLocationPermission();
178
- resolve(iosPerm);
179
- return;
180
- } else if (Platform.OS === 'android') {
181
- const locationServicesRequestStatus =
182
- (await requestEnableLocationServices()) as boolean;
183
- const gPlayServices = await requestEnableGooglePlayServices();
184
- const androidPerm =
185
- (await requestLocationPermission()) &&
186
- (await requestBackgroundLocationPermission());
187
- resolve(locationServicesRequestStatus && gPlayServices && androidPerm);
188
- } else {
189
- reject(
190
- new OkHiException({
191
- code: OkHiException.UNSUPPORTED_PLATFORM_CODE,
192
- message: OkHiException.UNSUPPORTED_PLATFORM_MESSAGE,
193
- })
194
- );
195
- }
196
- });
197
- };
198
-
199
- /**
200
- * Checks whether all necessary permissions and services are available in order to start the address verification process
201
- * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether or not all conditions are met to start the address verification process
202
- */
203
- export const checkVerificationStartRequirements = (): Promise<boolean> => {
204
- return new Promise(async (resolve, reject) => {
205
- if (Platform.OS === 'android') {
206
- const isPlayServicesAvailable = await isGooglePlayServicesAvailable();
207
- if (!isPlayServicesAvailable) {
208
- reject(
209
- new OkHiException({
210
- code: OkHiException.PLAY_SERVICES_UNAVAILABLE_CODE,
211
- message: 'Google Play Services is unavailable',
212
- })
213
- );
214
- return;
215
- }
216
- }
217
- if (!(await isLocationServicesEnabled())) {
218
- reject(
219
- new OkHiException({
220
- code: OkHiException.LOCATION_SERVICES_UNAVAILABLE_CODE,
221
- message: 'Location services unavailable',
222
- })
223
- );
224
- return;
225
- }
226
- if (!(await isBackgroundLocationPermissionGranted())) {
227
- reject(
228
- new OkHiException({
229
- code: OkHiException.PERMISSION_DENIED_CODE,
230
- message: 'Background Location permission not granted',
231
- })
232
- );
233
- return;
234
- }
235
- resolve(true);
236
- });
237
- };
238
-
239
- /**
240
- * Android Only - Updates user's device firebase push notification token
241
- * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has started successfully
242
- */
243
- export const onNewToken = (fcmPushNotificationToken: string) => {
244
- if (Platform.OS === 'android') {
245
- return OkHiNativeModule.onNewToken(fcmPushNotificationToken);
246
- }
247
- return Promise.resolve(true);
248
- };
249
-
250
- /**
251
- * Android Only - Should be invoked only when push notification is received.
252
- * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has started successfully
253
- */
254
- export const onMessageReceived = () => {
255
- if (Platform.OS === 'android') {
256
- return OkHiNativeModule.onMessageReceived();
257
- }
258
- return Promise.resolve(true);
259
- };
File without changes
File without changes