From e42b3ff11d4fa11f5b2f578385a4e9fc59c6c78f Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Tue, 4 Jul 2023 13:15:52 -0600 Subject: [PATCH] allow choice of no identity (for testing) --- .../World/components/objects/landmarks.js | 15 +++--- src/libs/endorserServer.ts | 12 +++-- src/views/AccountViewView.vue | 47 ++++++++++++++----- src/views/ContactsView.vue | 3 +- src/views/HomeView.vue | 19 ++++++-- 5 files changed, 66 insertions(+), 30 deletions(-) diff --git a/src/components/World/components/objects/landmarks.js b/src/components/World/components/objects/landmarks.js index a46033763..30f5e8379 100644 --- a/src/components/World/components/objects/landmarks.js +++ b/src/components/World/components/objects/landmarks.js @@ -22,17 +22,16 @@ export async function loadLandmarks(vue, world, scene, loop) { await accountsDB.open(); const accounts = await accountsDB.accounts.toArray(); const account = R.find((acc) => acc.did === activeDid, accounts); - const identity = JSON.parse(account?.identity || "undefined"); - if (!identity) { - throw new Error("No identity found."); - } - const token = await accessToken(identity); - - const url = apiServer + "/api/v2/report/claims?claimType=GiveAction"; const headers = { "Content-Type": "application/json", - Authorization: "Bearer " + token, }; + const identity = JSON.parse(account?.identity || "null"); + if (identity) { + const token = await accessToken(identity); + headers["Authorization"] = "Bearer " + token; + } + + const url = apiServer + "/api/v2/report/claims?claimType=GiveAction"; const resp = await axios.get(url, { headers: headers }); if (resp.status === 200) { const landmarks = resp.data.data; diff --git a/src/libs/endorserServer.ts b/src/libs/endorserServer.ts index 026e7057a..aaac8d24c 100644 --- a/src/libs/endorserServer.ts +++ b/src/libs/endorserServer.ts @@ -3,6 +3,7 @@ import { IIdentifier } from "@veramo/core"; import { accessToken, SimpleSigner } from "@/libs/crypto"; import * as didJwt from "did-jwt"; import { Axios, AxiosResponse } from "axios"; +import { Contact } from "@/db/tables/contacts"; export const SCHEMA_ORG_CONTEXT = "https://schema.org"; export const SERVICE_ID = "endorser.ch"; @@ -81,12 +82,15 @@ export function isHiddenDid(did) { /** always returns text, maybe UNNAMED_VISIBLE or UNKNOWN_ENTITY **/ -export function didInfo(did, identifiers, contacts) { - const myId = R.find((i) => i.did === did, identifiers); +export function didInfo(did, activeDid, identifiers, contacts) { + const myId: IIdentifier | undefined = R.find( + (i) => i.did === did, + identifiers + ); if (myId) { - return "You"; + return "You" + (myId.did !== activeDid ? " (Alt ID)" : ""); } else { - const contact = R.find((c) => c.did === did, contacts); + const contact: Contact | undefined = R.find((c) => c.did === did, contacts); if (contact) { return contact.name || "Someone Unnamed in Contacts"; } else if (!did) { diff --git a/src/views/AccountViewView.vue b/src/views/AccountViewView.vue index ed2c7df00..02bd79672 100644 --- a/src/views/AccountViewView.vue +++ b/src/views/AccountViewView.vue @@ -290,6 +290,11 @@
Switch Identifier + + +