2
1

webfinger.ts 839 B

123456789101112131415161718192021222324252627282930313233343536
  1. import * as express from 'express'
  2. import { asyncMiddleware } from '../middlewares'
  3. import { webfingerValidator } from '../middlewares/validators'
  4. const webfingerRouter = express.Router()
  5. webfingerRouter.get('/.well-known/webfinger',
  6. asyncMiddleware(webfingerValidator),
  7. webfingerController
  8. )
  9. // ---------------------------------------------------------------------------
  10. export {
  11. webfingerRouter
  12. }
  13. // ---------------------------------------------------------------------------
  14. function webfingerController (req: express.Request, res: express.Response) {
  15. const actor = res.locals.actor
  16. const json = {
  17. subject: req.query.resource,
  18. aliases: [ actor.url ],
  19. links: [
  20. {
  21. rel: 'self',
  22. type: 'application/activity+json',
  23. href: actor.url
  24. }
  25. ]
  26. }
  27. return res.json(json).end()
  28. }