adds really basic webfinger

This commit is contained in:
James Tomasino 2023-03-27 20:09:10 +00:00
parent 40c9ec9de6
commit 244665db1c
16 changed files with 90 additions and 0 deletions

40
config/winston.js Normal file
View File

@ -0,0 +1,40 @@
var appRoot = require('app-root-path');
var winston = require('winston');
// define the custom settings for each transport (file, console)
var options = {
file: {
level: 'info',
filename: `${appRoot}/logs/app.log`,
handleExceptions: true,
json: true,
maxsize: 5242880, // 5MB
maxFiles: 5,
colorize: false,
},
console: {
level: 'debug',
handleExceptions: true,
json: false,
colorize: true,
},
};
// instantiate a new Winston Logger with the settings defined above
var logger = new winston.Logger({
transports: [
new winston.transports.File(options.file),
new winston.transports.Console(options.console)
],
exitOnError: false, // do not exit on handled exceptions
});
// create a stream object with a 'write' function that will be used by `morgan`
logger.stream = {
write: function(message, encoding) {
// use the 'info' log level so the output will be picked up by both transports (file and console)
logger.info(message);
},
};
module.exports = logger;

View File

@ -136,6 +136,25 @@ app.get('/sitemap.xml', function (_req, res) {
})
})
app.get('/.well-known/webfinger', function(req, res) {
var resource = req.query.resource
if (resource && resource.startsWith('acct:') && resource.endsWith('@cosmic.voyage')) {
const regex = /acct:(\w+)@cosmic\.voyage/i
const resources = resource.match(regex)
if (resources.length) {
const user = resources[1].toLowerCase()
const path = '/home/' + user + '/.webfinger.json'
if (fs.existsSync(path)) {
const content = bufferFile(path)
res.setHeader('content-type', 'application/jrd+json')
res.render('raw', { content: content })
}
}
}
res.setHeader('content-type', 'application/jrd+json')
res.render('raw', { content: '' })
})
// Any link to a direct static resource will show it
app.use(express.static(path.join(__dirname, '/static')))

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
static/apple-touch-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

9
static/browserconfig.xml Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square150x150logo src="/mstile-150x150.png"/>
<TileColor>#00a300</TileColor>
</tile>
</msapplication>
</browserconfig>

BIN
static/favicon-16x16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 797 B

BIN
static/favicon-32x32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
static/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
static/mstile-144x144.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

BIN
static/mstile-150x150.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

BIN
static/mstile-310x150.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

BIN
static/mstile-310x310.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
static/mstile-70x70.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

3
static/robots.txt Normal file
View File

@ -0,0 +1,3 @@
User-agent: *
Disallow: /wp-login.php
Disallow: /xmlrpc.php

19
static/site.webmanifest Normal file
View File

@ -0,0 +1,19 @@
{
"name": "",
"short_name": "",
"icons": [
{
"src": "/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}