forked from trent_larson/crowd-funder-for-time-pwa
switch the encryption secret from localStorage to IndexedDB (because localStorage gets lost so often)
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user