diff --git a/src/pages/digitalId/ProfileId.jsx b/src/pages/digitalId/ProfileId.jsx
index 8a14d6d..8f669cc 100644
--- a/src/pages/digitalId/ProfileId.jsx
+++ b/src/pages/digitalId/ProfileId.jsx
@@ -6,6 +6,7 @@ import Header from '../../partials/Header';
import ProfileTable from '../../partials/profile/ProfileTable';
import Image from '../../images/transactions-image-04.svg';
import {labelMap} from '../../shared/labelMap';
+import {statusMap} from "../../shared/statusMap";
const initialPropertyValues = ['First name', 'Second name', 'Birthdate', 'Gender', 'National doctype', 'National doc ID', 'National doc issue date', 'National doc expiry date'];
@@ -28,7 +29,8 @@ const Profile = observer (() => {
const [updatedValues, setUpdatedValues] = useState([defaultValues]);
const [addedValues, setAddedValues] = useState(defaultValues);
const [isCheck, setIsCheck] = useState([]);
- const [alreadyExists, setAlreadyExists] = useState(false);
+ const [alreadyExists, setAlreadyExists] = useState(false)
+ const [blockChainValue, setBlockChainValue] = useState('');
useEffect(() => {
handleSelectedItems(isCheck);
@@ -57,12 +59,15 @@ const Profile = observer (() => {
};
const changeUpdatedValues = (value, field, key) => {
+ if(field==='value') {
+ setBlockChainValue(value)
+ }
setUpdatedValues((prevState) =>
prevState.map((elem) => (
- (elem.key === key) ? {
- ...elem,
- [field]: value,
- } : elem
+ (elem.key === key) ? {
+ ...elem,
+ [field]: value,
+ } : elem
))
)
};
@@ -371,7 +376,7 @@ const Profile = observer (() => {
type="text"
required
onChange={(e) => changeUpdatedValues(e.target.value, 'value', item.key)}
- value={item.value}
+ value={item.status===statusMap.blockchained?blockChainValue : item.value}
/>
diff --git a/src/partials/profile/ProfileTableItem.jsx b/src/partials/profile/ProfileTableItem.jsx
index cdc7ef8..371bc66 100644
--- a/src/partials/profile/ProfileTableItem.jsx
+++ b/src/partials/profile/ProfileTableItem.jsx
@@ -28,7 +28,7 @@ function ProfileTableItem(props) {
- {props.status === 'Blockchained' || props.status === statusMap.processed
+ {props.status === statusMap.blockchained || props.status === statusMap.processed
? `${props.value.slice(0, 4)}****${props.value.slice(props.value.length - 4)}`
: props.value}
@@ -36,15 +36,15 @@ function ProfileTableItem(props) {
-
-
- {props.status === 'Blockchained' ? (
+
+
+ {props.status === statusMap.blockchained ? (
{props.status}
) : props.status === statusMap.processed ? (
{props.status}
- ) : props.status === 'Stored' ? (
+ ) : props.status === statusMap.stored ? (
{props.status}
- ) : props.status === 'Completed' ? (
+ ) : props.status === statusMap.completed ? (
{props.status}
) : (
{props.status}
diff --git a/src/store/store.js b/src/store/store.js
index 1b03108..194c49c 100644
--- a/src/store/store.js
+++ b/src/store/store.js
@@ -4,8 +4,8 @@ import { passphrase } from '@liskhq/lisk-client';
import { getNodeInfo } from '../api/node';
import { fetchWrapper } from '../shared/fetchWrapper';
import { labelMap } from '../shared/labelMap';
-import { statusMap } from '../shared/statusMap';
import { generateSvgAvatar } from '../images/GenerateOnboardingSvg/GenerateSvg';
+import {decryptedData} from "../utils/decryptedData";
import { encryptAccountData, generateTransaction, hashAccountData } from '../utils/Utils';
class Store {
@@ -251,62 +251,8 @@ class Store {
};
});
}
-
get decryptedAccountData() {
- const allAccountData = this._accountData.concat(
- this.accountFeatures.filter((item) => !this._accountData.find((elem) => elem.label === item.label))
- );
- return allAccountData.map((elem) => {
- const initialData = {
- ...elem,
- key: elem.label,
- label: labelMap[elem.label] || elem.label,
- status: '',
- value: '',
- seed: '',
- };
- if(this.processedFeatures[elem.label])
- return {
- ...initialData,
- status: statusMap.processed,
- value: elem.value,
- }
- if (!this._accountData.find((item) => item.label === elem.label)) {
- return {
- ...initialData,
- status: statusMap.blockchained,
- value: elem.value,
- };
- }
- const [seed, value] = cryptography
- .decryptMessageWithPassphrase(elem.value, elem.value_nonce, this.passPhrase, this.pubKey)
- .split(':');
- const hashValue = cryptography
- .hash(Buffer.concat([Buffer.from(seed, 'utf8'), cryptography.hash(value, 'utf8')]))
- .toString('hex');
- if (!this.accountFeatures.find((item) => item.label === elem.label)) {
- return {
- ...initialData,
- status: statusMap.stored,
- value,
- seed,
- };
- }
- if (this.accountFeatures.find((item) => item.label === elem.label).value !== hashValue) {
- return {
- ...initialData,
- status: statusMap.incorrect,
- value,
- seed,
- };
- }
- return {
- ...initialData,
- status: statusMap.completed,
- value,
- seed,
- };
- });
+ return decryptedData(this._accountData, this.accountFeatures, this.passPhrase, this.pubKey)
}
get firstName() {
diff --git a/src/utils/decryptedData.js b/src/utils/decryptedData.js
new file mode 100644
index 0000000..ee78f10
--- /dev/null
+++ b/src/utils/decryptedData.js
@@ -0,0 +1,48 @@
+import {labelMap} from "../shared/labelMap";
+import {statusMap} from "../shared/statusMap";
+import {cryptography} from "@liskhq/lisk-client";
+
+export const decryptedData=(serverData, blockchainData, passPhrase, pubKey)=>{
+ const allAccountData=serverData.concat(blockchainData.filter(item=>!serverData.find(elem=>elem.label===item.label)))
+ return allAccountData.map((elem) => {
+ const initialData={
+ ...elem,
+ key: elem.label,
+ label: labelMap[elem.label] || elem.label,
+ status: '',
+ value: '',
+ seed: ''
+ }
+ if(!serverData.find(item=>item.label===elem.label)) {
+ return {
+ ...initialData,
+ status: statusMap.blockchained,
+ value: elem.value
+ }
+ }
+ const [seed, value] = cryptography.decryptMessageWithPassphrase(elem.value, elem.value_nonce, passPhrase, pubKey).split(':');
+ const hashValue=cryptography.hash(Buffer.concat([Buffer.from(seed, 'utf8'), cryptography.hash(value, 'utf8')])).toString('hex')
+ if(!blockchainData.find(item=>item.label===elem.label)) {
+ return {
+ ...initialData,
+ status: statusMap.stored,
+ value,
+ seed
+ }
+ }
+ if(blockchainData.find(item=>item.label===elem.label).value!==hashValue) {
+ return {
+ ...initialData,
+ status: statusMap.incorrect,
+ value,
+ seed
+ }
+ }
+ return {
+ ...initialData,
+ status: statusMap.completed,
+ value,
+ seed
+ }
+ })
+}
| |