diff --git a/README.md b/README.md index 9b43e43..72965aa 100644 --- a/README.md +++ b/README.md @@ -44,13 +44,14 @@ New users require registration. This can be done with a claim payload like this On the test server, User #0 has rights to register others, so you can start playing one of two ways: -- Import the keys for that test User `did:ethr:0x000Ee5654b9742f6Fe18ea970e32b97ee2247B51` by importing this seed phrase: `seminar accuse mystery assist delay law thing deal image undo guard initial shallow wrestle list fragile borrow velvet tomorrow awake explain test offer control` +- Import the keys for the test User `did:ethr:0x000Ee5654b9742f6Fe18ea970e32b97ee2247B51` by importing this seed phrase: + `seminar accuse mystery assist delay law thing deal image undo guard initial shallow wrestle list fragile borrow velvet tomorrow awake explain test offer control` -- Register someone else under User #0 on the `/account` page: +- Alternatively, register someone else under User #0 on the `/account` page: - * Edit the `src/views/AccountViewView.vue` file and uncomment the lines referring to "test". + * In the `src/views/AccountViewView.vue` file, uncomment the lines referring to "testServerRegisterUser". - * Use the [Vue Devtools browser extension](https://devtools.vuejs.org/) and type this into the console: `$vm.ctx.testRegisterUser()` + * Visit the `/account` page. diff --git a/package-lock.json b/package-lock.json index 06b8ae2..3814b71 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,6 +26,7 @@ "class-transformer": "^0.5.1", "core-js": "^3.26.1", "dexie": "^3.2.2", + "dexie-export-import": "^4.0.6", "did-jwt": "^6.9.0", "ethereum-cryptography": "^1.1.2", "ethereumjs-util": "^7.1.5", @@ -12187,6 +12188,14 @@ "node": ">=6.0" } }, + "node_modules/dexie-export-import": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/dexie-export-import/-/dexie-export-import-4.0.6.tgz", + "integrity": "sha512-WFTSm/XB4MNHBZVQJTrWjWvqur7vfpx1mWEWMuTUB9zdW3FTXvkpm7SvsUX55r6y6wmJ3libwA5eRCbVUKmuTw==", + "peerDependencies": { + "dexie": "^2.0.4 || ^3.0.0 || ^4.0.1-alpha.5" + } + }, "node_modules/did-jwt": { "version": "6.9.0", "resolved": "https://registry.npmjs.org/did-jwt/-/did-jwt-6.9.0.tgz", diff --git a/package.json b/package.json index e880fd5..9a7a3cb 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "class-transformer": "^0.5.1", "core-js": "^3.26.1", "dexie": "^3.2.2", + "dexie-export-import": "^4.0.6", "did-jwt": "^6.9.0", "ethereum-cryptography": "^1.1.2", "ethereumjs-util": "^7.1.5", diff --git a/project.yaml b/project.yaml index 8e2141f..a94ad5a 100644 --- a/project.yaml +++ b/project.yaml @@ -11,11 +11,24 @@ - replace user-affecting console.logs with error messages (eg. catches) -- contacts v1: +- contacts v1 : + - .2 show gives with new setting + - 01 show gives with confirmations + - .5 Add page to show seed. + - 01 Provide a way to import the non-sensitive data. + - 01 Provide way to share your contact info. + - .1 remove "scan new contact" + +- contacts v+ : - .5 make advanced "show/hide amounts" button into a nice UI toggle - .2 show error to user when adding a duplicate contact - parse input more robustly (with CSV lib and not commas) +- refactor UI : + - .5 Alerts show at the top and can be missed, eg. account data download + - 01 Code for "nav" tabs across the bottom is duplicated on each page. + - .2 Add "copied" feedback when they click "copy" on /account + - commit screen - discover screen diff --git a/src/db/index.ts b/src/db/index.ts index dc7e911..6806b60 100644 --- a/src/db/index.ts +++ b/src/db/index.ts @@ -1,17 +1,19 @@ import BaseDexie, { Table } from "dexie"; import { encrypted, Encryption } from "@pvermeer/dexie-encrypted-addon"; +import { Account, AccountsSchema } from "./tables/accounts"; +import { Contact, ContactsSchema } from "./tables/contacts"; import { - Account, - AccountsSchema, - Contact, - ContactsSchema, - MASTER_SETTINGS, + MASTER_SETTINGS_KEY, Settings, SettingsSchema, -} from "./tables"; +} from "./tables/settings"; -type AllTables = { +// a separate DB because the seed is super-sensitive data +type SensitiveTables = { accounts: Table; +}; + +type NonsensitiveTables = { contacts: Table; settings: Table; }; @@ -24,15 +26,14 @@ type AllTables = { * * https://9to5answer.com/how-to-bypass-warning-unexpected-any-specify-a-different-type-typescript-eslint-no-explicit-any */ -type DexieTables = AllTables; -export type Dexie = BaseDexie & T; -export const db = new BaseDexie("KickStart") as Dexie; -const AllSchemas = Object.assign( - {}, - AccountsSchema, - ContactsSchema, - SettingsSchema -); +export type SensitiveDexie = BaseDexie & T; +export const accountsDB = new BaseDexie("KickStartAccounts") as SensitiveDexie; +const SensitiveSchemas = Object.assign({}, AccountsSchema); + +export type NonsensitiveDexie = + BaseDexie & T; +export const db = new BaseDexie("KickStart") as NonsensitiveDexie; +const NonsensitiveSchemas = Object.assign({}, ContactsSchema, SettingsSchema); /** * Needed to enable a special webpack setting to allow *await* below: @@ -48,11 +49,13 @@ if (localStorage.getItem("secret") == null) { } //console.log("IndexedDB Encryption Secret:", secret); -encrypted(db, { secretKey: secret }); -db.version(1).stores(AllSchemas); +encrypted(accountsDB, { secretKey: secret }); +accountsDB.version(1).stores(SensitiveSchemas); + +db.version(1).stores(NonsensitiveSchemas); // initialize, a la https://dexie.org/docs/Tutorial/Design#the-populate-event db.on("populate", function () { // ensure there's an initial entry for settings - db.settings.add({ id: MASTER_SETTINGS }); + db.settings.add({ id: MASTER_SETTINGS_KEY }); }); diff --git a/src/db/tables/index.ts b/src/db/tables/accounts.ts similarity index 50% rename from src/db/tables/index.ts rename to src/db/tables/accounts.ts index 6b7b62f..9602439 100644 --- a/src/db/tables/index.ts +++ b/src/db/tables/accounts.ts @@ -13,29 +13,3 @@ export const AccountsSchema = { accounts: "++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; - firstName?: string; - lastName?: string; - showContactGivesInline?: boolean; -}; - -export const SettingsSchema = { - settings: "id", -}; - -export const MASTER_SETTINGS = 1; diff --git a/src/db/tables/contacts.ts b/src/db/tables/contacts.ts new file mode 100644 index 0000000..00923f5 --- /dev/null +++ b/src/db/tables/contacts.ts @@ -0,0 +1,11 @@ +export interface Contact { + did: string; + name?: string; + publicKeyBase64?: string; + seesMe?: boolean; + registered?: boolean; +} + +export const ContactsSchema = { + contacts: "++did, name, publicKeyBase64, registered, seesMe", +}; diff --git a/src/db/tables/settings.ts b/src/db/tables/settings.ts new file mode 100644 index 0000000..1da602a --- /dev/null +++ b/src/db/tables/settings.ts @@ -0,0 +1,13 @@ +// a singleton +export type Settings = { + id: number; + firstName?: string; + lastName?: string; + showContactGivesInline?: boolean; +}; + +export const SettingsSchema = { + settings: "id", +}; + +export const MASTER_SETTINGS_KEY = 1; diff --git a/src/router/index.ts b/src/router/index.ts index 376cfd7..bc4b683 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -1,5 +1,5 @@ import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router"; -import { db } from "@/db"; +import { accountsDB } from "@/db"; const routes: Array = [ { @@ -8,8 +8,8 @@ const routes: Array = [ component: () => import(/* webpackChunkName: "start" */ "../views/DiscoverView.vue"), beforeEnter: async (to, from, next) => { - await db.open(); - const num_accounts = await db.accounts.count(); + await accountsDB.open(); + const num_accounts = await accountsDB.accounts.count(); if (num_accounts > 0) { next(); } else { @@ -63,6 +63,12 @@ const routes: Array = [ component: () => import(/* webpackChunkName: "discover" */ "../views/DiscoverView.vue"), }, + { + path: "/help", + name: "help", + component: () => + import(/* webpackChunkName: "help" */ "../views/HelpView.vue"), + }, { path: "/import-account", name: "import-account", diff --git a/src/test/index.ts b/src/test/index.ts index 4f10fb7..fe593da 100644 --- a/src/test/index.ts +++ b/src/test/index.ts @@ -1,7 +1,7 @@ import axios from "axios"; import * as didJwt from "did-jwt"; import { AppString } from "@/constants/app"; -import { db } from "../db"; +import { accountsDB } from "../db"; import { SERVICE_ID } from "../libs/veramo/setup"; import { deriveAddress, newIdentifier } from "../libs/crypto"; @@ -13,8 +13,8 @@ export async function testServerRegisterUser() { const identity0 = newIdentifier(addr, publicHex, privateHex, deriPath); - await db.open(); - const accounts = await db.accounts.toArray(); + await accountsDB.open(); + const accounts = await accountsDB.accounts.toArray(); const thisIdentity = JSON.parse(accounts[0].identity); // Make a claim diff --git a/src/views/AccountViewView.vue b/src/views/AccountViewView.vue index 01bdf49..43407be 100644 --- a/src/views/AccountViewView.vue +++ b/src/views/AccountViewView.vue @@ -26,7 +26,7 @@ - +
  • +
    + + + + Help + + +
    +
    Edit Identity + Edit Identity +

    Contact Actions

    Scan New Contact + Scan New Contact + -

    Identity Actions

    +

    Data

    Backup Seed + Backup Identifier Seed + Backup Other Data + Download Settings & Contacts (excluding Identifier Data) + + @@ -198,10 +215,11 @@