@tap-payments/auth-jsconnect 2.12.11 → 2.12.12
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 +29 -0
- package/build/constants/api.d.ts +1 -2
- package/build/constants/api.js +6 -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,35 @@ 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
|
+
|
|
221
|
+
Notes:
|
|
222
|
+
|
|
223
|
+
- `region` is matched as a whole value and is case-insensitive (`SA` and `sa` are the same).
|
|
224
|
+
- 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.
|
|
225
|
+
- To support a new region, add its URL and map it in `REGION_BASE_URLS` in `src/constants/api.ts`.
|
|
226
|
+
|
|
227
|
+
```js
|
|
228
|
+
<ConnectLib
|
|
229
|
+
publicKey={'pk_live_xxxxxx'}
|
|
230
|
+
region='sahu' // Saudi Huawei cloud
|
|
231
|
+
...
|
|
232
|
+
/>
|
|
233
|
+
```
|
|
205
234
|
|
|
206
235
|
## Branch Information
|
|
207
236
|
|
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
|
BETA_BASE_URL: string;
|
|
18
16
|
BUSINESS_COUNTRIES: string;
|
|
@@ -60,3 +58,4 @@ export declare const ENDPOINT_PATHS: {
|
|
|
60
58
|
CURRENCY: string;
|
|
61
59
|
SEGMENT_LIST: string;
|
|
62
60
|
};
|
|
61
|
+
export declare const REGION_BASE_URLS: Record<string, string>;
|
package/build/constants/api.js
CHANGED
|
@@ -2,6 +2,7 @@ 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';
|
|
5
6
|
var DEV_BASE_URL = 'https://connect-mw.dev.tap.company/middleware';
|
|
6
7
|
var BETA_BASE_URL = 'https://connect-mw.beta.tap.company/middleware';
|
|
7
8
|
var API_BUSINESS_COUNTRIES = 'https://godata.sandbox.tap.company/api/v1/business/country/list';
|
|
@@ -71,8 +72,6 @@ export var ENDPOINT_PATHS = {
|
|
|
71
72
|
MIGRATION_STATUS: MIGRATION_STATUS,
|
|
72
73
|
SANDBOX_BASE_URL: SANDBOX_BASE_URL,
|
|
73
74
|
PRODUCTION_BASE_URL: PRODUCTION_BASE_URL,
|
|
74
|
-
PRODUCTION_BASE_URL_SA: PRODUCTION_BASE_URL_SA,
|
|
75
|
-
PRODUCTION_BASE_URL_SA_DR: PRODUCTION_BASE_URL_SA_DR,
|
|
76
75
|
DEV_BASE_URL: DEV_BASE_URL,
|
|
77
76
|
BETA_BASE_URL: BETA_BASE_URL,
|
|
78
77
|
BUSINESS_COUNTRIES: API_BUSINESS_COUNTRIES,
|
|
@@ -120,3 +119,8 @@ export var ENDPOINT_PATHS = {
|
|
|
120
119
|
CURRENCY: CURRENCY_PATH,
|
|
121
120
|
SEGMENT_LIST: SEGMENT_LIST
|
|
122
121
|
};
|
|
122
|
+
export var REGION_BASE_URLS = {
|
|
123
|
+
sa: PRODUCTION_BASE_URL_SA,
|
|
124
|
+
'sa-dr': PRODUCTION_BASE_URL_SA_DR,
|
|
125
|
+
sahu: PRODUCTION_BASE_URL_SA_HU
|
|
126
|
+
};
|
package/build/utils/common.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { axiosInstance } from '../api';
|
|
2
|
-
import { ENDPOINT_PATHS, CONNECT_SANDBOX_URL, CONNECT_PROD_URL } from '../constants';
|
|
2
|
+
import { ENDPOINT_PATHS, REGION_BASE_URLS, CONNECT_SANDBOX_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.SANDBOX_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
|
@@ -363,4 +363,3 @@ export function formatCode(code, chunkSize, delimiter) {
|
|
|
363
363
|
if (delimiter === void 0) { delimiter = ' - '; }
|
|
364
364
|
return ((_a = code.match(new RegExp(".{1,".concat(chunkSize, "}"), 'g'))) === null || _a === void 0 ? void 0 : _a.join(delimiter)) || code;
|
|
365
365
|
}
|
|
366
|
-
export var isDisasterRecoveryEnv = function (type) { return type === 'dr'; };
|