@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,44 +3,39 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { createTestTracerProvider, 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 "../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 } 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 { createFederation, handleActor, handleCollection, handleCustomCollection, handleInbox, handleObject, respondWithObject, respondWithObjectIfAcceptable } from "../middleware-DLaPtWGX.js";
|
|
13
|
+
import "../client-Dg7OfUDA.js";
|
|
14
|
+
import "../router-D9eI0s4b.js";
|
|
15
|
+
import "../types-CPz01LGH.js";
|
|
16
|
+
import "../key-t0uDOx8t.js";
|
|
17
|
+
import { signRequest } from "../http-DP374h--.js";
|
|
18
|
+
import "../ld-CpXPfqRW.js";
|
|
19
|
+
import "../owner-BaG2jUgZ.js";
|
|
20
|
+
import "../proof-D8bfMlig.js";
|
|
21
|
+
import "../docloader-2gNKaklf.js";
|
|
22
|
+
import "../kv-cache-BEeqyGER.js";
|
|
23
|
+
import { InboxListenerSet } from "../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 "../std__assert-DWivtrGR.js";
|
|
30
|
-
import
|
|
31
|
-
import "../
|
|
31
|
+
import "../assert_rejects-Ce45JcFg.js";
|
|
32
|
+
import "../assert_throws-BNXdRGWP.js";
|
|
32
33
|
import "../assert_not_equals-C80BG-_5.js";
|
|
33
|
-
import "../
|
|
34
|
-
import { rsaPrivateKey3, rsaPublicKey2, rsaPublicKey3 } from "../keys-
|
|
34
|
+
import { createInboxContext, createRequestContext } from "../context-Bns6uTJq.js";
|
|
35
|
+
import { rsaPrivateKey3, rsaPublicKey2, rsaPublicKey3 } from "../keys-ZbcByPg9.js";
|
|
36
|
+
import { Create, Note, Person } from "@fedify/vocab";
|
|
35
37
|
|
|
36
38
|
//#region src/federation/handler.test.ts
|
|
37
|
-
test("acceptsJsonLd()", () => {
|
|
38
|
-
assert(acceptsJsonLd(new Request("https://example.com/", { headers: { Accept: "application/activity+json" } })));
|
|
39
|
-
assert(acceptsJsonLd(new Request("https://example.com/", { headers: { Accept: "application/ld+json" } })));
|
|
40
|
-
assert(acceptsJsonLd(new Request("https://example.com/", { headers: { Accept: "application/json" } })));
|
|
41
|
-
assertFalse(acceptsJsonLd(new Request("https://example.com/", { headers: { Accept: "application/ld+json; q=0.5, text/html; q=0.8" } })));
|
|
42
|
-
assertFalse(acceptsJsonLd(new Request("https://example.com/", { headers: { Accept: "application/ld+json; q=0.4, application/xhtml+xml; q=0.9" } })));
|
|
43
|
-
});
|
|
44
39
|
test("handleActor()", async () => {
|
|
45
40
|
const federation = createFederation({ kv: new MemoryKvStore() });
|
|
46
41
|
let context = createRequestContext({
|
|
@@ -63,11 +58,6 @@ test("handleActor()", async () => {
|
|
|
63
58
|
onNotFoundCalled = request;
|
|
64
59
|
return new Response("Not found", { status: 404 });
|
|
65
60
|
};
|
|
66
|
-
let onNotAcceptableCalled = null;
|
|
67
|
-
const onNotAcceptable = (request) => {
|
|
68
|
-
onNotAcceptableCalled = request;
|
|
69
|
-
return new Response("Not acceptable", { status: 406 });
|
|
70
|
-
};
|
|
71
61
|
let onUnauthorizedCalled = null;
|
|
72
62
|
const onUnauthorized = (request) => {
|
|
73
63
|
onUnauthorizedCalled = request;
|
|
@@ -77,44 +67,21 @@ test("handleActor()", async () => {
|
|
|
77
67
|
context,
|
|
78
68
|
identifier: "someone",
|
|
79
69
|
onNotFound,
|
|
80
|
-
onNotAcceptable,
|
|
81
70
|
onUnauthorized
|
|
82
71
|
});
|
|
83
72
|
assertEquals(response.status, 404);
|
|
84
73
|
assertEquals(onNotFoundCalled, context.request);
|
|
85
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
86
74
|
assertEquals(onUnauthorizedCalled, null);
|
|
87
75
|
onNotFoundCalled = null;
|
|
88
|
-
context = createRequestContext({
|
|
89
|
-
...context,
|
|
90
|
-
getActor(handle) {
|
|
91
|
-
return Promise.resolve(actorDispatcher(context, handle));
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
response = await handleActor(context.request, {
|
|
95
|
-
context,
|
|
96
|
-
identifier: "someone",
|
|
97
|
-
actorDispatcher,
|
|
98
|
-
onNotFound,
|
|
99
|
-
onNotAcceptable,
|
|
100
|
-
onUnauthorized
|
|
101
|
-
});
|
|
102
|
-
assertEquals(response.status, 406);
|
|
103
|
-
assertEquals(onNotFoundCalled, null);
|
|
104
|
-
assertEquals(onNotAcceptableCalled, context.request);
|
|
105
|
-
assertEquals(onUnauthorizedCalled, null);
|
|
106
|
-
onNotAcceptableCalled = null;
|
|
107
76
|
response = await handleActor(context.request, {
|
|
108
77
|
context,
|
|
109
78
|
identifier: "no-one",
|
|
110
79
|
actorDispatcher,
|
|
111
80
|
onNotFound,
|
|
112
|
-
onNotAcceptable,
|
|
113
81
|
onUnauthorized
|
|
114
82
|
});
|
|
115
83
|
assertEquals(response.status, 404);
|
|
116
84
|
assertEquals(onNotFoundCalled, context.request);
|
|
117
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
118
85
|
assertEquals(onUnauthorizedCalled, null);
|
|
119
86
|
onNotFoundCalled = null;
|
|
120
87
|
context = createRequestContext({
|
|
@@ -126,7 +93,6 @@ test("handleActor()", async () => {
|
|
|
126
93
|
identifier: "someone",
|
|
127
94
|
actorDispatcher,
|
|
128
95
|
onNotFound,
|
|
129
|
-
onNotAcceptable,
|
|
130
96
|
onUnauthorized
|
|
131
97
|
});
|
|
132
98
|
assertEquals(response.status, 200);
|
|
@@ -175,19 +141,16 @@ test("handleActor()", async () => {
|
|
|
175
141
|
name: "Someone"
|
|
176
142
|
});
|
|
177
143
|
assertEquals(onNotFoundCalled, null);
|
|
178
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
179
144
|
assertEquals(onUnauthorizedCalled, null);
|
|
180
145
|
response = await handleActor(context.request, {
|
|
181
146
|
context,
|
|
182
147
|
identifier: "no-one",
|
|
183
148
|
actorDispatcher,
|
|
184
149
|
onNotFound,
|
|
185
|
-
onNotAcceptable,
|
|
186
150
|
onUnauthorized
|
|
187
151
|
});
|
|
188
152
|
assertEquals(response.status, 404);
|
|
189
153
|
assertEquals(onNotFoundCalled, context.request);
|
|
190
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
191
154
|
assertEquals(onUnauthorizedCalled, null);
|
|
192
155
|
onNotFoundCalled = null;
|
|
193
156
|
response = await handleActor(context.request, {
|
|
@@ -196,12 +159,10 @@ test("handleActor()", async () => {
|
|
|
196
159
|
actorDispatcher,
|
|
197
160
|
authorizePredicate: (_ctx, _handle, signedKey, signedKeyOwner) => signedKey != null && signedKeyOwner != null,
|
|
198
161
|
onNotFound,
|
|
199
|
-
onNotAcceptable,
|
|
200
162
|
onUnauthorized
|
|
201
163
|
});
|
|
202
164
|
assertEquals(response.status, 401);
|
|
203
165
|
assertEquals(onNotFoundCalled, null);
|
|
204
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
205
166
|
assertEquals(onUnauthorizedCalled, context.request);
|
|
206
167
|
onUnauthorizedCalled = null;
|
|
207
168
|
context = createRequestContext({
|
|
@@ -215,7 +176,6 @@ test("handleActor()", async () => {
|
|
|
215
176
|
actorDispatcher,
|
|
216
177
|
authorizePredicate: (_ctx, _handle, signedKey, signedKeyOwner) => signedKey != null && signedKeyOwner != null,
|
|
217
178
|
onNotFound,
|
|
218
|
-
onNotAcceptable,
|
|
219
179
|
onUnauthorized
|
|
220
180
|
});
|
|
221
181
|
assertEquals(response.status, 200);
|
|
@@ -264,7 +224,6 @@ test("handleActor()", async () => {
|
|
|
264
224
|
name: "Someone"
|
|
265
225
|
});
|
|
266
226
|
assertEquals(onNotFoundCalled, null);
|
|
267
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
268
227
|
assertEquals(onUnauthorizedCalled, null);
|
|
269
228
|
});
|
|
270
229
|
test("handleObject()", async () => {
|
|
@@ -289,11 +248,6 @@ test("handleObject()", async () => {
|
|
|
289
248
|
onNotFoundCalled = request;
|
|
290
249
|
return new Response("Not found", { status: 404 });
|
|
291
250
|
};
|
|
292
|
-
let onNotAcceptableCalled = null;
|
|
293
|
-
const onNotAcceptable = (request) => {
|
|
294
|
-
onNotAcceptableCalled = request;
|
|
295
|
-
return new Response("Not acceptable", { status: 406 });
|
|
296
|
-
};
|
|
297
251
|
let onUnauthorizedCalled = null;
|
|
298
252
|
const onUnauthorized = (request) => {
|
|
299
253
|
onUnauthorizedCalled = request;
|
|
@@ -306,12 +260,10 @@ test("handleObject()", async () => {
|
|
|
306
260
|
id: "123"
|
|
307
261
|
},
|
|
308
262
|
onNotFound,
|
|
309
|
-
onNotAcceptable,
|
|
310
263
|
onUnauthorized
|
|
311
264
|
});
|
|
312
265
|
assertEquals(response.status, 404);
|
|
313
266
|
assertEquals(onNotFoundCalled, context.request);
|
|
314
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
315
267
|
assertEquals(onUnauthorizedCalled, null);
|
|
316
268
|
onNotFoundCalled = null;
|
|
317
269
|
response = await handleObject(context.request, {
|
|
@@ -322,14 +274,11 @@ test("handleObject()", async () => {
|
|
|
322
274
|
},
|
|
323
275
|
objectDispatcher,
|
|
324
276
|
onNotFound,
|
|
325
|
-
onNotAcceptable,
|
|
326
277
|
onUnauthorized
|
|
327
278
|
});
|
|
328
|
-
assertEquals(response.status,
|
|
279
|
+
assertEquals(response.status, 200);
|
|
329
280
|
assertEquals(onNotFoundCalled, null);
|
|
330
|
-
assertEquals(onNotAcceptableCalled, context.request);
|
|
331
281
|
assertEquals(onUnauthorizedCalled, null);
|
|
332
|
-
onNotAcceptableCalled = null;
|
|
333
282
|
response = await handleObject(context.request, {
|
|
334
283
|
context,
|
|
335
284
|
values: {
|
|
@@ -338,12 +287,10 @@ test("handleObject()", async () => {
|
|
|
338
287
|
},
|
|
339
288
|
objectDispatcher,
|
|
340
289
|
onNotFound,
|
|
341
|
-
onNotAcceptable,
|
|
342
290
|
onUnauthorized
|
|
343
291
|
});
|
|
344
292
|
assertEquals(response.status, 404);
|
|
345
293
|
assertEquals(onNotFoundCalled, context.request);
|
|
346
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
347
294
|
assertEquals(onUnauthorizedCalled, null);
|
|
348
295
|
onNotFoundCalled = null;
|
|
349
296
|
response = await handleObject(context.request, {
|
|
@@ -354,12 +301,10 @@ test("handleObject()", async () => {
|
|
|
354
301
|
},
|
|
355
302
|
objectDispatcher,
|
|
356
303
|
onNotFound,
|
|
357
|
-
onNotAcceptable,
|
|
358
304
|
onUnauthorized
|
|
359
305
|
});
|
|
360
306
|
assertEquals(response.status, 404);
|
|
361
307
|
assertEquals(onNotFoundCalled, context.request);
|
|
362
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
363
308
|
assertEquals(onUnauthorizedCalled, null);
|
|
364
309
|
onNotFoundCalled = null;
|
|
365
310
|
context = createRequestContext({
|
|
@@ -374,7 +319,6 @@ test("handleObject()", async () => {
|
|
|
374
319
|
},
|
|
375
320
|
objectDispatcher,
|
|
376
321
|
onNotFound,
|
|
377
|
-
onNotAcceptable,
|
|
378
322
|
onUnauthorized
|
|
379
323
|
});
|
|
380
324
|
assertEquals(response.status, 200);
|
|
@@ -404,7 +348,6 @@ test("handleObject()", async () => {
|
|
|
404
348
|
type: "Note"
|
|
405
349
|
});
|
|
406
350
|
assertEquals(onNotFoundCalled, null);
|
|
407
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
408
351
|
assertEquals(onUnauthorizedCalled, null);
|
|
409
352
|
response = await handleObject(context.request, {
|
|
410
353
|
context,
|
|
@@ -414,12 +357,10 @@ test("handleObject()", async () => {
|
|
|
414
357
|
},
|
|
415
358
|
objectDispatcher,
|
|
416
359
|
onNotFound,
|
|
417
|
-
onNotAcceptable,
|
|
418
360
|
onUnauthorized
|
|
419
361
|
});
|
|
420
362
|
assertEquals(response.status, 404);
|
|
421
363
|
assertEquals(onNotFoundCalled, context.request);
|
|
422
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
423
364
|
assertEquals(onUnauthorizedCalled, null);
|
|
424
365
|
onNotFoundCalled = null;
|
|
425
366
|
response = await handleObject(context.request, {
|
|
@@ -430,12 +371,10 @@ test("handleObject()", async () => {
|
|
|
430
371
|
},
|
|
431
372
|
objectDispatcher,
|
|
432
373
|
onNotFound,
|
|
433
|
-
onNotAcceptable,
|
|
434
374
|
onUnauthorized
|
|
435
375
|
});
|
|
436
376
|
assertEquals(response.status, 404);
|
|
437
377
|
assertEquals(onNotFoundCalled, context.request);
|
|
438
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
439
378
|
assertEquals(onUnauthorizedCalled, null);
|
|
440
379
|
onNotFoundCalled = null;
|
|
441
380
|
response = await handleObject(context.request, {
|
|
@@ -447,12 +386,10 @@ test("handleObject()", async () => {
|
|
|
447
386
|
objectDispatcher,
|
|
448
387
|
authorizePredicate: (_ctx, _values, signedKey, signedKeyOwner) => signedKey != null && signedKeyOwner != null,
|
|
449
388
|
onNotFound,
|
|
450
|
-
onNotAcceptable,
|
|
451
389
|
onUnauthorized
|
|
452
390
|
});
|
|
453
391
|
assertEquals(response.status, 401);
|
|
454
392
|
assertEquals(onNotFoundCalled, null);
|
|
455
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
456
393
|
assertEquals(onUnauthorizedCalled, context.request);
|
|
457
394
|
onUnauthorizedCalled = null;
|
|
458
395
|
context = createRequestContext({
|
|
@@ -469,7 +406,6 @@ test("handleObject()", async () => {
|
|
|
469
406
|
objectDispatcher,
|
|
470
407
|
authorizePredicate: (_ctx, _values, signedKey, signedKeyOwner) => signedKey != null && signedKeyOwner != null,
|
|
471
408
|
onNotFound,
|
|
472
|
-
onNotAcceptable,
|
|
473
409
|
onUnauthorized
|
|
474
410
|
});
|
|
475
411
|
assertEquals(response.status, 200);
|
|
@@ -499,7 +435,6 @@ test("handleObject()", async () => {
|
|
|
499
435
|
type: "Note"
|
|
500
436
|
});
|
|
501
437
|
assertEquals(onNotFoundCalled, null);
|
|
502
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
503
438
|
assertEquals(onUnauthorizedCalled, null);
|
|
504
439
|
});
|
|
505
440
|
test("handleCollection()", async () => {
|
|
@@ -537,11 +472,6 @@ test("handleCollection()", async () => {
|
|
|
537
472
|
onNotFoundCalled = request;
|
|
538
473
|
return new Response("Not found", { status: 404 });
|
|
539
474
|
};
|
|
540
|
-
let onNotAcceptableCalled = null;
|
|
541
|
-
const onNotAcceptable = (request) => {
|
|
542
|
-
onNotAcceptableCalled = request;
|
|
543
|
-
return new Response("Not acceptable", { status: 406 });
|
|
544
|
-
};
|
|
545
475
|
let onUnauthorizedCalled = null;
|
|
546
476
|
const onUnauthorized = (request) => {
|
|
547
477
|
onUnauthorizedCalled = request;
|
|
@@ -555,12 +485,10 @@ test("handleCollection()", async () => {
|
|
|
555
485
|
return new URL(`https://example.com/users/${identifier}`);
|
|
556
486
|
},
|
|
557
487
|
onNotFound,
|
|
558
|
-
onNotAcceptable,
|
|
559
488
|
onUnauthorized
|
|
560
489
|
});
|
|
561
490
|
assertEquals(response.status, 404);
|
|
562
491
|
assertEquals(onNotFoundCalled, context.request);
|
|
563
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
564
492
|
assertEquals(onUnauthorizedCalled, null);
|
|
565
493
|
onNotFoundCalled = null;
|
|
566
494
|
response = await handleCollection(context.request, {
|
|
@@ -572,14 +500,11 @@ test("handleCollection()", async () => {
|
|
|
572
500
|
},
|
|
573
501
|
collectionCallbacks: { dispatcher },
|
|
574
502
|
onNotFound,
|
|
575
|
-
onNotAcceptable,
|
|
576
503
|
onUnauthorized
|
|
577
504
|
});
|
|
578
|
-
assertEquals(response.status,
|
|
505
|
+
assertEquals(response.status, 200);
|
|
579
506
|
assertEquals(onNotFoundCalled, null);
|
|
580
|
-
assertEquals(onNotAcceptableCalled, context.request);
|
|
581
507
|
assertEquals(onUnauthorizedCalled, null);
|
|
582
|
-
onNotAcceptableCalled = null;
|
|
583
508
|
response = await handleCollection(context.request, {
|
|
584
509
|
context,
|
|
585
510
|
name: "collection",
|
|
@@ -589,12 +514,10 @@ test("handleCollection()", async () => {
|
|
|
589
514
|
},
|
|
590
515
|
collectionCallbacks: { dispatcher },
|
|
591
516
|
onNotFound,
|
|
592
|
-
onNotAcceptable,
|
|
593
517
|
onUnauthorized
|
|
594
518
|
});
|
|
595
519
|
assertEquals(response.status, 404);
|
|
596
520
|
assertEquals(onNotFoundCalled, context.request);
|
|
597
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
598
521
|
assertEquals(onUnauthorizedCalled, null);
|
|
599
522
|
onNotFoundCalled = null;
|
|
600
523
|
context = createRequestContext({
|
|
@@ -610,12 +533,10 @@ test("handleCollection()", async () => {
|
|
|
610
533
|
},
|
|
611
534
|
collectionCallbacks: { dispatcher },
|
|
612
535
|
onNotFound,
|
|
613
|
-
onNotAcceptable,
|
|
614
536
|
onUnauthorized
|
|
615
537
|
});
|
|
616
538
|
assertEquals(response.status, 404);
|
|
617
539
|
assertEquals(onNotFoundCalled, context.request);
|
|
618
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
619
540
|
assertEquals(onUnauthorizedCalled, null);
|
|
620
541
|
onNotFoundCalled = null;
|
|
621
542
|
response = await handleCollection(context.request, {
|
|
@@ -627,7 +548,6 @@ test("handleCollection()", async () => {
|
|
|
627
548
|
},
|
|
628
549
|
collectionCallbacks: { dispatcher },
|
|
629
550
|
onNotFound,
|
|
630
|
-
onNotAcceptable,
|
|
631
551
|
onUnauthorized
|
|
632
552
|
});
|
|
633
553
|
assertEquals(response.status, 200);
|
|
@@ -700,7 +620,6 @@ test("handleCollection()", async () => {
|
|
|
700
620
|
]
|
|
701
621
|
});
|
|
702
622
|
assertEquals(onNotFoundCalled, null);
|
|
703
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
704
623
|
assertEquals(onUnauthorizedCalled, null);
|
|
705
624
|
response = await handleCollection(context.request, {
|
|
706
625
|
context,
|
|
@@ -714,12 +633,10 @@ test("handleCollection()", async () => {
|
|
|
714
633
|
authorizePredicate: (_ctx, _handle, key, keyOwner) => key != null && keyOwner != null
|
|
715
634
|
},
|
|
716
635
|
onNotFound,
|
|
717
|
-
onNotAcceptable,
|
|
718
636
|
onUnauthorized
|
|
719
637
|
});
|
|
720
638
|
assertEquals(response.status, 401);
|
|
721
639
|
assertEquals(onNotFoundCalled, null);
|
|
722
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
723
640
|
assertEquals(onUnauthorizedCalled, context.request);
|
|
724
641
|
onUnauthorizedCalled = null;
|
|
725
642
|
context = createRequestContext({
|
|
@@ -739,7 +656,6 @@ test("handleCollection()", async () => {
|
|
|
739
656
|
authorizePredicate: (_ctx, _handle, key, keyOwner) => key != null && keyOwner != null
|
|
740
657
|
},
|
|
741
658
|
onNotFound,
|
|
742
|
-
onNotAcceptable,
|
|
743
659
|
onUnauthorized
|
|
744
660
|
});
|
|
745
661
|
assertEquals(response.status, 200);
|
|
@@ -787,7 +703,6 @@ test("handleCollection()", async () => {
|
|
|
787
703
|
]
|
|
788
704
|
});
|
|
789
705
|
assertEquals(onNotFoundCalled, null);
|
|
790
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
791
706
|
assertEquals(onUnauthorizedCalled, null);
|
|
792
707
|
response = await handleCollection(context.request, {
|
|
793
708
|
context,
|
|
@@ -803,7 +718,6 @@ test("handleCollection()", async () => {
|
|
|
803
718
|
lastCursor
|
|
804
719
|
},
|
|
805
720
|
onNotFound,
|
|
806
|
-
onNotAcceptable,
|
|
807
721
|
onUnauthorized
|
|
808
722
|
});
|
|
809
723
|
assertEquals(response.status, 200);
|
|
@@ -837,7 +751,6 @@ test("handleCollection()", async () => {
|
|
|
837
751
|
last: "https://example.com/?cursor=2"
|
|
838
752
|
});
|
|
839
753
|
assertEquals(onNotFoundCalled, null);
|
|
840
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
841
754
|
assertEquals(onUnauthorizedCalled, null);
|
|
842
755
|
let url = new URL("https://example.com/?cursor=0");
|
|
843
756
|
context = createRequestContext({
|
|
@@ -859,7 +772,6 @@ test("handleCollection()", async () => {
|
|
|
859
772
|
lastCursor
|
|
860
773
|
},
|
|
861
774
|
onNotFound,
|
|
862
|
-
onNotAcceptable,
|
|
863
775
|
onUnauthorized
|
|
864
776
|
});
|
|
865
777
|
assertEquals(response.status, 200);
|
|
@@ -897,7 +809,6 @@ test("handleCollection()", async () => {
|
|
|
897
809
|
}]
|
|
898
810
|
});
|
|
899
811
|
assertEquals(onNotFoundCalled, null);
|
|
900
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
901
812
|
assertEquals(onUnauthorizedCalled, null);
|
|
902
813
|
url = new URL("https://example.com/?cursor=2");
|
|
903
814
|
context = createRequestContext({
|
|
@@ -919,7 +830,6 @@ test("handleCollection()", async () => {
|
|
|
919
830
|
lastCursor
|
|
920
831
|
},
|
|
921
832
|
onNotFound,
|
|
922
|
-
onNotAcceptable,
|
|
923
833
|
onUnauthorized
|
|
924
834
|
});
|
|
925
835
|
assertEquals(response.status, 200);
|
|
@@ -957,7 +867,6 @@ test("handleCollection()", async () => {
|
|
|
957
867
|
}]
|
|
958
868
|
});
|
|
959
869
|
assertEquals(onNotFoundCalled, null);
|
|
960
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
961
870
|
assertEquals(onUnauthorizedCalled, null);
|
|
962
871
|
});
|
|
963
872
|
test("handleInbox()", async () => {
|
|
@@ -1329,11 +1238,6 @@ test("handleCustomCollection()", async () => {
|
|
|
1329
1238
|
onNotFoundCalled = request;
|
|
1330
1239
|
return new Response("Not found", { status: 404 });
|
|
1331
1240
|
};
|
|
1332
|
-
let onNotAcceptableCalled = null;
|
|
1333
|
-
const onNotAcceptable = (request) => {
|
|
1334
|
-
onNotAcceptableCalled = request;
|
|
1335
|
-
return new Response("Not acceptable", { status: 406 });
|
|
1336
|
-
};
|
|
1337
1241
|
let onUnauthorizedCalled = null;
|
|
1338
1242
|
const onUnauthorized = (request) => {
|
|
1339
1243
|
onUnauthorizedCalled = request;
|
|
@@ -1341,7 +1245,6 @@ test("handleCustomCollection()", async () => {
|
|
|
1341
1245
|
};
|
|
1342
1246
|
const errorHandlers = {
|
|
1343
1247
|
onNotFound,
|
|
1344
|
-
onNotAcceptable,
|
|
1345
1248
|
onUnauthorized
|
|
1346
1249
|
};
|
|
1347
1250
|
let response = await handleCustomCollection(context.request, {
|
|
@@ -1352,21 +1255,7 @@ test("handleCustomCollection()", async () => {
|
|
|
1352
1255
|
});
|
|
1353
1256
|
assertEquals(response.status, 404);
|
|
1354
1257
|
assertEquals(onNotFoundCalled, context.request);
|
|
1355
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
1356
|
-
assertEquals(onUnauthorizedCalled, null);
|
|
1357
|
-
onNotFoundCalled = null;
|
|
1358
|
-
response = await handleCustomCollection(context.request, {
|
|
1359
|
-
context,
|
|
1360
|
-
name: "custom collection",
|
|
1361
|
-
values: { handle: "someone" },
|
|
1362
|
-
collectionCallbacks: { dispatcher },
|
|
1363
|
-
...errorHandlers
|
|
1364
|
-
});
|
|
1365
|
-
assertEquals(response.status, 406);
|
|
1366
|
-
assertEquals(onNotFoundCalled, null);
|
|
1367
|
-
assertEquals(onNotAcceptableCalled, context.request);
|
|
1368
1258
|
assertEquals(onUnauthorizedCalled, null);
|
|
1369
|
-
onNotAcceptableCalled = null;
|
|
1370
1259
|
context = createRequestContext({
|
|
1371
1260
|
...context,
|
|
1372
1261
|
request: new Request(context.url, { headers: { Accept: "application/activity+json" } })
|
|
@@ -1380,7 +1269,6 @@ test("handleCustomCollection()", async () => {
|
|
|
1380
1269
|
});
|
|
1381
1270
|
assertEquals(response.status, 404);
|
|
1382
1271
|
assertEquals(onNotFoundCalled, context.request);
|
|
1383
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
1384
1272
|
assertEquals(onUnauthorizedCalled, null);
|
|
1385
1273
|
onNotFoundCalled = null;
|
|
1386
1274
|
response = await handleCustomCollection(context.request, {
|
|
@@ -1461,7 +1349,6 @@ test("handleCustomCollection()", async () => {
|
|
|
1461
1349
|
]
|
|
1462
1350
|
});
|
|
1463
1351
|
assertEquals(onNotFoundCalled, null);
|
|
1464
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
1465
1352
|
assertEquals(onUnauthorizedCalled, null);
|
|
1466
1353
|
response = await handleCustomCollection(context.request, {
|
|
1467
1354
|
context,
|
|
@@ -1475,7 +1362,6 @@ test("handleCustomCollection()", async () => {
|
|
|
1475
1362
|
});
|
|
1476
1363
|
assertEquals(response.status, 401);
|
|
1477
1364
|
assertEquals(onNotFoundCalled, null);
|
|
1478
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
1479
1365
|
assertEquals(onUnauthorizedCalled, context.request);
|
|
1480
1366
|
onUnauthorizedCalled = null;
|
|
1481
1367
|
context = createRequestContext({
|
|
@@ -1518,7 +1404,6 @@ test("handleCustomCollection()", async () => {
|
|
|
1518
1404
|
]
|
|
1519
1405
|
});
|
|
1520
1406
|
assertEquals(onNotFoundCalled, null);
|
|
1521
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
1522
1407
|
assertEquals(onUnauthorizedCalled, null);
|
|
1523
1408
|
response = await handleCustomCollection(context.request, {
|
|
1524
1409
|
context,
|
|
@@ -1538,7 +1423,6 @@ test("handleCustomCollection()", async () => {
|
|
|
1538
1423
|
last: "https://example.com/?cursor=2"
|
|
1539
1424
|
});
|
|
1540
1425
|
assertEquals(onNotFoundCalled, null);
|
|
1541
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
1542
1426
|
assertEquals(onUnauthorizedCalled, null);
|
|
1543
1427
|
let url = new URL("https://example.com/?cursor=0");
|
|
1544
1428
|
context = createRequestContext({
|
|
@@ -1568,7 +1452,6 @@ test("handleCustomCollection()", async () => {
|
|
|
1568
1452
|
}
|
|
1569
1453
|
});
|
|
1570
1454
|
assertEquals(onNotFoundCalled, null);
|
|
1571
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
1572
1455
|
assertEquals(onUnauthorizedCalled, null);
|
|
1573
1456
|
url = new URL("https://example.com/?cursor=2");
|
|
1574
1457
|
context = createRequestContext({
|
|
@@ -1598,8 +1481,93 @@ test("handleCustomCollection()", async () => {
|
|
|
1598
1481
|
}
|
|
1599
1482
|
});
|
|
1600
1483
|
assertEquals(onNotFoundCalled, null);
|
|
1601
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
1602
1484
|
assertEquals(onUnauthorizedCalled, null);
|
|
1603
1485
|
});
|
|
1486
|
+
test("handleInbox() records OpenTelemetry span events", async () => {
|
|
1487
|
+
const [tracerProvider, exporter] = createTestTracerProvider();
|
|
1488
|
+
const kv = new MemoryKvStore();
|
|
1489
|
+
const federation = createFederation({
|
|
1490
|
+
kv,
|
|
1491
|
+
tracerProvider
|
|
1492
|
+
});
|
|
1493
|
+
const activity = new Create({
|
|
1494
|
+
id: new URL("https://example.com/activity"),
|
|
1495
|
+
actor: new URL("https://example.com/users/someone"),
|
|
1496
|
+
object: new Note({
|
|
1497
|
+
id: new URL("https://example.com/note"),
|
|
1498
|
+
content: "Hello, world!"
|
|
1499
|
+
})
|
|
1500
|
+
});
|
|
1501
|
+
const request = new Request("https://example.com/users/someone/inbox", {
|
|
1502
|
+
method: "POST",
|
|
1503
|
+
headers: { "Content-Type": "application/activity+json" },
|
|
1504
|
+
body: JSON.stringify(await activity.toJsonLd())
|
|
1505
|
+
});
|
|
1506
|
+
const signed = await signRequest(request, rsaPrivateKey3, new URL("https://example.com/users/someone#main-key"));
|
|
1507
|
+
const context = createRequestContext({
|
|
1508
|
+
federation,
|
|
1509
|
+
request: signed,
|
|
1510
|
+
url: new URL(signed.url),
|
|
1511
|
+
data: void 0,
|
|
1512
|
+
documentLoader: mockDocumentLoader,
|
|
1513
|
+
contextLoader: mockDocumentLoader,
|
|
1514
|
+
getActorUri(identifier) {
|
|
1515
|
+
return new URL(`https://example.com/users/${identifier}`);
|
|
1516
|
+
}
|
|
1517
|
+
});
|
|
1518
|
+
const actorDispatcher = (ctx, handle) => {
|
|
1519
|
+
if (handle !== "someone") return null;
|
|
1520
|
+
return new Person({
|
|
1521
|
+
id: ctx.getActorUri(handle),
|
|
1522
|
+
name: "Someone",
|
|
1523
|
+
inbox: new URL("https://example.com/users/someone/inbox"),
|
|
1524
|
+
publicKey: rsaPublicKey2
|
|
1525
|
+
});
|
|
1526
|
+
};
|
|
1527
|
+
const listeners = new InboxListenerSet();
|
|
1528
|
+
let receivedActivity = null;
|
|
1529
|
+
listeners.add(Create, (_ctx, activity$1) => {
|
|
1530
|
+
receivedActivity = activity$1;
|
|
1531
|
+
});
|
|
1532
|
+
const response = await handleInbox(signed, {
|
|
1533
|
+
recipient: "someone",
|
|
1534
|
+
context,
|
|
1535
|
+
inboxContextFactory(_activity) {
|
|
1536
|
+
return createInboxContext({
|
|
1537
|
+
...context,
|
|
1538
|
+
clone: void 0
|
|
1539
|
+
});
|
|
1540
|
+
},
|
|
1541
|
+
kv,
|
|
1542
|
+
kvPrefixes: {
|
|
1543
|
+
activityIdempotence: ["activityIdempotence"],
|
|
1544
|
+
publicKey: ["publicKey"]
|
|
1545
|
+
},
|
|
1546
|
+
actorDispatcher,
|
|
1547
|
+
inboxListeners: listeners,
|
|
1548
|
+
inboxErrorHandler: void 0,
|
|
1549
|
+
onNotFound: (_request) => new Response("Not found", { status: 404 }),
|
|
1550
|
+
signatureTimeWindow: false,
|
|
1551
|
+
skipSignatureVerification: true,
|
|
1552
|
+
tracerProvider
|
|
1553
|
+
});
|
|
1554
|
+
assertEquals(response.status, 202);
|
|
1555
|
+
assert(receivedActivity != null);
|
|
1556
|
+
const spans = exporter.getSpans("activitypub.inbox");
|
|
1557
|
+
assertEquals(spans.length, 1);
|
|
1558
|
+
const span = spans[0];
|
|
1559
|
+
assertEquals(span.attributes["fedify.inbox.recipient"], "someone");
|
|
1560
|
+
assertEquals(span.attributes["activitypub.activity.id"], "https://example.com/activity");
|
|
1561
|
+
const events = exporter.getEvents("activitypub.inbox", "activitypub.activity.received");
|
|
1562
|
+
assertEquals(events.length, 1);
|
|
1563
|
+
const event = events[0];
|
|
1564
|
+
assert(event.attributes != null);
|
|
1565
|
+
assertEquals(event.attributes["activitypub.activity.verified"], true);
|
|
1566
|
+
assertEquals(event.attributes["http_signatures.verified"], false);
|
|
1567
|
+
assert(typeof event.attributes["activitypub.activity.json"] === "string");
|
|
1568
|
+
const recordedActivity = JSON.parse(event.attributes["activitypub.activity.json"]);
|
|
1569
|
+
assertEquals(recordedActivity.id, "https://example.com/activity");
|
|
1570
|
+
assertEquals(recordedActivity.type, "Create");
|
|
1571
|
+
});
|
|
1604
1572
|
|
|
1605
1573
|
//#endregion
|