forked from jsnbuchanan/crowd-funder-for-time-pwa
switch the encryption secret from localStorage to IndexedDB (because localStorage gets lost so often)
This commit is contained in:
@@ -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