encrypt phone number
This commit is contained in:
@@ -41,6 +41,7 @@
|
|||||||
"@enact/ui": "^3.3.0",
|
"@enact/ui": "^3.3.0",
|
||||||
"@enact/webos": "^3.3.0",
|
"@enact/webos": "^3.3.0",
|
||||||
"axios": "^0.21.1",
|
"axios": "^0.21.1",
|
||||||
|
"crypto-js": "^4.0.0",
|
||||||
"google-libphonenumber": "^3.2.34",
|
"google-libphonenumber": "^3.2.34",
|
||||||
"ilib": "^14.3.0",
|
"ilib": "^14.3.0",
|
||||||
"patch-package": "^8.0.0",
|
"patch-package": "^8.0.0",
|
||||||
|
|||||||
@@ -1,63 +1,47 @@
|
|||||||
import React, {
|
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
||||||
useCallback,
|
|
||||||
useEffect,
|
|
||||||
useMemo,
|
|
||||||
useState,
|
|
||||||
} from 'react';
|
|
||||||
|
|
||||||
import classNames from 'classnames';
|
import classNames from "classnames";
|
||||||
|
import CryptoJS from "crypto-js";
|
||||||
import {
|
import {
|
||||||
AsYouTypeFormatter,
|
AsYouTypeFormatter,
|
||||||
PhoneNumberFormat,
|
PhoneNumberFormat,
|
||||||
PhoneNumberUtil,
|
PhoneNumberUtil,
|
||||||
} from 'google-libphonenumber';
|
} from "google-libphonenumber";
|
||||||
import {
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
useDispatch,
|
|
||||||
useSelector,
|
|
||||||
} from 'react-redux';
|
|
||||||
|
|
||||||
import {
|
import { off, on } from "@enact/core/dispatcher";
|
||||||
off,
|
import spotlight, { Spotlight } from "@enact/spotlight";
|
||||||
on,
|
import { SpotlightContainerDecorator } from "@enact/spotlight/SpotlightContainerDecorator";
|
||||||
} from '@enact/core/dispatcher';
|
import { Spottable } from "@enact/spotlight/Spottable";
|
||||||
import spotlight, { Spotlight } from '@enact/spotlight';
|
|
||||||
import {
|
|
||||||
SpotlightContainerDecorator,
|
|
||||||
} from '@enact/spotlight/SpotlightContainerDecorator';
|
|
||||||
import { Spottable } from '@enact/spotlight/Spottable';
|
|
||||||
|
|
||||||
import defaultImage from '../../../assets/images/img-thumb-empty-144@3x.png';
|
import defaultImage from "../../../assets/images/img-thumb-empty-144@3x.png";
|
||||||
import { types } from '../../actions/actionTypes';
|
import { types } from "../../actions/actionTypes";
|
||||||
import {
|
import { clearSMS, sendSms } from "../../actions/appDataActions";
|
||||||
clearSMS,
|
|
||||||
sendSms,
|
|
||||||
} from '../../actions/appDataActions';
|
|
||||||
import {
|
import {
|
||||||
changeLocalSettings,
|
changeLocalSettings,
|
||||||
setHidePopup,
|
setHidePopup,
|
||||||
setShowPopup,
|
setShowPopup,
|
||||||
} from '../../actions/commonActions';
|
} from "../../actions/commonActions";
|
||||||
import {
|
import {
|
||||||
clearRegisterDeviceInfo,
|
clearRegisterDeviceInfo,
|
||||||
getDeviceAdditionInfo,
|
getDeviceAdditionInfo,
|
||||||
registerDeviceInfo,
|
registerDeviceInfo,
|
||||||
} from '../../actions/deviceActions';
|
} from "../../actions/deviceActions";
|
||||||
import {
|
import {
|
||||||
clearCurationCoupon,
|
clearCurationCoupon,
|
||||||
setEventIssueReq,
|
setEventIssueReq,
|
||||||
} from '../../actions/eventActions';
|
} from "../../actions/eventActions";
|
||||||
import { sendLogShopByMobile } from '../../actions/logActions';
|
import { sendLogShopByMobile } from "../../actions/logActions";
|
||||||
import {
|
import { ACTIVE_POPUP, LOG_TP_NO } from "../../utils/Config";
|
||||||
ACTIVE_POPUP,
|
import { $L } from "../../utils/helperMethods";
|
||||||
LOG_TP_NO,
|
import CustomImage from "../CustomImage/CustomImage";
|
||||||
} from '../../utils/Config';
|
import TButton from "../TButton/TButton";
|
||||||
import { $L } from '../../utils/helperMethods';
|
import TPopUp from "../TPopUp/TPopUp";
|
||||||
import CustomImage from '../CustomImage/CustomImage';
|
import HistoryPhoneNumber from "./HistoryPhoneNumber/HistoryPhoneNumber";
|
||||||
import TButton from '../TButton/TButton';
|
import css from "./MobileSendPopUp.module.less";
|
||||||
import TPopUp from '../TPopUp/TPopUp';
|
import SMSNumKeyPad from "./SMSNumKeyPad";
|
||||||
import HistoryPhoneNumber from './HistoryPhoneNumber/HistoryPhoneNumber';
|
|
||||||
import css from './MobileSendPopUp.module.less';
|
const SECRET_KEY = "fy7BTKuM9eeTQqEC9sF3Iw5qG43Aaip";
|
||||||
import SMSNumKeyPad from './SMSNumKeyPad';
|
|
||||||
|
|
||||||
const Container = SpotlightContainerDecorator(
|
const Container = SpotlightContainerDecorator(
|
||||||
{ enterTo: "last-focused" },
|
{ enterTo: "last-focused" },
|
||||||
@@ -299,6 +283,10 @@ export default function MobileSendPopUp({
|
|||||||
naturalNumber = "82" + naturalNumber;
|
naturalNumber = "82" + naturalNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const encryptPhoneNumber = (phoneNumber) => {
|
||||||
|
return CryptoJS.AES.encrypt(phoneNumber, SECRET_KEY).toString();
|
||||||
|
};
|
||||||
|
|
||||||
if (recentSentNumber && recentSentNumber.length > 0) {
|
if (recentSentNumber && recentSentNumber.length > 0) {
|
||||||
const updatedNumbers = [...recentSentNumber];
|
const updatedNumbers = [...recentSentNumber];
|
||||||
|
|
||||||
@@ -317,10 +305,12 @@ export default function MobileSendPopUp({
|
|||||||
setChkAgreeBtn(true);
|
setChkAgreeBtn(true);
|
||||||
setRecentSentNumber(updatedNumbers);
|
setRecentSentNumber(updatedNumbers);
|
||||||
|
|
||||||
|
const encryptedNumbers = updatedNumbers.map(encryptPhoneNumber);
|
||||||
|
|
||||||
dispatch(
|
dispatch(
|
||||||
changeLocalSettings({
|
changeLocalSettings({
|
||||||
phoneNumbers: {
|
phoneNumbers: {
|
||||||
phoneNumberList: updatedNumbers,
|
phoneNumberList: encryptedNumbers,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@@ -329,7 +319,7 @@ export default function MobileSendPopUp({
|
|||||||
dispatch(
|
dispatch(
|
||||||
changeLocalSettings({
|
changeLocalSettings({
|
||||||
phoneNumbers: {
|
phoneNumbers: {
|
||||||
phoneNumberList: [mobileNumber],
|
phoneNumberList: [encryptPhoneNumber(mobileNumber)],
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@@ -526,6 +516,18 @@ export default function MobileSendPopUp({
|
|||||||
(smsRetCode !== undefined && smsRetCode !== 0) ||
|
(smsRetCode !== undefined && smsRetCode !== 0) ||
|
||||||
(curationCouponSuccess !== undefined && curationCouponSuccess !== 0);
|
(curationCouponSuccess !== undefined && curationCouponSuccess !== 0);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (phoneNumberList) {
|
||||||
|
const decryptPhoneNumber = (encryptedPhoneNumber) => {
|
||||||
|
const bytes = CryptoJS.AES.decrypt(encryptedPhoneNumber, SECRET_KEY);
|
||||||
|
return bytes.toString(CryptoJS.enc.Utf8);
|
||||||
|
};
|
||||||
|
|
||||||
|
const decryptedNumbers = phoneNumberList.map(decryptPhoneNumber);
|
||||||
|
setRecentSentNumber(decryptedNumbers);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{smsRetCode === undefined &&
|
{smsRetCode === undefined &&
|
||||||
|
|||||||
Reference in New Issue
Block a user