Skip to content

Commit 8f00045

Browse files
authored
Merge pull request #295 from Lamden/fix_change_password
HOTFIX: Fix change password
2 parents 6ae70ae + 8915219 commit 8f00045

10 files changed

+220
-21
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lamden-wallet",
3-
"version": "2.5.0",
3+
"version": "2.5.1",
44
"description": "A secure wallet for making transactions on the Lamden blockchain.",
55
"author": "Jeff Scott <[email protected]>",
66
"license": "",

src/js/backgroundControllers/accountsController.js

+33-3
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,21 @@ export const accountsController = (utils) => {
3232
const changePassword = async (oldpd, newpd) => {
3333
let { accountStore } = await getAccountsData()
3434
let { current } = await getSessionData()
35+
36+
if (oldpd != current) return false
3537
try{
3638
if (utils.validateTypes.isStringWithValue(oldpd) && utils.validateTypes.isStringWithValue(newpd)){
37-
await setCurrent(oldpd)
3839
let accounts = utils.stripRef(accountStore).map( account => {
3940
let decryptedKey;
4041
if (account.sk === "watchOnly") return account
41-
decryptedKey = decryptString(account.sk, current);
42+
decryptedKey = decryptString(account.sk, oldpd);
4243
if (decryptedKey) account.sk = decryptedKey
4344
else throw("Old password error")
4445
return account
4546
})
4647
await setCurrent(newpd)
4748
accounts.forEach(account => {
48-
if (account.sk !== 'watchOnly') account.sk = encryptString(account.sk, current)
49+
if (account.sk !== 'watchOnly') account.sk = encryptString(account.sk, newpd)
4950
})
5051
accountStore = accounts
5152
await refreshAccountStore(accountStore)
@@ -464,7 +465,36 @@ export const accountsController = (utils) => {
464465
await chrome.storage.session.set({current: string});
465466
}
466467

468+
// for version 2.5.0
469+
const repairVault = async (oldpd) => {
470+
let { accountStore } = await getAccountsData()
471+
let { current } = await getSessionData()
472+
473+
try{
474+
if (utils.validateTypes.isStringWithValue(oldpd) && utils.validateTypes.isStringWithValue(current)){
475+
let accounts = utils.stripRef(accountStore).map( account => {
476+
let decryptedKey;
477+
if (account.sk === "watchOnly") return account
478+
decryptedKey = decryptString(account.sk, oldpd);
479+
if (decryptedKey) account.sk = decryptedKey
480+
else throw("Old password error")
481+
return account
482+
})
483+
accounts.forEach(account => {
484+
if (account.sk !== 'watchOnly') account.sk = encryptString(account.sk, current)
485+
})
486+
accountStore = accounts
487+
await refreshAccountStore(accountStore)
488+
return true;
489+
}
490+
return false
491+
} catch (e){
492+
return false
493+
}
494+
}
495+
467496
return {
497+
repairVault,
468498
changePassword,
469499
createPassword,
470500
checkPassword,

src/js/backgroundControllers/masterController.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,8 @@ export const masterController = () => {
534534
isVaultCreated: accounts.isVaultCreated,
535535
getMnemonic: accounts.getMnemonic,
536536
addVaultAccount: accounts.addVaultAccount,
537-
auth: accounts.auth
537+
auth: accounts.auth,
538+
repairVault: accounts.repairVault
538539
},
539540
dapps: {
540541
initiateTrustedApp: dapps.initiateTrustedApp,

src/js/backgroundControllers/messagesHandler.js

+6
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ export const messagesHandler = () => {
100100
sendResponse(await masterController.changePassword(message.data))
101101
return true;
102102
}
103+
104+
// Reapir vault
105+
if (message.type === 'repairVault') {
106+
sendResponse(await masterController.accounts.repairVault(message.data))
107+
return true;
108+
}
103109
//Check if the wallet has been setup yet
104110
if(message.type === 'isFirstRun') {
105111
sendResponse(await masterController.accounts.firstRun())

src/js/latest_event.json

+8-15
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
11
{
2-
"title": "Manifest V3 Update",
3-
"type": "feature",
4-
"version": "2.5.0",
2+
"title": "Change Password Hotfix",
3+
"type": "hotfix",
4+
"version": "2.5.1",
55
"body": [
6-
"Updated the Lamden Wallet to use the new Manifest V3 standard.",
7-
"Also enabled the auth endpoint in the Lamden Vault API."
6+
"Hotfix for the change password bug."
87
],
98
"buttons": [
109
{
1110
"class": "primary",
12-
"link": "https://github.com/Lamden/wallet/releases/tag/v2.5.0",
11+
"link": "https://github.com/Lamden/wallet/releases/tag/v2.5.1",
1312
"name": "Release Info"
14-
},
15-
{
16-
"class": "secondary",
17-
"link": "https://docs.lamden.io/develop/wallet_api/auth/",
18-
"name": "Auth Documentation"
1913
}
2014
],
21-
"date_added": 1684243931195,
22-
"new_features": [
23-
"Added a new event called 'auth' to the Lamden Vault API. This allows dapps to call the wallet for user login. See documentation for more info.",
24-
"Updated the Lamden Wallet to use the new Manifest V3 standard."
15+
"date_added": 1686843863024,
16+
"fixes": [
17+
"The change password feature would change the loging password but fail to re-encrypt the keys in the legacy vault storage."
2518
]
2619
}

src/svelte/App.svelte

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"ContinueSwap",
6868
"ChangePassword",
6969
"ManageNetwork",
70+
"RepairVault"
7071
];
7172
const redirect = {
7273
FirstRunRestoreMain: "FirstRunMain",

src/svelte/Router.svelte

+2
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ import IdeMethodTx from './IDE/IdeMethodTx.svelte';
140140
//Misc
141141
import LockScreen from './misc/LockScreen.svelte';
142142
import About from './misc/About.svelte';
143+
import RepairVault from './misc/RepairVault.svelte';
143144
144145
//Token
145146
import TokenDetails from './tokens/TokenDetails.svelte';
@@ -252,6 +253,7 @@ export const Pages = {
252253
DashboardMain,
253254
DashboardNodeList,
254255
NodeDetails,
256+
RepairVault,
255257
...FirstRun
256258
};
257259

src/svelte/firstrun/FirstRunCreatePW.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
//PROPS
2424
export let restore = false;
2525
26-
let pattern = `(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*()_+\\-=\\[\\]{};':\"\\\|,.<>\\/? ]).{10,}`;
26+
let pattern = "(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*\\(\\)_+\\-=\\[\\]\\{\\};':\"\\|,.<>\\/\\?]).{10,}";
2727
let pwd = '';
2828
2929
const formValidation = () => {

src/svelte/misc/RepairVault.svelte

+159
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
<script>
2+
import { getContext, onDestroy, onMount} from 'svelte';
3+
//Components
4+
import { Components, LeftSideFullPage } from '../Router.svelte'
5+
import NavLogo from '../nav/NavLogo.svelte';
6+
import { fade } from 'svelte/transition';
7+
8+
//Stores
9+
import { SettingsStore } from '../../js/stores/stores.js';
10+
11+
//Utils
12+
import { hashStringValue } from '../../js/utils.js'
13+
14+
//Context
15+
const { switchPage, appHome} = getContext('app_functions');
16+
17+
const { Button, InputBox } = Components;
18+
19+
let oldPwd;
20+
21+
let password;
22+
let vaultExist = false;
23+
let step = 1;
24+
let repairSuccess = false;
25+
26+
onMount(() => {
27+
chrome.runtime.sendMessage({type: 'isVaultCreated'}, (ok) => {
28+
vaultExist = ok;
29+
})
30+
});
31+
32+
33+
onDestroy(()=> password = "")
34+
35+
const repair = () => {
36+
chrome.runtime.sendMessage({
37+
type: "repairVault",
38+
data: hashStringValue(oldPwd.value),
39+
}, (success) => {
40+
if (!success || chrome.runtime.lastError) {
41+
repairSuccess = false
42+
} else {
43+
repairSuccess = true
44+
}
45+
step = 2
46+
});
47+
}
48+
49+
</script>
50+
51+
<style>
52+
.layout{
53+
display: flex;
54+
flex-direction: column;
55+
flex-grow: 1;
56+
}
57+
58+
.content{
59+
flex-grow: 1;
60+
display: flex;
61+
}
62+
63+
.header{
64+
display: flex;
65+
flex-direction: row;
66+
position: absolute;
67+
left: 0%;
68+
right: 0%;
69+
top: 0%;
70+
bottom: 0%;
71+
right: 0;
72+
height: 97px;
73+
border-bottom: 1px solid var(--divider-light);
74+
}
75+
.alignc {
76+
align-items: center;
77+
}
78+
</style>
79+
80+
<div class="layout">
81+
<div class="header">
82+
<NavLogo />
83+
</div>
84+
<div class="content">
85+
<LeftSideFullPage title={`Repair Vault`}>
86+
<div slot="body">
87+
<div class="text-body1 weight-400 desc">
88+
This process will allow you to repair your vault if you have changed your password in version 2.5.0
89+
</div>
90+
</div>
91+
<div class="flex-row flow-page flex-just-center" in:fade="{{delay: 0, duration: 200}}" slot="content">
92+
<div class="flex-column">
93+
{#if step === 1}
94+
<h6 class="text-primary text-center">Repair Vault</h6>
95+
<div class="flex-column flow-buttons">
96+
{#if vaultExist}
97+
<InputBox
98+
id="oldPwd"
99+
bind:thisInput={oldPwd}
100+
label={"Old Password"}
101+
placeholder={"The password you previously used"}
102+
inputType={'password'}
103+
width={"347px"}
104+
height={"56px"}
105+
margin="0 0 0.5rem 0"
106+
disabledPWShowBtn={false}
107+
required={true}/>
108+
<Button id={'confirm-btn'}
109+
classes={'button__solid button__primary'}
110+
margin="1rem 0 1rem"
111+
name="Repair"
112+
width={'347px'}
113+
click={repair} />
114+
{:else}
115+
<div class="flow-text-box text-body1">Valut not exists</div>
116+
<Button id={'back-btn'}
117+
classes={'button__solid button__primary'}
118+
margin="1rem 0 1rem"
119+
name="Home"
120+
width={'347px'}
121+
click={appHome} />
122+
{/if}
123+
</div>
124+
{:else}
125+
<div class="flex-column flow-buttons alignc">
126+
{#if repairSuccess}
127+
128+
<h3 class="flow-text-box text-body1 text-green"> Your vault has been successfully repaired!</h3>
129+
<Button id={'home-btn'}
130+
classes={'button__solid button__primary'}
131+
margin="1rem 0 1rem"
132+
name="Home"
133+
width={'347px'}
134+
click={appHome} />
135+
{:else}
136+
<h3 class="flow-text-box text-body1 text-error"> Repair vault failed. Please try again or contact the developer</h3>
137+
<Button id={'back-btn'}
138+
classes={'button__solid button__primary'}
139+
margin="1rem 0 1rem"
140+
name="Back"
141+
width={'347px'}
142+
click={() => { step = 1}} />
143+
<Button id={'home-btn'}
144+
classes={'button__solid button__primary'}
145+
margin="1rem 0 1rem"
146+
name="Home"
147+
width={'347px'}
148+
click={appHome} />
149+
{/if}
150+
</div>
151+
{/if}
152+
</div>
153+
154+
</div>
155+
156+
</LeftSideFullPage>
157+
</div>
158+
</div>
159+

src/svelte/misc/Settings.svelte

+7
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@
5959
desc: "Keep your wallet safe by locking it after you’re done using it.",
6060
btnName: "Sign Out & Lock",
6161
page: "LockScreen"
62+
},{
63+
id: "fix-vaulte-btn",
64+
logo: "signout",
65+
title: "Fix Vault",
66+
desc: "If you have changed your password in version 2.5, you can use this feature to repair your vault.",
67+
btnName: "Fix Vault",
68+
page: "RepairVault"
6269
}]
6370
6471
const settingIcons = {

0 commit comments

Comments
 (0)