51 Commits
DID-1 ... DID-6

Author SHA1 Message Date
DwCay
0fb5764a70 Refactoring method saveDataRegistration in store 2022-07-11 11:15:53 +03:00
DuCay
138047fa10 Merge branch 'master' into DID-6 2022-07-08 21:24:04 +03:00
DwCay
a271da7bf9 Refactoring in Onboarding steps 2022-07-08 21:20:09 +03:00
Kirill Andrusyak
79784cbcee Merge pull request #32 from franze6/DID-7
Создана форма изменения параметров профиля, добавлен функционал для изменения и добавления параметров
2022-07-08 16:32:18 +03:00
Daria Golova
596c44aac3 changed strange IIFE function 2022-07-07 10:19:31 +03:00
Daria Golova
5d17137815 made sending data 2022-07-06 20:22:48 +03:00
Daria Golova
18bf373508 changed the names of the methods 2022-07-06 19:38:09 +03:00
Daria Golova
944c9989e9 fix seed 2022-07-06 19:33:27 +03:00
Daria Golova
202989f374 agreed on form to change and add 2022-07-06 19:33:27 +03:00
Daria Golova
f21d10f830 added prop key, made update form 2022-07-06 19:33:27 +03:00
DuCay
c8604a56ac Merge pull request #31 from franze6/DID-6
Changing data in store to array
2022-07-06 19:27:56 +03:00
DwCay
2d0ae35cc8 Changing data in store to array 2022-07-06 19:27:26 +03:00
DuCay
76f942b90f Merge pull request #30 from franze6/DID-6
Change methods in store
2022-07-06 18:52:22 +03:00
DwCay
f0e0d9479d Change methods in store 2022-07-06 18:51:57 +03:00
DuCay
3403289e0a Merge pull request #29 from franze6/DID-6
New naming for store
2022-07-06 12:59:44 +03:00
DwCay
25fddec6e8 New naming for store 2022-07-06 12:58:53 +03:00
DuCay
1d0cb45024 Merge pull request #28 from franze6/DID-6
Fix naming in store
2022-07-06 12:46:06 +03:00
DwCay
222850dfd9 Fix naming in store 2022-07-06 12:44:53 +03:00
Kirill Andrusyak
8f225752cf Merge pull request #27 from franze6/DID-6
Add method for delete property account
2022-07-06 12:28:46 +03:00
kandrusyak
038657751a add deploy files 2022-07-05 15:18:36 +03:00
kandrusyak
29d7d6fdb8 change endpoint url 2022-07-05 15:12:22 +03:00
DwCay
e44dfee284 Add method for delete property account 2022-07-04 18:02:34 +03:00
Kirill Andrusyak
0f455f126d Merge pull request #26 from franze6/DID-5
Интеграция таблицы страницы Profile с сервером
2022-07-04 10:10:03 +03:00
Daria Golova
0d4f27660a Merge branch 'DID-5' 2022-07-01 17:27:39 +03:00
Daria Golova
9703371f28 made a reference book 2022-07-01 17:16:09 +03:00
Daria Golova
16ca8a1df2 converted user data into Map object 2022-07-01 16:03:21 +03:00
Daria Golova
e883b190a7 converted user data into Map object 2022-07-01 16:01:20 +03:00
Daria Golova
85897a8efe changed name of the method in store.js 2022-06-30 14:50:59 +03:00
Daria Golova
5f85d1696a integrated received data into table 2022-06-30 14:42:59 +03:00
Daria Golova
1c539e5255 made userDataStore 2022-06-30 14:42:59 +03:00
DuCay
bcfc018560 Merge pull request #25 from franze6/DID-4
Did 4
2022-06-30 13:35:58 +03:00
DwCay
e175ca0295 fix naming for post method 2022-06-30 13:35:07 +03:00
DwCay
bac246eac2 fix label name for post request 2022-06-30 13:17:10 +03:00
DwCay
f65c99e86a fix store 2022-06-29 19:35:06 +03:00
DwCay
63439b2da1 Add method post encrypt auth data 2022-06-29 18:47:49 +03:00
Kirill Andrusyak
1d9368d200 Merge pull request #24 from franze6/DID-3
Доработка формы создания поля
2022-06-28 17:01:22 +03:00
kandrusyak
3a4ed9daf9 auth 2022-06-28 16:38:05 +03:00
Daria Golova
54ccd3ed9f fix popup hint 2022-06-23 18:52:19 +03:00
Daria Golova
fe1105e9d6 delete useEffect 2022-06-23 15:28:29 +03:00
Daria Golova
95cc2ac1e0 fix property field, added default value of seed 2022-06-23 15:21:08 +03:00
Daria Golova
b4516ef18e made a popup hint 2022-06-22 19:36:58 +03:00
kandrusyak
d617de75b5 router fix 2022-06-22 14:53:31 +03:00
Kirill Andrusyak
83e5e39d3c Merge pull request #21 from franze6/DID-2
Создание fetch wrapper
2022-06-21 11:47:58 +03:00
Kirill Andrusyak
f89d59e7df Merge branch 'master' into DID-2 2022-06-21 11:47:49 +03:00
Kirill Andrusyak
c944644db0 Merge pull request #23 from franze6/DID-1
Did 1
2022-06-21 11:44:57 +03:00
Daria Golova
f209ee5f5f added token availability check 2022-06-16 16:05:48 +03:00
Daria Golova
9bef3d9311 fix authorization by token 2022-06-16 15:25:25 +03:00
Daria Golova
632b98a81a added authorization by token 2022-06-16 14:30:41 +03:00
Daria Golova
81f5ec2741 fix methods 2022-06-15 14:36:23 +03:00
Daria Golova
3fcda54070 fix wrapper 2022-06-15 14:21:39 +03:00
Daria Golova
49aff14a80 create fetch wrapper 2022-06-14 13:53:28 +03:00
19 changed files with 758 additions and 323 deletions

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
# dependencies
/node_modules
.idea

15
Dockerfile Normal file
View File

@@ -0,0 +1,15 @@
FROM node:16-alpine AS builder
WORKDIR /front
COPY . .
RUN npm install
RUN npm run build
FROM nginx:1.21.6-alpine as runner
COPY ./deploy/nginx.conf /etc/nginx/nginx.conf
COPY --from=builder /front/build /var/www/html
EXPOSE 8080

33
deploy/nginx.conf Normal file
View File

