mirror of
https://codeberg.org/keyoxide/keyoxide-web.git
synced 2024-12-22 14:59:29 -07:00
fix: apply biome fixes
This commit is contained in:
parent
e0297d90fb
commit
c4b8423c6a
7 changed files with 32 additions and 33 deletions
|
@ -77,9 +77,9 @@ const doVerification = async (profile) => {
|
||||||
}
|
}
|
||||||
await Promise.all(promises)
|
await Promise.all(promises)
|
||||||
|
|
||||||
results.forEach(result => {
|
for (const result of results) {
|
||||||
profile.personas[result[0]].claims[result[1]] = result[2]
|
profile.personas[result[0]].claims[result[1]] = result[2]
|
||||||
})
|
}
|
||||||
|
|
||||||
return profile
|
return profile
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,8 @@ more information on this, and how to apply and follow the GNU AGPL, see <https:/
|
||||||
import express from 'express'
|
import express from 'express'
|
||||||
import * as httpContext from 'express-http-context2'
|
import * as httpContext from 'express-http-context2'
|
||||||
import { nanoid } from 'nanoid'
|
import { nanoid } from 'nanoid'
|
||||||
import { readFileSync } from 'fs'
|
import { readFileSync } from 'node:fs'
|
||||||
import { execSync } from 'child_process'
|
import { execSync } from 'node:child_process'
|
||||||
import { stringReplace } from 'string-replace-middleware'
|
import { stringReplace } from 'string-replace-middleware'
|
||||||
import * as pug from 'pug'
|
import * as pug from 'pug'
|
||||||
import * as dotenv from 'dotenv'
|
import * as dotenv from 'dotenv'
|
||||||
|
|
|
@ -29,7 +29,7 @@ more information on this, and how to apply and follow the GNU AGPL, see <https:/
|
||||||
*/
|
*/
|
||||||
import express from 'express'
|
import express from 'express'
|
||||||
import markdownImport from 'markdown-it'
|
import markdownImport from 'markdown-it'
|
||||||
import { readFileSync } from 'fs'
|
import { readFileSync } from 'node:fs'
|
||||||
import { getMetaFromReq } from '../server/utils.js'
|
import { getMetaFromReq } from '../server/utils.js'
|
||||||
|
|
||||||
const router = express.Router()
|
const router = express.Router()
|
||||||
|
@ -74,7 +74,8 @@ router.get('/.well-known/webfinger', (req, res) => {
|
||||||
if (!req.query.resource) {
|
if (!req.query.resource) {
|
||||||
res.status(400).send()
|
res.status(400).send()
|
||||||
return
|
return
|
||||||
} else if (![body.subject, ...body.aliases].includes(req.query.resource)) {
|
}
|
||||||
|
if (![body.subject, ...body.aliases].includes(req.query.resource)) {
|
||||||
res.status(404).send()
|
res.status(404).send()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,60 +32,60 @@ import { escapedParam, getMetaFromReq } from '../server/utils.js'
|
||||||
|
|
||||||
const router = express.Router()
|
const router = express.Router()
|
||||||
|
|
||||||
router.get('/', function (req, res) {
|
router.get('/', (req, res) => {
|
||||||
res.render('util/index', { meta: getMetaFromReq(req) })
|
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) })
|
res.render('util/profile-url', { meta: getMetaFromReq(req) })
|
||||||
})
|
})
|
||||||
router.get('/profile-url/:input',
|
router.get('/profile-url/:input',
|
||||||
escapedParam('input'),
|
escapedParam('input'),
|
||||||
function (req, res) {
|
(req, res) => {
|
||||||
res.render('util/profile-url', { input: req.params.input, meta: getMetaFromReq(req) })
|
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) })
|
res.render('util/qr', { meta: getMetaFromReq(req) })
|
||||||
})
|
})
|
||||||
router.get('/qr/:input',
|
router.get('/qr/:input',
|
||||||
escapedParam('input'),
|
escapedParam('input'),
|
||||||
function (req, res) {
|
(req, res) => {
|
||||||
res.render('util/qr', { input: req.params.input, meta: getMetaFromReq(req) })
|
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) })
|
res.render('util/qrfp', { meta: getMetaFromReq(req) })
|
||||||
})
|
})
|
||||||
router.get('/qrfp/:input',
|
router.get('/qrfp/:input',
|
||||||
escapedParam('input'),
|
escapedParam('input'),
|
||||||
function (req, res) {
|
(req, res) => {
|
||||||
res.render('util/qrfp', { input: req.params.input, meta: getMetaFromReq(req) })
|
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) })
|
res.render('util/wkd', { meta: getMetaFromReq(req) })
|
||||||
})
|
})
|
||||||
router.get('/wkd/:input',
|
router.get('/wkd/:input',
|
||||||
escapedParam('input'),
|
escapedParam('input'),
|
||||||
function (req, res) {
|
(req, res) => {
|
||||||
res.render('util/wkd', { input: req.params.input, meta: getMetaFromReq(req) })
|
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) })
|
res.render('util/argon2', { meta: getMetaFromReq(req) })
|
||||||
})
|
})
|
||||||
router.get('/argon2/:input',
|
router.get('/argon2/:input',
|
||||||
escapedParam('input'),
|
escapedParam('input'),
|
||||||
function (req, res) {
|
(req, res) => {
|
||||||
res.render('util/argon2', { input: req.params.input, meta: getMetaFromReq(req) })
|
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) })
|
res.render('util/bcrypt', { meta: getMetaFromReq(req) })
|
||||||
})
|
})
|
||||||
router.get('/bcrypt/:input',
|
router.get('/bcrypt/:input',
|
||||||
escapedParam('input'),
|
escapedParam('input'),
|
||||||
function (req, res) {
|
(req, res) => {
|
||||||
res.render('util/bcrypt', { input: req.params.input, meta: getMetaFromReq(req) })
|
res.render('util/bcrypt', { input: req.params.input, meta: getMetaFromReq(req) })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -205,16 +205,16 @@ const generateKeybaseProfile = async (username, fingerprint) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const processAspProfile = async (/** @type {import('doipjs').Profile */ profile) => {
|
const processAspProfile = async (/** @type {import('doipjs').Profile */ profile) => {
|
||||||
profile.personas.forEach(persona => {
|
for (const persona of profile.personas) {
|
||||||
// Remove faulty claims
|
// Remove faulty claims
|
||||||
persona.claims = persona.claims.filter(claim => {
|
persona.claims = persona.claims.filter(claim => {
|
||||||
return claim instanceof doipjs.Claim
|
return claim instanceof doipjs.Claim
|
||||||
})
|
})
|
||||||
|
|
||||||
// Match claims
|
// Match claims
|
||||||
persona.claims.forEach(claim => {
|
for (const claim of persona.claims) {
|
||||||
claim.match()
|
claim.match()
|
||||||
})
|
}
|
||||||
|
|
||||||
// Sort claims
|
// Sort claims
|
||||||
persona.claims.sort((a, b) => {
|
persona.claims.sort((a, b) => {
|
||||||
|
@ -229,7 +229,7 @@ const processAspProfile = async (/** @type {import('doipjs').Profile */ profile)
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
|
|
||||||
// Overwrite avatarUrl
|
// Overwrite avatarUrl
|
||||||
// TODO: don't overwrite avatarUrl once it's fully supported
|
// 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) => {
|
const processOpenPgpProfile = async (/** @type {import('doipjs').Profile */ profile) => {
|
||||||
profile.personas.forEach(persona => {
|
for (const persona of profile.personas) {
|
||||||
// Remove faulty claims
|
// Remove faulty claims
|
||||||
persona.claims = persona.claims.filter(claim => {
|
persona.claims = persona.claims.filter(claim => {
|
||||||
return claim instanceof doipjs.Claim
|
return claim instanceof doipjs.Claim
|
||||||
})
|
})
|
||||||
|
|
||||||
// Match claims
|
// Match claims
|
||||||
persona.claims.forEach(claim => {
|
for (const claim of persona.claims) {
|
||||||
claim.match()
|
claim.match()
|
||||||
})
|
}
|
||||||
|
|
||||||
// Sort claims
|
// Sort claims
|
||||||
persona.claims.sort((a, b) => {
|
persona.claims.sort((a, b) => {
|
||||||
|
@ -264,7 +264,7 @@ const processOpenPgpProfile = async (/** @type {import('doipjs').Profile */ prof
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
|
|
||||||
// Overwrite avatarUrl
|
// Overwrite avatarUrl
|
||||||
// TODO: don't overwrite avatarUrl once it's fully supported
|
// TODO: don't overwrite avatarUrl once it's fully supported
|
||||||
|
|
|
@ -32,7 +32,7 @@ import got from 'got'
|
||||||
import * as doipjs from 'doipjs'
|
import * as doipjs from 'doipjs'
|
||||||
import { readKey } from 'openpgp'
|
import { readKey } from 'openpgp'
|
||||||
import { computeWKDLocalPart } from './utils.js'
|
import { computeWKDLocalPart } from './utils.js'
|
||||||
import { createHash } from 'crypto'
|
import { createHash } from 'node:crypto'
|
||||||
import Keyv from 'keyv'
|
import Keyv from 'keyv'
|
||||||
|
|
||||||
let c = null
|
let c = null
|
||||||
|
@ -82,9 +82,8 @@ const fetchWKD = (id) => {
|
||||||
if (response.statusCode === 200) {
|
if (response.statusCode === 200) {
|
||||||
fetchURL = urlAdvanced
|
fetchURL = urlAdvanced
|
||||||
return new Uint8Array(response.rawBody)
|
return new Uint8Array(response.rawBody)
|
||||||
} else {
|
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
|
return null
|
||||||
})
|
})
|
||||||
} catch (errorAdvanced) {
|
} catch (errorAdvanced) {
|
||||||
logger.debug('Failed to fetch an OpenPGP profile via WKD (advanced URL)',
|
logger.debug('Failed to fetch an OpenPGP profile via WKD (advanced URL)',
|
||||||
|
@ -95,9 +94,8 @@ const fetchWKD = (id) => {
|
||||||
if (response.statusCode === 200) {
|
if (response.statusCode === 200) {
|
||||||
fetchURL = urlDirect
|
fetchURL = urlDirect
|
||||||
return new Uint8Array(response.rawBody)
|
return new Uint8Array(response.rawBody)
|
||||||
} else {
|
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
|
return null
|
||||||
})
|
})
|
||||||
} catch (errorDirect) {
|
} catch (errorDirect) {
|
||||||
logger.debug('Failed to fetch an OpenPGP profile via WKD (direct URL)',
|
logger.debug('Failed to fetch an OpenPGP profile via WKD (direct URL)',
|
||||||
|
|
|
@ -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
|
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 <https://www.gnu.org/licenses/>.
|
more information on this, and how to apply and follow the GNU AGPL, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import { webcrypto as crypto } from 'crypto'
|
import { webcrypto as crypto } from 'node:crypto'
|
||||||
import { Profile } from 'doipjs'
|
import { Profile } from 'doipjs'
|
||||||
import Color from 'colorjs.io'
|
import Color from 'colorjs.io'
|
||||||
import { param } from 'express-validator'
|
import { param } from 'express-validator'
|
||||||
|
|
Loading…
Reference in a new issue