Merge branch 'dev' into configurable-scheme

This commit is contained in:
Preston Maness 2023-09-10 22:17:02 -05:00
commit 8793b2e15d
2 changed files with 14 additions and 16 deletions

View file

@ -44,10 +44,10 @@
}, },
"scripts": { "scripts": {
"start": "node --experimental-fetch ./", "start": "node --experimental-fetch ./",
"dev": "LOG_LEVEL=debug yarn run watch & yarn run build:static:dev", "dev": "LOG_LEVEL=debug yarn run watch && yarn run build:static:dev",
"test": "yarn run lint && mocha --loader=esmock", "test": "yarn run lint && mocha --loader=esmock",
"watch": "./node_modules/.bin/nodemon --config nodemon.json ./", "watch": "./node_modules/.bin/nodemon --config nodemon.json ./",
"build": "yarn run build:server & yarn run build:static", "build": "yarn run build:server && yarn run build:static",
"build:server": "ncc build ./src/index.js -o dist", "build:server": "ncc build ./src/index.js -o dist",
"build:static": "webpack --config webpack.config.js --env static=true --env mode=production", "build:static": "webpack --config webpack.config.js --env static=true --env mode=production",
"build:static:dev": "webpack --config webpack.config.js --env static=true --env mode=development", "build:static:dev": "webpack --config webpack.config.js --env static=true --env mode=development",

View file

@ -44,12 +44,12 @@ const fetchWKD = (id) => {
let fetchURL = null let fetchURL = null
if (!id.includes('@')) { if (!id.includes('@')) {
reject(new Error(`The WKD identifier "${id}" is invalid`)) return reject(new Error(`The WKD identifier "${id}" is invalid`))
} }
const [, localPart, domain] = /([^@]*)@(.*)/.exec(id) const [, localPart, domain] = /([^@]*)@(.*)/.exec(id)
if (!(localPart && domain)) { if (!(localPart && domain)) {
reject(new Error(`The WKD identifier "${id}" is invalid`)) return reject(new Error(`The WKD identifier "${id}" is invalid`))
} }
const localEncoded = await computeWKDLocalPart(localPart) const localEncoded = await computeWKDLocalPart(localPart)
const urlAdvanced = `https://openpgpkey.${domain}/.well-known/openpgpkey/${domain}/hu/${localEncoded}` const urlAdvanced = `https://openpgpkey.${domain}/.well-known/openpgpkey/${domain}/hu/${localEncoded}`
@ -82,12 +82,12 @@ const fetchWKD = (id) => {
} }
}) })
} catch (error) { } catch (error) {
reject(new Error('No public keys could be fetched using WKD')) return reject(new Error('No public keys could be fetched using WKD'))
} }
} }
if (!plaintext) { if (!plaintext) {
reject(new Error('No public keys could be fetched using WKD')) return reject(new Error('No public keys could be fetched using WKD'))
} }
try { try {
@ -95,18 +95,17 @@ const fetchWKD = (id) => {
binaryKey: plaintext binaryKey: plaintext
}) })
} catch (error) { } catch (error) {
reject(new Error('No public keys could be read from the data fetched using WKD')) return reject(new Error('No public keys could be read from the data fetched using WKD'))
} }
if (!publicKey) { if (!publicKey) {
reject(new Error('No public keys could be read from the data fetched using WKD')) return reject(new Error('No public keys could be read from the data fetched using WKD'))
} }
try { try {
profile = await doipjs.openpgp.parsePublicKey(publicKey) profile = await doipjs.openpgp.parsePublicKey(publicKey)
} catch (error) { } catch (error) {
reject(new Error('No public keys could be fetched using WKD')) return reject(new Error('No public keys could be fetched using WKD'))
return
} }
profile.publicKey.fetch.method = 'wkd' profile.publicKey.fetch.method = 'wkd'
@ -160,8 +159,7 @@ const fetchHKP = (id, keyserverDomain) => {
} }
if (!profile) { if (!profile) {
reject(new Error('No public keys could be fetched using HKP')) return reject(new Error('No public keys could be fetched using HKP'))
return
} }
profile.publicKey.fetch.method = 'hkp' profile.publicKey.fetch.method = 'hkp'
@ -187,12 +185,12 @@ const fetchSignature = (signature) => {
profile = await doipjs.signatures.parse(signature) profile = await doipjs.signatures.parse(signature)
// TODO Find the URL to the key // TODO Find the URL to the key
} catch (error) { } catch (error) {
reject(new Error(`Signature could not be properly read (${error.message})`)) return reject(new Error(`Signature could not be properly read (${error.message})`))
} }
// Check if a key was fetched // Check if a key was fetched
if (!profile) { if (!profile) {
reject(new Error('No profile could be fetched')) return reject(new Error('No profile could be fetched'))
} }
resolve(profile) resolve(profile)
@ -210,11 +208,11 @@ const fetchKeybase = (username, fingerprint) => {
profile = await doipjs.openpgp.fetchKeybase(username, fingerprint) profile = await doipjs.openpgp.fetchKeybase(username, fingerprint)
fetchURL = `https://keybase.io/${username}/pgp_keys.asc?fingerprint=${fingerprint}` fetchURL = `https://keybase.io/${username}/pgp_keys.asc?fingerprint=${fingerprint}`
} catch (error) { } catch (error) {
reject(new Error('No public keys could be fetched from Keybase')) return reject(new Error('No public keys could be fetched from Keybase'))
} }
if (!profile) { if (!profile) {
reject(new Error('No public keys could be fetched from Keybase')) return reject(new Error('No public keys could be fetched from Keybase'))
} }
profile.publicKey.fetch.method = 'http' profile.publicKey.fetch.method = 'http'