From 63439b2da1fc9dde0a5f04c778a76b0640a259b1 Mon Sep 17 00:00:00 2001 From: DwCay Date: Wed, 29 Jun 2022 18:47:49 +0300 Subject: [PATCH 1/4] Add method post encrypt auth data --- src/pages/Onboarding4.jsx | 5 +++-- src/store/store.js | 22 ++++++++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/pages/Onboarding4.jsx b/src/pages/Onboarding4.jsx index 96dd347..b49256e 100644 --- a/src/pages/Onboarding4.jsx +++ b/src/pages/Onboarding4.jsx @@ -9,11 +9,12 @@ const Onboarding4 = observer(()=>{ const [checkBoxesSelected, setCheckBoxesSelected] = useState(false) - function validateCheckBox () { + function postAuthData () { let checkBoxes=[...document.getElementsByClassName("form-checkbox")] if(checkBoxes.find(item=>item.checked===false)) { return } else { + registrationStore.postAuth() setCheckBoxesSelected(true) } @@ -81,7 +82,7 @@ const Onboarding4 = observer(()=>{

{registrationStore.accountData.first_name ? `Nice to meet you, ${registrationStore.accountData.first_name} 🙌` : 'Please, go back step 2'}

- diff --git a/src/store/store.js b/src/store/store.js index 5281627..4049ea2 100644 --- a/src/store/store.js +++ b/src/store/store.js @@ -21,6 +21,14 @@ class Store { })) }; + postAuth() { + fetchWrapper.postAuth('http://3.125.47.101/api/data/account', { + networkIdentifier: this.nodeInfo.networkIdentifier, + lastBlockID: this.nodeInfo.lastBlockID + }, [...this.encryptAccountData]) + .then((result) => console.log(result)) + } + savePassPhrase(phrase) { this._passPhrase = phrase } @@ -37,7 +45,6 @@ class Store { fetchNodeInfoSuccess(info) { this._nodeInfo = info.data; - console.log(info) } fetchNodeInfoFailed(err) { @@ -52,6 +59,17 @@ class Store { return this._accountData }; + get encryptAccountData() { + return Object.keys(this.accountData).map((label) => { + let value = cryptography.encryptMessageWithPassphrase(cryptography.getRandomBytes(32).toString('hex') + ":" + this.accountData[label], this.passPhrase, this.pubKey); + return { + "label": label, + "value": value.encryptedMessage, + "value_nonce": value.nonce, + } + }) + } + get nodeInfo() { return this._nodeInfo; } @@ -69,7 +87,7 @@ class Store { } get tokenKey() { - const stringToSign = this.nodeInfo.networkIdentifier.concat(this.nodeInfo.lastBlockID); + const stringToSign = this.nodeInfo.networkIdentifier + this.nodeInfo.lastBlockID; if(!stringToSign) return ''; const sign = cryptography.signDataWithPassphrase(Buffer.from(stringToSign, 'hex'), this.passPhrase).toString('hex') From f65c99e86aeb640d643be58bc9a9dbafe95cdce7 Mon Sep 17 00:00:00 2001 From: DwCay Date: Wed, 29 Jun 2022 19:35:06 +0300 Subject: [PATCH 2/4] fix store --- src/store/store.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/store/store.js b/src/store/store.js index 4049ea2..d069077 100644 --- a/src/store/store.js +++ b/src/store/store.js @@ -26,7 +26,7 @@ class Store { networkIdentifier: this.nodeInfo.networkIdentifier, lastBlockID: this.nodeInfo.lastBlockID }, [...this.encryptAccountData]) - .then((result) => console.log(result)) + .catch(()=>{}) } savePassPhrase(phrase) { From bac246eac25cacd2411856437d17e2449fd07632 Mon Sep 17 00:00:00 2001 From: DwCay Date: Thu, 30 Jun 2022 13:17:10 +0300 Subject: [PATCH 3/4] fix label name for post request --- src/pages/Onboarding2.jsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pages/Onboarding2.jsx b/src/pages/Onboarding2.jsx index 51d1aad..1254836 100644 --- a/src/pages/Onboarding2.jsx +++ b/src/pages/Onboarding2.jsx @@ -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) @@ -107,8 +107,8 @@ const Onboarding2 = observer(()=>{ saveValueChange(event)} className="form-input w-full" type="text" />
- - saveValueChange(event)} className="form-input w-full" type="text" /> + + saveValueChange(event)} className="form-input w-full" type="text" />
@@ -119,8 +119,8 @@ const Onboarding2 = observer(()=>{
- - saveValueChange(event)} className="form-input w-full" type="date" autoComplete="on" /> + + saveValueChange(event)} className="form-input w-full" type="date" autoComplete="on" />
From e175ca02959dace124887f31e4bfb050e69a54f5 Mon Sep 17 00:00:00 2001 From: DwCay Date: Thu, 30 Jun 2022 13:35:07 +0300 Subject: [PATCH 4/4] fix naming for post method --- src/pages/Onboarding4.jsx | 6 +++--- src/store/store.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/Onboarding4.jsx b/src/pages/Onboarding4.jsx index b49256e..4d0211d 100644 --- a/src/pages/Onboarding4.jsx +++ b/src/pages/Onboarding4.jsx @@ -9,12 +9,12 @@ const Onboarding4 = observer(()=>{ const [checkBoxesSelected, setCheckBoxesSelected] = useState(false) - function postAuthData () { + function createAccount () { let checkBoxes=[...document.getElementsByClassName("form-checkbox")] if(checkBoxes.find(item=>item.checked===false)) { return } else { - registrationStore.postAuth() + registrationStore.fetchCreateNewAccount() setCheckBoxesSelected(true) } @@ -82,7 +82,7 @@ const Onboarding4 = observer(()=>{

{registrationStore.accountData.first_name ? `Nice to meet you, ${registrationStore.accountData.first_name} 🙌` : 'Please, go back step 2'}

-
diff --git a/src/store/store.js b/src/store/store.js index d069077..80ebc8b 100644 --- a/src/store/store.js +++ b/src/store/store.js @@ -21,7 +21,7 @@ class Store { })) }; - postAuth() { + fetchCreateNewAccount() { fetchWrapper.postAuth('http://3.125.47.101/api/data/account', { networkIdentifier: this.nodeInfo.networkIdentifier, lastBlockID: this.nodeInfo.lastBlockID