Hard-coded WebFinger and Actor object

Tested to work with Mastodon’s Search feature.
parent bea46fbf
......@@ -26,8 +26,91 @@ app.use(compress())
app.use(express.json())
app.use(express.urlencoded({ extended: true }))
app.use(favicon(path.join(app.get('public'), 'favicon.ico')))
// Host the public folder
app.use('/', express.static(app.get('public')))
app.use('/.well-known/webfinger', function (req, res, next) {
console.log('Web finger triggered.')
console.log(req.query)
res.set('Content-Type', 'application/jrd+json; charset=utf-8')
res.send(JSON.parse(`{
"subject": "person@iiuoizjrsz.localtunnel.me",
"links": [{
"rel": "self",
"type": "application/ld+json; profile='https://www.w3.org/ns/activitystreams'",
"href": "https://iiuoizjrsz.localtunnel.me/"
}]
}`)
)
})
app.use('/inbox', function(req, res, next) {
console.log('Inbox hit')
res.send({})
})
app.use('/', function (req, res, next) {
res.format({
'text/html': function () {
res.send('<h1>Hello, world</h1>')
},
'application/ld+json; profile="https://www.w3.org/ns/activitystreams"': function () {
res.set('Content-Type', 'application/activity+json; charset=utf-8')
res.set('Link', '<https://iiuoizjrsz.localtunnel.me/.well-known/webfinger?resource=acct%3Aperson%40iiuoizjrsz.localtunnel.me>; rel="lrdd"; type="application/xrd+xml", <https://iiuoizjrsz.localtunnel.me/>; rel="alternate"; type="application/activity+json"')
const sampleActorActivityStreamObject = JSON.parse(`{
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1",
{
"manuallyApprovesFollowers":"as:manuallyApprovesFollowers",
"sensitive":"as:sensitive",
"hashtag":"as:Hashtag",
"ostatus":"http://ostatus.org#",
"atomUri":"ostatus:atomUri",
"inReplyToAtomUri":"ostatus:inReplyToAtomUri",
"conversation":"ostatus:conversation",
"toot":"http://joinmastodon.org/ns#",
"Emoji":"toot:Emoji"
}
],
"type": "Person",
"id": "https://iiuoizjrsz.localtunnel.me/",
"following": "https://iiuoizjrsz.localtunnel.me/following",
"followers": "https://iiuoizjrsz.localtunnel.me/followers",
"inbox": "https://iiuoizjrsz.localtunnel.me/inbox",
"outbox": "https://iiuoizjrsz.localtunnel.me/outbox",
"preferredUsername": "person",
"name": "Aral Balkan",
"summary": "Just a guy.",
"url": "https://iiuoizjrsz.localtunnel.me/",
"icon": {
"type": "Image",
"mediaType": "image/jpeg",
"url": "https://ar.al/images/aral-432.jpg"
},
"image": {
"type": "Image",
"mediaType": "image/jpeg",
"url": "https://ar.al/images/aral-432.jpg"
},
"endpoints": {
"sharedInbox": "https://iiuoizjrsz.localtunnel.me/inbox"
},
"publicKey": {
"owner": "https://iiuoizjrsz.localtunnel.me/",
"id": "https://iiuoizjrsz.localtunnel.me/#main-key",
"publicKeyPem": "-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA8NY/rAs24sgBWrTFiE0ovxSbv9ekts8NM109W6WM3s30SpAAmK/dPVzmMLeZxrsHaJVOFOCuSe2X2vVHUkYySMDokdIUWfHfGf+hpied8QPVJopoZq8cv3zz6HC8j7RFUaQYQMYi5JpdF7z9y0ZpI8bvRxWH2TPchJQe0uDk8Jvdlcqm/FfQIC6rQyLgLnX2/kRs0e7TeYTmMlXvtbmUqbtBd9FHIA0Kz9xyPm310N2E0Ca/pbDRYEylw5roRN1FI3teov3dR3Jxoy02iwHTeI9FOUF4K/MaS+ebZGjlI7ArJa4zHQ0gqslFlNLbi+4KdOI6CQKyjBZqRNBGlXBD8QIDAQAB-----END PUBLIC KEY-----"
}
}
`)
res.send(sampleActorActivityStreamObject)
}
})
next()
})
// Set up Plugins and providers
app.configure(express.rest())
......@@ -41,6 +124,9 @@ app.configure(services)
app.configure(channels)
// Configure a middleware for 404s and the error handler
app.use(function (req, res) {
console.log(req.url)
})
app.use(express.notFound())
app.use(express.errorHandler({ logger }))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment