Add optional endpoints for webfinger and actor

This commit is contained in:
Robbie Antenesse 2019-01-10 16:57:11 -07:00
parent 3564783664
commit 2c3f8e55d6
4 changed files with 55 additions and 1 deletions

View File

@ -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);
});
}

View File

@ -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);
});
}

View File

@ -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) {

View File

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