@fedify/fedify 2.0.0-dev.1641 → 2.0.0-dev.167
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 +66 -30
- package/dist/{assert_rejects-7UF4R_Qs.js → assert_rejects-Ce45JcFg.js} +1 -1
- package/dist/{assert_is_error-B035L3om.js → assert_throws-BNXdRGWP.js} +31 -1
- package/dist/{builder-E2Icrl_a.js → builder-CRQGVq_N.js} +15 -8
- package/dist/{client-bgSdkFa2.d.ts → client-CUTUGgvJ.d.ts} +19 -19
- package/dist/{client-BW4V0OJx.js → client-Dg7OfUDA.js} +28 -23
- package/dist/{client-CegPX0Rn.d.cts → client-by-PEGAJ.d.cts} +19 -19
- package/dist/compat/mod.cjs +1 -1
- package/dist/compat/mod.d.cts +6 -12
- package/dist/compat/mod.d.ts +6 -12
- package/dist/compat/mod.js +1 -1
- package/dist/compat/transformers.test.js +21 -19
- package/dist/context-Bns6uTJq.js +109 -0
- package/dist/{context-CDSZdQHD.d.ts → context-C7vzWilY.d.ts} +374 -182
- package/dist/{context-Dq8aCtMH.d.cts → context-CrB9RFy5.d.cts} +374 -182
- package/dist/deno-Bvf4AA-X.js +117 -0
- package/dist/{testing-ByQmUvf-.js → dist-B5f6a8Tt.js} +90 -111
- package/dist/{authdocloader-BkIZCKQv.js → docloader-2gNKaklf.js} +17 -8
- package/dist/{esm-mtx3XJAD.js → esm-DGl7uK1r.js} +32 -17
- package/dist/federation/builder.test.js +9 -9
- package/dist/federation/collection.test.js +3 -6
- package/dist/federation/handler.test.js +113 -145
- package/dist/federation/idempotency.test.js +202 -0
- package/dist/federation/inbox.test.js +5 -6
- package/dist/federation/keycache.test.js +4 -5
- package/dist/federation/kv.test.js +58 -7
- package/dist/federation/middleware.test.js +306 -111
- package/dist/federation/mod.cjs +8 -12
- package/dist/federation/mod.d.cts +7 -13
- package/dist/federation/mod.d.ts +7 -13
- package/dist/federation/mod.js +8 -13
- package/dist/federation/mq.test.js +7 -8
- package/dist/federation/negotiation.test.js +25 -0
- package/dist/federation/retry.test.js +2 -4
- package/dist/federation/router.test.js +4 -6
- package/dist/federation/send.test.js +53 -13
- package/dist/{webfinger/handler.test.js → federation/webfinger.test.js} +25 -23
- package/dist/{federation-H2_En3j5.cjs → federation-B431K2gm.cjs} +22 -0
- package/dist/{federation-D1U8YY9t.js → federation-BbZwNNWj.js} +28 -6
- package/dist/{http-C7uYFcBo.js → http-0lpbWrFT.js} +371 -11
- package/dist/{http-BS6766zs.d.cts → http-ClB3pLcL.d.cts} +2 -2
- package/dist/{http-DqSNLFNY.d.ts → http-DLBDPal9.d.ts} +2 -2
- package/dist/{http-Cox5GsED.js → http-DP374h--.js} +3 -2
- package/dist/{http-ZhcoaYEa.cjs → http-d_vxukl7.cjs} +410 -14
- package/dist/{inbox-BDdRbWNI.js → inbox-Dv3k4z7l.js} +25 -7
- package/dist/{key-CfiBDu3o.js → key-t0uDOx8t.js} +3 -2
- package/dist/{keycache-CVBjz3xi.js → keycache-DRxpZ5r9.js} +1 -1
- package/dist/{keys-CBKbYaJA.js → keys-ZbcByPg9.js} +2 -1
- package/dist/{kv-63Cil1MD.d.cts → kv-B4vFhIYL.d.cts} +30 -1
- package/dist/{kv-C7sopW2E.d.ts → kv-CYySNrsn.d.ts} +30 -1
- package/dist/{kv-CRZrzyXm.js → kv-QzKcOQgP.js} +22 -0
- package/dist/kv-cache-BEeqyGER.js +107 -0
- package/dist/kv-cache-KFREoRaI.cjs +134 -0
- package/dist/kv-cache-aVS_ypNU.js +122 -0
- package/dist/{ld-CxgmnSO3.js → ld-CpXPfqRW.js} +4 -2
- package/dist/middleware-6Nb3n763.js +12 -0
- package/dist/{middleware-LyCG_YVM.cjs → middleware-Clcecst5.cjs} +309 -303
- package/dist/{middleware-DXidHY4N.js → middleware-DEy7WEOy.js} +254 -254
- package/dist/{middleware-ByPnvMMS.js → middleware-DLaPtWGX.js} +215 -313
- package/dist/middleware-DRg9fmN1.js +26 -0
- package/dist/middleware-lkdHuEk5.cjs +12 -0
- package/dist/mod-0p9zUdzg.d.cts +107 -0
- package/dist/mod-0qnPv4EC.d.cts +62 -0
- package/dist/{mod-BClfg3ej.d.cts → mod-BrS8tiad.d.cts} +3 -3
- package/dist/mod-C3SOvTD1.d.ts +64 -0
- package/dist/{mod-BhMnAkFX.d.cts → mod-D6pS5_xJ.d.cts} +4 -4
- package/dist/{mod-Drmz72EK.d.ts → mod-jOa7W503.d.ts} +3 -3
- package/dist/{mod-RI3-KvUI.d.ts → mod-waqu-BL_.d.ts} +4 -4
- package/dist/mod-xc20HhMD.d.ts +109 -0
- package/dist/mod.cjs +17 -112
- package/dist/mod.d.cts +11 -17
- package/dist/mod.d.ts +11 -17
- package/dist/mod.js +11 -17
- package/dist/negotiation-5NPJL6zp.js +71 -0
- package/dist/nodeinfo/client.test.js +5 -8
- package/dist/nodeinfo/handler.test.js +23 -22
- package/dist/nodeinfo/mod.cjs +2 -3
- package/dist/nodeinfo/mod.d.cts +2 -4
- package/dist/nodeinfo/mod.d.ts +2 -4
- package/dist/nodeinfo/mod.js +2 -3
- package/dist/nodeinfo/types.test.js +4 -7
- package/dist/otel/exporter.test.js +893 -0
- package/dist/otel/mod.cjs +256 -0
- package/dist/otel/mod.d.cts +230 -0
- package/dist/otel/mod.d.ts +232 -0
- package/dist/otel/mod.js +255 -0
- package/dist/{owner-Cxob5_PK.js → owner-BaG2jUgZ.js} +45 -8
- package/dist/{owner-CQPnQVtf.d.ts → owner-BgI8C-VY.d.ts} +2 -3
- package/dist/{owner-B-7Ptt_m.d.cts → owner-C-zfmVAD.d.cts} +2 -3
- package/dist/{proof-DkxwMaWE.js → proof-ClXweyp2.js} +47 -11
- package/dist/{proof-2Gcor0_N.cjs → proof-Cy-QcHCv.cjs} +69 -33
- package/dist/{proof-BiSQNUmQ.js → proof-D8bfMlig.js} +3 -2
- package/dist/router-D9eI0s4b.js +118 -0
- package/dist/{send-DSEhWIYD.js → send-BLogwy3G.js} +9 -4
- package/dist/sig/http.test.js +9 -11
- package/dist/sig/key.test.js +7 -9
- package/dist/sig/ld.test.js +8 -10
- package/dist/sig/mod.cjs +7 -11
- package/dist/sig/mod.d.cts +3 -7
- package/dist/sig/mod.d.ts +3 -7
- package/dist/sig/mod.js +3 -7
- package/dist/sig/owner.test.js +31 -10
- package/dist/sig/proof.test.js +11 -12
- package/dist/testing/mod.d.ts +243 -6982
- package/dist/testing/mod.js +4 -4
- package/dist/{transformers-CoBS-oFG.cjs → transformers-BjBg6Lag.cjs} +2 -2
- package/dist/{transformers-BFT6d7J5.js → transformers-N_ip_y4P.js} +2 -2
- package/dist/{types-l2uh_ZhP.js → types-8l28uC8o.js} +31 -26
- package/dist/{types-Bqt2EgP0.cjs → types-B6z6CqIz.cjs} +33 -28
- package/dist/{types-BSuWJsOm.js → types-CPz01LGH.js} +3 -3
- package/dist/{runtime/authdocloader.test.js → utils/docloader.test.js} +11 -13
- package/dist/utils/kv-cache.test.js +211 -0
- package/dist/utils/mod.cjs +10 -0
- package/dist/utils/mod.d.cts +4 -0
- package/dist/utils/mod.d.ts +6 -0
- package/dist/utils/mod.js +9 -0
- package/package.json +34 -75
- package/dist/actor-C22bXuuC.d.ts +0 -130
- package/dist/actor-CP03csrm.cjs +0 -37786
- package/dist/actor-DMgu-ZjT.d.cts +0 -128
- package/dist/actor-DU511yTk.js +0 -37312
- package/dist/actor-DVpsNXhn.js +0 -146
- package/dist/assert_throws-53_pKeP3.js +0 -39
- package/dist/authdocloader-BnsFSERg.cjs +0 -58
- package/dist/authdocloader-DCgMyo82.js +0 -52
- package/dist/denokv-jZ0Z2h0M.js +0 -57
- package/dist/docloader-BtqIh1OE.js +0 -4795
- package/dist/docloader-CxWcuWqQ.d.ts +0 -221
- package/dist/docloader-D-MrRyHl.d.cts +0 -219
- package/dist/docloader-kae6M-GI.cjs +0 -4861
- 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-B9Z5ZuX9.js +0 -10
- package/dist/key-Cc0JlcKe.js +0 -260
- package/dist/key-CgwCzDC4.js +0 -10
- package/dist/key-D-7DPHNl.cjs +0 -10
- package/dist/key-HqzOCwDc.cjs +0 -290
- package/dist/lookup-CiU3QxQz.js +0 -322
- package/dist/lookup-NuT9cCSl.js +0 -131
- package/dist/lookup-QHjmy4Og.cjs +0 -137
- package/dist/middleware-BHboQ4BE.js +0 -25
- package/dist/middleware-Bp3I9z8r.js +0 -17
- package/dist/middleware-oYqSU5ky.cjs +0 -17
- package/dist/mod-Cxt4Kpf6.d.ts +0 -291
- package/dist/mod-DBzN0aCM.d.ts +0 -115
- package/dist/mod-Dc_-mf8s.d.cts +0 -102
- package/dist/mod-FZd39qVq.d.cts +0 -1
- package/dist/mod-TFoH2Ql8.d.ts +0 -104
- package/dist/mod-evzlRVZq.d.cts +0 -289
- package/dist/mod-g0xFzAP9.d.ts +0 -2
- package/dist/mod-jQ4OODsl.d.cts +0 -113
- package/dist/mq-B7R1Q-M5.d.cts +0 -140
- package/dist/mq-CRGm1e_F.d.ts +0 -143
- package/dist/runtime/docloader.test.js +0 -522
- package/dist/runtime/key.test.js +0 -103
- package/dist/runtime/langstr.test.js +0 -39
- 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/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/type-B4NJkfVg.js +0 -42187
- package/dist/vocab/actor.test.d.ts +0 -3
- package/dist/vocab/actor.test.js +0 -5965
- package/dist/vocab/lookup.test.d.ts +0 -3
- package/dist/vocab/lookup.test.js +0 -206
- package/dist/vocab/mod.cjs +0 -87
- package/dist/vocab/mod.d.cts +0 -6
- package/dist/vocab/mod.d.ts +0 -8
- package/dist/vocab/mod.js +0 -10
- package/dist/vocab/schema.yaml +0 -247
- package/dist/vocab/type.test.d.ts +0 -3
- package/dist/vocab/type.test.js +0 -25
- package/dist/vocab/vocab.test.d.ts +0 -3
- package/dist/vocab/vocab.test.js +0 -3398
- package/dist/vocab-B0-5a8pw.cjs +0 -282
- package/dist/vocab-DJTYMqyU.d.cts +0 -14632
- package/dist/vocab-SOE1ifCr.d.ts +0 -14634
- package/dist/vocab-lBFcVxVF.js +0 -246
- package/dist/webfinger/handler.test.d.ts +0 -3
- package/dist/webfinger/lookup.test.d.ts +0 -3
- package/dist/webfinger/lookup.test.js +0 -195
- package/dist/webfinger/mod.cjs +0 -9
- package/dist/webfinger/mod.d.cts +0 -4
- package/dist/webfinger/mod.d.ts +0 -6
- package/dist/webfinger/mod.js +0 -9
- package/dist/webfinger-BjOEdFPs.cjs +0 -4
- package/dist/webfinger-De_bU0iE.js +0 -4
- 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/{runtime/authdocloader.test.d.ts → federation/idempotency.test.d.ts} +0 -0
- /package/dist/{runtime/docloader.test.d.ts → federation/negotiation.test.d.ts} +0 -0
- /package/dist/{runtime/key.test.d.ts → federation/webfinger.test.d.ts} +0 -0
- /package/dist/{mod-1pDWKvUL.d.ts → mod-1E3W847c.d.ts} +0 -0
- /package/dist/{mod-C2tOeRkN.d.cts → mod-C81L6_lQ.d.cts} +0 -0
- /package/dist/{nodeinfo-DfycQ8Wf.js → nodeinfo-BlLsRSiT.js} +0 -0
- /package/dist/{nodeinfo-Co9lJrWl.cjs → nodeinfo-DuMYTpbZ.cjs} +0 -0
- /package/dist/{runtime/langstr.test.d.ts → otel/exporter.test.d.ts} +0 -0
- /package/dist/{retry-CfF8Gn4d.js → retry-D4GJ670a.js} +0 -0
- /package/dist/{runtime-DPYEDf-o.js → sig-CwuONEzF.js} +0 -0
- /package/dist/{runtime-C58AJWSv.cjs → sig-DeXX2xnj.cjs} +0 -0
- /package/dist/{testing → utils}/docloader.test.d.ts +0 -0
- /package/dist/{runtime/link.test.d.ts → utils/kv-cache.test.d.ts} +0 -0
- /package/dist/{sig-ByHXzqUi.cjs → utils-Db0ZmjcD.cjs} +0 -0
- /package/dist/{sig-Cj3tk-ig.js → utils-Wranxuoe.js} +0 -0
|
@@ -3,38 +3,53 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { mockDocumentLoader, test } from "../dist-B5f6a8Tt.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
|
-
import { MemoryKvStore } from "../kv-
|
|
11
|
-
import
|
|
12
|
-
import "../
|
|
13
|
-
import
|
|
14
|
-
import "../
|
|
15
|
-
import "../
|
|
16
|
-
import "../key-
|
|
17
|
-
import { signRequest, verifyRequest } from "../http-
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import "../
|
|
23
|
-
import "../
|
|
10
|
+
import { MemoryKvStore } from "../kv-QzKcOQgP.js";
|
|
11
|
+
import "../deno-Bvf4AA-X.js";
|
|
12
|
+
import { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer, createFederation } from "../middleware-DLaPtWGX.js";
|
|
13
|
+
import "../client-Dg7OfUDA.js";
|
|
14
|
+
import { RouterError } from "../router-D9eI0s4b.js";
|
|
15
|
+
import "../types-CPz01LGH.js";
|
|
16
|
+
import "../key-t0uDOx8t.js";
|
|
17
|
+
import { signRequest, verifyRequest } from "../http-DP374h--.js";
|
|
18
|
+
import { detachSignature, signJsonLd, verifyJsonLd } from "../ld-CpXPfqRW.js";
|
|
19
|
+
import { doesActorOwnKey } from "../owner-BaG2jUgZ.js";
|
|
20
|
+
import { signObject, verifyObject } from "../proof-D8bfMlig.js";
|
|
21
|
+
import { fetchDocumentLoader, getAuthenticatedDocumentLoader } from "../docloader-2gNKaklf.js";
|
|
22
|
+
import "../kv-cache-BEeqyGER.js";
|
|
23
|
+
import "../inbox-Dv3k4z7l.js";
|
|
24
|
+
import "../builder-CRQGVq_N.js";
|
|
24
25
|
import "../collection-CcnIw1qY.js";
|
|
25
|
-
import "../keycache-
|
|
26
|
-
import "../
|
|
27
|
-
import "../
|
|
28
|
-
import
|
|
26
|
+
import "../keycache-DRxpZ5r9.js";
|
|
27
|
+
import "../negotiation-5NPJL6zp.js";
|
|
28
|
+
import "../retry-D4GJ670a.js";
|
|
29
|
+
import "../send-BLogwy3G.js";
|
|
29
30
|
import { assertStrictEquals } from "../std__assert-DWivtrGR.js";
|
|
30
|
-
import { assertFalse, assertRejects } from "../assert_rejects-
|
|
31
|
-
import "../
|
|
31
|
+
import { assertFalse, assertRejects } from "../assert_rejects-Ce45JcFg.js";
|
|
32
|
+
import { assertThrows } from "../assert_throws-BNXdRGWP.js";
|
|
32
33
|
import { assertNotEquals } from "../assert_not_equals-C80BG-_5.js";
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import
|
|
34
|
+
import { ed25519Multikey, ed25519PrivateKey, ed25519PublicKey, rsaPrivateKey2, rsaPrivateKey3, rsaPublicKey2, rsaPublicKey3 } from "../keys-ZbcByPg9.js";
|
|
35
|
+
import { esm_default } from "../esm-DGl7uK1r.js";
|
|
36
|
+
import * as vocab from "@fedify/vocab";
|
|
37
|
+
import { getTypeId, lookupObject } from "@fedify/vocab";
|
|
36
38
|
|
|
37
|
-
//#region src/
|
|
39
|
+
//#region ../fixture/src/fixtures/example.com/create.json
|
|
40
|
+
var __context$2 = "https://www.w3.org/ns/activitystreams";
|
|
41
|
+
var type$2 = "Create";
|
|
42
|
+
var id$2 = "https://example.com/create";
|
|
43
|
+
var actor = "https://example.com/person";
|
|
44
|
+
var create_default = {
|
|
45
|
+
"@context": __context$2,
|
|
46
|
+
type: type$2,
|
|
47
|
+
id: id$2,
|
|
48
|
+
actor
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region ../fixture/src/fixtures/example.com/person.json
|
|
38
53
|
var __context$1 = ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"];
|
|
39
54
|
var id$1 = "https://example.com/person";
|
|
40
55
|
var type$1 = "Person";
|
|
@@ -58,7 +73,7 @@ var person_default = {
|
|
|
58
73
|
};
|
|
59
74
|
|
|
60
75
|
//#endregion
|
|
61
|
-
//#region src/
|
|
76
|
+
//#region ../fixture/src/fixtures/example.com/person2.json
|
|
62
77
|
var __context = [
|
|
63
78
|
"https://www.w3.org/ns/activitystreams",
|
|
64
79
|
"https://w3id.org/security/v1",
|
|
@@ -107,7 +122,7 @@ test("createFederation()", async (t) => {
|
|
|
107
122
|
await t.step("allowPrivateAddress", () => {
|
|
108
123
|
assertThrows(() => createFederation({
|
|
109
124
|
kv,
|
|
110
|
-
|
|
125
|
+
contextLoaderFactory: () => mockDocumentLoader,
|
|
111
126
|
allowPrivateAddress: true
|
|
112
127
|
}), TypeError);
|
|
113
128
|
assertThrows(() => createFederation({
|
|
@@ -244,7 +259,7 @@ test({
|
|
|
244
259
|
assertStrictEquals(ctx.federation, federation);
|
|
245
260
|
assertThrows(() => ctx.getNodeInfoUri(), RouterError);
|
|
246
261
|
assertThrows(() => ctx.getActorUri("handle"), RouterError);
|
|
247
|
-
assertThrows(() => ctx.getObjectUri(Note, {
|
|
262
|
+
assertThrows(() => ctx.getObjectUri(vocab.Note, {
|
|
248
263
|
handle: "handle",
|
|
249
264
|
id: "id"
|
|
250
265
|
}), RouterError);
|
|
@@ -261,7 +276,7 @@ test({
|
|
|
261
276
|
assertEquals(ctx.parseUri(null), null);
|
|
262
277
|
assertEquals(await ctx.getActorKeyPairs("handle"), []);
|
|
263
278
|
await assertRejects(() => ctx.getDocumentLoader({ identifier: "handle" }), Error, "No actor key pairs dispatcher registered");
|
|
264
|
-
await assertRejects(() => ctx.sendActivity({ identifier: "handle" }, [], new Create({})), Error, "No actor key pairs dispatcher registered");
|
|
279
|
+
await assertRejects(() => ctx.sendActivity({ identifier: "handle" }, [], new vocab.Create({})), Error, "No actor key pairs dispatcher registered");
|
|
265
280
|
federation.setNodeInfoDispatcher("/nodeinfo/2.1", () => ({
|
|
266
281
|
software: {
|
|
267
282
|
name: "Example",
|
|
@@ -276,7 +291,7 @@ test({
|
|
|
276
291
|
}));
|
|
277
292
|
ctx = federation.createContext(new URL("https://example.com/"), 123);
|
|
278
293
|
assertEquals(ctx.getNodeInfoUri(), new URL("https://example.com/nodeinfo/2.1"));
|
|
279
|
-
federation.setActorDispatcher("/users/{identifier}", () => new Person({})).setKeyPairsDispatcher(() => [{
|
|
294
|
+
federation.setActorDispatcher("/users/{identifier}", () => new vocab.Person({})).setKeyPairsDispatcher(() => [{
|
|
280
295
|
privateKey: rsaPrivateKey2,
|
|
281
296
|
publicKey: rsaPublicKey2.publicKey
|
|
282
297
|
}, {
|
|
@@ -300,7 +315,7 @@ test({
|
|
|
300
315
|
id: new URL("https://example.com/users/handle#main-key"),
|
|
301
316
|
owner: new URL("https://example.com/users/handle")
|
|
302
317
|
}),
|
|
303
|
-
multikey: new Multikey({
|
|
318
|
+
multikey: new vocab.Multikey({
|
|
304
319
|
id: new URL("https://example.com/users/handle#main-key"),
|
|
305
320
|
controller: new URL("https://example.com/users/handle"),
|
|
306
321
|
publicKey: rsaPublicKey2.publicKey
|
|
@@ -313,7 +328,7 @@ test({
|
|
|
313
328
|
id: new URL("https://example.com/users/handle#key-2"),
|
|
314
329
|
owner: new URL("https://example.com/users/handle")
|
|
315
330
|
}),
|
|
316
|
-
multikey: new Multikey({
|
|
331
|
+
multikey: new vocab.Multikey({
|
|
317
332
|
id: new URL("https://example.com/users/handle#key-2"),
|
|
318
333
|
controller: new URL("https://example.com/users/handle"),
|
|
319
334
|
publicKey: ed25519PublicKey.publicKey
|
|
@@ -341,8 +356,8 @@ test({
|
|
|
341
356
|
document: true
|
|
342
357
|
});
|
|
343
358
|
assertEquals(await ctx.lookupObject("https://example.com/object"), null);
|
|
344
|
-
await assertRejects(() => ctx.sendActivity({ identifier: "handle" }, [], new Create({})), TypeError, "The activity to send must have at least one actor property.");
|
|
345
|
-
await ctx.sendActivity({ identifier: "handle" }, [], new Create({ actor: new URL("https://example.com/users/handle") }));
|
|
359
|
+
await assertRejects(() => ctx.sendActivity({ identifier: "handle" }, [], new vocab.Create({})), TypeError, "The activity to send must have at least one actor property.");
|
|
360
|
+
await ctx.sendActivity({ identifier: "handle" }, [], new vocab.Create({ actor: new URL("https://example.com/users/handle") }));
|
|
346
361
|
esm_default.get("https://example.com/object", () => new Response(JSON.stringify({
|
|
347
362
|
"@context": "https://www.w3.org/ns/activitystreams",
|
|
348
363
|
type: "Object",
|
|
@@ -355,21 +370,21 @@ test({
|
|
|
355
370
|
contextLoaderFactory: () => mockDocumentLoader
|
|
356
371
|
});
|
|
357
372
|
const ctx2 = federation2.createContext(new URL("https://example.com/"), 123);
|
|
358
|
-
assertEquals(await ctx2.lookupObject("https://example.com/object"), new Object
|
|
373
|
+
assertEquals(await ctx2.lookupObject("https://example.com/object"), new vocab.Object({
|
|
359
374
|
id: new URL("https://example.com/object"),
|
|
360
375
|
name: "Fetched object"
|
|
361
376
|
}));
|
|
362
|
-
federation.setObjectDispatcher(Note, "/users/{identifier}/notes/{id}", (_ctx, values) => {
|
|
363
|
-
return new Note({ summary: `Note ${values.id} by ${values.identifier}` });
|
|
377
|
+
federation.setObjectDispatcher(vocab.Note, "/users/{identifier}/notes/{id}", (_ctx, values) => {
|
|
378
|
+
return new vocab.Note({ summary: `Note ${values.id} by ${values.identifier}` });
|
|
364
379
|
});
|
|
365
380
|
ctx = federation.createContext(new URL("https://example.com/"), 123);
|
|
366
|
-
assertEquals(ctx.getObjectUri(Note, {
|
|
381
|
+
assertEquals(ctx.getObjectUri(vocab.Note, {
|
|
367
382
|
identifier: "john",
|
|
368
383
|
id: "123"
|
|
369
384
|
}), new URL("https://example.com/users/john/notes/123"));
|
|
370
385
|
assertEquals(ctx.parseUri(new URL("https://example.com/users/john/notes/123")), {
|
|
371
386
|
type: "object",
|
|
372
|
-
class: Note,
|
|
387
|
+
class: vocab.Note,
|
|
373
388
|
typeId: new URL("https://www.w3.org/ns/activitystreams#Note"),
|
|
374
389
|
values: {
|
|
375
390
|
identifier: "john",
|
|
@@ -452,7 +467,7 @@ test({
|
|
|
452
467
|
kv,
|
|
453
468
|
origin: "https://ap.example.com",
|
|
454
469
|
documentLoaderFactory: () => mockDocumentLoader,
|
|
455
|
-
|
|
470
|
+
contextLoaderFactory: () => mockDocumentLoader
|
|
456
471
|
});
|
|
457
472
|
const ctx = federation.createContext(new URL("https://example.com:1234/"));
|
|
458
473
|
assertEquals(ctx.origin, "https://example.com:1234");
|
|
@@ -472,7 +487,7 @@ test({
|
|
|
472
487
|
}
|
|
473
488
|
}));
|
|
474
489
|
assertEquals(ctx.getNodeInfoUri(), new URL("https://ap.example.com/nodeinfo/2.1"));
|
|
475
|
-
federation.setActorDispatcher("/users/{identifier}", () => new Person({}));
|
|
490
|
+
federation.setActorDispatcher("/users/{identifier}", () => new vocab.Person({}));
|
|
476
491
|
assertEquals(ctx.getActorUri("handle"), new URL("https://ap.example.com/users/handle"));
|
|
477
492
|
assertEquals(ctx.parseUri(new URL("https://ap.example.com/users/handle")), {
|
|
478
493
|
type: "actor",
|
|
@@ -484,16 +499,16 @@ test({
|
|
|
484
499
|
handle: "handle",
|
|
485
500
|
identifier: "handle"
|
|
486
501
|
});
|
|
487
|
-
federation.setObjectDispatcher(Note, "/users/{identifier}/notes/{id}", (_ctx, values) => {
|
|
488
|
-
return new Note({ summary: `Note ${values.id} by ${values.identifier}` });
|
|
502
|
+
federation.setObjectDispatcher(vocab.Note, "/users/{identifier}/notes/{id}", (_ctx, values) => {
|
|
503
|
+
return new vocab.Note({ summary: `Note ${values.id} by ${values.identifier}` });
|
|
489
504
|
});
|
|
490
|
-
assertEquals(ctx.getObjectUri(Note, {
|
|
505
|
+
assertEquals(ctx.getObjectUri(vocab.Note, {
|
|
491
506
|
identifier: "john",
|
|
492
507
|
id: "123"
|
|
493
508
|
}), new URL("https://ap.example.com/users/john/notes/123"));
|
|
494
509
|
assertEquals(ctx.parseUri(new URL("https://ap.example.com/users/john/notes/123")), {
|
|
495
510
|
type: "object",
|
|
496
|
-
class: Note,
|
|
511
|
+
class: vocab.Note,
|
|
497
512
|
typeId: new URL("https://www.w3.org/ns/activitystreams#Note"),
|
|
498
513
|
values: {
|
|
499
514
|
identifier: "john",
|
|
@@ -502,7 +517,7 @@ test({
|
|
|
502
517
|
});
|
|
503
518
|
assertEquals(ctx.parseUri(new URL("https://example.com:1234/users/john/notes/123")), {
|
|
504
519
|
type: "object",
|
|
505
|
-
class: Note,
|
|
520
|
+
class: vocab.Note,
|
|
506
521
|
typeId: new URL("https://www.w3.org/ns/activitystreams#Note"),
|
|
507
522
|
values: {
|
|
508
523
|
identifier: "john",
|
|
@@ -680,7 +695,7 @@ test({
|
|
|
680
695
|
kv,
|
|
681
696
|
documentLoaderFactory: () => mockDocumentLoader
|
|
682
697
|
});
|
|
683
|
-
const req = new Request("https://example.com/");
|
|
698
|
+
const req = new Request("https://example.com/", { headers: { "accept": "application/ld+json" } });
|
|
684
699
|
const ctx = federation.createContext(req, 123);
|
|
685
700
|
assertEquals(ctx.request, req);
|
|
686
701
|
assertEquals(ctx.url, new URL("https://example.com/"));
|
|
@@ -689,7 +704,7 @@ test({
|
|
|
689
704
|
assertEquals(ctx.hostname, "example.com");
|
|
690
705
|
assertEquals(ctx.data, 123);
|
|
691
706
|
await assertRejects(() => ctx.getActor("someone"), Error);
|
|
692
|
-
await assertRejects(() => ctx.getObject(Note, {
|
|
707
|
+
await assertRejects(() => ctx.getObject(vocab.Note, {
|
|
693
708
|
handle: "someone",
|
|
694
709
|
id: "123"
|
|
695
710
|
}), Error);
|
|
@@ -698,7 +713,7 @@ test({
|
|
|
698
713
|
assertEquals(await ctx.getSignedKey(), null);
|
|
699
714
|
assertEquals(await ctx.getSignedKeyOwner(), null);
|
|
700
715
|
await assertRejects(() => ctx.getActor("someone"), Error, "No actor dispatcher registered");
|
|
701
|
-
const signedReq = await signRequest(new Request("https://example.com/"), rsaPrivateKey2, rsaPublicKey2.id);
|
|
716
|
+
const signedReq = await signRequest(new Request("https://example.com/", { headers: { "accept": "application/ld+json" } }), rsaPrivateKey2, rsaPublicKey2.id);
|
|
702
717
|
const signedCtx = federation.createContext(signedReq, 456);
|
|
703
718
|
assertEquals(signedCtx.request, signedReq);
|
|
704
719
|
assertEquals(signedCtx.url, new URL("https://example.com/"));
|
|
@@ -707,7 +722,7 @@ test({
|
|
|
707
722
|
assertEquals(await signedCtx.getSignedKeyOwner(), null);
|
|
708
723
|
assertEquals(await signedCtx.getSignedKey(), rsaPublicKey2);
|
|
709
724
|
assertEquals(await signedCtx.getSignedKeyOwner(), null);
|
|
710
|
-
const signedReq2 = await signRequest(new Request("https://example.com/"), rsaPrivateKey3, rsaPublicKey3.id);
|
|
725
|
+
const signedReq2 = await signRequest(new Request("https://example.com/", { headers: { "accept": "application/ld+json" } }), rsaPrivateKey3, rsaPublicKey3.id);
|
|
711
726
|
const signedCtx2 = federation.createContext(signedReq2, 456);
|
|
712
727
|
assertEquals(signedCtx2.request, signedReq2);
|
|
713
728
|
assertEquals(signedCtx2.url, new URL("https://example.com/"));
|
|
@@ -720,27 +735,27 @@ test({
|
|
|
720
735
|
assertEquals(await signedCtx2.getSignedKeyOwner(), expectedOwner);
|
|
721
736
|
assertEquals(await signedCtx2.getSignedKey(), rsaPublicKey3);
|
|
722
737
|
assertEquals(await signedCtx2.getSignedKeyOwner(), expectedOwner);
|
|
723
|
-
federation.setActorDispatcher("/users/{identifier}", (_ctx, identifier) => new Person({ preferredUsername: identifier }));
|
|
738
|
+
federation.setActorDispatcher("/users/{identifier}", (_ctx, identifier) => new vocab.Person({ preferredUsername: identifier }));
|
|
724
739
|
const ctx2 = federation.createContext(req, 789);
|
|
725
740
|
assertEquals(ctx2.request, req);
|
|
726
741
|
assertEquals(ctx2.url, new URL("https://example.com/"));
|
|
727
742
|
assertEquals(ctx2.data, 789);
|
|
728
|
-
assertEquals(await ctx2.getActor("john"), new Person({ preferredUsername: "john" }));
|
|
729
|
-
federation.setObjectDispatcher(Note, "/users/{identifier}/notes/{id}", (_ctx, values) => {
|
|
730
|
-
return new Note({ summary: `Note ${values.id} by ${values.identifier}` });
|
|
743
|
+
assertEquals(await ctx2.getActor("john"), new vocab.Person({ preferredUsername: "john" }));
|
|
744
|
+
federation.setObjectDispatcher(vocab.Note, "/users/{identifier}/notes/{id}", (_ctx, values) => {
|
|
745
|
+
return new vocab.Note({ summary: `Note ${values.id} by ${values.identifier}` });
|
|
731
746
|
});
|
|
732
747
|
const ctx3 = federation.createContext(req, 123);
|
|
733
748
|
assertEquals(ctx3.request, req);
|
|
734
749
|
assertEquals(ctx3.url, new URL("https://example.com/"));
|
|
735
750
|
assertEquals(ctx3.data, 123);
|
|
736
|
-
assertEquals(await ctx2.getObject(Note, {
|
|
751
|
+
assertEquals(await ctx2.getObject(vocab.Note, {
|
|
737
752
|
identifier: "john",
|
|
738
753
|
id: "123"
|
|
739
|
-
}), new Note({ summary: "Note 123 by john" }));
|
|
754
|
+
}), new vocab.Note({ summary: "Note 123 by john" }));
|
|
740
755
|
});
|
|
741
756
|
await t.step("RequestContext.clone()", () => {
|
|
742
757
|
const federation = createFederation({ kv });
|
|
743
|
-
const req = new Request("https://example.com/");
|
|
758
|
+
const req = new Request("https://example.com/", { headers: { "accept": "application/ld+json" } });
|
|
744
759
|
const ctx = federation.createContext(req, 123);
|
|
745
760
|
const clone = ctx.clone(456);
|
|
746
761
|
assertStrictEquals(clone.request, ctx.request);
|
|
@@ -756,6 +771,157 @@ test({
|
|
|
756
771
|
esm_default.hardReset();
|
|
757
772
|
}
|
|
758
773
|
});
|
|
774
|
+
test("Federation.fetch()", async (t) => {
|
|
775
|
+
esm_default.spyGlobal();
|
|
776
|
+
esm_default.get("https://example.com/key2", {
|
|
777
|
+
headers: { "Content-Type": "application/activity+json" },
|
|
778
|
+
body: await rsaPublicKey2.toJsonLd({ contextLoader: mockDocumentLoader })
|
|
779
|
+
});
|
|
780
|
+
esm_default.get("begin:https://example.com/person", {
|
|
781
|
+
headers: { "Content-Type": "application/activity+json" },
|
|
782
|
+
body: person_default
|
|
783
|
+
});
|
|
784
|
+
const createTestContext = () => {
|
|
785
|
+
const kv = new MemoryKvStore();
|
|
786
|
+
const inbox = [];
|
|
787
|
+
const dispatches = [];
|
|
788
|
+
const federation = createFederation({
|
|
789
|
+
kv,
|
|
790
|
+
documentLoaderFactory: () => mockDocumentLoader,
|
|
791
|
+
authenticatedDocumentLoaderFactory(identity) {
|
|
792
|
+
const docLoader = getAuthenticatedDocumentLoader(identity);
|
|
793
|
+
return (url) => {
|
|
794
|
+
const urlObj = new URL(url);
|
|
795
|
+
if (urlObj.host === "example.com") return docLoader(url);
|
|
796
|
+
return mockDocumentLoader(url);
|
|
797
|
+
};
|
|
798
|
+
}
|
|
799
|
+
});
|
|
800
|
+
federation.setActorDispatcher("/users/{identifier}", (ctx, identifier) => {
|
|
801
|
+
dispatches.push(identifier);
|
|
802
|
+
return new vocab.Person({
|
|
803
|
+
id: ctx.getActorUri(identifier),
|
|
804
|
+
inbox: ctx.getInboxUri(identifier),
|
|
805
|
+
preferredUsername: identifier
|
|
806
|
+
});
|
|
807
|
+
}).setKeyPairsDispatcher(() => {
|
|
808
|
+
return [{
|
|
809
|
+
privateKey: rsaPrivateKey2,
|
|
810
|
+
publicKey: rsaPublicKey2.publicKey
|
|
811
|
+
}];
|
|
812
|
+
});
|
|
813
|
+
federation.setInboxDispatcher("/users/{identifier}/inbox", () => {
|
|
814
|
+
return { items: [] };
|
|
815
|
+
});
|
|
816
|
+
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(vocab.Create, (_ctx, activity) => {
|
|
817
|
+
inbox.push(activity.id.toString());
|
|
818
|
+
return;
|
|
819
|
+
});
|
|
820
|
+
return {
|
|
821
|
+
federation,
|
|
822
|
+
inbox,
|
|
823
|
+
dispatches
|
|
824
|
+
};
|
|
825
|
+
};
|
|
826
|
+
await t.step("GET without accepts header", async () => {
|
|
827
|
+
const { federation, dispatches } = createTestContext();
|
|
828
|
+
const response = await federation.fetch(new Request("https://example.com/users/actor", { method: "GET" }), { contextData: void 0 });
|
|
829
|
+
assertEquals(dispatches, []);
|
|
830
|
+
assertEquals(response.status, 406);
|
|
831
|
+
});
|
|
832
|
+
await t.step("POST with application/json", async () => {
|
|
833
|
+
const { federation, inbox } = createTestContext();
|
|
834
|
+
const request = await signRequest(new Request("https://example.com/users/json/inbox", {
|
|
835
|
+
method: "POST",
|
|
836
|
+
headers: {
|
|
837
|
+
"Accept": "application/json",
|
|
838
|
+
"Content-Type": "application/json"
|
|
839
|
+
},
|
|
840
|
+
body: JSON.stringify(create_default)
|
|
841
|
+
}), rsaPrivateKey2, rsaPublicKey2.id);
|
|
842
|
+
const response = await federation.fetch(request, { contextData: void 0 });
|
|
843
|
+
assertEquals(response.status, 202);
|
|
844
|
+
assertEquals(inbox.length, 1, "Expected one item in the inbox, json");
|
|
845
|
+
assertEquals(inbox[0], create_default.id);
|
|
846
|
+
});
|
|
847
|
+
await t.step("GET with application/json", async () => {
|
|
848
|
+
const { federation, dispatches } = createTestContext();
|
|
849
|
+
const response = await federation.fetch(new Request("https://example.com/users/json", {
|
|
850
|
+
method: "GET",
|
|
851
|
+
headers: { "Accept": "application/json" }
|
|
852
|
+
}), { contextData: void 0 });
|
|
853
|
+
assertEquals(dispatches, ["json"]);
|
|
854
|
+
assertEquals(response.status, 200);
|
|
855
|
+
});
|
|
856
|
+
await t.step("POST with application/ld+json", async () => {
|
|
857
|
+
const { federation, inbox } = createTestContext();
|
|
858
|
+
const request = await signRequest(new Request("https://example.com/users/ld/inbox", {
|
|
859
|
+
method: "POST",
|
|
860
|
+
headers: {
|
|
861
|
+
"Accept": "application/ld+json",
|
|
862
|
+
"Content-Type": "application/activity+json"
|
|
863
|
+
},
|
|
864
|
+
body: JSON.stringify(create_default)
|
|
865
|
+
}), rsaPrivateKey2, rsaPublicKey2.id);
|
|
866
|
+
const response = await federation.fetch(request, { contextData: void 0 });
|
|
867
|
+
assertEquals(response.status, 202);
|
|
868
|
+
assertEquals(inbox.length, 1, "Expected one inbox activity, ld+json");
|
|
869
|
+
assertEquals(inbox[0], create_default.id);
|
|
870
|
+
});
|
|
871
|
+
await t.step("GET with application/ld+json", async () => {
|
|
872
|
+
const { federation, dispatches } = createTestContext();
|
|
873
|
+
const request = new Request("https://example.com/users/ld", {
|
|
874
|
+
method: "GET",
|
|
875
|
+
headers: { "Accept": "application/ld+json" }
|
|
876
|
+
});
|
|
877
|
+
const response = await federation.fetch(request, { contextData: void 0 });
|
|
878
|
+
assertEquals(dispatches, ["ld"]);
|
|
879
|
+
assertEquals(response.status, 200);
|
|
880
|
+
});
|
|
881
|
+
await t.step("POST with application/activity+json", async () => {
|
|
882
|
+
const { federation, inbox } = createTestContext();
|
|
883
|
+
const request = await signRequest(new Request("https://example.com/users/activity/inbox", {
|
|
884
|
+
method: "POST",
|
|
885
|
+
headers: {
|
|
886
|
+
"Accept": "application/activity+json",
|
|
887
|
+
"Content-Type": "application/activity+json"
|
|
888
|
+
},
|
|
889
|
+
body: JSON.stringify(create_default)
|
|
890
|
+
}), rsaPrivateKey2, rsaPublicKey2.id);
|
|
891
|
+
const response = await federation.fetch(request, { contextData: void 0 });
|
|
892
|
+
assertEquals(response.status, 202);
|
|
893
|
+
assertEquals(inbox.length, 1);
|
|
894
|
+
assertEquals(inbox[0], create_default.id);
|
|
895
|
+
});
|
|
896
|
+
await t.step("GET with application/activity+json", async () => {
|
|
897
|
+
const { federation, dispatches } = createTestContext();
|
|
898
|
+
const request = new Request("https://example.com/users/activity", {
|
|
899
|
+
method: "GET",
|
|
900
|
+
headers: { "Accept": "application/ld+json" }
|
|
901
|
+
});
|
|
902
|
+
const response = await federation.fetch(request, { contextData: void 0 });
|
|
903
|
+
assertEquals(dispatches, ["activity"]);
|
|
904
|
+
assertEquals(response.status, 200);
|
|
905
|
+
});
|
|
906
|
+
await t.step("onNotAcceptable with GET", async () => {
|
|
907
|
+
const { federation } = createTestContext();
|
|
908
|
+
let notAcceptableCalled = false;
|
|
909
|
+
const response = await federation.fetch(new Request("https://example.com/users/html", {
|
|
910
|
+
method: "GET",
|
|
911
|
+
headers: { "Accept": "text/html" }
|
|
912
|
+
}), {
|
|
913
|
+
contextData: void 0,
|
|
914
|
+
onNotAcceptable: () => {
|
|
915
|
+
notAcceptableCalled = true;
|
|
916
|
+
return new Response("handled by onNotAcceptable", { status: 200 });
|
|
917
|
+
}
|
|
918
|
+
});
|
|
919
|
+
assertEquals(notAcceptableCalled, true);
|
|
920
|
+
assertEquals(response.status, 200);
|
|
921
|
+
assertEquals(await response.text(), "handled by onNotAcceptable");
|
|
922
|
+
});
|
|
923
|
+
esm_default.hardReset();
|
|
924
|
+
});
|
|
759
925
|
test("Federation.setInboxListeners()", async (t) => {
|
|
760
926
|
const kv = new MemoryKvStore();
|
|
761
927
|
esm_default.spyGlobal();
|
|
@@ -805,13 +971,16 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
805
971
|
}
|
|
806
972
|
});
|
|
807
973
|
const inbox = [];
|
|
808
|
-
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(Create, (ctx, create) => {
|
|
974
|
+
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(vocab.Create, (ctx, create) => {
|
|
809
975
|
inbox.push([ctx, create]);
|
|
810
976
|
});
|
|
811
|
-
let response = await federation.fetch(new Request("https://example.com/inbox", {
|
|
977
|
+
let response = await federation.fetch(new Request("https://example.com/inbox", {
|
|
978
|
+
method: "POST",
|
|
979
|
+
headers: { "accept": "application/ld+json" }
|
|
980
|
+
}), { contextData: void 0 });
|
|
812
981
|
assertEquals(inbox, []);
|
|
813
982
|
assertEquals(response.status, 404);
|
|
814
|
-
federation.setActorDispatcher("/users/{identifier}", (_, identifier) => identifier === "john" ? new Person({}) : null).setKeyPairsDispatcher(() => [{
|
|
983
|
+
federation.setActorDispatcher("/users/{identifier}", (_, identifier) => identifier === "john" ? new vocab.Person({}) : null).setKeyPairsDispatcher(() => [{
|
|
815
984
|
privateKey: rsaPrivateKey2,
|
|
816
985
|
publicKey: rsaPublicKey2.publicKey
|
|
817
986
|
}]);
|
|
@@ -819,29 +988,43 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
819
988
|
documentLoader: mockDocumentLoader,
|
|
820
989
|
contextLoader: mockDocumentLoader
|
|
821
990
|
};
|
|
822
|
-
const activity = () => new Create({
|
|
991
|
+
const activity = () => new vocab.Create({
|
|
823
992
|
id: new URL("https://example.com/activities/" + crypto.randomUUID()),
|
|
824
993
|
actor: new URL("https://example.com/person2")
|
|
825
994
|
});
|
|
826
995
|
response = await federation.fetch(new Request("https://example.com/inbox", {
|
|
827
996
|
method: "POST",
|
|
828
|
-
body: JSON.stringify(await activity().toJsonLd(options))
|
|
997
|
+
body: JSON.stringify(await activity().toJsonLd(options)),
|
|
998
|
+
headers: {
|
|
999
|
+
"accept": "application/ld+json",
|
|
1000
|
+
"content-type": "application/ld+json"
|
|
1001
|
+
}
|
|
829
1002
|
}), { contextData: void 0 });
|
|
830
1003
|
assertEquals(inbox, []);
|
|
831
1004
|
assertEquals(response.status, 401);
|
|
832
|
-
response = await federation.fetch(new Request("https://example.com/users/no-one/inbox", {
|
|
1005
|
+
response = await federation.fetch(new Request("https://example.com/users/no-one/inbox", {
|
|
1006
|
+
method: "POST",
|
|
1007
|
+
headers: { "accept": "application/ld+json" }
|
|
1008
|
+
}), { contextData: void 0 });
|
|
833
1009
|
assertEquals(inbox, []);
|
|
834
1010
|
assertEquals(response.status, 404);
|
|
835
1011
|
response = await federation.fetch(new Request("https://example.com/users/john/inbox", {
|
|
836
1012
|
method: "POST",
|
|
837
|
-
body: JSON.stringify(await activity().toJsonLd(options))
|
|
1013
|
+
body: JSON.stringify(await activity().toJsonLd(options)),
|
|
1014
|
+
headers: {
|
|
1015
|
+
"accept": "application/ld+json",
|
|
1016
|
+
"content-type": "application/ld+json"
|
|
1017
|
+
}
|
|
838
1018
|
}), { contextData: void 0 });
|
|
839
1019
|
assertEquals(inbox, []);
|
|
840
1020
|
assertEquals(response.status, 401);
|
|
841
1021
|
const activityPayload = await activity().toJsonLd(options);
|
|
842
1022
|
let request = new Request("https://example.com/users/john/inbox", {
|
|
843
1023
|
method: "POST",
|
|
844
|
-
headers: {
|
|
1024
|
+
headers: {
|
|
1025
|
+
"Content-Type": "application/activity+json",
|
|
1026
|
+
accept: "application/ld+json"
|
|
1027
|
+
},
|
|
845
1028
|
body: JSON.stringify(activityPayload)
|
|
846
1029
|
});
|
|
847
1030
|
request = await signRequest(request, rsaPrivateKey3, new URL("https://example.com/person2#key3"));
|
|
@@ -858,7 +1041,10 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
858
1041
|
inbox.shift();
|
|
859
1042
|
request = new Request("https://another.host/users/john/inbox", {
|
|
860
1043
|
method: "POST",
|
|
861
|
-
headers: {
|
|
1044
|
+
headers: {
|
|
1045
|
+
"Content-Type": "application/activity+json",
|
|
1046
|
+
"accept": "application/ld+json"
|
|
1047
|
+
},
|
|
862
1048
|
body: JSON.stringify(activityPayload)
|
|
863
1049
|
});
|
|
864
1050
|
request = await signRequest(request, rsaPrivateKey3, new URL("https://example.com/person2#key3"));
|
|
@@ -873,7 +1059,10 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
873
1059
|
inbox.shift();
|
|
874
1060
|
request = new Request("https://example.com/inbox", {
|
|
875
1061
|
method: "POST",
|
|
876
|
-
headers: {
|
|
1062
|
+
headers: {
|
|
1063
|
+
"Content-Type": "application/activity+json",
|
|
1064
|
+
"accept": "application/ld+json"
|
|
1065
|
+
},
|
|
877
1066
|
body: JSON.stringify(await activity().toJsonLd(options))
|
|
878
1067
|
});
|
|
879
1068
|
request = await signRequest(request, rsaPrivateKey3, new URL("https://example.com/person2#key3"));
|
|
@@ -888,7 +1077,10 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
888
1077
|
inbox.shift();
|
|
889
1078
|
request = new Request("https://example.com/users/john/inbox", {
|
|
890
1079
|
method: "POST",
|
|
891
|
-
headers: {
|
|
1080
|
+
headers: {
|
|
1081
|
+
"Content-Type": "application/activity+json",
|
|
1082
|
+
"accept": "application/ld+json"
|
|
1083
|
+
},
|
|
892
1084
|
body: JSON.stringify(await (await signObject(activity(), ed25519PrivateKey, ed25519Multikey.id, options)).toJsonLd(options))
|
|
893
1085
|
});
|
|
894
1086
|
response = await federation.fetch(request, { contextData: void 0 });
|
|
@@ -913,21 +1105,24 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
913
1105
|
};
|
|
914
1106
|
}
|
|
915
1107
|
});
|
|
916
|
-
federation.setActorDispatcher("/users/{identifier}", (_, identifier) => identifier === "john" ? new Person({}) : null).setKeyPairsDispatcher(() => [{
|
|
1108
|
+
federation.setActorDispatcher("/users/{identifier}", (_, identifier) => identifier === "john" ? new vocab.Person({}) : null).setKeyPairsDispatcher(() => [{
|
|
917
1109
|
privateKey: rsaPrivateKey2,
|
|
918
1110
|
publicKey: rsaPublicKey2.publicKey
|
|
919
1111
|
}]);
|
|
920
1112
|
const error = /* @__PURE__ */ new Error("test");
|
|
921
1113
|
const errors = [];
|
|
922
|
-
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(Create, () => {
|
|
1114
|
+
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(vocab.Create, () => {
|
|
923
1115
|
throw error;
|
|
924
1116
|
}).onError((_, e) => {
|
|
925
1117
|
errors.push(e);
|
|
926
1118
|
});
|
|
927
|
-
const activity = new Create({ actor: new URL("https://example.com/person") });
|
|
1119
|
+
const activity = new vocab.Create({ actor: new URL("https://example.com/person") });
|
|
928
1120
|
let request = new Request("https://example.com/users/john/inbox", {
|
|
929
1121
|
method: "POST",
|
|
930
|
-
headers: {
|
|
1122
|
+
headers: {
|
|
1123
|
+
"Content-Type": "application/activity+json",
|
|
1124
|
+
"Accept": "application/activity+json"
|
|
1125
|
+
},
|
|
931
1126
|
body: JSON.stringify(await activity.toJsonLd({ contextLoader: mockDocumentLoader }))
|
|
932
1127
|
});
|
|
933
1128
|
request = await signRequest(request, rsaPrivateKey2, new URL("https://example.com/key2"));
|
|
@@ -980,8 +1175,8 @@ test("FederationImpl.sendActivity()", async (t) => {
|
|
|
980
1175
|
let json = await cl.request.json();
|
|
981
1176
|
if (await verifyJsonLd(json, options)) verified.push("ld");
|
|
982
1177
|
json = detachSignature(json);
|
|
983
|
-
let activity = await verifyObject(Activity, json, options);
|
|
984
|
-
if (activity == null) activity = await Activity.fromJsonLd(json, options);
|
|
1178
|
+
let activity = await verifyObject(vocab.Activity, json, options);
|
|
1179
|
+
if (activity == null) activity = await vocab.Activity.fromJsonLd(json, options);
|
|
985
1180
|
else verified.push("proof");
|
|
986
1181
|
const key = await verifyRequest(request, options);
|
|
987
1182
|
if (key != null && await doesActorOwnKey(activity, key, options)) verified.push("http");
|
|
@@ -991,11 +1186,11 @@ test("FederationImpl.sendActivity()", async (t) => {
|
|
|
991
1186
|
const kv = new MemoryKvStore();
|
|
992
1187
|
const federation = new FederationImpl({
|
|
993
1188
|
kv,
|
|
994
|
-
|
|
1189
|
+
contextLoaderFactory: () => mockDocumentLoader
|
|
995
1190
|
});
|
|
996
1191
|
const context = federation.createContext(new URL("https://example.com/"));
|
|
997
1192
|
await t.step("success", async () => {
|
|
998
|
-
const activity = new Create({
|
|
1193
|
+
const activity = new vocab.Create({
|
|
999
1194
|
id: new URL("https://example.com/activity/1"),
|
|
1000
1195
|
actor: new URL("https://example.com/person")
|
|
1001
1196
|
});
|
|
@@ -1070,7 +1265,7 @@ test("FederationImpl.processQueuedTask()", async (t) => {
|
|
|
1070
1265
|
kv,
|
|
1071
1266
|
queue
|
|
1072
1267
|
});
|
|
1073
|
-
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(Create, () => {
|
|
1268
|
+
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(vocab.Create, () => {
|
|
1074
1269
|
throw new Error("Intended error for testing");
|
|
1075
1270
|
});
|
|
1076
1271
|
await assertRejects(() => federation.processQueuedTask(void 0, {
|
|
@@ -1132,7 +1327,7 @@ test("FederationImpl.processQueuedTask()", async (t) => {
|
|
|
1132
1327
|
kv,
|
|
1133
1328
|
queue
|
|
1134
1329
|
});
|
|
1135
|
-
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(Create, () => {
|
|
1330
|
+
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(vocab.Create, () => {
|
|
1136
1331
|
throw new Error("Intended error for testing");
|
|
1137
1332
|
});
|
|
1138
1333
|
const outboxMessage = {
|
|
@@ -1217,7 +1412,7 @@ test("ContextImpl.lookupObject()", async (t) => {
|
|
|
1217
1412
|
});
|
|
1218
1413
|
const ctx = federation.createContext(new URL("https://example.com/"));
|
|
1219
1414
|
const result = await ctx.lookupObject("@test@localhost");
|
|
1220
|
-
assertInstanceOf(result, Person);
|
|
1415
|
+
assertInstanceOf(result, vocab.Person);
|
|
1221
1416
|
assertEquals(result.id, new URL("https://localhost/actor"));
|
|
1222
1417
|
assertEquals(result.preferredUsername, "test");
|
|
1223
1418
|
});
|
|
@@ -1243,7 +1438,7 @@ test("ContextImpl.sendActivity()", async (t) => {
|
|
|
1243
1438
|
collectionSyncHeader = cl.request.headers.get("Collection-Synchronization");
|
|
1244
1439
|
const options = {
|
|
1245
1440
|
async documentLoader(url) {
|
|
1246
|
-
const response = await federation.fetch(new Request(url), { contextData: void 0 });
|
|
1441
|
+
const response = await federation.fetch(new Request(url, { headers: { "accept": "application/ld+json" } }), { contextData: void 0 });
|
|
1247
1442
|
if (response.ok) return {
|
|
1248
1443
|
contextUrl: null,
|
|
1249
1444
|
document: await response.json(),
|
|
@@ -1266,8 +1461,8 @@ test("ContextImpl.sendActivity()", async (t) => {
|
|
|
1266
1461
|
let json = await cl.request.json();
|
|
1267
1462
|
if (await verifyJsonLd(json, options)) verified.push("ld");
|
|
1268
1463
|
json = detachSignature(json);
|
|
1269
|
-
let activity = await verifyObject(Activity, json, options);
|
|
1270
|
-
if (activity == null) activity = await Activity.fromJsonLd(json, options);
|
|
1464
|
+
let activity = await verifyObject(vocab.Activity, json, options);
|
|
1465
|
+
if (activity == null) activity = await vocab.Activity.fromJsonLd(json, options);
|
|
1271
1466
|
else verified.push("proof");
|
|
1272
1467
|
const key = await verifyRequest(request, options);
|
|
1273
1468
|
if (key != null && await doesActorOwnKey(activity, key, options)) verified.push("http");
|
|
@@ -1277,12 +1472,12 @@ test("ContextImpl.sendActivity()", async (t) => {
|
|
|
1277
1472
|
const kv = new MemoryKvStore();
|
|
1278
1473
|
const federation = new FederationImpl({
|
|
1279
1474
|
kv,
|
|
1280
|
-
|
|
1475
|
+
contextLoaderFactory: () => mockDocumentLoader
|
|
1281
1476
|
});
|
|
1282
1477
|
federation.setActorDispatcher("/{identifier}", async (ctx, identifier) => {
|
|
1283
1478
|
if (identifier !== "1") return null;
|
|
1284
1479
|
const keys = await ctx.getActorKeyPairs(identifier);
|
|
1285
|
-
return new Person({
|
|
1480
|
+
return new vocab.Person({
|
|
1286
1481
|
id: ctx.getActorUri(identifier),
|
|
1287
1482
|
preferredUsername: "john",
|
|
1288
1483
|
publicKey: keys[0].cryptographicKey,
|
|
@@ -1303,7 +1498,7 @@ test("ContextImpl.sendActivity()", async (t) => {
|
|
|
1303
1498
|
inboxId: new URL("https://example.com/inbox")
|
|
1304
1499
|
}] }));
|
|
1305
1500
|
await t.step("success", async () => {
|
|
1306
|
-
const activity = new Create({ actor: new URL("https://example.com/person") });
|
|
1501
|
+
const activity = new vocab.Create({ actor: new URL("https://example.com/person") });
|
|
1307
1502
|
const ctx = new ContextImpl({
|
|
1308
1503
|
data: void 0,
|
|
1309
1504
|
federation,
|
|
@@ -1386,13 +1581,13 @@ test("ContextImpl.sendActivity()", async (t) => {
|
|
|
1386
1581
|
};
|
|
1387
1582
|
const federation2 = new FederationImpl({
|
|
1388
1583
|
kv,
|
|
1389
|
-
|
|
1584
|
+
contextLoaderFactory: () => mockDocumentLoader,
|
|
1390
1585
|
queue
|
|
1391
1586
|
});
|
|
1392
1587
|
federation2.setActorDispatcher("/{identifier}", async (ctx, identifier) => {
|
|
1393
1588
|
if (identifier !== "john") return null;
|
|
1394
1589
|
const keys = await ctx.getActorKeyPairs(identifier);
|
|
1395
|
-
return new Person({
|
|
1590
|
+
return new vocab.Person({
|
|
1396
1591
|
id: ctx.getActorUri(identifier),
|
|
1397
1592
|
preferredUsername: "john",
|
|
1398
1593
|
publicKey: keys[0].cryptographicKey,
|
|
@@ -1416,7 +1611,7 @@ test("ContextImpl.sendActivity()", async (t) => {
|
|
|
1416
1611
|
contextLoader: fetchDocumentLoader
|
|
1417
1612
|
});
|
|
1418
1613
|
await t.step("fanout: \"force\"", async () => {
|
|
1419
|
-
const activity = new Create({
|
|
1614
|
+
const activity = new vocab.Create({
|
|
1420
1615
|
id: new URL("https://example.com/activity/1"),
|
|
1421
1616
|
actor: new URL("https://example.com/person")
|
|
1422
1617
|
});
|
|
@@ -1445,7 +1640,7 @@ test("ContextImpl.sendActivity()", async (t) => {
|
|
|
1445
1640
|
});
|
|
1446
1641
|
queue.clear();
|
|
1447
1642
|
await t.step("fanout: \"skip\"", async () => {
|
|
1448
|
-
const activity = new Create({
|
|
1643
|
+
const activity = new vocab.Create({
|
|
1449
1644
|
id: new URL("https://example.com/activity/1"),
|
|
1450
1645
|
actor: new URL("https://example.com/person")
|
|
1451
1646
|
});
|
|
@@ -1460,7 +1655,7 @@ test("ContextImpl.sendActivity()", async (t) => {
|
|
|
1460
1655
|
});
|
|
1461
1656
|
queue.clear();
|
|
1462
1657
|
await t.step("fanout: \"auto\"", async () => {
|
|
1463
|
-
const activity = new Create({
|
|
1658
|
+
const activity = new vocab.Create({
|
|
1464
1659
|
id: new URL("https://example.com/activity/1"),
|
|
1465
1660
|
actor: new URL("https://example.com/person")
|
|
1466
1661
|
});
|
|
@@ -1509,7 +1704,7 @@ test("ContextImpl.sendActivity()", async (t) => {
|
|
|
1509
1704
|
documentLoader: fetchDocumentLoader,
|
|
1510
1705
|
contextLoader: fetchDocumentLoader
|
|
1511
1706
|
});
|
|
1512
|
-
const activity = new Create({
|
|
1707
|
+
const activity = new vocab.Create({
|
|
1513
1708
|
id: new URL("https://example.com/activity/1"),
|
|
1514
1709
|
actor: ctx.getActorUri("1"),
|
|
1515
1710
|
to: ctx.getFollowersUri("1")
|
|
@@ -1526,7 +1721,7 @@ test("ContextImpl.sendActivity()", async (t) => {
|
|
|
1526
1721
|
documentLoader: fetchDocumentLoader,
|
|
1527
1722
|
contextLoader: fetchDocumentLoader
|
|
1528
1723
|
});
|
|
1529
|
-
const activity = new Create({
|
|
1724
|
+
const activity = new vocab.Create({
|
|
1530
1725
|
id: new URL("https://example.com/activity/2"),
|
|
1531
1726
|
actor: ctx.getActorUri("1"),
|
|
1532
1727
|
to: ctx.getFollowersUri("1")
|
|
@@ -1548,7 +1743,7 @@ test({
|
|
|
1548
1743
|
async fn() {
|
|
1549
1744
|
const federation = new FederationImpl({ kv: new MemoryKvStore() });
|
|
1550
1745
|
const activities = [];
|
|
1551
|
-
federation.setInboxListeners("/u/{identifier}/i", "/i").on(Offer, (ctx$1, offer) => {
|
|
1746
|
+
federation.setInboxListeners("/u/{identifier}/i", "/i").on(vocab.Offer, (ctx$1, offer) => {
|
|
1552
1747
|
activities.push([ctx$1.recipient, offer]);
|
|
1553
1748
|
});
|
|
1554
1749
|
const ctx = new ContextImpl({
|
|
@@ -1558,52 +1753,52 @@ test({
|
|
|
1558
1753
|
documentLoader: mockDocumentLoader,
|
|
1559
1754
|
contextLoader: fetchDocumentLoader
|
|
1560
1755
|
});
|
|
1561
|
-
assertFalse(await ctx.routeActivity(null, new Offer({ actor: new URL("https://example.com/person") })));
|
|
1756
|
+
assertFalse(await ctx.routeActivity(null, new vocab.Offer({ actor: new URL("https://example.com/person") })));
|
|
1562
1757
|
assertEquals(activities, []);
|
|
1563
|
-
const signedOffer = await signObject(new Offer({ actor: new URL("https://example.com/person2") }), ed25519PrivateKey, ed25519Multikey.id);
|
|
1758
|
+
const signedOffer = await signObject(new vocab.Offer({ actor: new URL("https://example.com/person2") }), ed25519PrivateKey, ed25519Multikey.id);
|
|
1564
1759
|
assert(await ctx.routeActivity(null, signedOffer));
|
|
1565
1760
|
assertEquals(activities, [[null, signedOffer]]);
|
|
1566
|
-
const signedInvite = await signObject(new Invite({ actor: new URL("https://example.com/person2") }), ed25519PrivateKey, ed25519Multikey.id);
|
|
1761
|
+
const signedInvite = await signObject(new vocab.Invite({ actor: new URL("https://example.com/person2") }), ed25519PrivateKey, ed25519Multikey.id);
|
|
1567
1762
|
assert(await ctx.routeActivity("id", signedInvite));
|
|
1568
1763
|
assertEquals(activities, [[null, signedOffer], ["id", signedInvite]]);
|
|
1569
|
-
assertFalse(await ctx.routeActivity(null, new Create({
|
|
1764
|
+
assertFalse(await ctx.routeActivity(null, new vocab.Create({
|
|
1570
1765
|
id: new URL("https://example.com/not-found"),
|
|
1571
1766
|
actor: new URL("https://example.com/person")
|
|
1572
1767
|
})));
|
|
1573
1768
|
assertEquals(activities, [[null, signedOffer], ["id", signedInvite]]);
|
|
1574
|
-
assertFalse(await ctx.routeActivity(null, new Create({
|
|
1769
|
+
assertFalse(await ctx.routeActivity(null, new vocab.Create({
|
|
1575
1770
|
id: new URL("https://example.com/person"),
|
|
1576
1771
|
actor: new URL("https://example.com/person")
|
|
1577
1772
|
})));
|
|
1578
1773
|
assertEquals(activities, [[null, signedOffer], ["id", signedInvite]]);
|
|
1579
|
-
assertFalse(await ctx.routeActivity(null, new Announce({
|
|
1774
|
+
assertFalse(await ctx.routeActivity(null, new vocab.Announce({
|
|
1580
1775
|
id: new URL("https://example.com/announce#diffrent-id"),
|
|
1581
1776
|
actor: new URL("https://example.com/person")
|
|
1582
1777
|
})));
|
|
1583
1778
|
assertEquals(activities, [[null, signedOffer], ["id", signedInvite]]);
|
|
1584
|
-
assertFalse(await ctx.routeActivity(null, new Announce({
|
|
1779
|
+
assertFalse(await ctx.routeActivity(null, new vocab.Announce({
|
|
1585
1780
|
id: new URL("https://example.com/announce"),
|
|
1586
1781
|
actor: new URL("https://example.com/person")
|
|
1587
1782
|
})));
|
|
1588
1783
|
assertEquals(activities, [[null, signedOffer], ["id", signedInvite]]);
|
|
1589
|
-
assertFalse(await ctx.routeActivity(null, new Create({
|
|
1784
|
+
assertFalse(await ctx.routeActivity(null, new vocab.Create({
|
|
1590
1785
|
id: new URL("https://example.com/cross-origin-actor"),
|
|
1591
1786
|
actor: new URL("https://cross-origin.com/actor")
|
|
1592
1787
|
})));
|
|
1593
1788
|
assertEquals(activities, [[null, signedOffer], ["id", signedInvite]]);
|
|
1594
|
-
assert(await ctx.routeActivity(null, new Create({
|
|
1789
|
+
assert(await ctx.routeActivity(null, new vocab.Create({
|
|
1595
1790
|
id: new URL("https://example.com/create"),
|
|
1596
1791
|
actor: new URL("https://example.com/person")
|
|
1597
1792
|
})));
|
|
1598
1793
|
assertEquals(activities, [[null, signedOffer], ["id", signedInvite]]);
|
|
1599
|
-
assert(await ctx.routeActivity(null, new Invite({
|
|
1794
|
+
assert(await ctx.routeActivity(null, new vocab.Invite({
|
|
1600
1795
|
id: new URL("https://example.com/invite"),
|
|
1601
1796
|
actor: new URL("https://example.com/person")
|
|
1602
1797
|
})));
|
|
1603
1798
|
assertEquals(activities, [
|
|
1604
1799
|
[null, signedOffer],
|
|
1605
1800
|
["id", signedInvite],
|
|
1606
|
-
[null, new Invite({
|
|
1801
|
+
[null, new vocab.Invite({
|
|
1607
1802
|
id: new URL("https://example.com/invite"),
|
|
1608
1803
|
actor: new URL("https://example.com/person"),
|
|
1609
1804
|
object: new URL("https://example.com/object")
|
|
@@ -1625,15 +1820,15 @@ test("ContextImpl.getCollectionUri()", () => {
|
|
|
1625
1820
|
const dispatcher = (_ctx, _values) => ({ items: [] });
|
|
1626
1821
|
let url;
|
|
1627
1822
|
const strName = "registered";
|
|
1628
|
-
federation.setCollectionDispatcher(strName, Object
|
|
1823
|
+
federation.setCollectionDispatcher(strName, vocab.Object, "/string-route/{id}", dispatcher);
|
|
1629
1824
|
url = ctx.getCollectionUri(strName, values);
|
|
1630
1825
|
assertEquals(url.href, `${base}/string-route/123`);
|
|
1631
1826
|
const unnamedSymName = Symbol(strName);
|
|
1632
|
-
federation.setCollectionDispatcher(unnamedSymName, Object
|
|
1827
|
+
federation.setCollectionDispatcher(unnamedSymName, vocab.Object, "/symbol-route/{id}", dispatcher);
|
|
1633
1828
|
url = ctx.getCollectionUri(unnamedSymName, values);
|
|
1634
1829
|
assertEquals(url.href, `${base}/symbol-route/123`);
|
|
1635
1830
|
const namedSymName = Symbol.for(strName);
|
|
1636
|
-
federation.setCollectionDispatcher(namedSymName, Object
|
|
1831
|
+
federation.setCollectionDispatcher(namedSymName, vocab.Object, "/named-symbol-route/{id}", dispatcher);
|
|
1637
1832
|
url = ctx.getCollectionUri(namedSymName, values);
|
|
1638
1833
|
assertEquals(url.href, `${base}/named-symbol-route/123`);
|
|
1639
1834
|
const notReg = "not-registered";
|
|
@@ -1655,8 +1850,8 @@ test("InboxContextImpl.forwardActivity()", async (t) => {
|
|
|
1655
1850
|
let json = await cl.request.json();
|
|
1656
1851
|
if (await verifyJsonLd(json, options)) verified.push("ld");
|
|
1657
1852
|
json = detachSignature(json);
|
|
1658
|
-
let activity = await verifyObject(Activity, json, options);
|
|
1659
|
-
if (activity == null) activity = await Activity.fromJsonLd(json, options);
|
|
1853
|
+
let activity = await verifyObject(vocab.Activity, json, options);
|
|
1854
|
+
if (activity == null) activity = await vocab.Activity.fromJsonLd(json, options);
|
|
1660
1855
|
else verified.push("proof");
|
|
1661
1856
|
const key = await verifyRequest(request, options);
|
|
1662
1857
|
if (key != null && await doesActorOwnKey(activity, key, options)) verified.push("http");
|
|
@@ -1666,7 +1861,7 @@ test("InboxContextImpl.forwardActivity()", async (t) => {
|
|
|
1666
1861
|
const kv = new MemoryKvStore();
|
|
1667
1862
|
const federation = new FederationImpl({
|
|
1668
1863
|
kv,
|
|
1669
|
-
|
|
1864
|
+
contextLoaderFactory: () => mockDocumentLoader
|
|
1670
1865
|
});
|
|
1671
1866
|
await t.step("skip", async () => {
|
|
1672
1867
|
const activity = {
|
|
@@ -1715,7 +1910,7 @@ test("InboxContextImpl.forwardActivity()", async (t) => {
|
|
|
1715
1910
|
assertEquals(verified, []);
|
|
1716
1911
|
});
|
|
1717
1912
|
await t.step("Object Integrity Proofs", async () => {
|
|
1718
|
-
const activity = await signObject(new Create({
|
|
1913
|
+
const activity = await signObject(new vocab.Create({
|
|
1719
1914
|
id: new URL("https://example.com/activity"),
|
|
1720
1915
|
actor: new URL("https://example.com/person2")
|
|
1721
1916
|
}), ed25519PrivateKey, ed25519Multikey.id, {
|