forked from trent_larson/crowd-funder-for-time-pwa
Cleaned up old Dexie class. Added mnemonic and dateCreated columns.
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
import Dexie, { type Table } from "dexie";
|
||||
import { encrypted, Encryption } from "@pvermeer/dexie-encrypted-addon";
|
||||
|
||||
import { AppString } from "@/constants/app";
|
||||
import { AppTable } from "../constants/table";
|
||||
import { Field } from "@/constants/model";
|
||||
import { IDBAccount } from "@/models/Account";
|
||||
|
||||
export class DexieWrapper extends Dexie {
|
||||
[AppTable.ACCOUNTS]!: Table<IDBAccount>;
|
||||
|
||||
constructor(name: string, secret: string) {
|
||||
super(name, { autoOpen: true });
|
||||
encrypted(this, { secretKey: secret });
|
||||
this.version(1).stores({
|
||||
[AppTable.ACCOUNTS]: `#&${Field.ID}, $${Field.IDENTITY}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const secret =
|
||||
localStorage.getItem("secret") || Encryption.createRandomEncryptionKey();
|
||||
|
||||
if (localStorage.getItem("secret") == null) {
|
||||
localStorage.setItem("secret", secret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Preconfigured DexieWrapper
|
||||
*/
|
||||
export const dexieWrapper = new DexieWrapper(
|
||||
`${AppString.APP_NAME} v${AppString.VERSION}`,
|
||||
secret
|
||||
);
|
||||
Reference in New Issue
Block a user