From 403327c25a201da7d8fd566a4446fa7fa2cb86c6 Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Fri, 19 Jul 2024 20:49:43 -0600 Subject: [PATCH] create an identifier by default, while letting them choose if passkeys are enabled --- src/libs/crypto/vc/passkeyDidPeer.ts | 10 +++- src/views/HelpView.vue | 9 ++-- src/views/HomeView.vue | 77 +++++++++++----------------- src/views/StartView.vue | 7 ++- 4 files changed, 49 insertions(+), 54 deletions(-) diff --git a/src/libs/crypto/vc/passkeyDidPeer.ts b/src/libs/crypto/vc/passkeyDidPeer.ts index 920d751..5efc372 100644 --- a/src/libs/crypto/vc/passkeyDidPeer.ts +++ b/src/libs/crypto/vc/passkeyDidPeer.ts @@ -411,13 +411,21 @@ async function peerDidToDidDocument(did: string): Promise { } // this is basically hard-coded from https://www.w3.org/TR/did-core/#example-various-verification-method-types // (another reference is the @aviarytech/did-peer resolver) + + /** + * Looks like JsonWebKey2020 isn't too difficult: + * - change context security/suites link to jws-2020/v1 + * - change publicKeyMultibase to publicKeyJwk generated with cborToKeys + * - change type to JsonWebKey2020 + */ + const id = did.split(":")[2]; const multibase = id.slice(1); const encnumbasis = multibase.slice(1); const didDocument = { "@context": [ "https://www.w3.org/ns/did/v1", - "https://w3id.org/security/suites/jws-2020/v1", + "https://w3id.org/security/suites/secp256k1-2019/v1", ], assertionMethod: [did + "#" + encnumbasis], authentication: [did + "#" + encnumbasis], diff --git a/src/views/HelpView.vue b/src/views/HelpView.vue index ea6d3b5..02327fa 100644 --- a/src/views/HelpView.vue +++ b/src/views/HelpView.vue @@ -24,16 +24,15 @@

- This app is a window into data that you and your friends own, focused on - gifts and collaboration. + This app focuses on gifts & gratitude, using them to build cool things with your network.

What is the idea here?

We are building networks of people who want to grow a giving society. - First of all, you can see what people have given, and also recognize - gifts you've seen, in a way that leaves a permanent record -- one that - came from you, and the recipient can prove it was for them. This is + First of all, let's build gratitude: see what people have given, and recognize + gifts you've seen. This is done in a way that leaves a permanent record -- one that + came from you, and that the recipient can prove it was for them. This is personally gratifying, but it extends to broader work: volunteers get confirmation of activity, and selectively show off their contributions and network. diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 53ac742..25e4ead 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -77,58 +77,28 @@

-
-
-

- Choose how to see info from your contacts or share contributions: -

-
- - - Give me all the options. - -
-
-
-

- To recognize giving or collaborate, have someone register you: -

- - Share your contact info. - -
-
- -
- - + +
- Someone must register you before you can give kudos or make offers - or create projects... basically before doing anything. + To share, someone must register you. - Show Them Your Identifier Info + Show Them Default Identifier Info +
+ + See all your options first + +
@@ -340,7 +310,11 @@ import FeedFilters from "@/components/FeedFilters.vue"; import InfiniteScroll from "@/components/InfiniteScroll.vue"; import QuickNav from "@/components/QuickNav.vue"; import TopMessage from "@/components/TopMessage.vue"; -import { AppString, NotificationIface, PASSKEYS_ENABLED } from "@/constants/app"; +import { + AppString, + NotificationIface, + PASSKEYS_ENABLED, +} from "@/constants/app"; import { db, accountsDB } from "@/db/index"; import { Contact } from "@/db/tables/contacts"; import { @@ -359,7 +333,10 @@ import { GiverReceiverInputInfo, GiveSummaryRecord, } from "@/libs/endorserServer"; -import { registerSaveAndActivatePasskey } from "@/libs/util"; +import { + generateSaveAndActivateIdentity, + registerSaveAndActivatePasskey, +} from "@/libs/util"; interface GiveRecordWithContactInfo extends GiveSummaryRecord { giver: { @@ -423,7 +400,14 @@ export default class HomeView extends Vue { try { await accountsDB.open(); const allAccounts = await accountsDB.accounts.toArray(); - this.allMyDids = allAccounts.map((acc) => acc.did); + if (allAccounts.length > 0) { + this.allMyDids = allAccounts.map((acc) => acc.did); + } else { + this.isCreatingIdentifier = true; + const newDid = await generateSaveAndActivateIdentity(); + this.isCreatingIdentifier = false; + this.allMyDids = [newDid]; + } await db.open(); const settings = (await db.settings.get(MASTER_SETTINGS_KEY)) as Settings; @@ -440,6 +424,7 @@ export default class HomeView extends Vue { this.isAnyFeedFilterOn = isAnyFeedFilterOn(settings); + // someone may have have registered after sharing contact info, so recheck if (!this.isRegistered && this.activeDid) { try { @@ -481,7 +466,7 @@ export default class HomeView extends Vue { } } - async generateIdentifier() { + async generatePasskeyIdentifier() { this.isCreatingIdentifier = true; const account = await registerSaveAndActivatePasskey( AppString.APP_NAME + (this.givenName ? " - " + this.givenName : ""), diff --git a/src/views/StartView.vue b/src/views/StartView.vue index 54587d9..002db61 100644 --- a/src/views/StartView.vue +++ b/src/views/StartView.vue @@ -27,7 +27,7 @@

How do you want to create this identifier?

-

+

A passkey is easy to manage, though it is less interoperable with other systems for advanced uses.