allow choice of no identity (for testing)

This commit is contained in:
2023-07-04 13:15:52 -06:00
parent d98e95915b
commit e42b3ff11d
5 changed files with 66 additions and 30 deletions

View File

@@ -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) {