-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsystem_actor.ts
63 lines (60 loc) · 3.16 KB
/
system_actor.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
export type JsonResponse = { contentType: string, body: Record<string, unknown> }
export const computeWebfingerSubject = ({ origin, actorUsername }: { origin: string, actorUsername: string }) => `acct:${actorUsername}@${new URL(origin).host}`;
export const computeWebfingerResponse = ({ origin, actorUsername, actorPathname }: { origin: string, actorUsername: string, actorPathname: string }): JsonResponse => ({
contentType: 'application/jrd+json; charset=utf-8',
body: {
subject: computeWebfingerSubject({ origin, actorUsername }),
aliases: [`${origin}${actorPathname}`],
links: [
{ 'rel': 'self', 'type': 'application/activity+json', 'href': `${origin}${actorPathname}` }
]
},
});
export const computeSystemActorResponse = ({ origin, actorUsername, actorPathname, url, publicKeyPem }: { origin: string, actorUsername: string, actorPathname: string, url: string, publicKeyPem: string }): JsonResponse => ({
contentType: 'application/activity+json; charset=utf-8',
body: {
'@context': [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1',
{
'manuallyApprovesFollowers': 'as:manuallyApprovesFollowers',
'toot': 'http://joinmastodon.org/ns#',
'featured': { '@id': 'toot:featured', '@type': '@id' },
'featuredTags': { '@id': 'toot:featuredTags', '@type': '@id' },
'alsoKnownAs': { '@id': 'as:alsoKnownAs', '@type': '@id' },
'movedTo': { '@id': 'as:movedTo', '@type': '@id' },
'schema': 'http://schema.org#',
'PropertyValue': 'schema:PropertyValue',
'value': 'schema:value',
'discoverable': 'toot:discoverable',
'Device': 'toot:Device',
'Ed25519Signature': 'toot:Ed25519Signature',
'Ed25519Key': 'toot:Ed25519Key',
'Curve25519Key': 'toot:Curve25519Key',
'EncryptedMessage': 'toot:EncryptedMessage',
'publicKeyBase64': 'toot:publicKeyBase64',
'deviceId': 'toot:deviceId',
'claim': { '@type': '@id', '@id': 'toot:claim' },
'fingerprintKey': { '@type': '@id', '@id': 'toot:fingerprintKey' },
'identityKey': { '@type': '@id', '@id': 'toot:identityKey' },
'devices': { '@type': '@id', '@id': 'toot:devices' },
'messageFranking': 'toot:messageFranking',
'messageType': 'toot:messageType',
'cipherText': 'toot:cipherText',
'suspended': 'toot:suspended'
}
],
id: `${origin}${actorPathname}`,
type: 'Application',
inbox: `${origin}${actorPathname}/inbox`, // required, but never called
outbox: `${origin}${actorPathname}/outbox`, // required, but never called
preferredUsername: actorUsername,
url,
manuallyApprovesFollowers: true,
publicKey: {
id: `${origin}${actorPathname}#main-key`,
owner: `${origin}${actorPathname}`,
publicKeyPem,
},
}
});