@fedify/vocab 2.0.0-dev.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/LICENSE +20 -0
  2. package/deno.json +31 -0
  3. package/dist/accept.yaml +15 -0
  4. package/dist/activity.yaml +98 -0
  5. package/dist/actor.test.d.ts +2 -0
  6. package/dist/actor.test.js +6095 -0
  7. package/dist/add.yaml +16 -0
  8. package/dist/announce.yaml +30 -0
  9. package/dist/application.yaml +324 -0
  10. package/dist/arrive.yaml +15 -0
  11. package/dist/article.yaml +46 -0
  12. package/dist/audio.yaml +11 -0
  13. package/dist/block.yaml +16 -0
  14. package/dist/chatmessage.yaml +50 -0
  15. package/dist/collection.yaml +154 -0
  16. package/dist/collectionpage.yaml +55 -0
  17. package/dist/create.yaml +28 -0
  18. package/dist/dataintegrityproof.yaml +56 -0
  19. package/dist/delete.yaml +27 -0
  20. package/dist/deno-B-ypIMwF.js +1282 -0
  21. package/dist/didservice.yaml +22 -0
  22. package/dist/dislike.yaml +14 -0
  23. package/dist/document.yaml +31 -0
  24. package/dist/emoji.yaml +12 -0
  25. package/dist/emojireact.yaml +17 -0
  26. package/dist/endpoints.yaml +85 -0
  27. package/dist/event.yaml +11 -0
  28. package/dist/export.yaml +9 -0
  29. package/dist/flag.yaml +15 -0
  30. package/dist/follow.yaml +19 -0
  31. package/dist/group.yaml +324 -0
  32. package/dist/hashtag.yaml +14 -0
  33. package/dist/ignore.yaml +14 -0
  34. package/dist/image.yaml +9 -0
  35. package/dist/intransitiveactivity.yaml +15 -0
  36. package/dist/invite.yaml +14 -0
  37. package/dist/join.yaml +14 -0
  38. package/dist/key.yaml +28 -0
  39. package/dist/leave.yaml +14 -0
  40. package/dist/like.yaml +16 -0
  41. package/dist/link.yaml +101 -0
  42. package/dist/listen.yaml +12 -0
  43. package/dist/lookup.test.d.ts +2 -0
  44. package/dist/lookup.test.js +690 -0
  45. package/dist/mention.yaml +9 -0
  46. package/dist/mod.cjs +42036 -0
  47. package/dist/mod.d.cts +15329 -0
  48. package/dist/mod.d.ts +15330 -0
  49. package/dist/mod.js +41936 -0
  50. package/dist/move.yaml +15 -0
  51. package/dist/multikey.yaml +36 -0
  52. package/dist/note.yaml +48 -0
  53. package/dist/object.yaml +404 -0
  54. package/dist/offer.yaml +15 -0
  55. package/dist/orderedcollection.yaml +39 -0
  56. package/dist/orderedcollectionpage.yaml +50 -0
  57. package/dist/organization.yaml +324 -0
  58. package/dist/page.yaml +11 -0
  59. package/dist/person.yaml +324 -0
  60. package/dist/place.yaml +75 -0
  61. package/dist/profile.yaml +26 -0
  62. package/dist/propertyvalue.yaml +32 -0
  63. package/dist/question.yaml +103 -0
  64. package/dist/read.yaml +13 -0
  65. package/dist/reject.yaml +14 -0
  66. package/dist/relationship.yaml +52 -0
  67. package/dist/remove.yaml +14 -0
  68. package/dist/service.yaml +324 -0
  69. package/dist/source.yaml +26 -0
  70. package/dist/tentativeaccept.yaml +14 -0
  71. package/dist/tentativereject.yaml +14 -0
  72. package/dist/tombstone.yaml +24 -0
  73. package/dist/travel.yaml +16 -0
  74. package/dist/type-CNuABalk.js +13 -0
  75. package/dist/type.test.d.ts +2 -0
  76. package/dist/type.test.js +24 -0
  77. package/dist/undo.yaml +26 -0
  78. package/dist/update.yaml +58 -0
  79. package/dist/utils-BSWXlrig.js +13 -0
  80. package/dist/video.yaml +11 -0
  81. package/dist/view.yaml +13 -0
  82. package/dist/vocab-DBispxj5.js +41603 -0
  83. package/dist/vocab.test.d.ts +2 -0
  84. package/dist/vocab.test.js +1304 -0
  85. package/package.json +79 -0
  86. package/scripts/codegen.ts +20 -0
  87. package/src/__snapshots__/vocab.test.ts.snap +7903 -0
  88. package/src/accept.yaml +15 -0
  89. package/src/activity.yaml +98 -0
  90. package/src/actor.test.ts +263 -0
  91. package/src/actor.ts +293 -0
  92. package/src/add.yaml +16 -0
  93. package/src/announce.yaml +30 -0
  94. package/src/application.yaml +324 -0
  95. package/src/arrive.yaml +15 -0
  96. package/src/article.yaml +46 -0
  97. package/src/audio.yaml +11 -0
  98. package/src/block.yaml +16 -0
  99. package/src/chatmessage.yaml +50 -0
  100. package/src/collection.yaml +154 -0
  101. package/src/collectionpage.yaml +55 -0
  102. package/src/constants.ts +11 -0
  103. package/src/create.yaml +28 -0
  104. package/src/dataintegrityproof.yaml +56 -0
  105. package/src/delete.yaml +27 -0
  106. package/src/didservice.yaml +22 -0
  107. package/src/dislike.yaml +14 -0
  108. package/src/document.yaml +31 -0
  109. package/src/emoji.yaml +12 -0
  110. package/src/emojireact.yaml +17 -0
  111. package/src/endpoints.yaml +85 -0
  112. package/src/event.yaml +11 -0
  113. package/src/export.yaml +9 -0
  114. package/src/flag.yaml +15 -0
  115. package/src/follow.yaml +19 -0
  116. package/src/group.yaml +324 -0
  117. package/src/handle.ts +104 -0
  118. package/src/hashtag.yaml +14 -0
  119. package/src/ignore.yaml +14 -0
  120. package/src/image.yaml +9 -0
  121. package/src/intransitiveactivity.yaml +15 -0
  122. package/src/invite.yaml +14 -0
  123. package/src/join.yaml +14 -0
  124. package/src/key.yaml +28 -0
  125. package/src/keys.ts +50 -0
  126. package/src/leave.yaml +14 -0
  127. package/src/like.yaml +16 -0
  128. package/src/link.yaml +101 -0
  129. package/src/listen.yaml +12 -0
  130. package/src/lookup.test.ts +681 -0
  131. package/src/lookup.ts +318 -0
  132. package/src/mention.yaml +9 -0
  133. package/src/mod.ts +57 -0
  134. package/src/move.yaml +15 -0
  135. package/src/multikey.yaml +36 -0
  136. package/src/note.yaml +48 -0
  137. package/src/object.yaml +404 -0
  138. package/src/offer.yaml +15 -0
  139. package/src/orderedcollection.yaml +39 -0
  140. package/src/orderedcollectionpage.yaml +50 -0
  141. package/src/organization.yaml +324 -0
  142. package/src/page.yaml +11 -0
  143. package/src/person.yaml +324 -0
  144. package/src/place.yaml +75 -0
  145. package/src/profile.yaml +26 -0
  146. package/src/propertyvalue.yaml +32 -0
  147. package/src/question.yaml +103 -0
  148. package/src/read.yaml +13 -0
  149. package/src/reject.yaml +14 -0
  150. package/src/relationship.yaml +52 -0
  151. package/src/remove.yaml +14 -0
  152. package/src/service.yaml +324 -0
  153. package/src/source.yaml +26 -0
  154. package/src/tentativeaccept.yaml +14 -0
  155. package/src/tentativereject.yaml +14 -0
  156. package/src/tombstone.yaml +24 -0
  157. package/src/travel.yaml +16 -0
  158. package/src/type.test.ts +20 -0
  159. package/src/type.ts +102 -0
  160. package/src/undo.yaml +26 -0
  161. package/src/update.yaml +58 -0
  162. package/src/utils.ts +9 -0
  163. package/src/video.yaml +11 -0
  164. package/src/view.yaml +13 -0
  165. package/src/vocab.bench.ts +204 -0
  166. package/src/vocab.test.ts +2014 -0
  167. package/tsdown.config.ts +65 -0
