forked from trent_larson/crowd-funder-for-time-pwa
add number of confirmers to certificate & show DID info when appropriate
This commit is contained in:
@@ -437,6 +437,7 @@ export function didInfoForContact(
|
|||||||
activeDid: string | undefined,
|
activeDid: string | undefined,
|
||||||
contact?: Contact,
|
contact?: Contact,
|
||||||
allMyDids: string[] = [],
|
allMyDids: string[] = [],
|
||||||
|
showDidForVisible: boolean = false,
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
): { known: boolean; displayName: string; profileImageUrl?: string } {
|
): { known: boolean; displayName: string; profileImageUrl?: string } {
|
||||||
if (!did) return { displayName: "Someone Unnamed/Unknown", known: false };
|
if (!did) return { displayName: "Someone Unnamed/Unknown", known: false };
|
||||||
@@ -453,9 +454,11 @@ export function didInfoForContact(
|
|||||||
return myId
|
return myId
|
||||||
? { displayName: "You (Alt ID)", known: true }
|
? { displayName: "You (Alt ID)", known: true }
|
||||||
: isHiddenDid(did)
|
: isHiddenDid(did)
|
||||||
? { displayName: "Someone Totally Outside Your View", known: false }
|
? { displayName: "Someone Outside Your View", known: false }
|
||||||
: {
|
: {
|
||||||
displayName: "Someone Visible But Outside Your Contact List",
|
displayName: showDidForVisible
|
||||||
|
? did
|
||||||
|
: "Someone Visible But Not In Your Contact List",
|
||||||
known: false,
|
known: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -483,8 +486,13 @@ export function didInfoForCertificate(
|
|||||||
did: string | undefined,
|
did: string | undefined,
|
||||||
contacts: Contact[],
|
contacts: Contact[],
|
||||||
): string {
|
): string {
|
||||||
return didInfoForContact(did, undefined, contactForDid(did, contacts), [])
|
return didInfoForContact(
|
||||||
.displayName;
|
did,
|
||||||
|
undefined,
|
||||||
|
contactForDid(did, contacts),
|
||||||
|
[],
|
||||||
|
true,
|
||||||
|
).displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
let passkeyAccessToken: string = "";
|
let passkeyAccessToken: string = "";
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import QRCode from "qrcode";
|
|||||||
|
|
||||||
import { APP_SERVER, NotificationIface } from "@/constants/app";
|
import { APP_SERVER, NotificationIface } from "@/constants/app";
|
||||||
import { db, retrieveSettingsForActiveAccount } from "@/db/index";
|
import { db, retrieveSettingsForActiveAccount } from "@/db/index";
|
||||||
import * as endorserServer from "@/libs/endorserServer";
|
import * as serverUtil from "@/libs/endorserServer";
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
export default class ClaimCertificateView extends Vue {
|
export default class ClaimCertificateView extends Vue {
|
||||||
@@ -35,7 +35,7 @@ export default class ClaimCertificateView extends Vue {
|
|||||||
claimId = "";
|
claimId = "";
|
||||||
claimData = null;
|
claimData = null;
|
||||||
|
|
||||||
endorserServer = endorserServer;
|
serverUtil = serverUtil;
|
||||||
|
|
||||||
async created() {
|
async created() {
|
||||||
const settings = await retrieveSettingsForActiveAccount();
|
const settings = await retrieveSettingsForActiveAccount();
|
||||||
@@ -50,14 +50,27 @@ export default class ClaimCertificateView extends Vue {
|
|||||||
|
|
||||||
async fetchClaim() {
|
async fetchClaim() {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(
|
const headers = await serverUtil.getHeaders(this.activeDid);
|
||||||
|
const response = await this.axios.get(
|
||||||
`${this.apiServer}/api/claim/${this.claimId}`,
|
`${this.apiServer}/api/claim/${this.claimId}`,
|
||||||
|
{ headers },
|
||||||
);
|
);
|
||||||
if (response.ok) {
|
if (response.status === 200) {
|
||||||
this.claimData = await response.json();
|
this.claimData = await response.data;
|
||||||
|
const claimEntryIds = [this.claimId];
|
||||||
|
const headers = await serverUtil.getHeaders(this.activeDid);
|
||||||
|
const confirmerResponse = await this.axios.post(
|
||||||
|
`${this.apiServer}/api/v2/report/confirmers/?claimEntryIds=${this.claimId}`,
|
||||||
|
{ claimEntryIds },
|
||||||
|
{ headers },
|
||||||
|
);
|
||||||
|
let confirmerIds: Array<string> = [];
|
||||||
|
if (confirmerResponse.status === 200) {
|
||||||
|
confirmerIds = await confirmerResponse.data.data;
|
||||||
|
}
|
||||||
await nextTick(); // Wait for the DOM to update
|
await nextTick(); // Wait for the DOM to update
|
||||||
if (this.claimData) {
|
if (this.claimData) {
|
||||||
this.drawCanvas(this.claimData);
|
this.drawCanvas(this.claimData, confirmerIds);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Error fetching claim: ${response.statusText}`);
|
throw new Error(`Error fetching claim: ${response.statusText}`);
|
||||||
@@ -74,7 +87,8 @@ export default class ClaimCertificateView extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async drawCanvas(
|
async drawCanvas(
|
||||||
claimData: endorserServer.GenericCredWrapper<endorserServer.GenericVerifiableCredential>,
|
claimData: serverUtil.GenericCredWrapper<serverUtil.GenericVerifiableCredential>,
|
||||||
|
confirmerIds: Array<string>,
|
||||||
) {
|
) {
|
||||||
await db.open();
|
await db.open();
|
||||||
const allContacts = await db.contacts.toArray();
|
const allContacts = await db.contacts.toArray();
|
||||||
@@ -102,7 +116,7 @@ export default class ClaimCertificateView extends Vue {
|
|||||||
// Draw claim type
|
// Draw claim type
|
||||||
ctx.font = "bold 20px Arial";
|
ctx.font = "bold 20px Arial";
|
||||||
const claimTypeText =
|
const claimTypeText =
|
||||||
this.endorserServer.capitalizeAndInsertSpacesBeforeCaps(
|
this.serverUtil.capitalizeAndInsertSpacesBeforeCaps(
|
||||||
claimData.claimType || "",
|
claimData.claimType || "",
|
||||||
);
|
);
|
||||||
const claimTypeWidth = ctx.measureText(claimTypeText).width;
|
const claimTypeWidth = ctx.measureText(claimTypeText).width;
|
||||||
@@ -121,8 +135,10 @@ export default class ClaimCertificateView extends Vue {
|
|||||||
(CANVAS_WIDTH - presentedWidth) / 2, // Center horizontally
|
(CANVAS_WIDTH - presentedWidth) / 2, // Center horizontally
|
||||||
CANVAS_HEIGHT * 0.37,
|
CANVAS_HEIGHT * 0.37,
|
||||||
);
|
);
|
||||||
const agentText = endorserServer.didInfoForCertificate(
|
const agentDid =
|
||||||
claimData.claim.agent,
|
claimData.claim.agent.identifier || claimData.claim.agent;
|
||||||
|
const agentText = serverUtil.didInfoForCertificate(
|
||||||
|
agentDid,
|
||||||
allContacts,
|
allContacts,
|
||||||
);
|
);
|
||||||
ctx.font = "bold 20px Arial";
|
ctx.font = "bold 20px Arial";
|
||||||
@@ -155,12 +171,21 @@ export default class ClaimCertificateView extends Vue {
|
|||||||
ctx.font = "14px Arial";
|
ctx.font = "14px Arial";
|
||||||
const issuerText =
|
const issuerText =
|
||||||
"Issued by " +
|
"Issued by " +
|
||||||
endorserServer.didInfoForCertificate(
|
serverUtil.didInfoForCertificate(claimData.issuer, allContacts);
|
||||||
claimData.issuer,
|
|
||||||
allContacts,
|
|
||||||
);
|
|
||||||
ctx.fillText(issuerText, CANVAS_WIDTH * 0.3, CANVAS_HEIGHT * 0.6);
|
ctx.fillText(issuerText, CANVAS_WIDTH * 0.3, CANVAS_HEIGHT * 0.6);
|
||||||
}
|
}
|
||||||
|
if (confirmerIds.length > 0) {
|
||||||
|
const confirmerText =
|
||||||
|
"Confirmed by " +
|
||||||
|
confirmerIds.length +
|
||||||
|
(confirmerIds.length === 1 ? " person" : " people");
|
||||||
|
ctx.font = "14px Arial";
|
||||||
|
ctx.fillText(
|
||||||
|
confirmerText,
|
||||||
|
CANVAS_WIDTH * 0.3,
|
||||||
|
CANVAS_HEIGHT * 0.63,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Draw claim ID
|
// Draw claim ID
|
||||||
ctx.font = "14px Arial";
|
ctx.font = "14px Arial";
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
<!-- Details -->
|
<!-- Details -->
|
||||||
<div class="bg-slate-100 rounded-md overflow-hidden px-4 py-3 mb-4">
|
<div class="bg-slate-100 rounded-md overflow-hidden px-4 py-3 mb-4">
|
||||||
<div class="block flex gap-4 overflow-hidden">
|
<div class="block flex gap-4 overflow-hidden">
|
||||||
<div class="overflow-hidden">
|
<div class="overflow-hidden w-full">
|
||||||
<div class="flex justify-between">
|
<div class="flex justify-between">
|
||||||
<h2 class="text-md font-bold">
|
<h2 class="text-md font-bold">
|
||||||
{{ capitalizeAndInsertSpacesBeforeCaps(veriClaim.claimType) }}
|
{{ capitalizeAndInsertSpacesBeforeCaps(veriClaim.claimType) }}
|
||||||
|
|||||||
@@ -490,7 +490,7 @@ export default class NewEditProjectView extends Vue {
|
|||||||
title: "Error Saving Idea",
|
title: "Error Saving Idea",
|
||||||
text: "Server did not save the idea. Try again.",
|
text: "Server did not save the idea. Try again.",
|
||||||
},
|
},
|
||||||
-1,
|
5000,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -511,7 +511,7 @@ export default class NewEditProjectView extends Vue {
|
|||||||
title: "User Message",
|
title: "User Message",
|
||||||
text: userMessage,
|
text: userMessage,
|
||||||
},
|
},
|
||||||
-1,
|
5000,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
this.$notify(
|
this.$notify(
|
||||||
@@ -521,7 +521,7 @@ export default class NewEditProjectView extends Vue {
|
|||||||
title: "Server Message",
|
title: "Server Message",
|
||||||
text: JSON.stringify(serverError.toJSON()),
|
text: JSON.stringify(serverError.toJSON()),
|
||||||
},
|
},
|
||||||
-1,
|
5000,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -533,7 +533,7 @@ export default class NewEditProjectView extends Vue {
|
|||||||
title: "Claim Error",
|
title: "Claim Error",
|
||||||
text: error as string,
|
text: error as string,
|
||||||
},
|
},
|
||||||
-1,
|
5000,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// Now set that error for the user to see.
|
// Now set that error for the user to see.
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ test('Add contact, record gift, confirm gift', async ({ page }) => {
|
|||||||
await page.getByText('You have a seed').click();
|
await page.getByText('You have a seed').click();
|
||||||
await page.getByPlaceholder('Seed Phrase').fill('rigid shrug mobile smart veteran half all pond toilet brave review universe ship congress found yard skate elite apology jar uniform subway slender luggage');
|
await page.getByPlaceholder('Seed Phrase').fill('rigid shrug mobile smart veteran half all pond toilet brave review universe ship congress found yard skate elite apology jar uniform subway slender luggage');
|
||||||
await page.getByRole('button', { name: 'Import' }).click();
|
await page.getByRole('button', { name: 'Import' }).click();
|
||||||
|
await expect(page.getByRole('code')).toContainText('did:ethr:0x0000694B58C2cC69658993A90D3840C560f2F51F');
|
||||||
|
|
||||||
// Go to home view and look for gift
|
// Go to home view and look for gift
|
||||||
await page.goto('./');
|
await page.goto('./');
|
||||||
|
|||||||
Reference in New Issue
Block a user