@tap-payments/auth-jsconnect 1.0.22 → 1.0.25

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.
Files changed (50) hide show
  1. package/build/@types/app.d.ts +16 -9
  2. package/build/api/axios.js +20 -1
  3. package/build/api/lead.d.ts +1 -0
  4. package/build/app/settings.d.ts +4 -2
  5. package/build/app/settings.js +30 -2
  6. package/build/components/Button/Button.js +1 -0
  7. package/build/constants/app.d.ts +1 -0
  8. package/build/constants/app.js +1 -0
  9. package/build/constants/dummy.d.ts +1 -0
  10. package/build/constants/dummy.js +1 -0
  11. package/build/features/app/connect/connectStore.d.ts +1 -2
  12. package/build/features/app/connect/connectStore.js +75 -58
  13. package/build/features/bank/screens/BankDetails/BankName.js +6 -1
  14. package/build/features/business/screens/Activities/Activities.js +6 -2
  15. package/build/features/business/screens/Activities/ActivitiesList.d.ts +1 -1
  16. package/build/features/business/screens/Customers/CustomerLocations.d.ts +3 -2
  17. package/build/features/business/screens/Customers/CustomerLocations.js +3 -3
  18. package/build/features/business/screens/Customers/Customers.js +19 -1
  19. package/build/features/business/screens/Customers/ExpectedCustomers.d.ts +1 -0
  20. package/build/features/business/screens/Customers/ExpectedCustomers.js +3 -3
  21. package/build/features/business/screens/Customers/ExpectedSalesRange.d.ts +1 -0
  22. package/build/features/business/screens/Customers/ExpectedSalesRange.js +3 -3
  23. package/build/features/business/screens/VerifyNumber/VerifyNumber.js +1 -1
  24. package/build/features/connect/Connect.d.ts +2 -4
  25. package/build/features/connect/Connect.js +4 -4
  26. package/build/features/connect/screens/Individual/Email.js +9 -7
  27. package/build/features/connect/screens/Individual/Individual.js +12 -11
  28. package/build/features/connect/screens/Merchant/BrandName.js +7 -4
  29. package/build/features/connect/screens/Merchant/Merchant.js +5 -4
  30. package/build/features/connect/screens/Mobile/BusinessCountry.d.ts +0 -5
  31. package/build/features/connect/screens/Mobile/BusinessCountry.js +3 -24
  32. package/build/features/connect/screens/Mobile/Mobile.js +15 -5
  33. package/build/features/connect/screens/NID/DOB.js +12 -2
  34. package/build/features/connect/screens/NID/NID.js +5 -2
  35. package/build/features/connect/screens/NID/validation.js +1 -2
  36. package/build/features/connect/screens/ThankYou/ThankYou.js +6 -1
  37. package/build/features/shared/Button/Button.js +24 -24
  38. package/build/hooks/index.d.ts +1 -0
  39. package/build/hooks/index.js +1 -0
  40. package/build/hooks/useAppConfig.d.ts +3 -5
  41. package/build/hooks/useAppConfig.js +29 -2
  42. package/build/hooks/useErrorListener.d.ts +1 -0
  43. package/build/hooks/useErrorListener.js +19 -0
  44. package/build/utils/index.d.ts +1 -0
  45. package/build/utils/index.js +1 -0
  46. package/build/utils/rsa.d.ts +2 -0
  47. package/build/utils/rsa.js +19 -0
  48. package/build/utils/string.d.ts +1 -0
  49. package/build/utils/string.js +3 -0
  50. package/package.json +4 -1
@@ -1,9 +1,31 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
1
23
  import { useEffect } from 'react';
2
- import { handleActiveFlowScreens, settingsSelector, getClientIp, getBrowserFingerPrint, getOperator } from '../app/settings';
24
+ import { handleActiveFlowScreens, settingsSelector, getClientIp, getBrowserFingerPrint, getOperator, handleSetAppConfig, handleLanguage } from '../app/settings';
3
25
  import { useAppDispatch } from './useAppDispatch';
4
26
  import { useAppSelector } from './useAppSelector';
5
27
  export var useAppConfig = function (_a) {
6
- var appInfo = _a.appInfo, navigation = _a.navigation, publicKey = _a.publicKey;
28
+ var appInfo = _a.appInfo, navigation = _a.navigation, publicKey = _a.publicKey, rest = __rest(_a, ["appInfo", "navigation", "publicKey"]);
7
29
  var dispatch = useAppDispatch();
8
30
  var _b = useAppSelector(settingsSelector), data = _b.data, error = _b.error, loading = _b.loading;
9
31
  var deviceInfo = data.deviceInfo, language = data.language;
@@ -12,6 +34,7 @@ export var useAppConfig = function (_a) {
12
34
  dispatch(handleActiveFlowScreens(navigation));
13
35
  dispatch(getClientIp());
14
36
  dispatch(getBrowserFingerPrint(appInfo));
37
+ dispatch(handleSetAppConfig(__assign({ appInfo: appInfo, publicKey: publicKey }, rest)));
15
38
  }, []);
