Last active
November 24, 2022 18:21
-
-
Save mbbx6spp/2c0873c24dd9c7d417cea98b87eaf11e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# make sure you put this in the root of the generate site build, not just in the root of your netlify repository! | |
/.well-known/webfinger* https://APPNAME.deno.dev/:splat 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { serve } from "https://deno.land/[email protected]/http/server.ts"; | |
serve((req) => { | |
const url = new URL(req.url); | |
const resource = url.searchParams.get('resource') || 'acct:[email protected]'; | |
const rel = url.searchParams.get('rel'); | |
console.log({resource, rel, url: url.toString(), headers: { "X-From": req.headers.get('X-From') } }); | |
return new Response( | |
JSON.stringify(getSubjectByRel(resource, rel)), | |
{ headers: { "content-type": "application/json" } } | |
); | |
}); | |
const getSubjectByRel = (subject, rel) => { | |
const entry = subjects[subject]; | |
const filteredLinks = rel ? entry.links.filter(link => link.rel == rel) : entry.links; | |
return { subject: entry.subject, aliases: entry.aliases, links: filteredLinks, }; | |
}; | |
const mastodonDocument = { | |
"subject": "acct:[email protected]", | |
"aliases": [ | |
"https://mastodon.social/@SusanPotter", | |
"https://mastodon.social/users/SusanPotter" | |
], | |
"links": [ | |
{ | |
"rel": "http://webfinger.net/rel/profile-page", | |
"type": "text/html", | |
"href": "https://mastodon.social/@SusanPotter" | |
}, | |
{ | |
"rel": "self", | |
"type": "application/activity+json", | |
"href": "https://mastodon.social/users/SusanPotter" | |
}, | |
{ | |
"rel": "http://ostatus.org/schema/1.0/subscribe", | |
"template": "https://mastodon.social/authorize_interaction?uri={uri}" | |
} | |
] | |
}; | |
const subjects = { | |
"acct:[email protected]": mastodonDocument, | |
"acct:[email protected]": mastodonDocument, | |
"acct:[email protected]": mastodonDocument, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment