mirror of
https://codeberg.org/keyoxide/keyoxide-web.git
synced 2025-01-10 15:19:28 -07:00
Use data provided by doip sig verify
This commit is contained in:
parent
91999ca3b7
commit
a0dd7cd363
1 changed files with 8 additions and 35 deletions
|
@ -241,37 +241,8 @@ async function displayProfile(opts) {
|
||||||
if (opts.mode == 'sig') {
|
if (opts.mode == 'sig') {
|
||||||
try {
|
try {
|
||||||
sigVerification = await doip.signatures.verify(opts.input);
|
sigVerification = await doip.signatures.verify(opts.input);
|
||||||
|
keyData = sigVerification.publicKey.data;
|
||||||
if (sigVerification.errors.length > 0) {
|
fingerprint = sigVerification.publicKey.fingerprint;
|
||||||
throw(sigVerification.errors.join(', '))
|
|
||||||
}
|
|
||||||
|
|
||||||
keyData = sigVerification.publicKey
|
|
||||||
fingerprint = sigVerification.fingerprint
|
|
||||||
|
|
||||||
const sigData = await openpgp.cleartext.readArmored(opts.input);
|
|
||||||
const sigText = sigData.getText();
|
|
||||||
let sigKeys = [];
|
|
||||||
sigText.split('\n').forEach((line, i) => {
|
|
||||||
const match = line.match(/^(.*)\=(.*)$/i);
|
|
||||||
if (!match || !match[1]) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
switch (match[1].toLowerCase()) {
|
|
||||||
case 'key':
|
|
||||||
sigKeys.push(match[2]);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (sigKeys.length === 0) {
|
|
||||||
throw('No key URI found');
|
|
||||||
}
|
|
||||||
|
|
||||||
sigKeyUri = sigKeys[0];
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
feedback += `<p>There was a problem reading the signature.</p>`;
|
feedback += `<p>There was a problem reading the signature.</p>`;
|
||||||
feedback += `<code>${e}</code>`;
|
feedback += `<code>${e}</code>`;
|
||||||
|
@ -307,11 +278,13 @@ async function displayProfile(opts) {
|
||||||
|
|
||||||
// Determine WKD or HKP link
|
// Determine WKD or HKP link
|
||||||
let keyUriMode = opts.mode;
|
let keyUriMode = opts.mode;
|
||||||
|
let keyUriServer = null;
|
||||||
let keyUriId = opts.input;
|
let keyUriId = opts.input;
|
||||||
if (opts.mode === 'sig') {
|
if (opts.mode === 'sig') {
|
||||||
const keyUriMatch = sigKeyUri.match(/(.*):(.*)/);
|
const keyUriMatch = sigVerification.publicKey.uri.match(/([^:]*)(?:\:(.*))?:(.*)/);
|
||||||
keyUriMode = keyUriMatch[1];
|
keyUriMode = keyUriMatch[1];
|
||||||
keyUriId = keyUriMatch[2];
|
keyUriServer = keyUriMatch[2];
|
||||||
|
keyUriId = keyUriMatch[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (keyUriMode) {
|
switch (keyUriMode) {
|
||||||
|
@ -342,12 +315,12 @@ async function displayProfile(opts) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!keyLink) {
|
if (!keyLink) {
|
||||||
keyLink = `https://keys.openpgp.org/pks/lookup?op=get&options=mr&search=0x${fingerprint}`;
|
keyLink = `https://${keyUriServer ? keyUriServer : 'keys.openpgp.org'}/pks/lookup?op=get&options=mr&search=0x${fingerprint}`;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "hkp":
|
case "hkp":
|
||||||
keyLink = `https://keys.openpgp.org/pks/lookup?op=get&options=mr&search=0x${fingerprint}`;
|
keyLink = `https://${keyUriServer ? keyUriServer : 'keys.openpgp.org'}/pks/lookup?op=get&options=mr&search=0x${fingerprint}`;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "keybase":
|
case "keybase":
|
||||||
|
|
Loading…
Reference in a new issue