@tap-payments/auth-jsconnect 2.12.18-development → 2.12.19-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 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
 
@@ -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>;
@@ -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 API_BUSINESS_COUNTRIES = 'https://godata.sandbox.tap.company/api/v1/business/country/list';
7
8
  var API_COUNTRIES = 'https://utilities.tap.company/api/v1/country/list';
@@ -70,8 +71,6 @@ export var ENDPOINT_PATHS = {
70
71
  MIGRATION_STATUS: MIGRATION_STATUS,
71
72
  SANDBOX_BASE_URL: SANDBOX_BASE_URL,
72
73
  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
74
  DEV_BASE_URL: DEV_BASE_URL,
76
75
  BUSINESS_COUNTRIES: API_BUSINESS_COUNTRIES,
77
76
  COUNTRIES: API_COUNTRIES,
@@ -118,3 +117,8 @@ export var ENDPOINT_PATHS = {
118
117
  CURRENCY: CURRENCY_PATH,
119
118
  SEGMENT_LIST: SEGMENT_LIST
120
119
  };
120
+ export var REGION_BASE_URLS = {
121
+ sa: PRODUCTION_BASE_URL_SA,
122
+ 'sa-dr': PRODUCTION_BASE_URL_SA_DR,
123
+ sahu: PRODUCTION_BASE_URL_SA_HU
124
+ };
@@ -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
- if (isSA(country)) {
24
- axiosInstance.defaults.baseURL = isDisasterRecoveryEnv(envType) ? ENDPOINT_PATHS.PRODUCTION_BASE_URL_SA_DR : ENDPOINT_PATHS.PRODUCTION_BASE_URL_SA;
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;
@@ -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;
@@ -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'; };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.12.18-development",
3
+ "version": "2.12.19-development",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",