diff --git a/src/api/v3/keyoxide_profile.js b/src/api/v3/keyoxide_profile.js index ef637a0..3c56e39 100644 --- a/src/api/v3/keyoxide_profile.js +++ b/src/api/v3/keyoxide_profile.js @@ -77,9 +77,9 @@ const doVerification = async (profile) => { } await Promise.all(promises) - results.forEach(result => { + for (const result of results) { profile.personas[result[0]].claims[result[1]] = result[2] - }) + } return profile } diff --git a/src/index.js b/src/index.js index faf331d..fb0aa89 100644 --- a/src/index.js +++ b/src/index.js @@ -30,8 +30,8 @@ more information on this, and how to apply and follow the GNU AGPL, see { if (!req.query.resource) { res.status(400).send() return - } else if (![body.subject, ...body.aliases].includes(req.query.resource)) { + } + if (![body.subject, ...body.aliases].includes(req.query.resource)) { res.status(404).send() return } diff --git a/src/routes/util.js b/src/routes/util.js index 1d42175..d221185 100644 --- a/src/routes/util.js +++ b/src/routes/util.js @@ -32,60 +32,60 @@ import { escapedParam, getMetaFromReq } from '../server/utils.js' const router = express.Router() -router.get('/', function (req, res) { +router.get('/', (req, res) => { res.render('util/index', { meta: getMetaFromReq(req) }) }) -router.get('/profile-url', function (req, res) { +router.get('/profile-url', (req, res) => { res.render('util/profile-url', { meta: getMetaFromReq(req) }) }) router.get('/profile-url/:input', escapedParam('input'), - function (req, res) { + (req, res) => { res.render('util/profile-url', { input: req.params.input, meta: getMetaFromReq(req) }) }) -router.get('/qr', function (req, res) { +router.get('/qr', (req, res) => { res.render('util/qr', { meta: getMetaFromReq(req) }) }) router.get('/qr/:input', escapedParam('input'), - function (req, res) { + (req, res) => { res.render('util/qr', { input: req.params.input, meta: getMetaFromReq(req) }) }) -router.get('/qrfp', function (req, res) { +router.get('/qrfp', (req, res) => { res.render('util/qrfp', { meta: getMetaFromReq(req) }) }) router.get('/qrfp/:input', escapedParam('input'), - function (req, res) { + (req, res) => { res.render('util/qrfp', { input: req.params.input, meta: getMetaFromReq(req) }) }) -router.get('/wkd', function (req, res) { +router.get('/wkd', (req, res) => { res.render('util/wkd', { meta: getMetaFromReq(req) }) }) router.get('/wkd/:input', escapedParam('input'), - function (req, res) { + (req, res) => { res.render('util/wkd', { input: req.params.input, meta: getMetaFromReq(req) }) }) -router.get('/argon2', function (req, res) { +router.get('/argon2', (req, res) => { res.render('util/argon2', { meta: getMetaFromReq(req) }) }) router.get('/argon2/:input', escapedParam('input'), - function (req, res) { + (req, res) => { res.render('util/argon2', { input: req.params.input, meta: getMetaFromReq(req) }) }) -router.get('/bcrypt', function (req, res) { +router.get('/bcrypt', (req, res) => { res.render('util/bcrypt', { meta: getMetaFromReq(req) }) }) router.get('/bcrypt/:input', escapedParam('input'), - function (req, res) { + (req, res) => { res.render('util/bcrypt', { input: req.params.input, meta: getMetaFromReq(req) }) }) diff --git a/src/server/index.js b/src/server/index.js index cb453f4..c880b6b 100644 --- a/src/server/index.js +++ b/src/server/index.js @@ -205,16 +205,16 @@ const generateKeybaseProfile = async (username, fingerprint) => { } const processAspProfile = async (/** @type {import('doipjs').Profile */ profile) => { - profile.personas.forEach(persona => { + for (const persona of profile.personas) { // Remove faulty claims persona.claims = persona.claims.filter(claim => { return claim instanceof doipjs.Claim }) // Match claims - persona.claims.forEach(claim => { + for (const claim of persona.claims) { claim.match() - }) + } // Sort claims persona.claims.sort((a, b) => { @@ -229,7 +229,7 @@ const processAspProfile = async (/** @type {import('doipjs').Profile */ profile) } return 0 }) - }) + } // Overwrite avatarUrl // TODO: don't overwrite avatarUrl once it's fully supported @@ -240,16 +240,16 @@ const processAspProfile = async (/** @type {import('doipjs').Profile */ profile) } const processOpenPgpProfile = async (/** @type {import('doipjs').Profile */ profile) => { - profile.personas.forEach(persona => { + for (const persona of profile.personas) { // Remove faulty claims persona.claims = persona.claims.filter(claim => { return claim instanceof doipjs.Claim }) // Match claims - persona.claims.forEach(claim => { + for (const claim of persona.claims) { claim.match() - }) + } // Sort claims persona.claims.sort((a, b) => { @@ -264,7 +264,7 @@ const processOpenPgpProfile = async (/** @type {import('doipjs').Profile */ prof } return 0 }) - }) + } // Overwrite avatarUrl // TODO: don't overwrite avatarUrl once it's fully supported diff --git a/src/server/openpgpProfiles.js b/src/server/openpgpProfiles.js index b6605e7..b5180e2 100644 --- a/src/server/openpgpProfiles.js +++ b/src/server/openpgpProfiles.js @@ -32,7 +32,7 @@ import got from 'got' import * as doipjs from 'doipjs' import { readKey } from 'openpgp' import { computeWKDLocalPart } from './utils.js' -import { createHash } from 'crypto' +import { createHash } from 'node:crypto' import Keyv from 'keyv' let c = null @@ -82,9 +82,8 @@ const fetchWKD = (id) => { if (response.statusCode === 200) { fetchURL = urlAdvanced return new Uint8Array(response.rawBody) - } else { - return null } + return null }) } catch (errorAdvanced) { logger.debug('Failed to fetch an OpenPGP profile via WKD (advanced URL)', @@ -95,9 +94,8 @@ const fetchWKD = (id) => { if (response.statusCode === 200) { fetchURL = urlDirect return new Uint8Array(response.rawBody) - } else { - return null } + return null }) } catch (errorDirect) { logger.debug('Failed to fetch an OpenPGP profile via WKD (direct URL)', diff --git a/src/server/utils.js b/src/server/utils.js index 894fa6d..3699c7b 100644 --- a/src/server/utils.js +++ b/src/server/utils.js @@ -27,7 +27,7 @@ You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see . */ -import { webcrypto as crypto } from 'crypto' +import { webcrypto as crypto } from 'node:crypto' import { Profile } from 'doipjs' import Color from 'colorjs.io' import { param } from 'express-validator'