encrypt / decrypt logic isolate
This commit is contained in:
@@ -32,7 +32,11 @@ import {
|
|||||||
} from "../../actions/eventActions";
|
} from "../../actions/eventActions";
|
||||||
import { sendLogShopByMobile } from "../../actions/logActions";
|
import { sendLogShopByMobile } from "../../actions/logActions";
|
||||||
import { ACTIVE_POPUP, LOG_TP_NO } from "../../utils/Config";
|
import { ACTIVE_POPUP, LOG_TP_NO } from "../../utils/Config";
|
||||||
import { $L } from "../../utils/helperMethods";
|
import {
|
||||||
|
$L,
|
||||||
|
decryptPhoneNumber,
|
||||||
|
encryptPhoneNumber,
|
||||||
|
} from "../../utils/helperMethods";
|
||||||
import CustomImage from "../CustomImage/CustomImage";
|
import CustomImage from "../CustomImage/CustomImage";
|
||||||
import TButton from "../TButton/TButton";
|
import TButton from "../TButton/TButton";
|
||||||
import TPopUp from "../TPopUp/TPopUp";
|
import TPopUp from "../TPopUp/TPopUp";
|
||||||
@@ -225,10 +229,6 @@ export default function MobileSendPopUp({
|
|||||||
}
|
}
|
||||||
}, [deviceInfo, dispatch]);
|
}, [deviceInfo, dispatch]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (phoneNumberList) setRecentSentNumber(phoneNumberList);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!chkAgreeBtn) {
|
if (!chkAgreeBtn) {
|
||||||
if (recentSentNumber && recentSentNumber.length > 0) {
|
if (recentSentNumber && recentSentNumber.length > 0) {
|
||||||
@@ -260,10 +260,13 @@ export default function MobileSendPopUp({
|
|||||||
(_, index) => index !== selectedIndex
|
(_, index) => index !== selectedIndex
|
||||||
);
|
);
|
||||||
setRecentSentNumber(updateItems);
|
setRecentSentNumber(updateItems);
|
||||||
|
|
||||||
|
const encryptedNumbers = updateItems.map(encryptPhoneNumber);
|
||||||
|
|
||||||
dispatch(
|
dispatch(
|
||||||
changeLocalSettings({
|
changeLocalSettings({
|
||||||
phoneNumbers: {
|
phoneNumbers: {
|
||||||
phoneNumberList: updateItems,
|
phoneNumberList: encryptedNumbers,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@@ -282,13 +285,6 @@ export default function MobileSendPopUp({
|
|||||||
naturalNumber = "82" + naturalNumber;
|
naturalNumber = "82" + naturalNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
const encryptPhoneNumber = (phoneNumber) => {
|
|
||||||
if(typeof window === 'object'){
|
|
||||||
return window.CryptoJS.AES.encrypt(phoneNumber, SECRET_KEY).toString();
|
|
||||||
}
|
|
||||||
return phoneNumber;
|
|
||||||
};
|
|
||||||
|
|
||||||
if (recentSentNumber && recentSentNumber.length > 0) {
|
if (recentSentNumber && recentSentNumber.length > 0) {
|
||||||
const updatedNumbers = [...recentSentNumber];
|
const updatedNumbers = [...recentSentNumber];
|
||||||
|
|
||||||
@@ -518,18 +514,10 @@ export default function MobileSendPopUp({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (phoneNumberList) {
|
if (phoneNumberList) {
|
||||||
const decryptPhoneNumber = (encryptedPhoneNumber) => {
|
|
||||||
if(typeof window === 'object'){
|
|
||||||
const bytes = window.CryptoJS.AES.decrypt(encryptedPhoneNumber, SECRET_KEY);
|
|
||||||
return bytes.toString(window.CryptoJS.enc.Utf8);
|
|
||||||
}
|
|
||||||
return encryptedPhoneNumber;
|
|
||||||
};
|
|
||||||
|
|
||||||
const decryptedNumbers = phoneNumberList.map(decryptPhoneNumber);
|
const decryptedNumbers = phoneNumberList.map(decryptPhoneNumber);
|
||||||
setRecentSentNumber(decryptedNumbers);
|
setRecentSentNumber(decryptedNumbers);
|
||||||
}
|
}
|
||||||
}, []);
|
}, [phoneNumberList]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -92,6 +92,9 @@ export const PLAN = "PLAN";
|
|||||||
export const ADD_PLAN = "ADD_PLAN";
|
export const ADD_PLAN = "ADD_PLAN";
|
||||||
export const MORE = "MORE";
|
export const MORE = "MORE";
|
||||||
|
|
||||||
|
// cryptoJS Key
|
||||||
|
export const SECRET_KEY = "fy7BTKuM9eeTQqEC9sF3Iw5qG43Aaip";
|
||||||
|
|
||||||
export const MYPAGE_TABS = {
|
export const MYPAGE_TABS = {
|
||||||
MY_INFO: 30800,
|
MY_INFO: 30800,
|
||||||
MY_ORDERS: 30900,
|
MY_ORDERS: 30900,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import stringReSourceEn from "../../resources/en/strings.json";
|
|||||||
import stringReSourceGb from "../../resources/gb/strings.json";
|
import stringReSourceGb from "../../resources/gb/strings.json";
|
||||||
import stringReSourceRu from "../../resources/ru/strings.json";
|
import stringReSourceRu from "../../resources/ru/strings.json";
|
||||||
import { getRicCode } from "../api/apiConfig";
|
import { getRicCode } from "../api/apiConfig";
|
||||||
|
import { SECRET_KEY } from "./Config";
|
||||||
|
|
||||||
let _boundingRectCache = {};
|
let _boundingRectCache = {};
|
||||||
const BOUNDING_RECT_IGNORE_TIME = 10;
|
const BOUNDING_RECT_IGNORE_TIME = 10;
|
||||||
@@ -429,3 +430,20 @@ export const removeSpecificTags = (html) => {
|
|||||||
|
|
||||||
return sanitizedHtml;
|
return sanitizedHtml;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const encryptPhoneNumber = (phoneNumber) => {
|
||||||
|
if (typeof window === "object") {
|
||||||
|
return window.CryptoJS.AES.encrypt(phoneNumber, SECRET_KEY).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return phoneNumber;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const decryptPhoneNumber = (encryptedPhoneNumber) => {
|
||||||
|
if (typeof window === "object") {
|
||||||
|
const bytes = window.CryptoJS.AES.decrypt(encryptedPhoneNumber, SECRET_KEY);
|
||||||
|
return bytes.toString(window.CryptoJS.enc.Utf8);
|
||||||
|
}
|
||||||
|
|
||||||
|
return encryptedPhoneNumber;
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user