Make LocalTunnel URL a constant

Add comments to explain process.
parent 989e29e2
......@@ -17,6 +17,9 @@ const channels = require('./channels')
const app = express(feathers())
// Hardcoded LocalTunnel URL for testing federation.
const localDomain = 'iiuoizjrsz.localtunnel.me'
// Load app configuration
app.configure(configuration())
// Enable CORS, security, compression, favicon and body parsing
......@@ -33,11 +36,11 @@ app.use('/.well-known/webfinger', function (req, res, next) {
res.set('Content-Type', 'application/jrd+json; charset=utf-8')
res.send(JSON.parse(`{
"subject": "person@iiuoizjrsz.localtunnel.me",
"subject": `person@${localDomain}`,
"links": [{
"rel": "self",
"type": "application/ld+json; profile='https://www.w3.org/ns/activitystreams'",
"href": "https://iiuoizjrsz.localtunnel.me/"
"href": "https://${localDomain}/"
}]
}`)
)
......@@ -58,8 +61,20 @@ app.use('/', function (req, res, next) {
'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"')
// WebFinger support is not a requirement in the ActivityPub spec
// but it is required for federation with Mastodon.
// https://github.com/tootsuite/mastodon/issues/4906#issuecomment-328844846
res.set('Link', `<https://${localDomain}/.well-known/webfinger?resource=acct%3Aperson%40${localDomain}>; rel="lrdd"; type="application/xrd+xml", <https://${localDomain}/>; rel="alternate"; type="application/activity+json"`)
// The structure of this reponse is modelled on the Mastodon response
// to an Actor request. This full response should not be necessary
// to successfully interoperate with Mastodon. According to the same
// issue thread, above, the only requirements according to Eugen are
// the presence of an inbox endpoint and a link header pointing to
// the WebFinger endpoint (and the implementation of the webfinger
// endpoint itself.)
const sampleActorActivityStreamObject = JSON.parse(`{
"@context": [
"https://www.w3.org/ns/activitystreams",
......@@ -77,15 +92,15 @@ app.use('/', function (req, res, next) {
}
],
"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",
"id": "https://${localDomain}",
"following": "https://${localDomain}/following",
"followers": "https://${localDomain}/followers",
"inbox": "https://${localDomain}/inbox",
"outbox": "https://${localDomain}/outbox",
"preferredUsername": "person",
"name": "Aral Balkan",
"summary": "Just a guy.",
"url": "https://iiuoizjrsz.localtunnel.me/",
"url": "https://${localDomain}/",
"icon": {
"type": "Image",
"mediaType": "image/jpeg",
......@@ -97,11 +112,11 @@ app.use('/', function (req, res, next) {
"url": "https://ar.al/images/aral-432.jpg"
},
"endpoints": {
"sharedInbox": "https://iiuoizjrsz.localtunnel.me/inbox"
"sharedInbox": "https://${localDomain}/inbox"
},
"publicKey": {
"owner": "https://iiuoizjrsz.localtunnel.me/",
"id": "https://iiuoizjrsz.localtunnel.me/#main-key",
"owner": "https://${localDomain}/",
"id": "https://${localDomain}/#main-key",
"publicKeyPem": "-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA8NY/rAs24sgBWrTFiE0ovxSbv9ekts8NM109W6WM3s30SpAAmK/dPVzmMLeZxrsHaJVOFOCuSe2X2vVHUkYySMDokdIUWfHfGf+hpied8QPVJopoZq8cv3zz6HC8j7RFUaQYQMYi5JpdF7z9y0ZpI8bvRxWH2TPchJQe0uDk8Jvdlcqm/FfQIC6rQyLgLnX2/kRs0e7TeYTmMlXvtbmUqbtBd9FHIA0Kz9xyPm310N2E0Ca/pbDRYEylw5roRN1FI3teov3dR3Jxoy02iwHTeI9FOUF4K/MaS+ebZGjlI7ArJa4zHQ0gqslFlNLbi+4KdOI6CQKyjBZqRNBGlXBD8QIDAQAB-----END PUBLIC KEY-----"
}
}
......
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