react-native-okhi 1.2.17 → 1.2.18-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/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.9/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.9/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/build.gradle +2 -2
- package/android/src/main/java/com/reactnativeokhi/OkhiModule.java +25 -11
- package/ios/Okhi.m +3 -0
- package/ios/Okhi.swift +15 -1
- package/ios/Okhi.xcodeproj/project.xcworkspace/xcuserdata/kiano.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/lib/commonjs/OkCollect/Helpers.js +0 -7
- package/lib/commonjs/OkCollect/Helpers.js.map +1 -1
- package/lib/commonjs/OkCollect/OkHiLocationManager.js +23 -59
- package/lib/commonjs/OkCollect/OkHiLocationManager.js.map +1 -1
- package/lib/commonjs/OkCollect/Spinner.js +1 -6
- package/lib/commonjs/OkCollect/Spinner.js.map +1 -1
- package/lib/commonjs/OkCollect/Util.js +21 -49
- package/lib/commonjs/OkCollect/Util.js.map +1 -1
- package/lib/commonjs/OkCollect/app.json +1 -1
- package/lib/commonjs/OkCollect/index.js +0 -5
- package/lib/commonjs/OkCollect/index.js.map +1 -1
- package/lib/commonjs/OkCollect/types.js.map +1 -1
- package/lib/commonjs/OkCore/Helpers.js +16 -90
- package/lib/commonjs/OkCore/Helpers.js.map +1 -1
- package/lib/commonjs/OkCore/OkHiAuth.js +9 -30
- package/lib/commonjs/OkCore/OkHiAuth.js.map +1 -1
- package/lib/commonjs/OkCore/OkHiException.js +54 -91
- package/lib/commonjs/OkCore/OkHiException.js.map +1 -1
- package/lib/commonjs/OkCore/OkHiMode.js +1 -3
- package/lib/commonjs/OkCore/OkHiMode.js.map +1 -1
- package/lib/commonjs/OkCore/_helpers.js +2 -9
- package/lib/commonjs/OkCore/_helpers.js.map +1 -1
- package/lib/commonjs/OkCore/_types.js.map +1 -1
- package/lib/commonjs/OkCore/index.js +3 -24
- package/lib/commonjs/OkCore/index.js.map +1 -1
- package/lib/commonjs/OkCore/types.js.map +1 -1
- package/lib/commonjs/OkHiNativeModule/index.js +2 -7
- package/lib/commonjs/OkHiNativeModule/index.js.map +1 -1
- package/lib/commonjs/OkVerify/index.js +19 -87
- package/lib/commonjs/OkVerify/index.js.map +1 -1
- package/lib/commonjs/OkVerify/types.js.map +1 -1
- package/lib/commonjs/index.js +0 -6
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/OkCollect/Helpers.js +1 -3
- package/lib/module/OkCollect/Helpers.js.map +1 -1
- package/lib/module/OkCollect/OkHiLocationManager.js +21 -42
- package/lib/module/OkCollect/OkHiLocationManager.js.map +1 -1
- package/lib/module/OkCollect/Spinner.js +1 -1
- package/lib/module/OkCollect/Spinner.js.map +1 -1
- package/lib/module/OkCollect/Util.js +19 -37
- package/lib/module/OkCollect/Util.js.map +1 -1
- package/lib/module/OkCollect/app.json +1 -1
- package/lib/module/OkCollect/index.js.map +1 -1
- package/lib/module/OkCollect/types.js.map +1 -1
- package/lib/module/OkCore/Helpers.js +17 -56
- package/lib/module/OkCore/Helpers.js.map +1 -1
- package/lib/module/OkCore/OkHiAuth.js +9 -21
- package/lib/module/OkCore/OkHiAuth.js.map +1 -1
- package/lib/module/OkCore/OkHiException.js +54 -89
- package/lib/module/OkCore/OkHiException.js.map +1 -1
- package/lib/module/OkCore/OkHiMode.js.map +1 -1
- package/lib/module/OkCore/_helpers.js +2 -4
- package/lib/module/OkCore/_helpers.js.map +1 -1
- package/lib/module/OkCore/_types.js.map +1 -1
- package/lib/module/OkCore/index.js +3 -12
- package/lib/module/OkCore/index.js.map +1 -1
- package/lib/module/OkCore/types.js.map +1 -1
- package/lib/module/OkHiNativeModule/index.js +0 -1
- package/lib/module/OkHiNativeModule/index.js.map +1 -1
- package/lib/module/OkVerify/index.js +19 -36
- package/lib/module/OkVerify/index.js.map +1 -1
- package/lib/module/OkVerify/types.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/OkCollect/OkHiLocationManager.d.ts +2 -1
- package/lib/typescript/OkCollect/Spinner.d.ts +2 -1
- package/lib/typescript/OkCollect/types.d.ts +5 -4
- package/lib/typescript/OkCore/_types.d.ts +3 -3
- package/lib/typescript/OkCore/types.d.ts +10 -5
- package/lib/typescript/OkHiNativeModule/index.d.ts +2 -3
- package/lib/typescript/OkVerify/index.d.ts +5 -11
- package/lib/typescript/OkVerify/types.d.ts +0 -5
- package/package.json +1 -1
- package/react-native-okhi.podspec +1 -1
- package/src/OkCollect/OkHiLocationManager.tsx +8 -4
- package/src/OkCollect/Util.ts +2 -0
- package/src/OkCollect/app.json +1 -1
- package/src/OkCollect/types.ts +4 -3
- package/src/OkCore/OkHiAuth.ts +5 -0
- package/src/OkCore/types.ts +7 -0
- package/src/OkHiNativeModule/index.ts +1 -3
- package/src/OkVerify/index.ts +19 -21
- package/src/OkVerify/types.ts +0 -3
|
@@ -4,41 +4,28 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.OkHiAuth = void 0;
|
|
7
|
-
|
|
8
7
|
var _axios = _interopRequireDefault(require("axios"));
|
|
9
|
-
|
|
10
8
|
var _OkHiMode = require("./OkHiMode");
|
|
11
|
-
|
|
12
9
|
var _OkHiException = require("./OkHiException");
|
|
13
|
-
|
|
14
10
|
var _ = require("./");
|
|
15
|
-
|
|
16
11
|
var _OkHiNativeModule = require("../OkHiNativeModule");
|
|
17
|
-
|
|
18
12
|
var _reactNative = require("react-native");
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
function
|
|
23
|
-
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
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; }
|
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
16
|
+
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); }
|
|
24
17
|
/**
|
|
25
18
|
* @ignore
|
|
26
19
|
*/
|
|
27
20
|
class OkHiAuth {
|
|
28
21
|
constructor() {
|
|
29
22
|
_defineProperty(this, "API_VERSION", 'v5');
|
|
30
|
-
|
|
31
23
|
_defineProperty(this, "ANONYMOUS_SIGN_IN_ENDPOINT", '/auth/anonymous-signin');
|
|
32
|
-
|
|
33
24
|
_defineProperty(this, "DEV_BASE_URL", `https://dev-api.okhi.io/${this.API_VERSION}` + this.ANONYMOUS_SIGN_IN_ENDPOINT);
|
|
34
|
-
|
|
35
25
|
_defineProperty(this, "SANDBOX_BASE_URL", `https://sandbox-api.okhi.io/${this.API_VERSION}` + this.ANONYMOUS_SIGN_IN_ENDPOINT);
|
|
36
|
-
|
|
37
26
|
_defineProperty(this, "PROD_BASE_URL", `https://api.okhi.io/${this.API_VERSION}` + this.ANONYMOUS_SIGN_IN_ENDPOINT);
|
|
38
|
-
|
|
39
27
|
_defineProperty(this, "config", null);
|
|
40
28
|
}
|
|
41
|
-
|
|
42
29
|
anonymousSignInWithPhoneNumber(phone, scopes, config) {
|
|
43
30
|
this.config = config;
|
|
44
31
|
return this.anonymousSignIn({
|
|
@@ -46,19 +33,16 @@ class OkHiAuth {
|
|
|
46
33
|
phone
|
|
47
34
|
});
|
|
48
35
|
}
|
|
49
|
-
|
|
50
36
|
anonymousSignInWithUserId(userId, scopes) {
|
|
51
37
|
return this.anonymousSignIn({
|
|
52
38
|
scopes,
|
|
53
39
|
user_id: userId
|
|
54
40
|
});
|
|
55
41
|
}
|
|
56
|
-
|
|
57
42
|
async anonymousSignIn(payload) {
|
|
58
43
|
return new Promise(async (resolve, reject) => {
|
|
59
44
|
try {
|
|
60
45
|
const config = this.config || (await (0, _.getApplicationConfiguration)());
|
|
61
|
-
|
|
62
46
|
if (config === null || !config.auth || !config.auth.token) {
|
|
63
47
|
reject(new _OkHiException.OkHiException({
|
|
64
48
|
code: _OkHiException.OkHiException.UNAUTHORIZED_CODE,
|
|
@@ -70,7 +54,6 @@ class OkHiAuth {
|
|
|
70
54
|
context
|
|
71
55
|
} = config;
|
|
72
56
|
let url = this.SANDBOX_BASE_URL;
|
|
73
|
-
|
|
74
57
|
if ((context === null || context === void 0 ? void 0 : context.mode) === 'dev') {
|
|
75
58
|
url = this.DEV_BASE_URL;
|
|
76
59
|
} else if ((context === null || context === void 0 ? void 0 : context.mode) === _OkHiMode.OkHiMode.PROD) {
|
|
@@ -78,20 +61,18 @@ class OkHiAuth {
|
|
|
78
61
|
} else {
|
|
79
62
|
url = this.SANDBOX_BASE_URL;
|
|
80
63
|
}
|
|
81
|
-
|
|
82
64
|
const headers = {
|
|
83
65
|
Authorization: auth.token
|
|
84
66
|
};
|
|
67
|
+
console.log(payload);
|
|
85
68
|
const {
|
|
86
69
|
data
|
|
87
70
|
} = await _axios.default.post(url, payload, {
|
|
88
71
|
headers
|
|
89
72
|
});
|
|
90
|
-
|
|
91
73
|
if (_reactNative.Platform.OS === 'android') {
|
|
92
74
|
await _OkHiNativeModule.OkHiNativeModule.setItem('okhi:recent:token', data.authorization_token); //TODO: move all anonymousSignIn to native code
|
|
93
75
|
}
|
|
94
|
-
|
|
95
76
|
resolve(data.authorization_token);
|
|
96
77
|
}
|
|
97
78
|
} catch (error) {
|
|
@@ -99,7 +80,6 @@ class OkHiAuth {
|
|
|
99
80
|
}
|
|
100
81
|
});
|
|
101
82
|
}
|
|
102
|
-
|
|
103
83
|
parseRequestError(error) {
|
|
104
84
|
if (!error.response) {
|
|
105
85
|
return new _OkHiException.OkHiException({
|
|
@@ -107,20 +87,21 @@ class OkHiAuth {
|
|
|
107
87
|
message: _OkHiException.OkHiException.NETWORK_ERROR_MESSAGE
|
|
108
88
|
});
|
|
109
89
|
}
|
|
110
|
-
|
|
90
|
+
if (_axios.default.isAxiosError(error)) {
|
|
91
|
+
console.log(error.config.headers);
|
|
92
|
+
console.log(error.config.url);
|
|
93
|
+
}
|
|
111
94
|
switch (error.response.status) {
|
|
112
95
|
case 400:
|
|
113
96
|
return new _OkHiException.OkHiException({
|
|
114
97
|
code: _OkHiException.OkHiException.INVALID_PHONE_CODE,
|
|
115
98
|
message: _OkHiException.OkHiException.INVALID_PHONE_MESSAGE
|
|
116
99
|
});
|
|
117
|
-
|
|
118
100
|
case 401:
|
|
119
101
|
return new _OkHiException.OkHiException({
|
|
120
102
|
code: _OkHiException.OkHiException.UNAUTHORIZED_CODE,
|
|
121
103
|
message: _OkHiException.OkHiException.UNAUTHORIZED_MESSAGE
|
|
122
104
|
});
|
|
123
|
-
|
|
124
105
|
default:
|
|
125
106
|
return new _OkHiException.OkHiException({
|
|
126
107
|
code: _OkHiException.OkHiException.UNKNOWN_ERROR_CODE,
|
|
@@ -128,8 +109,6 @@ class OkHiAuth {
|
|
|
128
109
|
});
|
|
129
110
|
}
|
|
130
111
|
}
|
|
131
|
-
|
|
132
112
|
}
|
|
133
|
-
|
|
134
113
|
exports.OkHiAuth = OkHiAuth;
|
|
135
114
|
//# sourceMappingURL=OkHiAuth.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["OkHiAuth","API_VERSION","ANONYMOUS_SIGN_IN_ENDPOINT","anonymousSignInWithPhoneNumber","phone","scopes","config","anonymousSignIn","anonymousSignInWithUserId","userId","user_id","payload","Promise","resolve","reject","getApplicationConfiguration","auth","token","OkHiException","code","UNAUTHORIZED_CODE","message","UNAUTHORIZED_MESSAGE","context","url","SANDBOX_BASE_URL","mode","DEV_BASE_URL","OkHiMode","PROD","PROD_BASE_URL","headers","Authorization","data","axios","post","Platform","OS","OkHiNativeModule","setItem","authorization_token","error","parseRequestError","response","NETWORK_ERROR_CODE","NETWORK_ERROR_MESSAGE","status","INVALID_PHONE_CODE","INVALID_PHONE_MESSAGE","UNKNOWN_ERROR_CODE","UNKNOWN_ERROR_MESSAGE"],"sources":["OkHiAuth.ts"],"sourcesContent":["import axios from 'axios';\nimport { OkHiMode } from './OkHiMode';\nimport { OkHiException } from './OkHiException';\nimport type { AuthApplicationConfig, OkHiAccessScope } from './_types';\nimport { getApplicationConfiguration } from './';\nimport { OkHiNativeModule } from '../OkHiNativeModule';\nimport { Platform } from 'react-native';\n\n/**\n * @ignore\n */\nexport class OkHiAuth {\n private readonly API_VERSION = 'v5';\n private readonly ANONYMOUS_SIGN_IN_ENDPOINT = '/auth/anonymous-signin';\n private readonly DEV_BASE_URL =\n `https://dev-api.okhi.io/${this.API_VERSION}` +\n this.ANONYMOUS_SIGN_IN_ENDPOINT;\n private readonly SANDBOX_BASE_URL =\n `https://sandbox-api.okhi.io/${this.API_VERSION}` +\n this.ANONYMOUS_SIGN_IN_ENDPOINT;\n private readonly PROD_BASE_URL =\n `https://api.okhi.io/${this.API_VERSION}` + this.ANONYMOUS_SIGN_IN_ENDPOINT;\n private config: AuthApplicationConfig | null = null;\n\n anonymousSignInWithPhoneNumber(\n phone: string,\n scopes: Array<OkHiAccessScope>,\n config: AuthApplicationConfig\n ) {\n this.config = config;\n return this.anonymousSignIn({\n scopes,\n phone,\n });\n }\n\n protected anonymousSignInWithUserId(\n userId: string,\n scopes: Array<OkHiAccessScope>\n ) {\n return this.anonymousSignIn({\n scopes,\n user_id: userId,\n });\n }\n\n private async anonymousSignIn(payload: {\n scopes: Array<OkHiAccessScope>;\n [key: string]: any;\n }): Promise<string> {\n return new Promise(async (resolve, reject) => {\n try {\n const config = this.config || (await getApplicationConfiguration());\n if (config === null || !config.auth || !config.auth.token) {\n reject(\n new OkHiException({\n code: OkHiException.UNAUTHORIZED_CODE,\n message: OkHiException.UNAUTHORIZED_MESSAGE,\n })\n );\n } else {\n const { auth, context } = config;\n let url = this.SANDBOX_BASE_URL;\n if (context?.mode === ('dev' as any)) {\n url = this.DEV_BASE_URL;\n } else if (context?.mode === OkHiMode.PROD) {\n url = this.PROD_BASE_URL;\n } else {\n url = this.SANDBOX_BASE_URL;\n }\n const headers = { Authorization: auth.token };\n const { data } = await axios.post(url, payload, {\n headers,\n });\n if (Platform.OS === 'android') {\n await OkHiNativeModule.setItem(\n 'okhi:recent:token',\n data.authorization_token\n ); //TODO: move all anonymousSignIn to native code\n }\n resolve(data.authorization_token);\n }\n } catch (error) {\n reject(this.parseRequestError(error));\n }\n });\n }\n\n private parseRequestError(error: any) {\n if (!error.response) {\n return new OkHiException({\n code: OkHiException.NETWORK_ERROR_CODE,\n message: OkHiException.NETWORK_ERROR_MESSAGE,\n });\n }\n switch (error.response.status) {\n case 400:\n return new OkHiException({\n code: OkHiException.INVALID_PHONE_CODE,\n message: OkHiException.INVALID_PHONE_MESSAGE,\n });\n case 401:\n return new OkHiException({\n code: OkHiException.UNAUTHORIZED_CODE,\n message: OkHiException.UNAUTHORIZED_MESSAGE,\n });\n default:\n return new OkHiException({\n code: OkHiException.UNKNOWN_ERROR_CODE,\n message: error.message || OkHiException.UNKNOWN_ERROR_MESSAGE,\n });\n }\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_axios","_interopRequireDefault","require","_OkHiMode","_OkHiException","_","_OkHiNativeModule","_reactNative","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","OkHiAuth","constructor","API_VERSION","ANONYMOUS_SIGN_IN_ENDPOINT","anonymousSignInWithPhoneNumber","phone","scopes","config","anonymousSignIn","anonymousSignInWithUserId","userId","user_id","payload","Promise","resolve","reject","getApplicationConfiguration","auth","token","OkHiException","code","UNAUTHORIZED_CODE","message","UNAUTHORIZED_MESSAGE","context","url","SANDBOX_BASE_URL","mode","DEV_BASE_URL","OkHiMode","PROD","PROD_BASE_URL","headers","Authorization","console","log","data","axios","post","Platform","OS","OkHiNativeModule","setItem","authorization_token","error","parseRequestError","response","NETWORK_ERROR_CODE","NETWORK_ERROR_MESSAGE","isAxiosError","status","INVALID_PHONE_CODE","INVALID_PHONE_MESSAGE","UNKNOWN_ERROR_CODE","UNKNOWN_ERROR_MESSAGE","exports"],"sources":["OkHiAuth.ts"],"sourcesContent":["import axios from 'axios';\nimport { OkHiMode } from './OkHiMode';\nimport { OkHiException } from './OkHiException';\nimport type { AuthApplicationConfig, OkHiAccessScope } from './_types';\nimport { getApplicationConfiguration } from './';\nimport { OkHiNativeModule } from '../OkHiNativeModule';\nimport { Platform } from 'react-native';\n\n/**\n * @ignore\n */\nexport class OkHiAuth {\n private readonly API_VERSION = 'v5';\n private readonly ANONYMOUS_SIGN_IN_ENDPOINT = '/auth/anonymous-signin';\n private readonly DEV_BASE_URL =\n `https://dev-api.okhi.io/${this.API_VERSION}` +\n this.ANONYMOUS_SIGN_IN_ENDPOINT;\n private readonly SANDBOX_BASE_URL =\n `https://sandbox-api.okhi.io/${this.API_VERSION}` +\n this.ANONYMOUS_SIGN_IN_ENDPOINT;\n private readonly PROD_BASE_URL =\n `https://api.okhi.io/${this.API_VERSION}` + this.ANONYMOUS_SIGN_IN_ENDPOINT;\n private config: AuthApplicationConfig | null = null;\n\n anonymousSignInWithPhoneNumber(\n phone: string,\n scopes: Array<OkHiAccessScope>,\n config: AuthApplicationConfig\n ) {\n this.config = config;\n return this.anonymousSignIn({\n scopes,\n phone,\n });\n }\n\n protected anonymousSignInWithUserId(\n userId: string,\n scopes: Array<OkHiAccessScope>\n ) {\n return this.anonymousSignIn({\n scopes,\n user_id: userId,\n });\n }\n\n private async anonymousSignIn(payload: {\n scopes: Array<OkHiAccessScope>;\n [key: string]: any;\n }): Promise<string> {\n return new Promise(async (resolve, reject) => {\n try {\n const config = this.config || (await getApplicationConfiguration());\n if (config === null || !config.auth || !config.auth.token) {\n reject(\n new OkHiException({\n code: OkHiException.UNAUTHORIZED_CODE,\n message: OkHiException.UNAUTHORIZED_MESSAGE,\n })\n );\n } else {\n const { auth, context } = config;\n let url = this.SANDBOX_BASE_URL;\n if (context?.mode === ('dev' as any)) {\n url = this.DEV_BASE_URL;\n } else if (context?.mode === OkHiMode.PROD) {\n url = this.PROD_BASE_URL;\n } else {\n url = this.SANDBOX_BASE_URL;\n }\n const headers = { Authorization: auth.token };\n console.log(payload);\n const { data } = await axios.post(url, payload, {\n headers,\n });\n if (Platform.OS === 'android') {\n await OkHiNativeModule.setItem(\n 'okhi:recent:token',\n data.authorization_token\n ); //TODO: move all anonymousSignIn to native code\n }\n resolve(data.authorization_token);\n }\n } catch (error) {\n reject(this.parseRequestError(error));\n }\n });\n }\n\n private parseRequestError(error: any) {\n if (!error.response) {\n return new OkHiException({\n code: OkHiException.NETWORK_ERROR_CODE,\n message: OkHiException.NETWORK_ERROR_MESSAGE,\n });\n }\n if (axios.isAxiosError(error)) {\n console.log(error.config.headers);\n console.log(error.config.url);\n }\n switch (error.response.status) {\n case 400:\n return new OkHiException({\n code: OkHiException.INVALID_PHONE_CODE,\n message: OkHiException.INVALID_PHONE_MESSAGE,\n });\n case 401:\n return new OkHiException({\n code: OkHiException.UNAUTHORIZED_CODE,\n message: OkHiException.UNAUTHORIZED_MESSAGE,\n });\n default:\n return new OkHiException({\n code: OkHiException.UNKNOWN_ERROR_CODE,\n message: error.message || OkHiException.UNKNOWN_ERROR_MESSAGE,\n });\n }\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,S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BAAa,CAACgC,kBAAkB;UACtC7B,OAAO,EAAEH,4BAAa,CAACiC;QACzB,CAAC,CAAC;MACJ,KAAK,GAAG;QACN,OAAO,IAAIjC,4BAAa,CAAC;UACvBC,IAAI,EAAED,4BAAa,CAACE,iBAAiB;UACrCC,OAAO,EAAEH,4BAAa,CAACI;QACzB,CAAC,CAAC;MACJ;QACE,OAAO,IAAIJ,4BAAa,CAAC;UACvBC,IAAI,EAAED,4BAAa,CAACkC,kBAAkB;UACtC/B,OAAO,EAAEsB,KAAK,CAACtB,OAAO,IAAIH,4BAAa,CAACmC;QAC1C,CAAC,CAAC;IACN;EACF;AACF;AAACC,OAAA,CAAAvD,QAAA,GAAAA,QAAA","ignoreList":[]}
|
|
@@ -4,82 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.OkHiException = void 0;
|
|
7
|
-
|
|
8
|
-
function
|
|
9
|
-
|
|
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
10
|
/**
|
|
11
11
|
* The OkHiException class extends the Error class to provide additional information regarding the type of errors thrown while running any OkHiLibraries.
|
|
12
12
|
* It contains static string properties that can be used to evaluate the kind of errors being thrown and handle them appropriately.
|
|
13
13
|
*/
|
|
14
14
|
class OkHiException extends Error {
|
|
15
|
-
/**
|
|
16
|
-
* Error is thrown when location services is unavailable.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Error is thrown when play services is unavailable.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Error is thrown when the device can't connect to OkHi's servers.
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Error is thrown when the device can't connect to OkHi's servers.
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Error is thrown whenever there's an unknown error that occured during the usage of one of OkHi's services.
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Error is thrown whenever there's an unknown error that occured during the usage of one of OkHi's services.
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Error is thrown whenever an invalid phone number is provided to a service that requires a user's phone number.
|
|
41
|
-
*/
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Error is thrown whenever an invalid phone number is provided to a service that requires a user's phone number.
|
|
45
|
-
*/
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Error is thrown whenever there's an issue with the credentials provided.
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Error is thrown whenever there's an issue with the credentials provided.
|
|
53
|
-
*/
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Error is thrown whenever a particular permission is required for a service to run and isn't granted by the user.
|
|
57
|
-
*/
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Error is thrown whenever a particular device service is required for a library to run and isn't granted by the user.
|
|
61
|
-
*/
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Error is thrown whenever an OkHi service is run on an unsupported platform.
|
|
65
|
-
*/
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Error is thrown whenever an OkHi service is run on an unsupported platform.
|
|
69
|
-
*/
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Error is thrown whenever bad configuration is provided to an OkHi service.
|
|
73
|
-
*/
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Error is thrown whenever bad configuration is provided to an OkHi service.
|
|
77
|
-
*/
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Specific error code string detailing the kind of error being thrown.
|
|
81
|
-
*/
|
|
82
|
-
|
|
83
15
|
/**
|
|
84
16
|
* @param error An error object with code and respective message.
|
|
85
17
|
* @param error.code Specific error code string detailing the kind of error being thrown.
|
|
@@ -87,47 +19,78 @@ class OkHiException extends Error {
|
|
|
87
19
|
*/
|
|
88
20
|
constructor(error) {
|
|
89
21
|
super(error.message);
|
|
90
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Specific error code string detailing the kind of error being thrown.
|
|
24
|
+
*/
|
|
91
25
|
_defineProperty(this, "code", void 0);
|
|
92
|
-
|
|
93
26
|
this.name = 'OkHiException';
|
|
94
27
|
this.message = error.message;
|
|
95
28
|
this.code = error.code;
|
|
96
29
|
}
|
|
97
|
-
|
|
98
30
|
}
|
|
99
|
-
|
|
100
31
|
exports.OkHiException = OkHiException;
|
|
101
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Error is thrown when location services is unavailable.
|
|
34
|
+
*/
|
|
102
35
|
_defineProperty(OkHiException, "LOCATION_SERVICES_UNAVAILABLE_CODE", 'location_services_unavailable');
|
|
103
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Error is thrown when play services is unavailable.
|
|
38
|
+
*/
|
|
104
39
|
_defineProperty(OkHiException, "PLAY_SERVICES_UNAVAILABLE_CODE", 'play_services_unavailable');
|
|
105
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Error is thrown when the device can't connect to OkHi's servers.
|
|
42
|
+
*/
|
|
106
43
|
_defineProperty(OkHiException, "NETWORK_ERROR_CODE", 'network_error');
|
|
107
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Error is thrown when the device can't connect to OkHi's servers.
|
|
46
|
+
*/
|
|
108
47
|
_defineProperty(OkHiException, "NETWORK_ERROR_MESSAGE", 'Unable to establish a connection with OkHi servers');
|
|
109
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Error is thrown whenever there's an unknown error that occured during the usage of one of OkHi's services.
|
|
50
|
+
*/
|
|
110
51
|
_defineProperty(OkHiException, "UNKNOWN_ERROR_CODE", 'unknown_error');
|
|
111
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Error is thrown whenever there's an unknown error that occured during the usage of one of OkHi's services.
|
|
54
|
+
*/
|
|
112
55
|
_defineProperty(OkHiException, "UNKNOWN_ERROR_MESSAGE", 'Unable to process the request. Something went wrong');
|
|
113
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Error is thrown whenever an invalid phone number is provided to a service that requires a user's phone number.
|
|
58
|
+
*/
|
|
114
59
|
_defineProperty(OkHiException, "INVALID_PHONE_CODE", 'invalid_phone');
|
|
115
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Error is thrown whenever an invalid phone number is provided to a service that requires a user's phone number.
|
|
62
|
+
*/
|
|
116
63
|
_defineProperty(OkHiException, "INVALID_PHONE_MESSAGE", 'Invalid phone number provided. Please make sure its in MSISDN standard format');
|
|
117
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Error is thrown whenever there's an issue with the credentials provided.
|
|
66
|
+
*/
|
|
118
67
|
_defineProperty(OkHiException, "UNAUTHORIZED_CODE", 'unauthorized');
|
|
119
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Error is thrown whenever there's an issue with the credentials provided.
|
|
70
|
+
*/
|
|
120
71
|
_defineProperty(OkHiException, "UNAUTHORIZED_MESSAGE", 'Invalid credentials provided');
|
|
121
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Error is thrown whenever a particular permission is required for a service to run and isn't granted by the user.
|
|
74
|
+
*/
|
|
122
75
|
_defineProperty(OkHiException, "PERMISSION_DENIED_CODE", 'permission_denied');
|
|
123
|
-
|
|
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
|
+
*/
|
|
124
79
|
_defineProperty(OkHiException, "SERVICE_UNAVAILABLE_CODE", 'service_unavailable');
|
|
125
|
-
|
|
80
|
+
/**
|
|
81
|
+
* Error is thrown whenever an OkHi service is run on an unsupported platform.
|
|
82
|
+
*/
|
|
126
83
|
_defineProperty(OkHiException, "UNSUPPORTED_PLATFORM_CODE", 'unsupported_platform');
|
|
127
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Error is thrown whenever an OkHi service is run on an unsupported platform.
|
|
86
|
+
*/
|
|
128
87
|
_defineProperty(OkHiException, "UNSUPPORTED_PLATFORM_MESSAGE", 'Current platform is not supported');
|
|
129
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Error is thrown whenever bad configuration is provided to an OkHi service.
|
|
90
|
+
*/
|
|
130
91
|
_defineProperty(OkHiException, "BAD_REQUEST_CODE", 'bad_request');
|
|
131
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Error is thrown whenever bad configuration is provided to an OkHi service.
|
|
94
|
+
*/
|
|
132
95
|
_defineProperty(OkHiException, "BAD_REQUEST_MESSAGE", 'Invalid parameters provided');
|
|
133
96
|
//# sourceMappingURL=OkHiException.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["OkHiException","Error","constructor","error","message","name","code"],"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,
|
|
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":[]}
|
|
@@ -4,13 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.OkHiMode = void 0;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Sets the current mode that you'd like to use OkHi's services.
|
|
10
9
|
*/
|
|
11
|
-
const OkHiMode = Object.freeze({
|
|
10
|
+
const OkHiMode = exports.OkHiMode = Object.freeze({
|
|
12
11
|
SANDBOX: 'sandbox',
|
|
13
12
|
PROD: 'prod'
|
|
14
13
|
});
|
|
15
|
-
exports.OkHiMode = OkHiMode;
|
|
16
14
|
//# sourceMappingURL=OkHiMode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["OkHiMode","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":"
|
|
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":[]}
|
|
@@ -5,23 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.errorHandler = errorHandler;
|
|
7
7
|
exports.isValidPlatform = isValidPlatform;
|
|
8
|
-
|
|
9
8
|
var _reactNative = require("react-native");
|
|
10
|
-
|
|
11
9
|
var _OkHiException = require("./OkHiException");
|
|
12
|
-
|
|
13
10
|
const SUPPORTED_PLATFORMS = ['ios', 'android'];
|
|
14
|
-
|
|
15
11
|
function isValidPlatform(fn, platform) {
|
|
16
|
-
var _arguments$callee
|
|
17
|
-
|
|
18
|
-
const callingFunc = (arguments === null || arguments === void 0 ? void 0 : (_arguments$callee = arguments.callee) === null || _arguments$callee === void 0 ? void 0 : (_arguments$callee$cal = _arguments$callee.caller) === null || _arguments$callee$cal === void 0 ? void 0 : _arguments$callee$cal.name) || 'function';
|
|
12
|
+
var _arguments$callee;
|
|
13
|
+
const callingFunc = (arguments === null || arguments === void 0 || (_arguments$callee = arguments.callee) === null || _arguments$callee === void 0 || (_arguments$callee = _arguments$callee.caller) === null || _arguments$callee === void 0 ? void 0 : _arguments$callee.name) || 'function';
|
|
19
14
|
return new Promise((resolve, reject) => {
|
|
20
15
|
const error = new _OkHiException.OkHiException({
|
|
21
16
|
code: _OkHiException.OkHiException.UNSUPPORTED_PLATFORM_CODE,
|
|
22
17
|
message: callingFunc + ' is not supported in ' + _reactNative.Platform.OS
|
|
23
18
|
});
|
|
24
|
-
|
|
25
19
|
if (platform && _reactNative.Platform.OS !== platform) {
|
|
26
20
|
reject(error);
|
|
27
21
|
} else if (!SUPPORTED_PLATFORMS.includes(_reactNative.Platform.OS)) {
|
|
@@ -36,7 +30,6 @@ function isValidPlatform(fn, platform) {
|
|
|
36
30
|
}
|
|
37
31
|
});
|
|
38
32
|
}
|
|
39
|
-
|
|
40
33
|
function errorHandler(fn) {
|
|
41
34
|
return new Promise((resolve, reject) => {
|
|
42
35
|
fn().then(resolve).catch(error => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SUPPORTED_PLATFORMS","isValidPlatform","fn","platform","callingFunc","arguments","callee","caller","name","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 const callingFunc = arguments?.callee?.caller?.name || 'function';\n return new Promise<T>((resolve, reject) => {\n const error = new OkHiException({\n code: OkHiException.UNSUPPORTED_PLATFORM_CODE,\n message: callingFunc + ' 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":"
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_OkHiException","SUPPORTED_PLATFORMS","isValidPlatform","fn","platform","_arguments$callee","callingFunc","arguments","callee","caller","name","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 const callingFunc = arguments?.callee?.caller?.name || 'function';\n return new Promise<T>((resolve, reject) => {\n const error = new OkHiException({\n code: OkHiException.UNSUPPORTED_PLATFORM_CODE,\n message: callingFunc + ' 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.UNKN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,CAAC,CACH,CAAC;MACH,CAAC,CAAC;IACN;EACF,CAAC,CAAC;AACJ;AAEO,SAASC,YAAYA,CAAIvB,EAAoB,EAAE;EACpD,OAAO,IAAIQ,OAAO,CAAI,CAACC,OAAO,EAAEC,MAAM,KAAK;IACzCV,EAAE,CAAC,CAAC,CACDmB,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 +1 @@
|
|
|
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":""}
|
|
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":[]}
|
|
@@ -9,15 +9,10 @@ var _exportNames = {
|
|
|
9
9
|
};
|
|
10
10
|
exports.getApplicationConfiguration = getApplicationConfiguration;
|
|
11
11
|
exports.initialize = initialize;
|
|
12
|
-
|
|
13
12
|
var _reactNative = require("react-native");
|
|
14
|
-
|
|
15
13
|
var _OkHiNativeModule = require("../OkHiNativeModule");
|
|
16
|
-
|
|
17
14
|
var _helpers = require("./_helpers");
|
|
18
|
-
|
|
19
15
|
var _OkHiException = require("./OkHiException");
|
|
20
|
-
|
|
21
16
|
Object.keys(_OkHiException).forEach(function (key) {
|
|
22
17
|
if (key === "default" || key === "__esModule") return;
|
|
23
18
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -29,9 +24,7 @@ Object.keys(_OkHiException).forEach(function (key) {
|
|
|
29
24
|
}
|
|
30
25
|
});
|
|
31
26
|
});
|
|
32
|
-
|
|
33
27
|
var _types = require("./types");
|
|
34
|
-
|
|
35
28
|
Object.keys(_types).forEach(function (key) {
|
|
36
29
|
if (key === "default" || key === "__esModule") return;
|
|
37
30
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -43,9 +36,7 @@ Object.keys(_types).forEach(function (key) {
|
|
|
43
36
|
}
|
|
44
37
|
});
|
|
45
38
|
});
|
|
46
|
-
|
|
47
39
|
var _OkHiMode = require("./OkHiMode");
|
|
48
|
-
|
|
49
40
|
Object.keys(_OkHiMode).forEach(function (key) {
|
|
50
41
|
if (key === "default" || key === "__esModule") return;
|
|
51
42
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -57,9 +48,7 @@ Object.keys(_OkHiMode).forEach(function (key) {
|
|
|
57
48
|
}
|
|
58
49
|
});
|
|
59
50
|
});
|
|
60
|
-
|
|
61
51
|
var _Helpers = require("./Helpers");
|
|
62
|
-
|
|
63
52
|
Object.keys(_Helpers).forEach(function (key) {
|
|
64
53
|
if (key === "default" || key === "__esModule") return;
|
|
65
54
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -72,12 +61,10 @@ Object.keys(_Helpers).forEach(function (key) {
|
|
|
72
61
|
});
|
|
73
62
|
});
|
|
74
63
|
let okhiApplicationConfiguration;
|
|
75
|
-
|
|
76
64
|
function validateConfiguration(config) {
|
|
77
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) {
|
|
78
66
|
return false;
|
|
79
67
|
}
|
|
80
|
-
|
|
81
68
|
return true;
|
|
82
69
|
}
|
|
83
70
|
/**
|
|
@@ -85,50 +72,42 @@ function validateConfiguration(config) {
|
|
|
85
72
|
* @param {Object} configuration A configuration object with your OkHi credentials as well as library settings
|
|
86
73
|
* @returns {Promise<void>} A promise that resolves when initialization is successful
|
|
87
74
|
*/
|
|
88
|
-
|
|
89
|
-
|
|
90
75
|
function initialize(configuration) {
|
|
91
76
|
return (0, _helpers.errorHandler)(async () => {
|
|
92
77
|
const isValidConfig = validateConfiguration(configuration);
|
|
93
|
-
|
|
94
78
|
if (!isValidConfig) {
|
|
95
79
|
throw new _OkHiException.OkHiException({
|
|
96
80
|
code: _OkHiException.OkHiException.UNAUTHORIZED_CODE,
|
|
97
81
|
message: 'Invalid OkHi configuration provided.'
|
|
98
82
|
});
|
|
99
83
|
}
|
|
100
|
-
|
|
101
84
|
if (_reactNative.Platform.OS === 'ios') {
|
|
102
85
|
await _OkHiNativeModule.OkHiNativeModule.initializeIOS(configuration.credentials.branchId, configuration.credentials.clientKey, configuration.context.mode);
|
|
103
|
-
|
|
104
86
|
if (_reactNative.AppState.currentState !== 'background') {
|
|
105
87
|
await _OkHiNativeModule.OkHiNativeModule.onStart();
|
|
106
88
|
}
|
|
107
89
|
} else {
|
|
108
90
|
await _OkHiNativeModule.OkHiNativeModule.initialize(JSON.stringify(configuration));
|
|
109
91
|
}
|
|
110
|
-
|
|
111
92
|
okhiApplicationConfiguration = configuration;
|
|
112
93
|
});
|
|
113
94
|
}
|
|
95
|
+
|
|
114
96
|
/**
|
|
115
97
|
* Obtains your current running configuration
|
|
116
98
|
* @returns {Promise<void>} A promise that resolves with your application configuration
|
|
117
99
|
*/
|
|
118
|
-
|
|
119
|
-
|
|
120
100
|
async function getApplicationConfiguration() {
|
|
121
101
|
try {
|
|
122
102
|
if (typeof okhiApplicationConfiguration === 'object') {
|
|
123
103
|
var _okhiApplicationConfi, _okhiApplicationConfi2;
|
|
124
|
-
|
|
125
|
-
|
|
104
|
+
return {
|
|
105
|
+
...okhiApplicationConfiguration,
|
|
126
106
|
auth: {
|
|
127
107
|
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) || '')
|
|
128
108
|
}
|
|
129
109
|
};
|
|
130
110
|
}
|
|
131
|
-
|
|
132
111
|
return null;
|
|
133
112
|
} catch (error) {
|
|
134
113
|
throw error;
|