@fedify/fedify 2.2.19 → 2.2.21
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.
- package/dist/attachment-arrays-CalAATqD.mjs +16 -0
- package/dist/{builder-UmydCxtK.mjs → builder-4ImvtjG4.mjs} +3 -3
- package/dist/callback-0KrwzutD.d.mts +2607 -0
- package/dist/{client-CSddvgWN.d.ts → client-9DPcy_Yx.d.ts} +16 -1
- package/dist/{client-CAM_bQXx.d.cts → client-B3ruDgWg.d.cts} +16 -1
- package/dist/{client-9F_u23dc.mjs → client-XYMC0Mmk.mjs} +189 -65
- package/dist/compat/attachment-arrays.test.d.mts +2 -0
- package/dist/compat/attachment-arrays.test.mjs +255 -0
- package/dist/compat/mod.d.cts +1 -1
- package/dist/compat/mod.d.ts +1 -1
- package/dist/compat/outgoing-jsonld.test.mjs +1 -1
- package/dist/compat/public-audience.test.mjs +1 -1
- package/dist/compat/transformers.test.mjs +1 -1
- package/dist/{context-tJbL_Hkw.d.cts → context-CjWuov0g.d.cts} +57 -14
- package/dist/{context-OkwEpc3-.d.ts → context-DZqI2LJD.d.ts} +57 -14
- package/dist/{deno-CD-8UlUi.mjs → deno-AWk3S2Ug.mjs} +1 -1
- package/dist/docloader-Bogpjg4d.mjs +125 -0
- package/dist/federation/attachment-responses.test.d.mts +2 -0
- package/dist/federation/attachment-responses.test.mjs +182 -0
- package/dist/federation/builder.test.mjs +1 -1
- package/dist/federation/collection.test.mjs +1 -1
- package/dist/federation/delivery-attachments.test.d.mts +2 -0
- package/dist/federation/delivery-attachments.test.mjs +288 -0
- package/dist/federation/handler.test.mjs +208 -16
- package/dist/federation/idempotency.test.mjs +2 -2
- package/dist/federation/inbox.test.mjs +2 -2
- package/dist/federation/middleware.test.mjs +1567 -30
- package/dist/federation/mod.cjs +1 -1
- package/dist/federation/mod.d.cts +2 -2
- package/dist/federation/mod.d.ts +2 -2
- package/dist/federation/mod.js +1 -1
- package/dist/federation/negotiation.test.mjs +1 -1
- package/dist/federation/retry.test.mjs +1 -1
- package/dist/federation/send.test.mjs +723 -68
- package/dist/federation/temporal.test.mjs +25 -1
- package/dist/federation/webfinger.test.mjs +1 -1
- package/dist/{http-BBBUbwKh.mjs → http-B3wCvgu8.mjs} +199 -99
- package/dist/{http-DrUG4fPS.cjs → http-BNaPJVnF.cjs} +178 -107
- package/dist/{http-DJK2udgX.js → http-BpdLaGy8.js} +177 -106
- package/dist/{http-Dl00HXr4.d.ts → http-C8qLHs_Z.d.cts} +3 -4
- package/dist/{http-DqZhyEso.d.cts → http-D8WmcRAF.d.ts} +3 -4
- package/dist/{inbox-Dca_0fwc.mjs → inbox-DLy6WBXU.mjs} +1 -1
- package/dist/{key-DolXUaLH.mjs → key-Bhc8cQC7.mjs} +3 -2
- package/dist/{kv-cache-Bk3V1Tiu.cjs → kv-cache-Bj3CY9Jo.cjs} +59 -17
- package/dist/{kv-cache-DDm80t1K.js → kv-cache-CvjLUQTf.js} +60 -18
- package/dist/{ld-rTdIfZ63.mjs → ld-DTeykI0e.mjs} +153 -21
- package/dist/ld-signature-Dgz_b89j.mjs +23 -0
- package/dist/{middleware-BWOwEGpy.cjs → middleware-BSQP4d9p.cjs} +642 -149
- package/dist/{middleware-B4-Rzdi3.cjs → middleware-CWOzxb3o.cjs} +1 -1
- package/dist/{middleware-DYK_res8.mjs → middleware-DkMsC5mQ.mjs} +1 -1
- package/dist/{middleware-BimXKBcP.js → middleware-Dx1iwFk8.js} +641 -149
- package/dist/{middleware-CpXoRHs3.mjs → middleware-dlGvSrXl.mjs} +452 -122
- package/dist/{mod-D2JyWtW3.d.cts → mod-BmxqcEnU.d.ts} +30 -13
- package/dist/{mod-a6kmB8xD.d.cts → mod-DWEx2D4q.d.cts} +1 -1
- package/dist/{mod-DQGjRJUG.d.ts → mod-DnPmz3-S.d.ts} +1 -1
- package/dist/{mod-ej_rLx8h.d.ts → mod-INjDw-m0.d.cts} +30 -13
- package/dist/{mod-B6LmugJ4.d.ts → mod-REfljt0T.d.ts} +4 -10
- package/dist/{mod-V2vDnYNu.d.cts → mod-UvIGUHqW.d.cts} +4 -10
- package/dist/mod.cjs +5 -5
- package/dist/mod.d.cts +8 -8
- package/dist/mod.d.ts +8 -8
- package/dist/mod.js +5 -5
- package/dist/nodeinfo/client.test.mjs +764 -18
- package/dist/nodeinfo/handler.test.mjs +1 -1
- package/dist/nodeinfo/mod.cjs +1 -1
- package/dist/nodeinfo/mod.d.cts +1 -1
- package/dist/nodeinfo/mod.d.ts +1 -1
- package/dist/nodeinfo/mod.js +1 -1
- package/dist/nodeinfo/types.test.mjs +1 -1
- package/dist/otel/exporter.test.mjs +292 -30
- package/dist/otel/mod.cjs +36 -30
- package/dist/otel/mod.d.cts +13 -0
- package/dist/otel/mod.d.ts +13 -0
- package/dist/otel/mod.js +36 -30
- package/dist/{outgoing-jsonld-amccRMrV.mjs → outgoing-jsonld-DHf_DYXp.mjs} +38 -8
- package/dist/{owner-CVfzyM5V.mjs → owner-BsA7qMHB.mjs} +2 -2
- package/dist/{proof-gOGM-sJS.mjs → proof-C63Hqt9N.mjs} +40 -15
- package/dist/{proof-DhaTTn-P.cjs → proof-Dbz6ApNP.cjs} +1190 -1007
- package/dist/{proof-CaQ4KG6y.js → proof-QV_o5ZqS.js} +1174 -1003
- package/dist/send-CAdpwbFX.mjs +416 -0
- package/dist/sig/http.test.mjs +528 -2
- package/dist/sig/key-types.test.d.mts +218 -0
- package/dist/sig/key-types.test.mjs +8 -0
- package/dist/sig/key.test.mjs +2 -2
- package/dist/sig/ld.test.mjs +573 -8
- package/dist/sig/mod.cjs +2 -2
- package/dist/sig/mod.d.cts +3 -3
- package/dist/sig/mod.d.ts +3 -3
- package/dist/sig/mod.js +2 -2
- package/dist/sig/owner.test.mjs +1 -1
- package/dist/sig/proof.test.mjs +96 -4
- package/dist/{temporal-CA4Y9hBJ.mjs → temporal-B3JGkVgk.mjs} +3 -5
- package/dist/testing/mod.d.mts +1 -2396
- package/dist/{types-DRPjmHVV.cjs → types-BWx7zw3Y.cjs} +187 -63
- package/dist/{types-miAYfiGO.js → types-Dx_w2JSM.js} +188 -64
- package/dist/utils/docloader.test.mjs +318 -34
- package/dist/utils/mod.cjs +1 -1
- package/dist/utils/mod.d.cts +1 -1
- package/dist/utils/mod.d.ts +1 -1
- package/dist/utils/mod.js +1 -1
- package/package.json +6 -6
- package/dist/docloader-D1ghurDJ.mjs +0 -83
- package/dist/send-D35Va72B.mjs +0 -260
- /package/dist/{activity-listener-ell7W1s9.mjs → activity-listener-tztVvlNb.mjs} +0 -0
- /package/dist/{collection-D-HqUuA2.mjs → collection-CA3V5zyK.mjs} +0 -0
- /package/dist/{negotiation-SQvQgUqe.mjs → negotiation-VnHNB0Q5.mjs} +0 -0
- /package/dist/{public-audience-DpJqzPuh.mjs → public-audience-4g3_Ze4y.mjs} +0 -0
- /package/dist/{retry-v_sGLH1d.mjs → retry-CXg_MBI-.mjs} +0 -0
- /package/dist/{types-J53Kw7so.mjs → types-BFowWFTT.mjs} +0 -0
package/dist/testing/mod.d.mts
CHANGED
|
@@ -1,2403 +1,8 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
+
import { a as RequestContext, i as OutboxContext, r as InboxContext, s as Federation } from "../callback-0KrwzutD.mjs";
|
|
3
4
|
import { testDefinitions } from "@fedify/fixture";
|
|
4
|
-
import { Activity, Actor, Collection, CryptographicKey, Hashtag, Link, LookupObjectOptions, Multikey, Object as Object$1, Recipient, Tombstone, TraverseCollectionOptions } from "@fedify/vocab";
|
|
5
|
-
import { Link as Link$1, LookupWebFingerOptions, ResourceDescriptor } from "@fedify/webfinger";
|
|
6
|
-
import { TracerProvider } from "@opentelemetry/api";
|
|
7
|
-
import { DocumentLoader, GetUserAgentOptions } from "@fedify/vocab-runtime";
|
|
8
5
|
|
|
9
|
-
//#region src/nodeinfo/types.d.ts
|
|
10
|
-
/**
|
|
11
|
-
* The type of the result of parsing JSON.
|
|
12
|
-
*/
|
|
13
|
-
type JsonValue = {
|
|
14
|
-
[key: string]: JsonValue | undefined;
|
|
15
|
-
} | JsonValue[] | string | number | boolean | null;
|
|
16
|
-
/**
|
|
17
|
-
* A NodeInfo object as defined in the NodeInfo 2.1 schema.
|
|
18
|
-
*/
|
|
19
|
-
interface NodeInfo {
|
|
20
|
-
/**
|
|
21
|
-
* Metadata about server software in use.
|
|
22
|
-
*/
|
|
23
|
-
readonly software: Software;
|
|
24
|
-
/**
|
|
25
|
-
* The protocols supported on this server. At least one protocol must be
|
|
26
|
-
* supported.
|
|
27
|
-
*/
|
|
28
|
-
readonly protocols: readonly Protocol[];
|
|
29
|
-
/**
|
|
30
|
-
* The third party sites this server can connect to via their application API.
|
|
31
|
-
*/
|
|
32
|
-
readonly services?: Services;
|
|
33
|
-
/**
|
|
34
|
-
* Whether this server allows open self-registration. Defaults to `false`.
|
|
35
|
-
*/
|
|
36
|
-
readonly openRegistrations?: boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Usage statistics for this server.
|
|
39
|
-
*/
|
|
40
|
-
readonly usage: Usage;
|
|
41
|
-
/**
|
|
42
|
-
* Free form key value pairs for software specific values.
|
|
43
|
-
* Clients should not rely on any specific key present.
|
|
44
|
-
*/
|
|
45
|
-
readonly metadata?: Readonly<Record<string, JsonValue>>;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Metadata about server software in use.
|
|
49
|
-
*/
|
|
50
|
-
interface Software {
|
|
51
|
-
/**
|
|
52
|
-
* The canonical name of this server software. This must comply with
|
|
53
|
-
* pattern `/^[a-z0-9-]+$/`.
|
|
54
|
-
*/
|
|
55
|
-
readonly name: string;
|
|
56
|
-
/**
|
|
57
|
-
* The version of this server software.
|
|
58
|
-
*/
|
|
59
|
-
readonly version: string;
|
|
60
|
-
/**
|
|
61
|
-
* The URL of the source code repository of this server software.
|
|
62
|
-
*/
|
|
63
|
-
readonly repository?: URL;
|
|
64
|
-
/**
|
|
65
|
-
* The URL of the homepage of this server software.
|
|
66
|
-
*/
|
|
67
|
-
readonly homepage?: URL;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* The protocols supported on this server.
|
|
71
|
-
*/
|
|
72
|
-
type Protocol = "activitypub" | "buddycloud" | "dfrn" | "diaspora" | "libertree" | "ostatus" | "pumpio" | "tent" | "xmpp" | "zot";
|
|
73
|
-
/**
|
|
74
|
-
* The third party sites this server can connect to via their application API.
|
|
75
|
-
*/
|
|
76
|
-
interface Services {
|
|
77
|
-
/**
|
|
78
|
-
* The third party sites this server can retrieve messages from for combined
|
|
79
|
-
* display with regular traffic.
|
|
80
|
-
*/
|
|
81
|
-
readonly inbound?: readonly InboundService[];
|
|
82
|
-
/**
|
|
83
|
-
* The third party sites this server can publish messages to on the behalf
|
|
84
|
-
* of a user.
|
|
85
|
-
*/
|
|
86
|
-
readonly outbound?: readonly OutboundService[];
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* The third party sites this server can retrieve messages from for combined
|
|
90
|
-
* display with regular traffic.
|
|
91
|
-
*/
|
|
92
|
-
type InboundService = "atom1.0" | "gnusocial" | "imap" | "pnut" | "pop3" | "pumpio" | "rss2.0" | "twitter";
|
|
93
|
-
/**
|
|
94
|
-
* The third party sites this server can publish messages to on the behalf
|
|
95
|
-
* of a user.
|
|
96
|
-
*/
|
|
97
|
-
type OutboundService = "atom1.0" | "blogger" | "buddycloud" | "diaspora" | "dreamwidth" | "drupal" | "facebook" | "friendica" | "gnusocial" | "google" | "insanejournal" | "libertree" | "linkedin" | "livejournal" | "mediagoblin" | "myspace" | "pinterest" | "pnut" | "posterous" | "pumpio" | "redmatrix" | "rss2.0" | "smtp" | "tent" | "tumblr" | "twitter" | "wordpress" | "xmpp";
|
|
98
|
-
/**
|
|
99
|
-
* Usage statistics for this server.
|
|
100
|
-
*/
|
|
101
|
-
interface Usage {
|
|
102
|
-
/**
|
|
103
|
-
* Statistics about the users of this server.
|
|
104
|
-
*/
|
|
105
|
-
readonly users: {
|
|
106
|
-
/**
|
|
107
|
-
* The total amount of on this server registered users. This number
|
|
108
|
-
* has to be an integer greater than or equal to zero.
|
|
109
|
-
*/
|
|
110
|
-
readonly total?: number;
|
|
111
|
-
/**
|
|
112
|
-
* The amount of users that signed in at least once in the last 180 days.
|
|
113
|
-
* This number has to be an integer greater than or equal to zero.
|
|
114
|
-
*/
|
|
115
|
-
readonly activeHalfyear?: number;
|
|
116
|
-
/**
|
|
117
|
-
* The amount of users that signed in at least once in the last 30 days.
|
|
118
|
-
* This number has to be an integer greater than or equal to zero.
|
|
119
|
-
*/
|
|
120
|
-
readonly activeMonth?: number;
|
|
121
|
-
};
|
|
122
|
-
/**
|
|
123
|
-
* The amount of posts that were made by users that are registered on this
|
|
124
|
-
* server. This number has to be an integer greater than or equal to zero.
|
|
125
|
-
*/
|
|
126
|
-
readonly localPosts: number;
|
|
127
|
-
/**
|
|
128
|
-
* The amount of comments that were made by users that are registered on this
|
|
129
|
-
* server. This number has to be an integer greater than or equal to zero.
|
|
130
|
-
*/
|
|
131
|
-
readonly localComments: number;
|
|
132
|
-
}
|
|
133
|
-
//#endregion
|
|
134
|
-
//#region src/nodeinfo/client.d.ts
|
|
135
|
-
/**
|
|
136
|
-
* Options for {@link getNodeInfo} function.
|
|
137
|
-
* @since 1.2.0
|
|
138
|
-
*/
|
|
139
|
-
interface GetNodeInfoOptions {
|
|
140
|
-
/**
|
|
141
|
-
* Whether to directly fetch the NodeInfo document from the given URL.
|
|
142
|
-
* Otherwise, the NodeInfo document will be fetched from the `.well-known`
|
|
143
|
-
* location of the given URL.
|
|
144
|
-
*
|
|
145
|
-
* Turned off by default.
|
|
146
|
-
*/
|
|
147
|
-
direct?: boolean;
|
|
148
|
-
/**
|
|
149
|
-
* How strictly to parse the NodeInfo document.
|
|
150
|
-
*
|
|
151
|
-
* - `"strict"`: Parse the NodeInfo document strictly. If the document is
|
|
152
|
-
* invalid, `undefined` is returned. This is the default.
|
|
153
|
-
* - `"best-effort"`: Try to parse the NodeInfo document even if it is
|
|
154
|
-
* invalid.
|
|
155
|
-
* - `"none"`: Do not parse the NodeInfo document. The function will return
|
|
156
|
-
* the raw JSON value.
|
|
157
|
-
*/
|
|
158
|
-
parse?: "strict" | "best-effort" | "none";
|
|
159
|
-
/**
|
|
160
|
-
* The options for making `User-Agent` header.
|
|
161
|
-
* If a string is given, it is used as the `User-Agent` header value.
|
|
162
|
-
* If an object is given, it is passed to {@link getUserAgent} to generate
|
|
163
|
-
* the `User-Agent` header value.
|
|
164
|
-
* @since 1.3.0
|
|
165
|
-
*/
|
|
166
|
-
userAgent?: GetUserAgentOptions | string;
|
|
167
|
-
}
|
|
168
|
-
//#endregion
|
|
169
|
-
//#region src/sig/key.d.ts
|
|
170
|
-
/**
|
|
171
|
-
* Detailed fetch failure information from {@link fetchKeyDetailed}.
|
|
172
|
-
* @since 2.1.0
|
|
173
|
-
*/
|
|
174
|
-
type FetchKeyErrorResult = {
|
|
175
|
-
readonly status: number;
|
|
176
|
-
readonly response: Response;
|
|
177
|
-
} | {
|
|
178
|
-
readonly error: Error;
|
|
179
|
-
};
|
|
180
|
-
//#endregion
|
|
181
|
-
//#region src/sig/owner.d.ts
|
|
182
|
-
/**
|
|
183
|
-
* Options for {@link getKeyOwner}.
|
|
184
|
-
* @since 0.8.0
|
|
185
|
-
*/
|
|
186
|
-
interface GetKeyOwnerOptions {
|
|
187
|
-
/**
|
|
188
|
-
* The document loader to use for fetching the key and its owner.
|
|
189
|
-
*/
|
|
190
|
-
documentLoader?: DocumentLoader;
|
|
191
|
-
/**
|
|
192
|
-
* The context loader to use for JSON-LD context retrieval.
|
|
193
|
-
*/
|
|
194
|
-
contextLoader?: DocumentLoader;
|
|
195
|
-
/**
|
|
196
|
-
* The OpenTelemetry tracer provider to use for tracing. If omitted,
|
|
197
|
-
* the global tracer provider is used.
|
|
198
|
-
* @since 1.3.0
|
|
199
|
-
*/
|
|
200
|
-
tracerProvider?: TracerProvider;
|
|
201
|
-
}
|
|
202
|
-
//#endregion
|
|
203
|
-
//#region src/sig/http.d.ts
|
|
204
|
-
/**
|
|
205
|
-
* The reason why {@link verifyRequestDetailed} could not verify a request.
|
|
206
|
-
* @since 2.1.0
|
|
207
|
-
*/
|
|
208
|
-
type VerifyRequestFailureReason = {
|
|
209
|
-
readonly type: "keyFetchError";
|
|
210
|
-
readonly keyId: URL;
|
|
211
|
-
readonly result: FetchKeyErrorResult;
|
|
212
|
-
} | {
|
|
213
|
-
readonly type: "invalidSignature";
|
|
214
|
-
readonly keyId?: URL;
|
|
215
|
-
} | {
|
|
216
|
-
readonly type: "noSignature";
|
|
217
|
-
};
|
|
218
|
-
//#endregion
|
|
219
|
-
//#region src/federation/collection.d.ts
|
|
220
|
-
/**
|
|
221
|
-
* A page of items.
|
|
222
|
-
*/
|
|
223
|
-
interface PageItems<TItem> {
|
|
224
|
-
readonly prevCursor?: string | null;
|
|
225
|
-
readonly nextCursor?: string | null;
|
|
226
|
-
readonly items: readonly TItem[];
|
|
227
|
-
}
|
|
228
|
-
//#endregion
|
|
229
|
-
//#region src/federation/send.d.ts
|
|
230
|
-
/**
|
|
231
|
-
* A key pair for an actor who sends an activity.
|
|
232
|
-
* @since 0.10.0
|
|
233
|
-
*/
|
|
234
|
-
interface SenderKeyPair {
|
|
235
|
-
/**
|
|
236
|
-
* The actor's private key to sign the request.
|
|
237
|
-
*/
|
|
238
|
-
readonly privateKey: CryptoKey;
|
|
239
|
-
/**
|
|
240
|
-
* The public key ID that corresponds to the private key.
|
|
241
|
-
*/
|
|
242
|
-
readonly keyId: URL;
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* An error that is thrown when an activity fails to send to a remote inbox.
|
|
246
|
-
* It contains structured information about the failure, including the HTTP
|
|
247
|
-
* status code, the inbox URL, and the response body.
|
|
248
|
-
* @since 2.0.0
|
|
249
|
-
*/
|
|
250
|
-
declare class SendActivityError extends Error {
|
|
251
|
-
/**
|
|
252
|
-
* The inbox URL that the activity was being sent to.
|
|
253
|
-
*/
|
|
254
|
-
readonly inbox: URL;
|
|
255
|
-
/**
|
|
256
|
-
* The HTTP status code returned by the inbox.
|
|
257
|
-
*/
|
|
258
|
-
readonly statusCode: number;
|
|
259
|
-
/**
|
|
260
|
-
* The response body from the inbox, if any. Note that this may be
|
|
261
|
-
* truncated to a maximum of 1 KiB to prevent excessive memory consumption
|
|
262
|
-
* when remote servers return large error pages (e.g., Cloudflare error pages).
|
|
263
|
-
* If truncated, the string will end with `"… (truncated)"`.
|
|
264
|
-
*/
|
|
265
|
-
readonly responseBody: string;
|
|
266
|
-
/**
|
|
267
|
-
* Creates a new {@link SendActivityError}.
|
|
268
|
-
* @param inbox The inbox URL.
|
|
269
|
-
* @param statusCode The HTTP status code.
|
|
270
|
-
* @param message The error message.
|
|
271
|
-
* @param responseBody The response body.
|
|
272
|
-
*/
|
|
273
|
-
constructor(inbox: URL, statusCode: number, message: string, responseBody: string);
|
|
274
|
-
}
|
|
275
|
-
//#endregion
|
|
276
|
-
//#region src/federation/callback.d.ts
|
|
277
|
-
/**
|
|
278
|
-
* A callback that dispatches a {@link NodeInfo} object.
|
|
279
|
-
*
|
|
280
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
281
|
-
*/
|
|
282
|
-
type NodeInfoDispatcher<TContextData> = (context: RequestContext<TContextData>) => NodeInfo | Promise<NodeInfo>;
|
|
283
|
-
/**
|
|
284
|
-
* A callback that dispatches a array of {@link Link}.
|
|
285
|
-
*
|
|
286
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
287
|
-
* @param resource The URL queried via WebFinger.
|
|
288
|
-
* @returns Links related to the queried resource.
|
|
289
|
-
*/
|
|
290
|
-
type WebFingerLinksDispatcher<TContextData> = (context: RequestContext<TContextData>, resource: URL) => readonly Link$1[] | Promise<readonly Link$1[]>;
|
|
291
|
-
/**
|
|
292
|
-
* A callback that dispatches an {@link Actor} object or a {@link Tombstone}.
|
|
293
|
-
*
|
|
294
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
295
|
-
* @param context The request context.
|
|
296
|
-
* @param identifier The actor's internal identifier or username.
|
|
297
|
-
*/
|
|
298
|
-
type ActorDispatcher<TContextData> = (context: RequestContext<TContextData>, identifier: string) => Actor | Tombstone | null | Promise<Actor | Tombstone | null>;
|
|
299
|
-
/**
|
|
300
|
-
* A callback that dispatches key pairs for an actor.
|
|
301
|
-
*
|
|
302
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
303
|
-
* @param context The context.
|
|
304
|
-
* @param identifier The actor's internal identifier or username.
|
|
305
|
-
* @returns The key pairs.
|
|
306
|
-
* @since 0.10.0
|
|
307
|
-
*/
|
|
308
|
-
type ActorKeyPairsDispatcher<TContextData> = (context: Context<TContextData>, identifier: string) => CryptoKeyPair[] | Promise<CryptoKeyPair[]>;
|
|
309
|
-
/**
|
|
310
|
-
* A callback that maps a WebFinger username to the corresponding actor's
|
|
311
|
-
* internal identifier, or `null` if the username is not found.
|
|
312
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
313
|
-
* @param context The context.
|
|
314
|
-
* @param username The WebFinger username.
|
|
315
|
-
* @returns The actor's internal identifier, or `null` if the username is not
|
|
316
|
-
* found.
|
|
317
|
-
* @since 0.15.0
|
|
318
|
-
*/
|
|
319
|
-
type ActorHandleMapper<TContextData> = (context: Context<TContextData>, username: string) => string | null | Promise<string | null>;
|
|
320
|
-
/**
|
|
321
|
-
* A callback that maps a WebFinger query to the corresponding actor's
|
|
322
|
-
* internal identifier or username, or `null` if the query is not found.
|
|
323
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
324
|
-
* @param context The request context.
|
|
325
|
-
* @param resource The URL that was queried through WebFinger.
|
|
326
|
-
* @returns The actor's internal identifier or username, or `null` if the query
|
|
327
|
-
* is not found.
|
|
328
|
-
* @since 1.4.0
|
|
329
|
-
*/
|
|
330
|
-
type ActorAliasMapper<TContextData> = (context: RequestContext<TContextData>, resource: URL) => {
|
|
331
|
-
identifier: string;
|
|
332
|
-
} | {
|
|
333
|
-
username: string;
|
|
334
|
-
} | null | Promise<{
|
|
335
|
-
identifier: string;
|
|
336
|
-
} | {
|
|
337
|
-
username: string;
|
|
338
|
-
} | null>;
|
|
339
|
-
/**
|
|
340
|
-
* A callback that dispatches an object.
|
|
341
|
-
*
|
|
342
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
343
|
-
* @template TObject The type of object to dispatch.
|
|
344
|
-
* @template TParam The parameter names of the requested URL.
|
|
345
|
-
* @since 0.7.0
|
|
346
|
-
*/
|
|
347
|
-
type ObjectDispatcher<TContextData, TObject extends Object$1, TParam extends string> = (context: RequestContext<TContextData>, values: Record<TParam, string>) => TObject | null | Promise<TObject | null>;
|
|
348
|
-
/**
|
|
349
|
-
* A callback that dispatches a collection.
|
|
350
|
-
*
|
|
351
|
-
* @template TItem The type of items in the collection.
|
|
352
|
-
* @template TContext The type of the context. {@link Context} or
|
|
353
|
-
* {@link RequestContext}.
|
|
354
|
-
* @template TContextData The context data to pass to the `TContext`.
|
|
355
|
-
* @template TFilter The type of the filter, if any.
|
|
356
|
-
* @param context The context.
|
|
357
|
-
* @param identifier The internal identifier or the username of the collection
|
|
358
|
-
* owner.
|
|
359
|
-
* @param cursor The cursor to start the collection from, or `null` to dispatch
|
|
360
|
-
* the entire collection without pagination.
|
|
361
|
-
* @param filter The filter to apply to the collection, if any.
|
|
362
|
-
*/
|
|
363
|
-
type CollectionDispatcher<TItem, TContext extends Context<TContextData>, TContextData, TFilter> = (context: TContext, identifier: string, cursor: string | null, filter?: TFilter) => PageItems<TItem> | null | Promise<PageItems<TItem> | null>;
|
|
364
|
-
/**
|
|
365
|
-
* A callback that counts the number of items in a collection.
|
|
366
|
-
*
|
|
367
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
368
|
-
* @param context The context.
|
|
369
|
-
* @param identifier The internal identifier or the username of the collection
|
|
370
|
-
* owner.
|
|
371
|
-
* @param filter The filter to apply to the collection, if any.
|
|
372
|
-
*/
|
|
373
|
-
type CollectionCounter<TContextData, TFilter> = (context: RequestContext<TContextData>, identifier: string, filter?: TFilter) => number | bigint | null | Promise<number | bigint | null>;
|
|
374
|
-
/**
|
|
375
|
-
* A callback that returns a cursor for a collection.
|
|
376
|
-
*
|
|
377
|
-
* @template TContext The type of the context. {@link Context} or
|
|
378
|
-
* {@link RequestContext}.
|
|
379
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
380
|
-
* @template TFilter The type of the filter, if any.
|
|
381
|
-
* @param context The context.
|
|
382
|
-
* @param identifier The internal identifier or the username of the collection
|
|
383
|
-
* owner.
|
|
384
|
-
* @param filter The filter to apply to the collection, if any.
|
|
385
|
-
*/
|
|
386
|
-
type CollectionCursor<TContext extends Context<TContextData>, TContextData, TFilter> = (context: TContext, identifier: string, filter?: TFilter) => string | null | Promise<string | null>;
|
|
387
|
-
/**
|
|
388
|
-
* A callback that listens for activities in an inbox.
|
|
389
|
-
*
|
|
390
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
391
|
-
* @template TActivity The type of activity to listen for.
|
|
392
|
-
* @param context The inbox context.
|
|
393
|
-
* @param activity The activity that was received.
|
|
394
|
-
*/
|
|
395
|
-
type InboxListener<TContextData, TActivity extends Activity> = (context: InboxContext<TContextData>, activity: TActivity) => void | Promise<void>;
|
|
396
|
-
/**
|
|
397
|
-
* A callback that listens for activities in an outbox.
|
|
398
|
-
*
|
|
399
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
400
|
-
* @template TActivity The type of activity to listen for.
|
|
401
|
-
* @param context The outbox context.
|
|
402
|
-
* @param activity The activity that was received.
|
|
403
|
-
* @since 2.2.0
|
|
404
|
-
*/
|
|
405
|
-
type OutboxListener<TContextData, TActivity extends Activity> = (context: OutboxContext<TContextData>, activity: TActivity) => void | Promise<void>;
|
|
406
|
-
/**
|
|
407
|
-
* The reason why an incoming activity could not be verified.
|
|
408
|
-
*
|
|
409
|
-
* Unlike inbox listeners registered through {@link InboxListenerSetters.on},
|
|
410
|
-
* unverified activity handlers are called only when the activity payload could
|
|
411
|
-
* be parsed but its HTTP signatures could not be verified.
|
|
412
|
-
*
|
|
413
|
-
* @since 2.1.0
|
|
414
|
-
*/
|
|
415
|
-
type UnverifiedActivityReason = VerifyRequestFailureReason;
|
|
416
|
-
/**
|
|
417
|
-
* A callback that handles activities whose signatures could not be verified.
|
|
418
|
-
*
|
|
419
|
-
* Returning a {@link Response} overrides Fedify's default `401 Unauthorized`
|
|
420
|
-
* response. Returning `void` keeps the default behavior.
|
|
421
|
-
*
|
|
422
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
423
|
-
* @param context The request context.
|
|
424
|
-
* @param activity The incoming activity that could be parsed.
|
|
425
|
-
* @param reason The reason why signature verification failed.
|
|
426
|
-
* @since 2.1.0
|
|
427
|
-
*/
|
|
428
|
-
type UnverifiedActivityHandler<TContextData> = (context: RequestContext<TContextData>, activity: Activity, reason: UnverifiedActivityReason) => void | Response | Promise<void | Response>;
|
|
429
|
-
/**
|
|
430
|
-
* A callback that handles errors in an inbox.
|
|
431
|
-
*
|
|
432
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
433
|
-
* @param context The inbox context.
|
|
434
|
-
*/
|
|
435
|
-
type InboxErrorHandler<TContextData> = (context: Context<TContextData>, error: Error) => void | Promise<void>;
|
|
436
|
-
/**
|
|
437
|
-
* A callback that handles errors in an outbox listener.
|
|
438
|
-
*
|
|
439
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
440
|
-
* @param context The outbox context.
|
|
441
|
-
* @param error The error that occurred.
|
|
442
|
-
* @since 2.2.0
|
|
443
|
-
*/
|
|
444
|
-
type OutboxListenerErrorHandler<TContextData> = (context: OutboxContext<TContextData>, error: Error) => void | Promise<void>;
|
|
445
|
-
/**
|
|
446
|
-
* A callback that dispatches the key pair for the authenticated document loader
|
|
447
|
-
* of the {@link Context} passed to the shared inbox listener.
|
|
448
|
-
*
|
|
449
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
450
|
-
* @param context The context.
|
|
451
|
-
* @returns The username or the internal identifier of the actor or the key pair
|
|
452
|
-
* for the authenticated document loader of the {@link Context} passed
|
|
453
|
-
* to the shared inbox listener. If `null` is returned, the request is
|
|
454
|
-
* not authorized.
|
|
455
|
-
* @since 0.11.0
|
|
456
|
-
*/
|
|
457
|
-
type SharedInboxKeyDispatcher<TContextData> = (context: Context<TContextData>) => SenderKeyPair | {
|
|
458
|
-
identifier: string;
|
|
459
|
-
} | {
|
|
460
|
-
username: string;
|
|
461
|
-
} | null | Promise<SenderKeyPair | {
|
|
462
|
-
identifier: string;
|
|
463
|
-
} | {
|
|
464
|
-
username: string;
|
|
465
|
-
} | null>;
|
|
466
|
-
/**
|
|
467
|
-
* A callback that handles permanent delivery failures when sending activities
|
|
468
|
-
* to remote inboxes.
|
|
469
|
-
*
|
|
470
|
-
* This handler is called when an inbox returns an HTTP status code that
|
|
471
|
-
* indicates permanent failure (such as `410 Gone` or `404 Not Found`),
|
|
472
|
-
* allowing the application to clean up followers that are no longer reachable.
|
|
473
|
-
*
|
|
474
|
-
* Unlike {@link OutboxErrorHandler}, which is called for every delivery failure
|
|
475
|
-
* (including retries), this handler is called only once for permanent failures,
|
|
476
|
-
* after which delivery is not retried.
|
|
477
|
-
*
|
|
478
|
-
* If any errors are thrown in this callback, they are caught, logged,
|
|
479
|
-
* and ignored.
|
|
480
|
-
*
|
|
481
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
482
|
-
* @param context The context.
|
|
483
|
-
* @param values The delivery failure information.
|
|
484
|
-
* @since 2.0.0
|
|
485
|
-
*/
|
|
486
|
-
type OutboxPermanentFailureHandler<TContextData> = (context: Context<TContextData>, values: {
|
|
487
|
-
/** The inbox URL that failed. */readonly inbox: URL; /** The activity that failed to deliver. */
|
|
488
|
-
readonly activity: Activity; /** The error that occurred. */
|
|
489
|
-
readonly error: SendActivityError; /** The HTTP status code returned by the inbox. */
|
|
490
|
-
readonly statusCode: number;
|
|
491
|
-
/**
|
|
492
|
-
* The actor IDs that were supposed to receive the activity at this inbox.
|
|
493
|
-
*/
|
|
494
|
-
readonly actorIds: readonly URL[];
|
|
495
|
-
}) => void | Promise<void>;
|
|
496
|
-
/**
|
|
497
|
-
* A callback that determines if a request is authorized or not.
|
|
498
|
-
*
|
|
499
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
500
|
-
* @param context The request context.
|
|
501
|
-
* @param identifier The internal identifier of the actor that is being
|
|
502
|
-
* requested.
|
|
503
|
-
* @returns `true` if the request is authorized, `false` otherwise.
|
|
504
|
-
* @since 0.7.0
|
|
505
|
-
*/
|
|
506
|
-
type AuthorizePredicate<TContextData> = (context: RequestContext<TContextData>, identifier: string) => boolean | Promise<boolean>;
|
|
507
|
-
/**
|
|
508
|
-
* A callback that determines if a request is authorized or not.
|
|
509
|
-
*
|
|
510
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
511
|
-
* @template TParam The parameter names of the requested URL.
|
|
512
|
-
* @param context The request context.
|
|
513
|
-
* @param values The parameters of the requested URL.
|
|
514
|
-
* @returns `true` if the request is authorized, `false` otherwise.
|
|
515
|
-
* @since 0.7.0
|
|
516
|
-
*/
|
|
517
|
-
type ObjectAuthorizePredicate<TContextData, TParam extends string> = (context: RequestContext<TContextData>, values: Record<TParam, string>) => boolean | Promise<boolean>;
|
|
518
|
-
/**
|
|
519
|
-
* A callback that dispatches a custom collection.
|
|
520
|
-
*
|
|
521
|
-
* @template TItem The type of items in the collection.
|
|
522
|
-
* @template TParams The parameter names of the requested URL.
|
|
523
|
-
* @template TContext The type of the context. {@link Context} or
|
|
524
|
-
* {@link RequestContext}.
|
|
525
|
-
* @template TContextData The context data to pass to the `TContext`.
|
|
526
|
-
* @template TFilter The type of the filter, if any.
|
|
527
|
-
* @param context The context.
|
|
528
|
-
* @param values The parameters of the requested URL.
|
|
529
|
-
* @param cursor The cursor to start the collection from, or `null` to dispatch
|
|
530
|
-
* the entire collection without pagination.
|
|
531
|
-
* @since 1.8.0
|
|
532
|
-
*/
|
|
533
|
-
type CustomCollectionDispatcher<TItem, TParam extends string, TContext extends Context<TContextData>, TContextData> = (context: TContext, values: Record<TParam, string>, cursor: string | null) => PageItems<TItem> | null | Promise<PageItems<TItem> | null>;
|
|
534
|
-
/**
|
|
535
|
-
* A callback that counts the number of items in a custom collection.
|
|
536
|
-
*
|
|
537
|
-
* @template TParams The parameter names of the requested URL.
|
|
538
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
539
|
-
* @param context The context.
|
|
540
|
-
* @param values The parameters of the requested URL.
|
|
541
|
-
* @since 1.8.0
|
|
542
|
-
*/
|
|
543
|
-
type CustomCollectionCounter<TParam extends string, TContextData> = (context: RequestContext<TContextData>, values: Record<TParam, string>) => number | bigint | null | Promise<number | bigint | null>;
|
|
544
|
-
/**
|
|
545
|
-
* A callback that returns a cursor for a custom collection.
|
|
546
|
-
*
|
|
547
|
-
* @template TParams The parameter names of the requested URL.
|
|
548
|
-
* @template TContext The type of the context. {@link Context} or
|
|
549
|
-
* {@link RequestContext}.
|
|
550
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
551
|
-
* @template TFilter The type of the filter, if any.
|
|
552
|
-
* @param context The context.
|
|
553
|
-
* @param values The parameters of the requested URL.
|
|
554
|
-
* @since 1.8.0
|
|
555
|
-
*/
|
|
556
|
-
type CustomCollectionCursor<TParam extends string, TContext extends Context<TContextData>, TContextData> = (context: TContext, values: Record<TParam, string>) => string | null | Promise<string | null>;
|
|
557
|
-
//#endregion
|
|
558
|
-
//#region src/federation/queue.d.ts
|
|
559
|
-
interface SenderKeyJwkPair {
|
|
560
|
-
readonly keyId: string;
|
|
561
|
-
readonly privateKey: JsonWebKey;
|
|
562
|
-
}
|
|
563
|
-
/**
|
|
564
|
-
* A message that represents a task to be processed by the background worker.
|
|
565
|
-
* The concrete type of the message depends on the `type` property.
|
|
566
|
-
*
|
|
567
|
-
* Please do not depend on the concrete types of the messages, as they may
|
|
568
|
-
* change in the future. You should treat the `Message` type as an opaque
|
|
569
|
-
* type.
|
|
570
|
-
* @since 1.6.0
|
|
571
|
-
*/
|
|
572
|
-
type Message = FanoutMessage | OutboxMessage | InboxMessage;
|
|
573
|
-
interface FanoutMessage {
|
|
574
|
-
readonly type: "fanout";
|
|
575
|
-
readonly id: ReturnType<typeof crypto.randomUUID>;
|
|
576
|
-
readonly baseUrl: string;
|
|
577
|
-
readonly keys: readonly SenderKeyJwkPair[];
|
|
578
|
-
readonly inboxes: Readonly<Record<string, {
|
|
579
|
-
readonly actorIds: readonly string[];
|
|
580
|
-
readonly sharedInbox: boolean;
|
|
581
|
-
}>>;
|
|
582
|
-
readonly activity: unknown;
|
|
583
|
-
readonly activityId?: string;
|
|
584
|
-
readonly activityType: string;
|
|
585
|
-
readonly collectionSync?: string;
|
|
586
|
-
readonly orderingKey?: string;
|
|
587
|
-
/**
|
|
588
|
-
* Whether to apply outgoing JSON-LD wire-format normalization to queued
|
|
589
|
-
* activities that already carry Object Integrity Proofs.
|
|
590
|
-
*
|
|
591
|
-
* `true` is used for proofs Fedify created before fanout, or when callers
|
|
592
|
-
* explicitly request normalization for locally pre-signed activities.
|
|
593
|
-
* `false`/`undefined` preserves existing proofs as-is.
|
|
594
|
-
*/
|
|
595
|
-
readonly normalizeExistingProofs?: boolean;
|
|
596
|
-
readonly traceContext: Readonly<Record<string, string>>;
|
|
597
|
-
}
|
|
598
|
-
interface OutboxMessage {
|
|
599
|
-
readonly type: "outbox";
|
|
600
|
-
readonly id: ReturnType<typeof crypto.randomUUID>;
|
|
601
|
-
readonly baseUrl: string;
|
|
602
|
-
readonly keys: readonly SenderKeyJwkPair[];
|
|
603
|
-
readonly activity: unknown;
|
|
604
|
-
readonly activityId?: string;
|
|
605
|
-
readonly activityType: string;
|
|
606
|
-
readonly inbox: string;
|
|
607
|
-
readonly sharedInbox: boolean;
|
|
608
|
-
readonly actorIds?: readonly string[];
|
|
609
|
-
readonly started: string;
|
|
610
|
-
readonly attempt: number;
|
|
611
|
-
readonly headers: Readonly<Record<string, string>>;
|
|
612
|
-
readonly orderingKey?: string;
|
|
613
|
-
readonly traceContext: Readonly<Record<string, string>>;
|
|
614
|
-
}
|
|
615
|
-
interface InboxMessage {
|
|
616
|
-
readonly type: "inbox";
|
|
617
|
-
readonly id: ReturnType<typeof crypto.randomUUID>;
|
|
618
|
-
readonly baseUrl: string;
|
|
619
|
-
readonly activity: unknown;
|
|
620
|
-
/**
|
|
621
|
-
* The normalized JSON-LD representation of a signed inbox activity that
|
|
622
|
-
* Fedify already compacted successfully while accepting the request. Queue
|
|
623
|
-
* workers can reuse this producer-side parse cache under stricter loader or
|
|
624
|
-
* network constraints without changing the raw payload preserved for
|
|
625
|
-
* forwarding.
|
|
626
|
-
*
|
|
627
|
-
* This may exist even when {@link ldSignatureVerified} is `false`, because
|
|
628
|
-
* fallback-authenticated traffic and already-queued backlog items can still
|
|
629
|
-
* depend on the cached normalized form to avoid re-fetching remote custom
|
|
630
|
-
* contexts during worker processing.
|
|
631
|
-
*
|
|
632
|
-
* This is optional for backward compatibility with messages that were
|
|
633
|
-
* queued by older Fedify versions or that were already in a queue before
|
|
634
|
-
* upgrading.
|
|
635
|
-
*
|
|
636
|
-
* Fedify keeps this on the queued message itself instead of an external
|
|
637
|
-
* sidecar because generic queue backends do not provide reliable lifecycle
|
|
638
|
-
* guarantees for auxiliary storage across retries and redeliveries.
|
|
639
|
-
*
|
|
640
|
-
* @internal
|
|
641
|
-
*/
|
|
642
|
-
readonly normalizedActivity?: unknown;
|
|
643
|
-
/**
|
|
644
|
-
* Whether the producer actually verified the Linked Data Signature before
|
|
645
|
-
* queueing this message. This lets workers distinguish verified LDS replay
|
|
646
|
-
* from other authenticated inbox traffic that merely happened to include a
|
|
647
|
-
* signature block. This provenance marker is separate from the optional
|
|
648
|
-
* normalizedActivity parse cache.
|
|
649
|
-
*
|
|
650
|
-
* `undefined` preserves backward compatibility with older queued messages
|
|
651
|
-
* that predate this marker.
|
|
652
|
-
*
|
|
653
|
-
* @internal
|
|
654
|
-
*/
|
|
655
|
-
readonly ldSignatureVerified?: boolean;
|
|
656
|
-
readonly started: string;
|
|
657
|
-
readonly attempt: number;
|
|
658
|
-
readonly identifier: string | null;
|
|
659
|
-
readonly traceContext: Readonly<Record<string, string>>;
|
|
660
|
-
}
|
|
661
|
-
//#endregion
|
|
662
|
-
//#region src/federation/federation.d.ts
|
|
663
|
-
/**
|
|
664
|
-
* Options for {@link Federation.startQueue} method.
|
|
665
|
-
* @since 1.0.0
|
|
666
|
-
*/
|
|
667
|
-
interface FederationStartQueueOptions {
|
|
668
|
-
/**
|
|
669
|
-
* The signal to abort the task queue.
|
|
670
|
-
*/
|
|
671
|
-
signal?: AbortSignal;
|
|
672
|
-
/**
|
|
673
|
-
* Starts the task worker only for the specified queue. If unspecified,
|
|
674
|
-
* which is the default, the task worker starts for all three queues:
|
|
675
|
-
* inbox, outbox, and fanout.
|
|
676
|
-
* @since 1.3.0
|
|
677
|
-
*/
|
|
678
|
-
queue?: "inbox" | "outbox" | "fanout";
|
|
679
|
-
}
|
|
680
|
-
/**
|
|
681
|
-
* A common interface between {@link Federation} and {@link FederationBuilder}.
|
|
682
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
683
|
-
* @since 1.6.0
|
|
684
|
-
*/
|
|
685
|
-
interface Federatable<TContextData> {
|
|
686
|
-
/**
|
|
687
|
-
* Registers a NodeInfo dispatcher.
|
|
688
|
-
* @param path The URI path pattern for the NodeInfo dispatcher. The syntax
|
|
689
|
-
* is based on URI Template
|
|
690
|
-
* ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
|
|
691
|
-
* must have no variables.
|
|
692
|
-
* @param dispatcher A NodeInfo dispatcher callback to register.
|
|
693
|
-
* @throws {RouterError} Thrown if the path pattern is invalid.
|
|
694
|
-
*/
|
|
695
|
-
setNodeInfoDispatcher(path: string, dispatcher: NodeInfoDispatcher<TContextData>): void;
|
|
696
|
-
/**
|
|
697
|
-
* Registers a links dispatcher to WebFinger
|
|
698
|
-
* @param dispatcher A links dispatcher callback to register.
|
|
699
|
-
*/
|
|
700
|
-
setWebFingerLinksDispatcher(dispatcher: WebFingerLinksDispatcher<TContextData>): void;
|
|
701
|
-
/**
|
|
702
|
-
* Registers an actor dispatcher.
|
|
703
|
-
*
|
|
704
|
-
* @example
|
|
705
|
-
* ``` typescript
|
|
706
|
-
* federation.setActorDispatcher(
|
|
707
|
-
* "/users/{identifier}",
|
|
708
|
-
* async (ctx, identifier) => {
|
|
709
|
-
* return new Person({
|
|
710
|
-
* id: ctx.getActorUri(identifier),
|
|
711
|
-
* // ...
|
|
712
|
-
* });
|
|
713
|
-
* }
|
|
714
|
-
* );
|
|
715
|
-
* ```
|
|
716
|
-
*
|
|
717
|
-
* @param path The URI path pattern for the actor dispatcher. The syntax is
|
|
718
|
-
* based on URI Template
|
|
719
|
-
* ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
|
|
720
|
-
* must have one variable: `{identifier}`.
|
|
721
|
-
* @param dispatcher An actor dispatcher callback to register. It may return
|
|
722
|
-
* an actor, a `Tombstone`, or `null` if the actor is not
|
|
723
|
-
* found.
|
|
724
|
-
* @returns An object with methods to set other actor dispatcher callbacks.
|
|
725
|
-
* @throws {RouterError} Thrown if the path pattern is invalid.
|
|
726
|
-
*/
|
|
727
|
-
setActorDispatcher(path: `${string}${Rfc6570Expression<"identifier">}${string}`, dispatcher: ActorDispatcher<TContextData>): ActorCallbackSetters<TContextData>;
|
|
728
|
-
/**
|
|
729
|
-
* Registers an object dispatcher.
|
|
730
|
-
*
|
|
731
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
732
|
-
* @template TObject The type of object to dispatch.
|
|
733
|
-
* @template TParam The parameter names of the requested URL.
|
|
734
|
-
* @param cls The Activity Vocabulary class of the object to dispatch.
|
|
735
|
-
* @param path The URI path pattern for the object dispatcher. The syntax is
|
|
736
|
-
* based on URI Template
|
|
737
|
-
* ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
|
|
738
|
-
* must have one or more variables.
|
|
739
|
-
* @param dispatcher An object dispatcher callback to register.
|
|
740
|
-
*/
|
|
741
|
-
setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: ConstructorWithTypeId<TObject>, path: `${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
|
|
742
|
-
/**
|
|
743
|
-
* Registers an object dispatcher.
|
|
744
|
-
*
|
|
745
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
746
|
-
* @template TObject The type of object to dispatch.
|
|
747
|
-
* @template TParam The parameter names of the requested URL.
|
|
748
|
-
* @param cls The Activity Vocabulary class of the object to dispatch.
|
|
749
|
-
* @param path The URI path pattern for the object dispatcher. The syntax is
|
|
750
|
-
* based on URI Template
|
|
751
|
-
* ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
|
|
752
|
-
* must have one or more variables.
|
|
753
|
-
* @param dispatcher An object dispatcher callback to register.
|
|
754
|
-
*/
|
|
755
|
-
setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: ConstructorWithTypeId<TObject>, path: `${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
|
|
756
|
-
/**
|
|
757
|
-
* Registers an object dispatcher.
|
|
758
|
-
*
|
|
759
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
760
|
-
* @template TObject The type of object to dispatch.
|
|
761
|
-
* @template TParam The parameter names of the requested URL.
|
|
762
|
-
* @param cls The Activity Vocabulary class of the object to dispatch.
|
|
763
|
-
* @param path The URI path pattern for the object dispatcher. The syntax is
|
|
764
|
-
* based on URI Template
|
|
765
|
-
* ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
|
|
766
|
-
* must have one or more variables.
|
|
767
|
-
* @param dispatcher An object dispatcher callback to register.
|
|
768
|
-
*/
|
|
769
|
-
setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: ConstructorWithTypeId<TObject>, path: `${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}{${TParam}}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
|
|
770
|
-
/**
|
|
771
|
-
* Registers an object dispatcher.
|
|
772
|
-
*
|
|
773
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
774
|
-
* @template TObject The type of object to dispatch.
|
|
775
|
-
* @template TParam The parameter names of the requested URL.
|
|
776
|
-
* @param cls The Activity Vocabulary class of the object to dispatch.
|
|
777
|
-
* @param path The URI path pattern for the object dispatcher. The syntax is
|
|
778
|
-
* based on URI Template
|
|
779
|
-
* ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
|
|
780
|
-
* must have one or more variables.
|
|
781
|
-
* @param dispatcher An object dispatcher callback to register.
|
|
782
|
-
*/
|
|
783
|
-
setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
|
|
784
|
-
/**
|
|
785
|
-
* Registers an object dispatcher.
|
|
786
|
-
*
|
|
787
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
788
|
-
* @template TObject The type of object to dispatch.
|
|
789
|
-
* @template TParam The parameter names of the requested URL.
|
|
790
|
-
* @param cls The Activity Vocabulary class of the object to dispatch.
|
|
791
|
-
* @param path The URI path pattern for the object dispatcher. The syntax is
|
|
792
|
-
* based on URI Template
|
|
793
|
-
* ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
|
|
794
|
-
* must have one or more variables.
|
|
795
|
-
* @param dispatcher An object dispatcher callback to register.
|
|
796
|
-
*/
|
|
797
|
-
setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
|
|
798
|
-
/**
|
|
799
|
-
* Registers an object dispatcher.
|
|
800
|
-
*
|
|
801
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
802
|
-
* @template TObject The type of object to dispatch.
|
|
803
|
-
* @template TParam The parameter names of the requested URL.
|
|
804
|
-
* @param cls The Activity Vocabulary class of the object to dispatch.
|
|
805
|
-
* @param path The URI path pattern for the object dispatcher. The syntax is
|
|
806
|
-
* based on URI Template
|
|
807
|
-
* ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
|
|
808
|
-
* must have one or more variables.
|
|
809
|
-
* @param dispatcher An object dispatcher callback to register.
|
|
810
|
-
*/
|
|
811
|
-
setObjectDispatcher<TObject extends Object$1, TParam extends string>(cls: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: ObjectDispatcher<TContextData, TObject, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
|
|
812
|
-
/**
|
|
813
|
-
* Registers an inbox dispatcher.
|
|
814
|
-
*
|
|
815
|
-
* @param path The URI path pattern for the inbox dispatcher. The syntax is
|
|
816
|
-
* based on URI Template
|
|
817
|
-
* ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
|
|
818
|
-
* must have one variable: `{identifier}`, and must match
|
|
819
|
-
* the inbox listener path.
|
|
820
|
-
* @param dispatcher An inbox dispatcher callback to register.
|
|
821
|
-
* @throws {@link RouterError} Thrown if the path pattern is invalid.
|
|
822
|
-
*/
|
|
823
|
-
setInboxDispatcher(path: `${string}${Rfc6570Expression<"identifier">}${string}`, dispatcher: CollectionDispatcher<Activity, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
|
|
824
|
-
/**
|
|
825
|
-
* Registers an outbox dispatcher.
|
|
826
|
-
*
|
|
827
|
-
* @example
|
|
828
|
-
* ``` typescript
|
|
829
|
-
* federation.setOutboxDispatcher(
|
|
830
|
-
* "/users/{identifier}/outbox",
|
|
831
|
-
* async (ctx, identifier, options) => {
|
|
832
|
-
* let items: Activity[];
|
|
833
|
-
* let nextCursor: string;
|
|
834
|
-
* // ...
|
|
835
|
-
* return { items, nextCursor };
|
|
836
|
-
* }
|
|
837
|
-
* );
|
|
838
|
-
* ```
|
|
839
|
-
*
|
|
840
|
-
* @param path The URI path pattern for the outbox dispatcher. The syntax is
|
|
841
|
-
* based on URI Template
|
|
842
|
-
* ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
|
|
843
|
-
* must have one variable: `{identifier}`.
|
|
844
|
-
* @param dispatcher An outbox dispatcher callback to register.
|
|
845
|
-
* @throws {@link RouterError} Thrown if the path pattern is invalid.
|
|
846
|
-
*/
|
|
847
|
-
setOutboxDispatcher(path: `${string}${Rfc6570Expression<"identifier">}${string}`, dispatcher: CollectionDispatcher<Activity, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
|
|
848
|
-
/**
|
|
849
|
-
* Assigns the URL path for the outbox and starts setting outbox listeners.
|
|
850
|
-
*
|
|
851
|
-
* @example
|
|
852
|
-
* ``` typescript
|
|
853
|
-
* federation
|
|
854
|
-
* .setOutboxListeners("/users/{identifier}/outbox")
|
|
855
|
-
* .on(Activity, async (ctx, activity) => {
|
|
856
|
-
* await ctx.sendActivity({ identifier: ctx.identifier }, "followers", activity);
|
|
857
|
-
* })
|
|
858
|
-
* .authorize(async (ctx, identifier) => {
|
|
859
|
-
* return ctx.request.headers.get("authorization") === `Bearer ${identifier}`;
|
|
860
|
-
* });
|
|
861
|
-
* ```
|
|
862
|
-
*
|
|
863
|
-
* @param outboxPath The URI path pattern for the outbox. The syntax is based
|
|
864
|
-
* on URI Template
|
|
865
|
-
* ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The
|
|
866
|
-
* path must have one variable: `{identifier}`. If an
|
|
867
|
-
* outbox dispatcher is configured, this path must match
|
|
868
|
-
* the outbox dispatcher path.
|
|
869
|
-
* @returns An object to register outbox listeners.
|
|
870
|
-
* @throws {RouterError} Thrown if the path pattern is invalid.
|
|
871
|
-
* @since 2.2.0
|
|
872
|
-
*/
|
|
873
|
-
setOutboxListeners(outboxPath: `${string}${Rfc6570Expression<"identifier">}${string}`): OutboxListenerSetters<TContextData>;
|
|
874
|
-
/**
|
|
875
|
-
* Registers a following collection dispatcher.
|
|
876
|
-
* @param path The URI path pattern for the following collection. The syntax
|
|
877
|
-
* is based on URI Template
|
|
878
|
-
* ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
|
|
879
|
-
* must have one variable: `{identifier}`.
|
|
880
|
-
* @param dispatcher A following collection callback to register.
|
|
881
|
-
* @returns An object with methods to set other following collection
|
|
882
|
-
* callbacks.
|
|
883
|
-
* @throws {RouterError} Thrown if the path pattern is invalid.
|
|
884
|
-
*/
|
|
885
|
-
setFollowingDispatcher(path: `${string}${Rfc6570Expression<"identifier">}${string}`, dispatcher: CollectionDispatcher<Actor | URL, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
|
|
886
|
-
/**
|
|
887
|
-
* Registers a followers collection dispatcher.
|
|
888
|
-
* @param path The URI path pattern for the followers collection. The syntax
|
|
889
|
-
* is based on URI Template
|
|
890
|
-
* ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
|
|
891
|
-
* must have one variable: `{identifier}`.
|
|
892
|
-
* @param dispatcher A followers collection callback to register.
|
|
893
|
-
* @returns An object with methods to set other followers collection
|
|
894
|
-
* callbacks.
|
|
895
|
-
* @throws {@link RouterError} Thrown if the path pattern is invalid.
|
|
896
|
-
*/
|
|
897
|
-
setFollowersDispatcher(path: `${string}${Rfc6570Expression<"identifier">}${string}`, dispatcher: CollectionDispatcher<Recipient, Context<TContextData>, TContextData, URL>): CollectionCallbackSetters<Context<TContextData>, TContextData, URL>;
|
|
898
|
-
/**
|
|
899
|
-
* Registers a liked collection dispatcher.
|
|
900
|
-
* @param path The URI path pattern for the liked collection. The syntax
|
|
901
|
-
* is based on URI Template
|
|
902
|
-
* ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
|
|
903
|
-
* must have one variable: `{identifier}`.
|
|
904
|
-
* @param dispatcher A liked collection callback to register.
|
|
905
|
-
* @returns An object with methods to set other liked collection
|
|
906
|
-
* callbacks.
|
|
907
|
-
* @throws {@link RouterError} Thrown if the path pattern is invalid.
|
|
908
|
-
*/
|
|
909
|
-
setLikedDispatcher(path: `${string}${Rfc6570Expression<"identifier">}${string}`, dispatcher: CollectionDispatcher<Object$1 | URL, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
|
|
910
|
-
/**
|
|
911
|
-
* Registers a featured collection dispatcher.
|
|
912
|
-
* @param path The URI path pattern for the featured collection. The syntax
|
|
913
|
-
* is based on URI Template
|
|
914
|
-
* ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
|
|
915
|
-
* must have one variable: `{identifier}`.
|
|
916
|
-
* @param dispatcher A featured collection callback to register.
|
|
917
|
-
* @returns An object with methods to set other featured collection
|
|
918
|
-
* callbacks.
|
|
919
|
-
* @throws {@link RouterError} Thrown if the path pattern is invalid.
|
|
920
|
-
*/
|
|
921
|
-
setFeaturedDispatcher(path: `${string}${Rfc6570Expression<"identifier">}${string}`, dispatcher: CollectionDispatcher<Object$1, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
|
|
922
|
-
/**
|
|
923
|
-
* Registers a featured tags collection dispatcher.
|
|
924
|
-
* @param path The URI path pattern for the featured tags collection.
|
|
925
|
-
* The syntax is based on URI Template
|
|
926
|
-
* ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
|
|
927
|
-
* must have one variable: `{identifier}`.
|
|
928
|
-
* @param dispatcher A featured tags collection callback to register.
|
|
929
|
-
* @returns An object with methods to set other featured tags collection
|
|
930
|
-
* callbacks.
|
|
931
|
-
* @throws {@link RouterError} Thrown if the path pattern is invalid.
|
|
932
|
-
*/
|
|
933
|
-
setFeaturedTagsDispatcher(path: `${string}${Rfc6570Expression<"identifier">}${string}`, dispatcher: CollectionDispatcher<Hashtag, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
|
|
934
|
-
/**
|
|
935
|
-
* Assigns the URL path for the inbox and starts setting inbox listeners.
|
|
936
|
-
*
|
|
937
|
-
* @example
|
|
938
|
-
* ``` typescript
|
|
939
|
-
* federation
|
|
940
|
-
* .setInboxListeners("/users/{identifier}/inbox", "/inbox")
|
|
941
|
-
* .on(Follow, async (ctx, follow) => {
|
|
942
|
-
* const from = await follow.getActor(ctx);
|
|
943
|
-
* if (!isActor(from)) return;
|
|
944
|
-
* // ...
|
|
945
|
-
* })
|
|
946
|
-
* .on(Undo, async (ctx, undo) => {
|
|
947
|
-
* // ...
|
|
948
|
-
* });
|
|
949
|
-
* ```
|
|
950
|
-
*
|
|
951
|
-
* @param inboxPath The URI path pattern for the inbox. The syntax is based
|
|
952
|
-
* on URI Template
|
|
953
|
-
* ([RFC 6570](https://tools.ietf.org/html/rfc6570)).
|
|
954
|
-
* The path must have one variable: `{identifier}`, and must
|
|
955
|
-
* match the inbox dispatcher path.
|
|
956
|
-
* @param sharedInboxPath An optional URI path pattern for the shared inbox.
|
|
957
|
-
* The syntax is based on URI Template
|
|
958
|
-
* ([RFC 6570](https://tools.ietf.org/html/rfc6570)).
|
|
959
|
-
* The path must have no variables.
|
|
960
|
-
* @returns An object to register inbox listeners.
|
|
961
|
-
* @throws {RouterError} Thrown if the path pattern is invalid.
|
|
962
|
-
*/
|
|
963
|
-
setInboxListeners(inboxPath: `${string}${Rfc6570Expression<"identifier">}${string}`, sharedInboxPath?: string): InboxListenerSetters<TContextData>;
|
|
964
|
-
/**
|
|
965
|
-
* Registers a collection of objects dispatcher.
|
|
966
|
-
*
|
|
967
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
968
|
-
* @template TObject The type of objects to dispatch.
|
|
969
|
-
* @template TParam The parameter names of the requested URL.
|
|
970
|
-
* @param name A unique name for the collection dispatcher.
|
|
971
|
-
* @param itemType The Activity Vocabulary class of the object to dispatch.
|
|
972
|
-
* @param path The URI path pattern for the collection dispatcher.
|
|
973
|
-
* The syntax is based on URI Template
|
|
974
|
-
* ([RFC 6570](https://tools.ietf.org/html/rfc6570)).
|
|
975
|
-
* The path must have one or more variables.
|
|
976
|
-
* @param dispatcher A collection dispatcher callback to register.
|
|
977
|
-
*/
|
|
978
|
-
setCollectionDispatcher<TObject extends Object$1, TParam extends string>(name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: CustomCollectionDispatcher<TObject, TParam, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParam, RequestContext<TContextData>, TContextData>;
|
|
979
|
-
/**
|
|
980
|
-
* Registers a collection of objects dispatcher.
|
|
981
|
-
*
|
|
982
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
983
|
-
* @template TObject The type of objects to dispatch.
|
|
984
|
-
* @template TParam The parameter names of the requested URL.
|
|
985
|
-
* @param name A unique name for the collection dispatcher.
|
|
986
|
-
* @param itemType The Activity Vocabulary class of the object to dispatch.
|
|
987
|
-
* @param path The URI path pattern for the collection dispatcher.
|
|
988
|
-
* The syntax is based on URI Template
|
|
989
|
-
* ([RFC 6570](https://tools.ietf.org/html/rfc6570)).
|
|
990
|
-
* The path must have one or more variables.
|
|
991
|
-
* @param dispatcher A collection dispatcher callback to register.
|
|
992
|
-
*/
|
|
993
|
-
setCollectionDispatcher<TObject extends Object$1, TParam extends string>(name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: CustomCollectionDispatcher<TObject, TParam, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParam, RequestContext<TContextData>, TContextData>;
|
|
994
|
-
/**
|
|
995
|
-
* Registers a collection of objects dispatcher.
|
|
996
|
-
*
|
|
997
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
998
|
-
* @template TObject The type of objects to dispatch.
|
|
999
|
-
* @template TParam The parameter names of the requested URL.
|
|
1000
|
-
* @param name A unique name for the collection dispatcher.
|
|
1001
|
-
* @param itemType The Activity Vocabulary class of the object to dispatch.
|
|
1002
|
-
* @param path The URI path pattern for the collection dispatcher.
|
|
1003
|
-
* The syntax is based on URI Template
|
|
1004
|
-
* ([RFC 6570](https://tools.ietf.org/html/rfc6570)).
|
|
1005
|
-
* The path must have one or more variables.
|
|
1006
|
-
* @param dispatcher A collection dispatcher callback to register.
|
|
1007
|
-
*/
|
|
1008
|
-
setCollectionDispatcher<TObject extends Object$1, TParam extends string>(name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: CustomCollectionDispatcher<TObject, TParam, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParam, RequestContext<TContextData>, TContextData>;
|
|
1009
|
-
/**
|
|
1010
|
-
* Registers an ordered collection of objects dispatcher.
|
|
1011
|
-
*
|
|
1012
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
1013
|
-
* @template TObject The type of objects to dispatch.
|
|
1014
|
-
* @template TParam The parameter names of the requested URL.
|
|
1015
|
-
* @param name A unique name for the collection dispatcher.
|
|
1016
|
-
* @param itemType The Activity Vocabulary class of the object to dispatch.
|
|
1017
|
-
* @param path The URI path pattern for the collection dispatcher.
|
|
1018
|
-
* The syntax is based on URI Template
|
|
1019
|
-
* ([RFC 6570](https://tools.ietf.org/html/rfc6570)).
|
|
1020
|
-
* The path must have one or more variables.
|
|
1021
|
-
* @param dispatcher A collection dispatcher callback to register.
|
|
1022
|
-
*/
|
|
1023
|
-
setOrderedCollectionDispatcher<TObject extends Object$1, TParam extends string>(name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: CustomCollectionDispatcher<TObject, TParam, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParam, RequestContext<TContextData>, TContextData>;
|
|
1024
|
-
/**
|
|
1025
|
-
* Registers an ordered collection of objects dispatcher.
|
|
1026
|
-
*
|
|
1027
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
1028
|
-
* @template TObject The type of objects to dispatch.
|
|
1029
|
-
* @template TParam The parameter names of the requested URL.
|
|
1030
|
-
* @param name A unique name for the collection dispatcher.
|
|
1031
|
-
* @param itemType The Activity Vocabulary class of the object to dispatch.
|
|
1032
|
-
* @param path The URI path pattern for the collection dispatcher.
|
|
1033
|
-
* The syntax is based on URI Template
|
|
1034
|
-
* ([RFC 6570](https://tools.ietf.org/html/rfc6570)).
|
|
1035
|
-
* The path must have one or more variables.
|
|
1036
|
-
* @param dispatcher A collection dispatcher callback to register.
|
|
1037
|
-
*/
|
|
1038
|
-
setOrderedCollectionDispatcher<TObject extends Object$1, TParam extends string>(name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: CustomCollectionDispatcher<TObject, TParam, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParam, RequestContext<TContextData>, TContextData>;
|
|
1039
|
-
/**
|
|
1040
|
-
* Registers an ordered collection of objects dispatcher.
|
|
1041
|
-
*
|
|
1042
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
1043
|
-
* @template TObject The type of objects to dispatch.
|
|
1044
|
-
* @template TParam The parameter names of the requested URL.
|
|
1045
|
-
* @param name A unique name for the collection dispatcher.
|
|
1046
|
-
* @param itemType The Activity Vocabulary class of the object to dispatch.
|
|
1047
|
-
* @param path The URI path pattern for the collection dispatcher.
|
|
1048
|
-
* The syntax is based on URI Template
|
|
1049
|
-
* ([RFC 6570](https://tools.ietf.org/html/rfc6570)).
|
|
1050
|
-
* The path must have one or more variables.
|
|
1051
|
-
* @param dispatcher A collection dispatcher callback to register.
|
|
1052
|
-
*/
|
|
1053
|
-
setOrderedCollectionDispatcher<TObject extends Object$1, TParam extends string>(name: string | symbol, itemType: ConstructorWithTypeId<TObject>, path: `${string}${Rfc6570Expression<TParam>}${string}`, dispatcher: CustomCollectionDispatcher<TObject, TParam, RequestContext<TContextData>, TContextData>): CustomCollectionCallbackSetters<TParam, RequestContext<TContextData>, TContextData>;
|
|
1054
|
-
/**
|
|
1055
|
-
* Registers a handler for permanent delivery failures.
|
|
1056
|
-
*
|
|
1057
|
-
* This handler is called when an inbox returns an HTTP status code
|
|
1058
|
-
* that indicates permanent failure (`410 Gone`, `404 Not Found`, etc.),
|
|
1059
|
-
* allowing the application to clean up followers that are no longer
|
|
1060
|
-
* reachable.
|
|
1061
|
-
*
|
|
1062
|
-
* Unlike `onOutboxError`, which is called for every delivery failure
|
|
1063
|
-
* (including retries), this handler is called only once for permanent
|
|
1064
|
-
* failures, after which delivery is not retried.
|
|
1065
|
-
*
|
|
1066
|
-
* @param handler A callback to handle permanent failures.
|
|
1067
|
-
* @since 2.0.0
|
|
1068
|
-
*/
|
|
1069
|
-
setOutboxPermanentFailureHandler(handler: OutboxPermanentFailureHandler<TContextData>): void;
|
|
1070
|
-
}
|
|
1071
|
-
/**
|
|
1072
|
-
* An object that registers federation-related business logic and dispatches
|
|
1073
|
-
* requests to the appropriate handlers.
|
|
1074
|
-
*
|
|
1075
|
-
* It also provides a middleware interface for handling requests before your
|
|
1076
|
-
* web framework's router; see {@link Federation.fetch}.
|
|
1077
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
1078
|
-
* @since 0.13.0
|
|
1079
|
-
*/
|
|
1080
|
-
interface Federation<TContextData> extends Federatable<TContextData> {
|
|
1081
|
-
/**
|
|
1082
|
-
* Manually start the task queue.
|
|
1083
|
-
*
|
|
1084
|
-
* This method is useful when you set the `manuallyStartQueue` option to
|
|
1085
|
-
* `true` in the {@link createFederation} function.
|
|
1086
|
-
* @param contextData The context data to pass to the context.
|
|
1087
|
-
* @param options Additional options for starting the queue.
|
|
1088
|
-
*/
|
|
1089
|
-
startQueue(contextData: TContextData, options?: FederationStartQueueOptions): Promise<void>;
|
|
1090
|
-
/**
|
|
1091
|
-
* Processes a queued message task. This method handles different types of
|
|
1092
|
-
* tasks such as fanout, outbox, and inbox messages.
|
|
1093
|
-
*
|
|
1094
|
-
* Note that you usually do not need to call this method directly unless you
|
|
1095
|
-
* are deploying your federated application on a platform that does not
|
|
1096
|
-
* support long-running processing, such as Cloudflare Workers.
|
|
1097
|
-
* @param contextData The context data to pass to the context.
|
|
1098
|
-
* @param message The message that represents the task to be processed.
|
|
1099
|
-
* @returns A promise that resolves when the message has been processed.
|
|
1100
|
-
* @since 1.6.0
|
|
1101
|
-
*/
|
|
1102
|
-
processQueuedTask(contextData: TContextData, message: Message): Promise<void>;
|
|
1103
|
-
/**
|
|
1104
|
-
* Create a new context.
|
|
1105
|
-
* @param baseUrl The base URL of the server. The `pathname` remains root,
|
|
1106
|
-
* and the `search` and `hash` are stripped.
|
|
1107
|
-
* @param contextData The context data to pass to the context.
|
|
1108
|
-
* @returns The new context.
|
|
1109
|
-
*/
|
|
1110
|
-
createContext(baseUrl: URL, contextData: TContextData): Context<TContextData>;
|
|
1111
|
-
/**
|
|
1112
|
-
* Create a new context for a request.
|
|
1113
|
-
* @param request The request object.
|
|
1114
|
-
* @param contextData The context data to pass to the context.
|
|
1115
|
-
* @returns The new request context.
|
|
1116
|
-
*/
|
|
1117
|
-
createContext(request: Request, contextData: TContextData): RequestContext<TContextData>;
|
|
1118
|
-
/**
|
|
1119
|
-
* Handles a request related to federation. If a request is not related to
|
|
1120
|
-
* federation, the `onNotFound` or `onNotAcceptable` callback is called.
|
|
1121
|
-
*
|
|
1122
|
-
* Usually, this method is called from a server's request handler or
|
|
1123
|
-
* a web framework's middleware.
|
|
1124
|
-
*
|
|
1125
|
-
* @param request The request object.
|
|
1126
|
-
* @param parameters The parameters for handling the request.
|
|
1127
|
-
* @returns The response to the request.
|
|
1128
|
-
*/
|
|
1129
|
-
fetch(request: Request, options: FederationFetchOptions<TContextData>): Promise<Response>;
|
|
1130
|
-
}
|
|
1131
|
-
/**
|
|
1132
|
-
* Additional settings for the actor dispatcher.
|
|
1133
|
-
*
|
|
1134
|
-
* ``` typescript
|
|
1135
|
-
* const federation = createFederation<void>({ ... });
|
|
1136
|
-
* federation
|
|
1137
|
-
* .setActorDispatcher("/users/{identifier}", async (ctx, identifier) => {
|
|
1138
|
-
* // ...
|
|
1139
|
-
* })
|
|
1140
|
-
* .setKeyPairsDispatcher(async (ctxData, identifier) => {
|
|
1141
|
-
* // ...
|
|
1142
|
-
* });
|
|
1143
|
-
* ```
|
|
1144
|
-
*/
|
|
1145
|
-
interface ActorCallbackSetters<TContextData> {
|
|
1146
|
-
/**
|
|
1147
|
-
* Sets the key pairs dispatcher for actors.
|
|
1148
|
-
* @param dispatcher A callback that returns the key pairs for an actor.
|
|
1149
|
-
* @returns The setters object so that settings can be chained.
|
|
1150
|
-
* @since 0.10.0
|
|
1151
|
-
*/
|
|
1152
|
-
setKeyPairsDispatcher(dispatcher: ActorKeyPairsDispatcher<TContextData>): ActorCallbackSetters<TContextData>;
|
|
1153
|
-
/**
|
|
1154
|
-
* Sets the callback function that maps a WebFinger username to
|
|
1155
|
-
* the corresponding actor's identifier. If it's omitted, the identifier
|
|
1156
|
-
* is assumed to be the same as the WebFinger username, which makes your
|
|
1157
|
-
* actors have the immutable handles. If you want to let your actors change
|
|
1158
|
-
* their fediverse handles, you should set this dispatcher.
|
|
1159
|
-
* @param mapper A callback that maps a WebFinger username to
|
|
1160
|
-
* the corresponding actor's identifier.
|
|
1161
|
-
* @returns The setters object so that settings can be chained.
|
|
1162
|
-
* @since 0.15.0
|
|
1163
|
-
*/
|
|
1164
|
-
mapHandle(mapper: ActorHandleMapper<TContextData>): ActorCallbackSetters<TContextData>;
|
|
1165
|
-
/**
|
|
1166
|
-
* Sets the callback function that maps a WebFinger query to the corresponding
|
|
1167
|
-
* actor's identifier or username. If it's omitted, the WebFinger handler
|
|
1168
|
-
* only supports the actor URIs and `acct:` URIs. If you want to support
|
|
1169
|
-
* other queries, you should set this dispatcher.
|
|
1170
|
-
* @param mapper A callback that maps a WebFinger query to the corresponding
|
|
1171
|
-
* actor's identifier or username.
|
|
1172
|
-
* @returns The setters object so that settings can be chained.
|
|
1173
|
-
* @since 1.4.0
|
|
1174
|
-
*/
|
|
1175
|
-
mapAlias(mapper: ActorAliasMapper<TContextData>): ActorCallbackSetters<TContextData>;
|
|
1176
|
-
/**
|
|
1177
|
-
* Specifies the conditions under which requests are authorized.
|
|
1178
|
-
* @param predicate A callback that returns whether a request is authorized.
|
|
1179
|
-
* @returns The setters object so that settings can be chained.
|
|
1180
|
-
* @since 0.7.0
|
|
1181
|
-
*/
|
|
1182
|
-
authorize(predicate: AuthorizePredicate<TContextData>): ActorCallbackSetters<TContextData>;
|
|
1183
|
-
}
|
|
1184
|
-
/**
|
|
1185
|
-
* Additional settings for an object dispatcher.
|
|
1186
|
-
*/
|
|
1187
|
-
interface ObjectCallbackSetters<TContextData, TObject extends Object$1, TParam extends string> {
|
|
1188
|
-
/**
|
|
1189
|
-
* Specifies the conditions under which requests are authorized.
|
|
1190
|
-
* @param predicate A callback that returns whether a request is authorized.
|
|
1191
|
-
* @returns The setters object so that settings can be chained.
|
|
1192
|
-
* @since 0.7.0
|
|
1193
|
-
*/
|
|
1194
|
-
authorize(predicate: ObjectAuthorizePredicate<TContextData, TParam>): ObjectCallbackSetters<TContextData, TObject, TParam>;
|
|
1195
|
-
}
|
|
1196
|
-
/**
|
|
1197
|
-
* Additional settings for a collection dispatcher.
|
|
1198
|
-
*
|
|
1199
|
-
* @template TContext The type of the context. {@link Context} or
|
|
1200
|
-
* {@link RequestContext}.
|
|
1201
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
1202
|
-
* @template TFilter The type of filter for the collection.
|
|
1203
|
-
*/
|
|
1204
|
-
interface CollectionCallbackSetters<TContext extends Context<TContextData>, TContextData, TFilter> {
|
|
1205
|
-
/**
|
|
1206
|
-
* Sets the counter for the collection.
|
|
1207
|
-
* @param counter A callback that returns the number of items in the collection.
|
|
1208
|
-
* @returns The setters object so that settings can be chained.
|
|
1209
|
-
*/
|
|
1210
|
-
setCounter(counter: CollectionCounter<TContextData, TFilter>): CollectionCallbackSetters<TContext, TContextData, TFilter>;
|
|
1211
|
-
/**
|
|
1212
|
-
* Sets the first cursor for the collection.
|
|
1213
|
-
* @param cursor The cursor for the first item in the collection.
|
|
1214
|
-
* @returns The setters object so that settings can be chained.
|
|
1215
|
-
*/
|
|
1216
|
-
setFirstCursor(cursor: CollectionCursor<TContext, TContextData, TFilter>): CollectionCallbackSetters<TContext, TContextData, TFilter>;
|
|
1217
|
-
/**
|
|
1218
|
-
* Sets the last cursor for the collection.
|
|
1219
|
-
* @param cursor The cursor for the last item in the collection.
|
|
1220
|
-
* @returns The setters object so that settings can be chained.
|
|
1221
|
-
*/
|
|
1222
|
-
setLastCursor(cursor: CollectionCursor<TContext, TContextData, TFilter>): CollectionCallbackSetters<TContext, TContextData, TFilter>;
|
|
1223
|
-
/**
|
|
1224
|
-
* Specifies the conditions under which requests are authorized.
|
|
1225
|
-
* @param predicate A callback that returns whether a request is authorized.
|
|
1226
|
-
* @returns The setters object so that settings can be chained.
|
|
1227
|
-
* @since 0.7.0
|
|
1228
|
-
*/
|
|
1229
|
-
authorize(predicate: AuthorizePredicate<TContextData>): CollectionCallbackSetters<TContext, TContextData, TFilter>;
|
|
1230
|
-
}
|
|
1231
|
-
/**
|
|
1232
|
-
* The strategy for handling activity idempotency in inbox processing.
|
|
1233
|
-
*
|
|
1234
|
-
* - `"global"`: Activities are deduplicated globally across all inboxes and
|
|
1235
|
-
* origins. The same activity ID will be processed only once, regardless
|
|
1236
|
-
* of which inbox receives it or which server sent it.
|
|
1237
|
-
*
|
|
1238
|
-
* - `"per-origin"`: Activities are deduplicated per receiving server's origin.
|
|
1239
|
-
* The same activity ID will be processed only once on each receiving server,
|
|
1240
|
-
* but can be processed separately on different receiving servers. This had
|
|
1241
|
-
* been the default behavior in Fedify 1.x versions.
|
|
1242
|
-
*
|
|
1243
|
-
* - `"per-inbox"`: Activities are deduplicated per inbox. The same activity
|
|
1244
|
-
* ID can be processed once per inbox, allowing the same activity to be
|
|
1245
|
-
* delivered to multiple inboxes independently. This follows standard
|
|
1246
|
-
* ActivityPub behavior and is the default strategy since Fedify 2.0.0.
|
|
1247
|
-
*
|
|
1248
|
-
* @since 1.9.0
|
|
1249
|
-
*/
|
|
1250
|
-
type IdempotencyStrategy = "global" | "per-origin" | "per-inbox";
|
|
1251
|
-
/**
|
|
1252
|
-
* A callback to generate a custom idempotency key for an activity.
|
|
1253
|
-
* Returns the cache key to use, or null to skip idempotency checking.
|
|
1254
|
-
* @template TContextData The context data to pass to the {@link InboxContext}.
|
|
1255
|
-
* @param ctx The inbox context.
|
|
1256
|
-
* @param activity The activity being processed.
|
|
1257
|
-
* @returns The idempotency key to use for caching, or null to skip caching.
|
|
1258
|
-
* @since 1.9.0
|
|
1259
|
-
*/
|
|
1260
|
-
type IdempotencyKeyCallback<TContextData> = (ctx: InboxContext<TContextData>, activity: Activity) => string | null | Promise<string | null>;
|
|
1261
|
-
/**
|
|
1262
|
-
* Registry for outbox listeners for different activity types.
|
|
1263
|
-
* @since 2.2.0
|
|
1264
|
-
*/
|
|
1265
|
-
interface OutboxListenerSetters<TContextData> {
|
|
1266
|
-
/**
|
|
1267
|
-
* Registers a listener for a specific incoming activity type.
|
|
1268
|
-
*
|
|
1269
|
-
* @param type A subclass of {@link Activity} to listen to.
|
|
1270
|
-
* @param listener A callback to handle an incoming activity.
|
|
1271
|
-
* @returns The setters object so that settings can be chained.
|
|
1272
|
-
* @since 2.2.0
|
|
1273
|
-
*/
|
|
1274
|
-
on<TActivity extends Activity>(type: new (...args: any[]) => TActivity, listener: OutboxListener<TContextData, TActivity>): OutboxListenerSetters<TContextData>;
|
|
1275
|
-
/**
|
|
1276
|
-
* Registers an error handler for outbox listeners. Any exceptions thrown
|
|
1277
|
-
* from the listeners are caught and passed to this handler.
|
|
1278
|
-
*
|
|
1279
|
-
* @param handler A callback to handle an error.
|
|
1280
|
-
* @returns The setters object so that settings can be chained.
|
|
1281
|
-
* @since 2.2.0
|
|
1282
|
-
*/
|
|
1283
|
-
onError(handler: OutboxListenerErrorHandler<TContextData>): OutboxListenerSetters<TContextData>;
|
|
1284
|
-
/**
|
|
1285
|
-
* Registers a callback to authorize POST requests to the outbox.
|
|
1286
|
-
*
|
|
1287
|
-
* @param predicate A callback to authorize the request.
|
|
1288
|
-
* @returns The setters object so that settings can be chained.
|
|
1289
|
-
* @since 2.2.0
|
|
1290
|
-
*/
|
|
1291
|
-
authorize(predicate: AuthorizePredicate<TContextData>): OutboxListenerSetters<TContextData>;
|
|
1292
|
-
}
|
|
1293
|
-
/**
|
|
1294
|
-
* Registry for inbox listeners for different activity types.
|
|
1295
|
-
*/
|
|
1296
|
-
interface InboxListenerSetters<TContextData> {
|
|
1297
|
-
/**
|
|
1298
|
-
* Registers a listener for a specific incoming activity type.
|
|
1299
|
-
*
|
|
1300
|
-
* @param type A subclass of {@link Activity} to listen to.
|
|
1301
|
-
* @param listener A callback to handle an incoming activity.
|
|
1302
|
-
* @returns The setters object so that settings can be chained.
|
|
1303
|
-
*/
|
|
1304
|
-
on<TActivity extends Activity>(type: new (...args: any[]) => TActivity, listener: InboxListener<TContextData, TActivity>): InboxListenerSetters<TContextData>;
|
|
1305
|
-
/**
|
|
1306
|
-
* Registers an error handler for inbox listeners. Any exceptions thrown
|
|
1307
|
-
* from the listeners are caught and passed to this handler.
|
|
1308
|
-
*
|
|
1309
|
-
* @param handler A callback to handle an error.
|
|
1310
|
-
* @returns The setters object so that settings can be chained.
|
|
1311
|
-
*/
|
|
1312
|
-
onError(handler: InboxErrorHandler<TContextData>): InboxListenerSetters<TContextData>;
|
|
1313
|
-
/**
|
|
1314
|
-
* Registers a callback for incoming activities whose HTTP signatures could
|
|
1315
|
-
* not be verified.
|
|
1316
|
-
*
|
|
1317
|
-
* The regular inbox listeners registered through {@link on} continue to
|
|
1318
|
-
* receive only verified activities. This hook is an opt-in escape hatch for
|
|
1319
|
-
* applications that need to inspect unverified deliveries and optionally
|
|
1320
|
-
* override the default `401 Unauthorized` response.
|
|
1321
|
-
*
|
|
1322
|
-
* @example
|
|
1323
|
-
* ``` typescript
|
|
1324
|
-
* federation
|
|
1325
|
-
* .setInboxListeners("/users/{identifier}/inbox", "/inbox")
|
|
1326
|
-
* .onUnverifiedActivity((ctx, activity, reason) => {
|
|
1327
|
-
* if (
|
|
1328
|
-
* reason.type === "keyFetchError" &&
|
|
1329
|
-
* "status" in reason.result &&
|
|
1330
|
-
* reason.result.status === 410
|
|
1331
|
-
* ) {
|
|
1332
|
-
* return new Response(null, { status: 202 });
|
|
1333
|
-
* }
|
|
1334
|
-
* });
|
|
1335
|
-
* ```
|
|
1336
|
-
*
|
|
1337
|
-
* @param handler A callback to handle an unverified activity.
|
|
1338
|
-
* @returns The setters object so that settings can be chained.
|
|
1339
|
-
* @since 2.1.0
|
|
1340
|
-
*/
|
|
1341
|
-
onUnverifiedActivity(handler: UnverifiedActivityHandler<TContextData>): InboxListenerSetters<TContextData>;
|
|
1342
|
-
/**
|
|
1343
|
-
* Configures a callback to dispatch the key pair for the authenticated
|
|
1344
|
-
* document loader of the {@link Context} passed to the shared inbox listener.
|
|
1345
|
-
*
|
|
1346
|
-
* @param dispatcher A callback to dispatch the key pair for the authenticated
|
|
1347
|
-
* document loader.
|
|
1348
|
-
* @returns The setters object so that settings can be chained.
|
|
1349
|
-
* @since 0.11.0
|
|
1350
|
-
*/
|
|
1351
|
-
setSharedKeyDispatcher(dispatcher: SharedInboxKeyDispatcher<TContextData>): InboxListenerSetters<TContextData>;
|
|
1352
|
-
/**
|
|
1353
|
-
* Configures the strategy for handling activity idempotency in inbox processing.
|
|
1354
|
-
*
|
|
1355
|
-
* @example
|
|
1356
|
-
* Use per-inbox strategy (standard ActivityPub behavior):
|
|
1357
|
-
* ```
|
|
1358
|
-
* federation
|
|
1359
|
-
* .setInboxListeners("/users/{identifier}/inbox", "/inbox")
|
|
1360
|
-
* .withIdempotency("per-inbox");
|
|
1361
|
-
* ```
|
|
1362
|
-
*
|
|
1363
|
-
* Use custom strategy:
|
|
1364
|
-
* ```
|
|
1365
|
-
* federation
|
|
1366
|
-
* .setInboxListeners("/users/{identifier}/inbox", "/inbox")
|
|
1367
|
-
* .withIdempotency((ctx, activity) => {
|
|
1368
|
-
* // Return null to skip idempotency
|
|
1369
|
-
* return `${ctx.origin}:${activity.id?.href}:${ctx.recipient}`;
|
|
1370
|
-
* });
|
|
1371
|
-
* ```
|
|
1372
|
-
*
|
|
1373
|
-
* @param strategy The idempotency strategy to use. Can be:
|
|
1374
|
-
* - `"global"`: Activities are deduplicated across all inboxes and origins
|
|
1375
|
-
* - `"per-origin"`: Activities are deduplicated per inbox origin
|
|
1376
|
-
* - `"per-inbox"`: Activities are deduplicated per inbox
|
|
1377
|
-
* - A custom callback function that returns the cache key to use
|
|
1378
|
-
* @returns The setters object so that settings can be chained.
|
|
1379
|
-
* @since 1.9.0
|
|
1380
|
-
*/
|
|
1381
|
-
withIdempotency(strategy: IdempotencyStrategy | IdempotencyKeyCallback<TContextData>): InboxListenerSetters<TContextData>;
|
|
1382
|
-
}
|
|
1383
|
-
/**
|
|
1384
|
-
* Parameters of {@link Federation.fetch} method.
|
|
1385
|
-
*
|
|
1386
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
1387
|
-
* @since 0.6.0
|
|
1388
|
-
*/
|
|
1389
|
-
interface FederationFetchOptions<TContextData> {
|
|
1390
|
-
/**
|
|
1391
|
-
* The context data to pass to the {@link Context}.
|
|
1392
|
-
*/
|
|
1393
|
-
contextData: TContextData;
|
|
1394
|
-
/**
|
|
1395
|
-
* A callback to handle a request when the route is not found.
|
|
1396
|
-
* If not provided, a 404 response is returned.
|
|
1397
|
-
* @param request The request object.
|
|
1398
|
-
* @returns The response to the request.
|
|
1399
|
-
*/
|
|
1400
|
-
onNotFound?: (request: Request) => Response | Promise<Response>;
|
|
1401
|
-
/**
|
|
1402
|
-
* A callback to handle a request when the request's `Accept` header is not
|
|
1403
|
-
* acceptable. If not provided, a 406 response is returned.
|
|
1404
|
-
* @param request The request object.
|
|
1405
|
-
* @returns The response to the request.
|
|
1406
|
-
*/
|
|
1407
|
-
onNotAcceptable?: (request: Request) => Response | Promise<Response>;
|
|
1408
|
-
/**
|
|
1409
|
-
* A callback to handle a request when the request is unauthorized.
|
|
1410
|
-
* If not provided, a 401 response is returned.
|
|
1411
|
-
* @param request The request object.
|
|
1412
|
-
* @returns The response to the request.
|
|
1413
|
-
* @since 0.7.0
|
|
1414
|
-
*/
|
|
1415
|
-
onUnauthorized?: (request: Request) => Response | Promise<Response>;
|
|
1416
|
-
}
|
|
1417
|
-
/**
|
|
1418
|
-
* Additional settings for a custom collection dispatcher.
|
|
1419
|
-
*
|
|
1420
|
-
* @template TParam The type of the parameters in the URL path.
|
|
1421
|
-
* @template TContext The type of the context. {@link Context} or
|
|
1422
|
-
* {@link RequestContext}.
|
|
1423
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
1424
|
-
* @template TFilter The type of filter for the collection.
|
|
1425
|
-
*/
|
|
1426
|
-
interface CustomCollectionCallbackSetters<TParam extends string, TContext extends Context<TContextData>, TContextData> {
|
|
1427
|
-
/**
|
|
1428
|
-
* Sets the counter for the custom collection.
|
|
1429
|
-
* @param counter A callback that returns the number of items in the custom collection.
|
|
1430
|
-
* @returns The setters object so that settings can be chained.
|
|
1431
|
-
*/
|
|
1432
|
-
setCounter(counter: CustomCollectionCounter<TParam, TContextData>): CustomCollectionCallbackSetters<TParam, TContext, TContextData>;
|
|
1433
|
-
/**
|
|
1434
|
-
* Sets the first cursor for the custom collection.
|
|
1435
|
-
* @param cursor The cursor for the first item in the custom collection.
|
|
1436
|
-
* @returns The setters object so that settings can be chained.
|
|
1437
|
-
*/
|
|
1438
|
-
setFirstCursor(cursor: CustomCollectionCursor<TParam, TContext, TContextData>): CustomCollectionCallbackSetters<TParam, TContext, TContextData>;
|
|
1439
|
-
/**
|
|
1440
|
-
* Sets the last cursor for the custom collection.
|
|
1441
|
-
* @param cursor The cursor for the last item in the custom collection.
|
|
1442
|
-
* @returns The setters object so that settings can be chained.
|
|
1443
|
-
*/
|
|
1444
|
-
setLastCursor(cursor: CustomCollectionCursor<TParam, TContext, TContextData>): CustomCollectionCallbackSetters<TParam, TContext, TContextData>;
|
|
1445
|
-
/**
|
|
1446
|
-
* Specifies the conditions under which requests are authorized.
|
|
1447
|
-
* @param predicate A callback that returns whether a request is authorized.
|
|
1448
|
-
* @returns The setters object so that settings can be chained.
|
|
1449
|
-
* @since 0.7.0
|
|
1450
|
-
*/
|
|
1451
|
-
authorize(predicate: ObjectAuthorizePredicate<TContextData, string>): CustomCollectionCallbackSetters<TParam, TContext, TContextData>;
|
|
1452
|
-
}
|
|
1453
|
-
/**
|
|
1454
|
-
* Represents an object with a type ID, which is either a constructor or an
|
|
1455
|
-
* instance of the object.
|
|
1456
|
-
*
|
|
1457
|
-
* @template TObject The type of the object.
|
|
1458
|
-
*/
|
|
1459
|
-
type ConstructorWithTypeId<TObject extends Object$1> = (new (...args: any[]) => TObject) & {
|
|
1460
|
-
typeId: URL;
|
|
1461
|
-
};
|
|
1462
|
-
/**
|
|
1463
|
-
* Defines a union of all valid RFC 6570 URI Template expressions for a given
|
|
1464
|
-
* parameter name.
|
|
1465
|
-
*
|
|
1466
|
-
* RFC 6570 specifies a syntax for URI templates, allowing for variable
|
|
1467
|
-
* expansion. This type captures all Level 1-4 operator expressions for a
|
|
1468
|
-
* single, named variable.
|
|
1469
|
-
*
|
|
1470
|
-
* The supported expression types are:
|
|
1471
|
-
* - `{Param}`: Simple string expansion
|
|
1472
|
-
* - `+{Param}`: Reserved string expansion
|
|
1473
|
-
* - `#{Param}`: Fragment expansion
|
|
1474
|
-
* - `{.Param}`: Label expansion with a dot-prefix
|
|
1475
|
-
* - `{/Param}`: Path segment expansion
|
|
1476
|
-
* - `{;Param}`: Path-style parameter expansion
|
|
1477
|
-
* - `{?Param}`: Query component expansion
|
|
1478
|
-
* - `{&Param}`: Query continuation expansion
|
|
1479
|
-
*
|
|
1480
|
-
* @template Param The name of the parameter to be used in the expressions.
|
|
1481
|
-
* @example
|
|
1482
|
-
* ```ts
|
|
1483
|
-
* type UserIdExpression = Rfc6570Expression<"userId">;
|
|
1484
|
-
*
|
|
1485
|
-
* // The variable `userPath` can be assigned any of the valid expressions.
|
|
1486
|
-
* const userPath: UserIdExpression = "{/userId}";
|
|
1487
|
-
* ```
|
|
1488
|
-
* @see {@link https://tools.ietf.org/html/rfc6570} for the full specification.
|
|
1489
|
-
*/
|
|
1490
|
-
type Rfc6570Expression<Param extends string> = `{${Param}}` | `{+${Param}}` | `{#${Param}}` | `{.${Param}}` | `{/${Param}}` | `{;${Param}}` | `{?${Param}}` | `{&${Param}}`;
|
|
1491
|
-
//#endregion
|
|
1492
|
-
//#region src/federation/context.d.ts
|
|
1493
|
-
/**
|
|
1494
|
-
* A context.
|
|
1495
|
-
*/
|
|
1496
|
-
interface Context<TContextData> {
|
|
1497
|
-
/**
|
|
1498
|
-
* The origin of the federated server, including the scheme (`http://` or
|
|
1499
|
-
* `https://`) and the host (e.g., `example.com:8080`).
|
|
1500
|
-
* @since 0.12.0
|
|
1501
|
-
*/
|
|
1502
|
-
readonly origin: string;
|
|
1503
|
-
/**
|
|
1504
|
-
* The canonical origin of the federated server, including the scheme
|
|
1505
|
-
* (`http://` or `https://`) and the host (e.g., `example.com:8080`).
|
|
1506
|
-
*
|
|
1507
|
-
* When the associated {@link Federation} object does not have any explicit
|
|
1508
|
-
* canonical origin, it is the same as the {@link Context.origin}.
|
|
1509
|
-
* @since 1.5.0
|
|
1510
|
-
*/
|
|
1511
|
-
readonly canonicalOrigin: string;
|
|
1512
|
-
/**
|
|
1513
|
-
* The host of the federated server, including the hostname
|
|
1514
|
-
* (e.g., `example.com`) and the port following a colon (e.g., `:8080`)
|
|
1515
|
-
* if it is not the default port for the scheme.
|
|
1516
|
-
* @since 0.12.0
|
|
1517
|
-
*/
|
|
1518
|
-
readonly host: string;
|
|
1519
|
-
/**
|
|
1520
|
-
* The hostname of the federated server (e.g., `example.com`). This is
|
|
1521
|
-
* the same as the host without the port.
|
|
1522
|
-
* @since 0.12.0
|
|
1523
|
-
*/
|
|
1524
|
-
readonly hostname: string;
|
|
1525
|
-
/**
|
|
1526
|
-
* The user-defined data associated with the context.
|
|
1527
|
-
*/
|
|
1528
|
-
readonly data: TContextData;
|
|
1529
|
-
/**
|
|
1530
|
-
* The OpenTelemetry tracer provider.
|
|
1531
|
-
* @since 1.3.0
|
|
1532
|
-
*/
|
|
1533
|
-
readonly tracerProvider: TracerProvider;
|
|
1534
|
-
/**
|
|
1535
|
-
* The document loader for loading remote JSON-LD documents.
|
|
1536
|
-
*/
|
|
1537
|
-
readonly documentLoader: DocumentLoader;
|
|
1538
|
-
/**
|
|
1539
|
-
* The context loader for loading remote JSON-LD contexts.
|
|
1540
|
-
*/
|
|
1541
|
-
readonly contextLoader: DocumentLoader;
|
|
1542
|
-
/**
|
|
1543
|
-
* The federation object that this context belongs to.
|
|
1544
|
-
* @since 1.6.0
|
|
1545
|
-
*/
|
|
1546
|
-
readonly federation: Federation<TContextData>;
|
|
1547
|
-
/**
|
|
1548
|
-
* Creates a new context with the same properties as this one,
|
|
1549
|
-
* but with the given data.
|
|
1550
|
-
* @param data The new data to associate with the context.
|
|
1551
|
-
* @returns A new context with the same properties as this one,
|
|
1552
|
-
* but with the given data.
|
|
1553
|
-
* @since 1.6.0
|
|
1554
|
-
*/
|
|
1555
|
-
clone(data: TContextData): Context<TContextData>;
|
|
1556
|
-
/**
|
|
1557
|
-
* Builds the URI of the NodeInfo document.
|
|
1558
|
-
* @returns The NodeInfo URI.
|
|
1559
|
-
* @throws {RouterError} If no NodeInfo dispatcher is available.
|
|
1560
|
-
* @since 0.2.0
|
|
1561
|
-
*/
|
|
1562
|
-
getNodeInfoUri(): URL;
|
|
1563
|
-
/**
|
|
1564
|
-
* Builds the URI of an actor with the given identifier.
|
|
1565
|
-
* @param identifier The actor's identifier.
|
|
1566
|
-
* @returns The actor's URI.
|
|
1567
|
-
* @throws {RouterError} If no actor dispatcher is available.
|
|
1568
|
-
*/
|
|
1569
|
-
getActorUri(identifier: string): URL;
|
|
1570
|
-
/**
|
|
1571
|
-
* Builds the URI of an object with the given class and values.
|
|
1572
|
-
* @param cls The class of the object.
|
|
1573
|
-
* @param values The values to pass to the object dispatcher.
|
|
1574
|
-
* @returns The object's URI.
|
|
1575
|
-
* @throws {RouterError} If no object dispatcher is available for the class.
|
|
1576
|
-
* @throws {TypeError} If values are invalid.
|
|
1577
|
-
* @since 0.7.0
|
|
1578
|
-
*/
|
|
1579
|
-
getObjectUri<TObject extends Object$1>(cls: ConstructorWithTypeId<TObject>, values: Record<string, string>): URL;
|
|
1580
|
-
/**
|
|
1581
|
-
* Builds the URI of an actor's outbox with the given identifier.
|
|
1582
|
-
* @param identifier The actor's identifier.
|
|
1583
|
-
* @returns The actor's outbox URI.
|
|
1584
|
-
* @throws {RouterError} If no outbox dispatcher is available.
|
|
1585
|
-
*/
|
|
1586
|
-
getOutboxUri(identifier: string): URL;
|
|
1587
|
-
/**
|
|
1588
|
-
* Builds the URI of the shared inbox.
|
|
1589
|
-
* @returns The shared inbox URI.
|
|
1590
|
-
* @throws {RouterError} If no inbox listener is available.
|
|
1591
|
-
*/
|
|
1592
|
-
getInboxUri(): URL;
|
|
1593
|
-
/**
|
|
1594
|
-
* Builds the URI of an actor's inbox with the given identifier.
|
|
1595
|
-
* @param identifier The actor's identifier.
|
|
1596
|
-
* @returns The actor's inbox URI.
|
|
1597
|
-
* @throws {RouterError} If no inbox listener is available.
|
|
1598
|
-
*/
|
|
1599
|
-
getInboxUri(identifier: string): URL;
|
|
1600
|
-
/**
|
|
1601
|
-
* Builds the URI of an actor's following collection with the given
|
|
1602
|
-
* identifier.
|
|
1603
|
-
* @param identifier The actor's identifier.
|
|
1604
|
-
* @returns The actor's following collection URI.
|
|
1605
|
-
* @throws {RouterError} If no following collection is available.
|
|
1606
|
-
*/
|
|
1607
|
-
getFollowingUri(identifier: string): URL;
|
|
1608
|
-
/**
|
|
1609
|
-
* Builds the URI of an actor's followers collection with the given
|
|
1610
|
-
* identifier.
|
|
1611
|
-
* @param identifier The actor's identifier.
|
|
1612
|
-
* @returns The actor's followers collection URI.
|
|
1613
|
-
* @throws {RouterError} If no followers collection is available.
|
|
1614
|
-
*/
|
|
1615
|
-
getFollowersUri(identifier: string): URL;
|
|
1616
|
-
/**
|
|
1617
|
-
* Builds the URI of an actor's liked collection with the given identifier.
|
|
1618
|
-
* @param identifier The actor's identifier.
|
|
1619
|
-
* @returns The actor's liked collection URI.
|
|
1620
|
-
* @throws {RouterError} If no liked collection is available.
|
|
1621
|
-
* @since 0.11.0
|
|
1622
|
-
*/
|
|
1623
|
-
getLikedUri(identifier: string): URL;
|
|
1624
|
-
/**
|
|
1625
|
-
* Builds the URI of an actor's featured collection with the given identifier.
|
|
1626
|
-
* @param identifier The actor's identifier.
|
|
1627
|
-
* @returns The actor's featured collection URI.
|
|
1628
|
-
* @throws {RouterError} If no featured collection is available.
|
|
1629
|
-
* @since 0.11.0
|
|
1630
|
-
*/
|
|
1631
|
-
getFeaturedUri(identifier: string): URL;
|
|
1632
|
-
/**
|
|
1633
|
-
* Builds the URI of an actor's featured tags collection with the given
|
|
1634
|
-
* identifier.
|
|
1635
|
-
* @param identifier The actor's identifier.
|
|
1636
|
-
* @returns The actor's featured tags collection URI.
|
|
1637
|
-
* @throws {RouterError} If no featured tags collection is available.
|
|
1638
|
-
* @since 0.11.0
|
|
1639
|
-
*/
|
|
1640
|
-
getFeaturedTagsUri(identifier: string): URL;
|
|
1641
|
-
/**
|
|
1642
|
-
* Determines the type of the URI and extracts the associated data.
|
|
1643
|
-
* @param uri The URI to parse.
|
|
1644
|
-
* @returns The result of parsing the URI. If `null` is given or
|
|
1645
|
-
* the URI is not recognized, `null` is returned.
|
|
1646
|
-
* @since 0.9.0
|
|
1647
|
-
*/
|
|
1648
|
-
parseUri(uri: URL | null): ParseUriResult | null;
|
|
1649
|
-
/**
|
|
1650
|
-
* Gets the key pairs for an actor.
|
|
1651
|
-
* @param identifier The actor's identifier.
|
|
1652
|
-
* @returns An async iterable of the actor's key pairs. It can be empty.
|
|
1653
|
-
* @since 0.10.0
|
|
1654
|
-
*/
|
|
1655
|
-
getActorKeyPairs(identifier: string): Promise<ActorKeyPair[]>;
|
|
1656
|
-
/**
|
|
1657
|
-
* Gets an authenticated {@link DocumentLoader} for the given identity.
|
|
1658
|
-
* Note that an authenticated document loader intentionally does not cache
|
|
1659
|
-
* the fetched documents.
|
|
1660
|
-
* @param identity The identity to get the document loader for.
|
|
1661
|
-
* The actor's identifier or username.
|
|
1662
|
-
* @returns The authenticated document loader.
|
|
1663
|
-
* @throws {Error} If the identity is not valid.
|
|
1664
|
-
* @throws {TypeError} If the key is invalid or unsupported.
|
|
1665
|
-
* @since 0.4.0
|
|
1666
|
-
*/
|
|
1667
|
-
getDocumentLoader(identity: {
|
|
1668
|
-
identifier: string;
|
|
1669
|
-
} | {
|
|
1670
|
-
username: string;
|
|
1671
|
-
}): Promise<DocumentLoader>;
|
|
1672
|
-
/**
|
|
1673
|
-
* Gets an authenticated {@link DocumentLoader} for the given identity.
|
|
1674
|
-
* Note that an authenticated document loader intentionally does not cache
|
|
1675
|
-
* the fetched documents.
|
|
1676
|
-
* @param identity The identity to get the document loader for.
|
|
1677
|
-
* The actor's key pair.
|
|
1678
|
-
* @returns The authenticated document loader.
|
|
1679
|
-
* @throws {TypeError} If the key is invalid or unsupported.
|
|
1680
|
-
* @since 0.4.0
|
|
1681
|
-
*/
|
|
1682
|
-
getDocumentLoader(identity: {
|
|
1683
|
-
keyId: URL;
|
|
1684
|
-
privateKey: CryptoKey;
|
|
1685
|
-
}): DocumentLoader;
|
|
1686
|
-
/**
|
|
1687
|
-
* Looks up an ActivityStreams object by its URI (including `acct:` URIs)
|
|
1688
|
-
* or a fediverse handle (e.g., `@user@server` or `user@server`).
|
|
1689
|
-
*
|
|
1690
|
-
* @example
|
|
1691
|
-
* ``` typescript
|
|
1692
|
-
* // Look up an actor by its fediverse handle:
|
|
1693
|
-
* await ctx.lookupObject("@hongminhee@fosstodon.org");
|
|
1694
|
-
* // returning a `Person` object.
|
|
1695
|
-
*
|
|
1696
|
-
* // A fediverse handle can omit the leading '@':
|
|
1697
|
-
* await ctx.lookupObject("hongminhee@fosstodon.org");
|
|
1698
|
-
* // returning a `Person` object.
|
|
1699
|
-
*
|
|
1700
|
-
* // A `acct:` URI can be used as well:
|
|
1701
|
-
* await ctx.lookupObject("acct:hongminhee@fosstodon.org");
|
|
1702
|
-
* // returning a `Person` object.
|
|
1703
|
-
*
|
|
1704
|
-
* // Look up an object by its URI:
|
|
1705
|
-
* await ctx.lookupObject("https://todon.eu/@hongminhee/112060633798771581");
|
|
1706
|
-
* // returning a `Note` object.
|
|
1707
|
-
*
|
|
1708
|
-
* // It can be a `URL` object as well:
|
|
1709
|
-
* await ctx.lookupObject(
|
|
1710
|
-
* new URL("https://todon.eu/@hongminhee/112060633798771581")
|
|
1711
|
-
* );
|
|
1712
|
-
* // returning a `Note` object.
|
|
1713
|
-
* ```
|
|
1714
|
-
*
|
|
1715
|
-
* It's almost the same as the {@link lookupObject} function, but it uses
|
|
1716
|
-
* the context's document loader and context loader by default.
|
|
1717
|
-
*
|
|
1718
|
-
* @param identifier The URI or fediverse handle to look up.
|
|
1719
|
-
* @param options Lookup options.
|
|
1720
|
-
* @returns The object, or `null` if not found.
|
|
1721
|
-
* @since 0.15.0
|
|
1722
|
-
*/
|
|
1723
|
-
lookupObject(identifier: string | URL, options?: LookupObjectOptions): Promise<Object$1 | null>;
|
|
1724
|
-
/**
|
|
1725
|
-
* Traverses a collection, yielding each item in the collection.
|
|
1726
|
-
* If the collection is paginated, it will fetch the next page
|
|
1727
|
-
* automatically.
|
|
1728
|
-
*
|
|
1729
|
-
* @example
|
|
1730
|
-
* ``` typescript
|
|
1731
|
-
* const collection = await ctx.lookupObject(collectionUrl);
|
|
1732
|
-
* if (collection instanceof Collection) {
|
|
1733
|
-
* for await (const item of ctx.traverseCollection(collection)) {
|
|
1734
|
-
* console.log(item.id?.href);
|
|
1735
|
-
* }
|
|
1736
|
-
* }
|
|
1737
|
-
* ```
|
|
1738
|
-
*
|
|
1739
|
-
* It's almost the same as the {@link traverseCollection} function, but it
|
|
1740
|
-
* uses the context's document loader and context loader by default.
|
|
1741
|
-
* @param collection The collection to traverse.
|
|
1742
|
-
* @param options Options for traversing the collection.
|
|
1743
|
-
* @returns An async iterable of each item in the collection.
|
|
1744
|
-
* @since 1.1.0
|
|
1745
|
-
*/
|
|
1746
|
-
traverseCollection(collection: Collection, options?: TraverseCollectionOptions): AsyncIterable<Object$1 | Link>;
|
|
1747
|
-
/**
|
|
1748
|
-
* Fetches the NodeInfo document from the given URL.
|
|
1749
|
-
* @param url The base URL of the server. If `options.direct` is turned off
|
|
1750
|
-
* (default), the NodeInfo document will be fetched from
|
|
1751
|
-
* the `.well-known` location of this URL (hence the only origin
|
|
1752
|
-
* of the URL is used). If `options.direct` is turned on,
|
|
1753
|
-
* the NodeInfo document will be fetched from the given URL.
|
|
1754
|
-
* @param options Options for fetching the NodeInfo document.
|
|
1755
|
-
* @returns The NodeInfo document if it could be fetched successfully.
|
|
1756
|
-
* Otherwise, `undefined` is returned.
|
|
1757
|
-
* @since 1.4.0
|
|
1758
|
-
*/
|
|
1759
|
-
lookupNodeInfo(url: URL | string, options?: GetNodeInfoOptions & {
|
|
1760
|
-
parse?: "strict" | "best-effort";
|
|
1761
|
-
}): Promise<NodeInfo | undefined>;
|
|
1762
|
-
/**
|
|
1763
|
-
* Fetches the NodeInfo document from the given URL.
|
|
1764
|
-
* @param url The base URL of the server. If `options.direct` is turned off
|
|
1765
|
-
* (default), the NodeInfo document will be fetched from
|
|
1766
|
-
* the `.well-known` location of this URL (hence the only origin
|
|
1767
|
-
* of the URL is used). If `options.direct` is turned on,
|
|
1768
|
-
* the NodeInfo document will be fetched from the given URL.
|
|
1769
|
-
* @param options Options for fetching the NodeInfo document.
|
|
1770
|
-
* @returns The NodeInfo document if it could be fetched successfully.
|
|
1771
|
-
* Otherwise, `undefined` is returned.
|
|
1772
|
-
* @since 1.4.0
|
|
1773
|
-
*/
|
|
1774
|
-
lookupNodeInfo(url: URL | string, options?: GetNodeInfoOptions & {
|
|
1775
|
-
parse: "none";
|
|
1776
|
-
}): Promise<JsonValue | undefined>;
|
|
1777
|
-
/**
|
|
1778
|
-
* Looks up a WebFinger resource.
|
|
1779
|
-
*
|
|
1780
|
-
* It's almost the same as the {@link lookupWebFinger} function, but it uses
|
|
1781
|
-
* the context's configuration by default.
|
|
1782
|
-
*
|
|
1783
|
-
* @param resource The resource URL to look up.
|
|
1784
|
-
* @param options Extra options for looking up the resource.
|
|
1785
|
-
* @returns The resource descriptor, or `null` if not found.
|
|
1786
|
-
* @since 1.6.0
|
|
1787
|
-
*/
|
|
1788
|
-
lookupWebFinger(resource: URL | string, options?: LookupWebFingerOptions): Promise<ResourceDescriptor | null>;
|
|
1789
|
-
/**
|
|
1790
|
-
* Sends an activity to recipients' inboxes.
|
|
1791
|
-
* @param sender The sender's identifier or the sender's username or
|
|
1792
|
-
* the sender's key pair(s).
|
|
1793
|
-
* @param recipients The recipients of the activity.
|
|
1794
|
-
* @param activity The activity to send.
|
|
1795
|
-
* @param options Options for sending the activity.
|
|
1796
|
-
*/
|
|
1797
|
-
sendActivity(sender: SenderKeyPair | SenderKeyPair[] | {
|
|
1798
|
-
identifier: string;
|
|
1799
|
-
} | {
|
|
1800
|
-
username: string;
|
|
1801
|
-
}, recipients: Recipient | Recipient[], activity: Activity, options?: SendActivityOptions): Promise<void>;
|
|
1802
|
-
/**
|
|
1803
|
-
* Sends an activity to the inboxes of the sender's followers.
|
|
1804
|
-
* @param sender The sender's identifier or the sender's username.
|
|
1805
|
-
* @param recipients In this case, it must be `"followers"`.
|
|
1806
|
-
* @param activity The activity to send.
|
|
1807
|
-
* @param options Options for sending the activity.
|
|
1808
|
-
* @throws {Error} If no followers collection is registered.
|
|
1809
|
-
* @since 0.14.0
|
|
1810
|
-
*/
|
|
1811
|
-
sendActivity(sender: {
|
|
1812
|
-
identifier: string;
|
|
1813
|
-
} | {
|
|
1814
|
-
username: string;
|
|
1815
|
-
}, recipients: "followers", activity: Activity, options?: SendActivityOptionsForCollection): Promise<void>;
|
|
1816
|
-
/**
|
|
1817
|
-
* Manually routes an activity to the appropriate inbox listener.
|
|
1818
|
-
*
|
|
1819
|
-
* It is useful for routing an activity that is not received from the network,
|
|
1820
|
-
* or for routing an activity that is enclosed in another activity.
|
|
1821
|
-
*
|
|
1822
|
-
* Note that the activity will be verified if it has Object Integrity Proofs
|
|
1823
|
-
* or is equivalent to the actual remote object. If the activity is not
|
|
1824
|
-
* verified, it will be rejected.
|
|
1825
|
-
* @param recipient The recipient of the activity. If it is `null`,
|
|
1826
|
-
* the activity will be routed to the shared inbox.
|
|
1827
|
-
* Otherwise, the activity will be routed to the personal
|
|
1828
|
-
* inbox of the recipient with the given identifier.
|
|
1829
|
-
* @param activity The activity to route. It must have a proof or
|
|
1830
|
-
* a dereferenceable `id` to verify the activity.
|
|
1831
|
-
* @param options Options for routing the activity.
|
|
1832
|
-
* @returns `true` if the activity is successfully verified and routed.
|
|
1833
|
-
* Otherwise, `false`.
|
|
1834
|
-
* @since 1.3.0
|
|
1835
|
-
*/
|
|
1836
|
-
routeActivity(recipient: string | null, activity: Activity, options?: RouteActivityOptions): Promise<boolean>;
|
|
1837
|
-
/**
|
|
1838
|
-
* Builds the URI of a collection of objects with the given name and values.
|
|
1839
|
-
* @param name The name of the collection, which can be a string or a symbol.
|
|
1840
|
-
* @param values The values of the URI parameters.
|
|
1841
|
-
* @return The URI of the collection.
|
|
1842
|
-
* @throws {RouterError} If no object dispatcher is available for the name.
|
|
1843
|
-
* @throws {TypeError} If values are invalid.
|
|
1844
|
-
* @since 1.8.0
|
|
1845
|
-
*/
|
|
1846
|
-
getCollectionUri<TParam extends Record<string, string>>(name: string | symbol, values: TParam): URL;
|
|
1847
|
-
}
|
|
1848
|
-
/**
|
|
1849
|
-
* Options for {@link RequestContext.getActor}.
|
|
1850
|
-
* @since 2.2.0
|
|
1851
|
-
*/
|
|
1852
|
-
interface GetActorOptions {
|
|
1853
|
-
/**
|
|
1854
|
-
* Controls how tombstoned actors are returned.
|
|
1855
|
-
*
|
|
1856
|
-
* By default, tombstones are suppressed and returned as `null`. Set this to
|
|
1857
|
-
* `"passthrough"` to receive a {@link Tombstone} result instead.
|
|
1858
|
-
*/
|
|
1859
|
-
readonly tombstone?: "suppress" | "passthrough";
|
|
1860
|
-
}
|
|
1861
|
-
/**
|
|
1862
|
-
* A context for a request.
|
|
1863
|
-
*/
|
|
1864
|
-
interface RequestContext<TContextData> extends Context<TContextData> {
|
|
1865
|
-
/**
|
|
1866
|
-
* The request object.
|
|
1867
|
-
*/
|
|
1868
|
-
readonly request: Request;
|
|
1869
|
-
/**
|
|
1870
|
-
* The URL of the request.
|
|
1871
|
-
*/
|
|
1872
|
-
readonly url: URL;
|
|
1873
|
-
/**
|
|
1874
|
-
* Creates a new context with the same properties as this one,
|
|
1875
|
-
* but with the given data.
|
|
1876
|
-
* @param data The new data to associate with the context.
|
|
1877
|
-
* @returns A new context with the same properties as this one,
|
|
1878
|
-
* but with the given data.
|
|
1879
|
-
* @since 1.6.0
|
|
1880
|
-
*/
|
|
1881
|
-
clone(data: TContextData): RequestContext<TContextData>;
|
|
1882
|
-
/**
|
|
1883
|
-
* Gets an {@link Actor} object for the given identifier.
|
|
1884
|
-
* @param identifier The actor's identifier.
|
|
1885
|
-
* @returns The actor object, or `null` if the actor is not found.
|
|
1886
|
-
* @throws {Error} If no actor dispatcher is available.
|
|
1887
|
-
* @since 0.7.0
|
|
1888
|
-
*/
|
|
1889
|
-
getActor(identifier: string): Promise<Actor | null>;
|
|
1890
|
-
/**
|
|
1891
|
-
* Gets an {@link Actor} object or {@link Tombstone} for the given
|
|
1892
|
-
* identifier.
|
|
1893
|
-
* @param identifier The actor's identifier.
|
|
1894
|
-
* @param options Options for getting the actor. Set
|
|
1895
|
-
* `options.tombstone` to `"passthrough"` to receive
|
|
1896
|
-
* tombstoned actors instead of `null`.
|
|
1897
|
-
* @returns The actor object, a tombstone, or `null` if the actor is not
|
|
1898
|
-
* found.
|
|
1899
|
-
* @throws {Error} If no actor dispatcher is available.
|
|
1900
|
-
* @since 2.2.0
|
|
1901
|
-
*/
|
|
1902
|
-
getActor(identifier: string, options: GetActorOptions & {
|
|
1903
|
-
readonly tombstone: "passthrough";
|
|
1904
|
-
}): Promise<Actor | Tombstone | null>;
|
|
1905
|
-
/**
|
|
1906
|
-
* Gets an {@link Actor} object for the given identifier.
|
|
1907
|
-
* @param identifier The actor's identifier.
|
|
1908
|
-
* @param options Options for getting the actor.
|
|
1909
|
-
* @returns The actor object, or `null` if the actor is not found.
|
|
1910
|
-
* Tombstoned actors are suppressed unless `options.tombstone` is
|
|
1911
|
-
* `"passthrough"`.
|
|
1912
|
-
* @throws {Error} If no actor dispatcher is available.
|
|
1913
|
-
* @since 2.2.0
|
|
1914
|
-
*/
|
|
1915
|
-
getActor(identifier: string, options: GetActorOptions & {
|
|
1916
|
-
readonly tombstone?: "suppress" | undefined;
|
|
1917
|
-
}): Promise<Actor | null>;
|
|
1918
|
-
/**
|
|
1919
|
-
* Gets an {@link Actor} object or {@link Tombstone} for the given
|
|
1920
|
-
* identifier.
|
|
1921
|
-
* @param identifier The actor's identifier.
|
|
1922
|
-
* @param options Options for getting the actor.
|
|
1923
|
-
* @returns The actor object, a tombstone, or `null` if the actor is not
|
|
1924
|
-
* found. This broad overload is used when the caller passes an
|
|
1925
|
-
* options value whose `tombstone` mode is not known statically.
|
|
1926
|
-
* @throws {Error} If no actor dispatcher is available.
|
|
1927
|
-
* @since 2.2.0
|
|
1928
|
-
*/
|
|
1929
|
-
getActor(identifier: string, options: GetActorOptions): Promise<Actor | Tombstone | null>;
|
|
1930
|
-
/**
|
|
1931
|
-
* Gets an object of the given class with the given values.
|
|
1932
|
-
* @param cls The class to instantiate.
|
|
1933
|
-
* @param values The values to pass to the object dispatcher.
|
|
1934
|
-
* @returns The object of the given class with the given values, or `null`
|
|
1935
|
-
* if the object is not found.
|
|
1936
|
-
* @throws {Error} If no object dispatcher is available for the class.
|
|
1937
|
-
* @throws {TypeError} If values are invalid.
|
|
1938
|
-
* @since 0.7.0
|
|
1939
|
-
*/
|
|
1940
|
-
getObject<TObject extends Object$1>(cls: ConstructorWithTypeId<TObject>, values: Record<string, string>): Promise<TObject | null>;
|
|
1941
|
-
/**
|
|
1942
|
-
* Gets the public key of the sender, if any exists and it is verified.
|
|
1943
|
-
* Otherwise, `null` is returned.
|
|
1944
|
-
*
|
|
1945
|
-
* This can be used for implementing [authorized fetch] (also known as
|
|
1946
|
-
* secure mode) in ActivityPub.
|
|
1947
|
-
*
|
|
1948
|
-
* [authorized fetch]: https://swicg.github.io/activitypub-http-signature/#authorized-fetch
|
|
1949
|
-
*
|
|
1950
|
-
* @returns The public key of the sender, or `null` if the sender is not verified.
|
|
1951
|
-
* @since 0.7.0
|
|
1952
|
-
*/
|
|
1953
|
-
getSignedKey(): Promise<CryptographicKey | null>;
|
|
1954
|
-
/**
|
|
1955
|
-
* Gets the public key of the sender, if any exists and it is verified.
|
|
1956
|
-
* Otherwise, `null` is returned.
|
|
1957
|
-
*
|
|
1958
|
-
* This can be used for implementing [authorized fetch] (also known as
|
|
1959
|
-
* secure mode) in ActivityPub.
|
|
1960
|
-
*
|
|
1961
|
-
* [authorized fetch]: https://swicg.github.io/activitypub-http-signature/#authorized-fetch
|
|
1962
|
-
*
|
|
1963
|
-
* @param options Options for getting the signed key. You usually may want to
|
|
1964
|
-
* specify the custom `documentLoader` so that making
|
|
1965
|
-
* an HTTP request to the sender's server is signed with
|
|
1966
|
-
* your [instance actor].
|
|
1967
|
-
* @returns The public key of the sender, or `null` if the sender is not verified.
|
|
1968
|
-
* @since 1.5.0
|
|
1969
|
-
*
|
|
1970
|
-
* [instance actor]: https://swicg.github.io/activitypub-http-signature/#instance-actor
|
|
1971
|
-
*/
|
|
1972
|
-
getSignedKey(options: GetSignedKeyOptions): Promise<CryptographicKey | null>;
|
|
1973
|
-
/**
|
|
1974
|
-
* Gets the owner of the signed key, if any exists and it is verified.
|
|
1975
|
-
* Otherwise, `null` is returned.
|
|
1976
|
-
*
|
|
1977
|
-
* This can be used for implementing [authorized fetch] (also known as
|
|
1978
|
-
* secure mode) in ActivityPub.
|
|
1979
|
-
*
|
|
1980
|
-
* [authorized fetch]: https://swicg.github.io/activitypub-http-signature/#authorized-fetch
|
|
1981
|
-
*
|
|
1982
|
-
* @returns The owner of the signed key, or `null` if the key is not verified
|
|
1983
|
-
* or the owner is not found.
|
|
1984
|
-
* @since 0.7.0
|
|
1985
|
-
*/
|
|
1986
|
-
getSignedKeyOwner(): Promise<Actor | null>;
|
|
1987
|
-
/**
|
|
1988
|
-
* Gets the owner of the signed key, if any exists and it is verified.
|
|
1989
|
-
* Otherwise, `null` is returned.
|
|
1990
|
-
*
|
|
1991
|
-
* This can be used for implementing [authorized fetch] (also known as
|
|
1992
|
-
* secure mode) in ActivityPub.
|
|
1993
|
-
*
|
|
1994
|
-
* [authorized fetch]: https://swicg.github.io/activitypub-http-signature/#authorized-fetch
|
|
1995
|
-
*
|
|
1996
|
-
* @param options Options for getting the key owner. You usually may want to
|
|
1997
|
-
* specify the custom `documentLoader` so that making
|
|
1998
|
-
* an HTTP request to the key owner's server is signed with
|
|
1999
|
-
* your [instance actor].
|
|
2000
|
-
* @returns The owner of the signed key, or `null` if the key is not verified
|
|
2001
|
-
* or the owner is not found.
|
|
2002
|
-
* @since 1.5.0
|
|
2003
|
-
*
|
|
2004
|
-
* [instance actor]: https://swicg.github.io/activitypub-http-signature/#instance-actor
|
|
2005
|
-
*/
|
|
2006
|
-
getSignedKeyOwner(options: GetKeyOwnerOptions): Promise<Actor | null>;
|
|
2007
|
-
}
|
|
2008
|
-
/**
|
|
2009
|
-
* A context for inbox listeners.
|
|
2010
|
-
* @since 1.0.0
|
|
2011
|
-
*/
|
|
2012
|
-
interface InboxContext<TContextData> extends Context<TContextData> {
|
|
2013
|
-
/**
|
|
2014
|
-
* The identifier of the recipient of the inbox. If the inbox is a shared
|
|
2015
|
-
* inbox, it is `null`.
|
|
2016
|
-
* @since 1.2.0
|
|
2017
|
-
*/
|
|
2018
|
-
readonly recipient: string | null;
|
|
2019
|
-
/**
|
|
2020
|
-
* Creates a new context with the same properties as this one,
|
|
2021
|
-
* but with the given data.
|
|
2022
|
-
* @param data The new data to associate with the context.
|
|
2023
|
-
* @returns A new context with the same properties as this one,
|
|
2024
|
-
* but with the given data.
|
|
2025
|
-
* @since 1.6.0
|
|
2026
|
-
*/
|
|
2027
|
-
clone(data: TContextData): InboxContext<TContextData>;
|
|
2028
|
-
/**
|
|
2029
|
-
* Forwards a received activity to the recipients' inboxes. The forwarded
|
|
2030
|
-
* activity will be signed in HTTP Signatures by the forwarder, but its
|
|
2031
|
-
* payload will not be modified, i.e., Linked Data Signatures and Object
|
|
2032
|
-
* Integrity Proofs will not be added. Even when Fedify internally
|
|
2033
|
-
* normalizes a Linked Data Signature activity for parsing, this method still
|
|
2034
|
-
* forwards the original received payload so the sender's signatures/proofs
|
|
2035
|
-
* are preserved as-is. Therefore, if the activity is not signed (i.e., it
|
|
2036
|
-
* has neither Linked Data Signatures nor Object Integrity Proofs), the
|
|
2037
|
-
* recipient probably will not trust the activity.
|
|
2038
|
-
* @param forwarder The forwarder's identifier or the forwarder's username
|
|
2039
|
-
* or the forwarder's key pair(s).
|
|
2040
|
-
* @param recipients The recipients of the activity.
|
|
2041
|
-
* @param options Options for forwarding the activity.
|
|
2042
|
-
* @since 1.0.0
|
|
2043
|
-
*/
|
|
2044
|
-
forwardActivity(forwarder: SenderKeyPair | SenderKeyPair[] | {
|
|
2045
|
-
identifier: string;
|
|
2046
|
-
} | {
|
|
2047
|
-
username: string;
|
|
2048
|
-
}, recipients: Recipient | Recipient[], options?: ForwardActivityOptions): Promise<void>;
|
|
2049
|
-
/**
|
|
2050
|
-
* Forwards a received activity to the recipients' inboxes. The forwarded
|
|
2051
|
-
* activity will be signed in HTTP Signatures by the forwarder, but its
|
|
2052
|
-
* payload will not be modified, i.e., Linked Data Signatures and Object
|
|
2053
|
-
* Integrity Proofs will not be added. Even when Fedify internally
|
|
2054
|
-
* normalizes a Linked Data Signature activity for parsing, this method still
|
|
2055
|
-
* forwards the original received payload so the sender's signatures/proofs
|
|
2056
|
-
* are preserved as-is. Therefore, if the activity is not signed (i.e., it
|
|
2057
|
-
* has neither Linked Data Signatures nor Object Integrity Proofs), the
|
|
2058
|
-
* recipient probably will not trust the activity.
|
|
2059
|
-
* @param forwarder The forwarder's identifier or the forwarder's username.
|
|
2060
|
-
* @param recipients In this case, it must be `"followers"`.
|
|
2061
|
-
* @param options Options for forwarding the activity.
|
|
2062
|
-
* @since 1.0.0
|
|
2063
|
-
*/
|
|
2064
|
-
forwardActivity(forwarder: {
|
|
2065
|
-
identifier: string;
|
|
2066
|
-
} | {
|
|
2067
|
-
username: string;
|
|
2068
|
-
}, recipients: "followers", options?: ForwardActivityOptions): Promise<void>;
|
|
2069
|
-
}
|
|
2070
|
-
/**
|
|
2071
|
-
* A context for outbox listeners.
|
|
2072
|
-
* @since 2.2.0
|
|
2073
|
-
*/
|
|
2074
|
-
interface OutboxContext<TContextData> extends Context<TContextData> {
|
|
2075
|
-
/**
|
|
2076
|
-
* The identifier of the actor whose outbox received the POST.
|
|
2077
|
-
* @since 2.2.0
|
|
2078
|
-
*/
|
|
2079
|
-
readonly identifier: string;
|
|
2080
|
-
/**
|
|
2081
|
-
* Indicates whether the posted activity has been delivered during the
|
|
2082
|
-
* current outbox listener invocation.
|
|
2083
|
-
* @returns `true` if the posted activity has been delivered; `false`
|
|
2084
|
-
* otherwise.
|
|
2085
|
-
* @since 2.2.0
|
|
2086
|
-
*/
|
|
2087
|
-
hasDeliveredActivity(): boolean;
|
|
2088
|
-
/**
|
|
2089
|
-
* Forwards a posted activity to the recipients' inboxes without
|
|
2090
|
-
* re-serializing the original payload. The forwarded activity will be
|
|
2091
|
-
* signed in HTTP Signatures by the forwarder, but its payload will not be
|
|
2092
|
-
* modified, i.e., Linked Data Signatures and Object Integrity Proofs will
|
|
2093
|
-
* not be added. Therefore, if the posted activity is not signed (i.e., it
|
|
2094
|
-
* has neither Linked Data Signatures nor Object Integrity Proofs), the
|
|
2095
|
-
* recipients probably will not trust the activity.
|
|
2096
|
-
* @param forwarder The forwarder's identifier or the forwarder's username
|
|
2097
|
-
* or the forwarder's key pair(s).
|
|
2098
|
-
* @param recipients The recipients of the activity.
|
|
2099
|
-
* @param options Options for forwarding the activity.
|
|
2100
|
-
* @since 2.2.0
|
|
2101
|
-
*/
|
|
2102
|
-
forwardActivity(forwarder: SenderKeyPair | SenderKeyPair[] | {
|
|
2103
|
-
identifier: string;
|
|
2104
|
-
} | {
|
|
2105
|
-
username: string;
|
|
2106
|
-
}, recipients: Recipient | Recipient[], options?: ForwardActivityOptions): Promise<void>;
|
|
2107
|
-
/**
|
|
2108
|
-
* Forwards a posted activity to the recipients' inboxes without
|
|
2109
|
-
* re-serializing the original payload. The forwarded activity will be
|
|
2110
|
-
* signed in HTTP Signatures by the forwarder, but its payload will not be
|
|
2111
|
-
* modified, i.e., Linked Data Signatures and Object Integrity Proofs will
|
|
2112
|
-
* not be added. Therefore, if the posted activity is not signed (i.e., it
|
|
2113
|
-
* has neither Linked Data Signatures nor Object Integrity Proofs), the
|
|
2114
|
-
* recipients probably will not trust the activity.
|
|
2115
|
-
* @param forwarder The forwarder's identifier or the forwarder's username.
|
|
2116
|
-
* @param recipients In this case, it must be `"followers"`.
|
|
2117
|
-
* @param options Options for forwarding the activity.
|
|
2118
|
-
* @since 2.2.0
|
|
2119
|
-
*/
|
|
2120
|
-
forwardActivity(forwarder: {
|
|
2121
|
-
identifier: string;
|
|
2122
|
-
} | {
|
|
2123
|
-
username: string;
|
|
2124
|
-
}, recipients: "followers", options?: ForwardActivityOptions): Promise<void>;
|
|
2125
|
-
/**
|
|
2126
|
-
* Creates a new context with the same properties as this one,
|
|
2127
|
-
* but with the given data.
|
|
2128
|
-
* @param data The new data to associate with the context.
|
|
2129
|
-
* @returns A new context with the same properties as this one,
|
|
2130
|
-
* but with the given data.
|
|
2131
|
-
* @since 2.2.0
|
|
2132
|
-
*/
|
|
2133
|
-
clone(data: TContextData): OutboxContext<TContextData>;
|
|
2134
|
-
}
|
|
2135
|
-
/**
|
|
2136
|
-
* A result of parsing an URI.
|
|
2137
|
-
*/
|
|
2138
|
-
type ParseUriResult =
|
|
2139
|
-
/**
|
|
2140
|
-
* The case of an actor URI.
|
|
2141
|
-
*/
|
|
2142
|
-
{
|
|
2143
|
-
readonly type: "actor";
|
|
2144
|
-
readonly identifier: string;
|
|
2145
|
-
}
|
|
2146
|
-
/**
|
|
2147
|
-
* The case of an object URI.
|
|
2148
|
-
*/
|
|
2149
|
-
| {
|
|
2150
|
-
readonly type: "object";
|
|
2151
|
-
readonly class: ConstructorWithTypeId<Object$1>;
|
|
2152
|
-
readonly typeId: URL;
|
|
2153
|
-
readonly values: Record<string, string>;
|
|
2154
|
-
}
|
|
2155
|
-
/**
|
|
2156
|
-
* The case of an shared inbox URI.
|
|
2157
|
-
*/
|
|
2158
|
-
| {
|
|
2159
|
-
readonly type: "inbox";
|
|
2160
|
-
readonly identifier: undefined;
|
|
2161
|
-
}
|
|
2162
|
-
/**
|
|
2163
|
-
* The case of an personal inbox URI.
|
|
2164
|
-
*/
|
|
2165
|
-
| {
|
|
2166
|
-
readonly type: "inbox";
|
|
2167
|
-
readonly identifier: string;
|
|
2168
|
-
}
|
|
2169
|
-
/**
|
|
2170
|
-
* The case of an outbox collection URI.
|
|
2171
|
-
*/
|
|
2172
|
-
| {
|
|
2173
|
-
readonly type: "outbox";
|
|
2174
|
-
readonly identifier: string;
|
|
2175
|
-
}
|
|
2176
|
-
/**
|
|
2177
|
-
* The case of a following collection URI.
|
|
2178
|
-
*/
|
|
2179
|
-
| {
|
|
2180
|
-
readonly type: "following";
|
|
2181
|
-
readonly identifier: string;
|
|
2182
|
-
}
|
|
2183
|
-
/**
|
|
2184
|
-
* The case of a followers collection URI.
|
|
2185
|
-
*/
|
|
2186
|
-
| {
|
|
2187
|
-
readonly type: "followers";
|
|
2188
|
-
readonly identifier: string;
|
|
2189
|
-
}
|
|
2190
|
-
/**
|
|
2191
|
-
* The case of a liked collection URI.
|
|
2192
|
-
* @since 0.11.0
|
|
2193
|
-
*/
|
|
2194
|
-
| {
|
|
2195
|
-
readonly type: "liked";
|
|
2196
|
-
readonly identifier: string;
|
|
2197
|
-
}
|
|
2198
|
-
/**
|
|
2199
|
-
* The case of a featured collection URI.
|
|
2200
|
-
* @since 0.11.0
|
|
2201
|
-
*/
|
|
2202
|
-
| {
|
|
2203
|
-
readonly type: "featured";
|
|
2204
|
-
readonly identifier: string;
|
|
2205
|
-
}
|
|
2206
|
-
/**
|
|
2207
|
-
* The case of a featured tags collection URI.
|
|
2208
|
-
* @since 0.11.0
|
|
2209
|
-
*/
|
|
2210
|
-
| {
|
|
2211
|
-
readonly type: "featuredTags";
|
|
2212
|
-
readonly identifier: string;
|
|
2213
|
-
}
|
|
2214
|
-
/**
|
|
2215
|
-
* The case of a custom collection URI.
|
|
2216
|
-
* @since 1.8.0
|
|
2217
|
-
*/
|
|
2218
|
-
| {
|
|
2219
|
-
readonly type: "collection";
|
|
2220
|
-
readonly name: string | symbol;
|
|
2221
|
-
readonly class: ConstructorWithTypeId<Object$1>;
|
|
2222
|
-
readonly typeId: URL;
|
|
2223
|
-
readonly values: Record<string, string>;
|
|
2224
|
-
}
|
|
2225
|
-
/**
|
|
2226
|
-
* The case of a custom ordered collection URI.
|
|
2227
|
-
* @since 1.8.0
|
|
2228
|
-
*/
|
|
2229
|
-
| {
|
|
2230
|
-
readonly type: "orderedCollection";
|
|
2231
|
-
readonly name: string | symbol;
|
|
2232
|
-
readonly class: ConstructorWithTypeId<Object$1>;
|
|
2233
|
-
readonly typeId: URL;
|
|
2234
|
-
readonly values: Record<string, string>;
|
|
2235
|
-
};
|
|
2236
|
-
/**
|
|
2237
|
-
* Options for {@link Context.sendActivity} method.
|
|
2238
|
-
*/
|
|
2239
|
-
interface SendActivityOptions {
|
|
2240
|
-
/**
|
|
2241
|
-
* Whether to prefer the shared inbox for the recipients.
|
|
2242
|
-
*/
|
|
2243
|
-
readonly preferSharedInbox?: boolean;
|
|
2244
|
-
/**
|
|
2245
|
-
* Whether to send the activity immediately, without enqueuing it.
|
|
2246
|
-
* If `true`, the activity will be sent immediately and the retrial
|
|
2247
|
-
* policy will not be applied.
|
|
2248
|
-
*
|
|
2249
|
-
* @since 0.3.0
|
|
2250
|
-
*/
|
|
2251
|
-
readonly immediate?: boolean;
|
|
2252
|
-
/**
|
|
2253
|
-
* Determines how activities are queued when sent to multiple recipients.
|
|
2254
|
-
*
|
|
2255
|
-
* - "auto" (default): Automatically chooses optimal strategy based on
|
|
2256
|
-
* recipient count.
|
|
2257
|
-
* - "skip": Always enqueues individual messages per recipient,
|
|
2258
|
-
* bypassing the fanout queue. Use when payload needs to vary per recipient.
|
|
2259
|
-
* - "force": Always uses fanout queue regardless of recipient count.
|
|
2260
|
-
* Useful for testing or special cases.
|
|
2261
|
-
*
|
|
2262
|
-
* This option is ignored when `immediate: true` is specified, as immediate
|
|
2263
|
-
* delivery bypasses all queuing mechanisms.
|
|
2264
|
-
*
|
|
2265
|
-
* @default `"auto"`
|
|
2266
|
-
* @since 1.5.0
|
|
2267
|
-
*/
|
|
2268
|
-
readonly fanout?: "auto" | "skip" | "force";
|
|
2269
|
-
/**
|
|
2270
|
-
* Whether to apply Fedify's outgoing JSON-LD wire-format compatibility fixes
|
|
2271
|
-
* to activities that already carry Object Integrity Proofs.
|
|
2272
|
-
*
|
|
2273
|
-
* By default, Fedify preserves existing proofs byte-for-byte because it
|
|
2274
|
-
* cannot know whether they were created for the normalized outgoing wire
|
|
2275
|
-
* form. Set this to `true` when sending an activity that was pre-signed
|
|
2276
|
-
* locally with `signObject()` or `createProof()`, so the emitted
|
|
2277
|
-
* compact JSON-LD matches the bytes covered by the proof.
|
|
2278
|
-
*
|
|
2279
|
-
* @since 2.2.0
|
|
2280
|
-
*/
|
|
2281
|
-
readonly normalizeExistingProofs?: boolean;
|
|
2282
|
-
/**
|
|
2283
|
-
* The base URIs to exclude from the recipients' inboxes. It is useful
|
|
2284
|
-
* for excluding the recipients having the same shared inbox with the sender.
|
|
2285
|
-
*
|
|
2286
|
-
* Note that the only `origin` parts of the `URL`s are compared.
|
|
2287
|
-
*
|
|
2288
|
-
* @since 0.9.0
|
|
2289
|
-
*/
|
|
2290
|
-
readonly excludeBaseUris?: readonly URL[];
|
|
2291
|
-
/**
|
|
2292
|
-
* An optional key to ensure ordered delivery of activities. Activities with
|
|
2293
|
-
* the same `orderingKey` are guaranteed to be delivered in the order they
|
|
2294
|
-
* were enqueued, per recipient server.
|
|
2295
|
-
*
|
|
2296
|
-
* Typical use case: pass the object ID (e.g., `Note` ID) to ensure that
|
|
2297
|
-
* `Create`, `Update`, and `Delete` activities for the same object are
|
|
2298
|
-
* delivered in order.
|
|
2299
|
-
*
|
|
2300
|
-
* When omitted, no ordering is guaranteed (maximum parallelism).
|
|
2301
|
-
*
|
|
2302
|
-
* @since 2.0.0
|
|
2303
|
-
*/
|
|
2304
|
-
readonly orderingKey?: string;
|
|
2305
|
-
}
|
|
2306
|
-
/**
|
|
2307
|
-
* Options for {@link Context.sendActivity} method when sending to a collection.
|
|
2308
|
-
* @since 1.5.0
|
|
2309
|
-
*/
|
|
2310
|
-
interface SendActivityOptionsForCollection extends SendActivityOptions {
|
|
2311
|
-
/**
|
|
2312
|
-
* Whether to synchronize the collection using `Collection-Synchronization`
|
|
2313
|
-
* header ([FEP-8fcf]).
|
|
2314
|
-
*
|
|
2315
|
-
* [FEP-8fcf]: https://w3id.org/fep/8fcf
|
|
2316
|
-
*/
|
|
2317
|
-
syncCollection?: boolean;
|
|
2318
|
-
}
|
|
2319
|
-
/**
|
|
2320
|
-
* Options for {@link InboxContext.forwardActivity} method.
|
|
2321
|
-
* @since 1.0.0
|
|
2322
|
-
*/
|
|
2323
|
-
type ForwardActivityOptions = Omit<SendActivityOptions, "fanout"> & {
|
|
2324
|
-
/**
|
|
2325
|
-
* Whether to skip forwarding the activity if it is not signed, i.e., it has
|
|
2326
|
-
* neither Linked Data Signatures nor Object Integrity Proofs.
|
|
2327
|
-
*
|
|
2328
|
-
* If the activity is not signed, the recipient probably will not trust the
|
|
2329
|
-
* activity. Therefore, it is recommended to skip forwarding the activity
|
|
2330
|
-
* if it is not signed.
|
|
2331
|
-
*/
|
|
2332
|
-
skipIfUnsigned: boolean;
|
|
2333
|
-
};
|
|
2334
|
-
/**
|
|
2335
|
-
* Options for {@link Context.routeActivity} method.
|
|
2336
|
-
* @since 1.3.0
|
|
2337
|
-
*/
|
|
2338
|
-
interface RouteActivityOptions {
|
|
2339
|
-
/**
|
|
2340
|
-
* Whether to skip enqueuing the activity and invoke the listener immediately.
|
|
2341
|
-
* If no inbox queue is available, this option is ignored and the activity
|
|
2342
|
-
* will be always invoked immediately.
|
|
2343
|
-
* @default false
|
|
2344
|
-
*/
|
|
2345
|
-
immediate?: boolean;
|
|
2346
|
-
/**
|
|
2347
|
-
* The document loader for loading remote JSON-LD documents.
|
|
2348
|
-
*/
|
|
2349
|
-
documentLoader?: DocumentLoader;
|
|
2350
|
-
/**
|
|
2351
|
-
* The context loader for loading remote JSON-LD contexts.
|
|
2352
|
-
*/
|
|
2353
|
-
contextLoader?: DocumentLoader;
|
|
2354
|
-
/**
|
|
2355
|
-
* The OpenTelemetry tracer provider. If omitted, the global tracer provider
|
|
2356
|
-
* is used.
|
|
2357
|
-
*/
|
|
2358
|
-
tracerProvider?: TracerProvider;
|
|
2359
|
-
}
|
|
2360
|
-
/**
|
|
2361
|
-
* Options for {@link Context.getSignedKey} method.
|
|
2362
|
-
* @since 1.5.0
|
|
2363
|
-
*/
|
|
2364
|
-
interface GetSignedKeyOptions {
|
|
2365
|
-
/**
|
|
2366
|
-
* The document loader for loading remote JSON-LD documents.
|
|
2367
|
-
*/
|
|
2368
|
-
documentLoader?: DocumentLoader;
|
|
2369
|
-
/**
|
|
2370
|
-
* The context loader for loading remote JSON-LD contexts.
|
|
2371
|
-
*/
|
|
2372
|
-
contextLoader?: DocumentLoader;
|
|
2373
|
-
/**
|
|
2374
|
-
* The OpenTelemetry tracer provider. If omitted, the global tracer provider
|
|
2375
|
-
* is used.
|
|
2376
|
-
*/
|
|
2377
|
-
tracerProvider?: TracerProvider;
|
|
2378
|
-
}
|
|
2379
|
-
/**
|
|
2380
|
-
* A pair of a public key and a private key in various formats.
|
|
2381
|
-
* @since 0.10.0
|
|
2382
|
-
*/
|
|
2383
|
-
interface ActorKeyPair extends CryptoKeyPair {
|
|
2384
|
-
/**
|
|
2385
|
-
* The URI of the public key for {@link CryptographicKey}, which is used for
|
|
2386
|
-
* verifying HTTP Signatures and Linked Data Signatures. Note that this is
|
|
2387
|
-
* the ID of the {@link cryptographicKey}, not of the {@link multikey};
|
|
2388
|
-
* the {@link Multikey} instance has a distinct ID of its own.
|
|
2389
|
-
*/
|
|
2390
|
-
readonly keyId: URL;
|
|
2391
|
-
/**
|
|
2392
|
-
* A {@link CryptographicKey} instance of the public key.
|
|
2393
|
-
*/
|
|
2394
|
-
readonly cryptographicKey: CryptographicKey;
|
|
2395
|
-
/**
|
|
2396
|
-
* A {@link Multikey} instance of the public key.
|
|
2397
|
-
*/
|
|
2398
|
-
readonly multikey: Multikey;
|
|
2399
|
-
}
|
|
2400
|
-
//#endregion
|
|
2401
6
|
//#region src/testing/context.d.ts
|
|
2402
7
|
declare function createRequestContext<TContextData>(args: Partial<RequestContext<TContextData>> & {
|
|
2403
8
|
url: URL;
|