diff --git a/src/claims.js b/src/claims.js index 015aeca..b17ddf8 100644 --- a/src/claims.js +++ b/src/claims.js @@ -22,16 +22,22 @@ const keys = require('./keys') const utils = require('./utils') // Promise.allSettled polyfill -Promise.allSettled = Promise.allSettled || ((promises) => Promise.all(promises.map(p => p - .then(v => ({ - status: 'fulfilled', - value: v, - })) - .catch(e => ({ - status: 'rejected', - reason: e, - })) -))); +Promise.allSettled = + Promise.allSettled || + ((promises) => + Promise.all( + promises.map((p) => + p + .then((v) => ({ + status: 'fulfilled', + value: v, + })) + .catch((e) => ({ + status: 'rejected', + reason: e, + })) + ) + )) const runVerificationJson = ( res, diff --git a/src/keys.js b/src/keys.js index bfa24f8..eff39a0 100644 --- a/src/keys.js +++ b/src/keys.js @@ -31,18 +31,18 @@ const fetchHKP = (identifier, keyserverBaseUrl) => { query: identifier, } - let publicKey = await hkp.lookup(lookupOpts) - .catch((error) => { + let publicKey = await hkp.lookup(lookupOpts).catch((error) => { reject('Key does not exist or could not be fetched') }) - - publicKey = await openpgp.key.readArmored(publicKey) - .then((result) => { - return result.keys[0] - }) - .catch((error) => { - return null - }) + + publicKey = await openpgp.key + .readArmored(publicKey) + .then((result) => { + return result.keys[0] + }) + .catch((error) => { + return null + }) if (publicKey) { resolve(publicKey) @@ -59,13 +59,14 @@ const fetchWKD = (identifier) => { email: identifier, } - const publicKey = await wkd.lookup(lookupOpts) - .then((result) => { - return result.keys[0] - }) - .catch((error) => { - return null - }) + const publicKey = await wkd + .lookup(lookupOpts) + .then((result) => { + return result.keys[0] + }) + .catch((error) => { + return null + }) if (publicKey) { resolve(publicKey) @@ -89,14 +90,15 @@ const fetchKeybase = (username, fingerprint) => { } catch (e) { reject(`Error fetching Keybase key: ${e.message}`) } - - const publicKey = await openpgp.key.readArmored(rawKeyContent) - .then((result) => { - return result.keys[0] - }) - .catch((error) => { - return null - }) + + const publicKey = await openpgp.key + .readArmored(rawKeyContent) + .then((result) => { + return result.keys[0] + }) + .catch((error) => { + return null + }) if (publicKey) { resolve(publicKey) diff --git a/src/serviceproviders/twitter.js b/src/serviceproviders/twitter.js index 03f9cec..21ddb7a 100644 --- a/src/serviceproviders/twitter.js +++ b/src/serviceproviders/twitter.js @@ -23,7 +23,7 @@ const customRequestHandler = async (spData, opts) => { const client = new Twitter({ bearer_token: opts.twitterBearerToken, }) - const res = await client.get('statuses/show', {id: match[2]}) + const res = await client.get('statuses/show', { id: match[2] }) return res.text } else if ('nitterInstance' in opts && opts.nitterInstance) { spData.proof.fetch = `https://${opts.nitterInstance}/${match[1]}/status/${match[2]}` diff --git a/src/signatures.js b/src/signatures.js index d178293..ddfccc8 100644 --- a/src/signatures.js +++ b/src/signatures.js @@ -66,14 +66,14 @@ const verify = (signature, opts) => { try { keyUri = sigKeys[0] keyData = await keys.fetch.uri(keyUri) - } catch(e) {} + } catch (e) {} } // Try WKD if (!keyData && signersUserId) { try { keyUri = `wkd:${signersUserId}` keyData = await keys.fetch.uri(keyUri) - } catch(e) {} + } catch (e) {} } // Try HKP if (!keyData) { @@ -81,7 +81,7 @@ const verify = (signature, opts) => { const match = preferredKeyServer.match(/^(.*\:\/\/)?([^/]*)(?:\/)?$/i) keyUri = `hkp:${match[2]}:${issuerKeyId ? issuerKeyId : signersUserId}` keyData = await keys.fetch.uri(keyUri) - } catch(e) { + } catch (e) { errors.push('key_not_found') reject({ errors: errors }) return