WebFinger stub

This commit is contained in:
Bryan Ashby 2022-12-30 22:39:39 -07:00
parent d2d5aad236
commit b1bb66e52f
No known key found for this signature in database
GPG Key ID: C2C1B501E4EFD994
1 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,46 @@
const { ServerModule } = require('../../../server_module');
const Config = require('../../../config').get;
const WebServerPackageName = require('../web').moduleInfo.packageName;
const _ = require('lodash');
exports.moduleInfo = {
name: 'WebFinger',
desc: 'A simple WebFinger Server',
author: 'NuSkooler',
packageName: 'codes.l33t.enigma.web.finger.server',
};
exports.getModule = class WebFingerServerModule extends ServerModule {
constructor() {
super();
}
init(cb) {
if (!_.get(Config(), 'contentServers.web.handlers.webFinger.enabled')) {
return cb(null);
}
const { getServer } = require('../../../listening_server');
// we rely on the web server
this.webServer = getServer(WebServerPackageName);
if (!this.webServer || !this.webServer.instance.isEnabled()) {
return cb(null);
//return cb(Errors.DoesNotExist('Missing dependent server: Web server. Is it enabled?'));
}
this.webServer.instance.addRoute({
method: 'GET',
path: /^\/\.well-known\/webfinger\/?\?/,
handler: this._webFingerRequestHandler.bind(this),
});
return cb(null);
}
_webFingerRequestHandler(req, resp) {
console.log(req);
}
};