- if (Array.isArray(fun) === true) {
- fun[0](req, res, next) // FIXME: doesn't work
- }
+export {
+ checkSignature,
+ executeIfActivityPub,
+ checkHttpSignature
+}
+
+// ---------------------------------------------------------------------------
+
+async function checkHttpSignature (req: Request, res: Response) {
+ // FIXME: mastodon does not include the Signature scheme
+ const sig = req.headers[HTTP_SIGNATURE.HEADER_NAME] as string
+ if (sig && sig.startsWith('Signature ') === false) req.headers[HTTP_SIGNATURE.HEADER_NAME] = 'Signature ' + sig
+
+ const parsed = parseHTTPSignature(req)
+
+ const keyId = parsed.keyId
+ if (!keyId) {
+ res.sendStatus(403)
+ return false
+ }
+
+ logger.debug('Checking HTTP signature of actor %s...', keyId)