forked from trent_larson/crowd-funder-for-time-pwa
Merge branch 'master' into db-set-and-bak
This commit is contained in:
@@ -3,11 +3,19 @@ import { encrypted, Encryption } from "@pvermeer/dexie-encrypted-addon";
|
||||
import {
|
||||
Account,
|
||||
AccountsSchema,
|
||||
Contact,
|
||||
ContactsSchema,
|
||||
MASTER_SETTINGS,
|
||||
Settings,
|
||||
SettingsSchema,
|
||||
} from "./tables";
|
||||
|
||||
type AllTables = {
|
||||
accounts: Table<Account>;
|
||||
contacts: Table<Contact>;
|
||||
settings: Table<Settings>;
|
||||
};
|
||||
|
||||
/**
|
||||
* In order to make the next line be acceptable, the program needs to have its linter suppress a rule:
|
||||
* https://typescript-eslint.io/rules/no-unnecessary-type-constraint/
|
||||
@@ -16,15 +24,15 @@ import {
|
||||
*
|
||||
* https://9to5answer.com/how-to-bypass-warning-unexpected-any-specify-a-different-type-typescript-eslint-no-explicit-any
|
||||
*/
|
||||
type DexieTables = {
|
||||
accounts: Table<Account>;
|
||||
settings: Table<Settings>;
|
||||
};
|
||||
|
||||
type DexieTables = AllTables;
|
||||
export type Dexie<T extends unknown = DexieTables> = BaseDexie & T;
|
||||
export const db = new BaseDexie("KickStart") as Dexie;
|
||||
|
||||
const AllSchemas = Object.assign({}, AccountsSchema, SettingsSchema);
|
||||
const AllSchemas = Object.assign(
|
||||
{},
|
||||
AccountsSchema,
|
||||
ContactsSchema,
|
||||
SettingsSchema
|
||||
);
|
||||
|
||||
/**
|
||||
* Needed to enable a special webpack setting to allow *await* below:
|
||||
@@ -38,7 +46,8 @@ const secret =
|
||||
if (localStorage.getItem("secret") == null) {
|
||||
localStorage.setItem("secret", secret);
|
||||
}
|
||||
console.log("Secret:", secret);
|
||||
|
||||
//console.log("IndexedDB Encryption Secret:", secret);
|
||||
encrypted(db, { secretKey: secret });
|
||||
db.version(1).stores(AllSchemas);
|
||||
|
||||
|
||||
@@ -14,6 +14,18 @@ export const AccountsSchema = {
|
||||
"++id, dateCreated, derivationPath, $identity, $mnemonic, publicKeyHex",
|
||||
};
|
||||
|
||||
export interface Contact {
|
||||
did: string;
|
||||
name?: string;
|
||||
publicKeyBase64?: string;
|
||||
seesMe?: boolean;
|
||||
registered?: boolean;
|
||||
}
|
||||
|
||||
export const ContactsSchema = {
|
||||
contacts: "++did, name, publicKeyBase64, registered, seesMe",
|
||||
};
|
||||
|
||||
// a singleton
|
||||
export type Settings = {
|
||||
id: number;
|
||||
|
||||
Reference in New Issue
Block a user