From 8add6448fb9f40b61b80f9d9634f8b8b55211854 Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Tue, 11 Jul 2023 09:10:25 -0600 Subject: [PATCH 1/8] remove code that keeps the private key (account) data in memory --- src/views/AccountViewView.vue | 6 ++---- src/views/ContactAmountsView.vue | 7 ++----- src/views/HomeView.vue | 16 +++++++--------- src/views/NewEditProjectView.vue | 7 ++----- src/views/ProjectViewView.vue | 5 ++--- src/views/ProjectsView.vue | 7 ++----- 6 files changed, 17 insertions(+), 31 deletions(-) diff --git a/src/views/AccountViewView.vue b/src/views/AccountViewView.vue index a60c2af..5c0717c 100644 --- a/src/views/AccountViewView.vue +++ b/src/views/AccountViewView.vue @@ -320,7 +320,6 @@ export default class AccountViewView extends Vue { limitsMessage = ""; loadingLimits = true; // might as well now that we do it on mount, to avoid flashing the registration message showContactGives = false; - private accounts: AccountsSchema; showDidCopy = false; showDerCopy = false; @@ -374,9 +373,8 @@ export default class AccountViewView extends Vue { } async beforeCreate() { - accountsDB.open(); - this.accounts = accountsDB.accounts; - this.numAccounts = await this.accounts.count(); + await accountsDB.open(); + this.numAccounts = await accountsDB.accounts.count(); } async created() { diff --git a/src/views/ContactAmountsView.vue b/src/views/ContactAmountsView.vue index ca01ea4..fa02391 100644 --- a/src/views/ContactAmountsView.vue +++ b/src/views/ContactAmountsView.vue @@ -78,7 +78,6 @@ import * as R from "ramda"; import { Component, Vue } from "vue-facing-decorator"; import { accountsDB, db } from "@/db"; -import { AccountsSchema } from "@/db/tables/accounts"; import { Contact } from "@/db/tables/contacts"; import { MASTER_SETTINGS_KEY } from "@/db/tables/settings"; import { accessToken, SimpleSigner } from "@/libs/crypto"; @@ -101,13 +100,11 @@ export default class ContactsView extends Vue { giveRecords: Array = []; alertTitle = ""; alertMessage = ""; - accounts: AccountsSchema; numAccounts = 0; async beforeCreate() { - accountsDB.open(); - this.accounts = accountsDB.accounts; - this.numAccounts = await this.accounts.count(); + await accountsDB.open(); + this.numAccounts = await accountsDB.accounts.count(); } public async getIdentity(activeDid) { diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 956a602..b11fdef 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -73,7 +73,6 @@ import { Component, Vue } from "vue-facing-decorator"; import GiftedDialog from "@/components/GiftedDialog.vue"; import { db, accountsDB } from "@/db"; -import { AccountsSchema } from "@/db/tables/accounts"; import { MASTER_SETTINGS_KEY } from "@/db/tables/settings"; import { accessToken } from "@/libs/crypto"; import { createAndSubmitGive, didInfo } from "@/libs/endorserServer"; @@ -87,7 +86,6 @@ import QuickNav from "@/components/QuickNav"; }) export default class HomeView extends Vue { activeDid = ""; - allAccounts: Array = []; allContacts: Array = []; apiServer = ""; feedAllLoaded = false; @@ -97,13 +95,11 @@ export default class HomeView extends Vue { isHiddenSpinner = true; alertTitle = ""; alertMessage = ""; - accounts: AccountsSchema; numAccounts = 0; async beforeCreate() { - accountsDB.open(); - this.accounts = accountsDB.accounts; - this.numAccounts = await this.accounts.count(); + await accountsDB.open(); + this.numAccounts = await accountsDB.accounts.count(); } public async getIdentity(activeDid) { @@ -226,11 +222,13 @@ export default class HomeView extends Vue { } } - giveDescription(giveRecord) { + async giveDescription(giveRecord) { let claim = giveRecord.fullClaim; if (claim.claim) { claim = claim.claim; } + await accountsDB.open(); + const allAccounts = await accountsDB.accounts.toArray(); // agent.did is for legacy data, before March 2023 const giverDid = @@ -238,7 +236,7 @@ export default class HomeView extends Vue { const giverInfo = didInfo( giverDid, this.activeDid, - this.allAccounts, + allAccounts, this.allContacts, ); const gaveAmount = claim.object?.amountOfThisGood @@ -251,7 +249,7 @@ export default class HomeView extends Vue { didInfo( gaveRecipientId, this.activeDid, - this.allAccounts, + allAccounts, this.allContacts, ) : ""; diff --git a/src/views/NewEditProjectView.vue b/src/views/NewEditProjectView.vue index 3dc6633..f50e129 100644 --- a/src/views/NewEditProjectView.vue +++ b/src/views/NewEditProjectView.vue @@ -76,7 +76,6 @@ import * as didJwt from "did-jwt"; import { Component, Vue } from "vue-facing-decorator"; import { accountsDB, db } from "@/db"; -import { AccountsSchema } from "@/db/tables/accounts"; import { MASTER_SETTINGS_KEY } from "@/db/tables/settings"; import { accessToken, SimpleSigner } from "@/libs/crypto"; import { useAppStore } from "@/store/app"; @@ -92,15 +91,13 @@ export default class NewEditProjectView extends Vue { projectName = ""; description = ""; errorMessage = ""; - accounts: AccountsSchema; numAccounts = 0; alertTitle = ""; alertMessage = ""; async beforeCreate() { - accountsDB.open(); - this.accounts = accountsDB.accounts; - this.numAccounts = await this.accounts.count(); + await accountsDB.open(); + this.numAccounts = await accountsDB.accounts.count(); } public async getIdentity(activeDid) { diff --git a/src/views/ProjectViewView.vue b/src/views/ProjectViewView.vue index 1880943..8c733cf 100644 --- a/src/views/ProjectViewView.vue +++ b/src/views/ProjectViewView.vue @@ -198,9 +198,8 @@ export default class ProjectViewView extends Vue { truncateLength = 40; async beforeCreate() { - accountsDB.open(); - this.accounts = accountsDB.accounts; - this.numAccounts = (await this.accounts?.count()) || 0; + await accountsDB.open(); + this.numAccounts = (await accountsDB.accounts?.count()) || 0; } async created() { diff --git a/src/views/ProjectsView.vue b/src/views/ProjectsView.vue index 3c5672a..6c3d32a 100644 --- a/src/views/ProjectsView.vue +++ b/src/views/ProjectsView.vue @@ -75,7 +75,6 @@