Fix alias lookup, hardcoded domain, and content-type header

This commit is contained in:
Tyler Beckman 2024-03-14 15:11:23 -06:00 committed by Tyler Beckman
parent cb67d65e53
commit 946d9c5e5a

View file

@ -55,23 +55,31 @@ router.get('/.well-known/webfinger', (req, res) => {
return 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) { if (!req.query.resource) {
res.status(400).send() res.status(400).send()
return return
} else if (req.query.resource !== 'acct:keyoxide@keyoxide.org') { } else if (![body.subject, ...body.aliases].includes(req.query.resource)) {
res.status(404).send() res.status(404).send()
return return
} }
const body = { res.set('Content-Type', 'application/jrd+json')
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.json(body) res.json(body)
}) })