2019-02-20 22:12:29 +00:00
|
|
|
import express, { Router } from "express";
|
|
|
|
import { promises as fs } from "fs";
|
|
|
|
|
|
|
|
const domain = process.env.DOMAIN;
|
|
|
|
|
2019-02-20 23:07:29 +00:00
|
|
|
export default async function actor(router: Router) {
|
2019-02-20 22:12:29 +00:00
|
|
|
const pubKeyPem = (await fs.readFile(process.env.PUB_KEY_PEM!)).toString();
|
|
|
|
const actorObj = {
|
|
|
|
"@context": [
|
|
|
|
"https://www.w3.org/ns/activitystreams",
|
|
|
|
"https://w3id.org/security/v1"
|
|
|
|
],
|
|
|
|
"type": "Person",
|
|
|
|
"id": `https://${domain}/ap/actor`,
|
2019-02-24 15:21:14 +00:00
|
|
|
"preferredUsername": "blog",
|
2019-02-20 22:12:29 +00:00
|
|
|
"name": "shadowfacts' blog",
|
|
|
|
"icon": {
|
|
|
|
"type": "Image",
|
|
|
|
"mediaType": "image/png",
|
|
|
|
"url": `https://${domain}/shadowfacts.png`
|
|
|
|
},
|
|
|
|
"inbox": `https://${domain}/ap/inbox`,
|
|
|
|
"followers": `https://${domain}/ap/actor/followers`,
|
|
|
|
"publicKey": {
|
|
|
|
"id": `https://${domain}/ap/actor#main-key`,
|
|
|
|
"owner": `https://${domain}/ap/actor`,
|
|
|
|
"publicKeyPem": pubKeyPem
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
router.get("/ap/actor", (req, res) => {
|
2019-10-10 16:31:49 +00:00
|
|
|
if (req.accepts("text/html")) {
|
|
|
|
res.redirect("/");
|
|
|
|
} else {
|
2019-02-20 22:12:29 +00:00
|
|
|
res.type("application/activity+json");
|
|
|
|
res.json(actorObj);
|
|
|
|
res.end();
|
|
|
|
}
|
|
|
|
});
|
2019-10-10 16:31:49 +00:00
|
|
|
}
|