@tap-payments/auth-jsconnect 1.0.94-test → 2.0.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/README.md +2 -2
- package/build/@types/app.d.ts +2 -2
- package/build/api/auth.d.ts +2 -0
- package/build/api/axios.d.ts +2 -2
- package/build/api/axios.js +63 -0
- package/build/api/country.d.ts +1 -2
- package/build/api/country.js +7 -8
- package/build/api/firebase.d.ts +1 -1
- package/build/api/firebase.js +5 -2
- package/build/api/index.d.ts +4 -5
- package/build/api/ip.d.ts +1 -1
- package/build/api/ip.js +5 -2
- package/build/api/lead.d.ts +2 -0
- package/build/api/operator.d.ts +1 -1
- package/build/api/operator.js +60 -4
- package/build/app/settings.d.ts +6 -15
- package/build/app/settings.js +82 -142
- package/build/constants/app.d.ts +1 -0
- package/build/constants/app.js +1 -0
- package/build/features/app/bank/bankStore.js +2 -2
- package/build/features/app/business/businessStore.js +2 -2
- package/build/features/app/connect/connectStore.js +4 -2
- package/build/features/app/individual/individualStore.js +2 -2
- package/build/features/app/password/passwordStore.js +2 -2
- package/build/features/app/tax/taxStore.js +2 -2
- package/build/features/bank/Bank.js +3 -3
- package/build/features/business/Business.js +3 -3
- package/build/features/individual/Individual.js +3 -3
- package/build/features/password/Password.js +3 -3
- package/build/features/shared/Button/FlowsButtons.js +3 -2
- package/build/features/tax/Tax.js +3 -3
- package/build/hooks/useAppConfig.d.ts +1 -4
- package/build/hooks/useAppConfig.js +13 -113
- package/build/utils/array.d.ts +3 -0
- package/build/utils/array.js +10 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -77,8 +77,8 @@ const App = () => {
|
|
|
77
77
|
<meta charset="utf-8" />
|
|
78
78
|
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,shrink-to-fit=no" />
|
|
79
79
|
<title>Auth-JsConnect</title>
|
|
80
|
-
<script src="https://auth-jsconnect.b-cdn.net/build-
|
|
81
|
-
<link href="https://auth-jsconnect.b-cdn.net/build-
|
|
80
|
+
<script src="https://auth-jsconnect.b-cdn.net/build-2.0.0/main.js"></script>
|
|
81
|
+
<link href="https://auth-jsconnect.b-cdn.net/build-2.0.0/main.css" rel="stylesheet" />
|
|
82
82
|
</head>
|
|
83
83
|
<body>
|
|
84
84
|
<div id="root"></div>
|
package/build/@types/app.d.ts
CHANGED
|
@@ -143,14 +143,14 @@ export interface Entry {
|
|
|
143
143
|
version: string;
|
|
144
144
|
}
|
|
145
145
|
export interface DeviceInfo {
|
|
146
|
-
source: 'browser|app';
|
|
146
|
+
source: 'browser' | 'app';
|
|
147
147
|
device: DeviceDetails;
|
|
148
148
|
browser: BrowserDetails;
|
|
149
149
|
app: AppInfo & {
|
|
150
150
|
language?: string;
|
|
151
151
|
};
|
|
152
152
|
connection: Connection;
|
|
153
|
-
entry
|
|
153
|
+
entry?: Entry;
|
|
154
154
|
}
|
|
155
155
|
export interface LocalProps {
|
|
156
156
|
[country: string]: {
|
package/build/api/auth.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { LanguageMode } from '../@types';
|
|
2
3
|
export declare type MobileCredential = {
|
|
3
4
|
code: string;
|
|
4
5
|
phone: string;
|
|
@@ -17,6 +18,7 @@ export declare type CreateAuthBody = {
|
|
|
17
18
|
sign_in: boolean;
|
|
18
19
|
step_name: string;
|
|
19
20
|
encryption_contract: Array<string>;
|
|
21
|
+
lang?: LanguageMode;
|
|
20
22
|
};
|
|
21
23
|
export declare type VerifyAuthBody = {
|
|
22
24
|
auth_token: string;
|
package/build/api/axios.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
2
|
declare const instance: import("axios").AxiosInstance;
|
|
3
3
|
export declare const setAxiosGlobalHeaders: (headers: Record<string, string>) => void;
|
|
4
4
|
export declare const removeAxiosGlobalHeaders: (arr: Array<string>) => void;
|
|
5
|
-
export
|
|
5
|
+
export declare const httpClient: (config: AxiosRequestConfig) => Promise<any>;
|
|
6
6
|
export default instance;
|
package/build/api/axios.js
CHANGED
|
@@ -1,3 +1,39 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (_) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
1
37
|
import axios from 'axios';
|
|
2
38
|
import { get, set } from 'lodash-es';
|
|
3
39
|
import { ENCRYPTION_FLAG } from '../constants';
|
|
@@ -42,4 +78,31 @@ export var removeAxiosGlobalHeaders = function (arr) {
|
|
|
42
78
|
delete axios.defaults.headers.common[key];
|
|
43
79
|
});
|
|
44
80
|
};
|
|
81
|
+
export var httpClient = function (config) { return __awaiter(void 0, void 0, void 0, function () {
|
|
82
|
+
var data, description, error_1, response, data, description;
|
|
83
|
+
var _a, _b;
|
|
84
|
+
return __generator(this, function (_c) {
|
|
85
|
+
switch (_c.label) {
|
|
86
|
+
case 0:
|
|
87
|
+
_c.trys.push([0, 2, , 3]);
|
|
88
|
+
return [4, instance(config)];
|
|
89
|
+
case 1:
|
|
90
|
+
data = (_c.sent()).data;
|
|
91
|
+
if (data.errors && Array.isArray(data.errors)) {
|
|
92
|
+
description = ((_a = data.errors) === null || _a === void 0 ? void 0 : _a[0]).description;
|
|
93
|
+
throw new Error(description);
|
|
94
|
+
}
|
|
95
|
+
return [2, data];
|
|
96
|
+
case 2:
|
|
97
|
+
error_1 = _c.sent();
|
|
98
|
+
response = error_1.response;
|
|
99
|
+
data = (response || {}).data;
|
|
100
|
+
if (typeof data === 'string')
|
|
101
|
+
throw new Error(data);
|
|
102
|
+
description = (((_b = data.errors) === null || _b === void 0 ? void 0 : _b[0]) || {}).description;
|
|
103
|
+
throw new Error(description || 'Something went wrong');
|
|
104
|
+
case 3: return [2];
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}); };
|
|
45
108
|
export default instance;
|
package/build/api/country.d.ts
CHANGED
package/build/api/country.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { httpClient } from './axios';
|
|
2
2
|
import { ENDPOINT_PATHS } from '../constants';
|
|
3
|
-
var
|
|
4
|
-
return
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
var getCountries = function () {
|
|
4
|
+
return httpClient({
|
|
5
|
+
method: 'post',
|
|
6
|
+
url: ENDPOINT_PATHS.COUNTRIES
|
|
7
|
+
});
|
|
8
8
|
};
|
|
9
9
|
var countryService = {
|
|
10
|
-
|
|
11
|
-
getAllCountries: getAllCountries
|
|
10
|
+
getCountries: getCountries
|
|
12
11
|
};
|
|
13
12
|
export { countryService };
|
package/build/api/firebase.d.ts
CHANGED
package/build/api/firebase.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
1
|
import { ENDPOINT_PATHS } from '../constants';
|
|
2
|
+
import { httpClient } from './axios';
|
|
3
3
|
var getLocale = function () {
|
|
4
|
-
return
|
|
4
|
+
return httpClient({
|
|
5
|
+
method: 'get',
|
|
6
|
+
url: ENDPOINT_PATHS.FIREBASE_URL
|
|
7
|
+
});
|
|
5
8
|
};
|
|
6
9
|
var firebaseService = {
|
|
7
10
|
getLocale: getLocale
|
package/build/api/index.d.ts
CHANGED
|
@@ -8,14 +8,13 @@ import { CreateAccountBody } from './account';
|
|
|
8
8
|
import { BrandListBody } from './individual';
|
|
9
9
|
declare const API: {
|
|
10
10
|
ipService: {
|
|
11
|
-
getIP: () => Promise<
|
|
11
|
+
getIP: () => Promise<any>;
|
|
12
12
|
};
|
|
13
13
|
operatorService: {
|
|
14
|
-
validateOperator: (body: ValidateOperatorBody) => Promise<
|
|
14
|
+
validateOperator: (body: ValidateOperatorBody) => Promise<any>;
|
|
15
15
|
};
|
|
16
16
|
countryService: {
|
|
17
|
-
|
|
18
|
-
getAllCountries: () => Promise<import("axios").AxiosResponse<any, any>>;
|
|
17
|
+
getCountries: () => Promise<any>;
|
|
19
18
|
};
|
|
20
19
|
authService: {
|
|
21
20
|
createAuth: (data: CreateAuthBody, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
@@ -43,7 +42,7 @@ declare const API: {
|
|
|
43
42
|
checkIbanBank: (data: import("./availabilityServices").CheckIBanBody, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
44
43
|
};
|
|
45
44
|
firebaseService: {
|
|
46
|
-
getLocale: () => Promise<
|
|
45
|
+
getLocale: () => Promise<any>;
|
|
47
46
|
};
|
|
48
47
|
accountService: {
|
|
49
48
|
createAccount: (data: CreateAccountBody, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("axios").AxiosResponse<any, any>>;
|
package/build/api/ip.d.ts
CHANGED
package/build/api/ip.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { ENDPOINT_PATHS } from '../constants';
|
|
2
|
-
import
|
|
2
|
+
import { httpClient } from './axios';
|
|
3
3
|
var getIP = function () {
|
|
4
|
-
return
|
|
4
|
+
return httpClient({
|
|
5
|
+
method: 'get',
|
|
6
|
+
url: ENDPOINT_PATHS.IP
|
|
7
|
+
});
|
|
5
8
|
};
|
|
6
9
|
var ipService = {
|
|
7
10
|
getIP: getIP
|
package/build/api/lead.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { LanguageMode } from '../@types';
|
|
2
3
|
declare type Name = {
|
|
3
4
|
title?: string;
|
|
4
5
|
first?: string;
|
|
@@ -60,6 +61,7 @@ export declare type UpdateLeadBody = {
|
|
|
60
61
|
name: string;
|
|
61
62
|
url: string;
|
|
62
63
|
}[];
|
|
64
|
+
lang?: LanguageMode;
|
|
63
65
|
};
|
|
64
66
|
export declare type LeadVerifyBody = {
|
|
65
67
|
verify_token: string;
|
package/build/api/operator.d.ts
CHANGED
|
@@ -7,6 +7,6 @@ export declare type ValidateOperatorBody = {
|
|
|
7
7
|
connect_pkey?: string;
|
|
8
8
|
};
|
|
9
9
|
declare const operatorService: {
|
|
10
|
-
validateOperator: (body: ValidateOperatorBody) => Promise<
|
|
10
|
+
validateOperator: (body: ValidateOperatorBody) => Promise<any>;
|
|
11
11
|
};
|
|
12
12
|
export { operatorService };
|
package/build/api/operator.js
CHANGED
|
@@ -1,8 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (_) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
5
36
|
};
|
|
37
|
+
import { ENDPOINT_PATHS } from '../constants';
|
|
38
|
+
import { httpClient } from './axios';
|
|
39
|
+
var validateOperator = function (body) { return __awaiter(void 0, void 0, void 0, function () {
|
|
40
|
+
var data, error_1;
|
|
41
|
+
return __generator(this, function (_a) {
|
|
42
|
+
switch (_a.label) {
|
|
43
|
+
case 0:
|
|
44
|
+
_a.trys.push([0, 2, , 3]);
|
|
45
|
+
return [4, httpClient({
|
|
46
|
+
method: 'post',
|
|
47
|
+
url: ENDPOINT_PATHS.OPERATOR,
|
|
48
|
+
data: body
|
|
49
|
+
})];
|
|
50
|
+
case 1:
|
|
51
|
+
data = _a.sent();
|
|
52
|
+
if (data !== 'valid')
|
|
53
|
+
throw new Error('invalid operator');
|
|
54
|
+
return [2, data];
|
|
55
|
+
case 2:
|
|
56
|
+
error_1 = _a.sent();
|
|
57
|
+
throw new Error(error_1);
|
|
58
|
+
case 3: return [2];
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}); };
|
|
6
62
|
var operatorService = {
|
|
7
63
|
validateOperator: validateOperator
|
|
8
64
|
};
|
package/build/app/settings.d.ts
CHANGED
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
import { RootState } from './store';
|
|
2
|
-
import { ActionState, LanguageMode, SharedState, ThemeMode, ScreenStepNavigation, DeviceInfo,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
businessCountry:
|
|
6
|
-
|
|
2
|
+
import { ActionState, LanguageMode, SharedState, ThemeMode, ScreenStepNavigation, DeviceInfo, LibConfig, CountryCode } from '../@types';
|
|
3
|
+
export declare const fetchAppSettingsSync: import("@reduxjs/toolkit").AsyncThunk<{
|
|
4
|
+
countries: CountryCode[];
|
|
5
|
+
businessCountry: CountryCode;
|
|
6
|
+
locale: any;
|
|
7
|
+
deviceInfo: DeviceInfo;
|
|
7
8
|
}, void, {}>;
|
|
8
|
-
export declare const getClientIp: import("@reduxjs/toolkit").AsyncThunk<any, void, {}>;
|
|
9
|
-
export declare const getBrowserFingerPrint: import("@reduxjs/toolkit").AsyncThunk<{
|
|
10
|
-
fingerPrint: import("@fingerprintjs/fingerprintjs").GetResult;
|
|
11
|
-
client: import("device-detector-js/dist/parsers/client").ClientResult;
|
|
12
|
-
device: import("device-detector-js/dist/parsers/device").DeviceResult;
|
|
13
|
-
os: import("device-detector-js/dist/parsers/operating-system").Result;
|
|
14
|
-
appInfo: AppInfo;
|
|
15
|
-
}, AppInfo, {}>;
|
|
16
|
-
export declare const getOperator: import("@reduxjs/toolkit").AsyncThunk<any, ValidateOperatorBody, {}>;
|
|
17
|
-
export declare const getLocale: import("@reduxjs/toolkit").AsyncThunk<any, void, {}>;
|
|
18
9
|
export interface SettingsData {
|
|
19
10
|
skin: ThemeMode;
|
|
20
11
|
language: LanguageMode;
|
package/build/app/settings.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
1
12
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
13
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
14
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -36,79 +47,78 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
47
|
};
|
|
37
48
|
var _a;
|
|
38
49
|
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
|
39
|
-
import { getStoredData, storeData, isArray, findItem, getBrowserInfo, getFingerPrint } from '../utils';
|
|
50
|
+
import { getStoredData, storeData, isArray, findItem, getBrowserInfo, getFingerPrint, sortCountries, findCountryByIso2, getRequestHeaders, encryptString } from '../utils';
|
|
40
51
|
import { defaultCountry, DefaultDeviceInfo, LOCAL_STORAGE_KEYS } from '../constants';
|
|
41
52
|
import i18n from '../i18n';
|
|
42
53
|
import { updateLocale } from '../utils/locale';
|
|
43
|
-
import API from '../api';
|
|
44
|
-
export var
|
|
45
|
-
var settings,
|
|
46
|
-
return __generator(this, function (
|
|
47
|
-
switch (
|
|
54
|
+
import API, { setAxiosGlobalHeaders } from '../api';
|
|
55
|
+
export var fetchAppSettingsSync = createAsyncThunk('fetchAppSettingsSync', function (_, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
56
|
+
var settings, _a, appConfig, language, _b, client, device, os, _c, visitorId, _d, ip, latitude, longitude, locale, list, operatorData, deviceInfo, countries, businessCountry;
|
|
57
|
+
return __generator(this, function (_e) {
|
|
58
|
+
switch (_e.label) {
|
|
48
59
|
case 0:
|
|
49
60
|
settings = thunkApi.getState().settings;
|
|
50
|
-
|
|
61
|
+
_a = settings.data, appConfig = _a.appConfig, language = _a.language;
|
|
62
|
+
_b = getBrowserInfo(), client = _b.client, device = _b.device, os = _b.os;
|
|
63
|
+
return [4, Promise.all([
|
|
64
|
+
getFingerPrint(),
|
|
65
|
+
API.ipService.getIP(),
|
|
66
|
+
API.firebaseService.getLocale(),
|
|
67
|
+
API.countryService.getCountries()
|
|
68
|
+
])];
|
|
51
69
|
case 1:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
export var getLocale = createAsyncThunk('getLocale', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
99
|
-
var data;
|
|
100
|
-
return __generator(this, function (_a) {
|
|
101
|
-
switch (_a.label) {
|
|
102
|
-
case 0: return [4, API.firebaseService.getLocale()];
|
|
103
|
-
case 1:
|
|
104
|
-
data = (_a.sent()).data;
|
|
105
|
-
return [2, data];
|
|
70
|
+
_c = _e.sent(), visitorId = _c[0].visitorId, _d = _c[1], ip = _d.ip, latitude = _d.latitude, longitude = _d.longitude, locale = _c[2], list = _c[3].list;
|
|
71
|
+
operatorData = {
|
|
72
|
+
type: 'website',
|
|
73
|
+
app_client_version: 'js-auth-connect',
|
|
74
|
+
requirer_browser: "".concat(client === null || client === void 0 ? void 0 : client.name, " , ").concat(client === null || client === void 0 ? void 0 : client.version),
|
|
75
|
+
os: "".concat(os === null || os === void 0 ? void 0 : os.name, " , ").concat(os === null || os === void 0 ? void 0 : os.version),
|
|
76
|
+
locale: language
|
|
77
|
+
};
|
|
78
|
+
deviceInfo = {
|
|
79
|
+
app: {
|
|
80
|
+
language: appConfig.language || 'en',
|
|
81
|
+
name: appConfig.appInfo.name,
|
|
82
|
+
identifier: appConfig.appInfo.identifier || 'auth-connect',
|
|
83
|
+
version: appConfig.appInfo.version || '2.0.0'
|
|
84
|
+
},
|
|
85
|
+
browser: {
|
|
86
|
+
browser_id: visitorId,
|
|
87
|
+
name: (client === null || client === void 0 ? void 0 : client.name) || '',
|
|
88
|
+
user_agent: window.navigator.userAgent,
|
|
89
|
+
version: (client === null || client === void 0 ? void 0 : client.version) || ''
|
|
90
|
+
},
|
|
91
|
+
device: {
|
|
92
|
+
name: '',
|
|
93
|
+
brand: (device === null || device === void 0 ? void 0 : device.brand) || '',
|
|
94
|
+
model: (device === null || device === void 0 ? void 0 : device.model) || '',
|
|
95
|
+
type: (device === null || device === void 0 ? void 0 : device.type) || '',
|
|
96
|
+
os: {
|
|
97
|
+
name: (os === null || os === void 0 ? void 0 : os.name) || '',
|
|
98
|
+
version: (os === null || os === void 0 ? void 0 : os.version) || ''
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
connection: {
|
|
102
|
+
ip: ip,
|
|
103
|
+
latitude: latitude,
|
|
104
|
+
longitude: longitude,
|
|
105
|
+
mac: ''
|
|
106
|
+
},
|
|
107
|
+
source: 'browser'
|
|
108
|
+
};
|
|
109
|
+
setAxiosGlobalHeaders(__assign(__assign({}, getRequestHeaders(deviceInfo)), { authorization: encryptString(appConfig.publicKey), mdn: encryptString(window.location.origin) }));
|
|
110
|
+
return [4, API.operatorService.validateOperator(operatorData)];
|
|
111
|
+
case 2:
|
|
112
|
+
_e.sent();
|
|
113
|
+
countries = sortCountries(list);
|
|
114
|
+
businessCountry = findCountryByIso2(countries, appConfig.businessCountryCode) || defaultCountry;
|
|
115
|
+
return [2, { countries: countries, businessCountry: businessCountry, locale: locale, deviceInfo: deviceInfo }];
|
|
106
116
|
}
|
|
107
117
|
});
|
|
108
118
|
}); });
|
|
109
119
|
var initialState = {
|
|
110
120
|
error: null,
|
|
111
|
-
loading:
|
|
121
|
+
loading: true,
|
|
112
122
|
data: {
|
|
113
123
|
open: true,
|
|
114
124
|
isTapOrigin: true,
|
|
@@ -207,89 +217,19 @@ export var settingsSlice = createSlice({
|
|
|
207
217
|
}
|
|
208
218
|
},
|
|
209
219
|
extraReducers: function (builder) {
|
|
210
|
-
builder
|
|
211
|
-
.addCase(getCountries.fulfilled, function (state, action) {
|
|
212
|
-
state.error = null;
|
|
213
|
-
state.loading = false;
|
|
214
|
-
var _a = action.payload, countries = _a.countries, businessCountry = _a.businessCountry;
|
|
215
|
-
state.data.countries = countries;
|
|
216
|
-
state.data.businessCountry = businessCountry || defaultCountry;
|
|
217
|
-
})
|
|
218
|
-
.addCase(getCountries.pending, function (state) {
|
|
219
|
-
state.error = null;
|
|
220
|
+
builder.addCase(fetchAppSettingsSync.pending, function (state) {
|
|
220
221
|
state.loading = true;
|
|
221
|
-
})
|
|
222
|
-
.addCase(getCountries.rejected, function (state, action) {
|
|
223
|
-
state.error = action.error.message;
|
|
224
|
-
state.loading = false;
|
|
225
|
-
})
|
|
226
|
-
.addCase(getClientIp.pending, function (state) {
|
|
227
222
|
state.error = null;
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
.
|
|
231
|
-
state.
|
|
232
|
-
state.
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
state.data.deviceInfo.connection.latitude = latitude;
|
|
236
|
-
state.data.deviceInfo.connection.longitude = longitude;
|
|
237
|
-
})
|
|
238
|
-
.addCase(getClientIp.rejected, function (state, action) {
|
|
239
|
-
state.error = action.error.message;
|
|
240
|
-
state.loading = false;
|
|
241
|
-
})
|
|
242
|
-
.addCase(getBrowserFingerPrint.pending, function (state) {
|
|
243
|
-
state.loading = true;
|
|
244
|
-
state.error = null;
|
|
245
|
-
})
|
|
246
|
-
.addCase(getBrowserFingerPrint.fulfilled, function (state, action) {
|
|
247
|
-
state.loading = false;
|
|
248
|
-
state.error = null;
|
|
249
|
-
var _a = action.payload, appInfo = _a.appInfo, client = _a.client, device = _a.device, fingerPrint = _a.fingerPrint, os = _a.os;
|
|
250
|
-
state.data.deviceInfo.app.language = state.data.appConfig.language || 'en';
|
|
251
|
-
state.data.deviceInfo.app.name = appInfo.name;
|
|
252
|
-
state.data.deviceInfo.app.version = appInfo.version || '2.0.0';
|
|
253
|
-
state.data.deviceInfo.app.identifier = appInfo.identifier || 'auth-connect-demo';
|
|
254
|
-
state.data.deviceInfo.browser.browser_id = fingerPrint === null || fingerPrint === void 0 ? void 0 : fingerPrint.visitorId;
|
|
255
|
-
state.data.deviceInfo.browser.name = (client === null || client === void 0 ? void 0 : client.name) || '';
|
|
256
|
-
state.data.deviceInfo.browser.user_agent = window.navigator.userAgent;
|
|
257
|
-
state.data.deviceInfo.browser.version = (client === null || client === void 0 ? void 0 : client.version) || '';
|
|
258
|
-
state.data.deviceInfo.device.brand = (device === null || device === void 0 ? void 0 : device.brand) || '';
|
|
259
|
-
state.data.deviceInfo.device.model = (device === null || device === void 0 ? void 0 : device.model) || '';
|
|
260
|
-
state.data.deviceInfo.device.os.name = (os === null || os === void 0 ? void 0 : os.name) || '';
|
|
261
|
-
state.data.deviceInfo.device.os.version = (os === null || os === void 0 ? void 0 : os.version) || '';
|
|
262
|
-
state.data.deviceInfo.device.type = (device === null || device === void 0 ? void 0 : device.type) || '';
|
|
263
|
-
})
|
|
264
|
-
.addCase(getBrowserFingerPrint.rejected, function (state, action) {
|
|
265
|
-
state.loading = false;
|
|
266
|
-
state.loading = false;
|
|
267
|
-
state.error = action.error.message;
|
|
268
|
-
})
|
|
269
|
-
.addCase(getOperator.pending, function (state) {
|
|
270
|
-
state.error = null;
|
|
271
|
-
state.loading = true;
|
|
272
|
-
})
|
|
273
|
-
.addCase(getOperator.fulfilled, function (state, action) {
|
|
274
|
-
state.loading = false;
|
|
275
|
-
if (action.payload === 'valid') {
|
|
276
|
-
state.error = null;
|
|
277
|
-
}
|
|
278
|
-
})
|
|
279
|
-
.addCase(getOperator.rejected, function (state, action) {
|
|
280
|
-
state.error = action.error.message;
|
|
281
|
-
state.loading = false;
|
|
282
|
-
})
|
|
283
|
-
.addCase(getLocale.pending, function (state) {
|
|
284
|
-
state.error = null;
|
|
285
|
-
state.loading = true;
|
|
286
|
-
})
|
|
287
|
-
.addCase(getLocale.fulfilled, function (state, action) {
|
|
223
|
+
});
|
|
224
|
+
builder.addCase(fetchAppSettingsSync.fulfilled, function (state, action) {
|
|
225
|
+
var _a = action.payload, businessCountry = _a.businessCountry, countries = _a.countries, locale = _a.locale, deviceInfo = _a.deviceInfo;
|
|
226
|
+
state.data.countries = countries;
|
|
227
|
+
state.data.businessCountry = businessCountry;
|
|
228
|
+
state.data.deviceInfo = deviceInfo;
|
|
229
|
+
updateLocale(locale, businessCountry.iso2);
|
|
288
230
|
state.loading = false;
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
})
|
|
292
|
-
.addCase(getLocale.rejected, function (state, action) {
|
|
231
|
+
});
|
|
232
|
+
builder.addCase(fetchAppSettingsSync.rejected, function (state, action) {
|
|
293
233
|
state.loading = false;
|
|
294
234
|
state.error = action.error.message;
|
|
295
235
|
});
|
package/build/constants/app.d.ts
CHANGED
package/build/constants/app.js
CHANGED
|
@@ -272,6 +272,7 @@ export var CONNECT_STEP_NAMES = {
|
|
|
272
272
|
CONNECT_SUCCESS: 'connect_completed'
|
|
273
273
|
};
|
|
274
274
|
export var BUSINESS_STEP_NAMES = {
|
|
275
|
+
BUSINESS_INFO: 'business_info',
|
|
275
276
|
PHONE_AUTH: 'business_phone_auth',
|
|
276
277
|
IDENTITY_AUTH: 'business_identity_auth',
|
|
277
278
|
IDENTITY_VERIFY_AUTH: 'business_identity_auth_verify',
|
|
@@ -49,7 +49,7 @@ var _a;
|
|
|
49
49
|
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
|
50
50
|
import API from '../../../api';
|
|
51
51
|
import { FlowsTypes } from '../../../@types';
|
|
52
|
-
import { hasKey
|
|
52
|
+
import { hasKey } from '../../../utils';
|
|
53
53
|
import { handleNextScreenStep } from '../../../app/settings';
|
|
54
54
|
import { BANK_STEP_NAMES } from '../../../constants';
|
|
55
55
|
export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -211,6 +211,7 @@ export var updateLeadSuccess = createAsyncThunk('updateLeadBankSuccess', functio
|
|
|
211
211
|
if (!id)
|
|
212
212
|
return [2];
|
|
213
213
|
payload = {
|
|
214
|
+
lang: settings.data.language,
|
|
214
215
|
step_name: BANK_STEP_NAMES.BANK_SUCCESS,
|
|
215
216
|
id: id,
|
|
216
217
|
encryption_contract: []
|
|
@@ -355,7 +356,6 @@ export var bankSlice = createSlice({
|
|
|
355
356
|
}
|
|
356
357
|
var flows = response.flows, steps = response.steps;
|
|
357
358
|
state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { flows: flows, steps: steps });
|
|
358
|
-
removeRequestHeaders();
|
|
359
359
|
})
|
|
360
360
|
.addCase(updateLeadSuccess.pending, function (state) {
|
|
361
361
|
state.loading = true;
|
|
@@ -60,7 +60,7 @@ import moment from 'moment';
|
|
|
60
60
|
import API from '../../../api';
|
|
61
61
|
import { BusinessType, FlowsTypes } from '../../../@types';
|
|
62
62
|
import { BUSINESS_STEP_NAMES, IDENTIFICATION_TYPE, OTHER_CR_LICENSE, OTHER_FL_LICENSE } from '../../../constants';
|
|
63
|
-
import { convertNumbers2English, getFlowUrl, hasKey
|
|
63
|
+
import { convertNumbers2English, getFlowUrl, hasKey } from '../../../utils';
|
|
64
64
|
import { handleNextScreenStep } from '../../../app/settings';
|
|
65
65
|
export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
66
66
|
var payload, data, leadResponse;
|
|
@@ -377,6 +377,7 @@ export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (p
|
|
|
377
377
|
if (flowCompleted || !id)
|
|
378
378
|
return [2];
|
|
379
379
|
payload = {
|
|
380
|
+
lang: settings.data.language,
|
|
380
381
|
step_name: BUSINESS_STEP_NAMES.BUSINESS_SUCCESS,
|
|
381
382
|
id: id,
|
|
382
383
|
flows: [
|
|
@@ -771,7 +772,6 @@ export var businessSlice = createSlice({
|
|
|
771
772
|
return;
|
|
772
773
|
}
|
|
773
774
|
state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), response);
|
|
774
|
-
removeRequestHeaders();
|
|
775
775
|
})
|
|
776
776
|
.addCase(updateLeadSuccess.pending, function (state) {
|
|
777
777
|
state.loading = true;
|
|
@@ -61,7 +61,7 @@ import { FlowsTypes } from '../../../@types';
|
|
|
61
61
|
import API from '../../../api';
|
|
62
62
|
import { CONNECT_STEP_NAMES, IDENTIFICATION_TYPE, INSTAGRAM_URL, OTHER_BRAND, TWITTER_URL } from '../../../constants';
|
|
63
63
|
import { defaultCountry } from '../../../constants';
|
|
64
|
-
import { getIndividualName, getFlowUrl, capitalizeTheFirstLetterOfEachWord
|
|
64
|
+
import { getIndividualName, getFlowUrl, capitalizeTheFirstLetterOfEachWord } from '../../../utils';
|
|
65
65
|
export var createMobileAuth = createAsyncThunk('createMobileAuth', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
66
66
|
var settings, requestBody, data;
|
|
67
67
|
var _a, _b;
|
|
@@ -70,6 +70,7 @@ export var createMobileAuth = createAsyncThunk('createMobileAuth', function (par
|
|
|
70
70
|
case 0:
|
|
71
71
|
settings = thunkApi.getState().settings;
|
|
72
72
|
requestBody = {
|
|
73
|
+
lang: settings.data.language,
|
|
73
74
|
user_credentail: {
|
|
74
75
|
phone: params.mobile || '',
|
|
75
76
|
code: params.countryCode.idd_prefix.toString()
|
|
@@ -98,6 +99,7 @@ export var createNIDAuth = createAsyncThunk('createNIDAuth', function (params, t
|
|
|
98
99
|
_a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
|
|
99
100
|
identification_id_type = params.nid.startsWith('1') ? IDENTIFICATION_TYPE.NID : IDENTIFICATION_TYPE.IQAMA;
|
|
100
101
|
requestBody = {
|
|
102
|
+
lang: settings.data.language,
|
|
101
103
|
user_credentail: {
|
|
102
104
|
identification_id: params.nid,
|
|
103
105
|
identification_id_type: identification_id_type,
|
|
@@ -347,6 +349,7 @@ export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (p
|
|
|
347
349
|
isExistingUser = (responseBody === null || responseBody === void 0 ? void 0 : responseBody.new_user) === false;
|
|
348
350
|
leadId = isExistingUser ? (_c = brandData.responseBody) === null || _c === void 0 ? void 0 : _c.lead_id : (_d = otpData.responseBody) === null || _d === void 0 ? void 0 : _d.lead_id;
|
|
349
351
|
payload = {
|
|
352
|
+
lang: settings.data.language,
|
|
350
353
|
step_name: CONNECT_STEP_NAMES.CONNECT_SUCCESS,
|
|
351
354
|
flows: [
|
|
352
355
|
{
|
|
@@ -637,7 +640,6 @@ export var connectSlice = createSlice({
|
|
|
637
640
|
state.error = description;
|
|
638
641
|
return;
|
|
639
642
|
}
|
|
640
|
-
removeRequestHeaders();
|
|
641
643
|
})
|
|
642
644
|
.addCase(updateLeadSuccess.pending, function (state) {
|
|
643
645
|
state.loading = true;
|
|
@@ -49,7 +49,7 @@ var _a;
|
|
|
49
49
|
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
|
50
50
|
import API from '../../../api';
|
|
51
51
|
import { FlowsTypes } from '../../../@types';
|
|
52
|
-
import { hasKey
|
|
52
|
+
import { hasKey } from '../../../utils';
|
|
53
53
|
import { handleNextScreenStep } from '../../../app/settings';
|
|
54
54
|
import { INDIVIDUAl_STEP_NAMES } from '../../../constants';
|
|
55
55
|
export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -216,6 +216,7 @@ export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (p
|
|
|
216
216
|
if (!id)
|
|
217
217
|
return [2];
|
|
218
218
|
payload = {
|
|
219
|
+
lang: settings.data.language,
|
|
219
220
|
step_name: INDIVIDUAl_STEP_NAMES.INDIVIDUAl_SUCCESS,
|
|
220
221
|
id: id,
|
|
221
222
|
encryption_contract: []
|
|
@@ -407,7 +408,6 @@ export var individualSlice = createSlice({
|
|
|
407
408
|
}
|
|
408
409
|
var flows = response.flows, steps = response.steps;
|
|
409
410
|
state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { flows: flows, steps: steps });
|
|
410
|
-
removeRequestHeaders();
|
|
411
411
|
})
|
|
412
412
|
.addCase(updateLeadSuccess.pending, function (state) {
|
|
413
413
|
state.loading = true;
|
|
@@ -49,7 +49,7 @@ var _a;
|
|
|
49
49
|
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
|
50
50
|
import API from '../../../api';
|
|
51
51
|
import { FlowsTypes } from '../../../@types';
|
|
52
|
-
import { hasKey
|
|
52
|
+
import { hasKey } from '../../../utils';
|
|
53
53
|
import { handleNextScreenStep } from '../../../app/settings';
|
|
54
54
|
import { PASSWORD_STEP_NAMES } from '../../../constants';
|
|
55
55
|
export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -184,6 +184,7 @@ export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (p
|
|
|
184
184
|
if (!id)
|
|
185
185
|
return [2];
|
|
186
186
|
payload = {
|
|
187
|
+
lang: settings.data.language,
|
|
187
188
|
step_name: PASSWORD_STEP_NAMES.PASSWORD_SUCCESS,
|
|
188
189
|
id: id,
|
|
189
190
|
encryption_contract: []
|
|
@@ -346,7 +347,6 @@ export var passwordSlice = createSlice({
|
|
|
346
347
|
}
|
|
347
348
|
var flows = response.flows, steps = response.steps;
|
|
348
349
|
state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { flows: flows, steps: steps });
|
|
349
|
-
removeRequestHeaders();
|
|
350
350
|
})
|
|
351
351
|
.addCase(updateLeadSuccess.pending, function (state) {
|
|
352
352
|
state.loading = true;
|
|
@@ -49,7 +49,7 @@ var _a;
|
|
|
49
49
|
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
|
50
50
|
import API from '../../../api';
|
|
51
51
|
import { FlowsTypes } from '../../../@types';
|
|
52
|
-
import { hasKey
|
|
52
|
+
import { hasKey } from '../../../utils';
|
|
53
53
|
import { handleNextScreenStep } from '../../../app/settings';
|
|
54
54
|
import { TAX_STEP_NAMES } from '../../../constants';
|
|
55
55
|
export var verifyLeadToken = createAsyncThunk('verifyLeadToken', function (token, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -183,6 +183,7 @@ export var updateLeadSuccess = createAsyncThunk('updateLeadSuccess', function (p
|
|
|
183
183
|
if (!id)
|
|
184
184
|
return [2];
|
|
185
185
|
payload = {
|
|
186
|
+
lang: settings.data.language,
|
|
186
187
|
step_name: TAX_STEP_NAMES.TAX_SUCCESS,
|
|
187
188
|
id: id,
|
|
188
189
|
encryption_contract: []
|
|
@@ -345,7 +346,6 @@ export var taxSlice = createSlice({
|
|
|
345
346
|
}
|
|
346
347
|
var flows = response.flows, steps = response.steps;
|
|
347
348
|
state.data.verify.responseBody = __assign(__assign({}, state.data.verify.responseBody), { flows: flows, steps: steps });
|
|
348
|
-
removeRequestHeaders();
|
|
349
349
|
})
|
|
350
350
|
.addCase(updateLeadSuccess.pending, function (state) {
|
|
351
351
|
state.loading = true;
|
|
@@ -29,7 +29,7 @@ var Bank = memo(function (props) {
|
|
|
29
29
|
var dispatch = useAppDispatch();
|
|
30
30
|
var _a = useAppSelector(settingsSelector), data = _a.data, error = _a.error, settingLoading = _a.loading;
|
|
31
31
|
var _b = useAppSelector(bankSelector), customLoading = _b.customLoading, bankError = _b.error;
|
|
32
|
-
|
|
32
|
+
useAppConfig(__assign({ navigation: BANK_SCREENS_NAVIGATION }, props));
|
|
33
33
|
useErrorListener(bankError || error);
|
|
34
34
|
useStepStartedListener();
|
|
35
35
|
var activeScreen = data.activeScreen, isTapOrigin = data.isTapOrigin, open = data.open;
|
|
@@ -44,9 +44,9 @@ var Bank = memo(function (props) {
|
|
|
44
44
|
dispatch(verifyLeadToken(token));
|
|
45
45
|
};
|
|
46
46
|
useEffect(function () {
|
|
47
|
-
if (!
|
|
47
|
+
if (!settingLoading)
|
|
48
48
|
verifyToken();
|
|
49
|
-
}, [
|
|
49
|
+
}, [settingLoading]);
|
|
50
50
|
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Background, __assign({ isTapOrigin: isTapOrigin, loading: settingLoading || customLoading }, { children: _jsx(AnimationFlow, __assign({ isTapOrigin: isTapOrigin, loading: settingLoading || customLoading, error: error, open: open, breakpoint: 'sm', footer: _jsx(CustomFooter, {}) }, { children: _jsx(FeatureContainer, { children: bankFeatureScreens.map(function (_a, index) {
|
|
51
51
|
var Element = _a.element, name = _a.name;
|
|
52
52
|
var isActive = activeScreen.name === name;
|
|
@@ -29,7 +29,7 @@ var Business = memo(function (props) {
|
|
|
29
29
|
var dispatch = useAppDispatch();
|
|
30
30
|
var _a = useAppSelector(settingsSelector), data = _a.data, error = _a.error, settingLoading = _a.loading;
|
|
31
31
|
var _b = useAppSelector(businessSelector), customLoading = _b.customLoading, businessError = _b.error;
|
|
32
|
-
|
|
32
|
+
useAppConfig(__assign({ navigation: BUSINESS_SCREENS_NAVIGATION }, props));
|
|
33
33
|
useErrorListener(businessError || error);
|
|
34
34
|
useStepStartedListener();
|
|
35
35
|
var activeScreen = data.activeScreen, isTapOrigin = data.isTapOrigin, open = data.open;
|
|
@@ -44,9 +44,9 @@ var Business = memo(function (props) {
|
|
|
44
44
|
dispatch(verifyLeadToken(token));
|
|
45
45
|
};
|
|
46
46
|
useEffect(function () {
|
|
47
|
-
if (!
|
|
47
|
+
if (!settingLoading)
|
|
48
48
|
verifyToken();
|
|
49
|
-
}, [
|
|
49
|
+
}, [settingLoading]);
|
|
50
50
|
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Background, __assign({ isTapOrigin: isTapOrigin, loading: settingLoading || customLoading }, { children: _jsx(AnimationFlow, __assign({ isTapOrigin: isTapOrigin, loading: settingLoading || customLoading, error: error, open: open, breakpoint: 'sm', footer: _jsx(CustomFooter, {}) }, { children: _jsx(FeatureContainer, { children: businessFeatureScreens.map(function (_a, index) {
|
|
51
51
|
var Element = _a.element, name = _a.name;
|
|
52
52
|
var isActive = activeScreen.name === name;
|
|
@@ -29,7 +29,7 @@ var Individual = memo(function (props) {
|
|
|
29
29
|
var dispatch = useAppDispatch();
|
|
30
30
|
var _a = useAppSelector(settingsSelector), data = _a.data, error = _a.error, settingLoading = _a.loading;
|
|
31
31
|
var _b = useAppSelector(individualSelector), customLoading = _b.customLoading, individualError = _b.error;
|
|
32
|
-
|
|
32
|
+
useAppConfig(__assign({ navigation: INDIVIDUAL_SCREENS_NAVIGATION }, props));
|
|
33
33
|
useErrorListener(individualError || error);
|
|
34
34
|
useStepStartedListener();
|
|
35
35
|
var activeScreen = data.activeScreen, isTapOrigin = data.isTapOrigin, open = data.open;
|
|
@@ -44,9 +44,9 @@ var Individual = memo(function (props) {
|
|
|
44
44
|
dispatch(verifyLeadToken(token));
|
|
45
45
|
};
|
|
46
46
|
useEffect(function () {
|
|
47
|
-
if (!
|
|
47
|
+
if (!settingLoading)
|
|
48
48
|
verifyToken();
|
|
49
|
-
}, [
|
|
49
|
+
}, [settingLoading]);
|
|
50
50
|
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Background, __assign({ isTapOrigin: isTapOrigin, loading: settingLoading || customLoading }, { children: _jsx(AnimationFlow, __assign({ isTapOrigin: isTapOrigin, loading: settingLoading || customLoading, error: error, open: open, breakpoint: 'sm', footer: _jsx(CustomFooter, {}) }, { children: _jsx(FeatureContainer, { children: individualFeatureScreens.map(function (_a, index) {
|
|
51
51
|
var Element = _a.element, name = _a.name;
|
|
52
52
|
var isActive = activeScreen.name === name;
|
|
@@ -29,7 +29,7 @@ var Password = memo(function (props) {
|
|
|
29
29
|
var dispatch = useAppDispatch();
|
|
30
30
|
var _a = useAppSelector(settingsSelector), data = _a.data, error = _a.error, settingLoading = _a.loading;
|
|
31
31
|
var _b = useAppSelector(passwordSelector), customLoading = _b.customLoading, passwordError = _b.error;
|
|
32
|
-
|
|
32
|
+
useAppConfig(__assign({ navigation: PASSWORD_SCREENS_NAVIGATION }, props));
|
|
33
33
|
useErrorListener(passwordError || error);
|
|
34
34
|
useStepStartedListener();
|
|
35
35
|
var activeScreen = data.activeScreen, isTapOrigin = data.isTapOrigin, open = data.open;
|
|
@@ -44,9 +44,9 @@ var Password = memo(function (props) {
|
|
|
44
44
|
dispatch(verifyLeadToken(token));
|
|
45
45
|
};
|
|
46
46
|
useEffect(function () {
|
|
47
|
-
if (!
|
|
47
|
+
if (!settingLoading)
|
|
48
48
|
verifyToken();
|
|
49
|
-
}, [
|
|
49
|
+
}, [settingLoading]);
|
|
50
50
|
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Background, __assign({ isTapOrigin: isTapOrigin, loading: settingLoading || customLoading }, { children: _jsx(AnimationFlow, __assign({ isTapOrigin: isTapOrigin, loading: settingLoading || customLoading, error: error, open: open, breakpoint: 'sm', footer: _jsx(CustomFooter, {}) }, { children: _jsx(FeatureContainer, { children: passwordFeatureScreens.map(function (_a, index) {
|
|
51
51
|
var Element = _a.element, name = _a.name;
|
|
52
52
|
var isActive = activeScreen.name === name;
|
|
@@ -16,7 +16,7 @@ import Box from '@mui/material/Box';
|
|
|
16
16
|
import Link from '@mui/material/Link';
|
|
17
17
|
import { ICONS_NAMES } from '../../../constants';
|
|
18
18
|
import CheckIcon from '@mui/icons-material/Check';
|
|
19
|
-
import { useAppDispatch } from '../../../hooks';
|
|
19
|
+
import { useAppDispatch, useLanguage } from '../../../hooks';
|
|
20
20
|
import { handleOpen, handleCurrentActiveScreen } from '../../../app/settings';
|
|
21
21
|
import { getScreenNameBasedOnFlow } from '../../../utils';
|
|
22
22
|
var Image = styled('img')(function (_a) {
|
|
@@ -87,6 +87,7 @@ var CheckIconStyled = styled(CheckIcon)(function (_a) {
|
|
|
87
87
|
export default function FlowsButtons(_a) {
|
|
88
88
|
var buttons = _a.buttons, flowName = _a.flowName;
|
|
89
89
|
var dispatch = useAppDispatch();
|
|
90
|
+
var isAr = useLanguage().isAr;
|
|
90
91
|
var onRedirect = function (item) {
|
|
91
92
|
if (item.isCompleted)
|
|
92
93
|
return;
|
|
@@ -104,6 +105,6 @@ export default function FlowsButtons(_a) {
|
|
|
104
105
|
var isLast = idx === buttons.length - 1;
|
|
105
106
|
return (_jsx(Link, __assign({ underline: 'none', onClick: function () {
|
|
106
107
|
onRedirect({ title: title, href: href, src: src, hoverSrc: hoverSrc, isCompleted: isCompleted, name: name });
|
|
107
|
-
} }, { children: _jsx(ButtonStyled, __assign({ variant: 'outlined', isCompleted: isCompleted, sx: __assign({ mb: isLast ? 2.5 : 1.8 }, sx), endIcon: isCompleted ? (_jsx(CheckIconStyled, {})) : (_jsx(Image, { sx: { height: 15, transform: '
|
|
108
|
+
} }, { children: _jsx(ButtonStyled, __assign({ variant: 'outlined', isCompleted: isCompleted, sx: __assign({ mb: isLast ? 2.5 : 1.8 }, sx), endIcon: isCompleted ? (_jsx(CheckIconStyled, {})) : (_jsx(Image, { sx: { height: 15, transform: isAr ? 'scale(-1)' : 'scale(1)' }, src: ICONS_NAMES.Arrow_filled_right_icon })), startIcon: _jsx(Image, { src: src, alt: title }), type: 'button' }, { children: title })) }), idx));
|
|
108
109
|
}) }));
|
|
109
110
|
}
|
|
@@ -27,9 +27,9 @@ import Background from '../shared/Background';
|
|
|
27
27
|
var Tax = memo(function (props) {
|
|
28
28
|
var theme = useAppTheme().theme;
|
|
29
29
|
var dispatch = useAppDispatch();
|
|
30
|
-
var _a = useAppSelector(settingsSelector), data = _a.data, error = _a.error,
|
|
30
|
+
var _a = useAppSelector(settingsSelector), data = _a.data, error = _a.error, loading = _a.loading;
|
|
31
31
|
var _b = useAppSelector(taxSelector), customLoading = _b.customLoading, taxError = _b.error;
|
|
32
|
-
|
|
32
|
+
useAppConfig(__assign({ navigation: TAX_SCREENS_NAVIGATION }, props));
|
|
33
33
|
useErrorListener(taxError || error);
|
|
34
34
|
useStepStartedListener();
|
|
35
35
|
var activeScreen = data.activeScreen, isTapOrigin = data.isTapOrigin, open = data.open;
|
|
@@ -47,7 +47,7 @@ var Tax = memo(function (props) {
|
|
|
47
47
|
if (!loading)
|
|
48
48
|
verifyToken();
|
|
49
49
|
}, [loading]);
|
|
50
|
-
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Background, __assign({ isTapOrigin: isTapOrigin, loading:
|
|
50
|
+
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Background, __assign({ isTapOrigin: isTapOrigin, loading: loading || customLoading }, { children: _jsx(AnimationFlow, __assign({ isTapOrigin: isTapOrigin, open: open, error: error, loading: loading || customLoading, breakpoint: 'sm', footer: _jsx(CustomFooter, {}) }, { children: _jsx(FeatureContainer, { children: taxFeatureScreens.map(function (_a, index) {
|
|
51
51
|
var Element = _a.element, name = _a.name;
|
|
52
52
|
var isActive = activeScreen.name === name;
|
|
53
53
|
return (_jsx(Collapse, __assign({ in: isActive, timeout: { enter: 1000, exit: 800 } }, { children: _jsx(Element, {}) }), index));
|
|
@@ -2,8 +2,5 @@ import { LibConfig, ScreenStepNavigation } from '../@types';
|
|
|
2
2
|
interface AppConfigProps extends LibConfig {
|
|
3
3
|
navigation: ScreenStepNavigation[];
|
|
4
4
|
}
|
|
5
|
-
export declare const useAppConfig: ({ appInfo, navigation, publicKey, ...rest }: AppConfigProps) =>
|
|
6
|
-
loading: boolean;
|
|
7
|
-
error: string | null;
|
|
8
|
-
};
|
|
5
|
+
export declare const useAppConfig: ({ appInfo, navigation, publicKey, ...rest }: AppConfigProps) => void;
|
|
9
6
|
export {};
|
|
@@ -9,42 +9,6 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
-
function step(op) {
|
|
26
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (_) try {
|
|
28
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
-
switch (op[0]) {
|
|
31
|
-
case 0: case 1: t = op; break;
|
|
32
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
-
default:
|
|
36
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
-
if (t[2]) _.ops.pop();
|
|
41
|
-
_.trys.pop(); continue;
|
|
42
|
-
}
|
|
43
|
-
op = body.call(thisArg, _);
|
|
44
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
12
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
49
13
|
var t = {};
|
|
50
14
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -56,20 +20,15 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
56
20
|
}
|
|
57
21
|
return t;
|
|
58
22
|
};
|
|
59
|
-
import { useEffect
|
|
60
|
-
import { handleActiveFlowScreens,
|
|
23
|
+
import { useEffect } from 'react';
|
|
24
|
+
import { handleActiveFlowScreens, handleSetAppConfig, handleLanguage, handleOpen, handleIsTapOrigin, fetchAppSettingsSync } from '../app/settings';
|
|
61
25
|
import { useAppDispatch } from './useAppDispatch';
|
|
62
|
-
import {
|
|
63
|
-
import {
|
|
64
|
-
import { getRequestHeaders, encryptString, isTapDomain } from '../utils';
|
|
26
|
+
import { axiosInstance } from '../api';
|
|
27
|
+
import { isTapDomain, removeRequestHeaders } from '../utils';
|
|
65
28
|
import { ENDPOINT_PATHS } from '../constants';
|
|
66
29
|
export var useAppConfig = function (_a) {
|
|
67
30
|
var appInfo = _a.appInfo, navigation = _a.navigation, publicKey = _a.publicKey, rest = __rest(_a, ["appInfo", "navigation", "publicKey"]);
|
|
68
|
-
var _b = useState(true), loading = _b[0], setLoading = _b[1];
|
|
69
31
|
var dispatch = useAppDispatch();
|
|
70
|
-
var _c = useAppSelector(settingsSelector), data = _c.data, error = _c.error;
|
|
71
|
-
var deviceInfo = data.deviceInfo, language = data.language, appConfig = data.appConfig;
|
|
72
|
-
var device = deviceInfo.device, browser = deviceInfo.browser, connection = deviceInfo.connection;
|
|
73
32
|
var setBaseUrl = function () {
|
|
74
33
|
var isProd = publicKey.includes('pk_live');
|
|
75
34
|
if (isProd) {
|
|
@@ -78,82 +37,23 @@ export var useAppConfig = function (_a) {
|
|
|
78
37
|
}
|
|
79
38
|
axiosInstance.defaults.baseURL = ENDPOINT_PATHS.DEV_BASE_URL;
|
|
80
39
|
};
|
|
81
|
-
var
|
|
82
|
-
|
|
40
|
+
var setAppConfig = function () {
|
|
41
|
+
dispatch(handleSetAppConfig(__assign({ appInfo: appInfo, publicKey: publicKey }, rest)));
|
|
42
|
+
dispatch(handleActiveFlowScreens(navigation));
|
|
83
43
|
};
|
|
84
|
-
var handleAppConfig = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
85
|
-
return __generator(this, function (_a) {
|
|
86
|
-
dispatch(handleSetAppConfig(__assign({ appInfo: appInfo, publicKey: publicKey }, rest)));
|
|
87
|
-
setBaseUrl();
|
|
88
|
-
dispatch(handleActiveFlowScreens(navigation));
|
|
89
|
-
return [2];
|
|
90
|
-
});
|
|
91
|
-
}); };
|
|
92
44
|
var checkDomain = function () {
|
|
93
45
|
var isTap = isTapDomain(rest.merchantDomain);
|
|
94
46
|
dispatch(handleIsTapOrigin(isTap));
|
|
95
47
|
};
|
|
96
|
-
var handleAppApiConfig = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
97
|
-
return __generator(this, function (_a) {
|
|
98
|
-
switch (_a.label) {
|
|
99
|
-
case 0:
|
|
100
|
-
checkDomain();
|
|
101
|
-
return [4, dispatch(getLocale())];
|
|
102
|
-
case 1:
|
|
103
|
-
_a.sent();
|
|
104
|
-
return [4, dispatch(getClientIp())];
|
|
105
|
-
case 2:
|
|
106
|
-
_a.sent();
|
|
107
|
-
return [4, dispatch(getBrowserFingerPrint(appInfo))];
|
|
108
|
-
case 3:
|
|
109
|
-
_a.sent();
|
|
110
|
-
return [2];
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
}); };
|
|
114
|
-
var handleGetOperator = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
115
|
-
var payload;
|
|
116
|
-
var _a, _b;
|
|
117
|
-
return __generator(this, function (_c) {
|
|
118
|
-
switch (_c.label) {
|
|
119
|
-
case 0:
|
|
120
|
-
payload = {
|
|
121
|
-
type: 'website',
|
|
122
|
-
app_client_version: 'js-auth-connect',
|
|
123
|
-
requirer_browser: "".concat(browser === null || browser === void 0 ? void 0 : browser.name, " , ").concat(browser === null || browser === void 0 ? void 0 : browser.version),
|
|
124
|
-
os: "".concat((_a = device.os) === null || _a === void 0 ? void 0 : _a.name, " , ").concat((_b = device.os) === null || _b === void 0 ? void 0 : _b.version),
|
|
125
|
-
locale: language
|
|
126
|
-
};
|
|
127
|
-
return [4, dispatch(getOperator(payload))];
|
|
128
|
-
case 1:
|
|
129
|
-
_c.sent();
|
|
130
|
-
return [4, dispatch(getCountries())];
|
|
131
|
-
case 2:
|
|
132
|
-
_c.sent();
|
|
133
|
-
setLoading(false);
|
|
134
|
-
return [2];
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
}); };
|
|
138
48
|
useEffect(function () {
|
|
139
49
|
dispatch(handleOpen(rest.open));
|
|
140
50
|
}, [rest.open]);
|
|
141
51
|
useEffect(function () {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
52
|
+
removeRequestHeaders();
|
|
53
|
+
checkDomain();
|
|
54
|
+
setBaseUrl();
|
|
55
|
+
setAppConfig();
|
|
56
|
+
dispatch(handleLanguage(rest.language));
|
|
57
|
+
dispatch(fetchAppSettingsSync());
|
|
147
58
|
}, []);
|
|
148
|
-
useEffect(function () {
|
|
149
|
-
if (appConfig.publicKey)
|
|
150
|
-
handleAppApiConfig();
|
|
151
|
-
}, [appConfig]);
|
|
152
|
-
useEffect(function () {
|
|
153
|
-
if (connection.ip && browser.browser_id) {
|
|
154
|
-
addAxiosHeader();
|
|
155
|
-
handleGetOperator();
|
|
156
|
-
}
|
|
157
|
-
}, [connection, browser]);
|
|
158
|
-
return { loading: loading, error: error };
|
|
159
59
|
};
|
package/build/utils/array.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CountryCode } from '../@types';
|
|
1
2
|
export declare const isArray: (value: any) => value is any[];
|
|
2
3
|
export declare const joinArray: (items: Array<any>, joiner?: string) => string;
|
|
3
4
|
export declare const replaceStringArrayItems: (items: Array<string>, include: string, withThis: string) => string[];
|
|
@@ -8,3 +9,5 @@ export declare const isInclude: (items: Array<string | number>, item: any) => bo
|
|
|
8
9
|
export declare const findItem: (items: Array<string | number>, key: any) => string | number | undefined;
|
|
9
10
|
export declare const isExist: (items: Array<any>, id: string) => any;
|
|
10
11
|
export declare const allAreTruthy: (items: Array<any>, condition: boolean | string, key: string, exclude?: string) => boolean;
|
|
12
|
+
export declare const sortCountries: (countries: Array<CountryCode>) => CountryCode[];
|
|
13
|
+
export declare const findCountryByIso2: (countries: Array<CountryCode>, iso2: string) => CountryCode | undefined;
|
package/build/utils/array.js
CHANGED
|
@@ -53,3 +53,13 @@ export var allAreTruthy = function (items, condition, key, exclude) {
|
|
|
53
53
|
return item[key] === condition;
|
|
54
54
|
});
|
|
55
55
|
};
|
|
56
|
+
export var sortCountries = function (countries) {
|
|
57
|
+
return (countries || []).sort(function (cOne, cTwo) {
|
|
58
|
+
return cOne.name.english.localeCompare(cTwo.name.english);
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
export var findCountryByIso2 = function (countries, iso2) {
|
|
62
|
+
if (!iso2)
|
|
63
|
+
throw new Error('iso2 is required');
|
|
64
|
+
return countries.find(function (country) { return country.iso2.toLowerCase() === iso2.toLowerCase(); });
|
|
65
|
+
};
|