mirror of
https://codeberg.org/keyoxide/doipjs.git
synced 2024-12-22 22:49:28 -07:00
Run prettier
This commit is contained in:
parent
0bb3a59964
commit
95ac04b838
4 changed files with 47 additions and 39 deletions
|
@ -22,16 +22,22 @@ const keys = require('./keys')
|
||||||
const utils = require('./utils')
|
const utils = require('./utils')
|
||||||
|
|
||||||
// Promise.allSettled polyfill
|
// Promise.allSettled polyfill
|
||||||
Promise.allSettled = Promise.allSettled || ((promises) => Promise.all(promises.map(p => p
|
Promise.allSettled =
|
||||||
.then(v => ({
|
Promise.allSettled ||
|
||||||
status: 'fulfilled',
|
((promises) =>
|
||||||
value: v,
|
Promise.all(
|
||||||
}))
|
promises.map((p) =>
|
||||||
.catch(e => ({
|
p
|
||||||
status: 'rejected',
|
.then((v) => ({
|
||||||
reason: e,
|
status: 'fulfilled',
|
||||||
}))
|
value: v,
|
||||||
)));
|
}))
|
||||||
|
.catch((e) => ({
|
||||||
|
status: 'rejected',
|
||||||
|
reason: e,
|
||||||
|
}))
|
||||||
|
)
|
||||||
|
))
|
||||||
|
|
||||||
const runVerificationJson = (
|
const runVerificationJson = (
|
||||||
res,
|
res,
|
||||||
|
|
52
src/keys.js
52
src/keys.js
|
@ -31,18 +31,18 @@ const fetchHKP = (identifier, keyserverBaseUrl) => {
|
||||||
query: identifier,
|
query: identifier,
|
||||||
}
|
}
|
||||||
|
|
||||||
let publicKey = await hkp.lookup(lookupOpts)
|
let publicKey = await hkp.lookup(lookupOpts).catch((error) => {
|
||||||
.catch((error) => {
|
|
||||||
reject('Key does not exist or could not be fetched')
|
reject('Key does not exist or could not be fetched')
|
||||||
})
|
})
|
||||||
|
|
||||||
publicKey = await openpgp.key.readArmored(publicKey)
|
publicKey = await openpgp.key
|
||||||
.then((result) => {
|
.readArmored(publicKey)
|
||||||
return result.keys[0]
|
.then((result) => {
|
||||||
})
|
return result.keys[0]
|
||||||
.catch((error) => {
|
})
|
||||||
return null
|
.catch((error) => {
|
||||||
})
|
return null
|
||||||
|
})
|
||||||
|
|
||||||
if (publicKey) {
|
if (publicKey) {
|
||||||
resolve(publicKey)
|
resolve(publicKey)
|
||||||
|
@ -59,13 +59,14 @@ const fetchWKD = (identifier) => {
|
||||||
email: identifier,
|
email: identifier,
|
||||||
}
|
}
|
||||||
|
|
||||||
const publicKey = await wkd.lookup(lookupOpts)
|
const publicKey = await wkd
|
||||||
.then((result) => {
|
.lookup(lookupOpts)
|
||||||
return result.keys[0]
|
.then((result) => {
|
||||||
})
|
return result.keys[0]
|
||||||
.catch((error) => {
|
})
|
||||||
return null
|
.catch((error) => {
|
||||||
})
|
return null
|
||||||
|
})
|
||||||
|
|
||||||
if (publicKey) {
|
if (publicKey) {
|
||||||
resolve(publicKey)
|
resolve(publicKey)
|
||||||
|
@ -89,14 +90,15 @@ const fetchKeybase = (username, fingerprint) => {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
reject(`Error fetching Keybase key: ${e.message}`)
|
reject(`Error fetching Keybase key: ${e.message}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const publicKey = await openpgp.key.readArmored(rawKeyContent)
|
const publicKey = await openpgp.key
|
||||||
.then((result) => {
|
.readArmored(rawKeyContent)
|
||||||
return result.keys[0]
|
.then((result) => {
|
||||||
})
|
return result.keys[0]
|
||||||
.catch((error) => {
|
})
|
||||||
return null
|
.catch((error) => {
|
||||||
})
|
return null
|
||||||
|
})
|
||||||
|
|
||||||
if (publicKey) {
|
if (publicKey) {
|
||||||
resolve(publicKey)
|
resolve(publicKey)
|
||||||
|
|
|
@ -23,7 +23,7 @@ const customRequestHandler = async (spData, opts) => {
|
||||||
const client = new Twitter({
|
const client = new Twitter({
|
||||||
bearer_token: opts.twitterBearerToken,
|
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
|
return res.text
|
||||||
} else if ('nitterInstance' in opts && opts.nitterInstance) {
|
} else if ('nitterInstance' in opts && opts.nitterInstance) {
|
||||||
spData.proof.fetch = `https://${opts.nitterInstance}/${match[1]}/status/${match[2]}`
|
spData.proof.fetch = `https://${opts.nitterInstance}/${match[1]}/status/${match[2]}`
|
||||||
|
|
|
@ -66,14 +66,14 @@ const verify = (signature, opts) => {
|
||||||
try {
|
try {
|
||||||
keyUri = sigKeys[0]
|
keyUri = sigKeys[0]
|
||||||
keyData = await keys.fetch.uri(keyUri)
|
keyData = await keys.fetch.uri(keyUri)
|
||||||
} catch(e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
// Try WKD
|
// Try WKD
|
||||||
if (!keyData && signersUserId) {
|
if (!keyData && signersUserId) {
|
||||||
try {
|
try {
|
||||||
keyUri = `wkd:${signersUserId}`
|
keyUri = `wkd:${signersUserId}`
|
||||||
keyData = await keys.fetch.uri(keyUri)
|
keyData = await keys.fetch.uri(keyUri)
|
||||||
} catch(e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
// Try HKP
|
// Try HKP
|
||||||
if (!keyData) {
|
if (!keyData) {
|
||||||
|
@ -81,7 +81,7 @@ const verify = (signature, opts) => {
|
||||||
const match = preferredKeyServer.match(/^(.*\:\/\/)?([^/]*)(?:\/)?$/i)
|
const match = preferredKeyServer.match(/^(.*\:\/\/)?([^/]*)(?:\/)?$/i)
|
||||||
keyUri = `hkp:${match[2]}:${issuerKeyId ? issuerKeyId : signersUserId}`
|
keyUri = `hkp:${match[2]}:${issuerKeyId ? issuerKeyId : signersUserId}`
|
||||||
keyData = await keys.fetch.uri(keyUri)
|
keyData = await keys.fetch.uri(keyUri)
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
errors.push('key_not_found')
|
errors.push('key_not_found')
|
||||||
reject({ errors: errors })
|
reject({ errors: errors })
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue