Browse Source

Add optional endpoints for webfinger and actor

activitypub
Robbie Antenesse 4 years ago
parent
commit
2c3f8e55d6
  1. 27
      routes/activitypub/get_actor.js
  2. 19
      routes/activitypub/get_webfinger.js
  3. 5
      server.js
  4. 5
      settings.example.json

27
routes/activitypub/get_actor.js

@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
const settings = require('../../settings.json');
module.exports = function (app) {
app.server.get('/activitypub/actor', function (req, res) {
const actor = JSON.stringify({
'@context': [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1',
],
id: `https://${settings.domain}/activitypub/actor`,
type: 'Person',
preferredUsername: 'shelf',
inbox: `https://${settings.domain}/activitypub/inbox`,
outbox: `https://${settings.domain}/activitypub/outbox`,
publicKey: {
id: `https://${settings.domain}/activitypub/actor#main-key`,
owner: `https://${settings.domain}/activitypub/actor`,
publicKeyPem: settings.publicKey,
}
});
res.setHeader('Content-Type', 'application/activity+json');
res.send(actor);
});
}

19
routes/activitypub/get_webfinger.js

@ -0,0 +1,19 @@ @@ -0,0 +1,19 @@
const settings = require('../../settings.json');
module.exports = function (app) {
app.server.get('/.well-known/webfinger', function (req, res) {
const webfinger = JSON.stringify({
subject: `acct:shelf@${settings.domain}`,
links: [
{
rel: 'self',
type: 'application/activity+json',
href: `https://${settings.domain}/activitypub/actor`,
}
]
});
res.setHeader('Content-Type', 'application/activity+json');
res.send(webfinger);
});
}

5
server.js

@ -50,6 +50,11 @@ function Server () { @@ -50,6 +50,11 @@ function Server () {
require('./routes/post_tools')(this);
require('./routes/socketio')(this);
if (settings.federate) {
require('./routes/activitypub/get_webfinger')(this);
require('./routes/activitypub/get_actor')(this);
}
}
Server.prototype.replaceBodyWithTooManyBooksWarning = function (body) {

5
settings.example.json

@ -13,5 +13,8 @@ @@ -13,5 +13,8 @@
"sslPrivateKey": null,
"sslCertificate": null,
"sslCertificateAuthority": null,
"forceHTTPS": false
"forceHTTPS": false,
"federate": true,
"domain": "localhost",
"publicKey": null
}
Loading…
Cancel
Save