@fedify/fedify 2.3.0-dev.1131 → 2.3.0-dev.1145
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/README.md +3 -0
- package/dist/{assert-DikXweDx.mjs → assert-OguE97r2.mjs} +1 -1
- package/dist/{assert_instance_of-C4Ri6VuN.mjs → assert_instance_of-DBC5X09g.mjs} +1 -1
- package/dist/{assert_not_equals--wG9hV7u.mjs → assert_not_equals-DkVK8oqV.mjs} +1 -1
- package/dist/{assert_rejects-DQP-q39h.mjs → assert_rejects-DN60FHPX.mjs} +2 -2
- package/dist/{assert_strict_equals-Dmjbg-bA.mjs → assert_strict_equals-XEgZAlrj.mjs} +1 -1
- package/dist/{assert_throws-4NwKEy2q.mjs → assert_throws-BOkhLGYc.mjs} +1 -1
- package/dist/{builder-DckAhD27.mjs → builder-ShiR1K6b.mjs} +60 -41
- package/dist/compat/mod.d.cts +1 -1
- package/dist/compat/mod.d.ts +1 -1
- package/dist/compat/outgoing-jsonld.test.mjs +3 -3
- package/dist/compat/public-audience.test.mjs +3 -3
- package/dist/compat/transformers.test.mjs +5 -5
- package/dist/{context-Cq18Gplu.d.ts → context-DCtsSHDv.d.ts} +2 -86
- package/dist/{context-tc6VOOOL.d.cts → context-DI2gRbyN.d.cts} +1 -87
- package/dist/{context-BAE7AKLA.mjs → context-DVoTs_wM.mjs} +1 -1
- package/dist/{deno--CS-SBS9.mjs → deno-h0TWFuEz.mjs} +1 -1
- package/dist/{docloader-k6huZLQL.mjs → docloader-BdDN0Aqx.mjs} +3 -3
- package/dist/federation/builder.test.mjs +138 -10
- package/dist/federation/collection.test.mjs +3 -3
- package/dist/federation/handler.test.mjs +12 -12
- package/dist/federation/idempotency.test.mjs +6 -6
- package/dist/federation/inbox.test.mjs +3 -3
- package/dist/federation/keycache.test.mjs +5 -5
- package/dist/federation/kv.test.mjs +3 -3
- package/dist/federation/metrics.test.mjs +63 -4
- package/dist/federation/middleware.test.mjs +30 -18
- package/dist/federation/mod.cjs +155 -3
- package/dist/federation/mod.d.cts +2 -2
- package/dist/federation/mod.d.ts +2 -2
- package/dist/federation/mod.js +153 -1
- package/dist/federation/mq.test.mjs +5 -5
- package/dist/federation/negotiation.test.mjs +4 -4
- package/dist/federation/retry.test.mjs +3 -3
- package/dist/federation/router.test.mjs +190 -9
- package/dist/federation/send.test.mjs +16 -16
- package/dist/federation/webfinger.test.mjs +151 -6
- package/dist/{getMachineId-bsd-BY01PL1n.mjs → getMachineId-bsd-etIyxDet.mjs} +1 -1
- package/dist/{getMachineId-darwin-Dr1gkBkp.mjs → getMachineId-darwin-D23zTf4g.mjs} +1 -1
- package/dist/{getMachineId-win-QEYwcJiy.mjs → getMachineId-win-Dpap6v5i.mjs} +1 -1
- package/dist/{http-CJfvRL7D.cjs → http-7kAB7PVx.cjs} +53 -1
- package/dist/{http-cqujdCRz.js → http-B2hxA7dO.js} +48 -2
- package/dist/{http-IywnQdiX.mjs → http-QzW9IWfs.mjs} +4 -4
- package/dist/{key-Df3tMleh.mjs → key-Dh2OK1XQ.mjs} +2 -2
- package/dist/{kv-cache-L0SMQkcd.cjs → kv-cache-DCPp-MT0.cjs} +1 -1
- package/dist/{kv-cache-q9Ec2ryS.mjs → kv-cache-EZRIPZXD.mjs} +1 -1
- package/dist/{kv-cache-pEejzYq4.js → kv-cache-b22dNkjt.js} +1 -1
- package/dist/{ld-BGwiJpl3.mjs → ld-eZbar1rr.mjs} +3 -3
- package/dist/{metrics-BTOMkW8C.mjs → metrics-E0hAHtLZ.mjs} +48 -2
- package/dist/{middleware-B2rtdpFV.cjs → middleware-BUl1BH4x.cjs} +163 -212
- package/dist/{middleware-DtOddSVg.js → middleware-BrGIM_Ra.js} +127 -164
- package/dist/{middleware-BB0IbDow.mjs → middleware-CyJDCmNg.mjs} +89 -37
- package/dist/{middleware-Dnql59Y8.mjs → middleware-mToCR2tG.mjs} +1 -1
- package/dist/mod-CI9fduEi.d.cts +182 -0
- package/dist/mod-CkRiJHGA.d.ts +182 -0
- package/dist/mod.cjs +6 -6
- package/dist/mod.d.cts +2 -2
- package/dist/mod.d.ts +2 -2
- package/dist/mod.js +5 -5
- package/dist/nodeinfo/client.test.mjs +4 -4
- package/dist/nodeinfo/handler.test.mjs +5 -5
- package/dist/nodeinfo/types.test.mjs +4 -4
- package/dist/otel/exporter.test.mjs +3 -3
- package/dist/{outgoing-jsonld-BNL8AC14.mjs → outgoing-jsonld-BgFLCJQ_.mjs} +1 -1
- package/dist/{owner-CIt4hvmM.mjs → owner-ByO_Fw6U.mjs} +2 -2
- package/dist/{proof-DMGIjHYH.js → proof-BkRyFchv.js} +1 -1
- package/dist/{proof-BYlrRSmZ.mjs → proof-CSo0S8OK.mjs} +5 -5
- package/dist/{proof-B1_u25UV.cjs → proof-jVqClF49.cjs} +1 -1
- package/dist/{send-DJFpze7B.mjs → send-jzrTV1FU.mjs} +3 -3
- package/dist/sig/accept.test.mjs +1 -1
- package/dist/sig/http.test.mjs +9 -9
- package/dist/sig/key.test.mjs +6 -6
- package/dist/sig/ld.test.mjs +7 -7
- package/dist/sig/mod.cjs +2 -2
- package/dist/sig/mod.js +2 -2
- package/dist/sig/owner.test.mjs +6 -6
- package/dist/sig/proof.test.mjs +8 -8
- package/dist/{std__assert-BTEgfoJo.mjs → std__assert-BBjXFNOb.mjs} +4 -4
- package/dist/testing/mod.d.mts +1 -0
- package/dist/testing/mod.mjs +1 -1
- package/dist/utils/docloader.test.mjs +7 -7
- package/dist/utils/kv-cache.test.mjs +1 -1
- package/dist/utils/mod.cjs +1 -1
- package/dist/utils/mod.js +1 -1
- package/package.json +6 -7
- package/dist/mod-CajNYYkt.d.ts +0 -63
- package/dist/mod-DnzgcPcy.d.cts +0 -63
- package/dist/router-BT_F5748.mjs +0 -114
- /package/dist/{accept-CgDcxvjV.mjs → accept-CceiKpCy.mjs} +0 -0
- /package/dist/{activity-listener-BeTGV3wc.mjs → activity-listener-tztVvlNb.mjs} +0 -0
- /package/dist/{assert_equals-Ew3jOFa3.mjs → assert_equals-C-ZRDbaf.mjs} +0 -0
- /package/dist/{client-Bneh_DYR.mjs → client-B_A6mfn3.mjs} +0 -0
- /package/dist/{collection-Cc3DVAhE.mjs → collection-CA3V5zyK.mjs} +0 -0
- /package/dist/{esm-sdtqOUPu.mjs → esm-BQRw925N.mjs} +0 -0
- /package/dist/{execAsync-Dxb7rNf3.mjs → execAsync-DCBrgFiV.mjs} +0 -0
- /package/dist/{getMachineId-linux-Bbhofx-s.mjs → getMachineId-linux-ObI47Hql.mjs} +0 -0
- /package/dist/{getMachineId-unsupported-dIOte2Ct.mjs → getMachineId-unsupported-Ddu-PFeh.mjs} +0 -0
- /package/dist/{keycache-BeU0LCII.mjs → keycache-BYMd8q7F.mjs} +0 -0
- /package/dist/{keys-CSYsOMFG.mjs → keys-C3kae-6B.mjs} +0 -0
- /package/dist/{kv-QHE0oeM3.mjs → kv-x2IvBUyq.mjs} +0 -0
- /package/dist/{negotiation-DDstyBvc.mjs → negotiation-CDW-_gUU.mjs} +0 -0
- /package/dist/{public-audience-c9zmYKgA.mjs → public-audience-N3pyOx2p.mjs} +0 -0
- /package/dist/{retry-_VvV0h9f.mjs → retry-v_sGLH1d.mjs} +0 -0
- /package/dist/{types-D09GN0uZ.mjs → types-BFowWFTT.mjs} +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { t as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
4
|
+
import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
5
|
+
import { r as assertExists } from "../std__assert-BBjXFNOb.mjs";
|
|
6
|
+
import { t as assertThrows } from "../assert_throws-BOkhLGYc.mjs";
|
|
7
|
+
import { t as MemoryKvStore } from "../kv-x2IvBUyq.mjs";
|
|
8
|
+
import { r as createFederationBuilder } from "../builder-ShiR1K6b.mjs";
|
|
9
|
+
import { DisallowedOperatorError, DisallowedVarSpecModifierError, DuplicateRouteVariableError, RouteTemplateOptionsNotMatchedError, RouterError } from "@fedify/uri-template";
|
|
10
10
|
import { Activity, Note, Person } from "@fedify/vocab";
|
|
11
11
|
import { test } from "@fedify/fixture";
|
|
12
12
|
//#region src/federation/builder.test.ts
|
|
@@ -74,6 +74,21 @@ test("FederationBuilder", async (t) => {
|
|
|
74
74
|
assertEquals(impl.router.build("inbox", { identifier: "user1" }), "/users/user1/inbox");
|
|
75
75
|
await builder.build({ kv });
|
|
76
76
|
});
|
|
77
|
+
await t.step("should snapshot router state on build", async () => {
|
|
78
|
+
const builder = createFederationBuilder();
|
|
79
|
+
const kv = new MemoryKvStore();
|
|
80
|
+
const noteRouteName = `object:${Note.typeId.href}`;
|
|
81
|
+
builder.setActorDispatcher("/users/{identifier}", () => null);
|
|
82
|
+
const impl1 = await builder.build({ kv });
|
|
83
|
+
builder.setObjectDispatcher(Note, "/notes/{id}", () => null);
|
|
84
|
+
assertEquals(impl1.router.route("/notes/1"), null);
|
|
85
|
+
const impl2 = await builder.build({ kv });
|
|
86
|
+
assertEquals(impl2.router.route("/notes/1")?.name, noteRouteName);
|
|
87
|
+
impl1.router.add("/leaked/{id}", "leaked");
|
|
88
|
+
assertEquals(impl1.router.route("/leaked/1")?.name, "leaked");
|
|
89
|
+
assertEquals(impl2.router.route("/leaked/1"), null);
|
|
90
|
+
assertEquals((await builder.build({ kv })).router.route("/leaked/1"), null);
|
|
91
|
+
});
|
|
77
92
|
await t.step("should build with default options", async () => {
|
|
78
93
|
const builder = createFederationBuilder();
|
|
79
94
|
const kv = new MemoryKvStore();
|
|
@@ -89,15 +104,128 @@ test("FederationBuilder", async (t) => {
|
|
|
89
104
|
assertThrows(() => builder.setOutboxListeners("/users/{identifier}/outbox/{extra}"), RouterError);
|
|
90
105
|
assertThrows(() => builder.setOutboxListeners("/users/{identifier}/outbox/{identifier}"), RouterError);
|
|
91
106
|
const builderAfterInvalid = createFederationBuilder();
|
|
92
|
-
assertThrows(() => builderAfterInvalid.setOutboxListeners("/users/{identifier}/outbox/{extra}"),
|
|
107
|
+
assertThrows(() => builderAfterInvalid.setOutboxListeners("/users/{identifier}/outbox/{extra}"), RouteTemplateOptionsNotMatchedError);
|
|
108
|
+
assertThrows(() => builderAfterInvalid.setOutboxListeners("/users/{identifier:3}/outbox"), DisallowedVarSpecModifierError);
|
|
109
|
+
assertThrows(() => builderAfterInvalid.setOutboxListeners("/users/{identifier*}/outbox"), DisallowedVarSpecModifierError);
|
|
110
|
+
assertThrows(() => builderAfterInvalid.setOutboxListeners("/users/{identifier,identifier}/outbox"), DuplicateRouteVariableError);
|
|
93
111
|
builderAfterInvalid.setOutboxListeners("/users/{identifier}/outbox");
|
|
94
112
|
const builder2 = createFederationBuilder();
|
|
95
|
-
builder2.setOutboxListeners("/users{
|
|
113
|
+
builder2.setOutboxListeners("/users/{identifier}/outbox");
|
|
96
114
|
assertThrows(() => builder2.setOutboxDispatcher("/actors/{identifier}/outbox", () => ({ items: [] })), RouterError);
|
|
97
115
|
const builder3 = createFederationBuilder();
|
|
98
|
-
assertThrows(() => builder3.setOutboxListeners("/users{?identifier}/outbox"),
|
|
116
|
+
assertThrows(() => builder3.setOutboxListeners("/users{?identifier}/outbox"), DisallowedOperatorError);
|
|
117
|
+
const builder3a = createFederationBuilder();
|
|
118
|
+
assertThrows(() => builder3a.setOutboxListeners("/users{;identifier}/outbox"), DisallowedOperatorError);
|
|
119
|
+
const builder3b = createFederationBuilder();
|
|
120
|
+
assertThrows(() => builder3b.setOutboxListeners("/users{.identifier}/outbox"), DisallowedOperatorError);
|
|
99
121
|
const builder4 = createFederationBuilder();
|
|
100
|
-
assertThrows(() => builder4.setOutboxDispatcher("/users{?identifier}/outbox", () => ({ items: [] })),
|
|
122
|
+
assertThrows(() => builder4.setOutboxDispatcher("/users{?identifier}/outbox", () => ({ items: [] })), DisallowedOperatorError);
|
|
123
|
+
const builder5 = createFederationBuilder();
|
|
124
|
+
assertThrows(() => builder5.setOutboxDispatcher("/users/{identifier:3}/outbox", () => ({ items: [] })), DisallowedVarSpecModifierError);
|
|
125
|
+
});
|
|
126
|
+
await t.step("rejects non-segment-boundary identifier operators at registration for required-identifier routes", () => {
|
|
127
|
+
assertThrows(() => createFederationBuilder().setActorDispatcher("/users{/identifier}", () => null), DisallowedOperatorError);
|
|
128
|
+
assertThrows(() => createFederationBuilder().setActorDispatcher("{/identifier}", () => null), DisallowedOperatorError);
|
|
129
|
+
assertThrows(() => createFederationBuilder().setActorDispatcher("/users/{/identifier}", () => null), DisallowedOperatorError);
|
|
130
|
+
assertThrows(() => createFederationBuilder().setActorDispatcher("/users{?identifier}", () => null), DisallowedOperatorError);
|
|
131
|
+
assertThrows(() => createFederationBuilder().setInboxListeners("/users{/identifier}/inbox"), DisallowedOperatorError);
|
|
132
|
+
assertThrows(() => createFederationBuilder().setOutboxListeners("/users{/identifier}/outbox"), DisallowedOperatorError);
|
|
133
|
+
assertThrows(() => createFederationBuilder().setActorDispatcher("/users/{identifier:3}", () => null), DisallowedVarSpecModifierError);
|
|
134
|
+
assertThrows(() => createFederationBuilder().setActorDispatcher("/users/{identifier*}", () => null), DisallowedVarSpecModifierError);
|
|
135
|
+
createFederationBuilder().setActorDispatcher("/users/{identifier}", () => null);
|
|
136
|
+
createFederationBuilder().setInboxListeners("/users/{identifier}/inbox");
|
|
137
|
+
});
|
|
138
|
+
await t.step("every required-identifier setter rejects every omissible operator", () => {
|
|
139
|
+
const omissibleExprs = [
|
|
140
|
+
"{/identifier}",
|
|
141
|
+
"{?identifier}",
|
|
142
|
+
"{;identifier}",
|
|
143
|
+
"{.identifier}"
|
|
144
|
+
];
|
|
145
|
+
const registrars = [
|
|
146
|
+
["setActorDispatcher", (expr) => createFederationBuilder().setActorDispatcher(`/users${expr}`, () => null)],
|
|
147
|
+
["setInboxListeners", (expr) => createFederationBuilder().setInboxListeners(`/users${expr}/inbox`)],
|
|
148
|
+
["setOutboxListeners", (expr) => createFederationBuilder().setOutboxListeners(`/users${expr}/outbox`)],
|
|
149
|
+
["setOutboxDispatcher", (expr) => createFederationBuilder().setOutboxDispatcher(`/users${expr}/outbox`, () => ({ items: [] }))],
|
|
150
|
+
["setFollowingDispatcher", (expr) => createFederationBuilder().setFollowingDispatcher(`/users${expr}/following`, () => ({ items: [] }))],
|
|
151
|
+
["setFollowersDispatcher", (expr) => createFederationBuilder().setFollowersDispatcher(`/users${expr}/followers`, () => ({ items: [] }))],
|
|
152
|
+
["setLikedDispatcher", (expr) => createFederationBuilder().setLikedDispatcher(`/users${expr}/liked`, () => ({ items: [] }))],
|
|
153
|
+
["setFeaturedDispatcher", (expr) => createFederationBuilder().setFeaturedDispatcher(`/users${expr}/featured`, () => ({ items: [] }))],
|
|
154
|
+
["setFeaturedTagsDispatcher", (expr) => createFederationBuilder().setFeaturedTagsDispatcher(`/users${expr}/tags`, () => ({ items: [] }))]
|
|
155
|
+
];
|
|
156
|
+
for (const [name, register] of registrars) {
|
|
157
|
+
for (const expr of omissibleExprs) assertThrows(() => register(expr), DisallowedOperatorError, void 0, `${name} must reject ${expr} at registration`);
|
|
158
|
+
register("{identifier}");
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
await t.step("empty or missing identifier segments produce a runtime no-match", async () => {
|
|
162
|
+
const kv = new MemoryKvStore();
|
|
163
|
+
const builder = createFederationBuilder();
|
|
164
|
+
builder.setActorDispatcher("/users/{identifier}", () => null);
|
|
165
|
+
builder.setInboxListeners("/users/{identifier}/inbox");
|
|
166
|
+
builder.setOutboxDispatcher("/users/{identifier}/outbox", () => ({ items: [] }));
|
|
167
|
+
builder.setObjectDispatcher(Note, "/notes/{id}", () => null);
|
|
168
|
+
const impl = await builder.build({ kv });
|
|
169
|
+
assertEquals(impl.router.route("/users/alice")?.name, "actor");
|
|
170
|
+
assertEquals(impl.router.route("/users/alice/inbox")?.name, "inbox");
|
|
171
|
+
assertEquals(impl.router.route("/users/alice/outbox")?.name, "outbox");
|
|
172
|
+
assertEquals(impl.router.route("/notes/1")?.name, `object:${Note.typeId.href}`);
|
|
173
|
+
assertEquals(impl.router.route("/users/"), null);
|
|
174
|
+
assertEquals(impl.router.route("/users//inbox"), null);
|
|
175
|
+
assertEquals(impl.router.route("/users//outbox"), null);
|
|
176
|
+
assertEquals(impl.router.route("/notes/"), null);
|
|
177
|
+
});
|
|
178
|
+
await t.step("object dispatcher optional-operator routes no-match when unbound", async () => {
|
|
179
|
+
const kv = new MemoryKvStore();
|
|
180
|
+
const objectName = `object:${Note.typeId.href}`;
|
|
181
|
+
const query = createFederationBuilder();
|
|
182
|
+
query.setObjectDispatcher(Note, "/notes{?id}", () => null);
|
|
183
|
+
const queryImpl = await query.build({ kv });
|
|
184
|
+
assertEquals(queryImpl.router.route("/notes"), null);
|
|
185
|
+
assertEquals(queryImpl.router.route("/notes?id=1")?.name, objectName);
|
|
186
|
+
const matrix = createFederationBuilder();
|
|
187
|
+
matrix.setObjectDispatcher(Note, "/notes{;id}", () => null);
|
|
188
|
+
const matrixImpl = await matrix.build({ kv });
|
|
189
|
+
assertEquals(matrixImpl.router.route("/notes"), null);
|
|
190
|
+
assertEquals(matrixImpl.router.route("/notes;id=1")?.name, objectName);
|
|
191
|
+
const label = createFederationBuilder();
|
|
192
|
+
label.setObjectDispatcher(Note, "/notes{.id}", () => null);
|
|
193
|
+
const labelImpl = await label.build({ kv });
|
|
194
|
+
assertEquals(labelImpl.router.route("/notes"), null);
|
|
195
|
+
assertEquals(labelImpl.router.route("/notes.1")?.name, objectName);
|
|
196
|
+
});
|
|
197
|
+
await t.step("custom collection routes no-match empty or unbound variables", async () => {
|
|
198
|
+
const kv = new MemoryKvStore();
|
|
199
|
+
const builder = createFederationBuilder();
|
|
200
|
+
builder.setCollectionDispatcher("samples", Note, "/groups/{id}", () => ({ items: [] }));
|
|
201
|
+
builder.setCollectionDispatcher("optionals", Note, "/optional-groups{?id}", () => ({ items: [] }));
|
|
202
|
+
builder.setCollectionDispatcher("matrixOptionals", Note, "/matrix-groups{;id}", () => ({ items: [] }));
|
|
203
|
+
builder.setCollectionDispatcher("labelOptionals", Note, "/label-groups{.id}", () => ({ items: [] }));
|
|
204
|
+
const impl = await builder.build({ kv });
|
|
205
|
+
assertEquals(impl.router.route("/groups/1"), {
|
|
206
|
+
name: "collection:samples",
|
|
207
|
+
values: { id: "1" },
|
|
208
|
+
template: "/groups/{id}"
|
|
209
|
+
});
|
|
210
|
+
assertEquals(impl.router.route("/optional-groups?id=1"), {
|
|
211
|
+
name: "collection:optionals",
|
|
212
|
+
values: { id: "1" },
|
|
213
|
+
template: "/optional-groups{?id}"
|
|
214
|
+
});
|
|
215
|
+
assertEquals(impl.router.route("/matrix-groups;id=1"), {
|
|
216
|
+
name: "collection:matrixOptionals",
|
|
217
|
+
values: { id: "1" },
|
|
218
|
+
template: "/matrix-groups{;id}"
|
|
219
|
+
});
|
|
220
|
+
assertEquals(impl.router.route("/label-groups.1"), {
|
|
221
|
+
name: "collection:labelOptionals",
|
|
222
|
+
values: { id: "1" },
|
|
223
|
+
template: "/label-groups{.id}"
|
|
224
|
+
});
|
|
225
|
+
assertEquals(impl.router.route("/groups/"), null);
|
|
226
|
+
assertEquals(impl.router.route("/optional-groups"), null);
|
|
227
|
+
assertEquals(impl.router.route("/matrix-groups"), null);
|
|
228
|
+
assertEquals(impl.router.route("/label-groups"), null);
|
|
101
229
|
});
|
|
102
230
|
await t.step("should pass build options correctly", async () => {
|
|
103
231
|
const builder = createFederationBuilder();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { t as assertEquals } from "../assert_equals-
|
|
5
|
-
import "../std__assert-
|
|
6
|
-
import { n as digest, t as buildCollectionSynchronizationHeader } from "../collection-
|
|
4
|
+
import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
5
|
+
import "../std__assert-BBjXFNOb.mjs";
|
|
6
|
+
import { n as digest, t as buildCollectionSynchronizationHeader } from "../collection-CA3V5zyK.mjs";
|
|
7
7
|
import { test } from "@fedify/fixture";
|
|
8
8
|
import { decodeHex } from "byte-encodings/hex";
|
|
9
9
|
//#region src/federation/collection.test.ts
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as createOutboxContext, r as createRequestContext, t as createInboxContext } from "../context-
|
|
5
|
-
import { t as assertEquals } from "../assert_equals-
|
|
6
|
-
import "../std__assert-
|
|
7
|
-
import { n as assertGreaterOrEqual } from "../assert_rejects-
|
|
8
|
-
import { t as assertInstanceOf } from "../assert_instance_of-
|
|
9
|
-
import { t as assert } from "../assert-
|
|
10
|
-
import { r as parseAcceptSignature } from "../accept-
|
|
11
|
-
import { s as signRequest } from "../http-
|
|
12
|
-
import { a as rsaPrivateKey3, c as rsaPublicKey3, s as rsaPublicKey2 } from "../keys-
|
|
13
|
-
import { t as MemoryKvStore } from "../kv-
|
|
14
|
-
import { c as handleActor, d as handleInbox, f as handleObject, h as respondWithObjectIfAcceptable, l as handleCollection, m as respondWithObject, o as createFederation, p as handleOutbox, u as handleCustomCollection } from "../middleware-
|
|
15
|
-
import { t as ActivityListenerSet } from "../activity-listener-
|
|
4
|
+
import { n as createOutboxContext, r as createRequestContext, t as createInboxContext } from "../context-DVoTs_wM.mjs";
|
|
5
|
+
import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
6
|
+
import "../std__assert-BBjXFNOb.mjs";
|
|
7
|
+
import { n as assertGreaterOrEqual } from "../assert_rejects-DN60FHPX.mjs";
|
|
8
|
+
import { t as assertInstanceOf } from "../assert_instance_of-DBC5X09g.mjs";
|
|
9
|
+
import { t as assert } from "../assert-OguE97r2.mjs";
|
|
10
|
+
import { r as parseAcceptSignature } from "../accept-CceiKpCy.mjs";
|
|
11
|
+
import { s as signRequest } from "../http-QzW9IWfs.mjs";
|
|
12
|
+
import { a as rsaPrivateKey3, c as rsaPublicKey3, s as rsaPublicKey2 } from "../keys-C3kae-6B.mjs";
|
|
13
|
+
import { t as MemoryKvStore } from "../kv-x2IvBUyq.mjs";
|
|
14
|
+
import { c as handleActor, d as handleInbox, f as handleObject, h as respondWithObjectIfAcceptable, l as handleCollection, m as respondWithObject, o as createFederation, p as handleOutbox, u as handleCustomCollection } from "../middleware-CyJDCmNg.mjs";
|
|
15
|
+
import { t as ActivityListenerSet } from "../activity-listener-tztVvlNb.mjs";
|
|
16
16
|
import { Activity, Create, Note, Person, Tombstone } from "@fedify/vocab";
|
|
17
17
|
import { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
18
18
|
import { FetchError } from "@fedify/vocab-runtime";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { t as assertEquals } from "../assert_equals-
|
|
5
|
-
import "../std__assert-
|
|
6
|
-
import { n as ed25519PrivateKey, r as ed25519PublicKey, t as ed25519Multikey } from "../keys-
|
|
7
|
-
import { r as signObject } from "../proof-
|
|
8
|
-
import { t as MemoryKvStore } from "../kv-
|
|
9
|
-
import { o as createFederation } from "../middleware-
|
|
4
|
+
import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
5
|
+
import "../std__assert-BBjXFNOb.mjs";
|
|
6
|
+
import { n as ed25519PrivateKey, r as ed25519PublicKey, t as ed25519Multikey } from "../keys-C3kae-6B.mjs";
|
|
7
|
+
import { r as signObject } from "../proof-CSo0S8OK.mjs";
|
|
8
|
+
import { t as MemoryKvStore } from "../kv-x2IvBUyq.mjs";
|
|
9
|
+
import { o as createFederation } from "../middleware-CyJDCmNg.mjs";
|
|
10
10
|
import { Create, Follow, Person } from "@fedify/vocab";
|
|
11
11
|
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
12
12
|
//#region src/federation/idempotency.test.ts
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { t as assertEquals } from "../assert_equals-
|
|
5
|
-
import { t as assertThrows } from "../assert_throws-
|
|
6
|
-
import { t as ActivityListenerSet } from "../activity-listener-
|
|
4
|
+
import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
5
|
+
import { t as assertThrows } from "../assert_throws-BOkhLGYc.mjs";
|
|
6
|
+
import { t as ActivityListenerSet } from "../activity-listener-tztVvlNb.mjs";
|
|
7
7
|
import { Activity, Create, Invite, Offer, Update } from "@fedify/vocab";
|
|
8
8
|
import { test } from "@fedify/fixture";
|
|
9
9
|
//#region src/federation/inbox.test.ts
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { t as assertEquals } from "../assert_equals-
|
|
5
|
-
import { t as assertInstanceOf } from "../assert_instance_of-
|
|
6
|
-
import { t as assert } from "../assert-
|
|
7
|
-
import { t as MemoryKvStore } from "../kv-
|
|
8
|
-
import { t as KvKeyCache } from "../keycache-
|
|
4
|
+
import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
5
|
+
import { t as assertInstanceOf } from "../assert_instance_of-DBC5X09g.mjs";
|
|
6
|
+
import { t as assert } from "../assert-OguE97r2.mjs";
|
|
7
|
+
import { t as MemoryKvStore } from "../kv-x2IvBUyq.mjs";
|
|
8
|
+
import { t as KvKeyCache } from "../keycache-BYMd8q7F.mjs";
|
|
9
9
|
import { CryptographicKey, Multikey } from "@fedify/vocab";
|
|
10
10
|
import { test } from "@fedify/fixture";
|
|
11
11
|
//#region src/federation/keycache.test.ts
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { t as assertEquals } from "../assert_equals-
|
|
5
|
-
import "../std__assert-
|
|
6
|
-
import { t as MemoryKvStore } from "../kv-
|
|
4
|
+
import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
5
|
+
import "../std__assert-BBjXFNOb.mjs";
|
|
6
|
+
import { t as MemoryKvStore } from "../kv-x2IvBUyq.mjs";
|
|
7
7
|
import { test } from "@fedify/fixture";
|
|
8
8
|
//#region src/federation/kv.test.ts
|
|
9
9
|
test("MemoryKvStore", async (t) => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { t as assertEquals } from "../assert_equals-
|
|
5
|
-
import "../std__assert-
|
|
6
|
-
import { t as assertRejects } from "../assert_rejects-
|
|
7
|
-
import { a as instrumentDocumentLoader, c as recordDocumentCache, d as recordInboxActivity, f as recordKeyLookup, l as recordDocumentFetch, m as recordOutboxEnqueue, p as recordOutboxActivity, t as classifyFetchError, u as recordFanoutRecipients } from "../metrics-
|
|
4
|
+
import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
5
|
+
import "../std__assert-BBjXFNOb.mjs";
|
|
6
|
+
import { t as assertRejects } from "../assert_rejects-DN60FHPX.mjs";
|
|
7
|
+
import { a as instrumentDocumentLoader, c as recordDocumentCache, d as recordInboxActivity, f as recordKeyLookup, h as recordWebFingerHandle, l as recordDocumentFetch, m as recordOutboxEnqueue, p as recordOutboxActivity, t as classifyFetchError, u as recordFanoutRecipients } from "../metrics-E0hAHtLZ.mjs";
|
|
8
8
|
import { createTestMeterProvider, test } from "@fedify/fixture";
|
|
9
9
|
import { FetchError } from "@fedify/vocab-runtime";
|
|
10
10
|
//#region src/federation/metrics.test.ts
|
|
@@ -213,6 +213,65 @@ test("recordDocumentCache() records hit and miss as a counter", () => {
|
|
|
213
213
|
assertEquals(measurements[1].attributes["activitypub.lookup.result"], "miss");
|
|
214
214
|
assertEquals(measurements[1].attributes["activitypub.remote.host"], "w3id.org");
|
|
215
215
|
});
|
|
216
|
+
test("recordWebFingerHandle() records counter and duration with all attributes", () => {
|
|
217
|
+
const [meterProvider, recorder] = createTestMeterProvider();
|
|
218
|
+
recordWebFingerHandle(meterProvider, {
|
|
219
|
+
durationMs: 17,
|
|
220
|
+
result: "resolved",
|
|
221
|
+
scheme: "acct",
|
|
222
|
+
statusCode: 200
|
|
223
|
+
});
|
|
224
|
+
const counters = recorder.getMeasurements("webfinger.handle");
|
|
225
|
+
assertEquals(counters.length, 1);
|
|
226
|
+
assertEquals(counters[0].type, "counter");
|
|
227
|
+
assertEquals(counters[0].value, 1);
|
|
228
|
+
assertEquals(counters[0].attributes["webfinger.handle.result"], "resolved");
|
|
229
|
+
assertEquals(counters[0].attributes["webfinger.resource.scheme"], "acct");
|
|
230
|
+
assertEquals(counters[0].attributes["http.response.status_code"], 200);
|
|
231
|
+
const durations = recorder.getMeasurements("webfinger.handle.duration");
|
|
232
|
+
assertEquals(durations.length, 1);
|
|
233
|
+
assertEquals(durations[0].type, "histogram");
|
|
234
|
+
assertEquals(durations[0].value, 17);
|
|
235
|
+
assertEquals(durations[0].attributes["webfinger.handle.result"], "resolved");
|
|
236
|
+
assertEquals(durations[0].attributes["webfinger.resource.scheme"], "acct");
|
|
237
|
+
assertEquals(durations[0].attributes["http.response.status_code"], 200);
|
|
238
|
+
});
|
|
239
|
+
test("recordWebFingerHandle() records each non-resolved result with the matching status code", () => {
|
|
240
|
+
const [meterProvider, recorder] = createTestMeterProvider();
|
|
241
|
+
for (const [result, statusCode] of [
|
|
242
|
+
["invalid", 400],
|
|
243
|
+
["not_found", 404],
|
|
244
|
+
["tombstoned", 410]
|
|
245
|
+
]) recordWebFingerHandle(meterProvider, {
|
|
246
|
+
durationMs: 1,
|
|
247
|
+
result,
|
|
248
|
+
scheme: "acct",
|
|
249
|
+
statusCode
|
|
250
|
+
});
|
|
251
|
+
const counters = recorder.getMeasurements("webfinger.handle");
|
|
252
|
+
assertEquals(counters.length, 3);
|
|
253
|
+
assertEquals(counters.map((m) => m.attributes["webfinger.handle.result"]), [
|
|
254
|
+
"invalid",
|
|
255
|
+
"not_found",
|
|
256
|
+
"tombstoned"
|
|
257
|
+
]);
|
|
258
|
+
assertEquals(counters.map((m) => m.attributes["http.response.status_code"]), [
|
|
259
|
+
400,
|
|
260
|
+
404,
|
|
261
|
+
410
|
|
262
|
+
]);
|
|
263
|
+
});
|
|
264
|
+
test("recordWebFingerHandle() omits optional attributes when not provided", () => {
|
|
265
|
+
const [meterProvider, recorder] = createTestMeterProvider();
|
|
266
|
+
recordWebFingerHandle(meterProvider, {
|
|
267
|
+
durationMs: 0,
|
|
268
|
+
result: "error"
|
|
269
|
+
});
|
|
270
|
+
const counter = recorder.getMeasurement("webfinger.handle");
|
|
271
|
+
assertEquals(counter?.attributes["webfinger.handle.result"], "error");
|
|
272
|
+
assertEquals("webfinger.resource.scheme" in (counter?.attributes ?? {}), false);
|
|
273
|
+
assertEquals("http.response.status_code" in (counter?.attributes ?? {}), false);
|
|
274
|
+
});
|
|
216
275
|
test("classifyFetchError() classifies FetchError with 404 as not_found", () => {
|
|
217
276
|
assertEquals(classifyFetchError(new FetchError("https://example.com/k", "not found", new Response("", { status: 404 }))), {
|
|
218
277
|
result: "not_found",
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { r as
|
|
7
|
-
import {
|
|
8
|
-
import { t as
|
|
9
|
-
import { t as
|
|
10
|
-
import { t as
|
|
11
|
-
import { t as
|
|
12
|
-
import { t as
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import { t as
|
|
21
|
-
import { i as KvSpecDeterminer, n as FederationImpl, o as createFederation, r as InboxContextImpl, t as ContextImpl } from "../middleware-BB0IbDow.mjs";
|
|
4
|
+
import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
5
|
+
import { r as assertExists } from "../std__assert-BBjXFNOb.mjs";
|
|
6
|
+
import { r as assertFalse, t as assertRejects } from "../assert_rejects-DN60FHPX.mjs";
|
|
7
|
+
import { t as assertInstanceOf } from "../assert_instance_of-DBC5X09g.mjs";
|
|
8
|
+
import { t as assertThrows } from "../assert_throws-BOkhLGYc.mjs";
|
|
9
|
+
import { t as assertNotEquals } from "../assert_not_equals-DkVK8oqV.mjs";
|
|
10
|
+
import { t as assertStrictEquals } from "../assert_strict_equals-XEgZAlrj.mjs";
|
|
11
|
+
import { t as assert } from "../assert-OguE97r2.mjs";
|
|
12
|
+
import { t as esm_default } from "../esm-BQRw925N.mjs";
|
|
13
|
+
import { l as verifyRequest, s as signRequest } from "../http-QzW9IWfs.mjs";
|
|
14
|
+
import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-C3kae-6B.mjs";
|
|
15
|
+
import { t as getAuthenticatedDocumentLoader } from "../docloader-BdDN0Aqx.mjs";
|
|
16
|
+
import { a as signJsonLd, o as verifyJsonLd, r as detachSignature } from "../ld-eZbar1rr.mjs";
|
|
17
|
+
import { t as doesActorOwnKey } from "../owner-ByO_Fw6U.mjs";
|
|
18
|
+
import { i as verifyObject, r as signObject } from "../proof-CSo0S8OK.mjs";
|
|
19
|
+
import { t as MemoryKvStore } from "../kv-x2IvBUyq.mjs";
|
|
20
|
+
import { i as KvSpecDeterminer, n as FederationImpl, o as createFederation, r as InboxContextImpl, t as ContextImpl } from "../middleware-CyJDCmNg.mjs";
|
|
22
21
|
import { configure, reset } from "@logtape/logtape";
|
|
22
|
+
import { RouterError } from "@fedify/uri-template";
|
|
23
23
|
import * as vocab from "@fedify/vocab";
|
|
24
24
|
import { getTypeId, lookupObject } from "@fedify/vocab";
|
|
25
25
|
import { SpanStatusCode } from "@opentelemetry/api";
|
|
@@ -938,6 +938,18 @@ test("Federation.fetch()", async (t) => {
|
|
|
938
938
|
assertEquals(inbox, []);
|
|
939
939
|
assertEquals(response.status, 404);
|
|
940
940
|
});
|
|
941
|
+
await t.step("empty identifier segment is Not Found, dispatcher not invoked", async () => {
|
|
942
|
+
const { federation, dispatches } = createTestContext();
|
|
943
|
+
assertEquals((await federation.fetch(new Request("https://example.com/users/", {
|
|
944
|
+
method: "GET",
|
|
945
|
+
headers: { "Accept": "application/activity+json" }
|
|
946
|
+
}), { contextData: void 0 })).status, 404);
|
|
947
|
+
assertEquals((await federation.fetch(new Request("https://example.com/users//inbox", {
|
|
948
|
+
method: "POST",
|
|
949
|
+
headers: { "accept": "application/ld+json" }
|
|
950
|
+
}), { contextData: void 0 })).status, 404);
|
|
951
|
+
assertEquals(dispatches.includes(""), false);
|
|
952
|
+
});
|
|
941
953
|
await t.step("onNotAcceptable with GET", async () => {
|
|
942
954
|
const { federation } = createTestContext();
|
|
943
955
|
let notAcceptableCalled = false;
|
package/dist/federation/mod.cjs
CHANGED
|
@@ -2,7 +2,9 @@ const { Temporal } = require("@js-temporal/polyfill");
|
|
|
2
2
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
4
|
require("../chunk-DDcVe30Y.cjs");
|
|
5
|
-
const require_middleware = require("../middleware-
|
|
5
|
+
const require_middleware = require("../middleware-BUl1BH4x.cjs");
|
|
6
|
+
let _logtape_logtape = require("@logtape/logtape");
|
|
7
|
+
let _fedify_uri_template = require("@fedify/uri-template");
|
|
6
8
|
let es_toolkit = require("es-toolkit");
|
|
7
9
|
//#region src/federation/kv.ts
|
|
8
10
|
/**
|
|
@@ -347,11 +349,161 @@ var ParallelMessageQueue = class ParallelMessageQueue {
|
|
|
347
349
|
}
|
|
348
350
|
};
|
|
349
351
|
//#endregion
|
|
352
|
+
//#region src/federation/router.ts
|
|
353
|
+
const logger = (0, _logtape_logtape.getLogger)([
|
|
354
|
+
"fedify",
|
|
355
|
+
"federation",
|
|
356
|
+
"router",
|
|
357
|
+
"deprecated"
|
|
358
|
+
]);
|
|
359
|
+
let deprecationWarned = false;
|
|
360
|
+
function warnDeprecated() {
|
|
361
|
+
if (deprecationWarned) return;
|
|
362
|
+
deprecationWarned = true;
|
|
363
|
+
logger.warn("The `Router` and `RouterError` classes from `@fedify/fedify` are deprecated. Please use `Router` from `@fedify/uri-template` instead.");
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* URL router and constructor based on URI Template
|
|
367
|
+
* ([RFC 6570](https://tools.ietf.org/html/rfc6570)).
|
|
368
|
+
*
|
|
369
|
+
* @deprecated Import `Router` from `@fedify/uri-template` instead. This class
|
|
370
|
+
* remains only for compatibility with older Fedify code. The
|
|
371
|
+
* `@fedify/uri-template` router is the replacement implementation
|
|
372
|
+
* and should be used directly in new code.
|
|
373
|
+
*/
|
|
374
|
+
var Router = class Router {
|
|
375
|
+
#router;
|
|
376
|
+
/**
|
|
377
|
+
* Create a new {@link Router}.
|
|
378
|
+
* @param options Options for the router.
|
|
379
|
+
* @deprecated Use `new Router(options)` from `@fedify/uri-template`
|
|
380
|
+
* instead.
|
|
381
|
+
*/
|
|
382
|
+
constructor(options) {
|
|
383
|
+
this.#router = convertRouterError(() => new _fedify_uri_template.Router(options));
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Whether to ignore trailing slashes when matching paths.
|
|
387
|
+
* @deprecated Use `Router` from `@fedify/uri-template` instead. This
|
|
388
|
+
* accessor forwards to the underlying `@fedify/uri-template`
|
|
389
|
+
* router so that post-construction mutation keeps working as
|
|
390
|
+
* in older Fedify code.
|
|
391
|
+
*/
|
|
392
|
+
get trailingSlashInsensitive() {
|
|
393
|
+
return this.#router.trailingSlashInsensitive;
|
|
394
|
+
}
|
|
395
|
+
set trailingSlashInsensitive(value) {
|
|
396
|
+
this.#router.trailingSlashInsensitive = value;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Clones this router.
|
|
400
|
+
* @deprecated Use `Router` from `@fedify/uri-template` instead.
|
|
401
|
+
*/
|
|
402
|
+
clone() {
|
|
403
|
+
return convertRouterError(() => {
|
|
404
|
+
const clone = new Router();
|
|
405
|
+
clone.#router = this.#router.clone();
|
|
406
|
+
return clone;
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Checks if a path name exists in the router.
|
|
411
|
+
* @param name The name of the path.
|
|
412
|
+
* @returns `true` if the path name exists, otherwise `false`.
|
|
413
|
+
* @deprecated Use `Router` from `@fedify/uri-template` instead.
|
|
414
|
+
*/
|
|
415
|
+
has(name) {
|
|
416
|
+
return convertRouterError(() => this.#router.has(name));
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Adds a new path rule to the router.
|
|
420
|
+
* @param template The path pattern.
|
|
421
|
+
* @param name The name of the path.
|
|
422
|
+
* @returns The names of the variables in the path pattern.
|
|
423
|
+
* @deprecated Use `Router` from `@fedify/uri-template` instead. In this
|
|
424
|
+
* compatibility class, `add()` both registers the route and
|
|
425
|
+
* returns the variables in the path pattern. In
|
|
426
|
+
* `@fedify/uri-template`, these two responsibilities are split:
|
|
427
|
+
* `router.add(template, name)` registers the route and returns
|
|
428
|
+
* `void`, while the pure static method
|
|
429
|
+
* `Router.variables(template)` returns the variable names. To
|
|
430
|
+
* migrate, call `Router.variables(template)` when variables are
|
|
431
|
+
* needed, then call `router.add(template, name)` to register the
|
|
432
|
+
* route.
|
|
433
|
+
*/
|
|
434
|
+
add(template, name) {
|
|
435
|
+
return convertRouterError(() => {
|
|
436
|
+
(0, _fedify_uri_template.assertPath)(template);
|
|
437
|
+
this.#router.add(template, name);
|
|
438
|
+
return _fedify_uri_template.Router.variables(template);
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Resolves a path name and values from a URL, if any match.
|
|
443
|
+
* @param url The URL to resolve.
|
|
444
|
+
* @returns The name of the path and its values, if any match. Otherwise,
|
|
445
|
+
* `null`.
|
|
446
|
+
* @deprecated Use `Router` from `@fedify/uri-template` instead. Unlike the
|
|
447
|
+
* stricter `@fedify/uri-template` router, this compatibility
|
|
448
|
+
* method keeps the old Fedify 2.x contract of returning `null`
|
|
449
|
+
* (rather than throwing) for inputs that are not router paths.
|
|
450
|
+
*/
|
|
451
|
+
route(url) {
|
|
452
|
+
return convertRouterError(() => {
|
|
453
|
+
if (!(0, _fedify_uri_template.isPath)(url)) return null;
|
|
454
|
+
return this.#router.route(url);
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Constructs a URL/path from a path name and values.
|
|
459
|
+
* @param name The name of the path.
|
|
460
|
+
* @param values The values to expand the path with.
|
|
461
|
+
* @returns The URL/path, if the name exists. Otherwise, `null`.
|
|
462
|
+
* @deprecated Use `Router` from `@fedify/uri-template` instead.
|
|
463
|
+
*/
|
|
464
|
+
build(name, values) {
|
|
465
|
+
return convertRouterError(() => this.#router.build(name, values));
|
|
466
|
+
}
|
|
467
|
+
};
|
|
468
|
+
/**
|
|
469
|
+
* An error thrown by the {@link Router}.
|
|
470
|
+
* @deprecated Import `RouterError` from `@fedify/uri-template` instead.
|
|
471
|
+
*/
|
|
472
|
+
var RouterError = class extends _fedify_uri_template.RouterError {
|
|
473
|
+
/**
|
|
474
|
+
* Treats every `RouterError` from `@fedify/uri-template` as an instance of
|
|
475
|
+
* this deprecated class.
|
|
476
|
+
*
|
|
477
|
+
* @deprecated Import `RouterError` from `@fedify/uri-template` instead.
|
|
478
|
+
*/
|
|
479
|
+
static [Symbol.hasInstance](instance) {
|
|
480
|
+
return instance instanceof _fedify_uri_template.RouterError;
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Create a new {@link RouterError}.
|
|
484
|
+
* @param message The error message.
|
|
485
|
+
* @deprecated Import `RouterError` from `@fedify/uri-template` instead.
|
|
486
|
+
*/
|
|
487
|
+
constructor(message) {
|
|
488
|
+
super(message);
|
|
489
|
+
warnDeprecated();
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
function convertRouterError(func) {
|
|
493
|
+
try {
|
|
494
|
+
warnDeprecated();
|
|
495
|
+
return func();
|
|
496
|
+
} catch (error) {
|
|
497
|
+
if (error instanceof _fedify_uri_template.RouterError) throw new RouterError(error.message);
|
|
498
|
+
throw error;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
//#endregion
|
|
350
502
|
exports.InProcessMessageQueue = InProcessMessageQueue;
|
|
351
503
|
exports.MemoryKvStore = MemoryKvStore;
|
|
352
504
|
exports.ParallelMessageQueue = ParallelMessageQueue;
|
|
353
|
-
exports.Router =
|
|
354
|
-
exports.RouterError =
|
|
505
|
+
exports.Router = Router;
|
|
506
|
+
exports.RouterError = RouterError;
|
|
355
507
|
exports.SendActivityError = require_middleware.SendActivityError;
|
|
356
508
|
exports.buildCollectionSynchronizationHeader = require_middleware.buildCollectionSynchronizationHeader;
|
|
357
509
|
exports.createExponentialBackoffPolicy = require_middleware.createExponentialBackoffPolicy;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import { $ as
|
|
2
|
+
import { $ as CustomCollectionDispatcher, A as FederationKvPrefixes, B as RespondWithObjectOptions, C as IdempotencyKeyCallback, D as ObjectCallbackSetters, E as InboxListenerSetters, F as RetryContext, G as ActorHandleMapper, H as respondWithObjectIfAcceptable, I as RetryPolicy, J as CollectionCounter, K as ActorKeyPairsDispatcher, L as createExponentialBackoffPolicy, M as FederationQueueOptions, N as createFederation, O as OutboxListenerSetters, P as CreateExponentialBackoffPolicyOptions, Q as CustomCollectionCursor, R as Message, S as FederationStartQueueOptions, T as InboxChallengePolicy, U as ActorAliasMapper, V as respondWithObject, W as ActorDispatcher, X as CollectionDispatcher, Y as CollectionCursor, Z as CustomCollectionCounter, _ as Federatable, _t as digest, a as GetSignedKeyOptions, at as OutboxErrorHandler, b as FederationFetchOptions, c as ParseUriResult, ct as OutboxPermanentFailureHandler, d as SendActivityOptions, dt as UnverifiedActivityReason, et as InboxErrorHandler, f as SendActivityOptionsForCollection, ft as WebFingerLinksDispatcher, g as CustomCollectionCallbackSetters, gt as buildCollectionSynchronizationHeader, h as ConstructorWithTypeId, ht as PageItems, i as GetActorOptions, it as ObjectDispatcher, j as FederationOrigin, k as Rfc6570Expression, l as RequestContext, lt as SharedInboxKeyDispatcher, m as CollectionCallbackSetters, mt as SenderKeyPair, n as Context, nt as NodeInfoDispatcher, o as InboxContext, ot as OutboxListener, p as ActorCallbackSetters, pt as SendActivityError, q as AuthorizePredicate, r as ForwardActivityOptions, rt as ObjectAuthorizePredicate, s as OutboxContext, st as OutboxListenerErrorHandler, t as ActorKeyPair, tt as InboxListener, u as RouteActivityOptions, ut as UnverifiedActivityHandler, v as Federation, w as IdempotencyStrategy, x as FederationOptions, y as FederationBuilder, z as createFederationBuilder } from "../context-DI2gRbyN.cjs";
|
|
3
3
|
import { a as MemoryKvStore, i as KvStoreSetOptions, n as KvStore, r as KvStoreListEntry, t as KvKey } from "../kv-gJ8LYbxX.cjs";
|
|
4
4
|
import { a as MessageQueueEnqueueOptions, i as MessageQueueDepth, n as InProcessMessageQueueOptions, o as MessageQueueListenOptions, r as MessageQueue, s as ParallelMessageQueue, t as InProcessMessageQueue } from "../mq-D8uSFzxe.cjs";
|
|
5
|
-
import { n as handleWebFinger, t as WebFingerHandlerParameters } from "../mod-
|
|
5
|
+
import { a as RouterOptions, i as RouterError, n as handleWebFinger, o as RouterRouteResult, r as Router, t as WebFingerHandlerParameters } from "../mod-CI9fduEi.cjs";
|
|
6
6
|
export { ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, ConstructorWithTypeId, Context, CreateExponentialBackoffPolicyOptions, CustomCollectionCallbackSetters, CustomCollectionCounter, CustomCollectionCursor, CustomCollectionDispatcher, Federatable, Federation, FederationBuilder, FederationFetchOptions, FederationKvPrefixes, FederationOptions, FederationOrigin, FederationQueueOptions, FederationStartQueueOptions, ForwardActivityOptions, GetActorOptions, GetSignedKeyOptions, IdempotencyKeyCallback, IdempotencyStrategy, InProcessMessageQueue, InProcessMessageQueueOptions, InboxChallengePolicy, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MemoryKvStore, Message, MessageQueue, MessageQueueDepth, MessageQueueEnqueueOptions, MessageQueueListenOptions, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxContext, OutboxErrorHandler, OutboxListener, OutboxListenerErrorHandler, OutboxListenerSetters, OutboxPermanentFailureHandler, PageItems, ParallelMessageQueue, ParseUriResult, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, Rfc6570Expression, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityError, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, SharedInboxKeyDispatcher, UnverifiedActivityHandler, UnverifiedActivityReason, WebFingerHandlerParameters, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, handleWebFinger, respondWithObject, respondWithObjectIfAcceptable };
|