Skip to content

Commit 143d49b

Browse files
committed
fix: external cryptstore implementation Closes #18
1 parent 65f1e63 commit 143d49b

File tree

10 files changed

+95
-415
lines changed

10 files changed

+95
-415
lines changed

CryptStore.js

Lines changed: 0 additions & 286 deletions
This file was deleted.

components/dialogs/encrypt.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ import {
66
getStakeRows,
77
} from '../../lib/ui.js'
88
import {
9+
isStoreEncrypted,
910
getStoredKeys,
1011
initEncryptedStore,
1112
encryptKeys,
12-
store,
13-
ENCRYPT_IV,
1413
} from '../../lib/storage.js'
1514
// import {
1615
// // Secp256k1,
@@ -37,9 +36,7 @@ let encryptedStore
3736
let passphrase
3837

3938
export async function setupEncryptDialog(el, state = {}) {
40-
const isStoreEncrypted = !!(await store.getItem(`${ENCRYPT_IV}_iv`))
41-
42-
let cryptDirection = isStoreEncrypted ? 'decrypt' : 'encrypt'
39+
let cryptDirection = isStoreEncrypted() ? 'decrypt' : 'encrypt'
4340
let capCryptDir = `${capitalizeFirstLetter(cryptDirection)}`
4441
let title = `${capCryptDir} Wallet`
4542

@@ -189,7 +186,7 @@ export async function setupEncryptDialog(el, state = {}) {
189186

190187
trigger("set:pass", passphrase);
191188

192-
if (!isStoreEncrypted || decryptSuccess) {
189+
if (!isStoreEncrypted() || decryptSuccess) {
193190
await encryptKeys(storedKeys, passphrase)
194191

195192
let { storedKeys: decryptedKeys } = await getStoredKeys(passphrase)
@@ -213,7 +210,7 @@ export async function setupEncryptDialog(el, state = {}) {
213210
storedKeys,
214211
encryptedStore,
215212
decryptedStoredKeys,
216-
isStoreEncrypted,
213+
isStoreEncrypted: isStoreEncrypted(),
217214
dl: decryptedStoredKeys.length,
218215
el: storedKeys.length,
219216
})

components/forms/backup.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function setupBackupButton(el, state = {}) {
4949
}
5050

5151
if (
52-
!isStoreEncrypted || (
52+
!isStoreEncrypted() || (
5353
state.passphrase ||
5454
isDecryptedPhraseOrWif(state.phraseOrWif)
5555
)
@@ -71,7 +71,7 @@ export function setupBackupButton(el, state = {}) {
7171
// console.log(`${state.name} button handleSubmit`, event)
7272

7373
if (
74-
isStoreEncrypted && (
74+
isStoreEncrypted() && (
7575
!state.passphrase ||
7676
!isDecryptedPhraseOrWif(state.phraseOrWif)
7777
)

components/forms/wallet.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function setupWalletButton(el, state = {}) {
4949
}
5050

5151
if (
52-
!isStoreEncrypted || (
52+
!isStoreEncrypted() || (
5353
state.passphrase ||
5454
isDecryptedPhraseOrWif(state.phraseOrWif)
5555
)
@@ -78,7 +78,7 @@ export function setupWalletButton(el, state = {}) {
7878

7979
addWalletDialog.showModal()
8080
// if (
81-
// isStoreEncrypted && (
81+
// isStoreEncrypted() && (
8282
// !state.passphrase ||
8383
// !isDecryptedPhraseOrWif(state.phraseOrWif)
8484
// )

0 commit comments

Comments
 (0)