switch the encryption secret from localStorage to IndexedDB (because localStorage gets lost so often)

This commit is contained in:
2024-12-08 19:34:31 -07:00
parent fb0d855fac
commit bb3807a805
35 changed files with 295 additions and 255 deletions

View File

@@ -78,8 +78,9 @@ import {
newIdentifier,
nextDerivationPath,
} from "@/libs/crypto";
import { accountsDB, db } from "@/db/index";
import { accountsDBPromise, db } from "@/db/index";
import { MASTER_SETTINGS_KEY } from "@/db/tables/settings";
import { retrieveAllFullyDecryptedAccounts } from "@/libs/util";
@Component({
components: {},
@@ -90,8 +91,7 @@ export default class ImportAccountView extends Vue {
selectedArrayFirstDid = "";
async mounted() {
await accountsDB.open();
const accounts = await accountsDB.accounts.toArray();
const accounts = await retrieveAllFullyDecryptedAccounts(); // let's match derived accounts differently so we don't need the private info
const seedDids: Record<string, Array<string>> = {};
accounts.forEach((account) => {
const prevDids: Array<string> = seedDids[account.mnemonic] || [];
@@ -110,11 +110,11 @@ export default class ImportAccountView extends Vue {
}
public async incrementDerivation() {
await accountsDB.open();
// find the maximum derivation path for the selected DIDs
const selectedArray: Array<string> =
this.didArrays.find((dids) => dids[0] === this.selectedArrayFirstDid) ||
[];
const accountsDB = await accountsDBPromise; // let's match derived accounts differently so we don't need the private info
const allMatchingAccounts = await accountsDB.accounts
.where("did")
.anyOf(...selectedArray)