package/src/group.yaml ADDED
@@ -0,0 +1,324 @@
1
+ $schema: ../../vocab-tools/schema.yaml
2
+ name: Group
3
+ compactName: Group
4
+ uri: "https://www.w3.org/ns/activitystreams#Group"
5
+ extends: "https://www.w3.org/ns/activitystreams#Object"
6
+ entity: true
7
+ description: Represents a formal or informal collective of Actors.
8
+ defaultContext:
9
+ - "https://www.w3.org/ns/activitystreams"
10
+ - "https://w3id.org/security/v1"
11
+ - "https://w3id.org/security/data-integrity/v1"
12
+ - "https://www.w3.org/ns/did/v1"
13
+ - "https://w3id.org/security/multikey/v1"
14
+ - alsoKnownAs:
15
+ "@id": "as:alsoKnownAs"
16
+ "@type": "@id"
17
+ manuallyApprovesFollowers: "as:manuallyApprovesFollowers"
18
+ movedTo:
19
+ "@id": "as:movedTo"
20
+ "@type": "@id"
21
+ toot: "http://joinmastodon.org/ns#"
22
+ Emoji: "toot:Emoji"
23
+ featured:
24
+ "@id": "toot:featured"
25
+ "@type": "@id"
26
+ featuredTags:
27
+ "@id": "toot:featuredTags"
28
+ "@type": "@id"
29
+ discoverable: "toot:discoverable"
30
+ suspended: "toot:suspended"
31
+ memorial: "toot:memorial"
32
+ indexable: "toot:indexable"
33
+ schema: "http://schema.org#"
34
+ PropertyValue: "schema:PropertyValue"
35
+ value: "schema:value"
36
+ misskey: "https://misskey-hub.net/ns#"
37
+ _misskey_followedMessage: "misskey:_misskey_followedMessage"
38
+ isCat: "misskey:isCat"
39
+
40
+ properties:
41
+ - pluralName: preferredUsernames
42
+ singularName: preferredUsername
43
+ singularAccessor: true
44
+ compactName: preferredUsername
45
+ uri: "https://www.w3.org/ns/activitystreams#preferredUsername"
46
+ description: |
47
+ A short username which may be used to refer to the actor,
48
+ with no uniqueness guarantees.
49
+ range:
50
+ - "http://www.w3.org/2001/XMLSchema#string"
51
+ - "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"
52
+
53
+ - pluralName: publicKeys
54
+ singularName: publicKey
55
+ singularAccessor: true
56
+ compactName: publicKey
57
+ uri: "https://w3id.org/security#publicKey"
58
+ description: A public part of the key pair owned by this actor.
59
+ untyped: true
60
+ range:
61
+ - "https://w3id.org/security#Key"
62
+
63
+ - pluralName: assertionMethods
64
+ singularName: assertionMethod
65
+ singularAccessor: true
66
+ compactName: assertionMethod
67
+ uri: "https://w3id.org/security#assertionMethod"
68
+ description: |
69
+ Represents this actor's public keys. It serves as equivalent to
70
+ the `publicKeys` property, but is used for [FEP-521a] compliance.
71
+
72
+ [FEP-521a]: https://w3id.org/fep/521a
73
+ range:
74
+ - "https://w3id.org/security#Multikey"
75
+
76
+ - singularName: manuallyApprovesFollowers
77
+ functional: true
78
+ compactName: manuallyApprovesFollowers
79
+ uri: "https://www.w3.org/ns/activitystreams#manuallyApprovesFollowers"
80
+ description: |
81
+ When `true`, conveys that for this actor, follow requests are not usually
82
+ automatically approved, but instead are examined by a person who may accept
83
+ or reject the request, at some time in the future. Setting of `false`
84
+ conveys no information and may be ignored. This information is typically
85
+ used to affect display of accounts, such as showing an account as private or
86
+ locked.
87
+ range:
88
+ - "http://www.w3.org/2001/XMLSchema#boolean"
89
+
90
+ - singularName: inbox
91
+ functional: true
92
+ compactName: inbox
93
+ uri: "http://www.w3.org/ns/ldp#inbox"
94
+ description: |
95
+ The inbox stream contains all activities received by the actor. The server
96
+ SHOULD filter content according to the requester's permission. In general,
97
+ the owner of an inbox is likely to be able to access all of their inbox
98
+ contents. Depending on access control, some other content may be public,
99
+ whereas other content may require authentication for non-owner users,
100
+ if they can access the inbox at all.
101
+
102
+ The server MUST perform de-duplication of activities returned by the inbox.
103
+ Duplication can occur if an activity is addressed both to an actor's
104
+ followers, and a specific actor who also follows the recipient actor,
105
+ and the server has failed to de-duplicate the recipients list.
106
+ Such deduplication MUST be performed by comparing the `id` of the activities
107
+ and dropping any activities already seen.
108
+ range:
109
+ - "https://www.w3.org/ns/activitystreams#OrderedCollection"
110
+ - "https://www.w3.org/ns/activitystreams#OrderedCollectionPage"
111
+
112
+ - singularName: outbox
113
+ functional: true
114
+ compactName: outbox
115
+ uri: "https://www.w3.org/ns/activitystreams#outbox"
116
+ description: |
117
+ The outbox stream contains activities the user has published,
118
+ subject to the ability of the requestor to retrieve the activity
119
+ (that is, the contents of the outbox are filtered by the permissions of
120
+ the person reading it). If a user submits a request without
121
+ [Authorization](https://www.w3.org/TR/activitypub/#authorization)
122
+ the server should respond with all of the
123
+ [Public](https://www.w3.org/TR/activitypub/#public-addressing) posts.
124
+ This could potentially be all relevant objects published by the user,
125
+ though the number of available items is left to the discretion of those
126
+ implementing and deploying the server.
127
+ range:
128
+ - "https://www.w3.org/ns/activitystreams#OrderedCollection"
129
+ - "https://www.w3.org/ns/activitystreams#OrderedCollectionPage"
130
+
131
+ - singularName: following
132
+ functional: true
133
+ compactName: following
134
+ uri: "https://www.w3.org/ns/activitystreams#following"
135
+ description: |
136
+ This is a list of everybody that the actor has followed, added as a
137
+ [side effect](https://www.w3.org/TR/activitypub/#follow-activity-outbox).
138
+ The `following` collection MUST be either an {@link OrderedCollection}
139
+ or a {@link Collection} and MAY be filtered on privileges of
140
+ an authenticated user or as appropriate when no authentication is given.
141
+ range:
142
+ - "https://www.w3.org/ns/activitystreams#Collection"
143
+
144
+ - singularName: followers
145
+ functional: true
146
+ compactName: followers
147
+ uri: "https://www.w3.org/ns/activitystreams#followers"
148
+ description: |
149
+ This is a list of everyone who has sent a {@link Follow} activity
150
+ for the actor, added as a
151
+ [side effect](https://www.w3.org/TR/activitypub/#follow-activity-outbox).
152
+ This is where one would find a list of all the actors that are following
153
+ the actor. The `followers` collection MUST be either
154
+ an {@link OrderedCollection} or a {@link Collection} and MAY be filtered on
155
+ privileges of an authenticated user or as appropriate when no authentication
156
+ is given.
157
+ range:
158
+ - "https://www.w3.org/ns/activitystreams#Collection"
159
+
160
+ - singularName: liked
161
+ functional: true
162
+ compactName: liked
163
+ uri: "https://www.w3.org/ns/activitystreams#liked"
164
+ description: |
165
+ This is a list of every object from all of the actor's {@link Like}
166
+ activities, added as a
167
+ [side effect](https://www.w3.org/TR/activitypub/#like-activity-outbox).
168
+ The `liked` collection MUST be either an {@link OrderedCollection} or
169
+ a {@link Collection} and MAY be filtered on privileges of an authenticated
170
+ user or as appropriate when no authentication is given.
171
+ range:
172
+ - "https://www.w3.org/ns/activitystreams#Collection"
173
+
174
+ - singularName: featured
175
+ functional: true
176
+ compactName: featured
177
+ uri: "http://joinmastodon.org/ns#featured"
178
+ description: |
179
+ What is known in Mastodon as "pinned statuses", or statuses that are always
180
+ featured at the top of people's profiles, is implemented using an extra
181
+ property `featured` on the actor object that points to a {@link Collection}
182
+ of objects.
183
+ range:
184
+ - "https://www.w3.org/ns/activitystreams#Collection"
185
+
186
+ - singularName: featuredTags
187
+ functional: true
188
+ compactName: featuredTags
189
+ uri: "http://joinmastodon.org/ns#featuredTags"
190
+ description: |
191
+ What is known in Mastodon as "featured hashtags", hashtags that are featured
192
+ at people's profiles, is implemented using an extra property `featuredTags`
193
+ on the actor object that points to a {@link Collection} of {@link Hashtag}
194
+ objects specifically.
195
+ range:
196
+ - "https://www.w3.org/ns/activitystreams#Collection"
197
+
198
+ - pluralName: streams
199
+ singularName: stream
200
+ singularAccessor: false
201
+ compactName: streams
202
+ uri: "https://www.w3.org/ns/activitystreams#streams"
203
+ description: |
204
+ A list of supplementary Collections which may be of interest.
205
+ range:
206
+ - "https://www.w3.org/ns/activitystreams#Collection"
207
+
208
+ - singularName: endpoints
209
+ functional: true
210
+ compactName: endpoints
211
+ uri: "https://www.w3.org/ns/activitystreams#endpoints"
212
+ description: |
213
+ A JSON object which maps additional (typically server/domain-wide) endpoints
214
+ which may be useful either for this actor or someone referencing this actor.
215
+ This mapping may be nested inside the actor document as the value or may be
216
+ a link to a JSON-LD document with these properties.
217
+ range:
218
+ - "https://www.w3.org/ns/activitystreams#Endpoints"
219
+
220
+ - singularName: discoverable
221
+ functional: true
222
+ compactName: discoverable
223
+ uri: "http://joinmastodon.org/ns#discoverable"
224
+ description: |
225
+ Allows users to opt-in or opt-out of discoverability features like
226
+ the profile directory. This flag may also be used as an indicator of
227
+ the user's preferences toward being included in external discovery services,
228
+ such as search engines or other indexing tools.
229
+ range:
230
+ - "http://www.w3.org/2001/XMLSchema#boolean"
231
+
232
+ - singularName: suspended
233
+ functional: true
234
+ compactName: suspended
235
+ uri: "http://joinmastodon.org/ns#suspended"
236
+ description: |
237
+ Reports whether a user was locally suspended, for better handling of
238
+ these accounts.
239
+ range:
240
+ - "http://www.w3.org/2001/XMLSchema#boolean"
241
+
242
+ - singularName: memorial
243
+ functional: true
244
+ compactName: memorial
245
+ uri: "http://joinmastodon.org/ns#memorial"
246
+ description: Whether the actor is in-memorial state.
247
+ range:
248
+ - "http://www.w3.org/2001/XMLSchema#boolean"
249
+
250
+ - singularName: indexable
251
+ functional: true
252
+ compactName: indexable
253
+ uri: "http://joinmastodon.org/ns#indexable"
254
+ description: Whether the actor allows to be indexed.
255
+ range:
256
+ - "http://www.w3.org/2001/XMLSchema#boolean"
257
+
258
+ - singularName: successor
259
+ functional: true
260
+ compactName: movedTo
261
+ uri: "https://www.w3.org/ns/activitystreams#movedTo"
262
+ description: >-
263
+ Signifies that an actor has been moved to a different ID.
264
+ Used in Mastodon-style data portability with the {@link Move} activity;
265
+ see [ActivityPub Data Portability/Move
266
+ Action](https://swicg.github.io/activitypub-data-portability/#move-action)
267
+ for more details.
268
+ range:
269
+ - "https://www.w3.org/ns/activitystreams#Application"
270
+ - "https://www.w3.org/ns/activitystreams#Group"
271
+ - "https://www.w3.org/ns/activitystreams#Organization"
272
+ - "https://www.w3.org/ns/activitystreams#Person"
273
+ - "https://www.w3.org/ns/activitystreams#Service"
274
+
275
+ - pluralName: aliases
276
+ singularName: alias
277
+ singularAccessor: true
278
+ compactName: alsoKnownAs
279
+ uri: "https://www.w3.org/ns/activitystreams#alsoKnownAs"
280
+ description: |
281
+ The `aliases` (`alsoKnownAs`) property is used to specify alternative names
282
+ or aliases for an entity. It can be used to provide additional identifiers
283
+ or labels for an entity, which can be useful in scenarios where an entity
284
+ may have multiple names or aliases.
285
+ range:
286
+ - "https://www.w3.org/ns/activitystreams#Application"
287
+ - "https://www.w3.org/ns/activitystreams#Group"
288
+ - "https://www.w3.org/ns/activitystreams#Organization"
289
+ - "https://www.w3.org/ns/activitystreams#Person"
290
+ - "https://www.w3.org/ns/activitystreams#Service"
291
+
292
+ - pluralName: services
293
+ singularName: service
294
+ singularAccessor: true
295
+ compactName: service
296
+ uri: "https://www.w3.org/ns/did#service"
297
+ description: |
298
+ Means of communicating or interacting with the DID subject or associated
299
+ entities via one or more service endpoints. Examples include discovery
300
+ services, agent services, social networking services, file storage services,
301
+ and verifiable credential repository services.
302
+ range:
303
+ - "https://www.w3.org/ns/did#Service"
304
+
305
+ - singularName: followedMessage
306
+ functional: true
307
+ compactName: _misskey_followedMessage
308
+ uri: "https://misskey-hub.net/ns#_misskey_followedMessage"
309
+ description: |
310
+ This value is used for `Actor` type objects to show message on followed.
311
+ range:
312
+ - "http://www.w3.org/2001/XMLSchema#string"
313
+
314
+ - singularName: cat
315
+ functional: true
316
+ compactName: isCat
317
+ uri: "https://misskey-hub.net/ns#isCat"
318
+ description: |
319
+ Used on actors to indicate that they in some way identify as a cat,
320
+ expressed as a boolean value. If this property is set to `true`,
321
+ displaying the actor or their notes will have some special effects
322
+ attached in some clients.
323
+ range:
324
+ - "http://www.w3.org/2001/XMLSchema#boolean"
package/src/handle.ts ADDED
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Regular expression to match a fediverse handle in the format `@user@server`
3
+ * or `user@server`. The `user` part can contain alphanumeric characters and
4
+ * some special characters except `@`. The `server` part is all characters
5
+ * after the `@` symbol in the middle.
6
+ */
7
+ const handleRegexp =
8
+ /^@?((?:[-A-Za-z0-9._~!$&'()*+,;=]|%[A-Fa-f0-9]{2})+)@([^@]+)$/;
9
+
10
+ /**
11
+ * Represents a fediverse handle, which consists of a username and a host.
12
+ * The username can be alphanumeric and may include special characters,
13
+ * while the host is typically a domain name.
14
+ * @since 1.8.0
15
+ */
16
+ export interface FediverseHandle {
17
+ /**
18
+ * The username part of the fediverse handle.
19
+ * It can include alphanumeric characters and some special characters.
20
+ */
21
+ readonly username: string;
22
+ /**
23
+ * The host part of the fediverse handle, typically a domain name.
24
+ * It is the part after the `@` symbol in the handle.
25
+ */
26
+ readonly host: string;
27
+ }
28
+
29
+ /**
30
+ * Parses a fediverse handle in the format `@user@server` or `user@server`.
31
+ * The `user` part can contain alphanumeric characters and some special
32
+ * characters except `@`. The `server` part is all characters after the `@`
33
+ * symbol in the middle.
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * const handle = parseFediverseHandle("@username@example.com");
38
+ * console.log(handle?.username); // "username"
39
+ * console.log(handle?.host); // "example.com"
40
+ * ```
41
+ *
42
+ * @param handle - The fediverse handle string to parse.
43
+ * @returns A {@link FediverseHandle} object with `username` and `host`
44
+ * if the input is valid; otherwise `null`.
45
+ * @since 1.8.0
46
+ */
47
+ export function parseFediverseHandle(
48
+ handle: string,
49
+ ): FediverseHandle | null {
50
+ const match = handleRegexp.exec(handle);
51
+ if (match) {
52
+ return {
53
+ username: match[1],
54
+ host: match[2],
55
+ };
56
+ }
57
+ return null;
58
+ }
59
+
60
+ /**
61
+ * Checks if a string is a valid fediverse handle in the format `@user@server`
62
+ * or `user@server`. The `user` part can contain alphanumeric characters and
63
+ * some special characters except `@`. The `server` part is all characters
64
+ * after the `@` symbol in the middle.
65
+ *
66
+ * @example
67
+ * ```typescript
68
+ * console.log(isFediverseHandle("@username@example.com")); // true
69
+ * console.log(isFediverseHandle("username@example.com")); // true
70
+ * console.log(isFediverseHandle("@username@")); // false
71
+ * ```
72
+ *
73
+ * @param handle - The string to test as a fediverse handle.
74
+ * @returns `true` if the string matches the fediverse handle pattern;
75
+ * otherwise `false`.
76
+ * @since 1.8.0
77
+ */
78
+ export function isFediverseHandle(
79
+ handle: string,
80
+ ): handle is `${string}@${string}` {
81
+ return handleRegexp.test(handle);
82
+ }
83
+
84
+ /**
85
+ * Converts a fediverse handle in the format `@user@server` or `user@server`
86
+ * to an `acct:` URI, which is a URL-like identifier for ActivityPub actors.
87
+ *
88
+ * @example
89
+ * ```typescript
90
+ * const identifier = toAcctUrl("@username@example.com");
91
+ * console.log(identifier?.href); // "acct:username@example.com"
92
+ * ```
93
+ *
94
+ * @param handle - The fediverse handle string to convert.
95
+ * @returns A `URL` object representing the `acct:` URI if conversion succeeds;
96
+ * otherwise `null`.
97
+ * @since 1.8.0
98
+ */
99
+ export function toAcctUrl(handle: string): URL | null {
100
+ const parsed = parseFediverseHandle(handle);
101
+ if (!parsed) return null;
102
+ const identifier = new URL(`acct:${parsed.username}@${parsed.host}`);
103
+ return identifier;
104
+ }
@@ -0,0 +1,14 @@
1
+ $schema: ../../vocab-tools/schema.yaml
2
+ name: Hashtag
3
+ compactName: Hashtag
4
+ uri: "https://www.w3.org/ns/activitystreams#Hashtag"
5
+ extends: "https://www.w3.org/ns/activitystreams#Link"
6
+ entity: false
7
+ description: |
8
+ A specialized {@link Link} that represents an #hashtag.
9
+
10
+ See also <https://swicg.github.io/miscellany/#Hashtag>.
11
+ defaultContext:
12
+ - "https://www.w3.org/ns/activitystreams"
13
+ - Hashtag: "as:Hashtag"
14
+ properties: []
@@ -0,0 +1,14 @@
1
+ $schema: ../../vocab-tools/schema.yaml
2
+ name: Ignore
3
+ compactName: Ignore
4
+ uri: "https://www.w3.org/ns/activitystreams#Ignore"
5
+ extends: "https://www.w3.org/ns/activitystreams#Activity"
6
+ entity: true
7
+ description: |
8
+ Indicates that the `actor` is ignoring the `object`. The `target` and
9
+ `origin` typically have no defined meaning.
10
+ defaultContext:
11
+ - "https://w3id.org/identity/v1"
12
+ - "https://www.w3.org/ns/activitystreams"
13
+ - "https://w3id.org/security/data-integrity/v1"
14
+ properties: []
package/src/image.yaml ADDED
@@ -0,0 +1,9 @@
1
+ $schema: ../../vocab-tools/schema.yaml
2
+ name: Image
3
+ compactName: Image
4
+ uri: "https://www.w3.org/ns/activitystreams#Image"
5
+ extends: "https://www.w3.org/ns/activitystreams#Document"
6
+ entity: true
7
+ description: An image document of any kind.
8
+ defaultContext: "https://www.w3.org/ns/activitystreams"
9
+ properties: []
@@ -0,0 +1,15 @@
1
+ $schema: ../../vocab-tools/schema.yaml
2
+ name: IntransitiveActivity
3
+ compactName: IntransitiveActivity
4
+ uri: "https://www.w3.org/ns/activitystreams#IntransitiveActivity"
5
+ extends: "https://www.w3.org/ns/activitystreams#Activity"
6
+ entity: true
7
+ description: |
8
+ Instances of `IntransitiveActivity` are a subtype of {@link Activity}
9
+ representing intransitive actions. The `object` property is therefore
10
+ inappropriate for these activities.
11
+ defaultContext:
12
+ - "https://w3id.org/identity/v1"
13
+ - "https://www.w3.org/ns/activitystreams"
14
+ - "https://w3id.org/security/data-integrity/v1"
15
+ properties: []
@@ -0,0 +1,14 @@
1
+ $schema: ../../vocab-tools/schema.yaml
2
+ name: Invite
3
+ compactName: Invite
4
+ uri: "https://www.w3.org/ns/activitystreams#Invite"
5
+ extends: "https://www.w3.org/ns/activitystreams#Offer"
6
+ entity: true
7
+ description: |
8
+ A specialization of `Offer` in which the `actor` is extending an invitation
9
+ for the `object` to the `target`.
10
+ defaultContext:
11
+ - "https://w3id.org/identity/v1"
12
+ - "https://www.w3.org/ns/activitystreams"
13
+ - "https://w3id.org/security/data-integrity/v1"
14
+ properties: []
package/src/join.yaml ADDED
@@ -0,0 +1,14 @@
1
+ $schema: ../../vocab-tools/schema.yaml
2
+ name: Join
3
+ compactName: Join
4
+ uri: "https://www.w3.org/ns/activitystreams#Join"
5
+ extends: "https://www.w3.org/ns/activitystreams#Activity"
6
+ entity: true
7
+ description: |
8
+ Indicates that the `actor` has joined the `object`.
9
+ The `target` and `origin` typically have no defined meaning.
10
+ defaultContext:
11
+ - "https://w3id.org/identity/v1"
12
+ - "https://www.w3.org/ns/activitystreams"
13
+ - "https://w3id.org/security/data-integrity/v1"
14
+ properties: []
package/src/key.yaml ADDED
@@ -0,0 +1,28 @@
1
+ $schema: ../../vocab-tools/schema.yaml
2
+ name: CryptographicKey
3
+ compactName: CryptographicKey
4
+ uri: "https://w3id.org/security#Key"
5
+ entity: true
6
+ description: A key owned by an actor.
7
+ defaultContext: "https://w3id.org/security/v1"
8
+
9
+ properties:
10
+ - singularName: owner
11
+ functional: true
12
+ compactName: owner
13
+ uri: "https://w3id.org/security#owner"
14
+ description: An actor who owns this key.
15
+ range:
16
+ - "https://www.w3.org/ns/activitystreams#Application"
17
+ - "https://www.w3.org/ns/activitystreams#Group"
18
+ - "https://www.w3.org/ns/activitystreams#Organization"
19
+ - "https://www.w3.org/ns/activitystreams#Person"
20
+ - "https://www.w3.org/ns/activitystreams#Service"
21
+
22
+ - singularName: publicKey
23
+ functional: true
24
+ compactName: publicKeyPem
25
+ uri: "https://w3id.org/security#publicKeyPem"
26
+ description: A PEM-encoded public key.
27
+ range:
28
+ - "fedify:publicKey"
package/src/keys.ts ADDED
@@ -0,0 +1,50 @@
1
+ import { CryptographicKey } from "./vocab.ts";
2
+
3
+ export const ed25519PublicKey = new CryptographicKey({
4
+ id: new URL("https://example.com/person2#key4"),
5
+ owner: new URL("https://example.com/person2"),
6
+ publicKey: await crypto.subtle.importKey(
7
+ "jwk",
8
+ {
9
+ crv: "Ed25519",
10
+ ext: true,
11
+ key_ops: ["verify"],
12
+ kty: "OKP",
13
+ // cSpell: disable
14
+ x: "LR8epAGDe-cVq5p2Tx49CCfphpk1rNhkNoY9i-XEUfg",
15
+ // cSpell: enable
16
+ },
17
+ "Ed25519",
18
+ true,
19
+ ["verify"],
20
+ ),
21
+ }) as CryptographicKey & { publicKey: CryptoKey };
22
+
23
+ export const rsaPublicKey = new CryptographicKey({
24
+ id: new URL("https://example.com/key"),
25
+ owner: new URL("https://example.com/person"),
26
+ publicKey: await crypto.subtle.importKey(
27
+ "jwk",
28
+ {
29
+ kty: "RSA",
30
+ alg: "RS256",
31
+ // cSpell: disable
32
+ n: "yIB9rotX8G6r6_6toT-x24BUiQ_HaPH1Em9dOt4c94s-OPFoEdH7DY7Iym9A8Ll" +
33
+ "H4JaGF8KD38bLHWe1S4x0jV3gHJKhK7veJfGZCKUENcQecBZ-YWUs5HWvUIX1vVB" +
34
+ "__0luHrg6BQKGOrSOE-WIAxyr0qsWCFfZzQrvSnUD2yvg1arJX2xhms14uxoRd5K" +
35
+ "g9efKSCmmQaNEapicARUmFWrIEpGFa_nUUnqimssAGw1eZFqf3wA4TjhsuARBhGa" +
36
+ "Jtv_3KEa016eMZxy3kDlOjZnXZTaTgWkXdodwUvy8563fes3Al6BlcS2iJ9qbtha" +
37
+ "8rSm0FHqoUKH73JsLPKQIwQ",
38
+ e: "AQAB",
39
+ // cSpell: enable
40
+ key_ops: ["verify"],
41
+ ext: true,
42
+ },
43
+ {
44
+ name: "RSASSA-PKCS1-v1_5",
45
+ hash: "SHA-256",
46
+ },
47
+ true,
48
+ ["verify"],
49
+ ),
50
+ }) as CryptographicKey & { publicKey: CryptoKey };
package/src/leave.yaml ADDED
@@ -0,0 +1,14 @@
1
+ $schema: ../../vocab-tools/schema.yaml
2
+ name: Leave
3
+ compactName: Leave
4
+ uri: "https://www.w3.org/ns/activitystreams#Leave"
5
+ extends: "https://www.w3.org/ns/activitystreams#Activity"
6
+ entity: true
7
+ description: |
8
+ Indicates that the `actor` has left the `object`.
9
+ The `target` and `origin` typically have no meaning.
10
+ defaultContext:
11
+ - "https://w3id.org/identity/v1"
12
+ - "https://www.w3.org/ns/activitystreams"
13
+ - "https://w3id.org/security/data-integrity/v1"
14
+ properties: []
package/src/like.yaml ADDED
@@ -0,0 +1,16 @@
1
+ $schema: ../../vocab-tools/schema.yaml
2
+ name: Like
3
+ compactName: Like
4
+ uri: "https://www.w3.org/ns/activitystreams#Like"
5
+ extends: "https://www.w3.org/ns/activitystreams#Activity"
6
+ entity: true
7
+ description: |
8
+ Indicates that the `actor` likes, recommends or endorses the `object`.
9
+ The `target` and `origin` typically have no defined meaning.
10
+ defaultContext:
11
+ - "https://w3id.org/identity/v1"
12
+ - "https://www.w3.org/ns/activitystreams"
13
+ - "https://w3id.org/security/data-integrity/v1"
14
+ - toot: "http://joinmastodon.org/ns#"
15
+ Emoji: "toot:Emoji"
16
+ properties: []