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,34 +0,0 @@
|
|
|
1
|
-
import { Platform } from 'react-native';
|
|
2
|
-
import { OkHiException } from './OkHiException';
|
|
3
|
-
const SUPPORTED_PLATFORMS = ['ios', 'android'];
|
|
4
|
-
export function isValidPlatform(fn, platform) {
|
|
5
|
-
return new Promise((resolve, reject) => {
|
|
6
|
-
const error = new OkHiException({
|
|
7
|
-
code: OkHiException.UNSUPPORTED_PLATFORM_CODE,
|
|
8
|
-
message: 'function is not supported in ' + Platform.OS
|
|
9
|
-
});
|
|
10
|
-
if (platform && Platform.OS !== platform) {
|
|
11
|
-
reject(error);
|
|
12
|
-
} else if (!SUPPORTED_PLATFORMS.includes(Platform.OS)) {
|
|
13
|
-
reject(error);
|
|
14
|
-
} else {
|
|
15
|
-
fn().then(resolve).catch(error => {
|
|
16
|
-
reject(new OkHiException({
|
|
17
|
-
code: error.code || OkHiException.UNKNOWN_ERROR_CODE,
|
|
18
|
-
message: error.message || OkHiException.UNKNOWN_ERROR_MESSAGE
|
|
19
|
-
}));
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
export function errorHandler(fn) {
|
|
25
|
-
return new Promise((resolve, reject) => {
|
|
26
|
-
fn().then(resolve).catch(error => {
|
|
27
|
-
reject(new OkHiException({
|
|
28
|
-
code: error.code || OkHiException.UNKNOWN_ERROR_CODE,
|
|
29
|
-
message: error.message || OkHiException.UNKNOWN_ERROR_MESSAGE
|
|
30
|
-
}));
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=_helpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","OkHiException","SUPPORTED_PLATFORMS","isValidPlatform","fn","platform","Promise","resolve","reject","error","code","UNSUPPORTED_PLATFORM_CODE","message","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,SAASA,QAAQ,QAAwB,cAAc;AACvD,SAASC,aAAa,QAAQ,iBAAiB;AAE/C,MAAMC,mBAAmB,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC;AAE9C,OAAO,SAASC,eAAeA,CAC7BC,EAAoB,EACpBC,QAAyB,EACzB;EACA,OAAO,IAAIC,OAAO,CAAI,CAACC,OAAO,EAAEC,MAAM,KAAK;IACzC,MAAMC,KAAK,GAAG,IAAIR,aAAa,CAAC;MAC9BS,IAAI,EAAET,aAAa,CAACU,yBAAyB;MAC7CC,OAAO,EAAE,+BAA+B,GAAGZ,QAAQ,CAACa;IACtD,CAAC,CAAC;IACF,IAAIR,QAAQ,IAAIL,QAAQ,CAACa,EAAE,KAAKR,QAAQ,EAAE;MACxCG,MAAM,CAACC,KAAK,CAAC;IACf,CAAC,MAAM,IAAI,CAACP,mBAAmB,CAACY,QAAQ,CAACd,QAAQ,CAACa,EAAE,CAAC,EAAE;MACrDL,MAAM,CAACC,KAAK,CAAC;IACf,CAAC,MAAM;MACLL,EAAE,CAAC,CAAC,CACDW,IAAI,CAACR,OAAO,CAAC,CACbS,KAAK,CAAEP,KAAK,IAAK;QAChBD,MAAM,CACJ,IAAIP,aAAa,CAAC;UAChBS,IAAI,EAAED,KAAK,CAACC,IAAI,IAAIT,aAAa,CAACgB,kBAAkB;UACpDL,OAAO,EAAEH,KAAK,CAACG,OAAO,IAAIX,aAAa,CAACiB;QAC1C,CAAC,CACH,CAAC;MACH,CAAC,CAAC;IACN;EACF,CAAC,CAAC;AACJ;AAEA,OAAO,SAASC,YAAYA,CAAIf,EAAoB,EAAE;EACpD,OAAO,IAAIE,OAAO,CAAI,CAACC,OAAO,EAAEC,MAAM,KAAK;IACzCJ,EAAE,CAAC,CAAC,CACDW,IAAI,CAACR,OAAO,CAAC,CACbS,KAAK,CAAEP,KAAK,IAAK;MAChBD,MAAM,CACJ,IAAIP,aAAa,CAAC;QAChBS,IAAI,EAAED,KAAK,CAACC,IAAI,IAAIT,aAAa,CAACgB,kBAAkB;QACpDL,OAAO,EAAEH,KAAK,CAACG,OAAO,IAAIX,aAAa,CAACiB;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,65 +0,0 @@
|
|
|
1
|
-
import { Platform, AppState } from 'react-native';
|
|
2
|
-
import { OkHiNativeModule } from '../OkHiNativeModule';
|
|
3
|
-
import { errorHandler } from './_helpers';
|
|
4
|
-
import { OkHiException } from './OkHiException';
|
|
5
|
-
export * from './types';
|
|
6
|
-
export * from './OkHiException';
|
|
7
|
-
export * from './OkHiMode';
|
|
8
|
-
export * from './Helpers';
|
|
9
|
-
let okhiApplicationConfiguration;
|
|
10
|
-
function validateConfiguration(config) {
|
|
11
|
-
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) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Initializes the OkHi library with provided API keys
|
|
18
|
-
* @param {Object} configuration A configuration object with your OkHi credentials as well as library settings
|
|
19
|
-
* @returns {Promise<void>} A promise that resolves when initialization is successful
|
|
20
|
-
*/
|
|
21
|
-
export function initialize(configuration) {
|
|
22
|
-
if (!configuration.user || !configuration.user.phone) {
|
|
23
|
-
console.warn('[OkHi] Missing user in configuration object. Providing a user helps verify previous addresses. See https://docs.okhi.com');
|
|
24
|
-
}
|
|
25
|
-
return errorHandler(async () => {
|
|
26
|
-
const isValidConfig = validateConfiguration(configuration);
|
|
27
|
-
if (!isValidConfig) {
|
|
28
|
-
throw new OkHiException({
|
|
29
|
-
code: OkHiException.UNAUTHORIZED_CODE,
|
|
30
|
-
message: 'Invalid OkHi configuration provided.'
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
okhiApplicationConfiguration = configuration;
|
|
34
|
-
if (Platform.OS === 'ios') {
|
|
35
|
-
await OkHiNativeModule.initializeIOS(configuration.credentials.branchId, configuration.credentials.clientKey, configuration.context.mode);
|
|
36
|
-
if (AppState.currentState !== 'background') {
|
|
37
|
-
await OkHiNativeModule.onStart();
|
|
38
|
-
}
|
|
39
|
-
} else {
|
|
40
|
-
await OkHiNativeModule.initialize(JSON.stringify(configuration));
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Obtains your current running configuration
|
|
47
|
-
* @returns {Promise<void>} A promise that resolves with your application configuration
|
|
48
|
-
*/
|
|
49
|
-
export async function getApplicationConfiguration() {
|
|
50
|
-
try {
|
|
51
|
-
if (typeof okhiApplicationConfiguration === 'object') {
|
|
52
|
-
var _okhiApplicationConfi, _okhiApplicationConfi2;
|
|
53
|
-
return {
|
|
54
|
-
...okhiApplicationConfiguration,
|
|
55
|
-
auth: {
|
|
56
|
-
token: await OkHiNativeModule.getAuthToken(((_okhiApplicationConfi = okhiApplicationConfiguration) === null || _okhiApplicationConfi === void 0 ? void 0 : _okhiApplicationConfi.credentials.branchId) || '', ((_okhiApplicationConfi2 = okhiApplicationConfiguration) === null || _okhiApplicationConfi2 === void 0 ? void 0 : _okhiApplicationConfi2.credentials.clientKey) || '')
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
return null;
|
|
61
|
-
} catch (error) {
|
|
62
|
-
throw error;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","AppState","OkHiNativeModule","errorHandler","OkHiException","okhiApplicationConfiguration","validateConfiguration","config","credentials","branchId","trim","length","clientKey","initialize","configuration","user","phone","console","warn","isValidConfig","code","UNAUTHORIZED_CODE","message","OS","initializeIOS","context","mode","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 }\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IAC5C,IAAId,QAAQ,CAACuB,EAAE,KAAK,KAAK,EAAE;MACzB,MAAMrB,gBAAgB,CAACsB,aAAa,CAClCV,aAAa,CAACN,WAAW,CAACC,QAAQ,EAClCK,aAAa,CAACN,WAAW,CAACI,SAAS,EACnCE,aAAa,CAACW,OAAO,CAACC,IACxB,CAAC;MACD,IAAIzB,QAAQ,CAAC0B,YAAY,KAAK,YAAY,EAAE;QAC1C,MAAMzB,gBAAgB,CAAC0B,OAAO,CAAC,CAAC;MAClC;IACF,CAAC,MAAM;MACL,MAAM1B,gBAAgB,CAACW,UAAU,CAACgB,IAAI,CAACC,SAAS,CAAChB,aAAa,CAAC,CAAC;IAClE;EACF,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA,OAAO,eAAeiB,2BAA2BA,CAAA,EAA0C;EACzF,IAAI;IACF,IAAI,OAAO1B,4BAA4B,KAAK,QAAQ,EAAE;MAAA,IAAA2B,qBAAA,EAAAC,sBAAA;MACpD,OAAO;QACL,GAAG5B,4BAA4B;QAC/B6B,IAAI,EAAE;UACJC,KAAK,EAAE,MAAMjC,gBAAgB,CAACkC,YAAY,CACxC,EAAAJ,qBAAA,GAAA3B,4BAA4B,cAAA2B,qBAAA,uBAA5BA,qBAAA,CAA8BxB,WAAW,CAACC,QAAQ,KAAI,EAAE,EACxD,EAAAwB,sBAAA,GAAA5B,4BAA4B,cAAA4B,sBAAA,uBAA5BA,sBAAA,CAA8BzB,WAAW,CAACI,SAAS,KAAI,EACzD;QACF;MACF,CAAC;IACH;IACA,OAAO,IAAI;EACb,CAAC,CAAC,OAAOyB,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,13 +0,0 @@
|
|
|
1
|
-
import { NativeModules, NativeEventEmitter, Platform } from 'react-native';
|
|
2
|
-
const LINKING_ERROR = `The package 'react-native-okhi' doesn't seem to be linked. Make sure: \n\n` + Platform.select({
|
|
3
|
-
ios: "- You have run 'pod install'\n",
|
|
4
|
-
default: ''
|
|
5
|
-
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n';
|
|
6
|
-
export const OkHiNativeModule = NativeModules.Okhi ? NativeModules.Okhi : new Proxy({}, {
|
|
7
|
-
get() {
|
|
8
|
-
throw new Error(LINKING_ERROR);
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
export const OkHiNativeEvents = new NativeEventEmitter(NativeModules.Okhi);
|
|
12
|
-
OkHiNativeEvents.addListener('onLocationPermissionStatusUpdate', () => null);
|
|
13
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","NativeEventEmitter","Platform","LINKING_ERROR","select","ios","default","OkHiNativeModule","Okhi","Proxy","get","Error","OkHiNativeEvents","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,SAASA,aAAa,EAAEC,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;AAE1E,MAAMC,aAAa,GACjB,4EAA4E,GAC5ED,QAAQ,CAACE,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,6CAA6C;AAwE/C,OAAO,MAAMC,gBAAsC,GAAGP,aAAa,CAACQ,IAAI,GACpER,aAAa,CAACQ,IAAI,GAClB,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACR,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAEL,OAAO,MAAMS,gBAAgB,GAAG,IAAIX,kBAAkB,CAACD,aAAa,CAACQ,IAAI,CAAC;AAE1EI,gBAAgB,CAACC,WAAW,CAAC,kCAAkC,EAAE,MAAM,IAAI,CAAC","ignoreList":[]}
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import { Platform } from 'react-native';
|
|
2
|
-
import { isBackgroundLocationPermissionGranted, isGooglePlayServicesAvailable, isLocationServicesEnabled, requestBackgroundLocationPermission, requestEnableGooglePlayServices, requestEnableLocationServices, requestLocationPermission, isLocationPermissionGranted } from '../OkCore/Helpers';
|
|
3
|
-
import { errorHandler, isValidPlatform } from '../OkCore/_helpers';
|
|
4
|
-
import { OkHiNativeModule } from '../OkHiNativeModule';
|
|
5
|
-
import { OkHiException } from '../OkCore/OkHiException';
|
|
6
|
-
/**
|
|
7
|
-
* Starts verification for a particular address
|
|
8
|
-
* @param {string} phoneNumber A users phone number
|
|
9
|
-
* @param {string} locationId An OkHi location identifier obtained after successfull creation of addresses.
|
|
10
|
-
* @param {number} lat The latitude of the created address
|
|
11
|
-
* @param {number} lon The longitude of the created address
|
|
12
|
-
* @param usageTypes - Optional. An array of verification types that specifies the mode of verification.
|
|
13
|
-
* Can include "physical" and/or "digital" as valid values.
|
|
14
|
-
* @returns {Promise<string>} A promise that resolves to a string value of the location identifier
|
|
15
|
-
*/
|
|
16
|
-
export const start = (token, phoneNumber, okhiUserId, locationId, lat, lon, usageTypes) => {
|
|
17
|
-
return isValidPlatform(() => {
|
|
18
|
-
const utypes = Array.isArray(usageTypes) ? usageTypes : ['digital_verification'];
|
|
19
|
-
return OkHiNativeModule.startAddressVerification(token, phoneNumber, okhiUserId, locationId, lat, lon, utypes);
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Starts verification for a particular address using the response object returned by OkCollect
|
|
25
|
-
* @param {Object} response Response returned by OkCollect
|
|
26
|
-
* @returns {Promise<string>} A promise that resolves to a string value of the location identifier
|
|
27
|
-
*/
|
|
28
|
-
export const startVerification = response => {
|
|
29
|
-
return new Promise(async (resolve, reject) => {
|
|
30
|
-
try {
|
|
31
|
-
const {
|
|
32
|
-
location,
|
|
33
|
-
user
|
|
34
|
-
} = response;
|
|
35
|
-
if (!user.token || !user.id) {
|
|
36
|
-
throw new OkHiException({
|
|
37
|
-
code: OkHiException.UNAUTHORIZED_CODE,
|
|
38
|
-
message: OkHiException.UNAUTHORIZED_MESSAGE
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
if (!location.id) {
|
|
42
|
-
throw new OkHiException({
|
|
43
|
-
code: OkHiException.BAD_REQUEST_CODE,
|
|
44
|
-
message: 'Missing location id from response'
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
const usageTypes = Array.isArray(response.location.usageTypes) ? response.location.usageTypes : ['digital_verification'];
|
|
48
|
-
const result = await OkHiNativeModule.startAddressVerification(user.token, user.phone, user.id, location.id, location.lat, location.lon, usageTypes);
|
|
49
|
-
resolve(result);
|
|
50
|
-
} catch (error) {
|
|
51
|
-
reject(error);
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Stops verification for a particular address using a user's phonenumber and OkHi location identifier
|
|
58
|
-
* @param {string} phoneNumber The user's phone number
|
|
59
|
-
* @param {string} locationId An OkHi location identifier obtained after successfull creation of addresses.
|
|
60
|
-
* @returns {Promise<string>} A promise that resolves to a string value of the location identifier
|
|
61
|
-
*/
|
|
62
|
-
export const stopVerification = (phoneNumber, locationId) => {
|
|
63
|
-
return isValidPlatform(() => OkHiNativeModule.stopAddressVerification(phoneNumber, locationId));
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Android Only - Starts a foreground service that speeds up rate of verification
|
|
68
|
-
* @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has started successfully
|
|
69
|
-
*/
|
|
70
|
-
export const startForegroundService = () => {
|
|
71
|
-
return isValidPlatform(() => errorHandler(OkHiNativeModule.startForegroundService), 'android');
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Android Only - Stops previously started foreground services
|
|
76
|
-
* @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has stopped successfully
|
|
77
|
-
*/
|
|
78
|
-
export const stopForegroundService = () => {
|
|
79
|
-
return isValidPlatform(OkHiNativeModule.stopForegroundService, 'android');
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Android Only - Checks if the foreground service is running
|
|
84
|
-
* @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service is running
|
|
85
|
-
*/
|
|
86
|
-
export const isForegroundServiceRunning = () => {
|
|
87
|
-
return isValidPlatform(OkHiNativeModule.isForegroundServiceRunning, 'android');
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Checks whether all necessary permissions and services are available in order to start the address verification process
|
|
92
|
-
* @param {Object} configuration Object that determines whether or not to request these permissions and services from the user
|
|
93
|
-
* @param {boolean} configuration.requestServices Flag that determines whether to request the services from the user
|
|
94
|
-
* @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
|
|
95
|
-
*/
|
|
96
|
-
export const canStartVerification = configuration => {
|
|
97
|
-
return new Promise(async (resolve, reject) => {
|
|
98
|
-
const requestServices = configuration && configuration.requestServices;
|
|
99
|
-
const locationServicesStatus = await isLocationServicesEnabled();
|
|
100
|
-
const googlePlayServices = Platform.OS === 'android' ? await isGooglePlayServicesAvailable() : true;
|
|
101
|
-
const backgroundLocationPerm = await isBackgroundLocationPermissionGranted();
|
|
102
|
-
const whenInUseLocationPerm = await isLocationPermissionGranted();
|
|
103
|
-
if (!requestServices) {
|
|
104
|
-
resolve(locationServicesStatus && googlePlayServices && backgroundLocationPerm);
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
if (Platform.OS === 'ios') {
|
|
108
|
-
if (!locationServicesStatus) {
|
|
109
|
-
reject(new OkHiException({
|
|
110
|
-
code: OkHiException.SERVICE_UNAVAILABLE_CODE,
|
|
111
|
-
message: 'Location services is unavailable'
|
|
112
|
-
}));
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
if (backgroundLocationPerm) {
|
|
116
|
-
resolve(true);
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
if (whenInUseLocationPerm && !backgroundLocationPerm) {
|
|
120
|
-
resolve(false);
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
const iosPerm = await requestBackgroundLocationPermission();
|
|
124
|
-
resolve(iosPerm);
|
|
125
|
-
return;
|
|
126
|
-
} else if (Platform.OS === 'android') {
|
|
127
|
-
const locationServicesRequestStatus = await requestEnableLocationServices();
|
|
128
|
-
const gPlayServices = await requestEnableGooglePlayServices();
|
|
129
|
-
const androidPerm = (await requestLocationPermission()) && (await requestBackgroundLocationPermission());
|
|
130
|
-
resolve(locationServicesRequestStatus && gPlayServices && androidPerm);
|
|
131
|
-
} else {
|
|
132
|
-
reject(new OkHiException({
|
|
133
|
-
code: OkHiException.UNSUPPORTED_PLATFORM_CODE,
|
|
134
|
-
message: OkHiException.UNSUPPORTED_PLATFORM_MESSAGE
|
|
135
|
-
}));
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Checks whether all necessary permissions and services are available in order to start the address verification process
|
|
142
|
-
* @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
|
|
143
|
-
*/
|
|
144
|
-
export const checkVerificationStartRequirements = () => {
|
|
145
|
-
return new Promise(async (resolve, reject) => {
|
|
146
|
-
if (Platform.OS === 'android') {
|
|
147
|
-
const isPlayServicesAvailable = await isGooglePlayServicesAvailable();
|
|
148
|
-
if (!isPlayServicesAvailable) {
|
|
149
|
-
reject(new OkHiException({
|
|
150
|
-
code: OkHiException.PLAY_SERVICES_UNAVAILABLE_CODE,
|
|
151
|
-
message: 'Google Play Services is unavailable'
|
|
152
|
-
}));
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
if (!(await isLocationServicesEnabled())) {
|
|
157
|
-
reject(new OkHiException({
|
|
158
|
-
code: OkHiException.LOCATION_SERVICES_UNAVAILABLE_CODE,
|
|
159
|
-
message: 'Location services unavailable'
|
|
160
|
-
}));
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
if (!(await isBackgroundLocationPermissionGranted())) {
|
|
164
|
-
reject(new OkHiException({
|
|
165
|
-
code: OkHiException.PERMISSION_DENIED_CODE,
|
|
166
|
-
message: 'Background Location permission not granted'
|
|
167
|
-
}));
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
resolve(true);
|
|
171
|
-
});
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Android Only - Updates user's device firebase push notification token
|
|
176
|
-
* @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has started successfully
|
|
177
|
-
*/
|
|
178
|
-
export const onNewToken = fcmPushNotificationToken => {
|
|
179
|
-
if (Platform.OS === 'android') {
|
|
180
|
-
return OkHiNativeModule.onNewToken(fcmPushNotificationToken);
|
|
181
|
-
}
|
|
182
|
-
return Promise.resolve(true);
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Android Only - Should be invoked only when push notification is received.
|
|
187
|
-
* @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether the service has started successfully
|
|
188
|
-
*/
|
|
189
|
-
export const onMessageReceived = () => {
|
|
190
|
-
if (Platform.OS === 'android') {
|
|
191
|
-
return OkHiNativeModule.onMessageReceived();
|
|
192
|
-
}
|
|
193
|
-
return Promise.resolve(true);
|
|
194
|
-
};
|
|
195
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","isBackgroundLocationPermissionGranted","isGooglePlayServicesAvailable","isLocationServicesEnabled","requestBackgroundLocationPermission","requestEnableGooglePlayServices","requestEnableLocationServices","requestLocationPermission","isLocationPermissionGranted","errorHandler","isValidPlatform","OkHiNativeModule","OkHiException","start","token","phoneNumber","okhiUserId","locationId","lat","lon","usageTypes","utypes","Array","isArray","startAddressVerification","startVerification","response","Promise","resolve","reject","location","user","id","code","UNAUTHORIZED_CODE","message","UNAUTHORIZED_MESSAGE","BAD_REQUEST_CODE","result","phone","error","stopVerification","stopAddressVerification","startForegroundService","stopForegroundService","isForegroundServiceRunning","canStartVerification","configuration","requestServices","locationServicesStatus","googlePlayServices","OS","backgroundLocationPerm","whenInUseLocationPerm","SERVICE_UNAVAILABLE_CODE","iosPerm","locationServicesRequestStatus","gPlayServices","androidPerm","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,SAASA,QAAQ,QAAQ,cAAc;AACvC,SACEC,qCAAqC,EACrCC,6BAA6B,EAC7BC,yBAAyB,EACzBC,mCAAmC,EACnCC,+BAA+B,EAC/BC,6BAA6B,EAC7BC,yBAAyB,EACzBC,2BAA2B,QACtB,mBAAmB;AAC1B,SAASC,YAAY,EAAEC,eAAe,QAAQ,oBAAoB;AAClE,SAASC,gBAAgB,QAAQ,qBAAqB;AAEtD,SAASC,aAAa,QAAQ,yBAAyB;AAEvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,KAAK,GAAGA,CACnBC,KAAa,EACbC,WAAmB,EACnBC,UAAkB,EAClBC,UAAkB,EAClBC,GAAW,EACXC,GAAW,EACXC,UAAsB,KACnB;EACH,OAAOV,eAAe,CAAC,MAAM;IAC3B,MAAMW,MAAiB,GAAGC,KAAK,CAACC,OAAO,CAACH,UAAU,CAAC,GAC/CA,UAAU,GACV,CAAC,sBAAsB,CAAC;IAC5B,OAAOT,gBAAgB,CAACa,wBAAwB,CAC9CV,KAAK,EACLC,WAAW,EACXC,UAAU,EACVC,UAAU,EACVC,GAAG,EACHC,GAAG,EACHE,MACF,CAAC;EACH,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMI,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,C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B,IAAI,EAAErB,aAAa,CAACoD,kCAAkC;QACtD7B,OAAO,EAAE;MACX,CAAC,CACH,CAAC;MACD;IACF;IACA,IAAI,EAAE,MAAMlC,qCAAqC,CAAC,CAAC,CAAC,EAAE;MACpD4B,MAAM,CACJ,IAAIjB,aAAa,CAAC;QAChBqB,IAAI,EAAErB,aAAa,CAACqD,sBAAsB;QAC1C9B,OAAO,EAAE;MACX,CAAC,CACH,CAAC;MACD;IACF;IACAP,OAAO,CAAC,IAAI,CAAC;EACf,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMsC,UAAU,GAAIC,wBAAgC,IAAK;EAC9D,IAAInE,QAAQ,CAACmD,EAAE,KAAK,SAAS,EAAE;IAC7B,OAAOxC,gBAAgB,CAACuD,UAAU,CAACC,wBAAwB,CAAC;EAC9D;EACA,OAAOxC,OAAO,CAACC,OAAO,CAAC,IAAI,CAAC;AAC9B,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMwC,iBAAiB,GAAGA,CAAA,KAAM;EACrC,IAAIpE,QAAQ,CAACmD,EAAE,KAAK,SAAS,EAAE;IAC7B,OAAOxC,gBAAgB,CAACyD,iBAAiB,CAAC,CAAC;EAC7C;EACA,OAAOzC,OAAO,CAACC,OAAO,CAAC,IAAI,CAAC;AAC9B,CAAC","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":[""],"mappings":"","ignoreList":[]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks whether all necessary permissions and services are available in order to start the address creation process.
|
|
3
|
-
* @param {Object} configuration Object that determines whether or not to request these permissions and services from the user.
|
|
4
|
-
* @param {boolean} configuration.requestServices Flag that determines whether to request the services from the user.
|
|
5
|
-
* @returns {Promise<boolean>} A promise that resolves to a boolean value indicating whether or not all conditions are met to start the address creation process.
|
|
6
|
-
*/
|
|
7
|
-
export declare const canStartAddressCreation: (configuration?: {
|
|
8
|
-
requestServices?: boolean;
|
|
9
|
-
}) => Promise<boolean>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { OkHiLocationManagerProps } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* The OkHiLocationManager React Component is used to display an in app modal, enabling the user to quickly create an accurate OkHi address.
|
|
5
|
-
*/
|
|
6
|
-
export declare const OkHiLocationManager: (props: OkHiLocationManagerProps) => React.JSX.Element;
|
|
7
|
-
export default OkHiLocationManager;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { OkHiLocationManagerProps } from './types';
|
|
2
|
-
import { OkHiLocation } from '../OkCore';
|
|
3
|
-
import type { OkHiLocationManagerStartDataPayload, OkHiLocationManagerStartMessage } from './types';
|
|
4
|
-
import type { AuthApplicationConfig } from '../OkCore/_types';
|
|
5
|
-
export declare const fetchCurrentLocation: () => Promise<null | {
|
|
6
|
-
lat: number;
|
|
7
|
-
lng: number;
|
|
8
|
-
accuracy: number;
|
|
9
|
-
}>;
|
|
10
|
-
/**
|
|
11
|
-
* @ignore
|
|
12
|
-
*/
|
|
13
|
-
export declare const generateStartDataPayload: (props: OkHiLocationManagerProps, applicationConfiguration: AuthApplicationConfig) => Promise<OkHiLocationManagerStartDataPayload>;
|
|
14
|
-
/**
|
|
15
|
-
* @ignore
|
|
16
|
-
*/
|
|
17
|
-
export declare const getFrameUrl: (applicationConfiguration: AuthApplicationConfig) => string;
|
|
18
|
-
/**
|
|
19
|
-
* @ignore
|
|
20
|
-
*/
|
|
21
|
-
export declare const generateJavaScriptStartScript: (startPayload: {
|
|
22
|
-
message: OkHiLocationManagerStartMessage;
|
|
23
|
-
payload: OkHiLocationManagerStartDataPayload;
|
|
24
|
-
}) => {
|
|
25
|
-
jsBeforeLoad: string;
|
|
26
|
-
jsAfterLoad: string;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* @ignore
|
|
30
|
-
*/
|
|
31
|
-
export declare const parseOkHiLocation: (location: any) => OkHiLocation;
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import type { ViewStyle } from 'react-native';
|
|
2
|
-
import type { JSX } from 'react';
|
|
3
|
-
import type { OkHiException } from '../OkCore/OkHiException';
|
|
4
|
-
import type { OkHiUser, OkHiLocation, UsageType } from '../OkCore/types';
|
|
5
|
-
/**
|
|
6
|
-
* The OkCollect Success Response object contains information about the newly created user and location once an address has been successfully created.
|
|
7
|
-
* It can be used to extract information about the address and/or start address verification process.
|
|
8
|
-
*/
|
|
9
|
-
export interface OkCollectSuccessResponse {
|
|
10
|
-
/**
|
|
11
|
-
* The [OkHiUser](https://okhi.github.io/react-native-core/interfaces/okhiuser.html) object containing information about the newly created user.
|
|
12
|
-
*/
|
|
13
|
-
user: OkHiUser;
|
|
14
|
-
/**
|
|
15
|
-
* The [OkHiLocation](https://okhi.github.io/react-native-core/interfaces/okhilocation.html) object containing information about the newly created user.
|
|
16
|
-
*/
|
|
17
|
-
location: OkHiLocation;
|
|
18
|
-
/**
|
|
19
|
-
* Starts address verification
|
|
20
|
-
*/
|
|
21
|
-
startVerification: () => Promise<string>;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* The OkHiLocationManager exposes props that you can use to customise it's functionality and appearance.
|
|
25
|
-
*/
|
|
26
|
-
export interface OkHiLocationManagerProps {
|
|
27
|
-
/**
|
|
28
|
-
* **Required:** A boolean flag that determines whether or not to show the Location Manager.
|
|
29
|
-
*/
|
|
30
|
-
launch: boolean;
|
|
31
|
-
/**
|
|
32
|
-
* **Required:** A defined [OkHiUser](https://okhi.github.io/react-native-core/interfaces/okhiuser.html) object, with a mandatory "phone" key property.
|
|
33
|
-
*/
|
|
34
|
-
user: OkHiUser;
|
|
35
|
-
/**
|
|
36
|
-
* **Optional:** A custom JSX.Element that'll be used as a loading indicator.
|
|
37
|
-
*/
|
|
38
|
-
loader?: JSX.Element;
|
|
39
|
-
/**
|
|
40
|
-
* **Optional:** Used to customise the appearance of the Container that wraps the location manager.
|
|
41
|
-
*/
|
|
42
|
-
style?: ViewStyle;
|
|
43
|
-
/**
|
|
44
|
-
* **Required:** A callback that'll be invoked with an {@link OkCollectSuccessResponse} once an accurate OkHi address has been successfully created.
|
|
45
|
-
*/
|
|
46
|
-
onSuccess: (response: OkCollectSuccessResponse) => any;
|
|
47
|
-
/**
|
|
48
|
-
* **Required:** A callback that'll be invoked whenever an error occurs during the address creation process.
|
|
49
|
-
*/
|
|
50
|
-
onError: (error: OkHiException) => any;
|
|
51
|
-
/**
|
|
52
|
-
* **Required:** A callback that'll be invoked whenever a user taps on the close button.
|
|
53
|
-
*/
|
|
54
|
-
onCloseRequest: () => any;
|
|
55
|
-
/**
|
|
56
|
-
* **Optional:** An object that'll be used to customise the appearance of the Location Manager to better match your branding requirements.
|
|
57
|
-
*/
|
|
58
|
-
theme?: {
|
|
59
|
-
appBar?: {
|
|
60
|
-
backgroundColor?: string;
|
|
61
|
-
logo?: string;
|
|
62
|
-
};
|
|
63
|
-
colors?: {
|
|
64
|
-
primary?: string;
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* **Optional:** An object that'll be used to customise the functionality of the Location Manager. This object dictates whether you want some features on or off.
|
|
69
|
-
*/
|
|
70
|
-
config?: {
|
|
71
|
-
streetView?: boolean;
|
|
72
|
-
appBar?: {
|
|
73
|
-
visible?: boolean;
|
|
74
|
-
};
|
|
75
|
-
addressTypes?: {
|
|
76
|
-
home?: boolean;
|
|
77
|
-
work?: boolean;
|
|
78
|
-
};
|
|
79
|
-
usageTypes?: UsageType;
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* **Optional:** Enable a user to either select an existing address, or force to create a new one
|
|
83
|
-
*/
|
|
84
|
-
mode?: 'create' | 'select';
|
|
85
|
-
location?: {
|
|
86
|
-
id?: string;
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* @ignore
|
|
91
|
-
*/
|
|
92
|
-
export interface OkHiLocationManagerStartDataPayload {
|
|
93
|
-
style?: {
|
|
94
|
-
base?: {
|
|
95
|
-
color?: string;
|
|
96
|
-
logo?: string;
|
|
97
|
-
name?: string;
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
auth: {
|
|
101
|
-
authToken: string;
|
|
102
|
-
};
|
|
103
|
-
context: {
|
|
104
|
-
container?: {
|
|
105
|
-
name?: string;
|
|
106
|
-
version?: string;
|
|
107
|
-
};
|
|
108
|
-
developer: {
|
|
109
|
-
name: string;
|
|
110
|
-
};
|
|
111
|
-
library: {
|
|
112
|
-
name: string;
|
|
113
|
-
version: string;
|
|
114
|
-
};
|
|
115
|
-
platform: {
|
|
116
|
-
name: 'react-native';
|
|
117
|
-
};
|
|
118
|
-
};
|
|
119
|
-
config?: {
|
|
120
|
-
streetView?: boolean;
|
|
121
|
-
appBar?: {
|
|
122
|
-
color?: string;
|
|
123
|
-
visible?: boolean;
|
|
124
|
-
};
|
|
125
|
-
usageTypes: UsageType;
|
|
126
|
-
};
|
|
127
|
-
user: OkHiUser;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* @ignore
|
|
131
|
-
*/
|
|
132
|
-
export type OkHiLocationManagerStartMessage = 'select_location' | 'start_app';
|
|
133
|
-
/**
|
|
134
|
-
* @ignore
|
|
135
|
-
*/
|
|
136
|
-
export interface OkHiLocationManagerResponse {
|
|
137
|
-
message: 'location_selected' | 'location_created' | 'location_updated' | 'exit_app' | 'request_enable_protected_apps' | 'fatal_exit' | 'request_location_permission';
|
|
138
|
-
payload: any;
|
|
139
|
-
}
|