diff --git a/content/_code-samples/build-a-wallet/desktop-js/5-password/index.js b/content/_code-samples/build-a-wallet/desktop-js/5-password/index.js index 6cb2d56a94..bc11ee477c 100644 --- a/content/_code-samples/build-a-wallet/desktop-js/5-password/index.js +++ b/content/_code-samples/build-a-wallet/desktop-js/5-password/index.js @@ -42,7 +42,12 @@ const main = async () => { if (!fs.existsSync(path.join(__dirname, WALLET_DIR , 'seed.txt'))) { saveSaltedSeed(WALLET_DIR, seed, password) } else { - seed = loadSaltedSeed(WALLET_DIR, password) + try { + seed = loadSaltedSeed(WALLET_DIR, password) + } catch (error) { + appWindow.webContents.send('open-password-dialog', true) + return + } } const wallet = xrpl.Wallet.fromSeed(seed) diff --git a/content/_code-samples/build-a-wallet/desktop-js/5-password/view/renderer.js b/content/_code-samples/build-a-wallet/desktop-js/5-password/view/renderer.js index aae8e1c868..ea9dd7b682 100644 --- a/content/_code-samples/build-a-wallet/desktop-js/5-password/view/renderer.js +++ b/content/_code-samples/build-a-wallet/desktop-js/5-password/view/renderer.js @@ -17,6 +17,7 @@ window.electronAPI.onOpenSeedDialog((_event) => { const passwordDialog = document.getElementById('password-dialog') const passwordInput = passwordDialog.querySelector('input') +const passwordError = passwordDialog.querySelector('span.invalid-password') const passwordSubmitButton = passwordDialog.querySelector('button[type="submit"]') const changeSeedButton = passwordDialog.querySelector('button[type="button"]') @@ -31,7 +32,10 @@ const handleChangeSeedFn = () => { window.electronAPI.requestSeedChange() } -window.electronAPI.onOpenPasswordDialog((_event) => { +window.electronAPI.onOpenPasswordDialog((_event, showInvalidPassword = false) => { + if (showInvalidPassword) { + passwordError.innerHTML = 'INVALID PASSWORD' + } passwordSubmitButton.addEventListener('click', handlePasswordSubmitFn, {once : true}); changeSeedButton.addEventListener('click', handleChangeSeedFn, {once : true}); passwordDialog.showModal() diff --git a/content/_code-samples/build-a-wallet/desktop-js/5-password/view/template.html b/content/_code-samples/build-a-wallet/desktop-js/5-password/view/template.html index 609bd0c721..2948859a89 100644 --- a/content/_code-samples/build-a-wallet/desktop-js/5-password/view/template.html +++ b/content/_code-samples/build-a-wallet/desktop-js/5-password/view/template.html @@ -58,7 +58,8 @@

- +
+
diff --git a/content/_code-samples/build-a-wallet/desktop-js/6-styling/index.js b/content/_code-samples/build-a-wallet/desktop-js/6-styling/index.js index edafe8859d..95c640dc4a 100644 --- a/content/_code-samples/build-a-wallet/desktop-js/6-styling/index.js +++ b/content/_code-samples/build-a-wallet/desktop-js/6-styling/index.js @@ -42,7 +42,12 @@ const main = async () => { if (!fs.existsSync(path.join(__dirname, WALLET_DIR , 'seed.txt'))) { saveSaltedSeed(WALLET_DIR, seed, password) } else { - seed = loadSaltedSeed(WALLET_DIR, password) + try { + seed = loadSaltedSeed(WALLET_DIR, password) + } catch (error) { + appWindow.webContents.send('open-password-dialog', true) + return + } } const wallet = xrpl.Wallet.fromSeed(seed) diff --git a/content/_code-samples/build-a-wallet/desktop-js/6-styling/view/renderer.js b/content/_code-samples/build-a-wallet/desktop-js/6-styling/view/renderer.js index bf883ea177..786d78ba64 100644 --- a/content/_code-samples/build-a-wallet/desktop-js/6-styling/view/renderer.js +++ b/content/_code-samples/build-a-wallet/desktop-js/6-styling/view/renderer.js @@ -16,6 +16,7 @@ window.electronAPI.onOpenSeedDialog((_event) => { const passwordDialog = document.getElementById('password-dialog') const passwordInput = passwordDialog.querySelector('input') +const passwordError = passwordDialog.querySelector('span.invalid-password') const passwordSubmitButton = passwordDialog.querySelector('button[type="submit"]') const changeSeedButton = passwordDialog.querySelector('button[type="button"]') @@ -30,7 +31,10 @@ const handleChangeSeedFn = () => { window.electronAPI.requestSeedChange() } -window.electronAPI.onOpenPasswordDialog((_event) => { +window.electronAPI.onOpenPasswordDialog((_event, showInvalidPassword = false) => { + if (showInvalidPassword) { + passwordError.innerHTML = 'INVALID PASSWORD' + } passwordSubmitButton.addEventListener('click', handlePasswordSubmitFn, {once : true}); changeSeedButton.addEventListener('click', handleChangeSeedFn, {once : true}); passwordDialog.showModal() diff --git a/content/_code-samples/build-a-wallet/desktop-js/6-styling/view/template.html b/content/_code-samples/build-a-wallet/desktop-js/6-styling/view/template.html index d69b5637b6..64894ca891 100644 --- a/content/_code-samples/build-a-wallet/desktop-js/6-styling/view/template.html +++ b/content/_code-samples/build-a-wallet/desktop-js/6-styling/view/template.html @@ -102,7 +102,8 @@

- +
+
diff --git a/content/_code-samples/build-a-wallet/desktop-js/7-send-xrp/index.js b/content/_code-samples/build-a-wallet/desktop-js/7-send-xrp/index.js index 51ac9e82b3..687030d5df 100644 --- a/content/_code-samples/build-a-wallet/desktop-js/7-send-xrp/index.js +++ b/content/_code-samples/build-a-wallet/desktop-js/7-send-xrp/index.js @@ -43,7 +43,12 @@ const main = async () => { if (!fs.existsSync(path.join(__dirname, WALLET_DIR , 'seed.txt'))) { saveSaltedSeed(WALLET_DIR, seed, password) } else { - seed = loadSaltedSeed(WALLET_DIR, password) + try { + seed = loadSaltedSeed(WALLET_DIR, password) + } catch (error) { + appWindow.webContents.send('open-password-dialog', true) + return + } } const wallet = xrpl.Wallet.fromSeed(seed) diff --git a/content/_code-samples/build-a-wallet/desktop-js/7-send-xrp/view/renderer.js b/content/_code-samples/build-a-wallet/desktop-js/7-send-xrp/view/renderer.js index 80ca297cd1..1ec60473a7 100644 --- a/content/_code-samples/build-a-wallet/desktop-js/7-send-xrp/view/renderer.js +++ b/content/_code-samples/build-a-wallet/desktop-js/7-send-xrp/view/renderer.js @@ -16,6 +16,7 @@ window.electronAPI.onOpenSeedDialog((_event) => { const passwordDialog = document.getElementById('password-dialog') const passwordInput = passwordDialog.querySelector('input') +const passwordError = passwordDialog.querySelector('span.invalid-password') const passwordSubmitButton = passwordDialog.querySelector('button[type="submit"]') const changeSeedButton = passwordDialog.querySelector('button[type="button"]') @@ -30,7 +31,10 @@ const handleChangeSeedFn = () => { window.electronAPI.requestSeedChange() } -window.electronAPI.onOpenPasswordDialog((_event) => { +window.electronAPI.onOpenPasswordDialog((_event, showInvalidPassword = false) => { + if (showInvalidPassword) { + passwordError.innerHTML = 'INVALID PASSWORD' + } passwordSubmitButton.addEventListener('click', handlePasswordSubmitFn, {once : true}); changeSeedButton.addEventListener('click', handleChangeSeedFn, {once : true}); passwordDialog.showModal() diff --git a/content/_code-samples/build-a-wallet/desktop-js/7-send-xrp/view/template.html b/content/_code-samples/build-a-wallet/desktop-js/7-send-xrp/view/template.html index 29f7328878..b4af6637aa 100644 --- a/content/_code-samples/build-a-wallet/desktop-js/7-send-xrp/view/template.html +++ b/content/_code-samples/build-a-wallet/desktop-js/7-send-xrp/view/template.html @@ -138,7 +138,8 @@

- +
+
diff --git a/content/_code-samples/build-a-wallet/desktop-js/8-domain-verification/index.js b/content/_code-samples/build-a-wallet/desktop-js/8-domain-verification/index.js index 3f22598770..3aa11ce65e 100644 --- a/content/_code-samples/build-a-wallet/desktop-js/8-domain-verification/index.js +++ b/content/_code-samples/build-a-wallet/desktop-js/8-domain-verification/index.js @@ -44,7 +44,12 @@ const main = async () => { if (!fs.existsSync(path.join(__dirname, WALLET_DIR , 'seed.txt'))) { saveSaltedSeed(WALLET_DIR, seed, password) } else { - seed = loadSaltedSeed(WALLET_DIR, password) + try { + seed = loadSaltedSeed(WALLET_DIR, password) + } catch (error) { + appWindow.webContents.send('open-password-dialog', true) + return + } } const wallet = xrpl.Wallet.fromSeed(seed) diff --git a/content/_code-samples/build-a-wallet/desktop-js/8-domain-verification/view/renderer.js b/content/_code-samples/build-a-wallet/desktop-js/8-domain-verification/view/renderer.js index cf59d6ba92..c3e3667994 100644 --- a/content/_code-samples/build-a-wallet/desktop-js/8-domain-verification/view/renderer.js +++ b/content/_code-samples/build-a-wallet/desktop-js/8-domain-verification/view/renderer.js @@ -16,6 +16,7 @@ window.electronAPI.onOpenSeedDialog((_event) => { const passwordDialog = document.getElementById('password-dialog') const passwordInput = passwordDialog.querySelector('input') +const passwordError = passwordDialog.querySelector('span.invalid-password') const passwordSubmitButton = passwordDialog.querySelector('button[type="submit"]') const changeSeedButton = passwordDialog.querySelector('button[type="button"]') @@ -30,7 +31,10 @@ const handleChangeSeedFn = () => { window.electronAPI.requestSeedChange() } -window.electronAPI.onOpenPasswordDialog((_event) => { +window.electronAPI.onOpenPasswordDialog((_event, showInvalidPassword = false) => { + if (showInvalidPassword) { + passwordError.innerHTML = 'INVALID PASSWORD' + } passwordSubmitButton.addEventListener('click', handlePasswordSubmitFn, {once : true}); changeSeedButton.addEventListener('click', handleChangeSeedFn, {once : true}); passwordDialog.showModal() diff --git a/content/_code-samples/build-a-wallet/desktop-js/8-domain-verification/view/template.html b/content/_code-samples/build-a-wallet/desktop-js/8-domain-verification/view/template.html index 0fc7b050af..0e33077ae7 100644 --- a/content/_code-samples/build-a-wallet/desktop-js/8-domain-verification/view/template.html +++ b/content/_code-samples/build-a-wallet/desktop-js/8-domain-verification/view/template.html @@ -141,7 +141,8 @@

- +
+
diff --git a/content/_code-samples/build-a-wallet/desktop-js/bootstrap/custom.css b/content/_code-samples/build-a-wallet/desktop-js/bootstrap/custom.css index 00c34c6c22..975be118c5 100644 --- a/content/_code-samples/build-a-wallet/desktop-js/bootstrap/custom.css +++ b/content/_code-samples/build-a-wallet/desktop-js/bootstrap/custom.css @@ -64,6 +64,10 @@ main { height: 20px; } +.invalid-password { + color: #dc3545; +} + .accountVerificationIndicator{ width: 100%; } diff --git a/content/tutorials/build-apps/build-a-desktop-wallet-in-javascript.md b/content/tutorials/build-apps/build-a-desktop-wallet-in-javascript.md index 8d8fa08a3e..5b58299b2e 100644 --- a/content/tutorials/build-apps/build-a-desktop-wallet-in-javascript.md +++ b/content/tutorials/build-apps/build-a-desktop-wallet-in-javascript.md @@ -859,7 +859,12 @@ const main = async () => { if (!fs.existsSync(path.join(__dirname, WALLET_DIR , 'seed.txt'))) { saveSaltedSeed('../' + WALLET_DIR, seed, password) } else { - seed = loadSaltedSeed('../' + WALLET_DIR, password) + try { + seed = loadSaltedSeed(WALLET_DIR, password) + } catch (error) { + appWindow.webContents.send('open-password-dialog', true) + return + } } const wallet = xrpl.Wallet.fromSeed(seed) @@ -942,7 +947,8 @@ contextBridge.exposeInMainWorld('electronAPI', {
- +
+
@@ -994,6 +1000,7 @@ window.electronAPI.onOpenSeedDialog((_event) => { const passwordDialog = document.getElementById('password-dialog') const passwordInput = passwordDialog.querySelector('input') +const passwordError = passwordDialog.querySelector('span.invalid-password') const passwordSubmitButton = passwordDialog.querySelector('button[type="submit"]') const changeSeedButton = passwordDialog.querySelector('button[type="button"]') @@ -1008,7 +1015,10 @@ const handleChangeSeedFn = () => { window.electronAPI.requestSeedChange() } -window.electronAPI.onOpenPasswordDialog((_event) => { +window.electronAPI.onOpenPasswordDialog((_event, showInvalidPassword = false) => { + if (showInvalidPassword) { + passwordError.innerHTML = 'INVALID PASSWORD' + } passwordSubmitButton.addEventListener('click', handlePasswordSubmitFn, {once : true}); changeSeedButton.addEventListener('click', handleChangeSeedFn, {once : true}); passwordDialog.showModal()