Allow setting of custom HKP server

This commit is contained in:
Yarmo Mackenbach 2021-01-05 13:20:06 +01:00
parent 224891035e
commit fe423b54e0
3 changed files with 21 additions and 3 deletions

View file

@ -37,6 +37,10 @@ router.get('/hkp/:input', function(req, res) {
res.render('profile', { mode: "hkp", uid: req.params.input }) res.render('profile', { mode: "hkp", uid: req.params.input })
}); });
router.get('/hkp/:server/:input', function(req, res) {
res.render('profile', { mode: "hkp", uid: req.params.input, server: req.params.server })
});
router.get('/keybase/:username/:fingerprint', function(req, res) { router.get('/keybase/:username/:fingerprint', function(req, res) {
res.render('profile', { mode: "keybase", uid: `${req.params.username}/${req.params.fingerprint}` }) res.render('profile', { mode: "keybase", uid: `${req.params.username}/${req.params.fingerprint}` })
}); });

View file

@ -235,9 +235,14 @@ async function displayProfile(opts) {
let icon_qr = '<svg style="width:24px;height:24px" viewBox="0 0 24 24"><path fill="#ffffff" d="M3,11H5V13H3V11M11,5H13V9H11V5M9,11H13V15H11V13H9V11M15,11H17V13H19V11H21V13H19V15H21V19H19V21H17V19H13V21H11V17H15V15H17V13H15V11M19,19V15H17V19H19M15,3H21V9H15V3M17,5V7H19V5H17M3,3H9V9H3V3M5,5V7H7V5H5M3,15H9V21H3V15M5,17V19H7V17H5Z" /></svg>'; let icon_qr = '<svg style="width:24px;height:24px" viewBox="0 0 24 24"><path fill="#ffffff" d="M3,11H5V13H3V11M11,5H13V9H11V5M9,11H13V15H11V13H9V11M15,11H17V13H19V11H21V13H19V15H21V19H19V21H17V19H13V21H11V17H15V15H17V13H15V11M19,19V15H17V19H19M15,3H21V9H15V3M17,5V7H19V5H17M3,3H9V9H3V3M5,5V7H7V5H5M3,15H9V21H3V15M5,17V19H7V17H5Z" /></svg>';
try { try {
keyData = await doip.keys.fetch.uri(`${opts.mode}:${opts.input}`); let keyURI;
if (opts.mode === 'hkp' && opts.server) {
keyURI = `${opts.mode}:${opts.server}:${opts.input}`
} else {
keyURI = `${opts.mode}:${opts.input}`
}
keyData = await doip.keys.fetch.uri(keyURI);
fingerprint = keyData.keyPacket.getFingerprint(); fingerprint = keyData.keyPacket.getFingerprint();
// keyData = await fetchKeys(opts);
} catch (e) { } catch (e) {
feedback += `<p>There was a problem fetching the keys.</p>`; feedback += `<p>There was a problem fetching the keys.</p>`;
feedback += `<code>${e}</code>`; feedback += `<code>${e}</code>`;
@ -1026,6 +1031,7 @@ let elFormVerify = document.body.querySelector("#form-verify"),
elFormProofs = document.body.querySelector("#form-proofs"), elFormProofs = document.body.querySelector("#form-proofs"),
elProfileUid = document.body.querySelector("#profileUid"), elProfileUid = document.body.querySelector("#profileUid"),
elProfileMode = document.body.querySelector("#profileMode"), elProfileMode = document.body.querySelector("#profileMode"),
elProfileServer = document.body.querySelector("#profileServer"),
elModeSelect = document.body.querySelector("#modeSelect"), elModeSelect = document.body.querySelector("#modeSelect"),
elUtilWKD = document.body.querySelector("#form-util-wkd"), elUtilWKD = document.body.querySelector("#form-util-wkd"),
elUtilQRFP = document.body.querySelector("#form-util-qrfp"), elUtilQRFP = document.body.querySelector("#form-util-qrfp"),
@ -1171,7 +1177,7 @@ if (elFormProofs) {
} }
if (elProfileUid) { if (elProfileUid) {
let match, opts, profileUid = elProfileUid.innerHTML; let opts, profileUid = elProfileUid.innerHTML;
switch (elProfileMode.innerHTML) { switch (elProfileMode.innerHTML) {
default: default:
case "auto": case "auto":
@ -1191,6 +1197,13 @@ if (elProfileUid) {
break; break;
case "hkp": case "hkp":
opts = {
input: profileUid,
server: elProfileServer.innerHTML,
mode: elProfileMode.innerHTML
}
break;
case "wkd": case "wkd":
opts = { opts = {
input: profileUid, input: profileUid,

View file

@ -9,6 +9,7 @@ head
main.container.container--profile main.container.container--profile
.content .content
span#profileUid(style='display: none;') #{uid} span#profileUid(style='display: none;') #{uid}
span#profileServer(style='display: none;') #{server}
span#profileMode(style='display: none;') #{mode} span#profileMode(style='display: none;') #{mode}
#profileHeader #profileHeader
img#profileAvatar(src='/static/img/avatar_placeholder.png' alt='avatar' style='display: none') img#profileAvatar(src='/static/img/avatar_placeholder.png' alt='avatar' style='display: none')