diff --git a/static/scripts.js b/static/scripts.js index 25afe18..254138b 100644 --- a/static/scripts.js +++ b/static/scripts.js @@ -231,11 +231,13 @@ async function verifyProofs(opts) { } async function displayProfile(opts) { - let keyData, keyLink, feedback = "", notation, isVerified, verifications = []; + let keyData, keyLink, fingerprint, feedback = "", notation, isVerified, verifications = []; let icon_qr = ''; try { - keyData = await fetchKeys(opts); + keyData = await doip.keys.fetch.uri(`${opts.mode}:${opts.input}`); + fingerprint = keyData.keyPacket.getFingerprint(); + // keyData = await fetchKeys(opts); } catch (e) { feedback += `
There was a problem fetching the keys.
`; feedback += `${e}
`;
@@ -244,29 +246,13 @@ async function displayProfile(opts) {
return;
}
- let userData = keyData.user.user.userId;
- let userName = userData.name ? userData.name : userData.email;
- let userMail = userData.email ? userData.email : null;
+ const userPrimary = await keyData.getPrimaryUser();
+ const userData = userPrimary.user.userId;
+ const userName = userData.name ? userData.name : userData.email;
+ const userMail = userData.email ? userData.email : null;
let imgUri = null;
- let notations = [], notationsRaw = [];
- for (var i = 0; i < keyData.publicKey.users.length; i++) {
- if (keyData.publicKey.users[i].selfCertifications.length == 0) { continue; }
-
- notationsRaw = notationsRaw.concat(keyData.publicKey.users[i].selfCertifications[0].notations);
-
- if (keyData.publicKey.users[i].userAttribute != null && keyData.publicKey.users[i].userAttribute.attributes[0][0] === String.fromCharCode(1)) {
- imgUri = "data:image/jpeg;base64," + btoa(keyData.publicKey.users[i].userAttribute.attributes[0].substring(17));
- }
- }
- notationsRaw.forEach((item, i) => {
- if (item[0] == "proof@metacode.biz") {
- notations.push(item[1]);
- }
- });
- notations = Array.from(new Set(notations)); // Deduplicate (ES6)
-
// Determine WKD or HKP link
switch (opts.mode) {
case "wkd":
@@ -325,49 +311,21 @@ async function displayProfile(opts) {
feedback += ``;
feedback += `There was a problem verifying the claims.
`; + feedback += `${e}
`;
+ document.body.querySelector('#profileData').innerHTML = feedback;
+ document.body.querySelector('#profileName').innerHTML = "Could not load profile";
return;
}
- // Verify identity proofs
- let proofResult;
- for (var i = 0; i < notations.length; i++) {
- notation = notations[i];
- proofResult = await verifyProof(notation, keyData.fingerprint);
- if (!proofResult || !proofResult.display) { continue; }
- verifications.push(proofResult);
+ // Exit if no notations are available
+ if (verifications.length == 0) {
+ return;
}
- // One-line sorting function (order verifications by type)
- verifications = verifications.sort((a,b) => (a.type > b.type) ? 1 : ((b.type > a.type) ? -1 : 0));
-
feedback = "";
- if (verifications.length > 0) {
- for (var i = 0; i < verifications.length; i++) {
- if (!verifications[i].type) { continue; }
- feedback += `