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

@@ -92,8 +92,9 @@ import { Vue, Component, Prop } from "vue-facing-decorator";
import { NotificationIface } from "@/constants/app";
import { createAndSubmitGive, didInfo } from "@/libs/endorserServer";
import * as libsUtil from "@/libs/util";
import { accountsDB, db, retrieveSettingsForActiveAccount } from "@/db/index";
import { db, retrieveSettingsForActiveAccount } from "@/db/index";
import { Contact } from "@/db/tables/contacts";
import { retrieveAccountDids } from "@/libs/util";
@Component
export default class GiftedDialog extends Vue {
@@ -145,9 +146,7 @@ export default class GiftedDialog extends Vue {
this.allContacts = await db.contacts.toArray();
await accountsDB.open();
const allAccounts = await accountsDB.accounts.toArray();
this.allMyDids = allAccounts.map((acc) => acc.did);
this.allMyDids = await retrieveAccountDids();
if (this.giver && !this.giver.name) {
this.giver.name = didInfo(

View File

@@ -101,7 +101,12 @@
import { Component, Vue } from "vue-facing-decorator";
import { DEFAULT_PUSH_SERVER, NotificationIface } from "@/constants/app";
import { logConsoleAndDb, retrieveSettingsForActiveAccount } from "@/db/index";
import {
logConsoleAndDb,
retrieveSettingsForActiveAccount,
secretDB,
} from "@/db/index";
import { MASTER_SECRET_KEY } from "@/db/tables/secret";
import { urlBase64ToUint8Array } from "@/libs/crypto/vc/util";
import * as libsUtil from "@/libs/util";
@@ -270,7 +275,7 @@ export default class PushNotificationPermission extends Vue {
});
}
private askPermission(): Promise<NotificationPermission> {
private async askPermission(): Promise<NotificationPermission> {
logConsoleAndDb(
"Requesting permission for notifications: " + JSON.stringify(navigator),
);
@@ -280,7 +285,8 @@ export default class PushNotificationPermission extends Vue {
return Promise.reject("Service worker not available.");
}
const secret = localStorage.getItem("secret");
await secretDB.open();
const secret = (await secretDB.secret.get(MASTER_SECRET_KEY))?.secret;
if (!secret) {
return Promise.reject("No secret found.");
}