@tap-payments/auth-jsconnect 2.11.2-sandbox → 2.11.3-sandbox

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.
@@ -12,6 +12,7 @@ export declare const ENDPOINT_PATHS: {
12
12
  SANDBOX_BASE_URL: string;
13
13
  PRODUCTION_BASE_URL: string;
14
14
  PRODUCTION_BASE_URL_SA: string;
15
+ PRODUCTION_BASE_URL_SA_DR: string;
15
16
  DEV_BASE_URL: string;
16
17
  BUSINESS_COUNTRIES: string;
17
18
  COUNTRIES: string;
@@ -1,6 +1,7 @@
1
1
  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
+ var PRODUCTION_BASE_URL_SA_DR = 'https://connect-mw-test.tap.com.sa/middleware';
4
5
  var DEV_BASE_URL = 'https://connect-mw.dev.tap.company/middleware';
5
6
  var API_BUSINESS_COUNTRIES = 'https://godata.sandbox.tap.company/api/v1/business/country/list';
6
7
  var API_COUNTRIES = 'https://utilities.tap.company/api/v1/country/list';
@@ -70,6 +71,7 @@ export var ENDPOINT_PATHS = {
70
71
  SANDBOX_BASE_URL: SANDBOX_BASE_URL,
71
72
  PRODUCTION_BASE_URL: PRODUCTION_BASE_URL,
72
73
  PRODUCTION_BASE_URL_SA: PRODUCTION_BASE_URL_SA,
74
+ PRODUCTION_BASE_URL_SA_DR: PRODUCTION_BASE_URL_SA_DR,
73
75
  DEV_BASE_URL: DEV_BASE_URL,
74
76
  BUSINESS_COUNTRIES: API_BUSINESS_COUNTRIES,
75
77
  COUNTRIES: API_COUNTRIES,
@@ -1,7 +1,7 @@
1
1
  import { axiosInstance } from '../api';
2
2
  import { ENDPOINT_PATHS, CONNECT_SANDBOX_URL, CONNECT_PROD_URL } from '../constants';
3
3
  import { objectHasValues } from './object';
4
- import { isSA } from './string';
4
+ import { isDisasterRecoveryEnv, isSA } from './string';
5
5
  export var sleep = function (milliseconds) {
6
6
  if (milliseconds === void 0) { milliseconds = 1000; }
7
7
  return new Promise(function (resolve) { return setTimeout(resolve, milliseconds); });
@@ -13,12 +13,19 @@ export var dangerousMessage = function (message, callBack) {
13
13
  callBack === null || callBack === void 0 ? void 0 : callBack({ message: message });
14
14
  };
15
15
  export var setBaseUrl = function (publicKey, region) {
16
+ if (region === void 0) { region = ''; }
16
17
  var isProd = publicKey.includes('pk_live');
17
- if (isProd) {
18
- axiosInstance.defaults.baseURL = isSA(region) ? ENDPOINT_PATHS.PRODUCTION_BASE_URL_SA : ENDPOINT_PATHS.PRODUCTION_BASE_URL;
18
+ var _a = region.split('-'), country = _a[0], envType = _a[1];
19
+ if (!isProd) {
20
+ axiosInstance.defaults.baseURL = ENDPOINT_PATHS.DEV_BASE_URL;
19
21
  return;
20
22
  }
21
- axiosInstance.defaults.baseURL = ENDPOINT_PATHS.SANDBOX_BASE_URL;
23
+ if (isSA(country)) {
24
+ axiosInstance.defaults.baseURL = isDisasterRecoveryEnv(envType) ? ENDPOINT_PATHS.PRODUCTION_BASE_URL_SA_DR : ENDPOINT_PATHS.PRODUCTION_BASE_URL_SA;
25
+ }
26
+ else {
27
+ axiosInstance.defaults.baseURL = ENDPOINT_PATHS.PRODUCTION_BASE_URL;
28
+ }
22
29
  };
23
30
  export var updateLocationUrlWithCountry = function (countryIso2) {
24
31
  var country = countryIso2.toLowerCase();
@@ -79,3 +79,4 @@ export declare const getCurrencyByCountryIso2: (countryCode?: string) => string;
79
79
  export declare const getMobileNumberLen: (initialLen: number, number: string) => number;
80
80
  export declare const getWebsiteLink: (isAr: boolean, countryCode: string, path: string) => string;
81
81
  export declare function formatCode(code: string, chunkSize?: number, delimiter?: string): string;
82
+ export declare const isDisasterRecoveryEnv: (type?: string) => boolean;
@@ -355,3 +355,4 @@ export function formatCode(code, chunkSize, delimiter) {
355
355
  if (delimiter === void 0) { delimiter = ' - '; }
356
356
  return ((_a = code.match(new RegExp(".{1,".concat(chunkSize, "}"), 'g'))) === null || _a === void 0 ? void 0 : _a.join(delimiter)) || code;
357
357
  }
358
+ export var isDisasterRecoveryEnv = function (type) { return type === 'dr'; };
@@ -53,7 +53,7 @@ export var keepLettersAndSpace = function (str) {
53
53
  return str.replace(/[^a-zA-Z] /g, '');
54
54
  };
55
55
  export var isConnectTapDomain = function (domain) {
56
- var regex = /^(https:\/\/)?connect(\.\w+)?\.tap\.(company|com\.\w{2})$/;
56
+ var regex = /^(https:\/\/)?connect((\.|-)\w+)?\.tap\.(company|com\.\w{2})$/;
57
57
  return regex.test(domain);
58
58
  };
59
59
  export var isTapDomain = function (domain) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.11.2-sandbox",
3
+ "version": "2.11.3-sandbox",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",