Skip to content

Commit

Permalink
fix: external cryptstore implementation Closes #18
Browse files Browse the repository at this point in the history
  • Loading branch information
jojobyte committed Jun 21, 2023
1 parent 65f1e63 commit 143d49b
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 415 deletions.
286 changes: 0 additions & 286 deletions CryptStore.js

This file was deleted.

11 changes: 4 additions & 7 deletions components/dialogs/encrypt.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import {
getStakeRows,
} from '../../lib/ui.js'
import {
isStoreEncrypted,
getStoredKeys,
initEncryptedStore,
encryptKeys,
store,
ENCRYPT_IV,
} from '../../lib/storage.js'
// import {
// // Secp256k1,
Expand All @@ -37,9 +36,7 @@ let encryptedStore
let passphrase

export async function setupEncryptDialog(el, state = {}) {
const isStoreEncrypted = !!(await store.getItem(`${ENCRYPT_IV}_iv`))

let cryptDirection = isStoreEncrypted ? 'decrypt' : 'encrypt'
let cryptDirection = isStoreEncrypted() ? 'decrypt' : 'encrypt'
let capCryptDir = `${capitalizeFirstLetter(cryptDirection)}`
let title = `${capCryptDir} Wallet`

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

trigger("set:pass", passphrase);

if (!isStoreEncrypted || decryptSuccess) {
if (!isStoreEncrypted() || decryptSuccess) {
await encryptKeys(storedKeys, passphrase)

let { storedKeys: decryptedKeys } = await getStoredKeys(passphrase)
Expand All @@ -213,7 +210,7 @@ export async function setupEncryptDialog(el, state = {}) {
storedKeys,
encryptedStore,
decryptedStoredKeys,
isStoreEncrypted,
isStoreEncrypted: isStoreEncrypted(),
dl: decryptedStoredKeys.length,
el: storedKeys.length,
})
Expand Down
4 changes: 2 additions & 2 deletions components/forms/backup.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function setupBackupButton(el, state = {}) {
}

if (
!isStoreEncrypted || (
!isStoreEncrypted() || (
state.passphrase ||
isDecryptedPhraseOrWif(state.phraseOrWif)
)
Expand All @@ -71,7 +71,7 @@ export function setupBackupButton(el, state = {}) {
// console.log(`${state.name} button handleSubmit`, event)

if (
isStoreEncrypted && (
isStoreEncrypted() && (
!state.passphrase ||
!isDecryptedPhraseOrWif(state.phraseOrWif)
)
Expand Down
4 changes: 2 additions & 2 deletions components/forms/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function setupWalletButton(el, state = {}) {
}

if (
!isStoreEncrypted || (
!isStoreEncrypted() || (
state.passphrase ||
isDecryptedPhraseOrWif(state.phraseOrWif)
)
Expand Down Expand Up @@ -78,7 +78,7 @@ export function setupWalletButton(el, state = {}) {

addWalletDialog.showModal()
// if (
// isStoreEncrypted && (
// isStoreEncrypted() && (
// !state.passphrase ||
// !isDecryptedPhraseOrWif(state.phraseOrWif)
// )
Expand Down
Loading

0 comments on commit 143d49b

Please sign in to comment.