@fedify/fedify 2.0.0-dev.1604 → 2.0.0-dev.1690
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/actor-Be0ThtXy.cjs +42609 -0
- package/dist/{actor-BC3XtGTj.js → actor-ChbPLm6n.js} +7266 -2443
- package/dist/actor-D6K058Tb.d.cts +128 -0
- package/dist/{actor-CmRlosMl.js → actor-DuCeRiNh.js} +1 -1
- package/dist/{actor-C22bXuuC.d.ts → actor-T6RyhRgk.d.ts} +1 -1
- package/dist/{assert_rejects-7UF4R_Qs.js → assert_rejects-DiIiJbZn.js} +1 -1
- package/dist/{assert_throws-53_pKeP3.js → assert_throws-BOO88avQ.js} +1 -1
- package/dist/{authdocloader-CzpPQC01.js → authdocloader-Brax1A32.js} +3 -3
- package/dist/{authdocloader-D-DICGXT.js → authdocloader-CrxhFL8e.js} +6 -6
- package/dist/authdocloader-OSn_teLV.cjs +58 -0
- package/dist/{builder-D9zidAqR.js → builder-CYOcDUkj.js} +10 -4
- package/dist/chunk-DqRYRqnO.cjs +34 -0
- package/dist/client-CegPX0Rn.d.cts +222 -0
- package/dist/{client-Bsj0vQPr.js → client-CnOdwLLN.js} +1 -1
- package/dist/compat/mod.cjs +10 -0
- package/dist/compat/mod.d.cts +13 -0
- package/dist/compat/mod.d.ts +7 -7
- package/dist/compat/mod.js +5 -5
- package/dist/compat/transformers.test.js +18 -17
- package/dist/compat-DmDDELst.cjs +4 -0
- package/dist/compat-nxUqe4Z-.js +4 -0
- package/dist/{context-CDSZdQHD.d.ts → context-ByZprN0S.d.ts} +66 -6
- package/dist/context-C5BsZkDr.d.cts +2315 -0
- package/dist/docloader-CCqXeagZ.cjs +4861 -0
- package/dist/docloader-D-MrRyHl.d.cts +219 -0
- package/dist/{docloader-CkASOfZ5.js → docloader-XK3y2jn5.js} +189 -9
- package/dist/{esm-CXF1VoeR.js → esm-DnIzfEj0.js} +1 -1
- package/dist/federation/builder.test.js +10 -10
- package/dist/federation/collection.test.js +8 -8
- package/dist/federation/handler.test.js +26 -145
- package/dist/federation/idempotency.test.d.ts +3 -0
- package/dist/federation/idempotency.test.js +202 -0
- package/dist/federation/inbox.test.js +6 -6
- package/dist/federation/keycache.test.js +4 -4
- package/dist/federation/kv.test.js +9 -8
- package/dist/federation/middleware.test.js +232 -38
- package/dist/federation/mod.cjs +29 -0
- package/dist/federation/mod.d.cts +13 -0
- package/dist/federation/mod.d.ts +7 -7
- package/dist/federation/mod.js +15 -15
- package/dist/federation/mq.test.js +10 -10
- package/dist/federation/negotiation.test.d.ts +3 -0
- package/dist/federation/negotiation.test.js +28 -0
- package/dist/federation/retry.test.js +5 -5
- package/dist/federation/router.test.js +8 -8
- package/dist/federation/send.test.js +15 -15
- package/dist/{federation-CMX7WzeL.js → federation-D1U8YY9t.js} +3 -3
- package/dist/federation-H2_En3j5.cjs +244 -0
- package/dist/fixtures/media.example.com/avatars/test-avatar.jpg.json +6 -0
- package/dist/{http-CSYNybkH.js → http-BNOYnVsU.js} +2 -2
- package/dist/{http-B_pxY5of.js → http-BxbM8sEy.js} +6 -6
- package/dist/http-C7vbQwbz.cjs +826 -0
- package/dist/http-D-e6AFwR.d.cts +253 -0
- package/dist/{http-DqSNLFNY.d.ts → http-D6Uj2x2y.d.ts} +1 -1
- package/dist/{inbox-DoJlwIE4.js → inbox-BRru9pX3.js} +24 -7
- package/dist/{key-BOzqiGbl.js → key-1KXru8Ug.js} +2 -2
- package/dist/key-B3uag-rz.js +10 -0
- package/dist/key-BiBmb1Yy.cjs +10 -0
- package/dist/{key-DWWqeyaq.js → key-DK_nfU4I.js} +3 -3
- package/dist/key-Z6ceKnZC.cjs +290 -0
- package/dist/{key-Bif4eMj7.js → key-jyNTxCvK.js} +5 -5
- package/dist/{keycache--NYDYifd.js → keycache-CN61iGVj.js} +1 -1
- package/dist/{keys-MacD9GP6.js → keys-BPdFKgiy.js} +1 -1
- package/dist/kv-63Cil1MD.d.cts +81 -0
- package/dist/{ld-D9oTBLrs.js → ld-Dv8DNNAT.js} +2 -2
- package/dist/{lookup-Cz9VSYxw.js → lookup-BPviO8ij.js} +4 -4
- package/dist/lookup-hnMAAU5r.cjs +137 -0
- package/dist/{lookup-DuzrBbTj.js → lookup-pV0JOsuV.js} +21 -12
- package/dist/middleware-BmoOlgc1.cjs +4231 -0
- package/dist/{middleware-C0w2M0tb.js → middleware-Bz_A2jeJ.js} +87 -91
- package/dist/middleware-CI0-zw4U.js +26 -0
- package/dist/{middleware-CgNm3XOJ.js → middleware-DY9B2lL8.js} +57 -148
- package/dist/middleware-QNK-W-jE.cjs +17 -0
- package/dist/middleware-_vjt6FWU.js +17 -0
- package/dist/mod-8DMWKtQE.d.cts +80 -0
- package/dist/{mod-Drmz72EK.d.ts → mod-BhUKmBJD.d.ts} +2 -2
- package/dist/mod-C2tOeRkN.d.cts +1 -0
- package/dist/{mod-TFoH2Ql8.d.ts → mod-CerN_Sza.d.ts} +1 -1
- package/dist/mod-Cj1tHXBR.d.cts +102 -0
- package/dist/mod-CxkWO3Mg.d.cts +307 -0
- package/dist/{mod-RI3-KvUI.d.ts → mod-D6hQoxC5.d.ts} +2 -2
- package/dist/mod-Djzcw2ry.d.cts +266 -0
- package/dist/{mod-Cxt4Kpf6.d.ts → mod-DlU8ISoa.d.ts} +19 -1
- package/dist/mod-FZd39qVq.d.cts +1 -0
- package/dist/mod-jQ4OODsl.d.cts +113 -0
- package/dist/mod.cjs +150 -0
- package/dist/mod.d.cts +17 -0
- package/dist/mod.d.ts +10 -10
- package/dist/mod.js +20 -20
- package/dist/mq-B7R1Q-M5.d.cts +140 -0
- package/dist/negotiation-5NPJL6zp.js +71 -0
- package/dist/nodeinfo/client.test.js +10 -10
- package/dist/nodeinfo/handler.test.js +23 -22
- package/dist/nodeinfo/mod.cjs +11 -0
- package/dist/nodeinfo/mod.d.cts +5 -0
- package/dist/nodeinfo/mod.js +6 -6
- package/dist/nodeinfo/types.test.js +8 -8
- package/dist/nodeinfo-Co9lJrWl.cjs +4 -0
- package/dist/nodeinfo-DfycQ8Wf.js +4 -0
- package/dist/owner-BN_tO3cY.d.cts +67 -0
- package/dist/{owner-gB-pDKA-.js → owner-e3FYDhsk.js} +2 -2
- package/dist/{owner-CQPnQVtf.d.ts → owner-hd9lvQcP.d.ts} +2 -2
- package/dist/{proof-CScVkkIT.js → proof-6gFMwMNJ.js} +2 -2
- package/dist/proof-B-eqv0Ug.cjs +673 -0
- package/dist/{proof-VPikK_0V.js → proof-DfgvA3al.js} +6 -6
- package/dist/runtime/authdocloader.test.js +14 -14
- package/dist/runtime/docloader.test.js +9 -9
- package/dist/runtime/key.test.js +10 -10
- package/dist/runtime/langstr.test.js +8 -8
- package/dist/runtime/link.test.d.ts +3 -0
- package/dist/runtime/link.test.js +61 -0
- package/dist/runtime/mod.cjs +25 -0
- package/dist/runtime/mod.d.cts +6 -0
- package/dist/runtime/mod.d.ts +3 -3
- package/dist/runtime/mod.js +10 -10
- package/dist/runtime/multibase/multibase.test.js +8 -8
- package/dist/runtime/url.test.js +5 -5
- package/dist/runtime-C58AJWSv.cjs +4 -0
- package/dist/runtime-DPYEDf-o.js +4 -0
- package/dist/{send-flZ7H10-.js → send-Tl9NOnmO.js} +2 -2
- package/dist/sig/http.test.js +13 -13
- package/dist/sig/key.test.js +11 -11
- package/dist/sig/ld.test.js +10 -10
- package/dist/sig/mod.cjs +30 -0
- package/dist/sig/mod.d.cts +8 -0
- package/dist/sig/mod.d.ts +5 -5
- package/dist/sig/mod.js +10 -10
- package/dist/sig/owner.test.js +12 -12
- package/dist/sig/proof.test.js +12 -12
- package/dist/sig-ByHXzqUi.cjs +4 -0
- package/dist/sig-Cj3tk-ig.js +4 -0
- package/dist/testing/docloader.test.js +8 -8
- package/dist/testing/mod.d.ts +272 -0
- package/dist/testing/mod.js +3 -3
- package/dist/{testing-CdBSI4xF.js → testing-BWNCAbL-.js} +2 -2
- package/dist/{transformers-Dna8Fg7k.js → transformers-BFT6d7J5.js} +3 -3
- package/dist/transformers-CoBS-oFG.cjs +116 -0
- package/dist/{type-CAteiET0.js → type-C69ZBu7f.js} +7258 -2255
- package/dist/{types-Vo0qKhN7.js → types-DqxyTxOf.js} +4 -4
- package/dist/types-zqdWZh4O.cjs +315 -0
- package/dist/vocab/actor.test.js +10 -10
- package/dist/vocab/lookup.test.js +259 -9
- package/dist/vocab/mod.cjs +87 -0
- package/dist/vocab/mod.d.cts +6 -0
- package/dist/vocab/mod.d.ts +3 -3
- package/dist/vocab/mod.js +7 -7
- package/dist/vocab/type.test.js +3 -3
- package/dist/vocab/vocab.test.js +438 -14
- package/dist/vocab-B39-pFl9.cjs +291 -0
- package/dist/{vocab-SOE1ifCr.d.ts → vocab-BI0Ak5lL.d.ts} +290 -0
- package/dist/{vocab-89qErSc9.js → vocab-BWoeZsME.js} +26 -17
- package/dist/vocab-Dw1-yVGg.d.cts +14922 -0
- package/dist/webfinger/handler.test.js +23 -22
- package/dist/webfinger/lookup.test.js +9 -9
- package/dist/webfinger/mod.cjs +9 -0
- package/dist/webfinger/mod.d.cts +4 -0
- package/dist/webfinger/mod.js +6 -6
- package/dist/webfinger-BjOEdFPs.cjs +4 -0
- package/dist/webfinger-De_bU0iE.js +4 -0
- package/dist/x/cfworkers.cjs +100 -0
- package/dist/x/cfworkers.d.cts +59 -0
- package/dist/x/cfworkers.js +3 -3
- package/dist/x/cfworkers.test.js +8 -8
- package/dist/x/hono.cjs +61 -0
- package/dist/x/hono.d.cts +54 -0
- package/dist/x/hono.d.ts +6 -6
- package/dist/x/hono.js +3 -3
- package/dist/x/sveltekit.cjs +69 -0
- package/dist/x/sveltekit.d.cts +46 -0
- package/dist/x/sveltekit.d.ts +6 -6
- package/dist/x/sveltekit.js +3 -3
- package/package.json +68 -13
- package/dist/compat-Bb5myD13.js +0 -4
- package/dist/key-BteSu1lX.js +0 -10
- package/dist/middleware-CNfiKLIZ.js +0 -25
- package/dist/middleware-CnvU63kV.js +0 -17
- package/dist/nodeinfo-CyEbLjHs.js +0 -4
- package/dist/runtime-BSkOVUWM.js +0 -4
- package/dist/sig-BXJO--F9.js +0 -4
- package/dist/webfinger-C3GIyXIg.js +0 -4
- /package/dist/{assert_is_error-B035L3om.js → assert_is_error-BPGph1Jx.js} +0 -0
- /package/dist/{assert_not_equals-C80BG-_5.js → assert_not_equals-f3m3epl3.js} +0 -0
- /package/dist/{denokv-jZ0Z2h0M.js → denokv-Bv33Xxea.js} +0 -0
- /package/dist/{retry-CfF8Gn4d.js → retry-D4GJ670a.js} +0 -0
- /package/dist/{std__assert-DWivtrGR.js → std__assert-X-_kMxKM.js} +0 -0
@@ -0,0 +1,202 @@
|
|
1
|
+
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
4
|
+
globalThis.addEventListener = () => {};
|
5
|
+
|
6
|
+
import { Create, Follow, Person } from "../type-C69ZBu7f.js";
|
7
|
+
import { assertEquals } from "../assert_equals-DSbWqCm3.js";
|
8
|
+
import "../assert-MZs1qjMx.js";
|
9
|
+
import "../assert_instance_of-DHz7EHNU.js";
|
10
|
+
import { MemoryKvStore } from "../kv-CRZrzyXm.js";
|
11
|
+
import { createFederation } from "../middleware-DY9B2lL8.js";
|
12
|
+
import "../client-CnOdwLLN.js";
|
13
|
+
import "../lookup-pV0JOsuV.js";
|
14
|
+
import "../types-BSuWJsOm.js";
|
15
|
+
import "../actor-DuCeRiNh.js";
|
16
|
+
import "../key-1KXru8Ug.js";
|
17
|
+
import "../http-BNOYnVsU.js";
|
18
|
+
import "../authdocloader-Brax1A32.js";
|
19
|
+
import "../ld-Dv8DNNAT.js";
|
20
|
+
import "../owner-e3FYDhsk.js";
|
21
|
+
import { signObject } from "../proof-6gFMwMNJ.js";
|
22
|
+
import "../inbox-BRru9pX3.js";
|
23
|
+
import "../builder-CYOcDUkj.js";
|
24
|
+
import "../collection-CcnIw1qY.js";
|
25
|
+
import "../keycache-CN61iGVj.js";
|
26
|
+
import "../negotiation-5NPJL6zp.js";
|
27
|
+
import "../retry-D4GJ670a.js";
|
28
|
+
import "../send-Tl9NOnmO.js";
|
29
|
+
import { mockDocumentLoader, test } from "../testing-BWNCAbL-.js";
|
30
|
+
import "../std__assert-X-_kMxKM.js";
|
31
|
+
import "../assert_rejects-DiIiJbZn.js";
|
32
|
+
import "../assert_is_error-BPGph1Jx.js";
|
33
|
+
import "../assert_not_equals-f3m3epl3.js";
|
34
|
+
import "../assert_throws-BOO88avQ.js";
|
35
|
+
import { ed25519Multikey, ed25519PrivateKey, ed25519PublicKey } from "../keys-BPdFKgiy.js";
|
36
|
+
|
37
|
+
//#region src/federation/idempotency.test.ts
|
38
|
+
const kv = new MemoryKvStore();
|
39
|
+
const federationOptions = {
|
40
|
+
kv,
|
41
|
+
documentLoaderFactory: () => mockDocumentLoader,
|
42
|
+
authenticatedDocumentLoaderFactory: () => mockDocumentLoader
|
43
|
+
};
|
44
|
+
function createTestFederation() {
|
45
|
+
const federation = createFederation(federationOptions);
|
46
|
+
federation.setActorDispatcher("/users/{identifier}", (_, identifier) => identifier === "john" ? new Person({}) : null).setKeyPairsDispatcher(() => [{
|
47
|
+
privateKey: ed25519PrivateKey,
|
48
|
+
publicKey: ed25519PublicKey.publicKey
|
49
|
+
}]);
|
50
|
+
return federation;
|
51
|
+
}
|
52
|
+
test("Federation.setInboxListeners().withIdempotency() - per-origin strategy", async () => {
|
53
|
+
const federation = createTestFederation();
|
54
|
+
const processedActivities = [];
|
55
|
+
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").withIdempotency("per-origin").on(Create, (ctx, activity$1) => {
|
56
|
+
processedActivities.push([ctx.recipient, activity$1]);
|
57
|
+
});
|
58
|
+
const activity = new Create({
|
59
|
+
id: new URL("https://example.com/activities/1"),
|
60
|
+
actor: new URL("https://example.com/person2")
|
61
|
+
});
|
62
|
+
const signedActivity = await signObject(activity, ed25519PrivateKey, ed25519Multikey.id);
|
63
|
+
const body = JSON.stringify(await signedActivity.toJsonLd({ contextLoader: mockDocumentLoader }));
|
64
|
+
let response = await federation.fetch(new Request("https://example.com/users/john/inbox", {
|
65
|
+
method: "POST",
|
66
|
+
headers: { "Content-Type": "application/activity+json" },
|
67
|
+
body
|
68
|
+
}), { contextData: void 0 });
|
69
|
+
assertEquals(response.status, 202);
|
70
|
+
assertEquals(processedActivities.length, 1);
|
71
|
+
assertEquals(processedActivities[0][0], "john");
|
72
|
+
response = await federation.fetch(new Request("https://example.com/inbox", {
|
73
|
+
method: "POST",
|
74
|
+
headers: { "Content-Type": "application/activity+json" },
|
75
|
+
body
|
76
|
+
}), { contextData: void 0 });
|
77
|
+
assertEquals(response.status, 202);
|
78
|
+
assertEquals(processedActivities.length, 1);
|
79
|
+
await kv.delete([
|
80
|
+
"_fedify",
|
81
|
+
"activityIdempotence",
|
82
|
+
"https://example.com:https://example.com/activities/1"
|
83
|
+
]);
|
84
|
+
});
|
85
|
+
test("Federation.setInboxListeners().withIdempotency() - per-inbox strategy", async () => {
|
86
|
+
const federation = createTestFederation();
|
87
|
+
const processedActivities = [];
|
88
|
+
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").withIdempotency("per-inbox").on(Create, (ctx, activity$1) => {
|
89
|
+
processedActivities.push([ctx.recipient, activity$1]);
|
90
|
+
});
|
91
|
+
const activity = new Create({
|
92
|
+
id: new URL("https://example.com/activities/2"),
|
93
|
+
actor: new URL("https://example.com/person2")
|
94
|
+
});
|
95
|
+
const signedActivity = await signObject(activity, ed25519PrivateKey, ed25519Multikey.id);
|
96
|
+
const body = JSON.stringify(await signedActivity.toJsonLd({ contextLoader: mockDocumentLoader }));
|
97
|
+
let response = await federation.fetch(new Request("https://example.com/users/john/inbox", {
|
98
|
+
method: "POST",
|
99
|
+
headers: { "Content-Type": "application/activity+json" },
|
100
|
+
body
|
101
|
+
}), { contextData: void 0 });
|
102
|
+
assertEquals(response.status, 202);
|
103
|
+
assertEquals(processedActivities.length, 1);
|
104
|
+
assertEquals(processedActivities[0][0], "john");
|
105
|
+
response = await federation.fetch(new Request("https://example.com/inbox", {
|
106
|
+
method: "POST",
|
107
|
+
headers: { "Content-Type": "application/activity+json" },
|
108
|
+
body
|
109
|
+
}), { contextData: void 0 });
|
110
|
+
assertEquals(response.status, 202);
|
111
|
+
assertEquals(processedActivities.length, 2);
|
112
|
+
assertEquals(processedActivities[1][0], null);
|
113
|
+
response = await federation.fetch(new Request("https://example.com/users/john/inbox", {
|
114
|
+
method: "POST",
|
115
|
+
headers: { "Content-Type": "application/activity+json" },
|
116
|
+
body
|
117
|
+
}), { contextData: void 0 });
|
118
|
+
assertEquals(response.status, 202);
|
119
|
+
assertEquals(processedActivities.length, 2);
|
120
|
+
});
|
121
|
+
test("Federation.setInboxListeners().withIdempotency() - global strategy", async () => {
|
122
|
+
const federation = createTestFederation();
|
123
|
+
const processedActivities = [];
|
124
|
+
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").withIdempotency("global").on(Create, (ctx, activity$1) => {
|
125
|
+
processedActivities.push([ctx.recipient, activity$1]);
|
126
|
+
});
|
127
|
+
const activity = new Create({
|
128
|
+
id: new URL("https://example.com/activities/3"),
|
129
|
+
actor: new URL("https://example.com/person2")
|
130
|
+
});
|
131
|
+
const signedActivity = await signObject(activity, ed25519PrivateKey, ed25519Multikey.id);
|
132
|
+
const body = JSON.stringify(await signedActivity.toJsonLd({ contextLoader: mockDocumentLoader }));
|
133
|
+
let response = await federation.fetch(new Request("https://example.com/users/john/inbox", {
|
134
|
+
method: "POST",
|
135
|
+
headers: { "Content-Type": "application/activity+json" },
|
136
|
+
body
|
137
|
+
}), { contextData: void 0 });
|
138
|
+
assertEquals(response.status, 202);
|
139
|
+
assertEquals(processedActivities.length, 1);
|
140
|
+
response = await federation.fetch(new Request("https://example.com/inbox", {
|
141
|
+
method: "POST",
|
142
|
+
headers: { "Content-Type": "application/activity+json" },
|
143
|
+
body
|
144
|
+
}), { contextData: void 0 });
|
145
|
+
assertEquals(response.status, 202);
|
146
|
+
assertEquals(processedActivities.length, 1);
|
147
|
+
});
|
148
|
+
test("Federation.setInboxListeners().withIdempotency() - custom callback", async () => {
|
149
|
+
const federation = createTestFederation();
|
150
|
+
const processedActivities = [];
|
151
|
+
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").withIdempotency((ctx, activity) => {
|
152
|
+
if (activity instanceof Follow) return null;
|
153
|
+
const inboxId = ctx.recipient ?? "shared";
|
154
|
+
return `${ctx.origin}:${activity.id?.href}:${inboxId}`;
|
155
|
+
}).on(Create, (ctx, activity) => {
|
156
|
+
processedActivities.push([ctx.recipient, activity]);
|
157
|
+
}).on(Follow, (ctx, activity) => {
|
158
|
+
processedActivities.push([ctx.recipient, activity]);
|
159
|
+
});
|
160
|
+
const createActivity = new Create({
|
161
|
+
id: new URL("https://example.com/activities/4"),
|
162
|
+
actor: new URL("https://example.com/person2")
|
163
|
+
});
|
164
|
+
const signedCreate = await signObject(createActivity, ed25519PrivateKey, ed25519Multikey.id);
|
165
|
+
const createBody = JSON.stringify(await signedCreate.toJsonLd({ contextLoader: mockDocumentLoader }));
|
166
|
+
let response = await federation.fetch(new Request("https://example.com/users/john/inbox", {
|
167
|
+
method: "POST",
|
168
|
+
headers: { "Content-Type": "application/activity+json" },
|
169
|
+
body: createBody
|
170
|
+
}), { contextData: void 0 });
|
171
|
+
assertEquals(response.status, 202);
|
172
|
+
assertEquals(processedActivities.length, 1);
|
173
|
+
response = await federation.fetch(new Request("https://example.com/users/john/inbox", {
|
174
|
+
method: "POST",
|
175
|
+
headers: { "Content-Type": "application/activity+json" },
|
176
|
+
body: createBody
|
177
|
+
}), { contextData: void 0 });
|
178
|
+
assertEquals(response.status, 202);
|
179
|
+
assertEquals(processedActivities.length, 1);
|
180
|
+
const followActivity = new Follow({
|
181
|
+
id: new URL("https://example.com/activities/5"),
|
182
|
+
actor: new URL("https://example.com/person2")
|
183
|
+
});
|
184
|
+
const signedFollow = await signObject(followActivity, ed25519PrivateKey, ed25519Multikey.id);
|
185
|
+
const followBody = JSON.stringify(await signedFollow.toJsonLd({ contextLoader: mockDocumentLoader }));
|
186
|
+
response = await federation.fetch(new Request("https://example.com/users/john/inbox", {
|
187
|
+
method: "POST",
|
188
|
+
headers: { "Content-Type": "application/activity+json" },
|
189
|
+
body: followBody
|
190
|
+
}), { contextData: void 0 });
|
191
|
+
assertEquals(response.status, 202);
|
192
|
+
assertEquals(processedActivities.length, 2);
|
193
|
+
response = await federation.fetch(new Request("https://example.com/users/john/inbox", {
|
194
|
+
method: "POST",
|
195
|
+
headers: { "Content-Type": "application/activity+json" },
|
196
|
+
body: followBody
|
197
|
+
}), { contextData: void 0 });
|
198
|
+
assertEquals(response.status, 202);
|
199
|
+
assertEquals(processedActivities.length, 3);
|
200
|
+
});
|
201
|
+
|
202
|
+
//#endregion
|
@@ -3,13 +3,13 @@
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
4
4
|
globalThis.addEventListener = () => {};
|
5
5
|
|
6
|
-
import { Activity, Create, Invite, Offer, Update } from "../type-
|
6
|
+
import { Activity, Create, Invite, Offer, Update } from "../type-C69ZBu7f.js";
|
7
7
|
import { assertEquals } from "../assert_equals-DSbWqCm3.js";
|
8
|
-
import "../lookup-
|
9
|
-
import { InboxListenerSet } from "../inbox-
|
10
|
-
import { test } from "../testing-
|
11
|
-
import "../assert_is_error-
|
12
|
-
import { assertThrows } from "../assert_throws-
|
8
|
+
import "../lookup-pV0JOsuV.js";
|
9
|
+
import { InboxListenerSet } from "../inbox-BRru9pX3.js";
|
10
|
+
import { test } from "../testing-BWNCAbL-.js";
|
11
|
+
import "../assert_is_error-BPGph1Jx.js";
|
12
|
+
import { assertThrows } from "../assert_throws-BOO88avQ.js";
|
13
13
|
|
14
14
|
//#region src/federation/inbox.test.ts
|
15
15
|
test("InboxListenerSet", () => {
|
@@ -3,14 +3,14 @@
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
4
4
|
globalThis.addEventListener = () => {};
|
5
5
|
|
6
|
-
import { CryptographicKey, Multikey } from "../type-
|
6
|
+
import { CryptographicKey, Multikey } from "../type-C69ZBu7f.js";
|
7
7
|
import { assertEquals } from "../assert_equals-DSbWqCm3.js";
|
8
8
|
import { assert } from "../assert-MZs1qjMx.js";
|
9
9
|
import { assertInstanceOf } from "../assert_instance_of-DHz7EHNU.js";
|
10
10
|
import { MemoryKvStore } from "../kv-CRZrzyXm.js";
|
11
|
-
import "../lookup-
|
12
|
-
import { KvKeyCache } from "../keycache
|
13
|
-
import { test } from "../testing-
|
11
|
+
import "../lookup-pV0JOsuV.js";
|
12
|
+
import { KvKeyCache } from "../keycache-CN61iGVj.js";
|
13
|
+
import { test } from "../testing-BWNCAbL-.js";
|
14
14
|
|
15
15
|
//#region src/federation/keycache.test.ts
|
16
16
|
test("KvKeyCache.set()", async () => {
|
@@ -3,18 +3,18 @@
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
4
4
|
globalThis.addEventListener = () => {};
|
5
5
|
|
6
|
-
import "../type-
|
6
|
+
import "../type-C69ZBu7f.js";
|
7
7
|
import { assertEquals } from "../assert_equals-DSbWqCm3.js";
|
8
8
|
import "../assert-MZs1qjMx.js";
|
9
9
|
import "../assert_instance_of-DHz7EHNU.js";
|
10
10
|
import { MemoryKvStore } from "../kv-CRZrzyXm.js";
|
11
|
-
import "../lookup-
|
12
|
-
import { test } from "../testing-
|
13
|
-
import "../std__assert-
|
14
|
-
import "../assert_rejects-
|
15
|
-
import "../assert_is_error-
|
16
|
-
import "../assert_not_equals-
|
17
|
-
import "../assert_throws-
|
11
|
+
import "../lookup-pV0JOsuV.js";
|
12
|
+
import { test } from "../testing-BWNCAbL-.js";
|
13
|
+
import "../std__assert-X-_kMxKM.js";
|
14
|
+
import "../assert_rejects-DiIiJbZn.js";
|
15
|
+
import "../assert_is_error-BPGph1Jx.js";
|
16
|
+
import "../assert_not_equals-f3m3epl3.js";
|
17
|
+
import "../assert_throws-BOO88avQ.js";
|
18
18
|
|
19
19
|
//#region src/federation/kv.test.ts
|
20
20
|
test("MemoryKvStore", async (t) => {
|
@@ -24,6 +24,7 @@ test("MemoryKvStore", async (t) => {
|
|
24
24
|
assertEquals(await store.get(["foo", "bar"]), "foobar");
|
25
25
|
assertEquals(await store.get(["foo"]), void 0);
|
26
26
|
await store.set(["foo", "baz"], "baz", { ttl: Temporal.Duration.from({ seconds: 0 }) });
|
27
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
27
28
|
assertEquals(await store.get(["foo", "baz"]), void 0);
|
28
29
|
});
|
29
30
|
await t.step("delete()", async () => {
|
@@ -3,37 +3,51 @@
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
4
4
|
globalThis.addEventListener = () => {};
|
5
5
|
|
6
|
-
import { Activity, Announce, Create, Invite, Multikey, Note, Object as Object$1, Offer, Person, fetchDocumentLoader, getTypeId } from "../type-
|
6
|
+
import { Activity, Announce, Create, Invite, Multikey, Note, Object as Object$1, Offer, Person, fetchDocumentLoader, getTypeId } from "../type-C69ZBu7f.js";
|
7
7
|
import { assertEquals } from "../assert_equals-DSbWqCm3.js";
|
8
8
|
import { assert } from "../assert-MZs1qjMx.js";
|
9
9
|
import { assertInstanceOf } from "../assert_instance_of-DHz7EHNU.js";
|
10
10
|
import { MemoryKvStore } from "../kv-CRZrzyXm.js";
|
11
|
-
import { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer, createFederation } from "../middleware-
|
12
|
-
import "../client-
|
13
|
-
import { RouterError, lookupObject } from "../lookup-
|
11
|
+
import { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer, createFederation } from "../middleware-DY9B2lL8.js";
|
12
|
+
import "../client-CnOdwLLN.js";
|
13
|
+
import { RouterError, lookupObject } from "../lookup-pV0JOsuV.js";
|
14
14
|
import "../types-BSuWJsOm.js";
|
15
|
-
import "../actor-
|
16
|
-
import "../key-
|
17
|
-
import { signRequest, verifyRequest } from "../http-
|
18
|
-
import { getAuthenticatedDocumentLoader } from "../authdocloader-
|
19
|
-
import { detachSignature, signJsonLd, verifyJsonLd } from "../ld-
|
20
|
-
import { doesActorOwnKey } from "../owner-
|
21
|
-
import { signObject, verifyObject } from "../proof-
|
22
|
-
import "../inbox-
|
23
|
-
import "../builder-
|
15
|
+
import "../actor-DuCeRiNh.js";
|
16
|
+
import "../key-1KXru8Ug.js";
|
17
|
+
import { signRequest, verifyRequest } from "../http-BNOYnVsU.js";
|
18
|
+
import { getAuthenticatedDocumentLoader } from "../authdocloader-Brax1A32.js";
|
19
|
+
import { detachSignature, signJsonLd, verifyJsonLd } from "../ld-Dv8DNNAT.js";
|
20
|
+
import { doesActorOwnKey } from "../owner-e3FYDhsk.js";
|
21
|
+
import { signObject, verifyObject } from "../proof-6gFMwMNJ.js";
|
22
|
+
import "../inbox-BRru9pX3.js";
|
23
|
+
import "../builder-CYOcDUkj.js";
|
24
24
|
import "../collection-CcnIw1qY.js";
|
25
|
-
import "../keycache
|
26
|
-
import "../
|
27
|
-
import "../
|
28
|
-
import
|
29
|
-
import {
|
30
|
-
import {
|
31
|
-
import "../
|
32
|
-
import
|
33
|
-
import {
|
34
|
-
import {
|
35
|
-
import {
|
25
|
+
import "../keycache-CN61iGVj.js";
|
26
|
+
import "../negotiation-5NPJL6zp.js";
|
27
|
+
import "../retry-D4GJ670a.js";
|
28
|
+
import "../send-Tl9NOnmO.js";
|
29
|
+
import { mockDocumentLoader, test } from "../testing-BWNCAbL-.js";
|
30
|
+
import { assertStrictEquals } from "../std__assert-X-_kMxKM.js";
|
31
|
+
import { assertFalse, assertRejects } from "../assert_rejects-DiIiJbZn.js";
|
32
|
+
import "../assert_is_error-BPGph1Jx.js";
|
33
|
+
import { assertNotEquals } from "../assert_not_equals-f3m3epl3.js";
|
34
|
+
import { assertThrows } from "../assert_throws-BOO88avQ.js";
|
35
|
+
import { ed25519Multikey, ed25519PrivateKey, ed25519PublicKey, rsaPrivateKey2, rsaPrivateKey3, rsaPublicKey2, rsaPublicKey3 } from "../keys-BPdFKgiy.js";
|
36
|
+
import { esm_default } from "../esm-DnIzfEj0.js";
|
36
37
|
|
38
|
+
//#region src/testing/fixtures/example.com/create.json
|
39
|
+
var __context$2 = "https://www.w3.org/ns/activitystreams";
|
40
|
+
var type$2 = "Create";
|
41
|
+
var id$2 = "https://example.com/create";
|
42
|
+
var actor = "https://example.com/person";
|
43
|
+
var create_default = {
|
44
|
+
"@context": __context$2,
|
45
|
+
type: type$2,
|
46
|
+
id: id$2,
|
47
|
+
actor
|
48
|
+
};
|
49
|
+
|
50
|
+
//#endregion
|
37
51
|
//#region src/testing/fixtures/example.com/person.json
|
38
52
|
var __context$1 = ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"];
|
39
53
|
var id$1 = "https://example.com/person";
|
@@ -680,7 +694,7 @@ test({
|
|
680
694
|
kv,
|
681
695
|
documentLoaderFactory: () => mockDocumentLoader
|
682
696
|
});
|
683
|
-
const req = new Request("https://example.com/");
|
697
|
+
const req = new Request("https://example.com/", { headers: { "accept": "application/ld+json" } });
|
684
698
|
const ctx = federation.createContext(req, 123);
|
685
699
|
assertEquals(ctx.request, req);
|
686
700
|
assertEquals(ctx.url, new URL("https://example.com/"));
|
@@ -698,7 +712,7 @@ test({
|
|
698
712
|
assertEquals(await ctx.getSignedKey(), null);
|
699
713
|
assertEquals(await ctx.getSignedKeyOwner(), null);
|
700
714
|
await assertRejects(() => ctx.getActor("someone"), Error, "No actor dispatcher registered");
|
701
|
-
const signedReq = await signRequest(new Request("https://example.com/"), rsaPrivateKey2, rsaPublicKey2.id);
|
715
|
+
const signedReq = await signRequest(new Request("https://example.com/", { headers: { "accept": "application/ld+json" } }), rsaPrivateKey2, rsaPublicKey2.id);
|
702
716
|
const signedCtx = federation.createContext(signedReq, 456);
|
703
717
|
assertEquals(signedCtx.request, signedReq);
|
704
718
|
assertEquals(signedCtx.url, new URL("https://example.com/"));
|
@@ -707,7 +721,7 @@ test({
|
|
707
721
|
assertEquals(await signedCtx.getSignedKeyOwner(), null);
|
708
722
|
assertEquals(await signedCtx.getSignedKey(), rsaPublicKey2);
|
709
723
|
assertEquals(await signedCtx.getSignedKeyOwner(), null);
|
710
|
-
const signedReq2 = await signRequest(new Request("https://example.com/"), rsaPrivateKey3, rsaPublicKey3.id);
|
724
|
+
const signedReq2 = await signRequest(new Request("https://example.com/", { headers: { "accept": "application/ld+json" } }), rsaPrivateKey3, rsaPublicKey3.id);
|
711
725
|
const signedCtx2 = federation.createContext(signedReq2, 456);
|
712
726
|
assertEquals(signedCtx2.request, signedReq2);
|
713
727
|
assertEquals(signedCtx2.url, new URL("https://example.com/"));
|
@@ -740,7 +754,7 @@ test({
|
|
740
754
|
});
|
741
755
|
await t.step("RequestContext.clone()", () => {
|
742
756
|
const federation = createFederation({ kv });
|
743
|
-
const req = new Request("https://example.com/");
|
757
|
+
const req = new Request("https://example.com/", { headers: { "accept": "application/ld+json" } });
|
744
758
|
const ctx = federation.createContext(req, 123);
|
745
759
|
const clone = ctx.clone(456);
|
746
760
|
assertStrictEquals(clone.request, ctx.request);
|
@@ -756,6 +770,157 @@ test({
|
|
756
770
|
esm_default.hardReset();
|
757
771
|
}
|
758
772
|
});
|
773
|
+
test("Federation.fetch()", async (t) => {
|
774
|
+
esm_default.spyGlobal();
|
775
|
+
esm_default.get("https://example.com/key2", {
|
776
|
+
headers: { "Content-Type": "application/activity+json" },
|
777
|
+
body: await rsaPublicKey2.toJsonLd({ contextLoader: mockDocumentLoader })
|
778
|
+
});
|
779
|
+
esm_default.get("begin:https://example.com/person", {
|
780
|
+
headers: { "Content-Type": "application/activity+json" },
|
781
|
+
body: person_default
|
782
|
+
});
|
783
|
+
const createTestContext = () => {
|
784
|
+
const kv = new MemoryKvStore();
|
785
|
+
const inbox = [];
|
786
|
+
const dispatches = [];
|
787
|
+
const federation = createFederation({
|
788
|
+
kv,
|
789
|
+
documentLoaderFactory: () => mockDocumentLoader,
|
790
|
+
authenticatedDocumentLoaderFactory(identity) {
|
791
|
+
const docLoader = getAuthenticatedDocumentLoader(identity);
|
792
|
+
return (url) => {
|
793
|
+
const urlObj = new URL(url);
|
794
|
+
if (urlObj.host === "example.com") return docLoader(url);
|
795
|
+
return mockDocumentLoader(url);
|
796
|
+
};
|
797
|
+
}
|
798
|
+
});
|
799
|
+
federation.setActorDispatcher("/users/{identifier}", (ctx, identifier) => {
|
800
|
+
dispatches.push(identifier);
|
801
|
+
return new Person({
|
802
|
+
id: ctx.getActorUri(identifier),
|
803
|
+
inbox: ctx.getInboxUri(identifier),
|
804
|
+
preferredUsername: identifier
|
805
|
+
});
|
806
|
+
}).setKeyPairsDispatcher(() => {
|
807
|
+
return [{
|
808
|
+
privateKey: rsaPrivateKey2,
|
809
|
+
publicKey: rsaPublicKey2.publicKey
|
810
|
+
}];
|
811
|
+
});
|
812
|
+
federation.setInboxDispatcher("/users/{identifier}/inbox", () => {
|
813
|
+
return { items: [] };
|
814
|
+
});
|
815
|
+
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(Create, (_ctx, activity) => {
|
816
|
+
inbox.push(activity.id.toString());
|
817
|
+
return;
|
818
|
+
});
|
819
|
+
return {
|
820
|
+
federation,
|
821
|
+
inbox,
|
822
|
+
dispatches
|
823
|
+
};
|
824
|
+
};
|
825
|
+
await t.step("GET without accepts header", async () => {
|
826
|
+
const { federation, dispatches } = createTestContext();
|
827
|
+
const response = await federation.fetch(new Request("https://example.com/users/actor", { method: "GET" }), { contextData: void 0 });
|
828
|
+
assertEquals(dispatches, []);
|
829
|
+
assertEquals(response.status, 406);
|
830
|
+
});
|
831
|
+
await t.step("POST with application/json", async () => {
|
832
|
+
const { federation, inbox } = createTestContext();
|
833
|
+
const request = await signRequest(new Request("https://example.com/users/json/inbox", {
|
834
|
+
method: "POST",
|
835
|
+
headers: {
|
836
|
+
"Accept": "application/json",
|
837
|
+
"Content-Type": "application/json"
|
838
|
+
},
|
839
|
+
body: JSON.stringify(create_default)
|
840
|
+
}), rsaPrivateKey2, rsaPublicKey2.id);
|
841
|
+
const response = await federation.fetch(request, { contextData: void 0 });
|
842
|
+
assertEquals(response.status, 202);
|
843
|
+
assertEquals(inbox.length, 1, "Expected one item in the inbox, json");
|
844
|
+
assertEquals(inbox[0], create_default.id);
|
845
|
+
});
|
846
|
+
await t.step("GET with application/json", async () => {
|
847
|
+
const { federation, dispatches } = createTestContext();
|
848
|
+
const response = await federation.fetch(new Request("https://example.com/users/json", {
|
849
|
+
method: "GET",
|
850
|
+
headers: { "Accept": "application/json" }
|
851
|
+
}), { contextData: void 0 });
|
852
|
+
assertEquals(dispatches, ["json"]);
|
853
|
+
assertEquals(response.status, 200);
|
854
|
+
});
|
855
|
+
await t.step("POST with application/ld+json", async () => {
|
856
|
+
const { federation, inbox } = createTestContext();
|
857
|
+
const request = await signRequest(new Request("https://example.com/users/ld/inbox", {
|
858
|
+
method: "POST",
|
859
|
+
headers: {
|
860
|
+
"Accept": "application/ld+json",
|
861
|
+
"Content-Type": "application/activity+json"
|
862
|
+
},
|
863
|
+
body: JSON.stringify(create_default)
|
864
|
+
}), rsaPrivateKey2, rsaPublicKey2.id);
|
865
|
+
const response = await federation.fetch(request, { contextData: void 0 });
|
866
|
+
assertEquals(response.status, 202);
|
867
|
+
assertEquals(inbox.length, 1, "Expected one inbox activity, ld+json");
|
868
|
+
assertEquals(inbox[0], create_default.id);
|
869
|
+
});
|
870
|
+
await t.step("GET with application/ld+json", async () => {
|
871
|
+
const { federation, dispatches } = createTestContext();
|
872
|
+
const request = new Request("https://example.com/users/ld", {
|
873
|
+
method: "GET",
|
874
|
+
headers: { "Accept": "application/ld+json" }
|
875
|
+
});
|
876
|
+
const response = await federation.fetch(request, { contextData: void 0 });
|
877
|
+
assertEquals(dispatches, ["ld"]);
|
878
|
+
assertEquals(response.status, 200);
|
879
|
+
});
|
880
|
+
await t.step("POST with application/activity+json", async () => {
|
881
|
+
const { federation, inbox } = createTestContext();
|
882
|
+
const request = await signRequest(new Request("https://example.com/users/activity/inbox", {
|
883
|
+
method: "POST",
|
884
|
+
headers: {
|
885
|
+
"Accept": "application/activity+json",
|
886
|
+
"Content-Type": "application/activity+json"
|
887
|
+
},
|
888
|
+
body: JSON.stringify(create_default)
|
889
|
+
}), rsaPrivateKey2, rsaPublicKey2.id);
|
890
|
+
const response = await federation.fetch(request, { contextData: void 0 });
|
891
|
+
assertEquals(response.status, 202);
|
892
|
+
assertEquals(inbox.length, 1);
|
893
|
+
assertEquals(inbox[0], create_default.id);
|
894
|
+
});
|
895
|
+
await t.step("GET with application/activity+json", async () => {
|
896
|
+
const { federation, dispatches } = createTestContext();
|
897
|
+
const request = new Request("https://example.com/users/activity", {
|
898
|
+
method: "GET",
|
899
|
+
headers: { "Accept": "application/ld+json" }
|
900
|
+
});
|
901
|
+
const response = await federation.fetch(request, { contextData: void 0 });
|
902
|
+
assertEquals(dispatches, ["activity"]);
|
903
|
+
assertEquals(response.status, 200);
|
904
|
+
});
|
905
|
+
await t.step("onNotAcceptable with GET", async () => {
|
906
|
+
const { federation } = createTestContext();
|
907
|
+
let notAcceptableCalled = false;
|
908
|
+
const response = await federation.fetch(new Request("https://example.com/users/html", {
|
909
|
+
method: "GET",
|
910
|
+
headers: { "Accept": "text/html" }
|
911
|
+
}), {
|
912
|
+
contextData: void 0,
|
913
|
+
onNotAcceptable: () => {
|
914
|
+
notAcceptableCalled = true;
|
915
|
+
return new Response("handled by onNotAcceptable", { status: 200 });
|
916
|
+
}
|
917
|
+
});
|
918
|
+
assertEquals(notAcceptableCalled, true);
|
919
|
+
assertEquals(response.status, 200);
|
920
|
+
assertEquals(await response.text(), "handled by onNotAcceptable");
|
921
|
+
});
|
922
|
+
esm_default.hardReset();
|
923
|
+
});
|
759
924
|
test("Federation.setInboxListeners()", async (t) => {
|
760
925
|
const kv = new MemoryKvStore();
|
761
926
|
esm_default.spyGlobal();
|
@@ -808,7 +973,10 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
808
973
|
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(Create, (ctx, create) => {
|
809
974
|
inbox.push([ctx, create]);
|
810
975
|
});
|
811
|
-
let response = await federation.fetch(new Request("https://example.com/inbox", {
|
976
|
+
let response = await federation.fetch(new Request("https://example.com/inbox", {
|
977
|
+
method: "POST",
|
978
|
+
headers: { "accept": "application/ld+json" }
|
979
|
+
}), { contextData: void 0 });
|
812
980
|
assertEquals(inbox, []);
|
813
981
|
assertEquals(response.status, 404);
|
814
982
|
federation.setActorDispatcher("/users/{identifier}", (_, identifier) => identifier === "john" ? new Person({}) : null).setKeyPairsDispatcher(() => [{
|
@@ -825,23 +993,37 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
825
993
|
});
|
826
994
|
response = await federation.fetch(new Request("https://example.com/inbox", {
|
827
995
|
method: "POST",
|
828
|
-
body: JSON.stringify(await activity().toJsonLd(options))
|
996
|
+
body: JSON.stringify(await activity().toJsonLd(options)),
|
997
|
+
headers: {
|
998
|
+
"accept": "application/ld+json",
|
999
|
+
"content-type": "application/ld+json"
|
1000
|
+
}
|
829
1001
|
}), { contextData: void 0 });
|
830
1002
|
assertEquals(inbox, []);
|
831
1003
|
assertEquals(response.status, 401);
|
832
|
-
response = await federation.fetch(new Request("https://example.com/users/no-one/inbox", {
|
1004
|
+
response = await federation.fetch(new Request("https://example.com/users/no-one/inbox", {
|
1005
|
+
method: "POST",
|
1006
|
+
headers: { "accept": "application/ld+json" }
|
1007
|
+
}), { contextData: void 0 });
|
833
1008
|
assertEquals(inbox, []);
|
834
1009
|
assertEquals(response.status, 404);
|
835
1010
|
response = await federation.fetch(new Request("https://example.com/users/john/inbox", {
|
836
1011
|
method: "POST",
|
837
|
-
body: JSON.stringify(await activity().toJsonLd(options))
|
1012
|
+
body: JSON.stringify(await activity().toJsonLd(options)),
|
1013
|
+
headers: {
|
1014
|
+
"accept": "application/ld+json",
|
1015
|
+
"content-type": "application/ld+json"
|
1016
|
+
}
|
838
1017
|
}), { contextData: void 0 });
|
839
1018
|
assertEquals(inbox, []);
|
840
1019
|
assertEquals(response.status, 401);
|
841
1020
|
const activityPayload = await activity().toJsonLd(options);
|
842
1021
|
let request = new Request("https://example.com/users/john/inbox", {
|
843
1022
|
method: "POST",
|
844
|
-
headers: {
|
1023
|
+
headers: {
|
1024
|
+
"Content-Type": "application/activity+json",
|
1025
|
+
accept: "application/ld+json"
|
1026
|
+
},
|
845
1027
|
body: JSON.stringify(activityPayload)
|
846
1028
|
});
|
847
1029
|
request = await signRequest(request, rsaPrivateKey3, new URL("https://example.com/person2#key3"));
|
@@ -858,7 +1040,10 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
858
1040
|
inbox.shift();
|
859
1041
|
request = new Request("https://another.host/users/john/inbox", {
|
860
1042
|
method: "POST",
|
861
|
-
headers: {
|
1043
|
+
headers: {
|
1044
|
+
"Content-Type": "application/activity+json",
|
1045
|
+
"accept": "application/ld+json"
|
1046
|
+
},
|
862
1047
|
body: JSON.stringify(activityPayload)
|
863
1048
|
});
|
864
1049
|
request = await signRequest(request, rsaPrivateKey3, new URL("https://example.com/person2#key3"));
|
@@ -873,7 +1058,10 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
873
1058
|
inbox.shift();
|
874
1059
|
request = new Request("https://example.com/inbox", {
|
875
1060
|
method: "POST",
|
876
|
-
headers: {
|
1061
|
+
headers: {
|
1062
|
+
"Content-Type": "application/activity+json",
|
1063
|
+
"accept": "application/ld+json"
|
1064
|
+
},
|
877
1065
|
body: JSON.stringify(await activity().toJsonLd(options))
|
878
1066
|
});
|
879
1067
|
request = await signRequest(request, rsaPrivateKey3, new URL("https://example.com/person2#key3"));
|
@@ -888,7 +1076,10 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
888
1076
|
inbox.shift();
|
889
1077
|
request = new Request("https://example.com/users/john/inbox", {
|
890
1078
|
method: "POST",
|
891
|
-
headers: {
|
1079
|
+
headers: {
|
1080
|
+
"Content-Type": "application/activity+json",
|
1081
|
+
"accept": "application/ld+json"
|
1082
|
+
},
|
892
1083
|
body: JSON.stringify(await (await signObject(activity(), ed25519PrivateKey, ed25519Multikey.id, options)).toJsonLd(options))
|
893
1084
|
});
|
894
1085
|
response = await federation.fetch(request, { contextData: void 0 });
|
@@ -927,7 +1118,10 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
927
1118
|
const activity = new Create({ actor: new URL("https://example.com/person") });
|
928
1119
|
let request = new Request("https://example.com/users/john/inbox", {
|
929
1120
|
method: "POST",
|
930
|
-
headers: {
|
1121
|
+
headers: {
|
1122
|
+
"Content-Type": "application/activity+json",
|
1123
|
+
"Accept": "application/activity+json"
|
1124
|
+
},
|
931
1125
|
body: JSON.stringify(await activity.toJsonLd({ contextLoader: mockDocumentLoader }))
|
932
1126
|
});
|
933
1127
|
request = await signRequest(request, rsaPrivateKey2, new URL("https://example.com/key2"));
|
@@ -1243,7 +1437,7 @@ test("ContextImpl.sendActivity()", async (t) => {
|
|
1243
1437
|
collectionSyncHeader = cl.request.headers.get("Collection-Synchronization");
|
1244
1438
|
const options = {
|
1245
1439
|
async documentLoader(url) {
|
1246
|
-
const response = await federation.fetch(new Request(url), { contextData: void 0 });
|
1440
|
+
const response = await federation.fetch(new Request(url, { headers: { "accept": "application/ld+json" } }), { contextData: void 0 });
|
1247
1441
|
if (response.ok) return {
|
1248
1442
|
contextUrl: null,
|
1249
1443
|
document: await response.json(),
|