@tap-payments/auth-jsconnect 2.12.18-development → 2.12.20-development
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 +30 -0
- package/build/constants/api.d.ts +1 -2
- package/build/constants/api.js +8 -2
- package/build/utils/common.js +4 -5
- package/build/utils/string.d.ts +0 -1
- package/build/utils/string.js +0 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -202,6 +202,36 @@ const App = () => {
|
|
|
202
202
|
| onStepError `required` - `function` | callback function will call in case if any error happened in the screen |
|
|
203
203
|
| onStepCompleted `optional` - `function` | callback function will call after completing each step |
|
|
204
204
|
| onStepStarted `required` - `function` | callback function will call in the beginning of each step |
|
|
205
|
+
| region `optional` - `string` | selects the production API (middleware) region, see [Regions](#regions) |
|
|
206
|
+
|
|
207
|
+
## Regions
|
|
208
|
+
|
|
209
|
+
The library decides which backend (middleware) URL to call from the `publicKey` and the optional `region` prop.
|
|
210
|
+
|
|
211
|
+
- A `pk_test_*` key always uses the **development** URL. `region` is ignored.
|
|
212
|
+
- A `pk_live_*` key uses the production URL that matches `region`. If `region` is empty or not in the table, it falls back to the **global production** URL.
|
|
213
|
+
|
|
214
|
+
| `region` value | Meaning | Base URL |
|
|
215
|
+
| -------------- | ----------------------- | -------------------------------------------------- |
|
|
216
|
+
| _(empty)_ | Global production | `https://connect-mw.tap.company/middleware` |
|
|
217
|
+
| `sa` | Saudi production | `https://connect-mw.tap.com.sa/middleware` |
|
|
218
|
+
| `sa-dr` | Saudi disaster recovery | `https://connect-mw-tmp.tap.com.sa/middleware` |
|
|
219
|
+
| `sahu` | Saudi Huawei cloud | `https://connect-mw-temp.tap.com.sa/middleware` |
|
|
220
|
+
| `qagc` | Qatar GCP | `https://connect-mw.tappayments.com.qa/middleware` |
|
|
221
|
+
|
|
222
|
+
Notes:
|
|
223
|
+
|
|
224
|
+
- `region` is matched as a whole value and is case-insensitive (`SA` and `sa` are the same).
|
|
225
|
+
- Matching is exact. A value such as `sa-xyz` is **not** treated as Saudi and falls back to global production. Use one of the values above.
|
|
226
|
+
- To support a new region, add its URL and map it in `REGION_BASE_URLS` in `src/constants/api.ts`.
|
|
227
|
+
|
|
228
|
+
```js
|
|
229
|
+
<ConnectLib
|
|
230
|
+
publicKey={'pk_live_xxxxxx'}
|
|
231
|
+
region='sahu' // Saudi Huawei cloud
|
|
232
|
+
...
|
|
233
|
+
/>
|
|
234
|
+
```
|
|
205
235
|
|
|
206
236
|
## Branch Information
|
|
207
237
|
|
package/build/constants/api.d.ts
CHANGED
|
@@ -11,8 +11,6 @@ export declare const ENDPOINT_PATHS: {
|
|
|
11
11
|
MIGRATION_STATUS: string;
|
|
12
12
|
SANDBOX_BASE_URL: string;
|
|
13
13
|
PRODUCTION_BASE_URL: string;
|
|
14
|
-
PRODUCTION_BASE_URL_SA: string;
|
|
15
|
-
PRODUCTION_BASE_URL_SA_DR: string;
|
|
16
14
|
DEV_BASE_URL: string;
|
|
17
15
|
BUSINESS_COUNTRIES: string;
|
|
18
16
|
COUNTRIES: string;
|
|
@@ -59,3 +57,4 @@ export declare const ENDPOINT_PATHS: {
|
|
|
59
57
|
CURRENCY: string;
|
|
60
58
|
SEGMENT_LIST: string;
|
|
61
59
|
};
|
|
60
|
+
export declare const REGION_BASE_URLS: Record<string, string>;
|
package/build/constants/api.js
CHANGED
|
@@ -2,6 +2,8 @@ var SANDBOX_BASE_URL = 'https://connect-mw.sandbox.tap.company/middleware';
|
|
|
2
2
|
var PRODUCTION_BASE_URL = 'https://connect-mw.tap.company/middleware';
|
|
3
3
|
var PRODUCTION_BASE_URL_SA = 'https://connect-mw.tap.com.sa/middleware';
|
|
4
4
|
var PRODUCTION_BASE_URL_SA_DR = 'https://connect-mw-tmp.tap.com.sa/middleware';
|
|
5
|
+
var PRODUCTION_BASE_URL_SA_HU = 'https://connect-mw-temp.tap.com.sa/middleware';
|
|
6
|
+
var PRODUCTION_BASE_URL_QA_GC = 'https://connect-mw.tappayments.com.qa/middleware';
|
|
5
7
|
var DEV_BASE_URL = 'https://connect-mw.dev.tap.company/middleware';
|
|
6
8
|
var API_BUSINESS_COUNTRIES = 'https://godata.sandbox.tap.company/api/v1/business/country/list';
|
|
7
9
|
var API_COUNTRIES = 'https://utilities.tap.company/api/v1/country/list';
|
|
@@ -70,8 +72,6 @@ export var ENDPOINT_PATHS = {
|
|
|
70
72
|
MIGRATION_STATUS: MIGRATION_STATUS,
|
|
71
73
|
SANDBOX_BASE_URL: SANDBOX_BASE_URL,
|
|
72
74
|
PRODUCTION_BASE_URL: PRODUCTION_BASE_URL,
|
|
73
|
-
PRODUCTION_BASE_URL_SA: PRODUCTION_BASE_URL_SA,
|
|
74
|
-
PRODUCTION_BASE_URL_SA_DR: PRODUCTION_BASE_URL_SA_DR,
|
|
75
75
|
DEV_BASE_URL: DEV_BASE_URL,
|
|
76
76
|
BUSINESS_COUNTRIES: API_BUSINESS_COUNTRIES,
|
|
77
77
|
COUNTRIES: API_COUNTRIES,
|
|
@@ -118,3 +118,9 @@ export var ENDPOINT_PATHS = {
|
|
|
118
118
|
CURRENCY: CURRENCY_PATH,
|
|
119
119
|
SEGMENT_LIST: SEGMENT_LIST
|
|
120
120
|
};
|
|
121
|
+
export var REGION_BASE_URLS = {
|
|
122
|
+
sa: PRODUCTION_BASE_URL_SA,
|
|
123
|
+
'sa-dr': PRODUCTION_BASE_URL_SA_DR,
|
|
124
|
+
sahu: PRODUCTION_BASE_URL_SA_HU,
|
|
125
|
+
qagc: PRODUCTION_BASE_URL_QA_GC
|
|
126
|
+
};
|
package/build/utils/common.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { axiosInstance } from '../api';
|
|
2
|
-
import { ENDPOINT_PATHS, CONNECT_DEV_URL, CONNECT_PROD_URL } from '../constants';
|
|
2
|
+
import { ENDPOINT_PATHS, REGION_BASE_URLS, CONNECT_DEV_URL, CONNECT_PROD_URL } from '../constants';
|
|
3
3
|
import { objectHasValues } from './object';
|
|
4
|
-
import { isDisasterRecoveryEnv, isSA } from './string';
|
|
5
4
|
export var sleep = function (milliseconds) {
|
|
6
5
|
if (milliseconds === void 0) { milliseconds = 1000; }
|
|
7
6
|
return new Promise(function (resolve) { return setTimeout(resolve, milliseconds); });
|
|
@@ -15,13 +14,13 @@ export var dangerousMessage = function (message, callBack) {
|
|
|
15
14
|
export var setBaseUrl = function (publicKey, region) {
|
|
16
15
|
if (region === void 0) { region = ''; }
|
|
17
16
|
var isProd = publicKey.includes('pk_live');
|
|
18
|
-
var _a = region.split('-'), country = _a[0], envType = _a[1];
|
|
19
17
|
if (!isProd) {
|
|
20
18
|
axiosInstance.defaults.baseURL = ENDPOINT_PATHS.DEV_BASE_URL;
|
|
21
19
|
return;
|
|
22
20
|
}
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
var regionKey = (region || '').trim().toLowerCase();
|
|
22
|
+
if (Object.prototype.hasOwnProperty.call(REGION_BASE_URLS, regionKey)) {
|
|
23
|
+
axiosInstance.defaults.baseURL = REGION_BASE_URLS[regionKey];
|
|
25
24
|
}
|
|
26
25
|
else {
|
|
27
26
|
axiosInstance.defaults.baseURL = ENDPOINT_PATHS.PRODUCTION_BASE_URL;
|
package/build/utils/string.d.ts
CHANGED
|
@@ -81,4 +81,3 @@ export declare const getCurrencyByCountryIso2: (countryCode?: string) => string;
|
|
|
81
81
|
export declare const getMobileNumberLen: (initialLen: number, number: string) => number;
|
|
82
82
|
export declare const getWebsiteLink: (isAr: boolean, countryCode: string, path: string) => string;
|
|
83
83
|
export declare function formatCode(code: string, chunkSize?: number, delimiter?: string): string;
|
|
84
|
-
export declare const isDisasterRecoveryEnv: (type?: string) => boolean;
|
package/build/utils/string.js
CHANGED
|
@@ -372,4 +372,3 @@ export function formatCode(code, chunkSize, delimiter) {
|
|
|
372
372
|
if (delimiter === void 0) { delimiter = ' - '; }
|
|
373
373
|
return ((_a = code.match(new RegExp(".{1,".concat(chunkSize, "}"), 'g'))) === null || _a === void 0 ? void 0 : _a.join(delimiter)) || code;
|
|
374
374
|
}
|
|
375
|
-
export var isDisasterRecoveryEnv = function (type) { return type === 'dr'; };
|