@tap-payments/auth-jsconnect 2.5.8-test → 2.5.10-test

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.
@@ -47,7 +47,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
47
  };
48
48
  var _a;
49
49
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
50
- import { getStoredData, storeData, isArray, findItem, getBrowserInfo, getFingerPrint, sortCountries, findCountryByIso2, getRequestHeaders, encryptString, dangerousMessage, isKW, isSA, getParameterByName } from '../utils';
50
+ import { getStoredData, storeData, isArray, findItem, getBrowserInfo, getFingerPrint, sortCountries, findCountryByIso2, getRequestHeaders, encryptString, dangerousMessage, isKW, isSA, getParameterByName, setBaseUrl } from '../utils';
51
51
  import { DefaultDeviceInfo, LOCAL_STORAGE_KEYS } from '../constants';
52
52
  import i18n from '../i18n';
53
53
  import { updateLocale } from '../utils/locale';
@@ -87,8 +87,12 @@ export var fetchAppSettingsSync = createAsyncThunk('fetchAppSettingsSync', funct
87
87
  matureData = maturity_1 ? 'full' : 'express';
88
88
  thunkApi.dispatch(handleSetAppConfig(configInfo));
89
89
  thunkApi.dispatch(handleLanguage(language_1 || lang));
90
- if (public_key)
90
+ if (public_key) {
91
+ if (configToken) {
92
+ setBaseUrl(public_key);
93
+ }
91
94
  thunkApi.dispatch(handlePublicKey(public_key));
95
+ }
92
96
  if (typeof board_maturity === 'boolean')
93
97
  thunkApi.dispatch(handelBoardMaturity(board_maturity));
94
98
  onVerifyConfigTokenSuccess === null || onVerifyConfigTokenSuccess === void 0 ? void 0 : onVerifyConfigTokenSuccess(config);
@@ -24,21 +24,11 @@ import { useEffect } from 'react';
24
24
  import { handleActiveFlowScreens, handleSetAppConfig, handleLanguage, handleOpen, handleIsTapOrigin, fetchAppSettingsSync, handelBoardMaturity, settingsSelector } from '../app/settings';
25
25
  import { useAppDispatch } from './useAppDispatch';
26
26
  import { useAppSelector } from './useAppSelector';
27
- import { axiosInstance } from '../api';
28
- import { isTapDomain, removeRequestHeaders } from '../utils';
29
- import { ENDPOINT_PATHS } from '../constants';
27
+ import { isTapDomain, removeRequestHeaders, setBaseUrl } from '../utils';
30
28
  export var useAppConfig = function (_a) {
31
29
  var appInfo = _a.appInfo, navigation = _a.navigation, publicKey = _a.publicKey, disableCountries = _a.disableCountries, disableLocale = _a.disableLocale, disableSettingFetching = _a.disableSettingFetching, maturity = _a.maturity, boardMaturity = _a.boardMaturity, configToken = _a.configToken, onVerifyConfigTokenSuccess = _a.onVerifyConfigTokenSuccess, rest = __rest(_a, ["appInfo", "navigation", "publicKey", "disableCountries", "disableLocale", "disableSettingFetching", "maturity", "boardMaturity", "configToken", "onVerifyConfigTokenSuccess"]);
32
30
  var dispatch = useAppDispatch();
33
31
  var data = useAppSelector(settingsSelector).data;
34
- var setBaseUrl = function () {
35
- var isProd = publicKey.includes('pk_live');
36
- if (isProd) {
37
- axiosInstance.defaults.baseURL = ENDPOINT_PATHS.PRODUCTION_BASE_URL;
38
- return;
39
- }
40
- axiosInstance.defaults.baseURL = ENDPOINT_PATHS.DEV_BASE_URL;
41
- };
42
32
  var setAppConfig = function () {
43
33
  dispatch(handleSetAppConfig(__assign({ appInfo: appInfo, publicKey: publicKey }, rest)));
44
34
  dispatch(handleActiveFlowScreens(navigation));
@@ -56,7 +46,7 @@ export var useAppConfig = function (_a) {
56
46
  if (!disableSettingFetching)
57
47
  removeRequestHeaders();
58
48
  checkDomain();
59
- setBaseUrl();
49
+ setBaseUrl(publicKey);
60
50
  setAppConfig();
61
51
  if (typeof boardMaturity === 'boolean')
62
52
  dispatch(handelBoardMaturity(boardMaturity));
@@ -1,2 +1,3 @@
1
1
  export declare const sleep: (milliseconds?: number) => Promise<unknown>;
2
2
  export declare const dangerousMessage: (message: string, callBack?: Function) => void;
3
+ export declare const setBaseUrl: (publicKey: string) => void;
@@ -1,3 +1,5 @@
1
+ import { axiosInstance } from '../api';
2
+ import { ENDPOINT_PATHS } from '../constants';
1
3
  export var sleep = function (milliseconds) {
2
4
  if (milliseconds === void 0) { milliseconds = 1000; }
3
5
  return new Promise(function (resolve) { return setTimeout(resolve, milliseconds); });
@@ -8,3 +10,15 @@ export var dangerousMessage = function (message, callBack) {
8
10
  }
9
11
  callBack === null || callBack === void 0 ? void 0 : callBack({ message: message });
10
12
  };
13
+ export var setBaseUrl = function (publicKey) {
14
+ if (process.env.NODE_ENV === 'development') {
15
+ axiosInstance.defaults.baseURL = ENDPOINT_PATHS.DEV_BASE_URL;
16
+ return;
17
+ }
18
+ var isProd = publicKey.includes('pk_live');
19
+ if (isProd) {
20
+ axiosInstance.defaults.baseURL = ENDPOINT_PATHS.PRODUCTION_BASE_URL;
21
+ return;
22
+ }
23
+ axiosInstance.defaults.baseURL = ENDPOINT_PATHS.SANDBOX_BASE_URL;
24
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.5.8-test",
3
+ "version": "2.5.10-test",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",