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.
- package/LICENSE +1 -1
- package/README.md +34 -4
- package/ReactNativeOkhi.podspec +21 -0
- package/android/build.gradle +38 -99
- package/android/gradle.properties +3 -3
- package/android/src/main/AndroidManifest.xml +1 -3
- package/android/src/main/java/com/okhi/OkhiModule.kt +336 -0
- package/android/src/main/java/com/okhi/OkhiPackage.kt +33 -0
- package/ios/OkHiWrapper.swift +348 -0
- package/ios/Okhi.h +5 -0
- package/ios/Okhi.mm +170 -0
- package/lib/commonjs/NativeOkhi.js +9 -0
- package/lib/commonjs/NativeOkhi.js.map +1 -0
- package/lib/commonjs/index.js +234 -28
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/NativeOkhi.js +5 -0
- package/lib/module/NativeOkhi.js.map +1 -0
- package/lib/module/index.js +221 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/NativeOkhi.d.ts +25 -0
- package/lib/typescript/commonjs/src/NativeOkhi.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +22 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types.d.ts +81 -0
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/NativeOkhi.d.ts +25 -0
- package/lib/typescript/module/src/NativeOkhi.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +22 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/types.d.ts +81 -0
- package/lib/typescript/module/src/types.d.ts.map +1 -0
- package/package.json +91 -112
- package/src/NativeOkhi.ts +68 -0
- package/src/index.tsx +271 -3
- package/src/types.ts +90 -0
- package/android/src/main/java/com/reactnativeokhi/OkhiModule.java +0 -389
- package/android/src/main/java/com/reactnativeokhi/OkhiPackage.java +0 -28
- package/ios/OkHiExtension.swift +0 -27
- package/ios/OkHiStruct.swift +0 -29
- package/ios/Okhi-Bridging-Header.h +0 -3
- package/ios/Okhi.m +0 -62
- package/ios/Okhi.swift +0 -325
- package/ios/Okhi.xcodeproj/project.pbxproj +0 -283
- package/lib/commonjs/OkCollect/Helpers.js +0 -40
- package/lib/commonjs/OkCollect/Helpers.js.map +0 -1
- package/lib/commonjs/OkCollect/OkHiLocationManager.js +0 -305
- package/lib/commonjs/OkCollect/OkHiLocationManager.js.map +0 -1
- package/lib/commonjs/OkCollect/Spinner.js +0 -27
- package/lib/commonjs/OkCollect/Spinner.js.map +0 -1
- package/lib/commonjs/OkCollect/Util.js +0 -226
- package/lib/commonjs/OkCollect/Util.js.map +0 -1
- package/lib/commonjs/OkCollect/app.json +0 -4
- package/lib/commonjs/OkCollect/index.js +0 -47
- package/lib/commonjs/OkCollect/index.js.map +0 -1
- package/lib/commonjs/OkCollect/types.js +0 -6
- package/lib/commonjs/OkCollect/types.js.map +0 -1
- package/lib/commonjs/OkCore/Helpers.js +0 -386
- package/lib/commonjs/OkCore/Helpers.js.map +0 -1
- package/lib/commonjs/OkCore/OkHiException.js +0 -96
- package/lib/commonjs/OkCore/OkHiException.js.map +0 -1
- package/lib/commonjs/OkCore/OkHiMode.js +0 -14
- package/lib/commonjs/OkCore/OkHiMode.js.map +0 -1
- package/lib/commonjs/OkCore/_helpers.js +0 -41
- package/lib/commonjs/OkCore/_helpers.js.map +0 -1
- package/lib/commonjs/OkCore/_types.js +0 -2
- package/lib/commonjs/OkCore/_types.js.map +0 -1
- package/lib/commonjs/OkCore/index.js +0 -119
- package/lib/commonjs/OkCore/index.js.map +0 -1
- package/lib/commonjs/OkCore/types.js +0 -6
- package/lib/commonjs/OkCore/types.js.map +0 -1
- package/lib/commonjs/OkHiNativeModule/index.js +0 -19
- package/lib/commonjs/OkHiNativeModule/index.js.map +0 -1
- package/lib/commonjs/OkVerify/index.js +0 -211
- package/lib/commonjs/OkVerify/index.js.map +0 -1
- package/lib/commonjs/OkVerify/types.js.map +0 -1
- package/lib/module/OkCollect/Helpers.js +0 -34
- package/lib/module/OkCollect/Helpers.js.map +0 -1
- package/lib/module/OkCollect/OkHiLocationManager.js +0 -298
- package/lib/module/OkCollect/OkHiLocationManager.js.map +0 -1
- package/lib/module/OkCollect/Spinner.js +0 -20
- package/lib/module/OkCollect/Spinner.js.map +0 -1
- package/lib/module/OkCollect/Util.js +0 -214
- package/lib/module/OkCollect/Util.js.map +0 -1
- package/lib/module/OkCollect/app.json +0 -4
- package/lib/module/OkCollect/index.js +0 -4
- package/lib/module/OkCollect/index.js.map +0 -1
- package/lib/module/OkCollect/types.js +0 -2
- package/lib/module/OkCollect/types.js.map +0 -1
- package/lib/module/OkCore/Helpers.js +0 -363
- package/lib/module/OkCore/Helpers.js.map +0 -1
- package/lib/module/OkCore/OkHiException.js +0 -89
- package/lib/module/OkCore/OkHiException.js.map +0 -1
- package/lib/module/OkCore/OkHiMode.js +0 -8
- package/lib/module/OkCore/OkHiMode.js.map +0 -1
- package/lib/module/OkCore/_helpers.js +0 -34
- package/lib/module/OkCore/_helpers.js.map +0 -1
- package/lib/module/OkCore/_types.js +0 -2
- package/lib/module/OkCore/_types.js.map +0 -1
- package/lib/module/OkCore/index.js +0 -65
- package/lib/module/OkCore/index.js.map +0 -1
- package/lib/module/OkCore/types.js +0 -2
- package/lib/module/OkCore/types.js.map +0 -1
- package/lib/module/OkHiNativeModule/index.js +0 -13
- package/lib/module/OkHiNativeModule/index.js.map +0 -1
- package/lib/module/OkVerify/index.js +0 -195
- package/lib/module/OkVerify/index.js.map +0 -1
- package/lib/module/OkVerify/types.js +0 -2
- package/lib/module/OkVerify/types.js.map +0 -1
- package/lib/typescript/OkCollect/Helpers.d.ts +0 -9
- package/lib/typescript/OkCollect/OkHiLocationManager.d.ts +0 -7
- package/lib/typescript/OkCollect/Spinner.d.ts +0 -5
- package/lib/typescript/OkCollect/Util.d.ts +0 -31
- package/lib/typescript/OkCollect/index.d.ts +0 -3
- package/lib/typescript/OkCollect/types.d.ts +0 -139
- package/lib/typescript/OkCore/Helpers.d.ts +0 -95
- package/lib/typescript/OkCore/OkHiException.d.ts +0 -81
- package/lib/typescript/OkCore/OkHiMode.d.ts +0 -7
- package/lib/typescript/OkCore/_helpers.d.ts +0 -3
- package/lib/typescript/OkCore/_types.d.ts +0 -38
- package/lib/typescript/OkCore/index.d.ts +0 -17
- package/lib/typescript/OkCore/types.d.ts +0 -203
- package/lib/typescript/OkHiNativeModule/index.d.ts +0 -48
- package/lib/typescript/OkVerify/index.d.ts +0 -65
- package/lib/typescript/OkVerify/types.d.ts +0 -0
- package/lib/typescript/index.d.ts +0 -3
- package/react-native-okhi.podspec +0 -35
- package/src/OkCollect/Helpers.ts +0 -53
- package/src/OkCollect/OkHiLocationManager.tsx +0 -391
- package/src/OkCollect/Spinner.tsx +0 -18
- package/src/OkCollect/Util.ts +0 -270
- package/src/OkCollect/app.json +0 -4
- package/src/OkCollect/index.ts +0 -3
- package/src/OkCollect/types.ts +0 -154
- package/src/OkCore/Helpers.ts +0 -477
- package/src/OkCore/OkHiException.ts +0 -93
- package/src/OkCore/OkHiMode.ts +0 -7
- package/src/OkCore/_helpers.ts +0 -47
- package/src/OkCore/_types.ts +0 -37
- package/src/OkCore/index.ts +0 -87
- package/src/OkCore/types.ts +0 -235
- package/src/OkHiNativeModule/index.ts +0 -92
- package/src/OkVerify/index.ts +0 -259
- package/src/OkVerify/types.ts +0 -0
- /package/lib/commonjs/{OkVerify/types.js → types.js} +0 -0
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.OkHiException = void 0;
|
|
7
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
8
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
9
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
|
-
/**
|
|
11
|
-
* The OkHiException class extends the Error class to provide additional information regarding the type of errors thrown while running any OkHiLibraries.
|
|
12
|
-
* It contains static string properties that can be used to evaluate the kind of errors being thrown and handle them appropriately.
|
|
13
|
-
*/
|
|
14
|
-
class OkHiException extends Error {
|
|
15
|
-
/**
|
|
16
|
-
* @param error An error object with code and respective message.
|
|
17
|
-
* @param error.code Specific error code string detailing the kind of error being thrown.
|
|
18
|
-
* @param error.message Specific error message string detailing the kind of error being thrown.
|
|
19
|
-
*/
|
|
20
|
-
constructor(error) {
|
|
21
|
-
super(error.message);
|
|
22
|
-
/**
|
|
23
|
-
* Specific error code string detailing the kind of error being thrown.
|
|
24
|
-
*/
|
|
25
|
-
_defineProperty(this, "code", void 0);
|
|
26
|
-
this.name = 'OkHiException';
|
|
27
|
-
this.message = error.message;
|
|
28
|
-
this.code = error.code;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.OkHiException = OkHiException;
|
|
32
|
-
/**
|
|
33
|
-
* Error is thrown when location services is unavailable.
|
|
34
|
-
*/
|
|
35
|
-
_defineProperty(OkHiException, "LOCATION_SERVICES_UNAVAILABLE_CODE", 'location_services_unavailable');
|
|
36
|
-
/**
|
|
37
|
-
* Error is thrown when play services is unavailable.
|
|
38
|
-
*/
|
|
39
|
-
_defineProperty(OkHiException, "PLAY_SERVICES_UNAVAILABLE_CODE", 'play_services_unavailable');
|
|
40
|
-
/**
|
|
41
|
-
* Error is thrown when the device can't connect to OkHi's servers.
|
|
42
|
-
*/
|
|
43
|
-
_defineProperty(OkHiException, "NETWORK_ERROR_CODE", 'network_error');
|
|
44
|
-
/**
|
|
45
|
-
* Error is thrown when the device can't connect to OkHi's servers.
|
|
46
|
-
*/
|
|
47
|
-
_defineProperty(OkHiException, "NETWORK_ERROR_MESSAGE", 'Unable to establish a connection with OkHi servers');
|
|
48
|
-
/**
|
|
49
|
-
* Error is thrown whenever there's an unknown error that occured during the usage of one of OkHi's services.
|
|
50
|
-
*/
|
|
51
|
-
_defineProperty(OkHiException, "UNKNOWN_ERROR_CODE", 'unknown_error');
|
|
52
|
-
/**
|
|
53
|
-
* Error is thrown whenever there's an unknown error that occured during the usage of one of OkHi's services.
|
|
54
|
-
*/
|
|
55
|
-
_defineProperty(OkHiException, "UNKNOWN_ERROR_MESSAGE", 'Unable to process the request. Something went wrong');
|
|
56
|
-
/**
|
|
57
|
-
* Error is thrown whenever an invalid phone number is provided to a service that requires a user's phone number.
|
|
58
|
-
*/
|
|
59
|
-
_defineProperty(OkHiException, "INVALID_PHONE_CODE", 'invalid_phone');
|
|
60
|
-
/**
|
|
61
|
-
* Error is thrown whenever an invalid phone number is provided to a service that requires a user's phone number.
|
|
62
|
-
*/
|
|
63
|
-
_defineProperty(OkHiException, "INVALID_PHONE_MESSAGE", 'Invalid phone number provided. Please make sure its in MSISDN standard format');
|
|
64
|
-
/**
|
|
65
|
-
* Error is thrown whenever there's an issue with the credentials provided.
|
|
66
|
-
*/
|
|
67
|
-
_defineProperty(OkHiException, "UNAUTHORIZED_CODE", 'unauthorized');
|
|
68
|
-
/**
|
|
69
|
-
* Error is thrown whenever there's an issue with the credentials provided.
|
|
70
|
-
*/
|
|
71
|
-
_defineProperty(OkHiException, "UNAUTHORIZED_MESSAGE", 'Invalid credentials provided');
|
|
72
|
-
/**
|
|
73
|
-
* Error is thrown whenever a particular permission is required for a service to run and isn't granted by the user.
|
|
74
|
-
*/
|
|
75
|
-
_defineProperty(OkHiException, "PERMISSION_DENIED_CODE", 'permission_denied');
|
|
76
|
-
/**
|
|
77
|
-
* Error is thrown whenever a particular device service is required for a library to run and isn't granted by the user.
|
|
78
|
-
*/
|
|
79
|
-
_defineProperty(OkHiException, "SERVICE_UNAVAILABLE_CODE", 'service_unavailable');
|
|
80
|
-
/**
|
|
81
|
-
* Error is thrown whenever an OkHi service is run on an unsupported platform.
|
|
82
|
-
*/
|
|
83
|
-
_defineProperty(OkHiException, "UNSUPPORTED_PLATFORM_CODE", 'unsupported_platform');
|
|
84
|
-
/**
|
|
85
|
-
* Error is thrown whenever an OkHi service is run on an unsupported platform.
|
|
86
|
-
*/
|
|
87
|
-
_defineProperty(OkHiException, "UNSUPPORTED_PLATFORM_MESSAGE", 'Current platform is not supported');
|
|
88
|
-
/**
|
|
89
|
-
* Error is thrown whenever bad configuration is provided to an OkHi service.
|
|
90
|
-
*/
|
|
91
|
-
_defineProperty(OkHiException, "BAD_REQUEST_CODE", 'bad_request');
|
|
92
|
-
/**
|
|
93
|
-
* Error is thrown whenever bad configuration is provided to an OkHi service.
|
|
94
|
-
*/
|
|
95
|
-
_defineProperty(OkHiException, "BAD_REQUEST_MESSAGE", 'Invalid parameters provided');
|
|
96
|
-
//# sourceMappingURL=OkHiException.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["OkHiException","Error","constructor","error","message","_defineProperty","name","code","exports"],"sources":["OkHiException.ts"],"sourcesContent":["import type { OkHiError } from './types';\n\n/**\n * The OkHiException class extends the Error class to provide additional information regarding the type of errors thrown while running any OkHiLibraries.\n * It contains static string properties that can be used to evaluate the kind of errors being thrown and handle them appropriately.\n */\nexport class OkHiException extends Error {\n /**\n * Error is thrown when location services is unavailable.\n */\n static LOCATION_SERVICES_UNAVAILABLE_CODE = 'location_services_unavailable';\n\n /**\n * Error is thrown when play services is unavailable.\n */\n static PLAY_SERVICES_UNAVAILABLE_CODE = 'play_services_unavailable';\n /**\n * Error is thrown when the device can't connect to OkHi's servers.\n */\n static NETWORK_ERROR_CODE = 'network_error';\n /**\n * Error is thrown when the device can't connect to OkHi's servers.\n */\n static NETWORK_ERROR_MESSAGE =\n 'Unable to establish a connection with OkHi servers';\n /**\n * Error is thrown whenever there's an unknown error that occured during the usage of one of OkHi's services.\n */\n static UNKNOWN_ERROR_CODE = 'unknown_error';\n /**\n * Error is thrown whenever there's an unknown error that occured during the usage of one of OkHi's services.\n */\n static UNKNOWN_ERROR_MESSAGE =\n 'Unable to process the request. Something went wrong';\n /**\n * Error is thrown whenever an invalid phone number is provided to a service that requires a user's phone number.\n */\n static INVALID_PHONE_CODE = 'invalid_phone';\n /**\n * Error is thrown whenever an invalid phone number is provided to a service that requires a user's phone number.\n */\n static INVALID_PHONE_MESSAGE =\n 'Invalid phone number provided. Please make sure its in MSISDN standard format';\n /**\n * Error is thrown whenever there's an issue with the credentials provided.\n */\n static UNAUTHORIZED_CODE = 'unauthorized';\n /**\n * Error is thrown whenever there's an issue with the credentials provided.\n */\n static UNAUTHORIZED_MESSAGE = 'Invalid credentials provided';\n /**\n * Error is thrown whenever a particular permission is required for a service to run and isn't granted by the user.\n */\n static PERMISSION_DENIED_CODE = 'permission_denied';\n /**\n * Error is thrown whenever a particular device service is required for a library to run and isn't granted by the user.\n */\n static SERVICE_UNAVAILABLE_CODE = 'service_unavailable';\n /**\n * Error is thrown whenever an OkHi service is run on an unsupported platform.\n */\n static UNSUPPORTED_PLATFORM_CODE = 'unsupported_platform';\n /**\n * Error is thrown whenever an OkHi service is run on an unsupported platform.\n */\n static UNSUPPORTED_PLATFORM_MESSAGE = 'Current platform is not supported';\n /**\n * Error is thrown whenever bad configuration is provided to an OkHi service.\n */\n static BAD_REQUEST_CODE = 'bad_request';\n /**\n * Error is thrown whenever bad configuration is provided to an OkHi service.\n */\n static BAD_REQUEST_MESSAGE = 'Invalid parameters provided';\n\n /**\n * Specific error code string detailing the kind of error being thrown.\n */\n code: string;\n\n /**\n * @param error An error object with code and respective message.\n * @param error.code Specific error code string detailing the kind of error being thrown.\n * @param error.message Specific error message string detailing the kind of error being thrown.\n */\n constructor(error: OkHiError) {\n super(error.message);\n this.name = 'OkHiException';\n this.message = error.message;\n this.code = error.code;\n }\n}\n"],"mappings":";;;;;;;;;AAEA;AACA;AACA;AACA;AACO,MAAMA,aAAa,SAASC,KAAK,CAAC;EA2EvC;AACF;AACA;AACA;AACA;EACEC,WAAWA,CAACC,KAAgB,EAAE;IAC5B,KAAK,CAACA,KAAK,CAACC,OAAO,CAAC;IAXtB;AACF;AACA;IAFEC,eAAA;IAYE,IAAI,CAACC,IAAI,GAAG,eAAe;IAC3B,IAAI,CAACF,OAAO,GAAGD,KAAK,CAACC,OAAO;IAC5B,IAAI,CAACG,IAAI,GAAGJ,KAAK,CAACI,IAAI;EACxB;AACF;AAACC,OAAA,CAAAR,aAAA,GAAAA,aAAA;AArFC;AACF;AACA;AAFEK,eAAA,CADWL,aAAa,wCAIoB,+BAA+B;AAE3E;AACF;AACA;AAFEK,eAAA,CANWL,aAAa,oCASgB,2BAA2B;AACnE;AACF;AACA;AAFEK,eAAA,CAVWL,aAAa,wBAaI,eAAe;AAC3C;AACF;AACA;AAFEK,eAAA,CAdWL,aAAa,2BAkBtB,oDAAoD;AACtD;AACF;AACA;AAFEK,eAAA,CAnBWL,aAAa,wBAsBI,eAAe;AAC3C;AACF;AACA;AAFEK,eAAA,CAvBWL,aAAa,2BA2BtB,qDAAqD;AACvD;AACF;AACA;AAFEK,eAAA,CA5BWL,aAAa,wBA+BI,eAAe;AAC3C;AACF;AACA;AAFEK,eAAA,CAhCWL,aAAa,2BAoCtB,+EAA+E;AACjF;AACF;AACA;AAFEK,eAAA,CArCWL,aAAa,uBAwCG,cAAc;AACzC;AACF;AACA;AAFEK,eAAA,CAzCWL,aAAa,0BA4CM,8BAA8B;AAC5D;AACF;AACA;AAFEK,eAAA,CA7CWL,aAAa,4BAgDQ,mBAAmB;AACnD;AACF;AACA;AAFEK,eAAA,CAjDWL,aAAa,8BAoDU,qBAAqB;AACvD;AACF;AACA;AAFEK,eAAA,CArDWL,aAAa,+BAwDW,sBAAsB;AACzD;AACF;AACA;AAFEK,eAAA,CAzDWL,aAAa,kCA4Dc,mCAAmC;AACzE;AACF;AACA;AAFEK,eAAA,CA7DWL,aAAa,sBAgEE,aAAa;AACvC;AACF;AACA;AAFEK,eAAA,CAjEWL,aAAa,yBAoEK,6BAA6B","ignoreList":[]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.OkHiMode = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Sets the current mode that you'd like to use OkHi's services.
|
|
9
|
-
*/
|
|
10
|
-
const OkHiMode = exports.OkHiMode = Object.freeze({
|
|
11
|
-
SANDBOX: 'sandbox',
|
|
12
|
-
PROD: 'prod'
|
|
13
|
-
});
|
|
14
|
-
//# sourceMappingURL=OkHiMode.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["OkHiMode","exports","Object","freeze","SANDBOX","PROD"],"sources":["OkHiMode.ts"],"sourcesContent":["/**\n * Sets the current mode that you'd like to use OkHi's services.\n */\nexport const OkHiMode: { SANDBOX: string; PROD: string } = Object.freeze({\n SANDBOX: 'sandbox',\n PROD: 'prod',\n});\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACO,MAAMA,QAA2C,GAAAC,OAAA,CAAAD,QAAA,GAAGE,MAAM,CAACC,MAAM,CAAC;EACvEC,OAAO,EAAE,SAAS;EAClBC,IAAI,EAAE;AACR,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.errorHandler = errorHandler;
|
|
7
|
-
exports.isValidPlatform = isValidPlatform;
|
|
8
|
-
var _reactNative = require("react-native");
|
|
9
|
-
var _OkHiException = require("./OkHiException");
|
|
10
|
-
const SUPPORTED_PLATFORMS = ['ios', 'android'];
|
|
11
|
-
function isValidPlatform(fn, platform) {
|
|
12
|
-
return new Promise((resolve, reject) => {
|
|
13
|
-
const error = new _OkHiException.OkHiException({
|
|
14
|
-
code: _OkHiException.OkHiException.UNSUPPORTED_PLATFORM_CODE,
|
|
15
|
-
message: 'function is not supported in ' + _reactNative.Platform.OS
|
|
16
|
-
});
|
|
17
|
-
if (platform && _reactNative.Platform.OS !== platform) {
|
|
18
|
-
reject(error);
|
|
19
|
-
} else if (!SUPPORTED_PLATFORMS.includes(_reactNative.Platform.OS)) {
|
|
20
|
-
reject(error);
|
|
21
|
-
} else {
|
|
22
|
-
fn().then(resolve).catch(error => {
|
|
23
|
-
reject(new _OkHiException.OkHiException({
|
|
24
|
-
code: error.code || _OkHiException.OkHiException.UNKNOWN_ERROR_CODE,
|
|
25
|
-
message: error.message || _OkHiException.OkHiException.UNKNOWN_ERROR_MESSAGE
|
|
26
|
-
}));
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
function errorHandler(fn) {
|
|
32
|
-
return new Promise((resolve, reject) => {
|
|
33
|
-
fn().then(resolve).catch(error => {
|
|
34
|
-
reject(new _OkHiException.OkHiException({
|
|
35
|
-
code: error.code || _OkHiException.OkHiException.UNKNOWN_ERROR_CODE,
|
|
36
|
-
message: error.message || _OkHiException.OkHiException.UNKNOWN_ERROR_MESSAGE
|
|
37
|
-
}));
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=_helpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_OkHiException","SUPPORTED_PLATFORMS","isValidPlatform","fn","platform","Promise","resolve","reject","error","OkHiException","code","UNSUPPORTED_PLATFORM_CODE","message","Platform","OS","includes","then","catch","UNKNOWN_ERROR_CODE","UNKNOWN_ERROR_MESSAGE","errorHandler"],"sources":["_helpers.ts"],"sourcesContent":["import { Platform, PlatformOSType } from 'react-native';\nimport { OkHiException } from './OkHiException';\n\nconst SUPPORTED_PLATFORMS = ['ios', 'android'];\n\nexport function isValidPlatform<T>(\n fn: () => Promise<T>,\n platform?: PlatformOSType\n) {\n return new Promise<T>((resolve, reject) => {\n const error = new OkHiException({\n code: OkHiException.UNSUPPORTED_PLATFORM_CODE,\n message: 'function is not supported in ' + Platform.OS,\n });\n if (platform && Platform.OS !== platform) {\n reject(error);\n } else if (!SUPPORTED_PLATFORMS.includes(Platform.OS)) {\n reject(error);\n } else {\n fn()\n .then(resolve)\n .catch((error) => {\n reject(\n new OkHiException({\n code: error.code || OkHiException.UNKNOWN_ERROR_CODE,\n message: error.message || OkHiException.UNKNOWN_ERROR_MESSAGE,\n })\n );\n });\n }\n });\n}\n\nexport function errorHandler<T>(fn: () => Promise<T>) {\n return new Promise<T>((resolve, reject) => {\n fn()\n .then(resolve)\n .catch((error) => {\n reject(\n new OkHiException({\n code: error.code || OkHiException.UNKNOWN_ERROR_CODE,\n message: error.message || OkHiException.UNKNOWN_ERROR_MESSAGE,\n })\n );\n });\n });\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAEA,MAAME,mBAAmB,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC;AAEvC,SAASC,eAAeA,CAC7BC,EAAoB,EACpBC,QAAyB,EACzB;EACA,OAAO,IAAIC,OAAO,CAAI,CAACC,OAAO,EAAEC,MAAM,KAAK;IACzC,MAAMC,KAAK,GAAG,IAAIC,4BAAa,CAAC;MAC9BC,IAAI,EAAED,4BAAa,CAACE,yBAAyB;MAC7CC,OAAO,EAAE,+BAA+B,GAAGC,qBAAQ,CAACC;IACtD,CAAC,CAAC;IACF,IAAIV,QAAQ,IAAIS,qBAAQ,CAACC,EAAE,KAAKV,QAAQ,EAAE;MACxCG,MAAM,CAACC,KAAK,CAAC;IACf,CAAC,MAAM,IAAI,CAACP,mBAAmB,CAACc,QAAQ,CAACF,qBAAQ,CAACC,EAAE,CAAC,EAAE;MACrDP,MAAM,CAACC,KAAK,CAAC;IACf,CAAC,MAAM;MACLL,EAAE,CAAC,CAAC,CACDa,IAAI,CAACV,OAAO,CAAC,CACbW,KAAK,CAAET,KAAK,IAAK;QAChBD,MAAM,CACJ,IAAIE,4BAAa,CAAC;UAChBC,IAAI,EAAEF,KAAK,CAACE,IAAI,IAAID,4BAAa,CAACS,kBAAkB;UACpDN,OAAO,EAAEJ,KAAK,CAACI,OAAO,IAAIH,4BAAa,CAACU;QAC1C,CAAC,CACH,CAAC;MACH,CAAC,CAAC;IACN;EACF,CAAC,CAAC;AACJ;AAEO,SAASC,YAAYA,CAAIjB,EAAoB,EAAE;EACpD,OAAO,IAAIE,OAAO,CAAI,CAACC,OAAO,EAAEC,MAAM,KAAK;IACzCJ,EAAE,CAAC,CAAC,CACDa,IAAI,CAACV,OAAO,CAAC,CACbW,KAAK,CAAET,KAAK,IAAK;MAChBD,MAAM,CACJ,IAAIE,4BAAa,CAAC;QAChBC,IAAI,EAAEF,KAAK,CAACE,IAAI,IAAID,4BAAa,CAACS,kBAAkB;QACpDN,OAAO,EAAEJ,KAAK,CAACI,OAAO,IAAIH,4BAAa,CAACU;MAC1C,CAAC,CACH,CAAC;IACH,CAAC,CAAC;EACN,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["_types.ts"],"sourcesContent":["/**\n * @ignore\n */\nexport type OkHiAccessScope = 'verify' | 'address' | 'checkout' | 'profile';\n\nexport type OkHiInitializationConfiguration = {\n credentials: { branchId: string; clientKey: string };\n context: {\n mode: string;\n platform: 'react-native';\n developer: 'okhi' | 'external';\n };\n app?: {\n name?: string | null;\n version?: string | null;\n build?: number | null;\n };\n};\n\nexport type AuthApplicationConfig = {\n auth: {\n token: string;\n };\n credentials: {\n branchId: string;\n clientKey: string;\n };\n context: {\n mode: 'sandbox' | 'prod';\n developer?: 'okhi' | 'external';\n };\n app?: {\n name?: string;\n version?: string;\n build?: string;\n };\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _exportNames = {
|
|
7
|
-
initialize: true,
|
|
8
|
-
getApplicationConfiguration: true
|
|
9
|
-
};
|
|
10
|
-
exports.getApplicationConfiguration = getApplicationConfiguration;
|
|
11
|
-
exports.initialize = initialize;
|
|
12
|
-
var _reactNative = require("react-native");
|
|
13
|
-
var _OkHiNativeModule = require("../OkHiNativeModule");
|
|
14
|
-
var _helpers = require("./_helpers");
|
|
15
|
-
var _OkHiException = require("./OkHiException");
|
|
16
|
-
Object.keys(_OkHiException).forEach(function (key) {
|
|
17
|
-
if (key === "default" || key === "__esModule") return;
|
|
18
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
19
|
-
if (key in exports && exports[key] === _OkHiException[key]) return;
|
|
20
|
-
Object.defineProperty(exports, key, {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
get: function () {
|
|
23
|
-
return _OkHiException[key];
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
var _types = require("./types");
|
|
28
|
-
Object.keys(_types).forEach(function (key) {
|
|
29
|
-
if (key === "default" || key === "__esModule") return;
|
|
30
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
31
|
-
if (key in exports && exports[key] === _types[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _types[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
var _OkHiMode = require("./OkHiMode");
|
|
40
|
-
Object.keys(_OkHiMode).forEach(function (key) {
|
|
41
|
-
if (key === "default" || key === "__esModule") return;
|
|
42
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
43
|
-
if (key in exports && exports[key] === _OkHiMode[key]) return;
|
|
44
|
-
Object.defineProperty(exports, key, {
|
|
45
|
-
enumerable: true,
|
|
46
|
-
get: function () {
|
|
47
|
-
return _OkHiMode[key];
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
var _Helpers = require("./Helpers");
|
|
52
|
-
Object.keys(_Helpers).forEach(function (key) {
|
|
53
|
-
if (key === "default" || key === "__esModule") return;
|
|
54
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
55
|
-
if (key in exports && exports[key] === _Helpers[key]) return;
|
|
56
|
-
Object.defineProperty(exports, key, {
|
|
57
|
-
enumerable: true,
|
|
58
|
-
get: function () {
|
|
59
|
-
return _Helpers[key];
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
let okhiApplicationConfiguration;
|
|
64
|
-
function validateConfiguration(config) {
|
|
65
|
-
if (typeof config !== 'object' || config === null || !config.credentials || typeof config.credentials.branchId !== 'string' || config.credentials.branchId.trim().length === 0 || typeof config.credentials.clientKey !== 'string' || config.credentials.clientKey.trim().length === 0) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
return true;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Initializes the OkHi library with provided API keys
|
|
72
|
-
* @param {Object} configuration A configuration object with your OkHi credentials as well as library settings
|
|
73
|
-
* @returns {Promise<void>} A promise that resolves when initialization is successful
|
|
74
|
-
*/
|
|
75
|
-
function initialize(configuration) {
|
|
76
|
-
if (!configuration.user || !configuration.user.phone) {
|
|
77
|
-
console.warn('[OkHi] Missing user in configuration object. Providing a user helps verify previous addresses. See https://docs.okhi.com');
|
|
78
|
-
}
|
|
79
|
-
return (0, _helpers.errorHandler)(async () => {
|
|
80
|
-
const isValidConfig = validateConfiguration(configuration);
|
|
81
|
-
if (!isValidConfig) {
|
|
82
|
-
throw new _OkHiException.OkHiException({
|
|
83
|
-
code: _OkHiException.OkHiException.UNAUTHORIZED_CODE,
|
|
84
|
-
message: 'Invalid OkHi configuration provided.'
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
okhiApplicationConfiguration = configuration;
|
|
88
|
-
if (_reactNative.Platform.OS === 'ios') {
|
|
89
|
-
await _OkHiNativeModule.OkHiNativeModule.initializeIOS(configuration.credentials.branchId, configuration.credentials.clientKey, configuration.context.mode);
|
|
90
|
-
if (_reactNative.AppState.currentState !== 'background') {
|
|
91
|
-
await _OkHiNativeModule.OkHiNativeModule.onStart();
|
|
92
|
-
}
|
|
93
|
-
} else {
|
|
94
|
-
await _OkHiNativeModule.OkHiNativeModule.initialize(JSON.stringify(configuration));
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Obtains your current running configuration
|
|
101
|
-
* @returns {Promise<void>} A promise that resolves with your application configuration
|
|
102
|
-
*/
|
|
103
|
-
async function getApplicationConfiguration() {
|
|
104
|
-
try {
|
|
105
|
-
if (typeof okhiApplicationConfiguration === 'object') {
|
|
106
|
-
var _okhiApplicationConfi, _okhiApplicationConfi2;
|
|
107
|
-
return {
|
|
108
|
-
...okhiApplicationConfiguration,
|
|
109
|
-
auth: {
|
|
110
|
-
token: await _OkHiNativeModule.OkHiNativeModule.getAuthToken(((_okhiApplicationConfi = okhiApplicationConfiguration) === null || _okhiApplicationConfi === void 0 ? void 0 : _okhiApplicationConfi.credentials.branchId) || '', ((_okhiApplicationConfi2 = okhiApplicationConfiguration) === null || _okhiApplicationConfi2 === void 0 ? void 0 : _okhiApplicationConfi2.credentials.clientKey) || '')
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
return null;
|
|
115
|
-
} catch (error) {
|
|
116
|
-
throw error;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_OkHiNativeModule","_helpers","_OkHiException","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_types","_OkHiMode","_Helpers","okhiApplicationConfiguration","validateConfiguration","config","credentials","branchId","trim","length","clientKey","initialize","configuration","user","phone","console","warn","errorHandler","isValidConfig","OkHiException","code","UNAUTHORIZED_CODE","message","Platform","OS","OkHiNativeModule","initializeIOS","context","mode","AppState","currentState","onStart","JSON","stringify","getApplicationConfiguration","_okhiApplicationConfi","_okhiApplicationConfi2","auth","token","getAuthToken","error"],"sources":["index.ts"],"sourcesContent":["import { Platform, AppState } from 'react-native';\nimport { OkHiNativeModule } from '../OkHiNativeModule';\nimport type { OkHiApplicationConfiguration } from './types';\nimport { errorHandler } from './_helpers';\nimport type { AuthApplicationConfig } from './_types';\nimport { OkHiException } from './OkHiException';\n\nexport * from './types';\nexport * from './OkHiException';\nexport * from './OkHiMode';\nexport * from './Helpers';\n\nlet okhiApplicationConfiguration: OkHiApplicationConfiguration | undefined;\n\nfunction validateConfiguration(config: OkHiApplicationConfiguration) {\n if (\n typeof config !== 'object' ||\n config === null ||\n !config.credentials ||\n typeof config.credentials.branchId !== 'string' ||\n config.credentials.branchId.trim().length === 0 ||\n typeof config.credentials.clientKey !== 'string' ||\n config.credentials.clientKey.trim().length === 0\n ) {\n return false;\n }\n return true;\n}\n/**\n * Initializes the OkHi library with provided API keys\n * @param {Object} configuration A configuration object with your OkHi credentials as well as library settings\n * @returns {Promise<void>} A promise that resolves when initialization is successful\n */\nexport function initialize(\n configuration: OkHiApplicationConfiguration\n): Promise<void> {\n if (!configuration.user || !configuration.user.phone) {\n console.warn(\n '[OkHi] Missing user in configuration object. Providing a user helps verify previous addresses. See https://docs.okhi.com'\n );\n }\n return errorHandler(async () => {\n const isValidConfig = validateConfiguration(configuration);\n if (!isValidConfig) {\n throw new OkHiException({\n code: OkHiException.UNAUTHORIZED_CODE,\n message: 'Invalid OkHi configuration provided.',\n });\n }\n okhiApplicationConfiguration = configuration;\n if (Platform.OS === 'ios') {\n await OkHiNativeModule.initializeIOS(\n configuration.credentials.branchId,\n configuration.credentials.clientKey,\n configuration.context.mode\n );\n if (AppState.currentState !== 'background') {\n await OkHiNativeModule.onStart();\n }\n } else {\n await OkHiNativeModule.initialize(JSON.stringify(configuration));\n }\n });\n}\n\n/**\n * Obtains your current running configuration\n * @returns {Promise<void>} A promise that resolves with your application configuration\n */\nexport async function getApplicationConfiguration(): Promise<AuthApplicationConfig | null> {\n try {\n if (typeof okhiApplicationConfiguration === 'object') {\n return {\n ...okhiApplicationConfiguration,\n auth: {\n token: await OkHiNativeModule.getAuthToken(\n okhiApplicationConfiguration?.credentials.branchId || '',\n okhiApplicationConfiguration?.credentials.clientKey || ''\n ),\n },\n };\n }\n return null;\n } catch (error) {\n throw error;\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,cAAA,GAAAH,OAAA;AAGAI,MAAA,CAAAC,IAAA,CAAAF,cAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,cAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,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B,MAAMC,kCAAgB,CAACC,aAAa,CAClCd,aAAa,CAACN,WAAW,CAACC,QAAQ,EAClCK,aAAa,CAACN,WAAW,CAACI,SAAS,EACnCE,aAAa,CAACe,OAAO,CAACC,IACxB,CAAC;MACD,IAAIC,qBAAQ,CAACC,YAAY,KAAK,YAAY,EAAE;QAC1C,MAAML,kCAAgB,CAACM,OAAO,CAAC,CAAC;MAClC;IACF,CAAC,MAAM;MACL,MAAMN,kCAAgB,CAACd,UAAU,CAACqB,IAAI,CAACC,SAAS,CAACrB,aAAa,CAAC,CAAC;IAClE;EACF,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACO,eAAesB,2BAA2BA,CAAA,EAA0C;EACzF,IAAI;IACF,IAAI,OAAO/B,4BAA4B,KAAK,QAAQ,EAAE;MAAA,IAAAgC,qBAAA,EAAAC,sBAAA;MACpD,OAAO;QACL,GAAGjC,4BAA4B;QAC/BkC,IAAI,EAAE;UACJC,KAAK,EAAE,MAAMb,kCAAgB,CAACc,YAAY,CACxC,EAAAJ,qBAAA,GAAAhC,4BAA4B,cAAAgC,qBAAA,uBAA5BA,qBAAA,CAA8B7B,WAAW,CAACC,QAAQ,KAAI,EAAE,EACxD,EAAA6B,sBAAA,GAAAjC,4BAA4B,cAAAiC,sBAAA,uBAA5BA,sBAAA,CAA8B9B,WAAW,CAACI,SAAS,KAAI,EACzD;QACF;MACF,CAAC;IACH;IACA,OAAO,IAAI;EACb,CAAC,CAAC,OAAO8B,KAAK,EAAE;IACd,MAAMA,KAAK;EACb;AACF","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { OkHiException } from './OkHiException';\n\n/**\n * Defines the structure of the user object requried by OkHi services and libraries.\n */\nexport interface OkHiUser {\n /**\n * The user's phone number. Must be MSISDN standard format. e.g +254712345678.\n */\n phone: string;\n /**\n * The user's first name.\n */\n firstName?: string;\n /**\n * The user's last name.\n */\n lastName?: string;\n /**\n * The user's email address.\n */\n email?: string;\n /**\n * The OkHi's userId. Usually obtained after a user successfully creates an OkHi address.\n */\n id?: string;\n\n /**\n * @deprecated This field is no longer used.\n */\n fcmPushNotificationToken?: string;\n\n /**\n * The user's jwt token provided by OkHi after address creation.\n */\n token?: string;\n\n /**\n * Your assigned user id\n */\n appUserId?: string;\n}\n\n/**\n * Defines the current mode you'll be using OkHi's services as well as your application's meta information.\n */\nexport interface OkHiAppContext {\n /**\n * The current mode you'll be using OkHi services.\n */\n mode: 'sandbox' | 'prod' | string;\n /**\n * Your application's meta information.\n */\n app?: {\n /**\n * Your application's name.\n */\n name: string;\n /**\n * Your application's current version.\n */\n version: string;\n /**\n * Your application's current build number.\n */\n build: number;\n };\n /**\n * Meta information about the current developer.\n */\n developer?: string;\n}\n\n/**\n * Defines the structure of the OkHi location object once an address has been successfully created by the user.\n */\nexport interface OkHiLocation {\n /**\n * The latitude of the location.\n */\n lat: number;\n /**\n * The longitude of the location.\n */\n lon: number;\n /**\n * The OkHi's locationId. Usually obtained once an address has been successfully created by the user.\n */\n id?: string;\n /**\n * The id of a common residential or geological space such as apartment building or office block.\n */\n placeId?: string;\n /**\n * Geocode system for identifying an area anywhere on the Earth.\n * See https://plus.codes/\n */\n plusCode?: string;\n /**\n * The location's property name.\n */\n propertyName?: string;\n /**\n * The location's street name.\n */\n streetName?: string;\n /**\n * A string that can be used to render information about the location.\n */\n title?: string;\n /**\n * A string that can be used to render meta information about the location.\n */\n subtitle?: string;\n /**\n * User generated directions to the location.\n */\n directions?: string;\n /**\n * User generated meta information about the location, how to access it and any other relevant notes.\n */\n otherInformation?: string;\n /**\n * A link to the user's address visible on browser or desktop.\n */\n url?: string;\n /**\n * A Google's StreetView Panorama Id, if the address was created using Google StreetView.\n * See: https://developers.google.com/maps/documentation/javascript/streetview\n */\n streetViewPanoId?: string;\n /**\n * A Google's StreetView Panorama Url, if the address was created using Google StreetView.\n * See: https://developers.google.com/maps/documentation/javascript/streetview\n */\n streetViewPanoUrl?: string;\n /**\n * The OkHi's userId. Usually obtained after a user successfully creates an OkHi address.\n */\n userId?: string;\n /**\n * The location's property number.\n */\n propertyNumber?: string;\n /**\n * A link to the location's gate photo.\n */\n photo?: string;\n\n /**\n * A user's country\n */\n country?: string;\n\n /**\n * A user's city\n */\n city?: string;\n\n /**\n * A user's state\n */\n state?: string;\n\n /**\n * A formatted location information\n */\n displayTitle?: string;\n\n /**\n * A user's country code\n */\n countryCode?: string;\n\n /**\n * An array of usage types that specifies the mode of verification. Can include \"physical_verification\" and/or \"digital_verification\" as valid values.\n */\n usageTypes?: UsageType;\n}\n\n/**\n * @ignore\n */\nexport interface OkHiError {\n code: string;\n message: string;\n}\n\nexport type OkHiApplicationConfiguration = {\n credentials: {\n branchId: string;\n clientKey: string;\n };\n context: {\n mode: 'sandbox' | 'prod';\n developer?: 'okhi' | 'external';\n };\n app?: {\n name?: string;\n version?: string;\n build?: string;\n };\n notification?: {\n title: string;\n text: string;\n channelId: string;\n channelName: string;\n channelDescription: string;\n };\n user?: OkHiUser;\n};\n\nexport type LocationPermissionStatus =\n | 'notDetermined'\n | 'restricted'\n | 'denied'\n | 'authorizedAlways'\n | 'authorizedWhenInUse'\n | 'authorized'\n | 'unknown';\n\nexport type LocationPermissionStatusCallback =\n | LocationPermissionStatus\n | 'rationaleDissmissed';\nexport type LocationRequestPermissionType = 'whenInUse' | 'always';\n\nexport type LocationPermissionCallback = (\n status: LocationPermissionStatusCallback | null,\n error: OkHiException | null\n) => any;\n\nexport type UsageType = Array<\n 'physical_verification' | 'digital_verification' | 'address_book'\n>;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.OkHiNativeModule = exports.OkHiNativeEvents = void 0;
|
|
7
|
-
var _reactNative = require("react-native");
|
|
8
|
-
const LINKING_ERROR = `The package 'react-native-okhi' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
|
|
9
|
-
ios: "- You have run 'pod install'\n",
|
|
10
|
-
default: ''
|
|
11
|
-
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n';
|
|
12
|
-
const OkHiNativeModule = exports.OkHiNativeModule = _reactNative.NativeModules.Okhi ? _reactNative.NativeModules.Okhi : new Proxy({}, {
|
|
13
|
-
get() {
|
|
14
|
-
throw new Error(LINKING_ERROR);
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
const OkHiNativeEvents = exports.OkHiNativeEvents = new _reactNative.NativeEventEmitter(_reactNative.NativeModules.Okhi);
|
|
18
|
-
OkHiNativeEvents.addListener('onLocationPermissionStatusUpdate', () => null);
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","LINKING_ERROR","Platform","select","ios","default","OkHiNativeModule","exports","NativeModules","Okhi","Proxy","get","Error","OkHiNativeEvents","NativeEventEmitter","addListener"],"sources":["index.ts"],"sourcesContent":["import { NativeModules, NativeEventEmitter, Platform } from 'react-native';\n\nconst LINKING_ERROR =\n `The package 'react-native-okhi' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\ntype OkHiNativeModuleType = {\n isLocationServicesEnabled(): Promise<boolean>;\n isLocationPermissionGranted(): Promise<boolean>;\n isBackgroundLocationPermissionGranted(): Promise<boolean>;\n requestLocationPermission(): Promise<boolean>;\n requestBackgroundLocationPermission(): Promise<boolean>;\n requestEnableLocationServices(): Promise<boolean>;\n isGooglePlayServicesAvailable(): Promise<boolean>;\n requestEnableGooglePlayServices(): Promise<boolean>;\n getSystemVersion(): Promise<number | string>;\n getAuthToken(branchId: string, clientKey: string): Promise<string>;\n initialize(configuration: string): Promise<void>;\n startAddressVerification(\n token: string,\n phoneNumber: string,\n userId: string,\n locationId: string,\n lat: Number,\n lon: Number,\n usageTypes: string[]\n ): Promise<string>;\n stopAddressVerification(\n phoneNumber: string,\n locationId: string\n ): Promise<string>;\n startForegroundService(): Promise<boolean>;\n stopForegroundService(): Promise<boolean>;\n isForegroundServiceRunning(): Promise<boolean>;\n initializeIOS(\n branchId: string,\n clientKey: string,\n environment: string\n ): Promise<boolean>;\n openAppSettings(): Promise<void>;\n retriveLocationPermissionStatus(): Promise<string>;\n requestTrackingAuthorization(): Promise<string | null>;\n canOpenProtectedAppsSettings(): Promise<boolean>;\n openProtectedAppsSettings(): Promise<boolean>;\n retrieveDeviceInfo(): Promise<{\n manufacturer: string;\n model: string;\n osVersion: string;\n platform: 'android' | 'ios';\n }>;\n setItem(key: string, value: string): Promise<boolean>;\n onNewToken(fcmPushNotificationToken: string): Promise<boolean>;\n onMessageReceived(): Promise<boolean>;\n isNotificationPermissionGranted(): Promise<boolean>;\n requestNotificationPermission(): Promise<boolean>;\n fetchCurrentLocation(): Promise<null | {\n lat: number;\n lng: number;\n accuracy: number;\n }>;\n fetchIOSLocationPermissionStatus(): Promise<\n | 'notDetermined'\n | 'restricted'\n | 'denied'\n | 'authorizedAlways'\n | 'authorizedWhenInUse'\n | 'authorized'\n | 'unknown'\n >;\n onStart(): Promise<boolean>;\n fetchRegisteredGeofences(): Promise<string | null>;\n getLocationAccuracyLevel(): Promise<\n 'no_permission' | 'approximate' | 'precise'\n >;\n};\n\nexport const OkHiNativeModule: OkHiNativeModuleType = NativeModules.Okhi\n ? NativeModules.Okhi\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nexport const OkHiNativeEvents = new NativeEventEmitter(NativeModules.Okhi);\n\nOkHiNativeEvents.addListener('onLocationPermissionStatusUpdate', () => null);\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,MAAMC,aAAa,GACjB,4EAA4E,GAC5EC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,6CAA6C;AAwExC,MAAMC,gBAAsC,GAAAC,OAAA,CAAAD,gBAAA,GAAGE,0BAAa,CAACC,IAAI,GACpED,0BAAa,CAACC,IAAI,GAClB,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACX,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEE,MAAMY,gBAAgB,GAAAN,OAAA,CAAAM,gBAAA,GAAG,IAAIC,+BAAkB,CAACN,0BAAa,CAACC,IAAI,CAAC;AAE1EI,gBAAgB,CAACE,WAAW,CAAC,kCAAkC,EAAE,MAAM,IAAI,CAAC","ignoreList":[]}
|
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.stopVerification = exports.stopForegroundService = exports.startVerification = exports.startForegroundService = exports.start = exports.onNewToken = exports.onMessageReceived = exports.isForegroundServiceRunning = exports.checkVerificationStartRequirements = exports.canStartVerification = void 0;
|
|
7
|
-
var _reactNative = require("react-native");
|
|
8
|
-
var _Helpers = require("../OkCore/Helpers");
|
|
9
|
-
var _helpers = require("../OkCore/_helpers");
|
|
10
|
-
var _OkHiNativeModule = require("../OkHiNativeModule");
|
|
11
|
-
var _OkHiException = require("../OkCore/OkHiException");
|
|
12
|
-
/**
|
|
13
|
-
* Starts verification for a particular address
|
|
14
|
-
* @param {string} phoneNumber A users phone number
|
|
15
|
-
* @param {string} locationId An OkHi location identifier obtained after successfull creation of addresses.
|
|
16
|
-
* @param {number} lat The latitude of the created address
|
|
17
|
-
* @param {number} lon The longitude of the created address
|
|
18
|
-
* @param usageTypes - Optional. An array of verification types that specifies the mode of verification.
|
|
19
|
-
* Can include "physical" and/or "digital" as valid values.
|
|
20
|
-
* @returns {Promise<string>} A promise that resolves to a string value of the location identifier
|
|
21
|
-
*/
|
|
22
|
-
const start = (token, phoneNumber, okhiUserId, locationId, lat, lon, usageTypes) => {
|
|
23
|
-
return (0, _helpers.isValidPlatform)(() => {
|
|
24
|
-
const utypes = Array.isArray(usageTypes) ? usageTypes : ['digital_verification'];
|
|
25
|
-
return _OkHiNativeModule.OkHiNativeModule.startAddressVerification(token, phoneNumber, okhiUserId, locationId, lat, lon, utypes);
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Starts verification for a particular address using the response object returned by OkCollect
|
|
31
|
-
* @param {Object} response Response returned by OkCollect
|
|
32
|
-
* @returns {Promise<string>} A promise that resolves to a string value of the location identifier
|
|
33
|
-
*/
|
|
34
|
-
exports.start = start;
|
|
35
|
-
const startVerification = response => {
|
|
36
|
-
return new Promise(async (resolve, reject) => {
|
|
37
|
-
try {
|
|
38
|
-
const {
|
|
39
|
-
location,
|
|
40
|
-
user
|
|
41
|
-
} = response;
|
|
42
|
-
if (!user.token || !user.id) {
|
|
43
|
-
throw new _OkHiException.OkHiException({
|
|
44
|
-
code: _OkHiException.OkHiException.UNAUTHORIZED_CODE,
|
|
45
|
-
message: _OkHiException.OkHiException.UNAUTHORIZED_MESSAGE
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
if (!location.id) {
|
|
49
|
-
throw new _OkHiException.OkHiException({
|
|
50
|
-
code: _OkHiException.OkHiException.BAD_REQUEST_CODE,
|
|
51
|
-
message: 'Missing location id from response'
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
const usageTypes = Array.isArray(response.location.usageTypes) ? response.location.usageTypes : ['digital_verification'];
|
|
55
|
-
const result = await _OkHiNativeModule.OkHiNativeModule.startAddressVerification(user.token, user.phone, user.id, location.id, location.lat, location.lon, usageTypes);
|
|
56
|
-
resolve(result);
|
|
57
|
-
} catch (error) {
|
|
58
|
-
reject(error);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Stops verification for a particular address using a user's phonenumber and OkHi location identifier
|
|
65
|
-
* @param {string} phoneNumber The user's phone number
|
|
66
|
-
* @param {string} locationId An OkHi location identifier obtained after successfull creation of addresses.
|
|
67
|
-
* @returns {Promise<string>} A promise that resolves to a string value of the location identifier
|
|
68
|
-
*/
|
|
69
|
-
exports.startVerification = startVerification;
|
|
70
|
-
const stopVerification = (phoneNumber, locationId) => {
|
|
71
|
-
return (0, _helpers.isValidPlatform)(() => _OkHiNativeModule.OkHiNativeModule.stopAddressVerification(phoneNumber, locationId));
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Android Only - Starts a foreground service that speeds up rate of verification
|
|
76
|
-
* @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has started successfully
|
|
77
|
-
*/
|
|
78
|
-
exports.stopVerification = stopVerification;
|
|
79
|
-
const startForegroundService = () => {
|
|
80
|
-
return (0, _helpers.isValidPlatform)(() => (0, _helpers.errorHandler)(_OkHiNativeModule.OkHiNativeModule.startForegroundService), 'android');
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Android Only - Stops previously started foreground services
|
|
85
|
-
* @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has stopped successfully
|
|
86
|
-
*/
|
|
87
|
-
exports.startForegroundService = startForegroundService;
|
|
88
|
-
const stopForegroundService = () => {
|
|
89
|
-
return (0, _helpers.isValidPlatform)(_OkHiNativeModule.OkHiNativeModule.stopForegroundService, 'android');
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Android Only - Checks if the foreground service is running
|
|
94
|
-
* @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service is running
|
|
95
|
-
*/
|
|
96
|
-
exports.stopForegroundService = stopForegroundService;
|
|
97
|
-
const isForegroundServiceRunning = () => {
|
|
98
|
-
return (0, _helpers.isValidPlatform)(_OkHiNativeModule.OkHiNativeModule.isForegroundServiceRunning, 'android');
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Checks whether all necessary permissions and services are available in order to start the address verification process
|
|
103
|
-
* @param {Object} configuration Object that determines whether or not to request these permissions and services from the user
|
|
104
|
-
* @param {boolean} configuration.requestServices Flag that determines whether to request the services from the user
|
|
105
|
-
* @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
|
|
106
|
-
*/
|
|
107
|
-
exports.isForegroundServiceRunning = isForegroundServiceRunning;
|
|
108
|
-
const canStartVerification = configuration => {
|
|
109
|
-
return new Promise(async (resolve, reject) => {
|
|
110
|
-
const requestServices = configuration && configuration.requestServices;
|
|
111
|
-
const locationServicesStatus = await (0, _Helpers.isLocationServicesEnabled)();
|
|
112
|
-
const googlePlayServices = _reactNative.Platform.OS === 'android' ? await (0, _Helpers.isGooglePlayServicesAvailable)() : true;
|
|
113
|
-
const backgroundLocationPerm = await (0, _Helpers.isBackgroundLocationPermissionGranted)();
|
|
114
|
-
const whenInUseLocationPerm = await (0, _Helpers.isLocationPermissionGranted)();
|
|
115
|
-
if (!requestServices) {
|
|
116
|
-
resolve(locationServicesStatus && googlePlayServices && backgroundLocationPerm);
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
if (_reactNative.Platform.OS === 'ios') {
|
|
120
|
-
if (!locationServicesStatus) {
|
|
121
|
-
reject(new _OkHiException.OkHiException({
|
|
122
|
-
code: _OkHiException.OkHiException.SERVICE_UNAVAILABLE_CODE,
|
|
123
|
-
message: 'Location services is unavailable'
|
|
124
|
-
}));
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
if (backgroundLocationPerm) {
|
|
128
|
-
resolve(true);
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
if (whenInUseLocationPerm && !backgroundLocationPerm) {
|
|
132
|
-
resolve(false);
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
const iosPerm = await (0, _Helpers.requestBackgroundLocationPermission)();
|
|
136
|
-
resolve(iosPerm);
|
|
137
|
-
return;
|
|
138
|
-
} else if (_reactNative.Platform.OS === 'android') {
|
|
139
|
-
const locationServicesRequestStatus = await (0, _Helpers.requestEnableLocationServices)();
|
|
140
|
-
const gPlayServices = await (0, _Helpers.requestEnableGooglePlayServices)();
|
|
141
|
-
const androidPerm = (await (0, _Helpers.requestLocationPermission)()) && (await (0, _Helpers.requestBackgroundLocationPermission)());
|
|
142
|
-
resolve(locationServicesRequestStatus && gPlayServices && androidPerm);
|
|
143
|
-
} else {
|
|
144
|
-
reject(new _OkHiException.OkHiException({
|
|
145
|
-
code: _OkHiException.OkHiException.UNSUPPORTED_PLATFORM_CODE,
|
|
146
|
-
message: _OkHiException.OkHiException.UNSUPPORTED_PLATFORM_MESSAGE
|
|
147
|
-
}));
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Checks whether all necessary permissions and services are available in order to start the address verification process
|
|
154
|
-
* @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
|
|
155
|
-
*/
|
|
156
|
-
exports.canStartVerification = canStartVerification;
|
|
157
|
-
const checkVerificationStartRequirements = () => {
|
|
158
|
-
return new Promise(async (resolve, reject) => {
|
|
159
|
-
if (_reactNative.Platform.OS === 'android') {
|
|
160
|
-
const isPlayServicesAvailable = await (0, _Helpers.isGooglePlayServicesAvailable)();
|
|
161
|
-
if (!isPlayServicesAvailable) {
|
|
162
|
-
reject(new _OkHiException.OkHiException({
|
|
163
|
-
code: _OkHiException.OkHiException.PLAY_SERVICES_UNAVAILABLE_CODE,
|
|
164
|
-
message: 'Google Play Services is unavailable'
|
|
165
|
-
}));
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
if (!(await (0, _Helpers.isLocationServicesEnabled)())) {
|
|
170
|
-
reject(new _OkHiException.OkHiException({
|
|
171
|
-
code: _OkHiException.OkHiException.LOCATION_SERVICES_UNAVAILABLE_CODE,
|
|
172
|
-
message: 'Location services unavailable'
|
|
173
|
-
}));
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
if (!(await (0, _Helpers.isBackgroundLocationPermissionGranted)())) {
|
|
177
|
-
reject(new _OkHiException.OkHiException({
|
|
178
|
-
code: _OkHiException.OkHiException.PERMISSION_DENIED_CODE,
|
|
179
|
-
message: 'Background Location permission not granted'
|
|
180
|
-
}));
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
resolve(true);
|
|
184
|
-
});
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Android Only - Updates user's device firebase push notification token
|
|
189
|
-
* @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has started successfully
|
|
190
|
-
*/
|
|
191
|
-
exports.checkVerificationStartRequirements = checkVerificationStartRequirements;
|
|
192
|
-
const onNewToken = fcmPushNotificationToken => {
|
|
193
|
-
if (_reactNative.Platform.OS === 'android') {
|
|
194
|
-
return _OkHiNativeModule.OkHiNativeModule.onNewToken(fcmPushNotificationToken);
|
|
195
|
-
}
|
|
196
|
-
return Promise.resolve(true);
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Android Only - Should be invoked only when push notification is received.
|
|
201
|
-
* @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has started successfully
|
|
202
|
-
*/
|
|
203
|
-
exports.onNewToken = onNewToken;
|
|
204
|
-
const onMessageReceived = () => {
|
|
205
|
-
if (_reactNative.Platform.OS === 'android') {
|
|
206
|
-
return _OkHiNativeModule.OkHiNativeModule.onMessageReceived();
|
|
207
|
-
}
|
|
208
|
-
return Promise.resolve(true);
|
|
209
|
-
};
|
|
210
|
-
exports.onMessageReceived = onMessageReceived;
|
|
211
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_Helpers","_helpers","_OkHiNativeModule","_OkHiException","start","token","phoneNumber","okhiUserId","locationId","lat","lon","usageTypes","isValidPlatform","utypes","Array","isArray","OkHiNativeModule","startAddressVerification","exports","startVerification","response","Promise","resolve","reject","location","user","id","OkHiException","code","UNAUTHORIZED_CODE","message","UNAUTHORIZED_MESSAGE","BAD_REQUEST_CODE","result","phone","error","stopVerification","stopAddressVerification","startForegroundService","errorHandler","stopForegroundService","isForegroundServiceRunning","canStartVerification","configuration","requestServices","locationServicesStatus","isLocationServicesEnabled","googlePlayServices","Platform","OS","isGooglePlayServicesAvailable","backgroundLocationPerm","isBackgroundLocationPermissionGranted","whenInUseLocationPerm","isLocationPermissionGranted","SERVICE_UNAVAILABLE_CODE","iosPerm","requestBackgroundLocationPermission","locationServicesRequestStatus","requestEnableLocationServices","gPlayServices","requestEnableGooglePlayServices","androidPerm","requestLocationPermission","UNSUPPORTED_PLATFORM_CODE","UNSUPPORTED_PLATFORM_MESSAGE","checkVerificationStartRequirements","isPlayServicesAvailable","PLAY_SERVICES_UNAVAILABLE_CODE","LOCATION_SERVICES_UNAVAILABLE_CODE","PERMISSION_DENIED_CODE","onNewToken","fcmPushNotificationToken","onMessageReceived"],"sources":["index.ts"],"sourcesContent":["import { Platform } from 'react-native';\nimport {\n isBackgroundLocationPermissionGranted,\n isGooglePlayServicesAvailable,\n isLocationServicesEnabled,\n requestBackgroundLocationPermission,\n requestEnableGooglePlayServices,\n requestEnableLocationServices,\n requestLocationPermission,\n isLocationPermissionGranted,\n} from '../OkCore/Helpers';\nimport { errorHandler, isValidPlatform } from '../OkCore/_helpers';\nimport { OkHiNativeModule } from '../OkHiNativeModule';\nimport type { OkCollectSuccessResponse } from '../OkCollect/types';\nimport { OkHiException } from '../OkCore/OkHiException';\nimport type { UsageType } from '../OkCore';\n/**\n * Starts verification for a particular address\n * @param {string} phoneNumber A users phone number\n * @param {string} locationId An OkHi location identifier obtained after successfull creation of addresses.\n * @param {number} lat The latitude of the created address\n * @param {number} lon The longitude of the created address\n * @param usageTypes - Optional. An array of verification types that specifies the mode of verification.\n * Can include \"physical\" and/or \"digital\" as valid values.\n * @returns {Promise<string>} A promise that resolves to a string value of the location identifier\n */\nexport const start = (\n token: string,\n phoneNumber: string,\n okhiUserId: string,\n locationId: string,\n lat: number,\n lon: number,\n usageTypes?: UsageType\n) => {\n return isValidPlatform(() => {\n const utypes: UsageType = Array.isArray(usageTypes)\n ? usageTypes\n : ['digital_verification'];\n return OkHiNativeModule.startAddressVerification(\n token,\n phoneNumber,\n okhiUserId,\n locationId,\n lat,\n lon,\n utypes\n );\n });\n};\n\n/**\n * Starts verification for a particular address using the response object returned by OkCollect\n * @param {Object} response Response returned by OkCollect\n * @returns {Promise<string>} A promise that resolves to a string value of the location identifier\n */\nexport const startVerification = (\n response: OkCollectSuccessResponse\n): Promise<string> => {\n return new Promise(async (resolve, reject) => {\n try {\n const { location, user } = response;\n if (!user.token || !user.id) {\n throw new OkHiException({\n code: OkHiException.UNAUTHORIZED_CODE,\n message: OkHiException.UNAUTHORIZED_MESSAGE,\n });\n }\n if (!location.id) {\n throw new OkHiException({\n code: OkHiException.BAD_REQUEST_CODE,\n message: 'Missing location id from response',\n });\n }\n const usageTypes: UsageType = Array.isArray(response.location.usageTypes)\n ? response.location.usageTypes\n : ['digital_verification'];\n const result = await OkHiNativeModule.startAddressVerification(\n user.token,\n user.phone,\n user.id,\n location.id,\n location.lat,\n location.lon,\n usageTypes\n );\n resolve(result);\n } catch (error) {\n reject(error);\n }\n });\n};\n\n/**\n * Stops verification for a particular address using a user's phonenumber and OkHi location identifier\n * @param {string} phoneNumber The user's phone number\n * @param {string} locationId An OkHi location identifier obtained after successfull creation of addresses.\n * @returns {Promise<string>} A promise that resolves to a string value of the location identifier\n */\nexport const stopVerification = (phoneNumber: string, locationId: string) => {\n return isValidPlatform(() =>\n OkHiNativeModule.stopAddressVerification(phoneNumber, locationId)\n );\n};\n\n/**\n * Android Only - Starts a foreground service that speeds up rate of verification\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has started successfully\n */\nexport const startForegroundService = () => {\n return isValidPlatform(\n () => errorHandler(OkHiNativeModule.startForegroundService),\n 'android'\n );\n};\n\n/**\n * Android Only - Stops previously started foreground services\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has stopped successfully\n */\nexport const stopForegroundService = () => {\n return isValidPlatform(OkHiNativeModule.stopForegroundService, 'android');\n};\n\n/**\n * Android Only - Checks if the foreground service is running\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service is running\n */\nexport const isForegroundServiceRunning = () => {\n return isValidPlatform(\n OkHiNativeModule.isForegroundServiceRunning,\n 'android'\n );\n};\n\n/**\n * Checks whether all necessary permissions and services are available in order to start the address verification process\n * @param {Object} configuration Object that determines whether or not to request these permissions and services from the user\n * @param {boolean} configuration.requestServices Flag that determines whether to request the services from the user\n * @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\n */\nexport const canStartVerification = (configuration?: {\n requestServices?: boolean;\n}): Promise<boolean> => {\n return new Promise(async (resolve, reject) => {\n const requestServices = configuration && configuration.requestServices;\n const locationServicesStatus = await isLocationServicesEnabled();\n const googlePlayServices =\n Platform.OS === 'android' ? await isGooglePlayServicesAvailable() : true;\n const backgroundLocationPerm =\n await isBackgroundLocationPermissionGranted();\n const whenInUseLocationPerm = await isLocationPermissionGranted();\n if (!requestServices) {\n resolve(\n locationServicesStatus && googlePlayServices && backgroundLocationPerm\n );\n return;\n }\n if (Platform.OS === 'ios') {\n if (!locationServicesStatus) {\n reject(\n new OkHiException({\n code: OkHiException.SERVICE_UNAVAILABLE_CODE,\n message: 'Location services is unavailable',\n })\n );\n return;\n }\n if (backgroundLocationPerm) {\n resolve(true);\n return;\n }\n if (whenInUseLocationPerm && !backgroundLocationPerm) {\n resolve(false);\n return;\n }\n const iosPerm = await requestBackgroundLocationPermission();\n resolve(iosPerm);\n return;\n } else if (Platform.OS === 'android') {\n const locationServicesRequestStatus =\n (await requestEnableLocationServices()) as boolean;\n const gPlayServices = await requestEnableGooglePlayServices();\n const androidPerm =\n (await requestLocationPermission()) &&\n (await requestBackgroundLocationPermission());\n resolve(locationServicesRequestStatus && gPlayServices && androidPerm);\n } else {\n reject(\n new OkHiException({\n code: OkHiException.UNSUPPORTED_PLATFORM_CODE,\n message: OkHiException.UNSUPPORTED_PLATFORM_MESSAGE,\n })\n );\n }\n });\n};\n\n/**\n * Checks whether all necessary permissions and services are available in order to start the address verification process\n * @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\n */\nexport const checkVerificationStartRequirements = (): Promise<boolean> => {\n return new Promise(async (resolve, reject) => {\n if (Platform.OS === 'android') {\n const isPlayServicesAvailable = await isGooglePlayServicesAvailable();\n if (!isPlayServicesAvailable) {\n reject(\n new OkHiException({\n code: OkHiException.PLAY_SERVICES_UNAVAILABLE_CODE,\n message: 'Google Play Services is unavailable',\n })\n );\n return;\n }\n }\n if (!(await isLocationServicesEnabled())) {\n reject(\n new OkHiException({\n code: OkHiException.LOCATION_SERVICES_UNAVAILABLE_CODE,\n message: 'Location services unavailable',\n })\n );\n return;\n }\n if (!(await isBackgroundLocationPermissionGranted())) {\n reject(\n new OkHiException({\n code: OkHiException.PERMISSION_DENIED_CODE,\n message: 'Background Location permission not granted',\n })\n );\n return;\n }\n resolve(true);\n });\n};\n\n/**\n * Android Only - Updates user's device firebase push notification token\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has started successfully\n */\nexport const onNewToken = (fcmPushNotificationToken: string) => {\n if (Platform.OS === 'android') {\n return OkHiNativeModule.onNewToken(fcmPushNotificationToken);\n }\n return Promise.resolve(true);\n};\n\n/**\n * Android Only - Should be invoked only when push notification is received.\n * @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has started successfully\n */\nexport const onMessageReceived = () => {\n if (Platform.OS === 'android') {\n return OkHiNativeModule.onMessageReceived();\n }\n return Promise.resolve(true);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAUA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AAEA,IAAAI,cAAA,GAAAJ,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMK,KAAK,GAAGA,CACnBC,KAAa,EACbC,WAAmB,EACnBC,UAAkB,EAClBC,UAAkB,EAClBC,GAAW,EACXC,GAAW,EACXC,UAAsB,KACnB;EACH,OAAO,IAAAC,wBAAe,EAAC,MAAM;IAC3B,MAAMC,MAAiB,GAAGC,KAAK,CAACC,OAAO,CAACJ,UAAU,CAAC,GAC/CA,UAAU,GACV,CAAC,sBAAsB,CAAC;IAC5B,OAAOK,kCAAgB,CAACC,wBAAwB,CAC9CZ,KAAK,EACLC,WAAW,EACXC,UAAU,EACVC,UAAU,EACVC,GAAG,EACHC,GAAG,EACHG,MACF,CAAC;EACH,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJAK,OAAA,CAAAd,KAAA,GAAAA,KAAA;AAKO,MAAMe,iBAAiB,GAC5BC,QAAkC,IACd;EACpB,OAAO,IAAIC,OAAO,CAAC,OAAOC,OAAO,EAAEC,MAAM,KAAK;IAC5C,IAAI;MACF,MAAM;QAAEC,QAAQ;QAAEC;MAAK,CAAC,GAAGL,QAAQ;MACnC,IAAI,CAACK,IAAI,CAACpB,KAAK,IAAI,CAACoB,IAAI,CAACC,EAAE,EAAE;QAC3B,MAAM,IAAIC,4BAAa,CAAC;UACtBC,IAAI,EAAED,4BAAa,CAACE,iBAAiB;UACrCC,OAAO,EAAEH,4BAAa,CAACI;QACzB,CAAC,CAAC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