From 946d9c5e5aec564f04bb355cda7f2e30685cd1e2 Mon Sep 17 00:00:00 2001 From: Ty Date: Thu, 14 Mar 2024 15:11:23 -0600 Subject: [PATCH] Fix alias lookup, hardcoded domain, and content-type header --- src/routes/main.js | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/routes/main.js b/src/routes/main.js index 2712df6..60266d1 100644 --- a/src/routes/main.js +++ b/src/routes/main.js @@ -55,23 +55,31 @@ router.get('/.well-known/webfinger', (req, res) => { return } + const body = { + subject: `acct:keyoxide@${process.env.DOMAIN}`, + aliases: [`https://${process.env.DOMAIN}/users/keyoxide`], + links: [ + { + rel: 'self', + type: 'application/activity+json', + href: `https://${process.env.DOMAIN}/users/keyoxide` + }, { + rel: 'self', + type: 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"', + href: `https://${process.env.DOMAIN}/users/keyoxide` + } + ] + } + if (!req.query.resource) { res.status(400).send() return - } else if (req.query.resource !== 'acct:keyoxide@keyoxide.org') { + } else if (![body.subject, ...body.aliases].includes(req.query.resource)) { res.status(404).send() return } - const body = { - subject: `acct:keyoxide@${process.env.DOMAIN}`, - aliases: [`https://${process.env.DOMAIN}/users/keyoxide`], - links: [{ - rel: 'self', - type: 'application/activity+json', - href: `https://${process.env.DOMAIN}/users/keyoxide` - }] - } + res.set('Content-Type', 'application/jrd+json') res.json(body) })