bun-activitypub/actor.ts

114 lines
3.1 KiB
TypeScript
Raw Permalink Normal View History

import { BASE_URL, HOSTNAME, PUBLIC_KEY } from "./src/env"
// change "activitypub" to whatever you want your account name to be
export const preferredUsername:string = process.env.ACCOUNT || "activitypub"
export const name = process.env.REAL_NAME || preferredUsername
export const summary = ""
// avatar image
const icon:{ type:"Image", mediaType:string, url:string, name:string } = {
type: "Image",
mediaType: "image/svg+xml",
url: BASE_URL + "/assets/img/avatar-tt.svg",
name: "My profile photo — a pixelated version of me"
}
// banner image
const image:{ type:"Image", mediaType:string, url:string, name:string } = {
type: "Image",
mediaType: "image/jpeg",
url: BASE_URL + "/assets/img/banner-1500x500.jpg",
name: "A grim reaper in a decorated cubicle, writing and daydreaming, surrounded by many other grim reapers in bland, grey, cubicles"
}
// This is a list of other actor ids you identify as
const alsoKnownAs:string[] = []
// I'm not exactly sure what this time represents.
// The date your website got published?
const published:string = "2023-09-14T00:00:00Z"
// customize this to add or remove PropertyValues
// this is the table that appears on Mastodon, etc, profile pages
const attachment:{ type:"PropertyValue", name:string, value:string }[] = [
{
type: "PropertyValue",
name: "Pronouns",
value: "they/them"
},
{
type: "PropertyValue",
name: "Website",
value: `<a href="${BASE_URL}" target="_blank" rel="nofollow noopener noreferrer me">${BASE_URL}</a>`
}
]
2023-10-02 22:19:04 +00:00
const ACTOR = {
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1",
{
manuallyApprovesFollowers: "as:manuallyApprovesFollowers",
toot: "http://joinmastodon.org/ns#",
alsoKnownAs: {
"@id": "as:alsoKnownAs",
"@type": "@id"
},
schema: "http://schema.org#",
PropertyValue: "schema:PropertyValue",
value: "schema:value",
discoverable: "toot:discoverable",
Ed25519Signature: "toot:Ed25519Signature",
Ed25519Key: "toot:Ed25519Key",
Curve25519Key: "toot:Curve25519Key",
EncryptedMessage: "toot:EncryptedMessage",
publicKeyBase64: "toot:publicKeyBase64"
}
],
id: BASE_URL,
type: "Person",
following: `${BASE_URL}/following`,
followers: `${BASE_URL}/followers`,
inbox: `${BASE_URL}/inbox`,
outbox: `${BASE_URL}/outbox`,
preferredUsername,
name,
summary,
hostname: HOSTNAME,
url: BASE_URL,
manuallyApprovesFollowers: false,
discoverable: true,
published,
alsoKnownAs,
publicKey: {
id: `${BASE_URL}#main-key`,
owner: BASE_URL,
publicKeyPem: PUBLIC_KEY,
},
attachment,
icon,
image
2023-10-02 22:19:04 +00:00
}
export const handle = `${ACTOR.preferredUsername}@${HOSTNAME}`
export const webfinger = {
subject: `acct:${ACTOR.preferredUsername}@${HOSTNAME}`,
aliases: [ACTOR.id],
links: [
{
"rel": "http://webfinger.net/rel/profile-page",
"type": "text/html",
"href": ACTOR.url
},
{
rel: "self",
type: "application/activity+json",
href: ACTOR.id,
},
],
}
export default ACTOR