@@ -0,0 +1,33 @@
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
gzip_static on;
server {
listen 8080;
server_name localhost;
charset utf-8;
location / {
root /var/www/html;
try_files $uri /index.html;
etag on;
expires max;
add_header Cache-Control public;
location = /index.html {
expires 0;
add_header Cache-Control "no-cache, public, must-revalidate, proxy-revalidate";
}
}
}
}

19
package-lock.json generated
View File

@@ -12580,6 +12580,25 @@
"integrity": "sha512-bRuZp3C0itgLKHu/VNxi66DN/XVkQG7xtoBVWxpvC5FhAqbOCP21+nPhULjnzEqd7xBMybp6KwytdUpZKEgpIQ==",
"requires": {}
},
"mobx": {
"version": "6.6.0",
"resolved": "https://registry.npmjs.org/mobx/-/mobx-6.6.0.tgz",
"integrity": "sha512-MNTKevLH/6DShLZcmSL351+JgiJPO56A4GUpoiDQ3/yZ0mAtclNLdHK9q4BcQhibx8/JSDupfTpbX2NZPemlRg=="
},
"mobx-react": {
"version": "7.5.0",
"resolved": "https://registry.npmjs.org/mobx-react/-/mobx-react-7.5.0.tgz",
"integrity": "sha512-riHu0XZJA6f64L1iXZoAaDjVt6suYoy8I2HIfuz2tX3O4FFaAe4lVA2CoObttmUQTTFPM7j3Df6T4re0cHkghQ==",
"requires": {
"mobx-react-lite": "^3.4.0"
}
},
"mobx-react-lite": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/mobx-react-lite/-/mobx-react-lite-3.4.0.tgz",
"integrity": "sha512-bRuZp3C0itgLKHu/VNxi66DN/XVkQG7xtoBVWxpvC5FhAqbOCP21+nPhULjnzEqd7xBMybp6KwytdUpZKEgpIQ==",
"requires": {}
},
"moment": {
"version": "2.29.3",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.3.tgz",

View File

@@ -2,7 +2,7 @@ import React, { useEffect } from 'react';
import {
Routes,
Route,
useLocation
useLocation,
} from 'react-router-dom';
import './css/style.scss';

3
src/api/node.js Normal file
View File

@@ -0,0 +1,3 @@
import {fetchWrapper} from '../shared/fetchWrapper';
export const getNodeInfo = (headers) => fetchWrapper.get('node/info/', headers)

View File

@@ -2,7 +2,7 @@ import React, { useState, useRef, useEffect } from 'react';
import {observer} from "mobx-react-lite";
import { Link } from 'react-router-dom';
import Transition from '../utils/Transition';
import {registrationStore} from "../store/registrationStore";
import {registrationStore} from "../store/store";
import {generateSvgAvatar} from "../images/GenerateOnboardingSvg/GenerateSvg";
import UserAvatar from '../images/user-avatar-32.png';

View File

@@ -1,7 +1,7 @@
import React from 'react'
import ReactDOM from 'react-dom'
import {Buffer} from "buffer";
import { BrowserRouter as Router } from 'react-router-dom'
import { HashRouter as Router } from 'react-router-dom'
import App from './App'
globalThis.Buffer = Buffer

View File

@@ -1,4 +1,4 @@
import React, {useEffect} from 'react';
import React from 'react';
import { Link } from 'react-router-dom';
import OnboardingImage from '../images/onboarding-image.jpg';
@@ -6,14 +6,11 @@ import OnboardingDecoration from '../images/auth-decoration.png';
import Logo from "../images/logo.png";
import {observer} from "mobx-react-lite";
import {passphrase} from "@liskhq/lisk-client";
import {registrationStore} from "../store/registrationStore";
import {registrationStore} from "../store/store";
const Onboarding1 = observer(()=>{
let phrase = passphrase.Mnemonic.generateMnemonic()
registrationStore.savePassPhrase(phrase)
useEffect(()=>{
},[])
return (
<main className="bg-white">

View File

@@ -1,7 +1,7 @@
import React, {useEffect, useState} from 'react';
import React, {useState} from 'react';
import { Link } from 'react-router-dom';
import { observer } from "mobx-react-lite";
import { registrationStore } from "../store/registrationStore";
import { registrationStore } from "../store/store";
import OnboardingImage from '../images/onboarding-image.jpg';
import OnboardingDecoration from '../images/auth-decoration.png';
@@ -11,9 +11,9 @@ const Onboarding2 = observer(()=>{
const [dataRegistration, setDataRegistration] = useState(
{
first_name: '',
last_name: '',
second_name: '',
gender: '',
date_birth: '',
birthdate: '',
}
)
const [fillingForm, setFillingForm] = useState(false)
@@ -24,31 +24,22 @@ const Onboarding2 = observer(()=>{
...dataRegistration,
[event.target.id]: newValue
})
if(!Object.keys(dataRegistration).find(item=>!dataRegistration[item])) {
setFillingForm(true)
}
}
const saveStoreRegistration = ()=>{
Object.keys(dataRegistration).forEach(item=>{
let element=document.getElementById(item)
if(dataRegistration[item]) {
element.style.borderColor=""
} else {
element.style.borderColor="red"
}
})
if(Object.keys(dataRegistration).find(item=>!dataRegistration[item])) {
return
} else {
setFillingForm(true)
if(fillingForm) {
registrationStore.saveDataRegistration(Object.keys(dataRegistration).map(item=>{
return{
key: `${item}`,
value: dataRegistration[item]
}
}))
}
registrationStore.saveDataRegistration(dataRegistration)
}
useEffect(()=>{
if(fillingForm===true) {
document.getElementById("signup").click()
}
},[fillingForm])
return (
<main className="bg-white">
@@ -107,8 +98,8 @@ const Onboarding2 = observer(()=>{
<input id="first_name" onChange={(event)=>saveValueChange(event)} className="form-input w-full" type="text" />
</div>
<div>
<label className="block text-sm font-medium mb-1" htmlFor="last_name">Last name <span className="text-rose-500">*</span></label>
<input id="last_name" onChange={(event)=>saveValueChange(event)} className="form-input w-full" type="text" />
<label className="block text-sm font-medium mb-1" htmlFor="second_name">Last name <span className="text-rose-500">*</span></label>
<input id="second_name" onChange={(event)=>saveValueChange(event)} className="form-input w-full" type="text" />
</div>
<div>
<label className="block text-sm font-medium mb-1" htmlFor="gender">Gender <span className="text-rose-500">*</span></label>
@@ -119,8 +110,8 @@ const Onboarding2 = observer(()=>{
</select>
</div>
<div>
<label className="block text-sm font-medium mb-1" htmlFor="date_birth">Date of birth <span className="text-rose-500">*</span></label>
<input id="date_birth" onChange={(event)=>saveValueChange(event)} className="form-input w-full" type="date" autoComplete="on" />
<label className="block text-sm font-medium mb-1" htmlFor="birthdate">Date of birth <span className="text-rose-500">*</span></label>
<input id="birthdate" onChange={(event)=>saveValueChange(event)} className="form-input w-full" type="date" autoComplete="on" />
</div>
</div>
<div className="flex items-center justify-between mt-6">

View File

@@ -2,23 +2,22 @@ import React, { useState} from 'react';
import { Link } from 'react-router-dom';
import {generateSvgAvatar} from "../images/GenerateOnboardingSvg/GenerateSvg";
import Logo from "../images/logo.png";
import {registrationStore} from "../store/registrationStore";
import {registrationStore} from "../store/store";
import { passphrase } from "@liskhq/lisk-client";
function Onboarding3() {
const [passPhrase, setPassPhrase] = useState(registrationStore.passPhraseStore.replace(/\s+/g, ' ').split(' ').map((item, index) => ({str:item, id:index })))
const [passPhrase, setPassPhrase] = useState(convertPhraseToArray(registrationStore.passPhrase))
function generatePassPhrase() {
let phrase = passphrase.Mnemonic.generateMnemonic()
registrationStore.savePassPhrase(phrase)
let newPassPhrase = registrationStore.passPhraseStore.split(' ').map((item, index) => ({str:item, id:index }))
setPassPhrase(newPassPhrase)
setPassPhrase(convertPhraseToArray(registrationStore.passPhrase))
}
function savePassPhraseInStore (copiedPhrase) {
let phrasePaste = copiedPhrase.trim().replace(/\s+/g, ' ').split(' ')
let phrasePaste = convertPhraseToArray(copiedPhrase.trim())
if(phrasePaste.length===12) {
registrationStore.savePassPhrase(copiedPhrase)
setPassPhrase(phrasePaste.map((item, index) => ({str:item, id:index })))
registrationStore.savePassPhrase(copiedPhrase.trim())
setPassPhrase(phrasePaste)
} else {
return false
}
@@ -28,6 +27,10 @@ function Onboarding3() {
navigator.clipboard.readText().then(res=>savePassPhraseInStore(res))
}
function convertPhraseToArray(phrase) {
return phrase.split(' ').map((item, index) => ({str:item, id:index }))
}
return (
<main className="bg-white">

View File

@@ -1,29 +1,29 @@
import React, {useEffect, useState} from 'react';
import React, {useState} from 'react';
import { Link } from 'react-router-dom';
import {generateSvgAvatar} from "../images/GenerateOnboardingSvg/GenerateSvg";
import Logo from "../images/logo.png";
import {observer} from "mobx-react-lite";
import { registrationStore } from "../store/registrationStore";
import { registrationStore } from "../store/store";
const Onboarding4 = observer(()=>{
const [checkBoxesSelected, setCheckBoxesSelected] = useState(false)
function validateCheckBox () {
let checkBoxes=[...document.getElementsByClassName("form-checkbox")]
if(checkBoxes.find(item=>item.checked===false)) {
return
} else {
setCheckBoxesSelected(true)
const [checkBoxesSelected, setCheckBoxesSelected] = useState([])
function createAccount () {
if(checkBoxesSelected.length===2) {
registrationStore.pushAccountData()
}
}
useEffect(()=>{
if(checkBoxesSelected===true) {
document.getElementById("link-dashboard").click()
function saveCheckBoxesValues(e) {
const { id, checked } = e.target
setCheckBoxesSelected([...checkBoxesSelected, id])
if (!checked) {
setCheckBoxesSelected(checkBoxesSelected.filter(item=>item!==id))
}
},[checkBoxesSelected])
}
const firstNameAccount = registrationStore.accountData.length && registrationStore.accountData.find(item=>item.key==="first_name").value
return (
<main className="bg-white">
@@ -80,20 +80,20 @@ const Onboarding4 = observer(()=>{
<circle className="text-emerald-100" cx="32" cy="32" r="32" />
<path className="text-emerald-500" d="m28.5 41-8-8 3-3 5 5 12-12 3 3z" />
</svg>
<h1 className="text-3xl text-slate-800 font-bold mb-8">{registrationStore.accountData.first_name ? `Nice to meet you, ${registrationStore.accountData.first_name} 🙌` : 'Please, go back step 2'}</h1>
<button onClick={()=>validateCheckBox()} className="btn px-6 bg-indigo-500 hover:bg-indigo-600 text-white">
<Link id="link-dashboard" to={checkBoxesSelected && "/dashboard"}>Go To Profile -&gt;</Link>
<h1 className="text-3xl text-slate-800 font-bold mb-8">{firstNameAccount ? `Nice to meet you, ${firstNameAccount} 🙌` : 'Please, go back step 2'}</h1>
<button onClick={()=>createAccount()} className="btn px-6 bg-indigo-500 hover:bg-indigo-600 text-white">
<Link id="link-dashboard" to={checkBoxesSelected.length===2 && "/dashboard"}>Go To Profile -&gt;</Link>
</button>
</div>
<div className="flex items-center justify-between">
<div className="mr-1">
<label className="flex items-center">
<input type="checkbox" className="form-checkbox" />
<input id="checkbox-1" onChange={(e)=>saveCheckBoxesValues(e)} type="checkbox" className="form-checkbox" />
<span className="text-sm ml-2">I understand that Idntty cannot recover pass phrase</span>
</label>
<label className="flex items-center">
<input type="checkbox" className="form-checkbox" />
<input id="checkbox-2" onChange={(e)=>saveCheckBoxesValues(e)} type="checkbox" className="form-checkbox" />
<div className="text-sm ml-2">
I <Link className="text-indigo-500 hover:text-indigo-600 underline" to="/">store my pharse</Link> very carefuly
</div>

View File

@@ -1,34 +1,89 @@
import React, { useState } from 'react';
import { userDataStore } from '../../store/userDataStore';
import { registrationStore } from "../../store/store";
import Sidebar from '../../partials/Sidebar';
import { observer } from 'mobx-react-lite';
import Header from '../../partials/Header';
import ProfileTable from '../../partials/digitalId/ProfileTable';
import Image from '../../images/transactions-image-04.svg';
import ProfileIcon from '../../images/profile-icon.svg';
import Avatar01 from '../../images/avatar-01.jpg';
import Avatar02 from '../../images/avatar-02.jpg';
import Avatar03 from '../../images/avatar-03.jpg';
function Profile () {
const Profile = observer (() => {
const [sidebarOpen, setSidebarOpen] = useState(false);
const [buttonPanelOpen, setButtonPanelOpen] = useState(true);
const [removePanelOpen, setRemovePanelOpen] = useState(false);
const [changePanelOpen, setChangePanelOpen] = useState(false);
const [toggle, setToggle] = useState(true);
const [addPanelOpen, setAddPanelOpen] = useState(false);
const [updatePanelOpen, setUpdatePanelOpen] = useState(false);
const [selectedItems, setSelectedItems] = useState([]);
const defaultValues = {
label: '',
value: '',
seed: Math.floor(Math.random() * 90000000000000000000)
};
const initialPropertyValues = ['First name', 'Second name', 'Birthdate', 'Gender', 'National doctype', 'National doc id', 'National doc issue date', 'National doc expiry date'];
const [propertyValues, setPropertyValues] = useState([]);
const [updatedValues, setUpdatedValues] = useState([defaultValues]);
const [addedValues, setAddedValues] = useState(defaultValues);
const openHint = () => {
if (!addedValues.label) {
setPropertyValues(initialPropertyValues);
}
}
const changeAddedValues = (value, field) => {
setAddedValues((prevState) => (
field !== 'seed' ? {
...prevState,
[field]: value
} : {
...prevState,
[field]: +value,
}))
};
const changeUpdatedValues = (value, field, key) => {
setUpdatedValues((prevState) =>
prevState.map((elem) => (
(elem.key === key && field !== 'seed') ? {
...elem,
[field]: value,
} :
(elem.key === key) ? {
...elem,
[field]: +value,
} : elem
))
)
};
const closeHint = (element) => {
changeAddedValues(element, 'label');
setPropertyValues([]);
}
const handleSelectedItems = (selectedItems) => {
setSelectedItems([...selectedItems]);
setUpdatedValues(userDataStore.decryptedData.filter(({ key }) => selectedItems.includes(key))
.map(elem => (
(!elem.seed) ? {
...elem,
seed: Math.floor(Math.random() * 90000000000000000000)
}: elem)));
if (selectedItems.length > 0) {
setButtonPanelOpen(false);
setAddPanelOpen(false);
setChangePanelOpen(true);
}
if (removePanelOpen === true) {
if (removePanelOpen === true || updatePanelOpen === true) {
setChangePanelOpen(false);
}
if (selectedItems.length === 0) {
setRemovePanelOpen(false);
setUpdatePanelOpen(false);
setButtonPanelOpen(true);
setChangePanelOpen(false);
}
@@ -39,155 +94,90 @@ function Profile () {
setButtonPanelOpen(false);
}
const sendAddedData = () => {
if (!userDataStore.decryptedData.some((element) => element.label === addedValues.label) && (addedValues.seed.toString().length === 20)) {
setAddPanelOpen(false);
setButtonPanelOpen(true);
setAddedValues(defaultValues);
addDataParameters();
}
}
const sendUpdatedData = () => {
setUpdatePanelOpen(false);
changeDataParameters();
setChangePanelOpen(true);
}
const deleteDataParameters = () => {
const changeData = userDataStore.decryptedData.filter(item=>!selectedItems.includes(item.key))
registrationStore.pushAccountData(changeData);
}
const changeInitialArray = () => {
let newArr = [];
userDataStore.decryptedData.map(elem => {
updatedValues.forEach(item => {
if (elem.label === item.label) {
newArr.push({
...elem,
'value': item.value,
'seed': item.seed,
})
}
})
if (!newArr.find(element => element.label === elem.label)) {
newArr.push(elem);
}
})
return newArr;
}
const changeDataParameters = () => {
const updatedData = changeInitialArray();
registrationStore.pushAccountData(updatedData);
}
const addDataParameters = () => {
addedValues.key = addedValues.label.toLowerCase().split(' ').join('_');
registrationStore.pushAccountData(userDataStore.decryptedData.concat(addedValues));
}
const cancelAddPanel = () => {
setAddedValues(defaultValues);
setAddPanelOpen(false);
setButtonPanelOpen(true);
}
const cancelUpdatePanel = () => {
setUpdatePanelOpen(false);
setChangePanelOpen(true);
}
const openRemovePanel = () => {
setRemovePanelOpen(true);
setChangePanelOpen(false);
}
const applyRemovePanel = () => {
setRemovePanelOpen(false);
setButtonPanelOpen(true);
const openUpdatePanel = () => {
setUpdatePanelOpen(true);
setChangePanelOpen(false);
}
const userData = [
{
id: '0',
category: 'General',
validated: true,
blockchained: true,
image: ProfileIcon,
value: 'Dominik',
property: 'First name',
status: 'Completed',
transactions: ['0x7234ABC342342352345', '0x5745DEF342342352345'],
avatars: [Avatar01, Avatar02, Avatar03]
},
{
id: '1',
category: 'General',
validated: true,
blockchained: true,
image: ProfileIcon,
value: 'Lamakani',
property: 'Second name',
status: 'Progress',
transactions: ['0x7234ABC342342352345', '0x5745DEF342342352345'],
avatars: null
},
{
id: '2',
category: 'General',
validated: true,
blockchained: true,
image: ProfileIcon,
value: '05.10.1983',
property: 'Birthdate',
status: 'Incorrect',
transactions: ['0x7234ABC342342352345', '0x5745DEF342342352345'],
avatars: null
},
{
id: '3',
category: 'General',
validated: true,
blockchained: true,
image: ProfileIcon,
value: 'Male',
property: 'Gender',
status: 'Stored',
transactions: ['0x7234ABC342342352345', '0x5745DEF342342352345'],
avatars: null
},
{
id: '4',
category: 'Nationality',
validated: true,
blockchained: true,
image: ProfileIcon,
value: 'United Kindom',
property: 'Residence',
status: 'Completed',
transactions: ['0x7234ABC342342352345', '0x5745DEF342342352345'],
avatars: [Avatar01, Avatar02, Avatar03]
},
{
id: '5',
category: 'Nationality',
validated: true,
blockchained: true,
image: ProfileIcon,
value: 'Passport',
property: 'Document type',
status: 'Progress',
transactions: ['0x7234ABC342342352345', '0x5745DEF342342352345'],
avatars: [Avatar01, Avatar02, Avatar03]
},
{
id: '6',
category: 'Nationality',
validated: true,
blockchained: true,
image: ProfileIcon,
value: 'A123B3143',
property: 'Document ID',
status: 'Incorrect',
transactions: ['0x7234ABC342342352345', '0x5745DEF342342352345'],
avatars: null
},
{
id: '7',
category: 'Nationality',
validated: true,
blockchained: true,
image: ProfileIcon,
value: '05.10.2012',
property: 'Issue date',
status: 'Stored',
transactions: ['0x7234ABC342342352345', '0x5745DEF342342352345'],
avatars: null
},
{
id: '8',
category: 'Nationality',
validated: true,
blockchained: true,
image: ProfileIcon,
value: '05.10.2032',
property: 'Expiry date',
status: 'Stored',
transactions: ['0x7234ABC342342352345', '0x5745DEF342342352345'],
avatars: null
},
{
id: '9',
category: 'Social',
validated: true,
blockchained: true,
image: ProfileIcon,
value: '@lamakani',
property: 'Telegram',
status: 'Completed',
transactions: ['0x7234ABC342342352345', '0x5745DEF342342352345'],
avatars: null
},
{
id: '10',
category: 'Social',
validated: true,
blockchained: true,
image: ProfileIcon,
value: '@lamakani',
property: 'Telegram',
status: 'Progress',
transactions: ['0x7234ABC342342352345', '0x5745DEF342342352345'],
avatars: [Avatar01, Avatar02, Avatar03]
},
]
const applyDataDeletion = () => {
setRemovePanelOpen(false);
setButtonPanelOpen(true);
deleteDataParameters()
}
const handleInput = (text, field) => {
changeAddedValues(text, field);
setPropertyValues(initialPropertyValues);
if (text) {
let reg = new RegExp(`^${text}`, 'img');
setPropertyValues((prevState) => prevState.filter((element) => element.match(reg)));
}
};
return (
<div className="flex h-screen overflow-hidden">
@@ -222,7 +212,7 @@ function Profile () {
</ul>
</div>
{/* Table */}
<ProfileTable selectedItems={handleSelectedItems} userData={userData}/>
<ProfileTable selectedItems={handleSelectedItems} userData={userDataStore.decryptedData}/>
</div>
{/* Left sidebar */}
<div>
@@ -246,22 +236,56 @@ function Profile () {
<div className="flex flex-col gap-y-3">
<div>
<label className="block text-sm font-medium mb-1" htmlFor="mandatory">Property <span className="text-rose-500">*</span></label>
<input id="property" className="form-input w-full" type="text" required />
<input
autoComplete='off'
id="label"
className="form-input w-full"
type="text"
required
onInput={(e) => handleInput(e.target.value, 'label')}
value={addedValues.label}
onClick={openHint}
/>
<div className={`flex flex-col gap-y-2 py-2 pl-2 border border-t-0 border-slate-200 rounded ${(propertyValues.length > 0) || 'hidden'}`}>
<ul>
{propertyValues.map((element, index) => (
<li key={index} onClick={() => closeHint(element)}>{element}</li>
))}
</ul>
</div>
</div>
<div>
<label className="block text-sm font-medium mb-1" htmlFor="mandatory">Value <span className="text-rose-500">*</span></label>
<input id="value" className="form-input w-full" type="text" required />
<input
autoComplete='off'
id="value"
className="form-input w-full"
type="text"
required
onClick={() => setPropertyValues([])}
onChange={(e) => changeAddedValues(e.target.value, 'value')}
value={addedValues.value}
/>
</div>
<div>
<label className="block text-sm font-medium mb-1" htmlFor="mandatory">Seed <span className="text-rose-500">*</span></label>
<input id="seed" className="form-input w-full" type="text" required />
<input
autoComplete='off'
id="seed"
className="form-input w-full"
type="number"
required
onClick={() => setPropertyValues([])}
onChange={(e) => changeAddedValues(e.target.value, 'seed')}
value={addedValues.seed}
/>
</div>
</div>
<div className="flex flex-row justify-between pt-[16px] pb-[23px] items-center border-b border-slate-200">
<span className="block text-sm font-medium">Store data on blockchain</span>
<div className="flex items-center">
<div className="form-switch">
<input type="checkbox" id="switch-1" className="sr-only" checked={toggle} onChange={() => setToggle(!toggle)} />
<input type="checkbox" id="blockcheined" className="sr-only" checked={toggle} onChange={() => setToggle(!toggle)} />
<label className="bg-slate-400" htmlFor="switch-1">
<span className="bg-white shadow-sm" aria-hidden="true"></span>
</label>
@@ -278,7 +302,79 @@ function Profile () {
</button>
<button
className="btn-sm bg-indigo-500 hover:bg-indigo-600 text-white"
onClick={cancelAddPanel}
onClick={sendAddedData}
>
Send
</button>
</div>
</div>
{/* Update panel */}
<div className={`${!updatePanelOpen && 'hidden'} bg-white p-5 shadow-lg rounded-sm border border-slate-200 lg:w-72 xl:w-80 mb-11`}>
{updatedValues.map((item, index) => (
<div key={index} className="flex flex-col gap-y-3">
<div>
<label className="block text-sm font-medium mb-1" htmlFor="mandatory">Property <span className="text-rose-500">*</span></label>
<input
id={`${item.key}:label`}
className="form-input w-full"
type="text"
required
onChange={(e) => changeUpdatedValues(e.target.value, 'label', item.key)}
value={item.label}
disabled='disabled'
/>
</div>
<div>
<label className="block text-sm font-medium mb-1" htmlFor="mandatory">Value <span className="text-rose-500">*</span></label>
<input
autoComplete='off'
id={`${item.key}:value`}
className="form-input w-full"
type="text"
required
onChange={(e) => changeUpdatedValues(e.target.value, 'value', item.key)}
value={item.value}
/>
</div>
<div>
<label className="block text-sm font-medium mb-1" htmlFor="mandatory">Seed <span className="text-rose-500">*</span></label>
<input
autoComplete='off'
id={`${item.key}:seed`}
className="form-input w-full"
type="number"
required
onChange={(e) => changeUpdatedValues(e.target.value, 'seed', item.key)}
value={item.seed}
/>
</div>
{(updatedValues[index+1]) ? (
<div className="mt-2 mb-3.5 items-center border-b border-slate-200"></div>
) : null}
</div>
))}
<div className="flex flex-row justify-between pt-[16px] pb-[23px] items-center border-b border-slate-200">
<span className="block text-sm font-medium">Store data on blockchain</span>
<div className="flex items-center">
<div className="form-switch">
<input type="checkbox" id="blockcheined" className="sr-only" checked={toggle} onChange={() => setToggle(!toggle)} />
<label className="bg-slate-400" htmlFor="switch-1">
<span className="bg-white shadow-sm" aria-hidden="true"></span>
</label>
</div>
</div>
</div>
{/* Buttons */}
<div className="flex flex-row justify-end gap-x-2 pt-[18px] pb-[14px] items-end">
<button
className="btn-sm bg-white border-slate-200 hover:bg-slate-50 text-slate-600"
onClick={cancelUpdatePanel}
>
Cansel
</button>
<button
className="btn-sm bg-indigo-500 hover:bg-indigo-600 text-white"
onClick={sendUpdatedData}
>
Send
</button>
@@ -288,8 +384,8 @@ function Profile () {
<div className={`${!removePanelOpen && 'hidden'} bg-white px-5 pt-4 pb-[190px] shadow-lg rounded-sm border border-slate-200 lg:w-72 xl:w-80 mb-12`}>
<h2 className="grow text-base font-semibold text-slate-800 truncate mb-2">Summary</h2>
<div className="flex flex-col">
{userData.filter(({ id }) => selectedItems.includes(id)).map(item => (
<span key={item.id} className="text-sm font-normal text-slate-600 py-3 border-b border-slate-200">{item.property}</span>
{userDataStore.decryptedData.filter(({ key }) => selectedItems.includes(key)).map(item => (
<span key={item.label} className="text-sm font-normal text-slate-600 py-3 border-b border-slate-200">{item.label}</span>
))}
</div>
<div className="flex flex-row justify-between pt-[16px] pb-7 items-center">
@@ -306,7 +402,7 @@ function Profile () {
<div className="flex flex-row justify-end gap-x-2 pt-[20px] pb-[16px] items-end">
<button
className="btn w-full bg-indigo-500 hover:bg-indigo-600 text-white px-[100px] justify-start"
onClick={applyRemovePanel}
onClick={applyDataDeletion}
>
<svg className="w-4 h-4 fill-current shrink-0" viewBox="0 0 16 16">
<path d="m2.457 8.516.969-.99 2.516 2.481 5.324-5.304.985.989-6.309 6.284z" />
@@ -369,7 +465,10 @@ function Profile () {
</svg>
<span className="ml-2">Remove</span>
</button>
<button className="btn w-full border-slate-200 hover:border-slate-300 text-slate-600 px-[100px] justify-start">
<button
className="btn w-full border-slate-200 hover:border-slate-300 text-slate-600 px-[100px] justify-start"
onClick={openUpdatePanel}
>
<svg className="w-4 h-4 fill-rose-500 shrink-0" viewBox="0 0 16 16">
<path d="M14.682 2.318A4.485 4.485 0 0 0 11.5 1 4.377 4.377 0 0 0 8 2.707 4.383 4.383 0 0 0 4.5 1a4.5 4.5 0 0 0-3.182 7.682L8 15l6.682-6.318a4.5 4.5 0 0 0 0-6.364Zm-1.4 4.933L8 12.247l-5.285-5A2.5 2.5 0 0 1 4.5 3c1.437 0 2.312.681 3.5 2.625C9.187 3.681 10.062 3 11.5 3a2.5 2.5 0 0 1 1.785 4.251h-.003Z" />
</svg>
@@ -390,6 +489,6 @@ function Profile () {
</div>
</div>
)
}
})
export default Profile;
export default Profile

View File

@@ -2,7 +2,7 @@ import React, { useState } from 'react';
import Sidebar from '../../partials/Sidebar';
import Header from '../../partials/Header';
function Verify () {
const Verify = (() => {
const [sidebarOpen, setSidebarOpen] = useState(false);
const [descriptionOpen, setDescriptionOpen] = useState(false);
@@ -165,6 +165,6 @@ function Verify () {
</div>
</div>
)
}
})
export default Verify;

View File

@@ -1,5 +1,6 @@
import React, {useState, useEffect} from 'react';
import ProfileTableItem from './ProfileTableItem';
import ProfileIcon from '../../images/profile-icon.svg';
function ProfileTable({
selectedItems,
@@ -8,6 +9,13 @@ function ProfileTable({
const [isCheck, setIsCheck] = useState([]);
const defaultData = {
image: ProfileIcon,
status: 'Stored',
transactions: ['0x7234ABC342342352345', '0x5745DEF342342352345'],
avatars: null
}
useEffect(() => {
selectedItems(isCheck);
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -21,85 +29,123 @@ function ProfileTable({
}
};
const data = {
general:["First name","Second name", "Gender", "Birthdate", "Place of birth"],
nationality:["Nationality", "National ID", "National doctype", "National doc ID", "National doc issue date", "National doc expiry date"],
social:["Telephone", "Twitter", "Facebook", "Instagram", "Youtube", "Wechat", "Tiktok", "Linkedin", "Vk", "Github", "Telegram", "Qq", "Snapchat", "Reddit"]
}
const generalData = userData.filter(elem => data.general.includes(elem.label)),
nationalityData = userData.filter(elem => data.nationality.includes(elem.label)),
sosialData = userData.filter(elem => data.social.includes(elem.label)),
otherData = userData.filter((elem) =>
!data.general.includes(elem.label) && !data.nationality.includes(elem.label) && !data.social.includes(elem.label));
return (
<>
{/* General */}
<h2 className="grow text-base font-semibold text-slate-800 truncate mb-2.5 mt-8">General 🖋</h2>
<div className="overflow-x-auto w-[828px]">
<table className="w-[828px] table-auto w-full">
<tbody className="divide-slate-200 divide-y">
{userData.filter(data => data.category === 'General')
.map(data => {
<div className={`${generalData.length > 0 || 'hidden'}`}>
<h2 className="grow text-base font-semibold text-slate-800 truncate mb-2.5 mt-8">General 🖋</h2>
<div className="overflow-x-auto w-[828px]">
<table className="w-[828px] table-auto w-full">
<tbody className="divide-slate-200 divide-y">
{generalData.map((data) => {
return (
<ProfileTableItem
key={data.id}
id={data.id}
image={data.image}
value={data.value}
property={data.property}
status={data.status}
transactions={data.transactions}
avatars={data.avatars}
key={data.label}
id={data.key}
image={defaultData.image}
value={data.value.charAt(0).toUpperCase()+data.value.slice(1)}
property={data.label}
status={defaultData.status}
transactions={defaultData.transactions}
avatars={defaultData.avatars}
handleClick={handleClick}
isChecked={isCheck.includes(data.id)}
isChecked={isCheck.includes(data.key)}
/>
)
})
}
</tbody>
</table>
})}
</tbody>
</table>
</div>
</div>
{/* Nationality */}
<h2 className="grow text-base font-semibold text-slate-800 truncate mb-2.5 mt-8">Nationality 🖋</h2>
<div className="overflow-x-auto w-[828px]">
<table className="w-[828px] table-auto w-full">
<tbody className="text-sm divide-slate-200 divide-y ">
{userData.filter(data => data.category === 'Nationality')
.map(data => {
<div className={`${nationalityData.length > 0 || 'hidden'}`}>
<h2 className="grow text-base font-semibold text-slate-800 truncate mb-2.5 mt-8">Nationality 🖋</h2>
<div className="overflow-x-auto w-[828px]">
<table className="w-[828px] table-auto w-full">
<tbody className="text-sm divide-slate-200 divide-y ">
{nationalityData.map(data => {
return (
<ProfileTableItem
key={data.id}
id={data.id}
image={data.image}
value={data.value}
property={data.property}
status={data.status}
transactions={data.transactions}
avatars={data.avatars}
key={data.label}
id={data.key}
image={defaultData.image}
value={data.value.charAt(0).toUpperCase()+data.value.slice(1)}
property={data.label}
status={defaultData.status}
transactions={defaultData.transactions}
avatars={defaultData.avatars}
handleClick={handleClick}
isChecked={isCheck.includes(data.id)}
isChecked={isCheck.includes(data.key)}
/>
)
})
}
</tbody>
</table>
})}
</tbody>
</table>
</div>
</div>
{/* Social */}
<h2 className="grow text-base font-semibold text-slate-800 truncate mb-2.5 mt-8">Social 🖋</h2>
<div className="overflow-x-auto w-[828px]">
<table className="w-[828px] table-auto w-full">
<tbody className="text-sm divide-slate-200 divide-y ">
{userData.filter(data => data.category === 'Social')
.map(data => {
return (
<ProfileTableItem
key={data.id}
id={data.id}
image={data.image}
value={data.value}
property={data.property}
status={data.status}
transactions={data.transactions}
avatars={data.avatars}
handleClick={handleClick}
isChecked={isCheck.includes(data.id)}
/>
)
})
}
</tbody>
</table>
<div className={`${sosialData.length > 0 || 'hidden'}`}>
<h2 className="grow text-base font-semibold text-slate-800 truncate mb-2.5 mt-8">Social 🖋</h2>
<div className="overflow-x-auto w-[828px]">
<table className="w-[828px] table-auto w-full">
<tbody className="text-sm divide-slate-200 divide-y ">
{sosialData.map(data => {
return (
<ProfileTableItem
key={data.label}
id={data.key}
image={defaultData.image}
value={data.value.charAt(0).toUpperCase()+data.value.slice(1)}
property={data.label}
status={defaultData.status}
transactions={defaultData.transactions}
avatars={defaultData.avatars}
handleClick={handleClick}
isChecked={isCheck.includes(data.key)}
/>
)
})}
</tbody>
</table>
</div>
</div>
{/* Other */}
<div className={`${otherData.length > 0 || 'hidden'}`}>
<h2 className="grow text-base font-semibold text-slate-800 truncate mb-2.5 mt-8">Other 🖋</h2>
<div className="overflow-x-auto w-[828px]">
<table className="w-[828px] table-auto w-full">
<tbody className="text-sm divide-slate-200 divide-y ">
{otherData.map(data => {
return (
<ProfileTableItem
key={data.key}
id={data.key}
image={defaultData.image}
value={data.value}
property={data.label}
status={defaultData.status}
transactions={defaultData.transactions}
avatars={defaultData.avatars}
handleClick={handleClick}
isChecked={isCheck.includes(data.key)}
/>
)
})}
</tbody>
</table>
</div>
</div>
</>
)

103
src/shared/fetchWrapper.js Normal file
View File

@@ -0,0 +1,103 @@
import {registrationStore} from '../store/store';
function prepareUrl(url) {
if (url.startsWith('http')) return url;
return `http://3.125.47.101/api/${url}`;
}
function handleRequest(method, url, headers, attempts, token, body) {
return new Promise((resolve, reject) => {
(function internalRequest() {
return request(method, url, headers, token, body)
.then(resolve)
.catch(err => --attempts > 0 ? internalRequest() : reject(err))
})()
})
.then((res) => res.json())
.catch(() => [])
};
/**
* Request
* @param {string} method - method name
* @param {string} url - endpoint url.
* @param {string} token - auth token
* @param {object} body - request body.
* @param {object} headers - request headers
*/
function request(method, url, headers = {}, token, body) {
let controller = new AbortController;
let requestOptions = {};
if (method === 'GET' || method === 'DELETE'){
requestOptions = {
method: method,
headers: {
Authorization: `IDNTTY ${token}`,
...headers
},
signal: controller.signal,
}
};
if (method === 'POST' || method === 'PUT'){
requestOptions = {
method: method,
headers: {
Authorization: `IDNTTY ${token}`,
Accept: 'application/json',
'Content-Type': 'application/json',
...headers
},
body: JSON.stringify(body),
signal: controller.signal,
}
};
if (!token) {
requestOptions.headers.Authorization = null;
}
setTimeout(() => controller.abort(), 3000);
return fetch(prepareUrl(url), requestOptions);
};
function get(url, headers, attempts = 1) {
return handleRequest('GET', url, headers, attempts, null);
}
function getAuth(url, headers, attempts = 1) {
return handleRequest('GET', url, headers, attempts, registrationStore.tokenKey);
}
function del(url, headers, attempts = 1) {
return handleRequest('DELETE', url, headers, attempts, null);
}
function delAuth(url, headers, attempts = 1) {
return handleRequest('DELETE', url, headers, attempts, registrationStore.tokenKey);
}
function post(url, headers, body, attempts = 1) {
return handleRequest('POST', url, headers, attempts, null, body);
}
function postAuth(url, headers, body, attempts = 1) {
return handleRequest('POST', url, headers, attempts, registrationStore.tokenKey, body);
}
function put(url, headers, body, attempts = 1) {
return handleRequest('PUT', url, headers, attempts, null, body);
}
function putAuth(url, headers, body, attempts = 1) {
return handleRequest('PUT', url, headers, attempts, registrationStore.tokenKey, body);
}
export const fetchWrapper = {
get,
del,
post,
put,
getAuth,
delAuth,
postAuth,
putAuth,
baseUrl: ''
};

View File

@@ -1,41 +0,0 @@
import { reaction, makeAutoObservable } from "mobx";
import {cryptography} from "@liskhq/lisk-client";
class RegistrationStore {
_accountData = {}
_passPhraseStore=''
_pubKey = ''
constructor() {
makeAutoObservable(this);
reaction(()=>this.passPhraseStore, ()=>this.savePubKey())
};
savePassPhrase(phrase) {
this._passPhraseStore = phrase
}
saveDataRegistration(data) {
this._accountData = data;
};
savePubKey() {
this._pubKey = cryptography.bufferToHex(cryptography.getAddressAndPublicKeyFromPassphrase(this.passPhraseStore).publicKey)
}
get passPhraseStore() {
return this._passPhraseStore
}
get accountData() {
return this._accountData
};
get pubKey() {
return this._pubKey
}
};
export const registrationStore = new RegistrationStore();

113
src/store/store.js Normal file
View File

@@ -0,0 +1,113 @@
import { reaction, makeAutoObservable } from "mobx";
import {cryptography} from "@liskhq/lisk-client";
import {getNodeInfo} from '../api/node';
import {fetchWrapper} from '../shared/fetchWrapper';
class Store {
_accountData = []
_passPhrase='rocket north inform swift improve fringe sweet crew client canyon bean autumn'
_nodeInfo = {}
_userData = {}
constructor() {
makeAutoObservable(this);
this.fetchNodeInfo()
reaction(() => this.tokenKey, () => this.fetchNewAccountData())
};
fetchNewAccountData() {
fetchWrapper.getAuth('http://3.125.47.101/api/data/private', {
networkIdentifier: this.nodeInfo.networkIdentifier,
lastBlockID: this.nodeInfo.lastBlockID
}).then((res) => this.userDataFetchChange(res))
}
pushAccountData(data=this.accountData) {
fetchWrapper.postAuth('http://3.125.47.101/api/data/private', {
networkIdentifier: this.nodeInfo.networkIdentifier,
lastBlockID: this.nodeInfo.lastBlockID
}, [...this.encryptAccountData(data)])
.then(()=>this.fetchNewAccountData())
}
userDataFetchChange(res) {
this._userData = res;
}
get userData() {
return this._userData
}
savePassPhrase(phrase) {
this._passPhrase = phrase
}
saveDataRegistration(data) {
this._accountData = data;
};
fetchNodeInfo() {
getNodeInfo()
.then((info) => this.fetchNodeInfoSuccess(info))
.catch((err) => this.fetchNodeInfoFailed(err))
}
fetchNodeInfoSuccess(info) {
this._nodeInfo = info.data;
}
fetchNodeInfoFailed(err) {
console.log(err)
}
get passPhrase() {
return 'rocket north inform swift improve fringe sweet crew client canyon bean autumn'
}
get accountData() {
return this._accountData
};
encryptAccountData(data) {
return data.map((item) => {
let value = cryptography.encryptMessageWithPassphrase(cryptography.getRandomBytes(32).toString('hex') + ":" + item.value, this.passPhrase, this.pubKey);
return {
"label": item.key,
"value": value.encryptedMessage,
"value_nonce": value.nonce,
}
})
}
get nodeInfo() {
return this._nodeInfo;
}
get addressAndPubKey() {
return cryptography.getAddressAndPublicKeyFromPassphrase(this.passPhrase);
}
get pubKey() {
return this.addressAndPubKey.publicKey.toString('hex');
}
get address() {
return cryptography.bufferToHex(this.addressAndPubKey.address)
}
get tokenKey() {
const stringToSign = this.nodeInfo.networkIdentifier + this.nodeInfo.lastBlockID;
if(!stringToSign)
return '';
const sign = cryptography.signDataWithPassphrase(Buffer.from(stringToSign, 'hex'), this.passPhrase).toString('hex')
return this.pubKey + ':' +sign
}
};
export const registrationStore = new Store();

View File

@@ -0,0 +1,53 @@
import { cryptography } from "@liskhq/lisk-client";
import { makeAutoObservable, reaction } from "mobx";
import { registrationStore } from './store';
const labelMap = {
first_name: 'First name',
second_name: 'Second name',
gender: "Gender",
birthdate: "Birthdate",
place_of_birth: "Place of birth",
nationality: "Nationality",
national_id: "National ID",
national_doctype: "National doctype",
national_doc_id: "National doc ID",
national_doc_issue_date: "National doc issue date",
national_doc_expiry_date: "National doc expiry date",
telephone: "Telephone",
twitter: "Twitter",
facebook: "Facebook",
instagram: "Instagram",
youtube: "Youtube",
wechat: "Wechat",
tiktok: "Tiktok",
linkedin: "Linkedin",
vk: "Vk",
github: "Github",
telegram: "Telegram",
qq: "Qq",
snapchat: "Snapchat",
reddit: "Reddit"
};
class UserDataStore{
_data = [];
constructor() {
makeAutoObservable(this);
reaction(() => ({data: registrationStore.userData}), ({data}) => {
this._data = data.data;
})
}
get decryptedData(){
return this._data.map((elem) => ({
...elem,
key: elem.label,
label: labelMap[elem.label],
value: cryptography.decryptMessageWithPassphrase(elem.value, elem.value_nonce, registrationStore.passPhrase, registrationStore.pubKey).split(':')[1]
}))
}
}
export const userDataStore = new UserDataStore();