mirror of
https://codeberg.org/keyoxide/keyoxide-web.git
synced 2024-12-23 07:19:28 -07:00
Support images embedded in keys
This commit is contained in:
parent
5dc8e85d02
commit
875142fd8f
1 changed files with 13 additions and 1 deletions
|
@ -248,9 +248,17 @@ async function displayProfile(opts) {
|
||||||
let userName = userData.name ? userData.name : userData.email;
|
let userName = userData.name ? userData.name : userData.email;
|
||||||
let userMail = userData.email ? userData.email : null;
|
let userMail = userData.email ? userData.email : null;
|
||||||
|
|
||||||
|
let imgUri = null;
|
||||||
|
keyData.publicKey.users.forEach((user, i) => {
|
||||||
|
});
|
||||||
|
|
||||||
let notations = [], notationsRaw = [];
|
let notations = [], notationsRaw = [];
|
||||||
for (var i = 0; i < keyData.publicKey.users.length; i++) {
|
for (var i = 0; i < keyData.publicKey.users.length; i++) {
|
||||||
notationsRaw = notationsRaw.concat(keyData.publicKey.users[i].selfCertifications[0].notations);
|
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) => {
|
notationsRaw.forEach((item, i) => {
|
||||||
if (item[0] == "proof@metacode.biz") {
|
if (item[0] == "proof@metacode.biz") {
|
||||||
|
@ -305,7 +313,11 @@ async function displayProfile(opts) {
|
||||||
document.body.querySelector('#profileName').innerHTML = userName;
|
document.body.querySelector('#profileName').innerHTML = userName;
|
||||||
document.body.querySelector('#profileAvatar').style = "";
|
document.body.querySelector('#profileAvatar').style = "";
|
||||||
const profileHash = openpgp.util.str_to_hex(openpgp.util.Uint8Array_to_str(await openpgp.crypto.hash.md5(openpgp.util.str_to_Uint8Array(userData.email))));
|
const profileHash = openpgp.util.str_to_hex(openpgp.util.Uint8Array_to_str(await openpgp.crypto.hash.md5(openpgp.util.str_to_Uint8Array(userData.email))));
|
||||||
|
if (imgUri) {
|
||||||
|
document.body.querySelector('#profileAvatar').src = imgUri;
|
||||||
|
} else {
|
||||||
document.body.querySelector('#profileAvatar').src = `https://www.gravatar.com/avatar/${profileHash}?s=128&d=mm`;
|
document.body.querySelector('#profileAvatar').src = `https://www.gravatar.com/avatar/${profileHash}?s=128&d=mm`;
|
||||||
|
}
|
||||||
document.title = `${userName} - Keyoxide`;
|
document.title = `${userName} - Keyoxide`;
|
||||||
|
|
||||||
// Generate feedback
|
// Generate feedback
|
||||||
|
|
Loading…
Reference in a new issue