@fedify/fedify 2.2.0-dev.802 → 2.2.0-pr.695.16
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/{builder-DI1wKPDM.mjs → builder-7PVCiLiR.mjs} +7 -57
- package/dist/compat/mod.d.cts +1 -1
- package/dist/compat/mod.d.ts +1 -1
- package/dist/compat/transformers.test.mjs +1 -1
- package/dist/{context-BGrYMSTk.d.ts → context-78ecvxf5.d.ts} +1 -143
- package/dist/{context-CMUd4wy0.d.cts → context-DYDPdoCb.d.cts} +1 -143
- package/dist/{context-Dk_tacqz.mjs → context-Juj6bdHC.mjs} +2 -17
- package/dist/{deno-Cw2dzrO3.mjs → deno-vxcWcxQS.mjs} +1 -1
- package/dist/{docloader-DgqPtQaA.mjs → docloader-D7q0-Xef.mjs} +2 -2
- package/dist/federation/builder.test.mjs +1 -25
- package/dist/federation/handler.test.mjs +8 -369
- package/dist/federation/idempotency.test.mjs +2 -2
- package/dist/federation/inbox.test.mjs +3 -3
- package/dist/federation/middleware.test.mjs +8 -510
- package/dist/federation/mod.cjs +1 -1
- package/dist/federation/mod.d.cts +3 -3
- package/dist/federation/mod.d.ts +3 -3
- package/dist/federation/mod.js +1 -1
- package/dist/federation/send.test.mjs +3 -3
- package/dist/federation/webfinger.test.mjs +2 -2
- package/dist/{http-sBAA3RBV.js → http-D-MhhYUF.js} +1 -1
- package/dist/{http-B8Eh-Nuv.cjs → http-JxF7bG0o.cjs} +1 -1
- package/dist/{http-iFvJsgX5.mjs → http-RZPxDWq5.mjs} +2 -2
- package/dist/inbox-CmYvcSMM.mjs +179 -0
- package/dist/{key-hslhDRFM.mjs → key-CGx_dDkX.mjs} +1 -1
- package/dist/{kv-cache-BJGwpmdO.cjs → kv-cache-C2gdVgvb.cjs} +1 -1
- package/dist/{kv-cache-CPthE3cU.js → kv-cache-D84Mk0fZ.js} +1 -1
- package/dist/{ld-BDJhDECh.mjs → ld-wup-liFO.mjs} +3 -26
- package/dist/{middleware-CERbaJNL.mjs → middleware-BjVx-_bv.mjs} +180 -612
- package/dist/{middleware-gIhAvTk3.cjs → middleware-Bn75dPug.cjs} +365 -718
- package/dist/{middleware-uOgNgCF7.cjs → middleware-CXOVT4Ph.cjs} +1 -1
- package/dist/{middleware-D4erN-QW.js → middleware-RF-sUfTr.js} +368 -716
- package/dist/{middleware-_UvHRcH-.mjs → middleware-wdfeWjRJ.mjs} +1 -1
- package/dist/{mod-BcJHeuv1.d.cts → mod-CEohtXhV.d.cts} +1 -1
- package/dist/{mod-CJXfyw7v.d.ts → mod-CokIUYDr.d.ts} +1 -1
- package/dist/{mod-Cr3f-ACa.d.cts → mod-DoJBjjnO.d.cts} +1 -18
- package/dist/{mod-CR8soWa9.d.ts → mod-DvxszxXC.d.ts} +1 -18
- package/dist/mod.cjs +4 -6
- package/dist/mod.d.cts +5 -5
- package/dist/mod.d.ts +5 -5
- package/dist/mod.js +5 -5
- package/dist/nodeinfo/handler.test.mjs +2 -2
- package/dist/{owner-B4-VE_g8.mjs → owner-q2mUMM9a.mjs} +2 -2
- package/dist/{proof-B6PfWGbc.mjs → proof--CpZsF_p.mjs} +3 -32
- package/dist/{proof-BqB_7rN2.js → proof-CirP9OSd.js} +2 -54
- package/dist/{proof-4H8fV7OE.cjs → proof-_Zyfqyce.cjs} +3 -61
- package/dist/{send-BIh8F_6u.mjs → send-CVJfx7bF.mjs} +2 -2
- package/dist/sig/http.test.mjs +2 -2
- package/dist/sig/key.test.mjs +1 -1
- package/dist/sig/ld.test.mjs +2 -44
- package/dist/sig/mod.cjs +2 -4
- package/dist/sig/mod.d.cts +2 -2
- package/dist/sig/mod.d.ts +2 -2
- package/dist/sig/mod.js +3 -3
- package/dist/sig/owner.test.mjs +1 -1
- package/dist/sig/proof.test.mjs +2 -46
- package/dist/testing/mod.d.mts +1 -149
- package/dist/testing/mod.mjs +2 -2
- package/dist/utils/docloader.test.mjs +2 -2
- package/dist/utils/mod.cjs +1 -1
- package/dist/utils/mod.js +1 -1
- package/package.json +6 -6
- package/dist/activity-listener-Ck3JZ_hR.mjs +0 -40
|
@@ -2,23 +2,12 @@ import "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { n as RouterError, t as Router } from "./router-CrMLXoOr.mjs";
|
|
5
|
-
import { n as version, t as name } from "./deno-
|
|
6
|
-
import { t as
|
|
5
|
+
import { n as version, t as name } from "./deno-vxcWcxQS.mjs";
|
|
6
|
+
import { t as InboxListenerSet } from "./inbox-CmYvcSMM.mjs";
|
|
7
7
|
import { Tombstone, getTypeId } from "@fedify/vocab";
|
|
8
8
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
9
9
|
import { getLogger } from "@logtape/logtape";
|
|
10
10
|
//#region src/federation/builder.ts
|
|
11
|
-
function validateSingleIdentifierVariablePath(path, errorMessage) {
|
|
12
|
-
const operatorMatches = globalThis.Array.from(path.matchAll(/{([+#./;?&]?)([A-Za-z_][A-Za-z0-9_]*)}/g));
|
|
13
|
-
if (operatorMatches.length !== 1 || operatorMatches[0]?.[2] !== "identifier") throw new RouterError(errorMessage);
|
|
14
|
-
if (operatorMatches.some((match) => [
|
|
15
|
-
"?",
|
|
16
|
-
"&",
|
|
17
|
-
"#"
|
|
18
|
-
].includes(match[1]) && match[2] === "identifier")) throw new RouterError(errorMessage);
|
|
19
|
-
const variables = new Router().add(path, "outbox");
|
|
20
|
-
if (variables.size !== 1 || !variables.has("identifier")) throw new RouterError(errorMessage);
|
|
21
|
-
}
|
|
22
11
|
var FederationBuilderImpl = class {
|
|
23
12
|
router;
|
|
24
13
|
actorCallbacks;
|
|
@@ -27,7 +16,6 @@ var FederationBuilderImpl = class {
|
|
|
27
16
|
objectCallbacks;
|
|
28
17
|
objectTypeIds;
|
|
29
18
|
inboxPath;
|
|
30
|
-
outboxPath;
|
|
31
19
|
inboxCallbacks;
|
|
32
20
|
outboxCallbacks;
|
|
33
21
|
followingCallbacks;
|
|
@@ -36,10 +24,7 @@ var FederationBuilderImpl = class {
|
|
|
36
24
|
featuredCallbacks;
|
|
37
25
|
featuredTagsCallbacks;
|
|
38
26
|
inboxListeners;
|
|
39
|
-
outboxListeners;
|
|
40
27
|
inboxErrorHandler;
|
|
41
|
-
outboxListenerErrorHandler;
|
|
42
|
-
outboxAuthorizePredicate;
|
|
43
28
|
sharedInboxKeyDispatcher;
|
|
44
29
|
unverifiedActivityHandler;
|
|
45
30
|
outboxPermanentFailureHandler;
|
|
@@ -58,7 +43,7 @@ var FederationBuilderImpl = class {
|
|
|
58
43
|
this.collectionTypeIds = {};
|
|
59
44
|
}
|
|
60
45
|
async build(options) {
|
|
61
|
-
const { FederationImpl } = await import("./middleware-
|
|
46
|
+
const { FederationImpl } = await import("./middleware-wdfeWjRJ.mjs");
|
|
62
47
|
const f = new FederationImpl(options);
|
|
63
48
|
const trailingSlashInsensitiveValue = f.router.trailingSlashInsensitive;
|
|
64
49
|
f.router = this.router.clone();
|
|
@@ -70,7 +55,6 @@ var FederationBuilderImpl = class {
|
|
|
70
55
|
f.objectCallbacks = { ...this.objectCallbacks };
|
|
71
56
|
f.objectTypeIds = { ...this.objectTypeIds };
|
|
72
57
|
f.inboxPath = this.inboxPath;
|
|
73
|
-
f.outboxPath = this.outboxPath;
|
|
74
58
|
f.inboxCallbacks = this.inboxCallbacks == null ? void 0 : { ...this.inboxCallbacks };
|
|
75
59
|
f.outboxCallbacks = this.outboxCallbacks == null ? void 0 : { ...this.outboxCallbacks };
|
|
76
60
|
f.followingCallbacks = this.followingCallbacks == null ? void 0 : { ...this.followingCallbacks };
|
|
@@ -79,10 +63,7 @@ var FederationBuilderImpl = class {
|
|
|
79
63
|
f.featuredCallbacks = this.featuredCallbacks == null ? void 0 : { ...this.featuredCallbacks };
|
|
80
64
|
f.featuredTagsCallbacks = this.featuredTagsCallbacks == null ? void 0 : { ...this.featuredTagsCallbacks };
|
|
81
65
|
f.inboxListeners = this.inboxListeners?.clone();
|
|
82
|
-
f.outboxListeners = this.outboxListeners?.clone();
|
|
83
66
|
f.inboxErrorHandler = this.inboxErrorHandler;
|
|
84
|
-
f.outboxListenerErrorHandler = this.outboxListenerErrorHandler;
|
|
85
|
-
f.outboxAuthorizePredicate = this.outboxAuthorizePredicate;
|
|
86
67
|
f.sharedInboxKeyDispatcher = this.sharedInboxKeyDispatcher;
|
|
87
68
|
f.unverifiedActivityHandler = this.unverifiedActivityHandler;
|
|
88
69
|
f.outboxPermanentFailureHandler = this.outboxPermanentFailureHandler;
|
|
@@ -282,14 +263,9 @@ var FederationBuilderImpl = class {
|
|
|
282
263
|
return setters;
|
|
283
264
|
}
|
|
284
265
|
setOutboxDispatcher(path, dispatcher) {
|
|
285
|
-
if (this.
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
} else {
|
|
289
|
-
validateSingleIdentifierVariablePath(path, "Path for outbox dispatcher must have one variable: {identifier}");
|
|
290
|
-
this.router.add(path, "outbox");
|
|
291
|
-
this.outboxPath = path;
|
|
292
|
-
}
|
|
266
|
+
if (this.router.has("outbox")) throw new RouterError("Outbox dispatcher already set.");
|
|
267
|
+
const variables = this.router.add(path, "outbox");
|
|
268
|
+
if (variables.size !== 1 || !variables.has("identifier")) throw new RouterError("Path for outbox dispatcher must have one variable: {identifier}");
|
|
293
269
|
const callbacks = { dispatcher };
|
|
294
270
|
this.outboxCallbacks = callbacks;
|
|
295
271
|
const setters = {
|
|
@@ -312,32 +288,6 @@ var FederationBuilderImpl = class {
|
|
|
312
288
|
};
|
|
313
289
|
return setters;
|
|
314
290
|
}
|
|
315
|
-
setOutboxListeners(outboxPath) {
|
|
316
|
-
if (this.outboxListeners != null) throw new RouterError("Outbox listeners already set.");
|
|
317
|
-
if (this.router.has("outbox")) {
|
|
318
|
-
if (this.outboxPath !== outboxPath) throw new RouterError("Outbox listener path must match outbox dispatcher path.");
|
|
319
|
-
} else {
|
|
320
|
-
validateSingleIdentifierVariablePath(outboxPath, "Path for outbox must have one variable: {identifier}");
|
|
321
|
-
this.router.add(outboxPath, "outbox");
|
|
322
|
-
this.outboxPath = outboxPath;
|
|
323
|
-
}
|
|
324
|
-
const listeners = this.outboxListeners = new ActivityListenerSet();
|
|
325
|
-
const setters = {
|
|
326
|
-
on(type, listener) {
|
|
327
|
-
listeners.add(type, listener);
|
|
328
|
-
return setters;
|
|
329
|
-
},
|
|
330
|
-
onError: (handler) => {
|
|
331
|
-
this.outboxListenerErrorHandler = handler;
|
|
332
|
-
return setters;
|
|
333
|
-
},
|
|
334
|
-
authorize: (predicate) => {
|
|
335
|
-
this.outboxAuthorizePredicate = predicate;
|
|
336
|
-
return setters;
|
|
337
|
-
}
|
|
338
|
-
};
|
|
339
|
-
return setters;
|
|
340
|
-
}
|
|
341
291
|
setFollowingDispatcher(path, dispatcher) {
|
|
342
292
|
if (this.router.has("following")) throw new RouterError("Following collection dispatcher already set.");
|
|
343
293
|
const variables = this.router.add(path, "following");
|
|
@@ -480,7 +430,7 @@ var FederationBuilderImpl = class {
|
|
|
480
430
|
if (sharedInboxPath != null) {
|
|
481
431
|
if (this.router.add(sharedInboxPath, "sharedInbox").size !== 0) throw new RouterError("Path for shared inbox must have no variables.");
|
|
482
432
|
}
|
|
483
|
-
const listeners = this.inboxListeners = new
|
|
433
|
+
const listeners = this.inboxListeners = new InboxListenerSet();
|
|
484
434
|
const setters = {
|
|
485
435
|
on(type, listener) {
|
|
486
436
|
listeners.add(type, listener);
|
package/dist/compat/mod.d.cts
CHANGED
package/dist/compat/mod.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import {
|
|
3
|
+
import { n as Context, wt as ActivityTransformer } from "../context-78ecvxf5.js";
|
|
4
4
|
import { Activity } from "@fedify/vocab";
|
|
5
5
|
|
|
6
6
|
//#region src/compat/transformers.d.ts
|
|
@@ -5,7 +5,7 @@ import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
|
5
5
|
import { t as assertInstanceOf } from "../assert_instance_of-C4Ri6VuN.mjs";
|
|
6
6
|
import { t as assert } from "../assert-ddO5KLpe.mjs";
|
|
7
7
|
import { t as MemoryKvStore } from "../kv-tL2TOE9X.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { _ as autoIdAssigner, g as actorDehydrator, n as FederationImpl } from "../middleware-BjVx-_bv.mjs";
|
|
9
9
|
import { test } from "@fedify/fixture";
|
|
10
10
|
import { Follow, Person } from "@fedify/vocab";
|
|
11
11
|
//#region src/compat/transformers.test.ts
|
|
@@ -212,16 +212,6 @@ type CollectionCursor<TContext extends Context<TContextData>, TContextData, TFil
|
|
|
212
212
|
*/
|
|
213
213
|
type InboxListener<TContextData, TActivity extends Activity> = (context: InboxContext<TContextData>, activity: TActivity) => void | Promise<void>;
|
|
214
214
|
/**
|
|
215
|
-
* A callback that listens for activities in an outbox.
|
|
216
|
-
*
|
|
217
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
218
|
-
* @template TActivity The type of activity to listen for.
|
|
219
|
-
* @param context The outbox context.
|
|
220
|
-
* @param activity The activity that was received.
|
|
221
|
-
* @since 2.2.0
|
|
222
|
-
*/
|
|
223
|
-
type OutboxListener<TContextData, TActivity extends Activity> = (context: OutboxContext<TContextData>, activity: TActivity) => void | Promise<void>;
|
|
224
|
-
/**
|
|
225
215
|
* The reason why an incoming activity could not be verified.
|
|
226
216
|
*
|
|
227
217
|
* Unlike inbox listeners registered through {@link InboxListenerSetters.on},
|
|
@@ -252,15 +242,6 @@ type UnverifiedActivityHandler<TContextData> = (context: RequestContext<TContext
|
|
|
252
242
|
*/
|
|
253
243
|
type InboxErrorHandler<TContextData> = (context: Context<TContextData>, error: Error) => void | Promise<void>;
|
|
254
244
|
/**
|
|
255
|
-
* A callback that handles errors in an outbox listener.
|
|
256
|
-
*
|
|
257
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
258
|
-
* @param context The outbox context.
|
|
259
|
-
* @param error The error that occurred.
|
|
260
|
-
* @since 2.2.0
|
|
261
|
-
*/
|
|
262
|
-
type OutboxListenerErrorHandler<TContextData> = (context: OutboxContext<TContextData>, error: Error) => void | Promise<void>;
|
|
263
|
-
/**
|
|
264
245
|
* A callback that dispatches the key pair for the authenticated document loader
|
|
265
246
|
* of the {@link Context} passed to the shared inbox listener.
|
|
266
247
|
*
|
|
@@ -1070,32 +1051,6 @@ interface Federatable<TContextData> {
|
|
|
1070
1051
|
*/
|
|
1071
1052
|
setOutboxDispatcher(path: `${string}${Rfc6570Expression<"identifier">}${string}`, dispatcher: CollectionDispatcher<Activity, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
|
|
1072
1053
|
/**
|
|
1073
|
-
* Assigns the URL path for the outbox and starts setting outbox listeners.
|
|
1074
|
-
*
|
|
1075
|
-
* @example
|
|
1076
|
-
* ``` typescript
|
|
1077
|
-
* federation
|
|
1078
|
-
* .setOutboxListeners("/users/{identifier}/outbox")
|
|
1079
|
-
* .on(Activity, async (ctx, activity) => {
|
|
1080
|
-
* await ctx.sendActivity({ identifier: ctx.identifier }, "followers", activity);
|
|
1081
|
-
* })
|
|
1082
|
-
* .authorize(async (ctx, identifier) => {
|
|
1083
|
-
* return ctx.request.headers.get("authorization") === `Bearer ${identifier}`;
|
|
1084
|
-
* });
|
|
1085
|
-
* ```
|
|
1086
|
-
*
|
|
1087
|
-
* @param outboxPath The URI path pattern for the outbox. The syntax is based
|
|
1088
|
-
* on URI Template
|
|
1089
|
-
* ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The
|
|
1090
|
-
* path must have one variable: `{identifier}`. If an
|
|
1091
|
-
* outbox dispatcher is configured, this path must match
|
|
1092
|
-
* the outbox dispatcher path.
|
|
1093
|
-
* @returns An object to register outbox listeners.
|
|
1094
|
-
* @throws {RouterError} Thrown if the path pattern is invalid.
|
|
1095
|
-
* @since 2.2.0
|
|
1096
|
-
*/
|
|
1097
|
-
setOutboxListeners(outboxPath: `${string}${Rfc6570Expression<"identifier">}${string}`): OutboxListenerSetters<TContextData>;
|
|
1098
|
-
/**
|
|
1099
1054
|
* Registers a following collection dispatcher.
|
|
1100
1055
|
* @param path The URI path pattern for the following collection. The syntax
|
|
1101
1056
|
* is based on URI Template
|
|
@@ -1719,38 +1674,6 @@ type IdempotencyStrategy = "global" | "per-origin" | "per-inbox";
|
|
|
1719
1674
|
*/
|
|
1720
1675
|
type IdempotencyKeyCallback<TContextData> = (ctx: InboxContext<TContextData>, activity: Activity) => string | null | Promise<string | null>;
|
|
1721
1676
|
/**
|
|
1722
|
-
* Registry for outbox listeners for different activity types.
|
|
1723
|
-
* @since 2.2.0
|
|
1724
|
-
*/
|
|
1725
|
-
interface OutboxListenerSetters<TContextData> {
|
|
1726
|
-
/**
|
|
1727
|
-
* Registers a listener for a specific incoming activity type.
|
|
1728
|
-
*
|
|
1729
|
-
* @param type A subclass of {@link Activity} to listen to.
|
|
1730
|
-
* @param listener A callback to handle an incoming activity.
|
|
1731
|
-
* @returns The setters object so that settings can be chained.
|
|
1732
|
-
* @since 2.2.0
|
|
1733
|
-
*/
|
|
1734
|
-
on<TActivity extends Activity>(type: new (...args: any[]) => TActivity, listener: OutboxListener<TContextData, TActivity>): OutboxListenerSetters<TContextData>;
|
|
1735
|
-
/**
|
|
1736
|
-
* Registers an error handler for outbox listeners. Any exceptions thrown
|
|
1737
|
-
* from the listeners are caught and passed to this handler.
|
|
1738
|
-
*
|
|
1739
|
-
* @param handler A callback to handle an error.
|
|
1740
|
-
* @returns The setters object so that settings can be chained.
|
|
1741
|
-
* @since 2.2.0
|
|
1742
|
-
*/
|
|
1743
|
-
onError(handler: OutboxListenerErrorHandler<TContextData>): OutboxListenerSetters<TContextData>;
|
|
1744
|
-
/**
|
|
1745
|
-
* Registers a callback to authorize POST requests to the outbox.
|
|
1746
|
-
*
|
|
1747
|
-
* @param predicate A callback to authorize the request.
|
|
1748
|
-
* @returns The setters object so that settings can be chained.
|
|
1749
|
-
* @since 2.2.0
|
|
1750
|
-
*/
|
|
1751
|
-
authorize(predicate: AuthorizePredicate<TContextData>): OutboxListenerSetters<TContextData>;
|
|
1752
|
-
}
|
|
1753
|
-
/**
|
|
1754
1677
|
* Registry for inbox listeners for different activity types.
|
|
1755
1678
|
*/
|
|
1756
1679
|
interface InboxListenerSetters<TContextData> {
|
|
@@ -2522,71 +2445,6 @@ interface InboxContext<TContextData> extends Context<TContextData> {
|
|
|
2522
2445
|
}, recipients: "followers", options?: ForwardActivityOptions): Promise<void>;
|
|
2523
2446
|
}
|
|
2524
2447
|
/**
|
|
2525
|
-
* A context for outbox listeners.
|
|
2526
|
-
* @since 2.2.0
|
|
2527
|
-
*/
|
|
2528
|
-
interface OutboxContext<TContextData> extends Context<TContextData> {
|
|
2529
|
-
/**
|
|
2530
|
-
* The identifier of the actor whose outbox received the POST.
|
|
2531
|
-
* @since 2.2.0
|
|
2532
|
-
*/
|
|
2533
|
-
readonly identifier: string;
|
|
2534
|
-
/**
|
|
2535
|
-
* Indicates whether the posted activity has been delivered during the
|
|
2536
|
-
* current outbox listener invocation.
|
|
2537
|
-
* @returns `true` if the posted activity has been delivered; `false`
|
|
2538
|
-
* otherwise.
|
|
2539
|
-
* @since 2.2.0
|
|
2540
|
-
*/
|
|
2541
|
-
hasDeliveredActivity(): boolean;
|
|
2542
|
-
/**
|
|
2543
|
-
* Forwards a posted activity to the recipients' inboxes without
|
|
2544
|
-
* re-serializing the original payload. The forwarded activity will be
|
|
2545
|
-
* signed in HTTP Signatures by the forwarder, but its payload will not be
|
|
2546
|
-
* modified, i.e., Linked Data Signatures and Object Integrity Proofs will
|
|
2547
|
-
* not be added. Therefore, if the posted activity is not signed (i.e., it
|
|
2548
|
-
* has neither Linked Data Signatures nor Object Integrity Proofs), the
|
|
2549
|
-
* recipients probably will not trust the activity.
|
|
2550
|
-
* @param forwarder The forwarder's identifier or the forwarder's username
|
|
2551
|
-
* or the forwarder's key pair(s).
|
|
2552
|
-
* @param recipients The recipients of the activity.
|
|
2553
|
-
* @param options Options for forwarding the activity.
|
|
2554
|
-
* @since 2.2.0
|
|
2555
|
-
*/
|
|
2556
|
-
forwardActivity(forwarder: SenderKeyPair | SenderKeyPair[] | {
|
|
2557
|
-
identifier: string;
|
|
2558
|
-
} | {
|
|
2559
|
-
username: string;
|
|
2560
|
-
}, recipients: Recipient | Recipient[], options?: ForwardActivityOptions): Promise<void>;
|
|
2561
|
-
/**
|
|
2562
|
-
* Forwards a posted activity to the recipients' inboxes without
|
|
2563
|
-
* re-serializing the original payload. The forwarded activity will be
|
|
2564
|
-
* signed in HTTP Signatures by the forwarder, but its payload will not be
|
|
2565
|
-
* modified, i.e., Linked Data Signatures and Object Integrity Proofs will
|
|
2566
|
-
* not be added. Therefore, if the posted activity is not signed (i.e., it
|
|
2567
|
-
* has neither Linked Data Signatures nor Object Integrity Proofs), the
|
|
2568
|
-
* recipients probably will not trust the activity.
|
|
2569
|
-
* @param forwarder The forwarder's identifier or the forwarder's username.
|
|
2570
|
-
* @param recipients In this case, it must be `"followers"`.
|
|
2571
|
-
* @param options Options for forwarding the activity.
|
|
2572
|
-
* @since 2.2.0
|
|
2573
|
-
*/
|
|
2574
|
-
forwardActivity(forwarder: {
|
|
2575
|
-
identifier: string;
|
|
2576
|
-
} | {
|
|
2577
|
-
username: string;
|
|
2578
|
-
}, recipients: "followers", options?: ForwardActivityOptions): Promise<void>;
|
|
2579
|
-
/**
|
|
2580
|
-
* Creates a new context with the same properties as this one,
|
|
2581
|
-
* but with the given data.
|
|
2582
|
-
* @param data The new data to associate with the context.
|
|
2583
|
-
* @returns A new context with the same properties as this one,
|
|
2584
|
-
* but with the given data.
|
|
2585
|
-
* @since 2.2.0
|
|
2586
|
-
*/
|
|
2587
|
-
clone(data: TContextData): OutboxContext<TContextData>;
|
|
2588
|
-
}
|
|
2589
|
-
/**
|
|
2590
2448
|
* A result of parsing an URI.
|
|
2591
2449
|
*/
|
|
2592
2450
|
type ParseUriResult = {
|
|
@@ -2786,4 +2644,4 @@ interface ActorKeyPair extends CryptoKeyPair {
|
|
|
2786
2644
|
readonly multikey: Multikey;
|
|
2787
2645
|
}
|
|
2788
2646
|
//#endregion
|
|
2789
|
-
export {
|
|
2647
|
+
export { ActorHandleMapper as $, FederationQueueOptions as A, RouterOptions as B, IdempotencyStrategy as C, digest as Ct, Rfc6570Expression as D, ObjectCallbackSetters as E, createExponentialBackoffPolicy as F, InProcessMessageQueue as G, RespondWithObjectOptions as H, Message as I, MessageQueueEnqueueOptions as J, InProcessMessageQueueOptions as K, createFederationBuilder as L, CreateExponentialBackoffPolicyOptions as M, RetryContext as N, FederationKvPrefixes as O, RetryPolicy as P, ActorDispatcher as Q, Router as R, IdempotencyKeyCallback as S, buildCollectionSynchronizationHeader as St, InboxListenerSetters as T, respondWithObject as U, RouterRouteResult as V, respondWithObjectIfAcceptable as W, ParallelMessageQueue as X, MessageQueueListenOptions as Y, ActorAliasMapper as Z, Federation as _, UnverifiedActivityReason as _t, GetSignedKeyOptions as a, CustomCollectionCounter as at, FederationOptions as b, SenderKeyPair as bt, RequestContext as c, InboxErrorHandler as ct, SendActivityOptionsForCollection as d, ObjectAuthorizePredicate as dt, ActorKeyPairsDispatcher as et, ActorCallbackSetters as f, ObjectDispatcher as ft, Federatable as g, UnverifiedActivityHandler as gt, CustomCollectionCallbackSetters as h, SharedInboxKeyDispatcher as ht, GetActorOptions as i, CollectionDispatcher as it, createFederation as j, FederationOrigin as k, RouteActivityOptions as l, InboxListener as lt, ConstructorWithTypeId as m, OutboxPermanentFailureHandler as mt, Context as n, CollectionCounter as nt, InboxContext as o, CustomCollectionCursor as ot, CollectionCallbackSetters as p, OutboxErrorHandler as pt, MessageQueue as q, ForwardActivityOptions as r, CollectionCursor as rt, ParseUriResult as s, CustomCollectionDispatcher as st, ActorKeyPair as t, AuthorizePredicate as tt, SendActivityOptions as u, NodeInfoDispatcher as ut, FederationBuilder as v, WebFingerLinksDispatcher as vt, InboxChallengePolicy as w, ActivityTransformer as wt, FederationStartQueueOptions as x, PageItems as xt, FederationFetchOptions as y, SendActivityError as yt, RouterError as z };
|
|
@@ -210,16 +210,6 @@ type CollectionCursor<TContext extends Context<TContextData>, TContextData, TFil
|
|
|
210
210
|
*/
|
|
211
211
|
type InboxListener<TContextData, TActivity extends Activity> = (context: InboxContext<TContextData>, activity: TActivity) => void | Promise<void>;
|
|
212
212
|
/**
|
|
213
|
-
* A callback that listens for activities in an outbox.
|
|
214
|
-
*
|
|
215
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
216
|
-
* @template TActivity The type of activity to listen for.
|
|
217
|
-
* @param context The outbox context.
|
|
218
|
-
* @param activity The activity that was received.
|
|
219
|
-
* @since 2.2.0
|
|
220
|
-
*/
|
|
221
|
-
type OutboxListener<TContextData, TActivity extends Activity> = (context: OutboxContext<TContextData>, activity: TActivity) => void | Promise<void>;
|
|
222
|
-
/**
|
|
223
213
|
* The reason why an incoming activity could not be verified.
|
|
224
214
|
*
|
|
225
215
|
* Unlike inbox listeners registered through {@link InboxListenerSetters.on},
|
|
@@ -250,15 +240,6 @@ type UnverifiedActivityHandler<TContextData> = (context: RequestContext<TContext
|
|
|
250
240
|
*/
|
|
251
241
|
type InboxErrorHandler<TContextData> = (context: Context<TContextData>, error: Error) => void | Promise<void>;
|
|
252
242
|
/**
|
|
253
|
-
* A callback that handles errors in an outbox listener.
|
|
254
|
-
*
|
|
255
|
-
* @template TContextData The context data to pass to the {@link Context}.
|
|
256
|
-
* @param context The outbox context.
|
|
257
|
-
* @param error The error that occurred.
|
|
258
|
-
* @since 2.2.0
|
|
259
|
-
*/
|
|
260
|
-
type OutboxListenerErrorHandler<TContextData> = (context: OutboxContext<TContextData>, error: Error) => void | Promise<void>;
|
|
261
|
-
/**
|
|
262
243
|
* A callback that dispatches the key pair for the authenticated document loader
|
|
263
244
|
* of the {@link Context} passed to the shared inbox listener.
|
|
264
245
|
*
|
|
@@ -1068,32 +1049,6 @@ interface Federatable<TContextData> {
|
|
|
1068
1049
|
*/
|
|
1069
1050
|
setOutboxDispatcher(path: `${string}${Rfc6570Expression<"identifier">}${string}`, dispatcher: CollectionDispatcher<Activity, RequestContext<TContextData>, TContextData, void>): CollectionCallbackSetters<RequestContext<TContextData>, TContextData, void>;
|
|
1070
1051
|
/**
|
|
1071
|
-
* Assigns the URL path for the outbox and starts setting outbox listeners.
|
|
1072
|
-
*
|
|
1073
|
-
* @example
|
|
1074
|
-
* ``` typescript
|
|
1075
|
-
* federation
|
|
1076
|
-
* .setOutboxListeners("/users/{identifier}/outbox")
|
|
1077
|
-
* .on(Activity, async (ctx, activity) => {
|
|
1078
|
-
* await ctx.sendActivity({ identifier: ctx.identifier }, "followers", activity);
|
|
1079
|
-
* })
|
|
1080
|
-
* .authorize(async (ctx, identifier) => {
|
|
1081
|
-
* return ctx.request.headers.get("authorization") === `Bearer ${identifier}`;
|
|
1082
|
-
* });
|
|
1083
|
-
* ```
|
|
1084
|
-
*
|
|
1085
|
-
* @param outboxPath The URI path pattern for the outbox. The syntax is based
|
|
1086
|
-
* on URI Template
|
|
1087
|
-
* ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The
|
|
1088
|
-
* path must have one variable: `{identifier}`. If an
|
|
1089
|
-
* outbox dispatcher is configured, this path must match
|
|
1090
|
-
* the outbox dispatcher path.
|
|
1091
|
-
* @returns An object to register outbox listeners.
|
|
1092
|
-
* @throws {RouterError} Thrown if the path pattern is invalid.
|
|
1093
|
-
* @since 2.2.0
|
|
1094
|
-
*/
|
|
1095
|
-
setOutboxListeners(outboxPath: `${string}${Rfc6570Expression<"identifier">}${string}`): OutboxListenerSetters<TContextData>;
|
|
1096
|
-
/**
|
|
1097
1052
|
* Registers a following collection dispatcher.
|
|
1098
1053
|
* @param path The URI path pattern for the following collection. The syntax
|
|
1099
1054
|
* is based on URI Template
|
|
@@ -1717,38 +1672,6 @@ type IdempotencyStrategy = "global" | "per-origin" | "per-inbox";
|
|
|
1717
1672
|
*/
|
|
1718
1673
|
type IdempotencyKeyCallback<TContextData> = (ctx: InboxContext<TContextData>, activity: Activity) => string | null | Promise<string | null>;
|
|
1719
1674
|
/**
|
|
1720
|
-
* Registry for outbox listeners for different activity types.
|
|
1721
|
-
* @since 2.2.0
|
|
1722
|
-
*/
|
|
1723
|
-
interface OutboxListenerSetters<TContextData> {
|
|
1724
|
-
/**
|
|
1725
|
-
* Registers a listener for a specific incoming activity type.
|
|
1726
|
-
*
|
|
1727
|
-
* @param type A subclass of {@link Activity} to listen to.
|
|
1728
|
-
* @param listener A callback to handle an incoming activity.
|
|
1729
|
-
* @returns The setters object so that settings can be chained.
|
|
1730
|
-
* @since 2.2.0
|
|
1731
|
-
*/
|
|
1732
|
-
on<TActivity extends Activity>(type: new (...args: any[]) => TActivity, listener: OutboxListener<TContextData, TActivity>): OutboxListenerSetters<TContextData>;
|
|
1733
|
-
/**
|
|
1734
|
-
* Registers an error handler for outbox listeners. Any exceptions thrown
|
|
1735
|
-
* from the listeners are caught and passed to this handler.
|
|
1736
|
-
*
|
|
1737
|
-
* @param handler A callback to handle an error.
|
|
1738
|
-
* @returns The setters object so that settings can be chained.
|
|
1739
|
-
* @since 2.2.0
|
|
1740
|
-
*/
|
|
1741
|
-
onError(handler: OutboxListenerErrorHandler<TContextData>): OutboxListenerSetters<TContextData>;
|
|
1742
|
-
/**
|
|
1743
|
-
* Registers a callback to authorize POST requests to the outbox.
|
|
1744
|
-
*
|
|
1745
|
-
* @param predicate A callback to authorize the request.
|
|
1746
|
-
* @returns The setters object so that settings can be chained.
|
|
1747
|
-
* @since 2.2.0
|
|
1748
|
-
*/
|
|
1749
|
-
authorize(predicate: AuthorizePredicate<TContextData>): OutboxListenerSetters<TContextData>;
|
|
1750
|
-
}
|
|
1751
|
-
/**
|
|
1752
1675
|
* Registry for inbox listeners for different activity types.
|
|
1753
1676
|
*/
|
|
1754
1677
|
interface InboxListenerSetters<TContextData> {
|
|
@@ -2520,71 +2443,6 @@ interface InboxContext<TContextData> extends Context<TContextData> {
|
|
|
2520
2443
|
}, recipients: "followers", options?: ForwardActivityOptions): Promise<void>;
|
|
2521
2444
|
}
|
|
2522
2445
|
/**
|
|
2523
|
-
* A context for outbox listeners.
|
|
2524
|
-
* @since 2.2.0
|
|
2525
|
-
*/
|
|
2526
|
-
interface OutboxContext<TContextData> extends Context<TContextData> {
|
|
2527
|
-
/**
|
|
2528
|
-
* The identifier of the actor whose outbox received the POST.
|
|
2529
|
-
* @since 2.2.0
|
|
2530
|
-
*/
|
|
2531
|
-
readonly identifier: string;
|
|
2532
|
-
/**
|
|
2533
|
-
* Indicates whether the posted activity has been delivered during the
|
|
2534
|
-
* current outbox listener invocation.
|
|
2535
|
-
* @returns `true` if the posted activity has been delivered; `false`
|
|
2536
|
-
* otherwise.
|
|
2537
|
-
* @since 2.2.0
|
|
2538
|
-
*/
|
|
2539
|
-
hasDeliveredActivity(): boolean;
|
|
2540
|
-
/**
|
|
2541
|
-
* Forwards a posted activity to the recipients' inboxes without
|
|
2542
|
-
* re-serializing the original payload. The forwarded activity will be
|
|
2543
|
-
* signed in HTTP Signatures by the forwarder, but its payload will not be
|
|
2544
|
-
* modified, i.e., Linked Data Signatures and Object Integrity Proofs will
|
|
2545
|
-
* not be added. Therefore, if the posted activity is not signed (i.e., it
|
|
2546
|
-
* has neither Linked Data Signatures nor Object Integrity Proofs), the
|
|
2547
|
-
* recipients probably will not trust the activity.
|
|
2548
|
-
* @param forwarder The forwarder's identifier or the forwarder's username
|
|
2549
|
-
* or the forwarder's key pair(s).
|
|
2550
|
-
* @param recipients The recipients of the activity.
|
|
2551
|
-
* @param options Options for forwarding the activity.
|
|
2552
|
-
* @since 2.2.0
|
|
2553
|
-
*/
|
|
2554
|
-
forwardActivity(forwarder: SenderKeyPair | SenderKeyPair[] | {
|
|
2555
|
-
identifier: string;
|
|
2556
|
-
} | {
|
|
2557
|
-
username: string;
|
|
2558
|
-
}, recipients: Recipient | Recipient[], options?: ForwardActivityOptions): Promise<void>;
|
|
2559
|
-
/**
|
|
2560
|
-
* Forwards a posted activity to the recipients' inboxes without
|
|
2561
|
-
* re-serializing the original payload. The forwarded activity will be
|
|
2562
|
-
* signed in HTTP Signatures by the forwarder, but its payload will not be
|
|
2563
|
-
* modified, i.e., Linked Data Signatures and Object Integrity Proofs will
|
|
2564
|
-
* not be added. Therefore, if the posted activity is not signed (i.e., it
|
|
2565
|
-
* has neither Linked Data Signatures nor Object Integrity Proofs), the
|
|
2566
|
-
* recipients probably will not trust the activity.
|
|
2567
|
-
* @param forwarder The forwarder's identifier or the forwarder's username.
|
|
2568
|
-
* @param recipients In this case, it must be `"followers"`.
|
|
2569
|
-
* @param options Options for forwarding the activity.
|
|
2570
|
-
* @since 2.2.0
|
|
2571
|
-
*/
|
|
2572
|
-
forwardActivity(forwarder: {
|
|
2573
|
-
identifier: string;
|
|
2574
|
-
} | {
|
|
2575
|
-
username: string;
|
|
2576
|
-
}, recipients: "followers", options?: ForwardActivityOptions): Promise<void>;
|
|
2577
|
-
/**
|
|
2578
|
-
* Creates a new context with the same properties as this one,
|
|
2579
|
-
* but with the given data.
|
|
2580
|
-
* @param data The new data to associate with the context.
|
|
2581
|
-
* @returns A new context with the same properties as this one,
|
|
2582
|
-
* but with the given data.
|
|
2583
|
-
* @since 2.2.0
|
|
2584
|
-
*/
|
|
2585
|
-
clone(data: TContextData): OutboxContext<TContextData>;
|
|
2586
|
-
}
|
|
2587
|
-
/**
|
|
2588
2446
|
* A result of parsing an URI.
|
|
2589
2447
|
*/
|
|
2590
2448
|
type ParseUriResult = {
|
|
@@ -2784,4 +2642,4 @@ interface ActorKeyPair extends CryptoKeyPair {
|
|
|
2784
2642
|
readonly multikey: Multikey;
|
|
2785
2643
|
}
|
|
2786
2644
|
//#endregion
|
|
2787
|
-
export {
|
|
2645
|
+
export { ActorHandleMapper as $, FederationQueueOptions as A, RouterOptions as B, IdempotencyStrategy as C, digest as Ct, Rfc6570Expression as D, ObjectCallbackSetters as E, createExponentialBackoffPolicy as F, InProcessMessageQueue as G, RespondWithObjectOptions as H, Message as I, MessageQueueEnqueueOptions as J, InProcessMessageQueueOptions as K, createFederationBuilder as L, CreateExponentialBackoffPolicyOptions as M, RetryContext as N, FederationKvPrefixes as O, RetryPolicy as P, ActorDispatcher as Q, Router as R, IdempotencyKeyCallback as S, buildCollectionSynchronizationHeader as St, InboxListenerSetters as T, respondWithObject as U, RouterRouteResult as V, respondWithObjectIfAcceptable as W, ParallelMessageQueue as X, MessageQueueListenOptions as Y, ActorAliasMapper as Z, Federation as _, UnverifiedActivityReason as _t, GetSignedKeyOptions as a, CustomCollectionCounter as at, FederationOptions as b, SenderKeyPair as bt, RequestContext as c, InboxErrorHandler as ct, SendActivityOptionsForCollection as d, ObjectAuthorizePredicate as dt, ActorKeyPairsDispatcher as et, ActorCallbackSetters as f, ObjectDispatcher as ft, Federatable as g, UnverifiedActivityHandler as gt, CustomCollectionCallbackSetters as h, SharedInboxKeyDispatcher as ht, GetActorOptions as i, CollectionDispatcher as it, createFederation as j, FederationOrigin as k, RouteActivityOptions as l, InboxListener as lt, ConstructorWithTypeId as m, OutboxPermanentFailureHandler as mt, Context as n, CollectionCounter as nt, InboxContext as o, CustomCollectionCursor as ot, CollectionCallbackSetters as p, OutboxErrorHandler as pt, MessageQueue as q, ForwardActivityOptions as r, CollectionCursor as rt, ParseUriResult as s, CustomCollectionDispatcher as st, ActorKeyPair as t, AuthorizePredicate as tt, SendActivityOptions as u, NodeInfoDispatcher as ut, FederationBuilder as v, WebFingerLinksDispatcher as vt, InboxChallengePolicy as w, ActivityTransformer as wt, FederationStartQueueOptions as x, PageItems as xt, FederationFetchOptions as y, SendActivityError as yt, RouterError as z };
|
|
@@ -96,25 +96,10 @@ function createInboxContext(args) {
|
|
|
96
96
|
data
|
|
97
97
|
})),
|
|
98
98
|
recipient: args.recipient ?? null,
|
|
99
|
-
forwardActivity: args.forwardActivity ?? ((
|
|
99
|
+
forwardActivity: args.forwardActivity ?? ((_params) => {
|
|
100
100
|
throw new Error("Not implemented");
|
|
101
101
|
})
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
|
-
function createOutboxContext(args) {
|
|
105
|
-
const forwardActivity = args.forwardActivity ?? ((_forwarder, _recipients, _options) => {
|
|
106
|
-
throw new Error("Not implemented");
|
|
107
|
-
});
|
|
108
|
-
return {
|
|
109
|
-
...createContext(args),
|
|
110
|
-
clone: args.clone ?? ((data) => createOutboxContext({
|
|
111
|
-
...args,
|
|
112
|
-
data
|
|
113
|
-
})),
|
|
114
|
-
identifier: args.identifier,
|
|
115
|
-
hasDeliveredActivity: args.hasDeliveredActivity ?? (() => false),
|
|
116
|
-
forwardActivity
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
104
|
//#endregion
|
|
120
|
-
export {
|
|
105
|
+
export { createRequestContext as n, createInboxContext as t };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { o as validateCryptoKey } from "./key-
|
|
5
|
-
import { n as doubleKnock } from "./http-
|
|
4
|
+
import { o as validateCryptoKey } from "./key-CGx_dDkX.mjs";
|
|
5
|
+
import { n as doubleKnock } from "./http-RZPxDWq5.mjs";
|
|
6
6
|
import { curry } from "es-toolkit";
|
|
7
7
|
import { UrlError, createActivityPubRequest, getRemoteDocument, logRequest, validatePublicUrl } from "@fedify/vocab-runtime";
|
|
8
8
|
import { getLogger } from "@logtape/logtape";
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as RouterError } from "../router-CrMLXoOr.mjs";
|
|
5
4
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
6
5
|
import { a as assertExists } from "../std__assert-Duiq_YC9.mjs";
|
|
7
6
|
import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
|
|
8
7
|
import { t as MemoryKvStore } from "../kv-tL2TOE9X.mjs";
|
|
9
|
-
import { n as createFederationBuilder } from "../builder-
|
|
8
|
+
import { n as createFederationBuilder } from "../builder-7PVCiLiR.mjs";
|
|
10
9
|
import { test } from "@fedify/fixture";
|
|
11
10
|
import { Activity, Note, Person } from "@fedify/vocab";
|
|
12
11
|
//#region src/federation/builder.test.ts
|
|
@@ -20,8 +19,6 @@ test("FederationBuilder", async (t) => {
|
|
|
20
19
|
builder.setActorDispatcher("/users/{identifier}", actorDispatcher);
|
|
21
20
|
const inboxListener = (_ctx, _activity) => {};
|
|
22
21
|
builder.setInboxListeners("/users/{identifier}/inbox").on(Activity, inboxListener);
|
|
23
|
-
const outboxListener = (_ctx, _activity) => {};
|
|
24
|
-
builder.setOutboxListeners("/users/{identifier}/outbox").on(Activity, outboxListener);
|
|
25
22
|
const objectDispatcher = (_ctx, _values) => {
|
|
26
23
|
return null;
|
|
27
24
|
};
|
|
@@ -53,15 +50,12 @@ test("FederationBuilder", async (t) => {
|
|
|
53
50
|
assertEquals(impl.router.route("/.well-known/webfinger")?.name, "webfinger");
|
|
54
51
|
assertEquals(impl.router.route("/users/test123")?.name, "actor");
|
|
55
52
|
assertEquals(impl.router.route("/users/test123/inbox")?.name, "inbox");
|
|
56
|
-
assertEquals(impl.router.route("/users/test123/outbox")?.name, "outbox");
|
|
57
53
|
assertEquals(impl.router.route("/notes/456")?.name, `object:${Note.typeId.href}`);
|
|
58
54
|
assertEquals(impl.router.route("/nodeinfo")?.name, "nodeInfo");
|
|
59
55
|
const actorCallbacksDispatcher = impl.actorCallbacks?.dispatcher;
|
|
60
56
|
assertExists(actorCallbacksDispatcher);
|
|
61
57
|
const inboxListeners = impl.inboxListeners;
|
|
62
58
|
assertExists(inboxListeners);
|
|
63
|
-
const outboxListeners = impl.outboxListeners;
|
|
64
|
-
assertExists(outboxListeners);
|
|
65
59
|
assertExists(impl.objectCallbacks[Note.typeId.href]);
|
|
66
60
|
assertExists(impl.nodeInfoDispatcher);
|
|
67
61
|
assertEquals(impl.router.build(`object:${Note.typeId.href}`, { id: "123" }), "/notes/123");
|
|
@@ -76,24 +70,6 @@ test("FederationBuilder", async (t) => {
|
|
|
76
70
|
assertExists(federation);
|
|
77
71
|
assertEquals(federation.kv, kv);
|
|
78
72
|
});
|
|
79
|
-
await t.step("should validate outbox listener paths", () => {
|
|
80
|
-
const builder = createFederationBuilder();
|
|
81
|
-
builder.setOutboxDispatcher("/users/{identifier}/outbox", () => ({ items: [] }));
|
|
82
|
-
assertThrows(() => builder.setOutboxListeners("/actors/{identifier}/outbox"), RouterError);
|
|
83
|
-
assertThrows(() => builder.setOutboxListeners("/users/outbox"), RouterError);
|
|
84
|
-
assertThrows(() => builder.setOutboxListeners("/users/{identifier}/outbox/{extra}"), RouterError);
|
|
85
|
-
assertThrows(() => builder.setOutboxListeners("/users/{identifier}/outbox/{identifier}"), RouterError);
|
|
86
|
-
const builderAfterInvalid = createFederationBuilder();
|
|
87
|
-
assertThrows(() => builderAfterInvalid.setOutboxListeners("/users/{identifier}/outbox/{extra}"), RouterError);
|
|
88
|
-
builderAfterInvalid.setOutboxListeners("/users/{identifier}/outbox");
|
|
89
|
-
const builder2 = createFederationBuilder();
|
|
90
|
-
builder2.setOutboxListeners("/users{/identifier}/outbox");
|
|
91
|
-
assertThrows(() => builder2.setOutboxDispatcher("/actors/{identifier}/outbox", () => ({ items: [] })), RouterError);
|
|
92
|
-
const builder3 = createFederationBuilder();
|
|
93
|
-
assertThrows(() => builder3.setOutboxListeners("/users{?identifier}/outbox"), RouterError);
|
|
94
|
-
const builder4 = createFederationBuilder();
|
|
95
|
-
assertThrows(() => builder4.setOutboxDispatcher("/users{?identifier}/outbox", () => ({ items: [] })), RouterError);
|
|
96
|
-
});
|
|
97
73
|
await t.step("should pass build options correctly", async () => {
|
|
98
74
|
const builder = createFederationBuilder();
|
|
99
75
|
const kv = new MemoryKvStore();
|