16
39
  var handleGetOperator = function () {
17
40
  var _a, _b;
@@ -25,6 +48,10 @@ export var useAppConfig = function (_a) {
25
48
  };
26
49
  dispatch(getOperator(payload));
27
50
  };
51
+ useEffect(function () {
52
+ if (data.appConfig.language)
53
+ dispatch(handleLanguage(data.appConfig.language));
54
+ }, [data.appConfig.language]);
28
55
  useEffect(function () {
29
56
  if (device.os.name && browser.name && publicKey) {
30
57
  handleGetOperator();
@@ -0,0 +1 @@
1
+ export declare const useErrorListener: () => void;
@@ -0,0 +1,19 @@
1
+ import { useEffect } from 'react';
2
+ import { settingsSelector } from '../app/settings';
3
+ import { useAppSelector } from './useAppSelector';
4
+ import { connectSelector } from '../features/app/connect/connectStore';
5
+ export var useErrorListener = function () {
6
+ var settings = useAppSelector(settingsSelector);
7
+ var connect = useAppSelector(connectSelector);
8
+ useEffect(function () {
9
+ var _a, _b;
10
+ if (connect.error || settings.error) {
11
+ (_b = (_a = settings.data.appConfig) === null || _a === void 0 ? void 0 : _a.onError) === null || _b === void 0 ? void 0 : _b.call(_a, settings.error || connect.error);
12
+ }
13
+ }, [connect.error, settings.error]);
14
+ useEffect(function () {
15
+ var _a, _b;
16
+ if (!settings.error)
17
+ (_b = (_a = settings.data.appConfig).onReady) === null || _b === void 0 ? void 0 : _b.call(_a);
18
+ }, [settings.error]);
19
+ };
@@ -6,3 +6,4 @@ export * from './html';
6
6
  export * from './validation';
7
7
  export * from './string';
8
8
  export * from './device';
9
+ export * from './rsa';
@@ -6,3 +6,4 @@ export * from './html';
6
6
  export * from './validation';
7
7
  export * from './string';
8
8
  export * from './device';
9
+ export * from './rsa';
@@ -0,0 +1,2 @@
1
+ export declare const encryptObject: (data: unknown) => string | false;
2
+ export declare const encryptString: (string: string) => string;
@@ -0,0 +1,19 @@
1
+ import { JSEncrypt } from 'jsencrypt';
2
+ import { RSA_FRONTEND_MW_PUBLIC_KEY } from '../constants';
3
+ var rsa = new JSEncrypt();
4
+ rsa.setPublicKey(RSA_FRONTEND_MW_PUBLIC_KEY);
5
+ export var encryptObject = function (data) {
6
+ if (typeof data !== 'object')
7
+ throw new Error('data should be from type object');
8
+ var obj2Str = JSON.stringify(data);
9
+ var encrypted = rsa.encrypt(obj2Str);
10
+ return encrypted;
11
+ };
12
+ export var encryptString = function (string) {
13
+ if (typeof string !== 'string')
14
+ throw new Error('string should be from type string');
15
+ var encrypted = rsa.encrypt(string);
16
+ if (!encrypted)
17
+ throw new Error('encryption data reached max allowed length');
18
+ return encrypted;
19
+ };
@@ -6,3 +6,4 @@ export declare const getIndividualName: (name: string) => {
6
6
  middle: string;
7
7
  last: string;
8
8
  } | undefined;
9
+ export declare const convertNumbers2English: (str: string) => string;
@@ -37,3 +37,6 @@ export var getIndividualName = function (name) {
37
37
  }
38
38
  return { first: first, middle: middle, last: last };
39
39
  };
40
+ export var convertNumbers2English = function (str) {
41
+ return str.replace(/[٠-٩]/g, function (d) { return '٠١٢٣٤٥٦٧٨٩'.indexOf(d); });
42
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "1.0.22",
3
+ "version": "1.0.25",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",
@@ -35,6 +35,7 @@
35
35
  "@babel/preset-react": "^7.18.6",
36
36
  "@babel/preset-typescript": "^7.18.6",
37
37
  "@types/lodash-es": "^4.17.6",
38
+ "@types/moment-hijri": "^2.1.0",
38
39
  "@types/react": "^18.0.15",
39
40
  "@types/react-calendar": "~3.5.1",
40
41
  "@types/react-dom": "^18.0.6",
@@ -86,7 +87,9 @@
86
87
  "i18next": "^21.8.14",
87
88
  "i18next-browser-languagedetector": "^6.1.4",
88
89
  "i18next-http-backend": "^1.4.1",
90
+ "jsencrypt": "^3.2.1",
89
91
  "lodash-es": "^4.17.21",
92
+ "moment-hijri": "~2.1.2",
90
93
  "react": "^18.2.0",
91
94
  "react-calendar": "~3.7.0",
92
95
  "react-dom": "^18.2.0",