From 934664b9c993374aba414f4c7ede55a235735c4e Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Wed, 3 Jan 2024 17:44:41 -0700 Subject: [PATCH] add the hashed-next-key to the contact data, shown & stored --- project.task.yaml | 4 +--- src/db/tables/contacts.ts | 3 ++- src/libs/crypto/index.ts | 16 ++++++++++++++++ src/views/ContactQRScanShowView.vue | 16 +++++++++++++--- src/views/ContactsView.vue | 5 +++++ src/views/ImportDerivedAccountView.vue | 13 ++----------- 6 files changed, 39 insertions(+), 18 deletions(-) diff --git a/project.task.yaml b/project.task.yaml index 609e7c7f..ab097bd1 100644 --- a/project.task.yaml +++ b/project.task.yaml @@ -6,8 +6,6 @@ tasks: - fix maskable icon -- 04 generate & store next public key hash, and give to contacts for storage - - .5 If notifications are not enabled, add message to front page with link/button to enable - Release Minimum Viable Product : @@ -32,7 +30,7 @@ tasks: - record donations vs gives - make server endpoint for full English description of limits - make identicons for contacts into more-memorable faces (and maybe change project identicons, too) -- 02 watch for the service worker activation before showing the button to turn on notifications + - 01 server - show all claim details when issued by the issuer - bug - got error adding on Firefox user #0 as contact for themselves - bug (that is hard to reproduce) - back-and-forth on discovery & project pages led to "You need an identity to load your projects." error on product page when I had an identity diff --git a/src/db/tables/contacts.ts b/src/db/tables/contacts.ts index f1e1b90d..2f59a417 100644 --- a/src/db/tables/contacts.ts +++ b/src/db/tables/contacts.ts @@ -1,11 +1,12 @@ export interface Contact { did: string; name?: string; + nextPublicKeyHashBase64?: string; // base64-encoded SHA256 hash of next public key publicKeyBase64?: string; seesMe?: boolean; registered?: boolean; } export const ContactSchema = { - contacts: "&did, name", // no need to key by publicKeyBase64, registered, seesMe + contacts: "&did, name", // no need to key by other things }; diff --git a/src/libs/crypto/index.ts b/src/libs/crypto/index.ts index be8ccefd..e5d120ef 100644 --- a/src/libs/crypto/index.ts +++ b/src/libs/crypto/index.ts @@ -173,3 +173,19 @@ export const getContactPayloadFromJwtUrl = (jwtUrlText: string) => { return jwt.payload; }; + +export const nextDerivationPath = (origDerivPath: string) => { + let lastStr = origDerivPath.split("/").slice(-1)[0]; + if (lastStr.endsWith("'")) { + lastStr = lastStr.slice(0, -1); + } + const lastNum = parseInt(lastStr, 10); + const newLastNum = lastNum + 1; + const newLastStr = newLastNum.toString() + (lastStr.endsWith("'") ? "'" : ""); + const newDerivPath = origDerivPath + .split("/") + .slice(0, -1) + .concat([newLastStr]) + .join("/"); + return newDerivPath; +}; diff --git a/src/views/ContactQRScanShowView.vue b/src/views/ContactQRScanShowView.vue index 9bef1b09..8b6d9f9d 100644 --- a/src/views/ContactQRScanShowView.vue +++ b/src/views/ContactQRScanShowView.vue @@ -58,16 +58,17 @@