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,93 +0,0 @@
1
- import type { OkHiError } from './types';
2
-
3
- /**
4
- * The OkHiException class extends the Error class to provide additional information regarding the type of errors thrown while running any OkHiLibraries.
5
- * It contains static string properties that can be used to evaluate the kind of errors being thrown and handle them appropriately.
6
- */
7
- export class OkHiException extends Error {
8
- /**
9
- * Error is thrown when location services is unavailable.
10
- */
11
- static LOCATION_SERVICES_UNAVAILABLE_CODE = 'location_services_unavailable';
12
-
13
- /**
14
- * Error is thrown when play services is unavailable.
15
- */
16
- static PLAY_SERVICES_UNAVAILABLE_CODE = 'play_services_unavailable';
17
- /**
18
- * Error is thrown when the device can't connect to OkHi's servers.
19
- */
20
- static NETWORK_ERROR_CODE = 'network_error';
21
- /**
22
- * Error is thrown when the device can't connect to OkHi's servers.
23
- */
24
- static NETWORK_ERROR_MESSAGE =
25
- 'Unable to establish a connection with OkHi servers';
26
- /**
27
- * Error is thrown whenever there's an unknown error that occured during the usage of one of OkHi's services.
28
- */
29
- static UNKNOWN_ERROR_CODE = 'unknown_error';
30
- /**
31
- * Error is thrown whenever there's an unknown error that occured during the usage of one of OkHi's services.
32
- */
33
- static UNKNOWN_ERROR_MESSAGE =
34
- 'Unable to process the request. Something went wrong';
35
- /**
36
- * Error is thrown whenever an invalid phone number is provided to a service that requires a user's phone number.
37
- */
38
- static INVALID_PHONE_CODE = 'invalid_phone';
39
- /**
40
- * Error is thrown whenever an invalid phone number is provided to a service that requires a user's phone number.
41
- */
42
- static INVALID_PHONE_MESSAGE =
43
- 'Invalid phone number provided. Please make sure its in MSISDN standard format';
44
- /**
45
- * Error is thrown whenever there's an issue with the credentials provided.
46
- */
47
- static UNAUTHORIZED_CODE = 'unauthorized';
48
- /**
49
- * Error is thrown whenever there's an issue with the credentials provided.
50
- */
51
- static UNAUTHORIZED_MESSAGE = 'Invalid credentials provided';
52
- /**
53
- * Error is thrown whenever a particular permission is required for a service to run and isn't granted by the user.
54
- */
55
- static PERMISSION_DENIED_CODE = 'permission_denied';
56
- /**
57
- * Error is thrown whenever a particular device service is required for a library to run and isn't granted by the user.
58
- */
59
- static SERVICE_UNAVAILABLE_CODE = 'service_unavailable';
60
- /**
61
- * Error is thrown whenever an OkHi service is run on an unsupported platform.
62
- */
63
- static UNSUPPORTED_PLATFORM_CODE = 'unsupported_platform';
64
- /**
65
- * Error is thrown whenever an OkHi service is run on an unsupported platform.
66
- */
67
- static UNSUPPORTED_PLATFORM_MESSAGE = 'Current platform is not supported';
68
- /**
69
- * Error is thrown whenever bad configuration is provided to an OkHi service.
70
- */
71
- static BAD_REQUEST_CODE = 'bad_request';
72
- /**
73
- * Error is thrown whenever bad configuration is provided to an OkHi service.
74
- */
75
- static BAD_REQUEST_MESSAGE = 'Invalid parameters provided';
76
-
77
- /**
78
- * Specific error code string detailing the kind of error being thrown.
79
- */
80
- code: string;
81
-
82
- /**
83
- * @param error An error object with code and respective message.
84
- * @param error.code Specific error code string detailing the kind of error being thrown.
85
- * @param error.message Specific error message string detailing the kind of error being thrown.
86
- */
87
- constructor(error: OkHiError) {
88
- super(error.message);
89
- this.name = 'OkHiException';
90
- this.message = error.message;
91
- this.code = error.code;
92
- }
93
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * Sets the current mode that you'd like to use OkHi's services.
3
- */
4
- export const OkHiMode: { SANDBOX: string; PROD: string } = Object.freeze({
5
- SANDBOX: 'sandbox',
6
- PROD: 'prod',
7
- });
@@ -1,47 +0,0 @@
1
- import { Platform, PlatformOSType } from 'react-native';
2
- import { OkHiException } from './OkHiException';
3
-
4
- const SUPPORTED_PLATFORMS = ['ios', 'android'];
5
-
6
- export function isValidPlatform<T>(
7
- fn: () => Promise<T>,
8
- platform?: PlatformOSType
9
- ) {
10
- return new Promise<T>((resolve, reject) => {
11
- const error = new OkHiException({
12
- code: OkHiException.UNSUPPORTED_PLATFORM_CODE,
13
- message: 'function is not supported in ' + Platform.OS,
14
- });
15
- if (platform && Platform.OS !== platform) {
16
- reject(error);
17
- } else if (!SUPPORTED_PLATFORMS.includes(Platform.OS)) {
18
- reject(error);
19
- } else {
20
- fn()
21
- .then(resolve)
22
- .catch((error) => {
23
- reject(
24
- new OkHiException({
25
- code: error.code || OkHiException.UNKNOWN_ERROR_CODE,
26
- message: error.message || OkHiException.UNKNOWN_ERROR_MESSAGE,
27
- })
28
- );
29
- });
30
- }
31
- });
32
- }
33
-
34
- export function errorHandler<T>(fn: () => Promise<T>) {
35
- return new Promise<T>((resolve, reject) => {
36
- fn()
37
- .then(resolve)
38
- .catch((error) => {
39
- reject(
40
- new OkHiException({
41
- code: error.code || OkHiException.UNKNOWN_ERROR_CODE,
42
- message: error.message || OkHiException.UNKNOWN_ERROR_MESSAGE,
43
- })
44
- );
45
- });
46
- });
47
- }
@@ -1,37 +0,0 @@
1
- /**
2
- * @ignore
3
- */
4
- export type OkHiAccessScope = 'verify' | 'address' | 'checkout' | 'profile';
5
-
6
- export type OkHiInitializationConfiguration = {
7
- credentials: { branchId: string; clientKey: string };
8
- context: {
9
- mode: string;
10
- platform: 'react-native';
11
- developer: 'okhi' | 'external';
12
- };
13
- app?: {
14
- name?: string | null;
15
- version?: string | null;
16
- build?: number | null;
17
- };
18
- };
19
-
20
- export type AuthApplicationConfig = {
21
- auth: {
22
- token: string;
23
- };
24
- credentials: {
25
- branchId: string;
26
- clientKey: string;
27
- };
28
- context: {
29
- mode: 'sandbox' | 'prod';
30
- developer?: 'okhi' | 'external';
31
- };
32
- app?: {
33
- name?: string;
34
- version?: string;
35
- build?: string;
36
- };
37
- };
@@ -1,87 +0,0 @@
1
- import { Platform, AppState } from 'react-native';
2
- import { OkHiNativeModule } from '../OkHiNativeModule';
3
- import type { OkHiApplicationConfiguration } from './types';
4
- import { errorHandler } from './_helpers';
5
- import type { AuthApplicationConfig } from './_types';
6
- import { OkHiException } from './OkHiException';
7
-
8
- export * from './types';
9
- export * from './OkHiException';
10
- export * from './OkHiMode';
11
- export * from './Helpers';
12
-
13
- let okhiApplicationConfiguration: OkHiApplicationConfiguration | undefined;
14
-
15
- function validateConfiguration(config: OkHiApplicationConfiguration) {
16
- if (
17
- typeof config !== 'object' ||
18
- config === null ||
19
- !config.credentials ||
20
- typeof config.credentials.branchId !== 'string' ||
21
- config.credentials.branchId.trim().length === 0 ||
22
- typeof config.credentials.clientKey !== 'string' ||
23
- config.credentials.clientKey.trim().length === 0
24
- ) {
25
- return false;
26
- }
27
- return true;
28
- }
29
- /**
30
- * Initializes the OkHi library with provided API keys
31
- * @param {Object} configuration A configuration object with your OkHi credentials as well as library settings
32
- * @returns {Promise<void>} A promise that resolves when initialization is successful
33
- */
34
- export function initialize(
35
- configuration: OkHiApplicationConfiguration
36
- ): Promise<void> {
37
- if (!configuration.user || !configuration.user.phone) {
38
- console.warn(
39
- '[OkHi] Missing user in configuration object. Providing a user helps verify previous addresses. See https://docs.okhi.com'
40
- );
41
- }
42
- return errorHandler(async () => {
43
- const isValidConfig = validateConfiguration(configuration);
44
- if (!isValidConfig) {
45
- throw new OkHiException({
46
- code: OkHiException.UNAUTHORIZED_CODE,
47
- message: 'Invalid OkHi configuration provided.',
48
- });
49
- }
50
- okhiApplicationConfiguration = configuration;
51
- if (Platform.OS === 'ios') {
52
- await OkHiNativeModule.initializeIOS(
53
- configuration.credentials.branchId,
54
- configuration.credentials.clientKey,
55
- configuration.context.mode
56
- );
57
- if (AppState.currentState !== 'background') {
58
- await OkHiNativeModule.onStart();
59
- }
60
- } else {
61
- await OkHiNativeModule.initialize(JSON.stringify(configuration));
62
- }
63
- });
64
- }
65
-
66
- /**
67
- * Obtains your current running configuration
68
- * @returns {Promise<void>} A promise that resolves with your application configuration
69
- */
70
- export async function getApplicationConfiguration(): Promise<AuthApplicationConfig | null> {
71
- try {
72
- if (typeof okhiApplicationConfiguration === 'object') {
73
- return {
74
- ...okhiApplicationConfiguration,
75
- auth: {
76
- token: await OkHiNativeModule.getAuthToken(
77
- okhiApplicationConfiguration?.credentials.branchId || '',
78
- okhiApplicationConfiguration?.credentials.clientKey || ''
79
- ),
80
- },
81
- };
82
- }
83
- return null;
84
- } catch (error) {
85
- throw error;
86
- }
87
- }
@@ -1,235 +0,0 @@
1
- import type { OkHiException } from './OkHiException';
2
-
3
- /**
4
- * Defines the structure of the user object requried by OkHi services and libraries.
5
- */
6
- export interface OkHiUser {
7
- /**
8
- * The user's phone number. Must be MSISDN standard format. e.g +254712345678.
9
- */
10
- phone: string;
11
- /**
12
- * The user's first name.
13
- */
14
- firstName?: string;
15
- /**
16
- * The user's last name.
17
- */
18
- lastName?: string;
19
- /**
20
- * The user's email address.
21
- */
22
- email?: string;
23
- /**
24
- * The OkHi's userId. Usually obtained after a user successfully creates an OkHi address.
25
- */
26
- id?: string;
27
-
28
- /**
29
- * @deprecated This field is no longer used.
30
- */
31
- fcmPushNotificationToken?: string;
32
-
33
- /**
34
- * The user's jwt token provided by OkHi after address creation.
35
- */
36
- token?: string;
37
-
38
- /**
39
- * Your assigned user id
40
- */
41
- appUserId?: string;
42
- }
43
-
44
- /**
45
- * Defines the current mode you'll be using OkHi's services as well as your application's meta information.
46
- */
47
- export interface OkHiAppContext {
48
- /**
49
- * The current mode you'll be using OkHi services.
50
- */
51
- mode: 'sandbox' | 'prod' | string;
52
- /**
53
- * Your application's meta information.
54
- */
55
- app?: {
56
- /**
57
- * Your application's name.
58
- */
59
- name: string;
60
- /**
61
- * Your application's current version.
62
- */
63
- version: string;
64
- /**
65
- * Your application's current build number.
66
- */
67
- build: number;
68
- };
69
- /**
70
- * Meta information about the current developer.
71
- */
72
- developer?: string;
73
- }
74
-
75
- /**
76
- * Defines the structure of the OkHi location object once an address has been successfully created by the user.
77
- */
78
- export interface OkHiLocation {
79
- /**
80
- * The latitude of the location.
81
- */
82
- lat: number;
83
- /**
84
- * The longitude of the location.
85
- */
86
- lon: number;
87
- /**
88
- * The OkHi's locationId. Usually obtained once an address has been successfully created by the user.
89
- */
90
- id?: string;
91
- /**
92
- * The id of a common residential or geological space such as apartment building or office block.
93
- */
94
- placeId?: string;
95
- /**
96
- * Geocode system for identifying an area anywhere on the Earth.
97
- * See https://plus.codes/
98
- */
99
- plusCode?: string;
100
- /**
101
- * The location's property name.
102
- */
103
- propertyName?: string;
104
- /**
105
- * The location's street name.
106
- */
107
- streetName?: string;
108
- /**
109
- * A string that can be used to render information about the location.
110
- */
111
- title?: string;
112
- /**
113
- * A string that can be used to render meta information about the location.
114
- */
115
- subtitle?: string;
116
- /**
117
- * User generated directions to the location.
118
- */
119
- directions?: string;
120
- /**
121
- * User generated meta information about the location, how to access it and any other relevant notes.
122
- */
123
- otherInformation?: string;
124
- /**
125
- * A link to the user's address visible on browser or desktop.
126
- */
127
- url?: string;
128
- /**
129
- * A Google's StreetView Panorama Id, if the address was created using Google StreetView.
130
- * See: https://developers.google.com/maps/documentation/javascript/streetview
131
- */
132
- streetViewPanoId?: string;
133
- /**
134
- * A Google's StreetView Panorama Url, if the address was created using Google StreetView.
135
- * See: https://developers.google.com/maps/documentation/javascript/streetview
136
- */
137
- streetViewPanoUrl?: string;
138
- /**
139
- * The OkHi's userId. Usually obtained after a user successfully creates an OkHi address.
140
- */
141
- userId?: string;
142
- /**
143
- * The location's property number.
144
- */
145
- propertyNumber?: string;
146
- /**
147
- * A link to the location's gate photo.
148
- */
149
- photo?: string;
150
-
151
- /**
152
- * A user's country
153
- */
154
- country?: string;
155
-
156
- /**
157
- * A user's city
158
- */
159
- city?: string;
160
-
161
- /**
162
- * A user's state
163
- */
164
- state?: string;
165
-
166
- /**
167
- * A formatted location information
168
- */
169
- displayTitle?: string;
170
-
171
- /**
172
- * A user's country code
173
- */
174
- countryCode?: string;
175
-
176
- /**
177
- * An array of usage types that specifies the mode of verification. Can include "physical_verification" and/or "digital_verification" as valid values.
178
- */
179
- usageTypes?: UsageType;
180
- }
181
-
182
- /**
183
- * @ignore
184
- */
185
- export interface OkHiError {
186
- code: string;
187
- message: string;
188
- }
189
-
190
- export type OkHiApplicationConfiguration = {
191
- credentials: {
192
- branchId: string;
193
- clientKey: string;
194
- };
195
- context: {
196
- mode: 'sandbox' | 'prod';
197
- developer?: 'okhi' | 'external';
198
- };
199
- app?: {
200
- name?: string;
201
- version?: string;
202
- build?: string;
203
- };
204
- notification?: {
205
- title: string;
206
- text: string;
207
- channelId: string;
208
- channelName: string;
209
- channelDescription: string;
210
- };
211
- user?: OkHiUser;
212
- };
213
-
214
- export type LocationPermissionStatus =
215
- | 'notDetermined'
216
- | 'restricted'
217
- | 'denied'
218
- | 'authorizedAlways'
219
- | 'authorizedWhenInUse'
220
- | 'authorized'
221
- | 'unknown';
222
-
223
- export type LocationPermissionStatusCallback =
224
- | LocationPermissionStatus
225
- | 'rationaleDissmissed';
226
- export type LocationRequestPermissionType = 'whenInUse' | 'always';
227
-
228
- export type LocationPermissionCallback = (
229
- status: LocationPermissionStatusCallback | null,
230
- error: OkHiException | null
231
- ) => any;
232
-
233
- export type UsageType = Array<
234
- 'physical_verification' | 'digital_verification' | 'address_book'
235
- >;
@@ -1,92 +0,0 @@
1
- import { NativeModules, NativeEventEmitter, Platform } from 'react-native';
2
-
3
- const LINKING_ERROR =
4
- `The package 'react-native-okhi' doesn't seem to be linked. Make sure: \n\n` +
5
- Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
6
- '- You rebuilt the app after installing the package\n' +
7
- '- You are not using Expo managed workflow\n';
8
-
9
- type OkHiNativeModuleType = {
10
- isLocationServicesEnabled(): Promise<boolean>;
11
- isLocationPermissionGranted(): Promise<boolean>;
12
- isBackgroundLocationPermissionGranted(): Promise<boolean>;
13
- requestLocationPermission(): Promise<boolean>;
14
- requestBackgroundLocationPermission(): Promise<boolean>;
15
- requestEnableLocationServices(): Promise<boolean>;
16
- isGooglePlayServicesAvailable(): Promise<boolean>;
17
- requestEnableGooglePlayServices(): Promise<boolean>;
18
- getSystemVersion(): Promise<number | string>;
19
- getAuthToken(branchId: string, clientKey: string): Promise<string>;
20
- initialize(configuration: string): Promise<void>;
21
- startAddressVerification(
22
- token: string,
23
- phoneNumber: string,
24
- userId: string,
25
- locationId: string,
26
- lat: Number,
27
- lon: Number,
28
- usageTypes: string[]
29
- ): Promise<string>;
30
- stopAddressVerification(
31
- phoneNumber: string,
32
- locationId: string
33
- ): Promise<string>;
34
- startForegroundService(): Promise<boolean>;
35
- stopForegroundService(): Promise<boolean>;
36
- isForegroundServiceRunning(): Promise<boolean>;
37
- initializeIOS(
38
- branchId: string,
39
- clientKey: string,
40
- environment: string
41
- ): Promise<boolean>;
42
- openAppSettings(): Promise<void>;
43
- retriveLocationPermissionStatus(): Promise<string>;
44
- requestTrackingAuthorization(): Promise<string | null>;
45
- canOpenProtectedAppsSettings(): Promise<boolean>;
46
- openProtectedAppsSettings(): Promise<boolean>;
47
- retrieveDeviceInfo(): Promise<{
48
- manufacturer: string;
49
- model: string;
50
- osVersion: string;
51
- platform: 'android' | 'ios';
52
- }>;
53
- setItem(key: string, value: string): Promise<boolean>;
54
- onNewToken(fcmPushNotificationToken: string): Promise<boolean>;
55
- onMessageReceived(): Promise<boolean>;
56
- isNotificationPermissionGranted(): Promise<boolean>;
57
- requestNotificationPermission(): Promise<boolean>;
58
- fetchCurrentLocation(): Promise<null | {
59
- lat: number;
60
- lng: number;
61
- accuracy: number;
62
- }>;
63
- fetchIOSLocationPermissionStatus(): Promise<
64
- | 'notDetermined'
65
- | 'restricted'
66
- | 'denied'
67
- | 'authorizedAlways'
68
- | 'authorizedWhenInUse'
69
- | 'authorized'
70
- | 'unknown'
71
- >;
72
- onStart(): Promise<boolean>;
73
- fetchRegisteredGeofences(): Promise<string | null>;
74
- getLocationAccuracyLevel(): Promise<
75
- 'no_permission' | 'approximate' | 'precise'
76
- >;
77
- };
78
-
79
- export const OkHiNativeModule: OkHiNativeModuleType = NativeModules.Okhi
80
- ? NativeModules.Okhi
81
- : new Proxy(
82
- {},
83
- {
84
- get() {
85
- throw new Error(LINKING_ERROR);
86
- },
87
- }
88
- );
89
-
90
- export const OkHiNativeEvents = new NativeEventEmitter(NativeModules.Okhi);
91
-
92
- OkHiNativeEvents.addListener('onLocationPermissionStatusUpdate', () => null);