@fedify/fedify 2.0.0-dev.1485 → 2.0.0-dev.150
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/LICENSE +1 -1
- package/README.md +38 -18
- package/dist/actor-Bhc5FasL.cjs +42079 -0
- package/dist/{actor-7ivEf1H3.js → actor-C6cDxaJJ.js} +4 -1
- package/dist/{actor-DXTdNCfp.js → actor-DPvScYuz.js} +7058 -2722
- package/dist/{actor-C22bXuuC.d.ts → actor-DqFajh9s.d.ts} +2 -2
- package/dist/actor-f2NtjyCg.d.cts +128 -0
- package/dist/{assert-MZs1qjMx.js → assert-Dp5_aoAs.js} +1 -1
- package/dist/{assert_instance_of-DHz7EHNU.js → assert_instance_of-D1m8F7x0.js} +1 -1
- package/dist/{assert_not_equals-f3m3epl3.js → assert_not_equals-B2R_8p36.js} +1 -1
- package/dist/{assert_rejects-DiIiJbZn.js → assert_rejects-BoKYY0g1.js} +2 -2
- package/dist/{assert_is_error-BPGph1Jx.js → assert_throws-DjkXin1a.js} +32 -2
- package/dist/{builder-BPGqEvtB.js → builder-DcDoTCBH.js} +20 -8
- package/dist/chunk-DqRYRqnO.cjs +34 -0
- package/dist/chunk-HsBuZ-b2.js +41 -0
- package/dist/client-94iWEfQa.d.cts +222 -0
- package/dist/{client-DF8anIB5.d.ts → client-BsGzbnV-.d.ts} +3 -75
- package/dist/{client-g2FDBoeY.js → client-CD87uCL_.js} +4 -23
- package/dist/compat/mod.cjs +10 -0
- package/dist/compat/mod.d.cts +11 -0
- package/dist/compat/mod.d.ts +10 -12
- package/dist/compat/mod.js +5 -5
- package/dist/compat/transformers.test.js +29 -24
- package/dist/compat-DmDDELst.cjs +4 -0
- package/dist/compat-nxUqe4Z-.js +4 -0
- package/dist/context-DBQ7nMCw.d.cts +2449 -0
- package/dist/context-DpN-0qNU.js +109 -0
- package/dist/{context-DmlbRh9p.d.ts → context-mM0Nu5yo.d.ts} +335 -134
- package/dist/deno-DHmnBq8X.js +131 -0
- package/dist/{testing-BG_8Fyas.js → dist-lStjlyET.js} +73 -114
- package/dist/{authdocloader-D_IvQE4z.js → docloader-C2QNrF7j.js} +17 -8
- package/dist/{esm-CPZhxxGc.js → esm-B52TuumP.js} +32 -17
- package/dist/federation/builder.test.js +16 -16
- package/dist/federation/collection.test.js +9 -12
- package/dist/federation/handler.test.js +123 -152
- package/dist/federation/idempotency.test.js +206 -0
- package/dist/federation/inbox.test.js +7 -7
- package/dist/federation/keycache.test.js +7 -8
- package/dist/federation/kv.test.js +64 -12
- package/dist/federation/middleware.test.js +281 -99
- package/dist/federation/mod.cjs +27 -0
- package/dist/federation/mod.d.cts +11 -0
- package/dist/federation/mod.d.ts +11 -13
- package/dist/federation/mod.js +13 -15
- package/dist/federation/mq.test.js +12 -13
- package/dist/federation/negotiation.test.js +25 -0
- package/dist/federation/retry.test.js +4 -6
- package/dist/federation/router.test.js +9 -11
- package/dist/federation/send.test.js +61 -18
- package/dist/federation-CoW-KDKv.cjs +266 -0
- package/dist/{federation-CMX7WzeL.js → federation-D0hkM4T7.js} +25 -3
- package/dist/{http-zsOxPKCt.js → http-B1d-Jhbj.js} +260 -10
- package/dist/{http-DqSNLFNY.d.ts → http-BbO0ejuk.d.ts} +2 -2
- package/dist/http-CS6iqtXa.cjs +1106 -0
- package/dist/http-M8k5mKc0.d.cts +253 -0
- package/dist/{http-C7rxW7Kh.js → http-b10BrywC.js} +4 -3
- package/dist/{inbox-eK2W2MF3.js → inbox-gPnuScsy.js} +26 -7
- package/dist/{key-CYOcZ9G5.js → key-W6YaI4J_.js} +4 -2
- package/dist/{keycache-BLq6GT4_.js → keycache-DkTZcjkH.js} +1 -1
- package/dist/{keys-BIwlbtMN.js → keys-CfcSjjys.js} +2 -1
- package/dist/{kv-C7sopW2E.d.ts → kv-BpJND1Hr.d.ts} +30 -1
- package/dist/{kv-CRZrzyXm.js → kv-DaWUKuhD.js} +22 -0
- package/dist/kv-cD_d4hg-.d.cts +110 -0
- package/dist/kv-cache-C6NrTtII.js +107 -0
- package/dist/kv-cache-DhRe6qxQ.js +122 -0
- package/dist/kv-cache-a7LD3ze0.cjs +134 -0
- package/dist/{ld-DWwLYT4e.js → ld-UYagkye9.js} +7 -4
- package/dist/lookup-C-ajaa9S.js +256 -0
- package/dist/{lookup-DNQyH8UQ.js → lookup-CjgzNtAk.js} +33 -125
- package/dist/lookup-DI7YTXtl.cjs +268 -0
- package/dist/{lookup-BHYMosdS.js → lookup-DP8Hm9oD.js} +3 -1
- package/dist/middleware-Botvlnr6.js +31 -0
- package/dist/{middleware-DakCaqXu.js → middleware-C2V0Hmj1.js} +105 -188
- package/dist/middleware-D5o8ITlx.cjs +4237 -0
- package/dist/middleware-ESmU0CBL.cjs +15 -0
- package/dist/middleware-JqrIzuk6.js +15 -0
- package/dist/{middleware-BcVqlHyD.js → middleware-V7PNM-lv.js} +143 -136
- package/dist/mod-B-hUPT2N.d.cts +1 -0
- package/dist/{mod-Cxt4Kpf6.d.ts → mod-BlVovdcy.d.ts} +20 -2
- package/dist/mod-BxRCHTz-.d.cts +307 -0
- package/dist/mod-C58MZ7Wx.d.cts +113 -0
- package/dist/mod-CAdoBu0x.d.ts +109 -0
- package/dist/mod-CcDPcLJW.d.cts +1 -0
- package/dist/{mod-Drmz72EK.d.ts → mod-D5Z2tISD.d.ts} +3 -3
- package/dist/mod-DgxG-byT.d.cts +266 -0
- package/dist/{lookup-3czM5mmU.d.ts → mod-Ds0mpFZU.d.ts} +9 -2
- package/dist/mod-Dy2fJtmN.d.cts +80 -0
- package/dist/{mod-0EysZ-dJ.d.ts → mod-GetHzY6F.d.ts} +2 -2
- package/dist/mod-fxr25Gv7.d.cts +107 -0
- package/dist/mod.cjs +137 -0
- package/dist/mod.d.cts +15 -0
- package/dist/mod.d.ts +15 -18
- package/dist/mod.js +19 -21
- package/dist/negotiation-B4NJHk1f.js +71 -0
- package/dist/nodeinfo/client.test.js +32 -114
- package/dist/nodeinfo/handler.test.js +35 -30
- package/dist/nodeinfo/mod.cjs +10 -0
- package/dist/nodeinfo/mod.d.cts +3 -0
- package/dist/nodeinfo/mod.d.ts +3 -5
- package/dist/nodeinfo/mod.js +6 -7
- package/dist/nodeinfo/types.test.js +10 -18
- package/dist/nodeinfo-BnthBobC.js +4 -0
- package/dist/nodeinfo-CdN0rEnZ.cjs +4 -0
- package/dist/otel/exporter.test.js +899 -0
- package/dist/otel/mod.cjs +262 -0
- package/dist/otel/mod.d.cts +230 -0
- package/dist/otel/mod.d.ts +232 -0
- package/dist/otel/mod.js +261 -0
- package/dist/owner-B4HbyP8s.d.cts +67 -0
- package/dist/{owner-smArESGi.js → owner-DgNCw_Z-.js} +46 -8
- package/dist/{owner-CQPnQVtf.d.ts → owner-kQRGVXG1.d.ts} +3 -3
- package/dist/{proof-C6z-uqeO.js → proof-BwleRoo3.js} +5 -3
- package/dist/proof-M11sS3Oq.cjs +710 -0
- package/dist/{proof-CT1SITRP.js → proof-TlLZC_r7.js} +53 -16
- package/dist/router-CVRQXlZi.js +118 -0
- package/dist/{send-1zdmNlUo.js → send-BMU9B7Sm.js} +9 -4
- package/dist/sig/http.test.js +19 -17
- package/dist/sig/key.test.js +15 -14
- package/dist/sig/ld.test.js +13 -12
- package/dist/sig/mod.cjs +28 -0
- package/dist/sig/mod.d.cts +6 -0
- package/dist/sig/mod.d.ts +5 -7
- package/dist/sig/mod.js +8 -10
- package/dist/sig/owner.test.js +40 -15
- package/dist/sig/proof.test.js +19 -17
- package/dist/sig-C34-oHBl.js +4 -0
- package/dist/sig-YYj5tCnr.cjs +4 -0
- package/dist/{std__assert-X-_kMxKM.js → std__assert-Cm-MfI66.js} +1 -1
- package/dist/testing/mod.d.ts +410 -232
- package/dist/testing/mod.js +9 -4
- package/dist/{transformers-Dna8Fg7k.js → transformers-BFT6d7J5.js} +3 -3
- package/dist/transformers-CoBS-oFG.cjs +116 -0
- package/dist/type-BSNcIxTd.js +14 -0
- package/dist/{types-BzyGRkRt.js → types-BtUjyi5y.js} +9 -170
- package/dist/types-CWgzGaqk.cjs +315 -0
- package/dist/{types-BIgY6c-l.js → types-D2jhK2VG.js} +1 -3
- package/dist/{runtime/authdocloader.test.js → utils/docloader.test.js} +20 -18
- package/dist/utils/kv-cache.test.js +211 -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/utils-D-Va7aXC.js +4 -0
- package/dist/utils-DyRU1gdZ.cjs +4 -0
- package/dist/vocab/actor.test.js +15 -13
- package/dist/vocab/lookup.test.js +285 -12
- package/dist/vocab/mod.cjs +86 -0
- package/dist/vocab/mod.d.cts +4 -0
- package/dist/vocab/mod.d.ts +3 -5
- package/dist/vocab/mod.js +6 -7
- package/dist/vocab/type.test.js +4 -4
- package/dist/vocab/vocab.test.js +8058 -1987
- package/dist/{vocab-SOE1ifCr.d.ts → vocab-BCWe1Ih5.d.ts} +292 -21
- package/dist/vocab-CeDBzu-f.d.cts +14903 -0
- package/dist/{type-I68qwqmo.js → vocab-Durhw0Gx.js} +6947 -7381
- package/dist/{vocab-Bg1J3mu4.js → vocab-NOF1dCjQ.js} +32 -18
- package/dist/vocab-Vw1RxMp6.cjs +296 -0
- package/dist/webfinger/handler.test.js +62 -29
- package/dist/webfinger/lookup.test.js +11 -12
- package/dist/webfinger/mod.cjs +8 -0
- package/dist/webfinger/mod.d.cts +2 -0
- package/dist/webfinger/mod.d.ts +1 -4
- package/dist/webfinger/mod.js +5 -6
- package/dist/webfinger-C72Y8lrh.js +4 -0
- package/dist/webfinger-vAtLmxOF.cjs +4 -0
- package/package.json +81 -45
- package/dist/assert_throws-BOO88avQ.js +0 -39
- package/dist/authdocloader-Bq0gEHRj.js +0 -52
- package/dist/compat-Bb5myD13.js +0 -4
- package/dist/denokv-Bv33Xxea.js +0 -57
- package/dist/docloader-BlVueewg.js +0 -4615
- package/dist/docloader-CxWcuWqQ.d.ts +0 -221
- package/dist/fixtures/activitypub.academy/users/brauca_darradiul.json +0 -83
- package/dist/fixtures/example.com/announce.json +0 -6
- package/dist/fixtures/example.com/collection.json +0 -19
- package/dist/fixtures/example.com/create.json +0 -6
- package/dist/fixtures/example.com/cross-origin-actor.json +0 -6
- package/dist/fixtures/example.com/hong-gildong.json +0 -11
- package/dist/fixtures/example.com/invite.json +0 -7
- package/dist/fixtures/example.com/key.json +0 -7
- package/dist/fixtures/example.com/key2.json +0 -6
- package/dist/fixtures/example.com/object.json +0 -6
- package/dist/fixtures/example.com/orderedcollectionpage.json +0 -24
- package/dist/fixtures/example.com/paged/a.json +0 -13
- package/dist/fixtures/example.com/paged/b.json +0 -16
- package/dist/fixtures/example.com/paged-collection.json +0 -6
- package/dist/fixtures/example.com/person.json +0 -22
- package/dist/fixtures/example.com/person2.json +0 -40
- package/dist/fixtures/example.com/test.json +0 -5
- package/dist/fixtures/example.com/users/handle.json +0 -16
- package/dist/fixtures/example.com/wrong-type.json +0 -3
- package/dist/fixtures/oeee.cafe/ap/users/3609fd4e-d51d-4db8-9f04-4189815864dd.json +0 -24
- package/dist/fixtures/remote.domain/users/bob.json +0 -20
- package/dist/fixtures/server.example/users/alice.json +0 -20
- package/dist/fixtures/w3id.org/identity/v1.json +0 -152
- package/dist/fixtures/w3id.org/security/data-integrity/v1.json +0 -74
- package/dist/fixtures/w3id.org/security/multikey/v1.json +0 -35
- package/dist/fixtures/w3id.org/security/v1.json +0 -50
- package/dist/fixtures/wizard.casa/users/hongminhee.json +0 -69
- package/dist/fixtures/www.w3.org/ns/activitystreams.json +0 -379
- package/dist/fixtures/www.w3.org/ns/did/v1.json +0 -58
- package/dist/key-Dn7Lram-.js +0 -260
- package/dist/key-S7WllAWz.js +0 -10
- package/dist/key-rRCUafNm.js +0 -10
- package/dist/middleware-CWbGhXnl.js +0 -26
- package/dist/middleware-D-OlNiyj.js +0 -17
- package/dist/mod-TFoH2Ql8.d.ts +0 -104
- package/dist/mod-g0xFzAP9.d.ts +0 -2
- package/dist/mq-CRGm1e_F.d.ts +0 -143
- package/dist/nodeinfo/semver.test.js +0 -143
- package/dist/nodeinfo-CyEbLjHs.js +0 -4
- package/dist/runtime/docloader.test.js +0 -522
- package/dist/runtime/key.test.js +0 -103
- package/dist/runtime/langstr.test.d.ts +0 -3
- package/dist/runtime/langstr.test.js +0 -39
- 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/runtime-BSkOVUWM.js +0 -4
- package/dist/semver-dArNLkR9.js +0 -149
- package/dist/sig-BXJO--F9.js +0 -4
- package/dist/src/vocab/accept.yaml +0 -15
- package/dist/src/vocab/activity.yaml +0 -98
- package/dist/src/vocab/add.yaml +0 -16
- package/dist/src/vocab/announce.yaml +0 -30
- package/dist/src/vocab/application.yaml +0 -324
- package/dist/src/vocab/arrive.yaml +0 -15
- package/dist/src/vocab/article.yaml +0 -46
- package/dist/src/vocab/audio.yaml +0 -11
- package/dist/src/vocab/block.yaml +0 -16
- package/dist/src/vocab/chatmessage.yaml +0 -50
- package/dist/src/vocab/collection.yaml +0 -154
- package/dist/src/vocab/collectionpage.yaml +0 -55
- package/dist/src/vocab/create.yaml +0 -28
- package/dist/src/vocab/dataintegrityproof.yaml +0 -56
- package/dist/src/vocab/delete.yaml +0 -27
- package/dist/src/vocab/didservice.yaml +0 -22
- package/dist/src/vocab/dislike.yaml +0 -14
- package/dist/src/vocab/document.yaml +0 -31
- package/dist/src/vocab/emoji.yaml +0 -12
- package/dist/src/vocab/emojireact.yaml +0 -17
- package/dist/src/vocab/endpoints.yaml +0 -85
- package/dist/src/vocab/event.yaml +0 -11
- package/dist/src/vocab/export.yaml +0 -9
- package/dist/src/vocab/flag.yaml +0 -15
- package/dist/src/vocab/follow.yaml +0 -19
- package/dist/src/vocab/group.yaml +0 -324
- package/dist/src/vocab/hashtag.yaml +0 -14
- package/dist/src/vocab/ignore.yaml +0 -14
- package/dist/src/vocab/image.yaml +0 -9
- package/dist/src/vocab/intransitiveactivity.yaml +0 -15
- package/dist/src/vocab/invite.yaml +0 -14
- package/dist/src/vocab/join.yaml +0 -14
- package/dist/src/vocab/key.yaml +0 -28
- package/dist/src/vocab/leave.yaml +0 -14
- package/dist/src/vocab/like.yaml +0 -16
- package/dist/src/vocab/link.yaml +0 -101
- package/dist/src/vocab/listen.yaml +0 -12
- package/dist/src/vocab/mention.yaml +0 -9
- package/dist/src/vocab/move.yaml +0 -15
- package/dist/src/vocab/multikey.yaml +0 -36
- package/dist/src/vocab/note.yaml +0 -48
- package/dist/src/vocab/object.yaml +0 -404
- package/dist/src/vocab/offer.yaml +0 -15
- package/dist/src/vocab/orderedcollection.yaml +0 -39
- package/dist/src/vocab/orderedcollectionpage.yaml +0 -50
- package/dist/src/vocab/organization.yaml +0 -324
- package/dist/src/vocab/page.yaml +0 -11
- package/dist/src/vocab/person.yaml +0 -324
- package/dist/src/vocab/place.yaml +0 -75
- package/dist/src/vocab/profile.yaml +0 -26
- package/dist/src/vocab/propertyvalue.yaml +0 -32
- package/dist/src/vocab/question.yaml +0 -103
- package/dist/src/vocab/read.yaml +0 -13
- package/dist/src/vocab/reject.yaml +0 -14
- package/dist/src/vocab/relationship.yaml +0 -52
- package/dist/src/vocab/remove.yaml +0 -14
- package/dist/src/vocab/service.yaml +0 -324
- package/dist/src/vocab/source.yaml +0 -26
- package/dist/src/vocab/tentativeaccept.yaml +0 -14
- package/dist/src/vocab/tentativereject.yaml +0 -14
- package/dist/src/vocab/tombstone.yaml +0 -24
- package/dist/src/vocab/travel.yaml +0 -16
- package/dist/src/vocab/undo.yaml +0 -26
- package/dist/src/vocab/update.yaml +0 -58
- package/dist/src/vocab/video.yaml +0 -11
- package/dist/src/vocab/view.yaml +0 -13
- package/dist/testing/docloader.test.js +0 -24
- package/dist/vocab/schema.yaml +0 -247
- package/dist/webfinger-C3GIyXIg.js +0 -4
- 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.d.ts +0 -56
- package/dist/x/hono.js +0 -60
- package/dist/x/sveltekit.d.ts +0 -48
- package/dist/x/sveltekit.js +0 -68
- /package/dist/{assert_equals-DSbWqCm3.js → assert_equals-Gbplq4lg.js} +0 -0
- /package/dist/{collection-CSzG2j1P.js → collection-CrkRM5Ep.js} +0 -0
- /package/dist/{nodeinfo/semver.test.d.ts → federation/idempotency.test.d.ts} +0 -0
- /package/dist/{runtime/authdocloader.test.d.ts → federation/negotiation.test.d.ts} +0 -0
- /package/dist/{mod-1pDWKvUL.d.ts → mod-CVgZgliM.d.ts} +0 -0
- /package/dist/{mod-GIh5OYxW.d.ts → mod-bjzj5QIb.d.ts} +0 -0
- /package/dist/{runtime/docloader.test.d.ts → otel/exporter.test.d.ts} +0 -0
- /package/dist/{retry-D4GJ670a.js → retry-Bz5pP75o.js} +0 -0
- /package/dist/{testing → utils}/docloader.test.d.ts +0 -0
- /package/dist/{runtime/key.test.d.ts → utils/kv-cache.test.d.ts} +0 -0
|
@@ -3,39 +3,56 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import { assertEquals } from "../assert_equals-
|
|
8
|
-
import { assert } from "../assert-
|
|
9
|
-
import { assertInstanceOf } from "../assert_instance_of-
|
|
10
|
-
import { MemoryKvStore } from "../kv-
|
|
11
|
-
import
|
|
12
|
-
import "../
|
|
13
|
-
import "../client-
|
|
14
|
-
import { RouterError
|
|
15
|
-
import "../types-
|
|
16
|
-
import "../
|
|
17
|
-
import "../
|
|
18
|
-
import {
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import "../
|
|
24
|
-
import "../
|
|
25
|
-
import "../
|
|
26
|
-
import "../
|
|
27
|
-
import "../
|
|
28
|
-
import "../
|
|
29
|
-
import
|
|
30
|
-
import
|
|
31
|
-
import
|
|
32
|
-
import "../
|
|
33
|
-
import
|
|
34
|
-
import
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
6
|
+
import { mockDocumentLoader, test } from "../dist-lStjlyET.js";
|
|
7
|
+
import { assertEquals } from "../assert_equals-Gbplq4lg.js";
|
|
8
|
+
import { assert } from "../assert-Dp5_aoAs.js";
|
|
9
|
+
import { assertInstanceOf } from "../assert_instance_of-D1m8F7x0.js";
|
|
10
|
+
import { MemoryKvStore } from "../kv-DaWUKuhD.js";
|
|
11
|
+
import "../deno-DHmnBq8X.js";
|
|
12
|
+
import { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer, createFederation } from "../middleware-C2V0Hmj1.js";
|
|
13
|
+
import "../client-CD87uCL_.js";
|
|
14
|
+
import { RouterError } from "../router-CVRQXlZi.js";
|
|
15
|
+
import "../types-D2jhK2VG.js";
|
|
16
|
+
import { Activity, Announce, Create, Invite, Multikey, Note, Object as Object$1, Offer, Person } from "../vocab-Durhw0Gx.js";
|
|
17
|
+
import "../lookup-DP8Hm9oD.js";
|
|
18
|
+
import { getTypeId } from "../type-BSNcIxTd.js";
|
|
19
|
+
import "../actor-C6cDxaJJ.js";
|
|
20
|
+
import "../key-W6YaI4J_.js";
|
|
21
|
+
import { signRequest, verifyRequest } from "../http-b10BrywC.js";
|
|
22
|
+
import { detachSignature, signJsonLd, verifyJsonLd } from "../ld-UYagkye9.js";
|
|
23
|
+
import { doesActorOwnKey } from "../owner-DgNCw_Z-.js";
|
|
24
|
+
import { signObject, verifyObject } from "../proof-BwleRoo3.js";
|
|
25
|
+
import { fetchDocumentLoader, getAuthenticatedDocumentLoader } from "../docloader-C2QNrF7j.js";
|
|
26
|
+
import "../kv-cache-C6NrTtII.js";
|
|
27
|
+
import { lookupObject } from "../lookup-CjgzNtAk.js";
|
|
28
|
+
import "../inbox-gPnuScsy.js";
|
|
29
|
+
import "../builder-DcDoTCBH.js";
|
|
30
|
+
import "../collection-CrkRM5Ep.js";
|
|
31
|
+
import "../keycache-DkTZcjkH.js";
|
|
32
|
+
import "../negotiation-B4NJHk1f.js";
|
|
33
|
+
import "../retry-Bz5pP75o.js";
|
|
34
|
+
import "../send-BMU9B7Sm.js";
|
|
35
|
+
import { assertStrictEquals } from "../std__assert-Cm-MfI66.js";
|
|
36
|
+
import { assertFalse, assertRejects } from "../assert_rejects-BoKYY0g1.js";
|
|
37
|
+
import { assertThrows } from "../assert_throws-DjkXin1a.js";
|
|
38
|
+
import { assertNotEquals } from "../assert_not_equals-B2R_8p36.js";
|
|
39
|
+
import { ed25519Multikey, ed25519PrivateKey, ed25519PublicKey, rsaPrivateKey2, rsaPrivateKey3, rsaPublicKey2, rsaPublicKey3 } from "../keys-CfcSjjys.js";
|
|
40
|
+
import { esm_default } from "../esm-B52TuumP.js";
|
|
37
41
|
|
|
38
|
-
//#region src/
|
|
42
|
+
//#region ../fixture/src/fixtures/example.com/create.json
|
|
43
|
+
var __context$2 = "https://www.w3.org/ns/activitystreams";
|
|
44
|
+
var type$2 = "Create";
|
|
45
|
+
var id$2 = "https://example.com/create";
|
|
46
|
+
var actor = "https://example.com/person";
|
|
47
|
+
var create_default = {
|
|
48
|
+
"@context": __context$2,
|
|
49
|
+
type: type$2,
|
|
50
|
+
id: id$2,
|
|
51
|
+
actor
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region ../fixture/src/fixtures/example.com/person.json
|
|
39
56
|
var __context$1 = ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"];
|
|
40
57
|
var id$1 = "https://example.com/person";
|
|
41
58
|
var type$1 = "Person";
|
|
@@ -59,7 +76,7 @@ var person_default = {
|
|
|
59
76
|
};
|
|
60
77
|
|
|
61
78
|
//#endregion
|
|
62
|
-
//#region src/
|
|
79
|
+
//#region ../fixture/src/fixtures/example.com/person2.json
|
|
63
80
|
var __context = [
|
|
64
81
|
"https://www.w3.org/ns/activitystreams",
|
|
65
82
|
"https://w3id.org/security/v1",
|
|
@@ -108,12 +125,7 @@ test("createFederation()", async (t) => {
|
|
|
108
125
|
await t.step("allowPrivateAddress", () => {
|
|
109
126
|
assertThrows(() => createFederation({
|
|
110
127
|
kv,
|
|
111
|
-
|
|
112
|
-
allowPrivateAddress: true
|
|
113
|
-
}), TypeError);
|
|
114
|
-
assertThrows(() => createFederation({
|
|
115
|
-
kv,
|
|
116
|
-
contextLoader: mockDocumentLoader,
|
|
128
|
+
contextLoaderFactory: () => mockDocumentLoader,
|
|
117
129
|
allowPrivateAddress: true
|
|
118
130
|
}), TypeError);
|
|
119
131
|
assertThrows(() => createFederation({
|
|
@@ -223,11 +235,8 @@ test({
|
|
|
223
235
|
},
|
|
224
236
|
async fn(t) {
|
|
225
237
|
const kv = new MemoryKvStore();
|
|
226
|
-
const documentLoader = (url) => {
|
|
227
|
-
throw new FetchError(new URL(url), "Not found");
|
|
228
|
-
};
|
|
229
238
|
esm_default.spyGlobal();
|
|
230
|
-
esm_default.get("https://example.com/
|
|
239
|
+
esm_default.get("https://example.com/auth-check", async (cl) => {
|
|
231
240
|
const v = await verifyRequest(cl.request, {
|
|
232
241
|
contextLoader: mockDocumentLoader,
|
|
233
242
|
documentLoader: mockDocumentLoader,
|
|
@@ -236,10 +245,11 @@ test({
|
|
|
236
245
|
return new Response(JSON.stringify(v != null), { headers: { "Content-Type": "application/json" } });
|
|
237
246
|
});
|
|
238
247
|
await t.step("Context", async () => {
|
|
248
|
+
const rejectingLoader = (_url) => Promise.reject(/* @__PURE__ */ new Error("Not found"));
|
|
239
249
|
const federation = createFederation({
|
|
240
250
|
kv,
|
|
241
|
-
|
|
242
|
-
|
|
251
|
+
documentLoaderFactory: () => rejectingLoader,
|
|
252
|
+
contextLoaderFactory: () => mockDocumentLoader
|
|
243
253
|
});
|
|
244
254
|
let ctx = federation.createContext(new URL("https://example.com:1234/"), 123);
|
|
245
255
|
assertEquals(ctx.data, 123);
|
|
@@ -247,7 +257,7 @@ test({
|
|
|
247
257
|
assertEquals(ctx.canonicalOrigin, "https://example.com:1234");
|
|
248
258
|
assertEquals(ctx.host, "example.com:1234");
|
|
249
259
|
assertEquals(ctx.hostname, "example.com");
|
|
250
|
-
assertStrictEquals(ctx.documentLoader,
|
|
260
|
+
assertStrictEquals(ctx.documentLoader, rejectingLoader);
|
|
251
261
|
assertStrictEquals(ctx.contextLoader, mockDocumentLoader);
|
|
252
262
|
assertStrictEquals(ctx.federation, federation);
|
|
253
263
|
assertThrows(() => ctx.getNodeInfoUri(), RouterError);
|
|
@@ -273,11 +283,7 @@ test({
|
|
|
273
283
|
federation.setNodeInfoDispatcher("/nodeinfo/2.1", () => ({
|
|
274
284
|
software: {
|
|
275
285
|
name: "Example",
|
|
276
|
-
version:
|
|
277
|
-
major: 1,
|
|
278
|
-
minor: 2,
|
|
279
|
-
patch: 3
|
|
280
|
-
}
|
|
286
|
+
version: "1.2.3"
|
|
281
287
|
},
|
|
282
288
|
protocols: ["activitypub"],
|
|
283
289
|
usage: {
|
|
@@ -332,33 +338,39 @@ test({
|
|
|
332
338
|
})
|
|
333
339
|
}]);
|
|
334
340
|
const loader = await ctx.getDocumentLoader({ identifier: "handle" });
|
|
335
|
-
assertEquals(await loader("https://example.com/
|
|
341
|
+
assertEquals(await loader("https://example.com/auth-check"), {
|
|
336
342
|
contextUrl: null,
|
|
337
|
-
documentUrl: "https://example.com/
|
|
343
|
+
documentUrl: "https://example.com/auth-check",
|
|
338
344
|
document: true
|
|
339
345
|
});
|
|
340
346
|
const loader2 = await ctx.getDocumentLoader({ username: "HANDLE" });
|
|
341
|
-
assertEquals(await loader2("https://example.com/
|
|
347
|
+
assertEquals(await loader2("https://example.com/auth-check"), {
|
|
342
348
|
contextUrl: null,
|
|
343
|
-
documentUrl: "https://example.com/
|
|
349
|
+
documentUrl: "https://example.com/auth-check",
|
|
344
350
|
document: true
|
|
345
351
|
});
|
|
346
352
|
const loader3 = ctx.getDocumentLoader({
|
|
347
353
|
keyId: new URL("https://example.com/key2"),
|
|
348
354
|
privateKey: rsaPrivateKey2
|
|
349
355
|
});
|
|
350
|
-
assertEquals(await loader3("https://example.com/
|
|
356
|
+
assertEquals(await loader3("https://example.com/auth-check"), {
|
|
351
357
|
contextUrl: null,
|
|
352
|
-
documentUrl: "https://example.com/
|
|
358
|
+
documentUrl: "https://example.com/auth-check",
|
|
353
359
|
document: true
|
|
354
360
|
});
|
|
355
361
|
assertEquals(await ctx.lookupObject("https://example.com/object"), null);
|
|
356
362
|
await assertRejects(() => ctx.sendActivity({ identifier: "handle" }, [], new Create({})), TypeError, "The activity to send must have at least one actor property.");
|
|
357
363
|
await ctx.sendActivity({ identifier: "handle" }, [], new Create({ actor: new URL("https://example.com/users/handle") }));
|
|
364
|
+
esm_default.get("https://example.com/object", () => new Response(JSON.stringify({
|
|
365
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
366
|
+
type: "Object",
|
|
367
|
+
id: "https://example.com/object",
|
|
368
|
+
name: "Fetched object"
|
|
369
|
+
}), { headers: { "Content-Type": "application/activity+json" } }));
|
|
358
370
|
const federation2 = createFederation({
|
|
359
371
|
kv,
|
|
360
|
-
|
|
361
|
-
|
|
372
|
+
documentLoaderFactory: () => fetchDocumentLoader,
|
|
373
|
+
contextLoaderFactory: () => mockDocumentLoader
|
|
362
374
|
});
|
|
363
375
|
const ctx2 = federation2.createContext(new URL("https://example.com/"), 123);
|
|
364
376
|
assertEquals(await ctx2.lookupObject("https://example.com/object"), new Object$1({
|
|
@@ -457,8 +469,8 @@ test({
|
|
|
457
469
|
const federation = createFederation({
|
|
458
470
|
kv,
|
|
459
471
|
origin: "https://ap.example.com",
|
|
460
|
-
|
|
461
|
-
|
|
472
|
+
documentLoaderFactory: () => mockDocumentLoader,
|
|
473
|
+
contextLoaderFactory: () => mockDocumentLoader
|
|
462
474
|
});
|
|
463
475
|
const ctx = federation.createContext(new URL("https://example.com:1234/"));
|
|
464
476
|
assertEquals(ctx.origin, "https://example.com:1234");
|
|
@@ -468,11 +480,7 @@ test({
|
|
|
468
480
|
federation.setNodeInfoDispatcher("/nodeinfo/2.1", () => ({
|
|
469
481
|
software: {
|
|
470
482
|
name: "Example",
|
|
471
|
-
version:
|
|
472
|
-
major: 1,
|
|
473
|
-
minor: 2,
|
|
474
|
-
patch: 3
|
|
475
|
-
}
|
|
483
|
+
version: "1.2.3"
|
|
476
484
|
},
|
|
477
485
|
protocols: ["activitypub"],
|
|
478
486
|
usage: {
|
|
@@ -662,13 +670,7 @@ test({
|
|
|
662
670
|
assertEquals(nodeInfo, {
|
|
663
671
|
software: {
|
|
664
672
|
name: "foo",
|
|
665
|
-
version:
|
|
666
|
-
major: 1,
|
|
667
|
-
minor: 2,
|
|
668
|
-
patch: 3,
|
|
669
|
-
build: [],
|
|
670
|
-
prerelease: []
|
|
671
|
-
}
|
|
673
|
+
version: "1.2.3"
|
|
672
674
|
},
|
|
673
675
|
protocols: ["activitypub", "diaspora"],
|
|
674
676
|
usage: {
|
|
@@ -694,9 +696,9 @@ test({
|
|
|
694
696
|
await t.step("RequestContext", async () => {
|
|
695
697
|
const federation = createFederation({
|
|
696
698
|
kv,
|
|
697
|
-
|
|
699
|
+
documentLoaderFactory: () => mockDocumentLoader
|
|
698
700
|
});
|
|
699
|
-
const req = new Request("https://example.com/");
|
|
701
|
+
const req = new Request("https://example.com/", { headers: { "accept": "application/ld+json" } });
|
|
700
702
|
const ctx = federation.createContext(req, 123);
|
|
701
703
|
assertEquals(ctx.request, req);
|
|
702
704
|
assertEquals(ctx.url, new URL("https://example.com/"));
|
|
@@ -714,7 +716,7 @@ test({
|
|
|
714
716
|
assertEquals(await ctx.getSignedKey(), null);
|
|
715
717
|
assertEquals(await ctx.getSignedKeyOwner(), null);
|
|
716
718
|
await assertRejects(() => ctx.getActor("someone"), Error, "No actor dispatcher registered");
|
|
717
|
-
const signedReq = await signRequest(new Request("https://example.com/"), rsaPrivateKey2, rsaPublicKey2.id);
|
|
719
|
+
const signedReq = await signRequest(new Request("https://example.com/", { headers: { "accept": "application/ld+json" } }), rsaPrivateKey2, rsaPublicKey2.id);
|
|
718
720
|
const signedCtx = federation.createContext(signedReq, 456);
|
|
719
721
|
assertEquals(signedCtx.request, signedReq);
|
|
720
722
|
assertEquals(signedCtx.url, new URL("https://example.com/"));
|
|
@@ -723,7 +725,7 @@ test({
|
|
|
723
725
|
assertEquals(await signedCtx.getSignedKeyOwner(), null);
|
|
724
726
|
assertEquals(await signedCtx.getSignedKey(), rsaPublicKey2);
|
|
725
727
|
assertEquals(await signedCtx.getSignedKeyOwner(), null);
|
|
726
|
-
const signedReq2 = await signRequest(new Request("https://example.com/"), rsaPrivateKey3, rsaPublicKey3.id);
|
|
728
|
+
const signedReq2 = await signRequest(new Request("https://example.com/", { headers: { "accept": "application/ld+json" } }), rsaPrivateKey3, rsaPublicKey3.id);
|
|
727
729
|
const signedCtx2 = federation.createContext(signedReq2, 456);
|
|
728
730
|
assertEquals(signedCtx2.request, signedReq2);
|
|
729
731
|
assertEquals(signedCtx2.url, new URL("https://example.com/"));
|
|
@@ -756,7 +758,7 @@ test({
|
|
|
756
758
|
});
|
|
757
759
|
await t.step("RequestContext.clone()", () => {
|
|
758
760
|
const federation = createFederation({ kv });
|
|
759
|
-
const req = new Request("https://example.com/");
|
|
761
|
+
const req = new Request("https://example.com/", { headers: { "accept": "application/ld+json" } });
|
|
760
762
|
const ctx = federation.createContext(req, 123);
|
|
761
763
|
const clone = ctx.clone(456);
|
|
762
764
|
assertStrictEquals(clone.request, ctx.request);
|
|
@@ -772,6 +774,157 @@ test({
|
|
|
772
774
|
esm_default.hardReset();
|
|
773
775
|
}
|
|
774
776
|
});
|
|
777
|
+
test("Federation.fetch()", async (t) => {
|
|
778
|
+
esm_default.spyGlobal();
|
|
779
|
+
esm_default.get("https://example.com/key2", {
|
|
780
|
+
headers: { "Content-Type": "application/activity+json" },
|
|
781
|
+
body: await rsaPublicKey2.toJsonLd({ contextLoader: mockDocumentLoader })
|
|
782
|
+
});
|
|
783
|
+
esm_default.get("begin:https://example.com/person", {
|
|
784
|
+
headers: { "Content-Type": "application/activity+json" },
|
|
785
|
+
body: person_default
|
|
786
|
+
});
|
|
787
|
+
const createTestContext = () => {
|
|
788
|
+
const kv = new MemoryKvStore();
|
|
789
|
+
const inbox = [];
|
|
790
|
+
const dispatches = [];
|
|
791
|
+
const federation = createFederation({
|
|
792
|
+
kv,
|
|
793
|
+
documentLoaderFactory: () => mockDocumentLoader,
|
|
794
|
+
authenticatedDocumentLoaderFactory(identity) {
|
|
795
|
+
const docLoader = getAuthenticatedDocumentLoader(identity);
|
|
796
|
+
return (url) => {
|
|
797
|
+
const urlObj = new URL(url);
|
|
798
|
+
if (urlObj.host === "example.com") return docLoader(url);
|
|
799
|
+
return mockDocumentLoader(url);
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
});
|
|
803
|
+
federation.setActorDispatcher("/users/{identifier}", (ctx, identifier) => {
|
|
804
|
+
dispatches.push(identifier);
|
|
805
|
+
return new Person({
|
|
806
|
+
id: ctx.getActorUri(identifier),
|
|
807
|
+
inbox: ctx.getInboxUri(identifier),
|
|
808
|
+
preferredUsername: identifier
|
|
809
|
+
});
|
|
810
|
+
}).setKeyPairsDispatcher(() => {
|
|
811
|
+
return [{
|
|
812
|
+
privateKey: rsaPrivateKey2,
|
|
813
|
+
publicKey: rsaPublicKey2.publicKey
|
|
814
|
+
}];
|
|
815
|
+
});
|
|
816
|
+
federation.setInboxDispatcher("/users/{identifier}/inbox", () => {
|
|
817
|
+
return { items: [] };
|
|
818
|
+
});
|
|
819
|
+
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(Create, (_ctx, activity) => {
|
|
820
|
+
inbox.push(activity.id.toString());
|
|
821
|
+
return;
|
|
822
|
+
});
|
|
823
|
+
return {
|
|
824
|
+
federation,
|
|
825
|
+
inbox,
|
|
826
|
+
dispatches
|
|
827
|
+
};
|
|
828
|
+
};
|
|
829
|
+
await t.step("GET without accepts header", async () => {
|
|
830
|
+
const { federation, dispatches } = createTestContext();
|
|
831
|
+
const response = await federation.fetch(new Request("https://example.com/users/actor", { method: "GET" }), { contextData: void 0 });
|
|
832
|
+
assertEquals(dispatches, []);
|
|
833
|
+
assertEquals(response.status, 406);
|
|
834
|
+
});
|
|
835
|
+
await t.step("POST with application/json", async () => {
|
|
836
|
+
const { federation, inbox } = createTestContext();
|
|
837
|
+
const request = await signRequest(new Request("https://example.com/users/json/inbox", {
|
|
838
|
+
method: "POST",
|
|
839
|
+
headers: {
|
|
840
|
+
"Accept": "application/json",
|
|
841
|
+
"Content-Type": "application/json"
|
|
842
|
+
},
|
|
843
|
+
body: JSON.stringify(create_default)
|
|
844
|
+
}), rsaPrivateKey2, rsaPublicKey2.id);
|
|
845
|
+
const response = await federation.fetch(request, { contextData: void 0 });
|
|
846
|
+
assertEquals(response.status, 202);
|
|
847
|
+
assertEquals(inbox.length, 1, "Expected one item in the inbox, json");
|
|
848
|
+
assertEquals(inbox[0], create_default.id);
|
|
849
|
+
});
|
|
850
|
+
await t.step("GET with application/json", async () => {
|
|
851
|
+
const { federation, dispatches } = createTestContext();
|
|
852
|
+
const response = await federation.fetch(new Request("https://example.com/users/json", {
|
|
853
|
+
method: "GET",
|
|
854
|
+
headers: { "Accept": "application/json" }
|
|
855
|
+
}), { contextData: void 0 });
|
|
856
|
+
assertEquals(dispatches, ["json"]);
|
|
857
|
+
assertEquals(response.status, 200);
|
|
858
|
+
});
|
|
859
|
+
await t.step("POST with application/ld+json", async () => {
|
|
860
|
+
const { federation, inbox } = createTestContext();
|
|
861
|
+
const request = await signRequest(new Request("https://example.com/users/ld/inbox", {
|
|
862
|
+
method: "POST",
|
|
863
|
+
headers: {
|
|
864
|
+
"Accept": "application/ld+json",
|
|
865
|
+
"Content-Type": "application/activity+json"
|
|
866
|
+
},
|
|
867
|
+
body: JSON.stringify(create_default)
|
|
868
|
+
}), rsaPrivateKey2, rsaPublicKey2.id);
|
|
869
|
+
const response = await federation.fetch(request, { contextData: void 0 });
|
|
870
|
+
assertEquals(response.status, 202);
|
|
871
|
+
assertEquals(inbox.length, 1, "Expected one inbox activity, ld+json");
|
|
872
|
+
assertEquals(inbox[0], create_default.id);
|
|
873
|
+
});
|
|
874
|
+
await t.step("GET with application/ld+json", async () => {
|
|
875
|
+
const { federation, dispatches } = createTestContext();
|
|
876
|
+
const request = new Request("https://example.com/users/ld", {
|
|
877
|
+
method: "GET",
|
|
878
|
+
headers: { "Accept": "application/ld+json" }
|
|
879
|
+
});
|
|
880
|
+
const response = await federation.fetch(request, { contextData: void 0 });
|
|
881
|
+
assertEquals(dispatches, ["ld"]);
|
|
882
|
+
assertEquals(response.status, 200);
|
|
883
|
+
});
|
|
884
|
+
await t.step("POST with application/activity+json", async () => {
|
|
885
|
+
const { federation, inbox } = createTestContext();
|
|
886
|
+
const request = await signRequest(new Request("https://example.com/users/activity/inbox", {
|
|
887
|
+
method: "POST",
|
|
888
|
+
headers: {
|
|
889
|
+
"Accept": "application/activity+json",
|
|
890
|
+
"Content-Type": "application/activity+json"
|
|
891
|
+
},
|
|
892
|
+
body: JSON.stringify(create_default)
|
|
893
|
+
}), rsaPrivateKey2, rsaPublicKey2.id);
|
|
894
|
+
const response = await federation.fetch(request, { contextData: void 0 });
|
|
895
|
+
assertEquals(response.status, 202);
|
|
896
|
+
assertEquals(inbox.length, 1);
|
|
897
|
+
assertEquals(inbox[0], create_default.id);
|
|
898
|
+
});
|
|
899
|
+
await t.step("GET with application/activity+json", async () => {
|
|
900
|
+
const { federation, dispatches } = createTestContext();
|
|
901
|
+
const request = new Request("https://example.com/users/activity", {
|
|
902
|
+
method: "GET",
|
|
903
|
+
headers: { "Accept": "application/ld+json" }
|
|
904
|
+
});
|
|
905
|
+
const response = await federation.fetch(request, { contextData: void 0 });
|
|
906
|
+
assertEquals(dispatches, ["activity"]);
|
|
907
|
+
assertEquals(response.status, 200);
|
|
908
|
+
});
|
|
909
|
+
await t.step("onNotAcceptable with GET", async () => {
|
|
910
|
+
const { federation } = createTestContext();
|
|
911
|
+
let notAcceptableCalled = false;
|
|
912
|
+
const response = await federation.fetch(new Request("https://example.com/users/html", {
|
|
913
|
+
method: "GET",
|
|
914
|
+
headers: { "Accept": "text/html" }
|
|
915
|
+
}), {
|
|
916
|
+
contextData: void 0,
|
|
917
|
+
onNotAcceptable: () => {
|
|
918
|
+
notAcceptableCalled = true;
|
|
919
|
+
return new Response("handled by onNotAcceptable", { status: 200 });
|
|
920
|
+
}
|
|
921
|
+
});
|
|
922
|
+
assertEquals(notAcceptableCalled, true);
|
|
923
|
+
assertEquals(response.status, 200);
|
|
924
|
+
assertEquals(await response.text(), "handled by onNotAcceptable");
|
|
925
|
+
});
|
|
926
|
+
esm_default.hardReset();
|
|
927
|
+
});
|
|
775
928
|
test("Federation.setInboxListeners()", async (t) => {
|
|
776
929
|
const kv = new MemoryKvStore();
|
|
777
930
|
esm_default.spyGlobal();
|
|
@@ -790,7 +943,7 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
790
943
|
await t.step("path match", () => {
|
|
791
944
|
const federation = createFederation({
|
|
792
945
|
kv,
|
|
793
|
-
|
|
946
|
+
documentLoaderFactory: () => mockDocumentLoader
|
|
794
947
|
});
|
|
795
948
|
federation.setInboxDispatcher("/users/{identifier}/inbox", () => ({ items: [] }));
|
|
796
949
|
assertThrows(() => federation.setInboxListeners("/users/{identifier}/inbox2"), RouterError);
|
|
@@ -798,7 +951,7 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
798
951
|
await t.step("wrong variables in path", () => {
|
|
799
952
|
const federation = createFederation({
|
|
800
953
|
kv,
|
|
801
|
-
|
|
954
|
+
documentLoaderFactory: () => mockDocumentLoader
|
|
802
955
|
});
|
|
803
956
|
assertThrows(() => federation.setInboxListeners("/users/inbox"), RouterError);
|
|
804
957
|
assertThrows(() => federation.setInboxListeners("/users/{identifier}/inbox/{id2}"), RouterError);
|
|
@@ -809,7 +962,7 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
809
962
|
const authenticatedRequests = [];
|
|
810
963
|
const federation = createFederation({
|
|
811
964
|
kv,
|
|
812
|
-
|
|
965
|
+
documentLoaderFactory: () => mockDocumentLoader,
|
|
813
966
|
authenticatedDocumentLoaderFactory(identity) {
|
|
814
967
|
const docLoader = getAuthenticatedDocumentLoader(identity);
|
|
815
968
|
return (url) => {
|
|
@@ -824,7 +977,10 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
824
977
|
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(Create, (ctx, create) => {
|
|
825
978
|
inbox.push([ctx, create]);
|
|
826
979
|
});
|
|
827
|
-
let response = await federation.fetch(new Request("https://example.com/inbox", {
|
|
980
|
+
let response = await federation.fetch(new Request("https://example.com/inbox", {
|
|
981
|
+
method: "POST",
|
|
982
|
+
headers: { "accept": "application/ld+json" }
|
|
983
|
+
}), { contextData: void 0 });
|
|
828
984
|
assertEquals(inbox, []);
|
|
829
985
|
assertEquals(response.status, 404);
|
|
830
986
|
federation.setActorDispatcher("/users/{identifier}", (_, identifier) => identifier === "john" ? new Person({}) : null).setKeyPairsDispatcher(() => [{
|
|
@@ -841,23 +997,37 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
841
997
|
});
|
|
842
998
|
response = await federation.fetch(new Request("https://example.com/inbox", {
|
|
843
999
|
method: "POST",
|
|
844
|
-
body: JSON.stringify(await activity().toJsonLd(options))
|
|
1000
|
+
body: JSON.stringify(await activity().toJsonLd(options)),
|
|
1001
|
+
headers: {
|
|
1002
|
+
"accept": "application/ld+json",
|
|
1003
|
+
"content-type": "application/ld+json"
|
|
1004
|
+
}
|
|
845
1005
|
}), { contextData: void 0 });
|
|
846
1006
|
assertEquals(inbox, []);
|
|
847
1007
|
assertEquals(response.status, 401);
|
|
848
|
-
response = await federation.fetch(new Request("https://example.com/users/no-one/inbox", {
|
|
1008
|
+
response = await federation.fetch(new Request("https://example.com/users/no-one/inbox", {
|
|
1009
|
+
method: "POST",
|
|
1010
|
+
headers: { "accept": "application/ld+json" }
|
|
1011
|
+
}), { contextData: void 0 });
|
|
849
1012
|
assertEquals(inbox, []);
|
|
850
1013
|
assertEquals(response.status, 404);
|
|
851
1014
|
response = await federation.fetch(new Request("https://example.com/users/john/inbox", {
|
|
852
1015
|
method: "POST",
|
|
853
|
-
body: JSON.stringify(await activity().toJsonLd(options))
|
|
1016
|
+
body: JSON.stringify(await activity().toJsonLd(options)),
|
|
1017
|
+
headers: {
|
|
1018
|
+
"accept": "application/ld+json",
|
|
1019
|
+
"content-type": "application/ld+json"
|
|
1020
|
+
}
|
|
854
1021
|
}), { contextData: void 0 });
|
|
855
1022
|
assertEquals(inbox, []);
|
|
856
1023
|
assertEquals(response.status, 401);
|
|
857
1024
|
const activityPayload = await activity().toJsonLd(options);
|
|
858
1025
|
let request = new Request("https://example.com/users/john/inbox", {
|
|
859
1026
|
method: "POST",
|
|
860
|
-
headers: {
|
|
1027
|
+
headers: {
|
|
1028
|
+
"Content-Type": "application/activity+json",
|
|
1029
|
+
accept: "application/ld+json"
|
|
1030
|
+
},
|
|
861
1031
|
body: JSON.stringify(activityPayload)
|
|
862
1032
|
});
|
|
863
1033
|
request = await signRequest(request, rsaPrivateKey3, new URL("https://example.com/person2#key3"));
|
|
@@ -874,7 +1044,10 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
874
1044
|
inbox.shift();
|
|
875
1045
|
request = new Request("https://another.host/users/john/inbox", {
|
|
876
1046
|
method: "POST",
|
|
877
|
-
headers: {
|
|
1047
|
+
headers: {
|
|
1048
|
+
"Content-Type": "application/activity+json",
|
|
1049
|
+
"accept": "application/ld+json"
|
|
1050
|
+
},
|
|
878
1051
|
body: JSON.stringify(activityPayload)
|
|
879
1052
|
});
|
|
880
1053
|
request = await signRequest(request, rsaPrivateKey3, new URL("https://example.com/person2#key3"));
|
|
@@ -889,7 +1062,10 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
889
1062
|
inbox.shift();
|
|
890
1063
|
request = new Request("https://example.com/inbox", {
|
|
891
1064
|
method: "POST",
|
|
892
|
-
headers: {
|
|
1065
|
+
headers: {
|
|
1066
|
+
"Content-Type": "application/activity+json",
|
|
1067
|
+
"accept": "application/ld+json"
|
|
1068
|
+
},
|
|
893
1069
|
body: JSON.stringify(await activity().toJsonLd(options))
|
|
894
1070
|
});
|
|
895
1071
|
request = await signRequest(request, rsaPrivateKey3, new URL("https://example.com/person2#key3"));
|
|
@@ -904,7 +1080,10 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
904
1080
|
inbox.shift();
|
|
905
1081
|
request = new Request("https://example.com/users/john/inbox", {
|
|
906
1082
|
method: "POST",
|
|
907
|
-
headers: {
|
|
1083
|
+
headers: {
|
|
1084
|
+
"Content-Type": "application/activity+json",
|
|
1085
|
+
"accept": "application/ld+json"
|
|
1086
|
+
},
|
|
908
1087
|
body: JSON.stringify(await (await signObject(activity(), ed25519PrivateKey, ed25519Multikey.id, options)).toJsonLd(options))
|
|
909
1088
|
});
|
|
910
1089
|
response = await federation.fetch(request, { contextData: void 0 });
|
|
@@ -919,7 +1098,7 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
919
1098
|
await t.step("onError()", async () => {
|
|
920
1099
|
const federation = createFederation({
|
|
921
1100
|
kv,
|
|
922
|
-
|
|
1101
|
+
documentLoaderFactory: () => mockDocumentLoader,
|
|
923
1102
|
authenticatedDocumentLoaderFactory(identity) {
|
|
924
1103
|
const docLoader = getAuthenticatedDocumentLoader(identity);
|
|
925
1104
|
return (url) => {
|
|
@@ -943,7 +1122,10 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
943
1122
|
const activity = new Create({ actor: new URL("https://example.com/person") });
|
|
944
1123
|
let request = new Request("https://example.com/users/john/inbox", {
|
|
945
1124
|
method: "POST",
|
|
946
|
-
headers: {
|
|
1125
|
+
headers: {
|
|
1126
|
+
"Content-Type": "application/activity+json",
|
|
1127
|
+
"Accept": "application/activity+json"
|
|
1128
|
+
},
|
|
947
1129
|
body: JSON.stringify(await activity.toJsonLd({ contextLoader: mockDocumentLoader }))
|
|
948
1130
|
});
|
|
949
1131
|
request = await signRequest(request, rsaPrivateKey2, new URL("https://example.com/key2"));
|
|
@@ -959,7 +1141,7 @@ test("Federation.setInboxDispatcher()", async (t) => {
|
|
|
959
1141
|
await t.step("path match", () => {
|
|
960
1142
|
const federation = createFederation({
|
|
961
1143
|
kv,
|
|
962
|
-
|
|
1144
|
+
documentLoaderFactory: () => mockDocumentLoader
|
|
963
1145
|
});
|
|
964
1146
|
federation.setInboxListeners("/users/{identifier}/inbox");
|
|
965
1147
|
assertThrows(() => federation.setInboxDispatcher("/users/{identifier}/inbox2", () => ({ items: [] })), RouterError);
|
|
@@ -967,7 +1149,7 @@ test("Federation.setInboxDispatcher()", async (t) => {
|
|
|
967
1149
|
await t.step("path match", () => {
|
|
968
1150
|
const federation = createFederation({
|
|
969
1151
|
kv,
|
|
970
|
-
|
|
1152
|
+
documentLoaderFactory: () => mockDocumentLoader
|
|
971
1153
|
});
|
|
972
1154
|
federation.setInboxListeners("/users/{identifier}/inbox");
|
|
973
1155
|
federation.setInboxDispatcher("/users/{identifier}/inbox", () => ({ items: [] }));
|
|
@@ -975,7 +1157,7 @@ test("Federation.setInboxDispatcher()", async (t) => {
|
|
|
975
1157
|
await t.step("wrong variables in path", () => {
|
|
976
1158
|
const federation = createFederation({
|
|
977
1159
|
kv,
|
|
978
|
-
|
|
1160
|
+
documentLoaderFactory: () => mockDocumentLoader
|
|
979
1161
|
});
|
|
980
1162
|
assertThrows(() => federation.setInboxDispatcher("/users/inbox", () => ({ items: [] })), RouterError);
|
|
981
1163
|
assertThrows(() => federation.setInboxDispatcher("/users/{identifier}/inbox/{identifier2}", () => ({ items: [] })), RouterError);
|
|
@@ -1007,7 +1189,7 @@ test("FederationImpl.sendActivity()", async (t) => {
|
|
|
1007
1189
|
const kv = new MemoryKvStore();
|
|
1008
1190
|
const federation = new FederationImpl({
|
|
1009
1191
|
kv,
|
|
1010
|
-
|
|
1192
|
+
contextLoaderFactory: () => mockDocumentLoader
|
|
1011
1193
|
});
|
|
1012
1194
|
const context = federation.createContext(new URL("https://example.com/"));
|
|
1013
1195
|
await t.step("success", async () => {
|
|
@@ -1259,7 +1441,7 @@ test("ContextImpl.sendActivity()", async (t) => {
|
|
|
1259
1441
|
collectionSyncHeader = cl.request.headers.get("Collection-Synchronization");
|
|
1260
1442
|
const options = {
|
|
1261
1443
|
async documentLoader(url) {
|
|
1262
|
-
const response = await federation.fetch(new Request(url), { contextData: void 0 });
|
|
1444
|
+
const response = await federation.fetch(new Request(url, { headers: { "accept": "application/ld+json" } }), { contextData: void 0 });
|
|
1263
1445
|
if (response.ok) return {
|
|
1264
1446
|
contextUrl: null,
|
|
1265
1447
|
document: await response.json(),
|
|
@@ -1293,7 +1475,7 @@ test("ContextImpl.sendActivity()", async (t) => {
|
|
|
1293
1475
|
const kv = new MemoryKvStore();
|
|
1294
1476
|
const federation = new FederationImpl({
|
|
1295
1477
|
kv,
|
|
1296
|
-
|
|
1478
|
+
contextLoaderFactory: () => mockDocumentLoader
|
|
1297
1479
|
});
|
|
1298
1480
|
federation.setActorDispatcher("/{identifier}", async (ctx, identifier) => {
|
|
1299
1481
|
if (identifier !== "1") return null;
|
|
@@ -1402,7 +1584,7 @@ test("ContextImpl.sendActivity()", async (t) => {
|
|
|
1402
1584
|
};
|
|
1403
1585
|
const federation2 = new FederationImpl({
|
|
1404
1586
|
kv,
|
|
1405
|
-
|
|
1587
|
+
contextLoaderFactory: () => mockDocumentLoader,
|
|
1406
1588
|
queue
|
|
1407
1589
|
});
|
|
1408
1590
|
federation2.setActorDispatcher("/{identifier}", async (ctx, identifier) => {
|
|
@@ -1682,7 +1864,7 @@ test("InboxContextImpl.forwardActivity()", async (t) => {
|
|
|
1682
1864
|
const kv = new MemoryKvStore();
|
|
1683
1865
|
const federation = new FederationImpl({
|
|
1684
1866
|
kv,
|
|
1685
|
-
|
|
1867
|
+
contextLoaderFactory: () => mockDocumentLoader
|
|
1686
1868
|
});
|
|
1687
1869
|
await t.step("skip", async () => {
|
|
1688
1870
|
const activity = {
|