@fedify/fedify 1.10.0-dev.2 → 2.0.0-dev.12
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/{actor-eIATKOh7.js → actor-C-FuEZU4.js} +220 -705
- package/dist/{actor-C1Euqngb.d.ts → actor-DqFajh9s.d.ts} +2 -2
- package/dist/{actor-8zynMl2a.cjs → actor-_9UN5RVT.cjs} +952 -1479
- package/dist/{actor-Ydzhc8dj.d.cts → actor-f2NtjyCg.d.cts} +2 -2
- package/dist/{actor-Bv7llTFW.js → actor-rOm0sXHU.js} +1 -1
- package/dist/{assert_rejects-DiIiJbZn.js → assert_rejects-Ce45JcFg.js} +1 -1
- package/dist/{assert_is_error-BPGph1Jx.js → assert_throws-BNXdRGWP.js} +31 -1
- package/dist/{builder-C7fApQY_.js → builder-hArjoWjW.js} +3 -4
- package/dist/{client-DjT_tegg.d.cts → client-94iWEfQa.d.cts} +3 -75
- package/dist/{client-DF8anIB5.d.ts → client-BsGzbnV-.d.ts} +3 -75
- package/dist/{client-Bwnrdh_A.js → client-pY7-3icS.js} +3 -22
- package/dist/compat/mod.d.cts +10 -12
- package/dist/compat/mod.d.ts +10 -12
- package/dist/compat/transformers.test.js +20 -20
- package/dist/{context-CwUAkopp.d.cts → context-PxGADCsD.d.cts} +152 -27
- package/dist/{context-CXUibY4L.d.ts → context-V-XS2_6O.d.ts} +152 -27
- package/dist/{authdocloader-TNeksncq.js → docloader-CE1lRhEV.js} +17 -8
- package/dist/{esm-aj4vkb76.js → esm-BEFbR5eN.js} +32 -17
- package/dist/federation/builder.test.js +9 -12
- package/dist/federation/collection.test.js +7 -9
- package/dist/federation/handler.test.js +28 -149
- package/dist/federation/idempotency.test.js +26 -27
- package/dist/federation/inbox.test.js +4 -6
- package/dist/federation/keycache.test.js +3 -4
- package/dist/federation/kv.test.js +6 -8
- package/dist/federation/middleware.test.js +270 -93
- package/dist/federation/mod.cjs +9 -11
- package/dist/federation/mod.d.cts +10 -12
- package/dist/federation/mod.d.ts +10 -12
- package/dist/federation/mod.js +9 -11
- package/dist/federation/mq.test.js +10 -10
- package/dist/federation/negotiation.test.js +26 -0
- package/dist/federation/retry.test.js +4 -5
- package/dist/federation/router.test.js +6 -8
- package/dist/federation/send.test.js +14 -16
- package/dist/{http-wsGR6KkT.d.ts → http-BbO0ejuk.d.ts} +2 -2
- package/dist/{http-DXmKLE1t.js → http-Bmx7ea3F.js} +2 -2
- package/dist/{http-B1_DzfAU.d.cts → http-M8k5mKc0.d.cts} +2 -2
- package/dist/{http-DMJrVRf0.js → http-Q_l4fCEE.js} +256 -6
- package/dist/{http-CK80ff9S.cjs → http-So5V_Tgv.cjs} +289 -9
- package/dist/{inbox-Dt-Q2rJt.js → inbox-B9PjFn2S.js} +2 -7
- package/dist/{key-Tt9B2Qkj.js → key-khQpfFdw.js} +3 -2
- package/dist/{keycache-CXF4YAON.js → keycache-BU3fsZFa.js} +1 -1
- package/dist/{keys-CAUbEZtV.js → keys-BaMFfIdL.js} +2 -1
- package/dist/kv-cache-DN9pfMBe.js +94 -0
- package/dist/kv-cache-R1oW382l.js +122 -0
- package/dist/kv-cache-X2ggcnHI.cjs +134 -0
- package/dist/{ld-CqoYKNwB.js → ld-BLMebnep.js} +3 -2
- package/dist/{type-E_91dusN.js → lookup-C7SSHgK7.js} +542 -5394
- package/dist/{lookup-BXlOCJsH.cjs → lookup-CLaDFNx1.cjs} +134 -5
- package/dist/{lookup-8Ik9lSMm.js → lookup-CtC3x1M6.js} +125 -2
- package/dist/middleware-BYBwqvTv.cjs +15 -0
- package/dist/{middleware-DnXc8LK4.js → middleware-Bda2JO66.js} +38 -84
- package/dist/{middleware-nSw7nWf8.js → middleware-C3ml59Hp.js} +43 -146
- package/dist/middleware-DC7h2qq-.js +26 -0
- package/dist/{middleware-bN29Orv5.cjs → middleware-DFLterpx.cjs} +58 -104
- package/dist/middleware-mQR2SM7T.js +15 -0
- package/dist/{mod-CDObsV1d.d.ts → mod-BlVovdcy.d.ts} +2 -2
- package/dist/{mod-mXx9V0q5.d.cts → mod-BoRKfJPE.d.cts} +2 -2
- package/dist/{mod-BUbqxBev.d.cts → mod-BxRCHTz-.d.cts} +2 -2
- package/dist/{mod-jQ4OODsl.d.cts → mod-C58MZ7Wx.d.cts} +1 -1
- package/dist/{mod-BcObK1Lz.d.ts → mod-Cdo6SYlJ.d.ts} +2 -2
- package/dist/{mod-DgcYoyZK.d.ts → mod-D5Z2tISD.d.ts} +3 -3
- package/dist/mod-DMpuiKXi.d.cts +107 -0
- package/dist/{mod-fjqfsrty.d.cts → mod-DgxG-byT.d.cts} +3 -3
- package/dist/{mod-DBzN0aCM.d.ts → mod-Ds0mpFZU.d.ts} +1 -1
- package/dist/mod-aAE2wOWV.d.ts +109 -0
- package/dist/mod.cjs +19 -34
- package/dist/mod.d.cts +15 -17
- package/dist/mod.d.ts +15 -17
- package/dist/mod.js +14 -16
- package/dist/negotiation-C4nFufNk.js +71 -0
- package/dist/nodeinfo/client.test.js +30 -111
- package/dist/nodeinfo/handler.test.js +25 -26
- package/dist/nodeinfo/mod.cjs +3 -6
- package/dist/nodeinfo/mod.d.cts +3 -5
- package/dist/nodeinfo/mod.d.ts +3 -5
- package/dist/nodeinfo/mod.js +3 -4
- package/dist/nodeinfo/types.test.js +8 -15
- package/dist/{owner-6KSEp9eV.d.cts → owner-B4HbyP8s.d.cts} +3 -3
- package/dist/{owner-9jSx_21P.js → owner-XzzTSr4S.js} +3 -2
- package/dist/{owner-BbeUDvOu.d.ts → owner-kQRGVXG1.d.ts} +3 -3
- package/dist/{proof-BT3OPhWQ.js → proof-B-qOSAuQ.js} +5 -4
- package/dist/{proof-BuLnngRI.cjs → proof-BzJkFBBF.cjs} +18 -17
- package/dist/{proof-B5YI7sn5.js → proof-C9sfVit1.js} +2 -2
- package/dist/{send-DlPE7bKe.js → send-yEkZlxzW.js} +2 -2
- package/dist/sig/http.test.js +12 -13
- package/dist/sig/key.test.js +9 -11
- package/dist/sig/ld.test.js +8 -10
- package/dist/sig/mod.cjs +9 -11
- package/dist/sig/mod.d.cts +5 -7
- package/dist/sig/mod.d.ts +5 -7
- package/dist/sig/mod.js +5 -7
- package/dist/sig/owner.test.js +11 -13
- package/dist/sig/proof.test.js +13 -14
- package/dist/src/vocab/accept.yaml +1 -1
- package/dist/src/vocab/activity.yaml +1 -1
- package/dist/src/vocab/add.yaml +1 -1
- package/dist/src/vocab/announce.yaml +1 -1
- package/dist/src/vocab/application.yaml +1 -1
- package/dist/src/vocab/arrive.yaml +1 -1
- package/dist/src/vocab/article.yaml +1 -1
- package/dist/src/vocab/audio.yaml +1 -1
- package/dist/src/vocab/block.yaml +1 -1
- package/dist/src/vocab/chatmessage.yaml +1 -1
- package/dist/src/vocab/collection.yaml +1 -1
- package/dist/src/vocab/collectionpage.yaml +1 -1
- package/dist/src/vocab/create.yaml +1 -1
- package/dist/src/vocab/dataintegrityproof.yaml +1 -1
- package/dist/src/vocab/delete.yaml +1 -1
- package/dist/src/vocab/didservice.yaml +1 -1
- package/dist/src/vocab/dislike.yaml +1 -1
- package/dist/src/vocab/document.yaml +1 -1
- package/dist/src/vocab/emoji.yaml +1 -1
- package/dist/src/vocab/emojireact.yaml +1 -1
- package/dist/src/vocab/endpoints.yaml +1 -1
- package/dist/src/vocab/event.yaml +1 -1
- package/dist/src/vocab/export.yaml +1 -1
- package/dist/src/vocab/flag.yaml +1 -1
- package/dist/src/vocab/follow.yaml +1 -1
- package/dist/src/vocab/group.yaml +1 -1
- package/dist/src/vocab/hashtag.yaml +1 -1
- package/dist/src/vocab/ignore.yaml +1 -1
- package/dist/src/vocab/image.yaml +1 -1
- package/dist/src/vocab/intransitiveactivity.yaml +1 -1
- package/dist/src/vocab/invite.yaml +1 -1
- package/dist/src/vocab/join.yaml +1 -1
- package/dist/src/vocab/key.yaml +1 -1
- package/dist/src/vocab/leave.yaml +1 -1
- package/dist/src/vocab/like.yaml +1 -1
- package/dist/src/vocab/link.yaml +1 -1
- package/dist/src/vocab/listen.yaml +1 -1
- package/dist/src/vocab/mention.yaml +1 -1
- package/dist/src/vocab/move.yaml +1 -1
- package/dist/src/vocab/multikey.yaml +1 -1
- package/dist/src/vocab/note.yaml +1 -1
- package/dist/src/vocab/object.yaml +1 -1
- package/dist/src/vocab/offer.yaml +1 -1
- package/dist/src/vocab/orderedcollection.yaml +1 -1
- package/dist/src/vocab/orderedcollectionpage.yaml +1 -1
- package/dist/src/vocab/organization.yaml +1 -1
- package/dist/src/vocab/page.yaml +1 -1
- package/dist/src/vocab/person.yaml +1 -1
- package/dist/src/vocab/place.yaml +1 -1
- package/dist/src/vocab/profile.yaml +1 -1
- package/dist/src/vocab/propertyvalue.yaml +1 -1
- package/dist/src/vocab/question.yaml +1 -1
- package/dist/src/vocab/read.yaml +1 -1
- package/dist/src/vocab/reject.yaml +1 -1
- package/dist/src/vocab/relationship.yaml +1 -1
- package/dist/src/vocab/remove.yaml +1 -1
- package/dist/src/vocab/service.yaml +1 -1
- package/dist/src/vocab/source.yaml +1 -1
- package/dist/src/vocab/tentativeaccept.yaml +1 -1
- package/dist/src/vocab/tentativereject.yaml +1 -1
- package/dist/src/vocab/tombstone.yaml +1 -1
- package/dist/src/vocab/travel.yaml +1 -1
- package/dist/src/vocab/undo.yaml +1 -1
- package/dist/src/vocab/update.yaml +1 -1
- package/dist/src/vocab/video.yaml +1 -1
- package/dist/src/vocab/view.yaml +1 -1
- package/dist/testing/docloader.test.js +6 -8
- package/dist/testing/mod.d.ts +10 -119
- package/dist/testing/mod.js +2 -3
- package/dist/{testing-B17zODFD.js → testing-D-nLIHkh.js} +1 -2
- package/dist/{types-By5LByL1.js → types-BtUjyi5y.js} +5 -166
- package/dist/{types-BIgY6c-l.js → types-C2XVl6gj.js} +1 -3
- package/dist/{types-Ci8XKEfO.cjs → types-CWgzGaqk.cjs} +6 -179
- package/dist/{runtime/authdocloader.test.js → utils/docloader.test.js} +14 -15
- package/dist/utils/kv-cache.test.js +209 -0
- package/dist/utils/mod.cjs +12 -0
- package/dist/utils/mod.d.cts +5 -0
- package/dist/utils/mod.d.ts +7 -0
- package/dist/utils/mod.js +11 -0
- package/dist/vocab/actor.test.js +8 -10
- package/dist/vocab/lookup.test.js +8 -10
- package/dist/vocab/mod.cjs +3 -4
- package/dist/vocab/mod.d.cts +3 -5
- package/dist/vocab/mod.d.ts +3 -5
- package/dist/vocab/mod.js +3 -4
- package/dist/vocab/type.test.js +2 -3
- package/dist/vocab/vocab.test.js +7618 -1973
- package/dist/{vocab-CDHNj5zp.d.ts → vocab-BCWe1Ih5.d.ts} +9 -25
- package/dist/{vocab-BjnZ49Xt.cjs → vocab-C96aggZM.cjs} +5 -5
- package/dist/{vocab-Cfs0937i.d.cts → vocab-CeDBzu-f.d.cts} +9 -25
- package/dist/{vocab-CthegyUc.js → vocab-axlR_8k0.js} +3 -3
- package/dist/webfinger/handler.test.js +24 -25
- package/dist/webfinger/lookup.test.js +7 -9
- package/dist/webfinger/mod.cjs +2 -3
- package/dist/webfinger/mod.d.cts +1 -3
- package/dist/webfinger/mod.d.ts +1 -3
- package/dist/webfinger/mod.js +2 -3
- package/package.json +20 -51
- package/dist/assert_throws-BOO88avQ.js +0 -39
- package/dist/authdocloader-BEPeTSD8.cjs +0 -58
- package/dist/authdocloader-BNIyrORx.js +0 -52
- package/dist/denokv-D0nfNQ1x.js +0 -57
- package/dist/docloader-CLYexeNv.js +0 -4825
- package/dist/docloader-CdsuyjrU.cjs +0 -4891
- package/dist/docloader-CxWcuWqQ.d.ts +0 -221
- package/dist/docloader-D-MrRyHl.d.cts +0 -219
- package/dist/key-BL8DRhuI.js +0 -10
- package/dist/key-BU1Vsq8S.cjs +0 -290
- package/dist/key-DTzAk78O.js +0 -10
- package/dist/key-DWDJFZzD.js +0 -260
- package/dist/key-gZEWdYwT.cjs +0 -10
- package/dist/lookup-Co4Y1ycg.js +0 -336
- package/dist/middleware-09gZVY21.cjs +0 -17
- package/dist/middleware-B8Q9c1ys.js +0 -26
- package/dist/middleware-DHUCp8iq.js +0 -17
- package/dist/mod-CIbqfZW0.d.ts +0 -104
- package/dist/mod-Dt-G9ZOS.d.cts +0 -102
- package/dist/mq-B7R1Q-M5.d.cts +0 -140
- package/dist/mq-CRGm1e_F.d.ts +0 -143
- package/dist/nodeinfo/semver.test.js +0 -143
- package/dist/runtime/docloader.test.js +0 -588
- package/dist/runtime/key.test.d.ts +0 -3
- package/dist/runtime/key.test.js +0 -103
- package/dist/runtime/langstr.test.d.ts +0 -3
- package/dist/runtime/langstr.test.js +0 -40
- package/dist/runtime/link.test.d.ts +0 -3
- package/dist/runtime/link.test.js +0 -61
- package/dist/runtime/mod.cjs +0 -25
- package/dist/runtime/mod.d.cts +0 -6
- package/dist/runtime/mod.d.ts +0 -8
- package/dist/runtime/mod.js +0 -13
- package/dist/runtime/multibase/multibase.test.d.ts +0 -3
- package/dist/runtime/multibase/multibase.test.js +0 -358
- package/dist/runtime/url.test.d.ts +0 -3
- package/dist/runtime/url.test.js +0 -45
- package/dist/semver-dArNLkR9.js +0 -149
- package/dist/vocab/schema.yaml +0 -247
- package/dist/x/cfworkers.cjs +0 -100
- package/dist/x/cfworkers.d.cts +0 -59
- package/dist/x/cfworkers.d.ts +0 -61
- package/dist/x/cfworkers.js +0 -98
- package/dist/x/cfworkers.test.d.ts +0 -3
- package/dist/x/cfworkers.test.js +0 -179
- package/dist/x/hono.cjs +0 -61
- package/dist/x/hono.d.cts +0 -54
- package/dist/x/hono.d.ts +0 -56
- package/dist/x/hono.js +0 -60
- package/dist/x/sveltekit.cjs +0 -69
- package/dist/x/sveltekit.d.cts +0 -46
- package/dist/x/sveltekit.d.ts +0 -48
- package/dist/x/sveltekit.js +0 -68
- /package/dist/{assert_not_equals-f3m3epl3.js → assert_not_equals-C80BG-_5.js} +0 -0
- /package/dist/{collection-CSzG2j1P.js → collection-BzWsN9pB.js} +0 -0
- /package/dist/{nodeinfo/semver.test.d.ts → federation/negotiation.test.d.ts} +0 -0
- /package/dist/{federation-H2_En3j5.cjs → federation-CRpdnOMS.cjs} +0 -0
- /package/dist/{federation-D1U8YY9t.js → federation-jcR8-ZxP.js} +0 -0
- /package/dist/{kv-C7sopW2E.d.ts → kv-BKNZ-Tb-.d.ts} +0 -0
- /package/dist/{kv-63Cil1MD.d.cts → kv-Bxr0Q87_.d.cts} +0 -0
- /package/dist/{mod-C2tOeRkN.d.cts → mod-B-hUPT2N.d.cts} +0 -0
- /package/dist/{mod-1pDWKvUL.d.ts → mod-CVgZgliM.d.ts} +0 -0
- /package/dist/{mod-FZd39qVq.d.cts → mod-CcDPcLJW.d.cts} +0 -0
- /package/dist/{mod-g0xFzAP9.d.ts → mod-bjzj5QIb.d.ts} +0 -0
- /package/dist/{nodeinfo-DfycQ8Wf.js → nodeinfo-BnthBobC.js} +0 -0
- /package/dist/{nodeinfo-Co9lJrWl.cjs → nodeinfo-CdN0rEnZ.cjs} +0 -0
- /package/dist/{otel-Chy5T2Xh.js → otel-1BmGPuZc.js} +0 -0
- /package/dist/{retry-D4GJ670a.js → retry-CfF8Gn4d.js} +0 -0
- /package/dist/{runtime-DPYEDf-o.js → sig-C34-oHBl.js} +0 -0
- /package/dist/{runtime-C58AJWSv.cjs → sig-YYj5tCnr.cjs} +0 -0
- /package/dist/{std__assert-X-_kMxKM.js → std__assert-DWivtrGR.js} +0 -0
- /package/dist/{runtime → utils}/docloader.test.d.ts +0 -0
- /package/dist/{runtime/authdocloader.test.d.ts → utils/kv-cache.test.d.ts} +0 -0
- /package/dist/{sig-Cj3tk-ig.js → utils-D-Va7aXC.js} +0 -0
- /package/dist/{sig-ByHXzqUi.cjs → utils-DyRU1gdZ.cjs} +0 -0
- /package/dist/{webfinger-De_bU0iE.js → webfinger-C72Y8lrh.js} +0 -0
- /package/dist/{webfinger-BjOEdFPs.cjs → webfinger-vAtLmxOF.cjs} +0 -0
|
@@ -3,18 +3,16 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import "../
|
|
6
|
+
import "../lookup-C7SSHgK7.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 "../
|
|
12
|
-
import
|
|
13
|
-
import "../
|
|
14
|
-
import "../
|
|
15
|
-
import "../
|
|
16
|
-
import "../assert_not_equals-f3m3epl3.js";
|
|
17
|
-
import "../assert_throws-BOO88avQ.js";
|
|
11
|
+
import { test } from "../testing-D-nLIHkh.js";
|
|
12
|
+
import "../std__assert-DWivtrGR.js";
|
|
13
|
+
import "../assert_rejects-Ce45JcFg.js";
|
|
14
|
+
import "../assert_throws-BNXdRGWP.js";
|
|
15
|
+
import "../assert_not_equals-C80BG-_5.js";
|
|
18
16
|
|
|
19
17
|
//#region src/federation/kv.test.ts
|
|
20
18
|
test("MemoryKvStore", async (t) => {
|
|
@@ -3,38 +3,50 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import { Activity, Announce, Create,
|
|
6
|
+
import { Activity, Announce, Create, Invite, Multikey, Note, Object as Object$1, Offer, Person, RouterError, getTypeId, lookupObject } from "../lookup-C7SSHgK7.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 "../
|
|
13
|
-
import "../
|
|
14
|
-
import
|
|
15
|
-
import "../
|
|
16
|
-
import "../
|
|
17
|
-
import "../
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import "../
|
|
24
|
-
import "../
|
|
25
|
-
import "../
|
|
26
|
-
import "../
|
|
27
|
-
import "../retry-
|
|
28
|
-
import "../send-
|
|
29
|
-
import { mockDocumentLoader, test } from "../testing-
|
|
30
|
-
import { assertStrictEquals } from "../std__assert-
|
|
31
|
-
import { assertFalse, assertRejects } from "../assert_rejects-
|
|
32
|
-
import "../
|
|
33
|
-
import { assertNotEquals } from "../assert_not_equals-
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import { esm_default } from "../esm-aj4vkb76.js";
|
|
11
|
+
import { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer, createFederation } from "../middleware-C3ml59Hp.js";
|
|
12
|
+
import "../client-pY7-3icS.js";
|
|
13
|
+
import "../types-C2XVl6gj.js";
|
|
14
|
+
import "../actor-rOm0sXHU.js";
|
|
15
|
+
import "../key-khQpfFdw.js";
|
|
16
|
+
import { signRequest, verifyRequest } from "../http-Bmx7ea3F.js";
|
|
17
|
+
import { detachSignature, signJsonLd, verifyJsonLd } from "../ld-BLMebnep.js";
|
|
18
|
+
import { doesActorOwnKey } from "../owner-XzzTSr4S.js";
|
|
19
|
+
import { signObject, verifyObject } from "../proof-C9sfVit1.js";
|
|
20
|
+
import { fetchDocumentLoader, getAuthenticatedDocumentLoader } from "../docloader-CE1lRhEV.js";
|
|
21
|
+
import "../kv-cache-DN9pfMBe.js";
|
|
22
|
+
import "../inbox-B9PjFn2S.js";
|
|
23
|
+
import "../builder-hArjoWjW.js";
|
|
24
|
+
import "../collection-BzWsN9pB.js";
|
|
25
|
+
import "../keycache-BU3fsZFa.js";
|
|
26
|
+
import "../negotiation-C4nFufNk.js";
|
|
27
|
+
import "../retry-CfF8Gn4d.js";
|
|
28
|
+
import "../send-yEkZlxzW.js";
|
|
29
|
+
import { mockDocumentLoader, test } from "../testing-D-nLIHkh.js";
|
|
30
|
+
import { assertStrictEquals } from "../std__assert-DWivtrGR.js";
|
|
31
|
+
import { assertFalse, assertRejects } from "../assert_rejects-Ce45JcFg.js";
|
|
32
|
+
import { assertThrows } from "../assert_throws-BNXdRGWP.js";
|
|
33
|
+
import { assertNotEquals } from "../assert_not_equals-C80BG-_5.js";
|
|
34
|
+
import { ed25519Multikey, ed25519PrivateKey, ed25519PublicKey, rsaPrivateKey2, rsaPrivateKey3, rsaPublicKey2, rsaPublicKey3 } from "../keys-BaMFfIdL.js";
|
|
35
|
+
import { esm_default } from "../esm-BEFbR5eN.js";
|
|
37
36
|
|
|
37
|
+
//#region src/testing/fixtures/example.com/create.json
|
|
38
|
+
var __context$2 = "https://www.w3.org/ns/activitystreams";
|
|
39
|
+
var type$2 = "Create";
|
|
40
|
+
var id$2 = "https://example.com/create";
|
|
41
|
+
var actor = "https://example.com/person";
|
|
42
|
+
var create_default = {
|
|
43
|
+
"@context": __context$2,
|
|
44
|
+
type: type$2,
|
|
45
|
+
id: id$2,
|
|
46
|
+
actor
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
38
50
|
//#region src/testing/fixtures/example.com/person.json
|
|
39
51
|
var __context$1 = ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"];
|
|
40
52
|
var id$1 = "https://example.com/person";
|
|
@@ -108,12 +120,7 @@ test("createFederation()", async (t) => {
|
|
|
108
120
|
await t.step("allowPrivateAddress", () => {
|
|
109
121
|
assertThrows(() => createFederation({
|
|
110
122
|
kv,
|
|
111
|
-
|
|
112
|
-
allowPrivateAddress: true
|
|
113
|
-
}), TypeError);
|
|
114
|
-
assertThrows(() => createFederation({
|
|
115
|
-
kv,
|
|
116
|
-
contextLoader: mockDocumentLoader,
|
|
123
|
+
contextLoaderFactory: () => mockDocumentLoader,
|
|
117
124
|
allowPrivateAddress: true
|
|
118
125
|
}), TypeError);
|
|
119
126
|
assertThrows(() => createFederation({
|
|
@@ -223,11 +230,8 @@ test({
|
|
|
223
230
|
},
|
|
224
231
|
async fn(t) {
|
|
225
232
|
const kv = new MemoryKvStore();
|
|
226
|
-
const documentLoader = (url) => {
|
|
227
|
-
throw new FetchError(new URL(url), "Not found");
|
|
228
|
-
};
|
|
229
233
|
esm_default.spyGlobal();
|
|
230
|
-
esm_default.get("https://example.com/
|
|
234
|
+
esm_default.get("https://example.com/auth-check", async (cl) => {
|
|
231
235
|
const v = await verifyRequest(cl.request, {
|
|
232
236
|
contextLoader: mockDocumentLoader,
|
|
233
237
|
documentLoader: mockDocumentLoader,
|
|
@@ -236,10 +240,11 @@ test({
|
|
|
236
240
|
return new Response(JSON.stringify(v != null), { headers: { "Content-Type": "application/json" } });
|
|
237
241
|
});
|
|
238
242
|
await t.step("Context", async () => {
|
|
243
|
+
const rejectingLoader = (_url) => Promise.reject(/* @__PURE__ */ new Error("Not found"));
|
|
239
244
|
const federation = createFederation({
|
|
240
245
|
kv,
|
|
241
|
-
|
|
242
|
-
|
|
246
|
+
documentLoaderFactory: () => rejectingLoader,
|
|
247
|
+
contextLoaderFactory: () => mockDocumentLoader
|
|
243
248
|
});
|
|
244
249
|
let ctx = federation.createContext(new URL("https://example.com:1234/"), 123);
|
|
245
250
|
assertEquals(ctx.data, 123);
|
|
@@ -247,7 +252,7 @@ test({
|
|
|
247
252
|
assertEquals(ctx.canonicalOrigin, "https://example.com:1234");
|
|
248
253
|
assertEquals(ctx.host, "example.com:1234");
|
|
249
254
|
assertEquals(ctx.hostname, "example.com");
|
|
250
|
-
assertStrictEquals(ctx.documentLoader,
|
|
255
|
+
assertStrictEquals(ctx.documentLoader, rejectingLoader);
|
|
251
256
|
assertStrictEquals(ctx.contextLoader, mockDocumentLoader);
|
|
252
257
|
assertStrictEquals(ctx.federation, federation);
|
|
253
258
|
assertThrows(() => ctx.getNodeInfoUri(), RouterError);
|
|
@@ -273,11 +278,7 @@ test({
|
|
|
273
278
|
federation.setNodeInfoDispatcher("/nodeinfo/2.1", () => ({
|
|
274
279
|
software: {
|
|
275
280
|
name: "Example",
|
|
276
|
-
version:
|
|
277
|
-
major: 1,
|
|
278
|
-
minor: 2,
|
|
279
|
-
patch: 3
|
|
280
|
-
}
|
|
281
|
+
version: "1.2.3"
|
|
281
282
|
},
|
|
282
283
|
protocols: ["activitypub"],
|
|
283
284
|
usage: {
|
|
@@ -332,33 +333,39 @@ test({
|
|
|
332
333
|
})
|
|
333
334
|
}]);
|
|
334
335
|
const loader = await ctx.getDocumentLoader({ identifier: "handle" });
|
|
335
|
-
assertEquals(await loader("https://example.com/
|
|
336
|
+
assertEquals(await loader("https://example.com/auth-check"), {
|
|
336
337
|
contextUrl: null,
|
|
337
|
-
documentUrl: "https://example.com/
|
|
338
|
+
documentUrl: "https://example.com/auth-check",
|
|
338
339
|
document: true
|
|
339
340
|
});
|
|
340
341
|
const loader2 = await ctx.getDocumentLoader({ username: "HANDLE" });
|
|
341
|
-
assertEquals(await loader2("https://example.com/
|
|
342
|
+
assertEquals(await loader2("https://example.com/auth-check"), {
|
|
342
343
|
contextUrl: null,
|
|
343
|
-
documentUrl: "https://example.com/
|
|
344
|
+
documentUrl: "https://example.com/auth-check",
|
|
344
345
|
document: true
|
|
345
346
|
});
|
|
346
347
|
const loader3 = ctx.getDocumentLoader({
|
|
347
348
|
keyId: new URL("https://example.com/key2"),
|
|
348
349
|
privateKey: rsaPrivateKey2
|
|
349
350
|
});
|
|
350
|
-
assertEquals(await loader3("https://example.com/
|
|
351
|
+
assertEquals(await loader3("https://example.com/auth-check"), {
|
|
351
352
|
contextUrl: null,
|
|
352
|
-
documentUrl: "https://example.com/
|
|
353
|
+
documentUrl: "https://example.com/auth-check",
|
|
353
354
|
document: true
|
|
354
355
|
});
|
|
355
356
|
assertEquals(await ctx.lookupObject("https://example.com/object"), null);
|
|
356
357
|
await assertRejects(() => ctx.sendActivity({ identifier: "handle" }, [], new Create({})), TypeError, "The activity to send must have at least one actor property.");
|
|
357
358
|
await ctx.sendActivity({ identifier: "handle" }, [], new Create({ actor: new URL("https://example.com/users/handle") }));
|
|
359
|
+
esm_default.get("https://example.com/object", () => new Response(JSON.stringify({
|
|
360
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
361
|
+
type: "Object",
|
|
362
|
+
id: "https://example.com/object",
|
|
363
|
+
name: "Fetched object"
|
|
364
|
+
}), { headers: { "Content-Type": "application/activity+json" } }));
|
|
358
365
|
const federation2 = createFederation({
|
|
359
366
|
kv,
|
|
360
|
-
|
|
361
|
-
|
|
367
|
+
documentLoaderFactory: () => fetchDocumentLoader,
|
|
368
|
+
contextLoaderFactory: () => mockDocumentLoader
|
|
362
369
|
});
|
|
363
370
|
const ctx2 = federation2.createContext(new URL("https://example.com/"), 123);
|
|
364
371
|
assertEquals(await ctx2.lookupObject("https://example.com/object"), new Object$1({
|
|
@@ -457,8 +464,8 @@ test({
|
|
|
457
464
|
const federation = createFederation({
|
|
458
465
|
kv,
|
|
459
466
|
origin: "https://ap.example.com",
|
|
460
|
-
|
|
461
|
-
|
|
467
|
+
documentLoaderFactory: () => mockDocumentLoader,
|
|
468
|
+
contextLoaderFactory: () => mockDocumentLoader
|
|
462
469
|
});
|
|
463
470
|
const ctx = federation.createContext(new URL("https://example.com:1234/"));
|
|
464
471
|
assertEquals(ctx.origin, "https://example.com:1234");
|
|
@@ -468,11 +475,7 @@ test({
|
|
|
468
475
|
federation.setNodeInfoDispatcher("/nodeinfo/2.1", () => ({
|
|
469
476
|
software: {
|
|
470
477
|
name: "Example",
|
|
471
|
-
version:
|
|
472
|
-
major: 1,
|
|
473
|
-
minor: 2,
|
|
474
|
-
patch: 3
|
|
475
|
-
}
|
|
478
|
+
version: "1.2.3"
|
|
476
479
|
},
|
|
477
480
|
protocols: ["activitypub"],
|
|
478
481
|
usage: {
|
|
@@ -662,13 +665,7 @@ test({
|
|
|
662
665
|
assertEquals(nodeInfo, {
|
|
663
666
|
software: {
|
|
664
667
|
name: "foo",
|
|
665
|
-
version:
|
|
666
|
-
major: 1,
|
|
667
|
-
minor: 2,
|
|
668
|
-
patch: 3,
|
|
669
|
-
build: [],
|
|
670
|
-
prerelease: []
|
|
671
|
-
}
|
|
668
|
+
version: "1.2.3"
|
|
672
669
|
},
|
|
673
670
|
protocols: ["activitypub", "diaspora"],
|
|
674
671
|
usage: {
|
|
@@ -694,9 +691,9 @@ test({
|
|
|
694
691
|
await t.step("RequestContext", async () => {
|
|
695
692
|
const federation = createFederation({
|
|
696
693
|
kv,
|
|
697
|
-
|
|
694
|
+
documentLoaderFactory: () => mockDocumentLoader
|
|
698
695
|
});
|
|
699
|
-
const req = new Request("https://example.com/");
|
|
696
|
+
const req = new Request("https://example.com/", { headers: { "accept": "application/ld+json" } });
|
|
700
697
|
const ctx = federation.createContext(req, 123);
|
|
701
698
|
assertEquals(ctx.request, req);
|
|
702
699
|
assertEquals(ctx.url, new URL("https://example.com/"));
|
|
@@ -714,7 +711,7 @@ test({
|
|
|
714
711
|
assertEquals(await ctx.getSignedKey(), null);
|
|
715
712
|
assertEquals(await ctx.getSignedKeyOwner(), null);
|
|
716
713
|
await assertRejects(() => ctx.getActor("someone"), Error, "No actor dispatcher registered");
|
|
717
|
-
const signedReq = await signRequest(new Request("https://example.com/"), rsaPrivateKey2, rsaPublicKey2.id);
|
|
714
|
+
const signedReq = await signRequest(new Request("https://example.com/", { headers: { "accept": "application/ld+json" } }), rsaPrivateKey2, rsaPublicKey2.id);
|
|
718
715
|
const signedCtx = federation.createContext(signedReq, 456);
|
|
719
716
|
assertEquals(signedCtx.request, signedReq);
|
|
720
717
|
assertEquals(signedCtx.url, new URL("https://example.com/"));
|
|
@@ -723,7 +720,7 @@ test({
|
|
|
723
720
|
assertEquals(await signedCtx.getSignedKeyOwner(), null);
|
|
724
721
|
assertEquals(await signedCtx.getSignedKey(), rsaPublicKey2);
|
|
725
722
|
assertEquals(await signedCtx.getSignedKeyOwner(), null);
|
|
726
|
-
const signedReq2 = await signRequest(new Request("https://example.com/"), rsaPrivateKey3, rsaPublicKey3.id);
|
|
723
|
+
const signedReq2 = await signRequest(new Request("https://example.com/", { headers: { "accept": "application/ld+json" } }), rsaPrivateKey3, rsaPublicKey3.id);
|
|
727
724
|
const signedCtx2 = federation.createContext(signedReq2, 456);
|
|
728
725
|
assertEquals(signedCtx2.request, signedReq2);
|
|
729
726
|
assertEquals(signedCtx2.url, new URL("https://example.com/"));
|
|
@@ -756,7 +753,7 @@ test({
|
|
|
756
753
|
});
|
|
757
754
|
await t.step("RequestContext.clone()", () => {
|
|
758
755
|
const federation = createFederation({ kv });
|
|
759
|
-
const req = new Request("https://example.com/");
|
|
756
|
+
const req = new Request("https://example.com/", { headers: { "accept": "application/ld+json" } });
|
|
760
757
|
const ctx = federation.createContext(req, 123);
|
|
761
758
|
const clone = ctx.clone(456);
|
|
762
759
|
assertStrictEquals(clone.request, ctx.request);
|
|
@@ -772,6 +769,157 @@ test({
|
|
|
772
769
|
esm_default.hardReset();
|
|
773
770
|
}
|
|
774
771
|
});
|
|
772
|
+
test("Federation.fetch()", async (t) => {
|
|
773
|
+
esm_default.spyGlobal();
|
|
774
|
+
esm_default.get("https://example.com/key2", {
|
|
775
|
+
headers: { "Content-Type": "application/activity+json" },
|
|
776
|
+
body: await rsaPublicKey2.toJsonLd({ contextLoader: mockDocumentLoader })
|
|
777
|
+
});
|
|
778
|
+
esm_default.get("begin:https://example.com/person", {
|
|
779
|
+
headers: { "Content-Type": "application/activity+json" },
|
|
780
|
+
body: person_default
|
|
781
|
+
});
|
|
782
|
+
const createTestContext = () => {
|
|
783
|
+
const kv = new MemoryKvStore();
|
|
784
|
+
const inbox = [];
|
|
785
|
+
const dispatches = [];
|
|
786
|
+
const federation = createFederation({
|
|
787
|
+
kv,
|
|
788
|
+
documentLoaderFactory: () => mockDocumentLoader,
|
|
789
|
+
authenticatedDocumentLoaderFactory(identity) {
|
|
790
|
+
const docLoader = getAuthenticatedDocumentLoader(identity);
|
|
791
|
+
return (url) => {
|
|
792
|
+
const urlObj = new URL(url);
|
|
793
|
+
if (urlObj.host === "example.com") return docLoader(url);
|
|
794
|
+
return mockDocumentLoader(url);
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
});
|
|
798
|
+
federation.setActorDispatcher("/users/{identifier}", (ctx, identifier) => {
|
|
799
|
+
dispatches.push(identifier);
|
|
800
|
+
return new Person({
|
|
801
|
+
id: ctx.getActorUri(identifier),
|
|
802
|
+
inbox: ctx.getInboxUri(identifier),
|
|
803
|
+
preferredUsername: identifier
|
|
804
|
+
});
|
|
805
|
+
}).setKeyPairsDispatcher(() => {
|
|
806
|
+
return [{
|
|
807
|
+
privateKey: rsaPrivateKey2,
|
|
808
|
+
publicKey: rsaPublicKey2.publicKey
|
|
809
|
+
}];
|
|
810
|
+
});
|
|
811
|
+
federation.setInboxDispatcher("/users/{identifier}/inbox", () => {
|
|
812
|
+
return { items: [] };
|
|
813
|
+
});
|
|
814
|
+
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(Create, (_ctx, activity) => {
|
|
815
|
+
inbox.push(activity.id.toString());
|
|
816
|
+
return;
|
|
817
|
+
});
|
|
818
|
+
return {
|
|
819
|
+
federation,
|
|
820
|
+
inbox,
|
|
821
|
+
dispatches
|
|
822
|
+
};
|
|
823
|
+
};
|
|
824
|
+
await t.step("GET without accepts header", async () => {
|
|
825
|
+
const { federation, dispatches } = createTestContext();
|
|
826
|
+
const response = await federation.fetch(new Request("https://example.com/users/actor", { method: "GET" }), { contextData: void 0 });
|
|
827
|
+
assertEquals(dispatches, []);
|
|
828
|
+
assertEquals(response.status, 406);
|
|
829
|
+
});
|
|
830
|
+
await t.step("POST with application/json", async () => {
|
|
831
|
+
const { federation, inbox } = createTestContext();
|
|
832
|
+
const request = await signRequest(new Request("https://example.com/users/json/inbox", {
|
|
833
|
+
method: "POST",
|
|
834
|
+
headers: {
|
|
835
|
+
"Accept": "application/json",
|
|
836
|
+
"Content-Type": "application/json"
|
|
837
|
+
},
|
|
838
|
+
body: JSON.stringify(create_default)
|
|
839
|
+
}), rsaPrivateKey2, rsaPublicKey2.id);
|
|
840
|
+
const response = await federation.fetch(request, { contextData: void 0 });
|
|
841
|
+
assertEquals(response.status, 202);
|
|
842
|
+
assertEquals(inbox.length, 1, "Expected one item in the inbox, json");
|
|
843
|
+
assertEquals(inbox[0], create_default.id);
|
|
844
|
+
});
|
|
845
|
+
await t.step("GET with application/json", async () => {
|
|
846
|
+
const { federation, dispatches } = createTestContext();
|
|
847
|
+
const response = await federation.fetch(new Request("https://example.com/users/json", {
|
|
848
|
+
method: "GET",
|
|
849
|
+
headers: { "Accept": "application/json" }
|
|
850
|
+
}), { contextData: void 0 });
|
|
851
|
+
assertEquals(dispatches, ["json"]);
|
|
852
|
+
assertEquals(response.status, 200);
|
|
853
|
+
});
|
|
854
|
+
await t.step("POST with application/ld+json", async () => {
|
|
855
|
+
const { federation, inbox } = createTestContext();
|
|
856
|
+
const request = await signRequest(new Request("https://example.com/users/ld/inbox", {
|
|
857
|
+
method: "POST",
|
|
858
|
+
headers: {
|
|
859
|
+
"Accept": "application/ld+json",
|
|
860
|
+
"Content-Type": "application/activity+json"
|
|
861
|
+
},
|
|
862
|
+
body: JSON.stringify(create_default)
|
|
863
|
+
}), rsaPrivateKey2, rsaPublicKey2.id);
|
|
864
|
+
const response = await federation.fetch(request, { contextData: void 0 });
|
|
865
|
+
assertEquals(response.status, 202);
|
|
866
|
+
assertEquals(inbox.length, 1, "Expected one inbox activity, ld+json");
|
|
867
|
+
assertEquals(inbox[0], create_default.id);
|
|
868
|
+
});
|
|
869
|
+
await t.step("GET with application/ld+json", async () => {
|
|
870
|
+
const { federation, dispatches } = createTestContext();
|
|
871
|
+
const request = new Request("https://example.com/users/ld", {
|
|
872
|
+
method: "GET",
|
|
873
|
+
headers: { "Accept": "application/ld+json" }
|
|
874
|
+
});
|
|
875
|
+
const response = await federation.fetch(request, { contextData: void 0 });
|
|
876
|
+
assertEquals(dispatches, ["ld"]);
|
|
877
|
+
assertEquals(response.status, 200);
|
|
878
|
+
});
|
|
879
|
+
await t.step("POST with application/activity+json", async () => {
|
|
880
|
+
const { federation, inbox } = createTestContext();
|
|
881
|
+
const request = await signRequest(new Request("https://example.com/users/activity/inbox", {
|
|
882
|
+
method: "POST",
|
|
883
|
+
headers: {
|
|
884
|
+
"Accept": "application/activity+json",
|
|
885
|
+
"Content-Type": "application/activity+json"
|
|
886
|
+
},
|
|
887
|
+
body: JSON.stringify(create_default)
|
|
888
|
+
}), rsaPrivateKey2, rsaPublicKey2.id);
|
|
889
|
+
const response = await federation.fetch(request, { contextData: void 0 });
|
|
890
|
+
assertEquals(response.status, 202);
|
|
891
|
+
assertEquals(inbox.length, 1);
|
|
892
|
+
assertEquals(inbox[0], create_default.id);
|
|
893
|
+
});
|
|
894
|
+
await t.step("GET with application/activity+json", async () => {
|
|
895
|
+
const { federation, dispatches } = createTestContext();
|
|
896
|
+
const request = new Request("https://example.com/users/activity", {
|
|
897
|
+
method: "GET",
|
|
898
|
+
headers: { "Accept": "application/ld+json" }
|
|
899
|
+
});
|
|
900
|
+
const response = await federation.fetch(request, { contextData: void 0 });
|
|
901
|
+
assertEquals(dispatches, ["activity"]);
|
|
902
|
+
assertEquals(response.status, 200);
|
|
903
|
+
});
|
|
904
|
+
await t.step("onNotAcceptable with GET", async () => {
|
|
905
|
+
const { federation } = createTestContext();
|
|
906
|
+
let notAcceptableCalled = false;
|
|
907
|
+
const response = await federation.fetch(new Request("https://example.com/users/html", {
|
|
908
|
+
method: "GET",
|
|
909
|
+
headers: { "Accept": "text/html" }
|
|
910
|
+
}), {
|
|
911
|
+
contextData: void 0,
|
|
912
|
+
onNotAcceptable: () => {
|
|
913
|
+
notAcceptableCalled = true;
|
|
914
|
+
return new Response("handled by onNotAcceptable", { status: 200 });
|
|
915
|
+
}
|
|
916
|
+
});
|
|
917
|
+
assertEquals(notAcceptableCalled, true);
|
|
918
|
+
assertEquals(response.status, 200);
|
|
919
|
+
assertEquals(await response.text(), "handled by onNotAcceptable");
|
|
920
|
+
});
|
|
921
|
+
esm_default.hardReset();
|
|
922
|
+
});
|
|
775
923
|
test("Federation.setInboxListeners()", async (t) => {
|
|
776
924
|
const kv = new MemoryKvStore();
|
|
777
925
|
esm_default.spyGlobal();
|
|
@@ -790,7 +938,7 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
790
938
|
await t.step("path match", () => {
|
|
791
939
|
const federation = createFederation({
|
|
792
940
|
kv,
|
|
793
|
-
|
|
941
|
+
documentLoaderFactory: () => mockDocumentLoader
|
|
794
942
|
});
|
|
795
943
|
federation.setInboxDispatcher("/users/{identifier}/inbox", () => ({ items: [] }));
|
|
796
944
|
assertThrows(() => federation.setInboxListeners("/users/{identifier}/inbox2"), RouterError);
|
|
@@ -798,7 +946,7 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
798
946
|
await t.step("wrong variables in path", () => {
|
|
799
947
|
const federation = createFederation({
|
|
800
948
|
kv,
|
|
801
|
-
|
|
949
|
+
documentLoaderFactory: () => mockDocumentLoader
|
|
802
950
|
});
|
|
803
951
|
assertThrows(() => federation.setInboxListeners("/users/inbox"), RouterError);
|
|
804
952
|
assertThrows(() => federation.setInboxListeners("/users/{identifier}/inbox/{id2}"), RouterError);
|
|
@@ -809,7 +957,7 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
809
957
|
const authenticatedRequests = [];
|
|
810
958
|
const federation = createFederation({
|
|
811
959
|
kv,
|
|
812
|
-
|
|
960
|
+
documentLoaderFactory: () => mockDocumentLoader,
|
|
813
961
|
authenticatedDocumentLoaderFactory(identity) {
|
|
814
962
|
const docLoader = getAuthenticatedDocumentLoader(identity);
|
|
815
963
|
return (url) => {
|
|
@@ -824,7 +972,10 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
824
972
|
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(Create, (ctx, create) => {
|
|
825
973
|
inbox.push([ctx, create]);
|
|
826
974
|
});
|
|
827
|
-
let response = await federation.fetch(new Request("https://example.com/inbox", {
|
|
975
|
+
let response = await federation.fetch(new Request("https://example.com/inbox", {
|
|
976
|
+
method: "POST",
|
|
977
|
+
headers: { "accept": "application/ld+json" }
|
|
978
|
+
}), { contextData: void 0 });
|
|
828
979
|
assertEquals(inbox, []);
|
|
829
980
|
assertEquals(response.status, 404);
|
|
830
981
|
federation.setActorDispatcher("/users/{identifier}", (_, identifier) => identifier === "john" ? new Person({}) : null).setKeyPairsDispatcher(() => [{
|
|
@@ -841,23 +992,37 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
841
992
|
});
|
|
842
993
|
response = await federation.fetch(new Request("https://example.com/inbox", {
|
|
843
994
|
method: "POST",
|
|
844
|
-
body: JSON.stringify(await activity().toJsonLd(options))
|
|
995
|
+
body: JSON.stringify(await activity().toJsonLd(options)),
|
|
996
|
+
headers: {
|
|
997
|
+
"accept": "application/ld+json",
|
|
998
|
+
"content-type": "application/ld+json"
|
|
999
|
+
}
|
|
845
1000
|
}), { contextData: void 0 });
|
|
846
1001
|
assertEquals(inbox, []);
|
|
847
1002
|
assertEquals(response.status, 401);
|
|
848
|
-
response = await federation.fetch(new Request("https://example.com/users/no-one/inbox", {
|
|
1003
|
+
response = await federation.fetch(new Request("https://example.com/users/no-one/inbox", {
|
|
1004
|
+
method: "POST",
|
|
1005
|
+
headers: { "accept": "application/ld+json" }
|
|
1006
|
+
}), { contextData: void 0 });
|
|
849
1007
|
assertEquals(inbox, []);
|
|
850
1008
|
assertEquals(response.status, 404);
|
|
851
1009
|
response = await federation.fetch(new Request("https://example.com/users/john/inbox", {
|
|
852
1010
|
method: "POST",
|
|
853
|
-
body: JSON.stringify(await activity().toJsonLd(options))
|
|
1011
|
+
body: JSON.stringify(await activity().toJsonLd(options)),
|
|
1012
|
+
headers: {
|
|
1013
|
+
"accept": "application/ld+json",
|
|
1014
|
+
"content-type": "application/ld+json"
|
|
1015
|
+
}
|
|
854
1016
|
}), { contextData: void 0 });
|
|
855
1017
|
assertEquals(inbox, []);
|
|
856
1018
|
assertEquals(response.status, 401);
|
|
857
1019
|
const activityPayload = await activity().toJsonLd(options);
|
|
858
1020
|
let request = new Request("https://example.com/users/john/inbox", {
|
|
859
1021
|
method: "POST",
|
|
860
|
-
headers: {
|
|
1022
|
+
headers: {
|
|
1023
|
+
"Content-Type": "application/activity+json",
|
|
1024
|
+
accept: "application/ld+json"
|
|
1025
|
+
},
|
|
861
1026
|
body: JSON.stringify(activityPayload)
|
|
862
1027
|
});
|
|
863
1028
|
request = await signRequest(request, rsaPrivateKey3, new URL("https://example.com/person2#key3"));
|
|
@@ -874,7 +1039,10 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
874
1039
|
inbox.shift();
|
|
875
1040
|
request = new Request("https://another.host/users/john/inbox", {
|
|
876
1041
|
method: "POST",
|
|
877
|
-
headers: {
|
|
1042
|
+
headers: {
|
|
1043
|
+
"Content-Type": "application/activity+json",
|
|
1044
|
+
"accept": "application/ld+json"
|
|
1045
|
+
},
|
|
878
1046
|
body: JSON.stringify(activityPayload)
|
|
879
1047
|
});
|
|
880
1048
|
request = await signRequest(request, rsaPrivateKey3, new URL("https://example.com/person2#key3"));
|
|
@@ -889,7 +1057,10 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
889
1057
|
inbox.shift();
|
|
890
1058
|
request = new Request("https://example.com/inbox", {
|
|
891
1059
|
method: "POST",
|
|
892
|
-
headers: {
|
|
1060
|
+
headers: {
|
|
1061
|
+
"Content-Type": "application/activity+json",
|
|
1062
|
+
"accept": "application/ld+json"
|
|
1063
|
+
},
|
|
893
1064
|
body: JSON.stringify(await activity().toJsonLd(options))
|
|
894
1065
|
});
|
|
895
1066
|
request = await signRequest(request, rsaPrivateKey3, new URL("https://example.com/person2#key3"));
|
|
@@ -904,7 +1075,10 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
904
1075
|
inbox.shift();
|
|
905
1076
|
request = new Request("https://example.com/users/john/inbox", {
|
|
906
1077
|
method: "POST",
|
|
907
|
-
headers: {
|
|
1078
|
+
headers: {
|
|
1079
|
+
"Content-Type": "application/activity+json",
|
|
1080
|
+
"accept": "application/ld+json"
|
|
1081
|
+
},
|
|
908
1082
|
body: JSON.stringify(await (await signObject(activity(), ed25519PrivateKey, ed25519Multikey.id, options)).toJsonLd(options))
|
|
909
1083
|
});
|
|
910
1084
|
response = await federation.fetch(request, { contextData: void 0 });
|
|
@@ -919,7 +1093,7 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
919
1093
|
await t.step("onError()", async () => {
|
|
920
1094
|
const federation = createFederation({
|
|
921
1095
|
kv,
|
|
922
|
-
|
|
1096
|
+
documentLoaderFactory: () => mockDocumentLoader,
|
|
923
1097
|
authenticatedDocumentLoaderFactory(identity) {
|
|
924
1098
|
const docLoader = getAuthenticatedDocumentLoader(identity);
|
|
925
1099
|
return (url) => {
|
|
@@ -943,7 +1117,10 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
943
1117
|
const activity = new Create({ actor: new URL("https://example.com/person") });
|
|
944
1118
|
let request = new Request("https://example.com/users/john/inbox", {
|
|
945
1119
|
method: "POST",
|
|
946
|
-
headers: {
|
|
1120
|
+
headers: {
|
|
1121
|
+
"Content-Type": "application/activity+json",
|
|
1122
|
+
"Accept": "application/activity+json"
|
|
1123
|
+
},
|
|
947
1124
|
body: JSON.stringify(await activity.toJsonLd({ contextLoader: mockDocumentLoader }))
|
|
948
1125
|
});
|
|
949
1126
|
request = await signRequest(request, rsaPrivateKey2, new URL("https://example.com/key2"));
|
|
@@ -959,7 +1136,7 @@ test("Federation.setInboxDispatcher()", async (t) => {
|
|
|
959
1136
|
await t.step("path match", () => {
|
|
960
1137
|
const federation = createFederation({
|
|
961
1138
|
kv,
|
|
962
|
-
|
|
1139
|
+
documentLoaderFactory: () => mockDocumentLoader
|
|
963
1140
|
});
|
|
964
1141
|
federation.setInboxListeners("/users/{identifier}/inbox");
|
|
965
1142
|
assertThrows(() => federation.setInboxDispatcher("/users/{identifier}/inbox2", () => ({ items: [] })), RouterError);
|
|
@@ -967,7 +1144,7 @@ test("Federation.setInboxDispatcher()", async (t) => {
|
|
|
967
1144
|
await t.step("path match", () => {
|
|
968
1145
|
const federation = createFederation({
|
|
969
1146
|
kv,
|
|
970
|
-
|
|
1147
|
+
documentLoaderFactory: () => mockDocumentLoader
|
|
971
1148
|
});
|
|
972
1149
|
federation.setInboxListeners("/users/{identifier}/inbox");
|
|
973
1150
|
federation.setInboxDispatcher("/users/{identifier}/inbox", () => ({ items: [] }));
|
|
@@ -975,7 +1152,7 @@ test("Federation.setInboxDispatcher()", async (t) => {
|
|
|
975
1152
|
await t.step("wrong variables in path", () => {
|
|
976
1153
|
const federation = createFederation({
|
|
977
1154
|
kv,
|
|
978
|
-
|
|
1155
|
+
documentLoaderFactory: () => mockDocumentLoader
|
|
979
1156
|
});
|
|
980
1157
|
assertThrows(() => federation.setInboxDispatcher("/users/inbox", () => ({ items: [] })), RouterError);
|
|
981
1158
|
assertThrows(() => federation.setInboxDispatcher("/users/{identifier}/inbox/{identifier2}", () => ({ items: [] })), RouterError);
|
|
@@ -1007,7 +1184,7 @@ test("FederationImpl.sendActivity()", async (t) => {
|
|
|
1007
1184
|
const kv = new MemoryKvStore();
|
|
1008
1185
|
const federation = new FederationImpl({
|
|
1009
1186
|
kv,
|
|
1010
|
-
|
|
1187
|
+
contextLoaderFactory: () => mockDocumentLoader
|
|
1011
1188
|
});
|
|
1012
1189
|
const context = federation.createContext(new URL("https://example.com/"));
|
|
1013
1190
|
await t.step("success", async () => {
|
|
@@ -1259,7 +1436,7 @@ test("ContextImpl.sendActivity()", async (t) => {
|
|
|
1259
1436
|
collectionSyncHeader = cl.request.headers.get("Collection-Synchronization");
|
|
1260
1437
|
const options = {
|
|
1261
1438
|
async documentLoader(url) {
|
|
1262
|
-
const response = await federation.fetch(new Request(url), { contextData: void 0 });
|
|
1439
|
+
const response = await federation.fetch(new Request(url, { headers: { "accept": "application/ld+json" } }), { contextData: void 0 });
|
|
1263
1440
|
if (response.ok) return {
|
|
1264
1441
|
contextUrl: null,
|
|
1265
1442
|
document: await response.json(),
|
|
@@ -1293,7 +1470,7 @@ test("ContextImpl.sendActivity()", async (t) => {
|
|
|
1293
1470
|
const kv = new MemoryKvStore();
|
|
1294
1471
|
const federation = new FederationImpl({
|
|
1295
1472
|
kv,
|
|
1296
|
-
|
|
1473
|
+
contextLoaderFactory: () => mockDocumentLoader
|
|
1297
1474
|
});
|
|
1298
1475
|
federation.setActorDispatcher("/{identifier}", async (ctx, identifier) => {
|
|
1299
1476
|
if (identifier !== "1") return null;
|
|
@@ -1402,7 +1579,7 @@ test("ContextImpl.sendActivity()", async (t) => {
|
|
|
1402
1579
|
};
|
|
1403
1580
|
const federation2 = new FederationImpl({
|
|
1404
1581
|
kv,
|
|
1405
|
-
|
|
1582
|
+
contextLoaderFactory: () => mockDocumentLoader,
|
|
1406
1583
|
queue
|
|
1407
1584
|
});
|
|
1408
1585
|
federation2.setActorDispatcher("/{identifier}", async (ctx, identifier) => {
|
|
@@ -1682,7 +1859,7 @@ test("InboxContextImpl.forwardActivity()", async (t) => {
|
|
|
1682
1859
|
const kv = new MemoryKvStore();
|
|
1683
1860
|
const federation = new FederationImpl({
|
|
1684
1861
|
kv,
|
|
1685
|
-
|
|
1862
|
+
contextLoaderFactory: () => mockDocumentLoader
|
|
1686
1863
|
});
|
|
1687
1864
|
await t.step("skip", async () => {
|
|
1688
1865
|
const activity = {
|