-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathactor.js
More file actions
67 lines (65 loc) · 2.09 KB
/
actor.js
File metadata and controls
67 lines (65 loc) · 2.09 KB
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
64
65
66
67
export function actorJson(pubkey, domain, account, actorInfo) {
if (!pubkey || !domain || !account || !actorInfo) {
throw new Error('Missing required argument');
}
return {
'@context': ['https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1'],
id: `https://${domain}/u/${account}`,
type: 'Person',
preferredUsername: `${account}`,
name: actorInfo.displayName,
summary: actorInfo.description,
inbox: `https://${domain}/inbox`,
outbox: `https://${domain}/u/${account}/outbox`,
followers: `https://${domain}/u/${account}/followers`,
following: `https://${domain}/u/${account}/following`,
endpoints: {
sharedInbox: `https://${domain}/inbox`,
},
publicKey: {
id: `https://${domain}/u/${account}#main-key`,
owner: `https://${domain}/u/${account}`,
publicKeyPem: pubkey,
},
};
}
export function actorJsonMock(pubkey, domain, accountName) {
if (!pubkey || !domain || !accountName) {
throw new Error('Missing required argument');
}
return {
'@context': ['https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1'],
id: `https://${domain}/u/${accountName}`,
type: 'Person',
preferredUsername: `${accountName}`,
name: accountName,
summary: 'A mock user for testing purposes',
inbox: `https://${domain}/inbox`,
outbox: `https://${domain}/u/${accountName}/outbox`,
followers: `https://${domain}/u/${accountName}/followers`,
following: `https://${domain}/u/${accountName}/following`,
endpoints: {
sharedInbox: `https://${domain}/inbox`,
},
publicKey: {
id: `https://${domain}/u/${accountName}#main-key`,
owner: `https://${domain}/u/${accountName}`,
publicKeyPem: pubkey,
},
};
}
export function webfingerJson(domain, accountName) {
if (!domain || !accountName) {
throw new Error('Missing required argument');
}
return {
subject: `acct:${accountName}@${domain}`,
links: [
{
rel: 'self',
type: 'application/activity+json',
href: `https://${domain}/u/${accountName}`,
},
],
};
}