@fedify/fedify 2.0.0-dev.1566 → 2.0.0-dev.159
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-DiIiJbZn.js → assert_rejects-Ce45JcFg.js} +1 -1
- package/dist/{assert_is_error-BPGph1Jx.js → assert_throws-BNXdRGWP.js} +31 -1
- package/dist/{builder-B2I70zuM.js → builder-oZcZfn1d.js} +15 -8
- package/dist/chunk-DqRYRqnO.cjs +34 -0
- package/dist/client-94iWEfQa.d.cts +222 -0
- package/dist/{client-DF8anIB5.d.ts → client-BivSNrEg.d.ts} +3 -75
- package/dist/{client-BVDUd3WA.js → client-CgMTXmAD.js} +3 -22
- package/dist/compat/mod.cjs +10 -0
- package/dist/compat/mod.d.cts +7 -0
- package/dist/compat/mod.d.ts +6 -12
- package/dist/compat/mod.js +5 -5
- package/dist/compat/transformers.test.js +21 -20
- package/dist/compat-DmDDELst.cjs +4 -0
- package/dist/compat-nxUqe4Z-.js +4 -0
- package/dist/context-Bns6uTJq.js +109 -0
- package/dist/{context-9gCpIkiz.d.ts → context-CYZ2i00R.d.ts} +321 -129
- package/dist/context-D2MrtLch.d.cts +2447 -0
- package/dist/deno-CGe3r5lB.js +117 -0
- package/dist/{testing-CWE5Nn0S.js → dist-B5f6a8Tt.js} +90 -111
- package/dist/{authdocloader-BilVqAPe.js → docloader-Bh4ZzxTs.js} +17 -8
- package/dist/{esm-eH43VACi.js → esm-DGl7uK1r.js} +32 -17
- package/dist/federation/builder.test.js +12 -13
- package/dist/federation/collection.test.js +6 -9
- package/dist/federation/handler.test.js +115 -148
- 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 +61 -9
- package/dist/federation/middleware.test.js +311 -131
- package/dist/federation/mod.cjs +25 -0
- package/dist/federation/mod.d.cts +7 -0
- package/dist/federation/mod.d.ts +7 -13
- package/dist/federation/mod.js +11 -16
- package/dist/federation/mq.test.js +9 -10
- package/dist/federation/negotiation.test.js +25 -0
- package/dist/federation/retry.test.js +2 -4
- package/dist/federation/router.test.js +6 -8
- package/dist/federation/send.test.js +55 -15
- package/dist/{webfinger/handler.test.js → federation/webfinger.test.js} +27 -26
- package/dist/federation-B431K2gm.cjs +266 -0
- package/dist/{federation-CMX7WzeL.js → federation-BbZwNNWj.js} +31 -9
- package/dist/http-AW19epBO.cjs +1222 -0
- package/dist/{http-BE2S7wC2.js → http-CN7c23sh.js} +4 -3
- package/dist/{http-Cdjyj7h1.js → http-CZ24XIWJ.js} +375 -15
- package/dist/http-ClB3pLcL.d.cts +253 -0
- package/dist/{http-DqSNLFNY.d.ts → http-DLBDPal9.d.ts} +2 -2
- package/dist/{inbox-CtcEN1S1.js → inbox-DLgz90Tj.js} +25 -7
- package/dist/{key-q4xxkABj.js → key-fb8Ovh-p.js} +3 -2
- package/dist/{keycache-CtCHz6HR.js → keycache-DRxpZ5r9.js} +1 -1
- package/dist/{keys-BiuLoxwK.js → keys-ZbcByPg9.js} +2 -1
- package/dist/{kv-C7sopW2E.d.ts → kv-CtOmTRNc.d.ts} +30 -1
- package/dist/kv-D8q9fLkA.d.cts +110 -0
- package/dist/{kv-CRZrzyXm.js → kv-QzKcOQgP.js} +22 -0
- package/dist/kv-cache-8rnKI8DT.cjs +134 -0
- package/dist/kv-cache-BEeqyGER.js +107 -0
- package/dist/kv-cache-DGCF5il_.js +122 -0
- package/dist/{ld-PkXepnwg.js → ld-9If_eMWm.js} +6 -4
- package/dist/{middleware-BQHcEUgM.js → middleware-BpTxdimj.js} +230 -327
- package/dist/middleware-DR-CCeAc.cjs +12 -0
- package/dist/{middleware-HDts7zkt.js → middleware-DdBvEeAn.js} +272 -271
- package/dist/middleware-DrwTlwzK.js +12 -0
- package/dist/middleware-psDtCgD-.cjs +4242 -0
- package/dist/middleware-vXfeY_vA.js +26 -0
- package/dist/mod-BrS8tiad.d.cts +266 -0
- package/dist/mod-C81L6_lQ.d.cts +1 -0
- package/dist/mod-CJgbdSqb.d.ts +109 -0
- package/dist/mod-CNNTHyBC.d.cts +80 -0
- package/dist/mod-CS-MS7gZ.d.cts +62 -0
- package/dist/{mod-Bqxcp7eN.d.ts → mod-D_cmv2il.d.ts} +4 -4
- package/dist/mod-DcPRcifg.d.cts +107 -0
- package/dist/mod-DqFSzJA0.d.ts +64 -0
- package/dist/{mod-Drmz72EK.d.ts → mod-jOa7W503.d.ts} +3 -3
- package/dist/mod.cjs +55 -0
- package/dist/mod.d.cts +11 -0
- package/dist/mod.d.ts +11 -17
- package/dist/mod.js +15 -21
- package/dist/negotiation-5NPJL6zp.js +71 -0
- package/dist/nodeinfo/client.test.js +29 -111
- package/dist/nodeinfo/handler.test.js +26 -26
- package/dist/nodeinfo/mod.cjs +10 -0
- package/dist/nodeinfo/mod.d.cts +3 -0
- package/dist/nodeinfo/mod.d.ts +3 -5
- package/dist/nodeinfo/mod.js +6 -7
- package/dist/nodeinfo/types.test.js +7 -15
- package/dist/nodeinfo-BlLsRSiT.js +4 -0
- package/dist/nodeinfo-DuMYTpbZ.cjs +4 -0
- package/dist/otel/exporter.test.js +899 -0
- package/dist/otel/mod.cjs +262 -0
- package/dist/otel/mod.d.cts +230 -0
- package/dist/otel/mod.d.ts +232 -0
- package/dist/otel/mod.js +261 -0
- package/dist/{owner-CQPnQVtf.d.ts → owner-BgI8C-VY.d.ts} +2 -3
- package/dist/owner-C-zfmVAD.d.cts +66 -0
- package/dist/{owner-DZ5zP8JS.js → owner-CCSlDz_P.js} +45 -8
- package/dist/{proof-D8S7qgEZ.js → proof-1s5PweRC.js} +53 -17
- package/dist/proof-DCmRymP1.cjs +709 -0
- package/dist/{proof-ohtusUSV.js → proof-WPbBCoJ-.js} +4 -3
- package/dist/router-D9eI0s4b.js +118 -0
- package/dist/{send-BBi1tzS8.js → send-DBgPrFik.js} +9 -4
- package/dist/sig/http.test.js +12 -14
- package/dist/sig/key.test.js +9 -11
- package/dist/sig/ld.test.js +8 -10
- package/dist/sig/mod.cjs +26 -0
- package/dist/sig/mod.d.cts +4 -0
- package/dist/sig/mod.d.ts +3 -7
- package/dist/sig/mod.js +6 -10
- package/dist/sig/owner.test.js +33 -12
- package/dist/sig/proof.test.js +13 -14
- package/dist/sig-CwuONEzF.js +4 -0
- package/dist/sig-DeXX2xnj.cjs +4 -0
- package/dist/testing/mod.d.ts +180 -6946
- package/dist/testing/mod.js +4 -4
- package/dist/transformers-BjBg6Lag.cjs +116 -0
- package/dist/{transformers-Dna8Fg7k.js → transformers-N_ip_y4P.js} +5 -5
- package/dist/{types-BIgY6c-l.js → types-BEdCLHqP.js} +1 -3
- package/dist/types-Q-qkJXBV.cjs +315 -0
- package/dist/{types-CTYFFnQp.js → types-hKTi53FO.js} +8 -169
- package/dist/{runtime/authdocloader.test.js → utils/docloader.test.js} +13 -15
- 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/dist/utils-Db0ZmjcD.cjs +4 -0
- package/dist/utils-Wranxuoe.js +4 -0
- package/package.json +69 -55
- package/dist/actor-BKxX_F1w.js +0 -37311
- package/dist/actor-C22bXuuC.d.ts +0 -130
- package/dist/actor-DI_YpFlI.js +0 -146
- package/dist/assert_throws-BOO88avQ.js +0 -39
- package/dist/authdocloader-UdvnssIx.js +0 -52
- package/dist/compat-Bb5myD13.js +0 -4
- package/dist/denokv-Bv33Xxea.js +0 -57
- package/dist/docloader-4XS4XdXc.js +0 -4615
- package/dist/docloader-CxWcuWqQ.d.ts +0 -221
- package/dist/fixtures/activitypub.academy/users/brauca_darradiul.json +0 -83
- package/dist/fixtures/example.com/announce.json +0 -6
- package/dist/fixtures/example.com/collection.json +0 -19
- package/dist/fixtures/example.com/create.json +0 -6
- package/dist/fixtures/example.com/cross-origin-actor.json +0 -6
- package/dist/fixtures/example.com/hong-gildong.json +0 -11
- package/dist/fixtures/example.com/invite.json +0 -7
- package/dist/fixtures/example.com/key.json +0 -7
- package/dist/fixtures/example.com/key2.json +0 -6
- package/dist/fixtures/example.com/object.json +0 -6
- package/dist/fixtures/example.com/orderedcollectionpage.json +0 -24
- package/dist/fixtures/example.com/paged/a.json +0 -13
- package/dist/fixtures/example.com/paged/b.json +0 -16
- package/dist/fixtures/example.com/paged-collection.json +0 -6
- package/dist/fixtures/example.com/person.json +0 -22
- package/dist/fixtures/example.com/person2.json +0 -40
- package/dist/fixtures/example.com/test.json +0 -5
- package/dist/fixtures/example.com/users/handle.json +0 -16
- package/dist/fixtures/example.com/wrong-type.json +0 -3
- package/dist/fixtures/oeee.cafe/ap/users/3609fd4e-d51d-4db8-9f04-4189815864dd.json +0 -24
- package/dist/fixtures/remote.domain/users/bob.json +0 -20
- package/dist/fixtures/server.example/users/alice.json +0 -20
- package/dist/fixtures/w3id.org/identity/v1.json +0 -152
- package/dist/fixtures/w3id.org/security/data-integrity/v1.json +0 -74
- package/dist/fixtures/w3id.org/security/multikey/v1.json +0 -35
- package/dist/fixtures/w3id.org/security/v1.json +0 -50
- package/dist/fixtures/wizard.casa/users/hongminhee.json +0 -69
- package/dist/fixtures/www.w3.org/ns/activitystreams.json +0 -379
- package/dist/fixtures/www.w3.org/ns/did/v1.json +0 -58
- package/dist/key-C2_QSigr.js +0 -260
- package/dist/key-Ck2-lYS5.js +0 -10
- package/dist/key-II1NsE_S.js +0 -10
- package/dist/lookup-DCIN2EFw.js +0 -322
- package/dist/lookup-DVlWgAsd.js +0 -131
- package/dist/middleware-CTQfgVW8.js +0 -17
- package/dist/middleware-D3rOl6Au.js +0 -26
- package/dist/mod-Cxt4Kpf6.d.ts +0 -291
- package/dist/mod-DBzN0aCM.d.ts +0 -115
- package/dist/mod-TFoH2Ql8.d.ts +0 -104
- package/dist/mod-g0xFzAP9.d.ts +0 -2
- package/dist/mq-CRGm1e_F.d.ts +0 -143
- package/dist/nodeinfo/semver.test.js +0 -143
- package/dist/nodeinfo-CyEbLjHs.js +0 -4
- package/dist/runtime/docloader.test.js +0 -522
- package/dist/runtime/key.test.js +0 -103
- package/dist/runtime/langstr.test.js +0 -39
- package/dist/runtime/mod.d.ts +0 -8
- package/dist/runtime/mod.js +0 -13
- package/dist/runtime/multibase/multibase.test.d.ts +0 -3
- package/dist/runtime/multibase/multibase.test.js +0 -358
- package/dist/runtime/url.test.d.ts +0 -3
- package/dist/runtime/url.test.js +0 -45
- package/dist/runtime-BSkOVUWM.js +0 -4
- package/dist/semver-dArNLkR9.js +0 -149
- package/dist/sig-BXJO--F9.js +0 -4
- package/dist/src/vocab/accept.yaml +0 -15
- package/dist/src/vocab/activity.yaml +0 -98
- package/dist/src/vocab/add.yaml +0 -16
- package/dist/src/vocab/announce.yaml +0 -30
- package/dist/src/vocab/application.yaml +0 -324
- package/dist/src/vocab/arrive.yaml +0 -15
- package/dist/src/vocab/article.yaml +0 -46
- package/dist/src/vocab/audio.yaml +0 -11
- package/dist/src/vocab/block.yaml +0 -16
- package/dist/src/vocab/chatmessage.yaml +0 -50
- package/dist/src/vocab/collection.yaml +0 -154
- package/dist/src/vocab/collectionpage.yaml +0 -55
- package/dist/src/vocab/create.yaml +0 -28
- package/dist/src/vocab/dataintegrityproof.yaml +0 -56
- package/dist/src/vocab/delete.yaml +0 -27
- package/dist/src/vocab/didservice.yaml +0 -22
- package/dist/src/vocab/dislike.yaml +0 -14
- package/dist/src/vocab/document.yaml +0 -31
- package/dist/src/vocab/emoji.yaml +0 -12
- package/dist/src/vocab/emojireact.yaml +0 -17
- package/dist/src/vocab/endpoints.yaml +0 -85
- package/dist/src/vocab/event.yaml +0 -11
- package/dist/src/vocab/export.yaml +0 -9
- package/dist/src/vocab/flag.yaml +0 -15
- package/dist/src/vocab/follow.yaml +0 -19
- package/dist/src/vocab/group.yaml +0 -324
- package/dist/src/vocab/hashtag.yaml +0 -14
- package/dist/src/vocab/ignore.yaml +0 -14
- package/dist/src/vocab/image.yaml +0 -9
- package/dist/src/vocab/intransitiveactivity.yaml +0 -15
- package/dist/src/vocab/invite.yaml +0 -14
- package/dist/src/vocab/join.yaml +0 -14
- package/dist/src/vocab/key.yaml +0 -28
- package/dist/src/vocab/leave.yaml +0 -14
- package/dist/src/vocab/like.yaml +0 -16
- package/dist/src/vocab/link.yaml +0 -101
- package/dist/src/vocab/listen.yaml +0 -12
- package/dist/src/vocab/mention.yaml +0 -9
- package/dist/src/vocab/move.yaml +0 -15
- package/dist/src/vocab/multikey.yaml +0 -36
- package/dist/src/vocab/note.yaml +0 -48
- package/dist/src/vocab/object.yaml +0 -404
- package/dist/src/vocab/offer.yaml +0 -15
- package/dist/src/vocab/orderedcollection.yaml +0 -39
- package/dist/src/vocab/orderedcollectionpage.yaml +0 -50
- package/dist/src/vocab/organization.yaml +0 -324
- package/dist/src/vocab/page.yaml +0 -11
- package/dist/src/vocab/person.yaml +0 -324
- package/dist/src/vocab/place.yaml +0 -75
- package/dist/src/vocab/profile.yaml +0 -26
- package/dist/src/vocab/propertyvalue.yaml +0 -32
- package/dist/src/vocab/question.yaml +0 -103
- package/dist/src/vocab/read.yaml +0 -13
- package/dist/src/vocab/reject.yaml +0 -14
- package/dist/src/vocab/relationship.yaml +0 -52
- package/dist/src/vocab/remove.yaml +0 -14
- package/dist/src/vocab/service.yaml +0 -324
- package/dist/src/vocab/source.yaml +0 -26
- package/dist/src/vocab/tentativeaccept.yaml +0 -14
- package/dist/src/vocab/tentativereject.yaml +0 -14
- package/dist/src/vocab/tombstone.yaml +0 -24
- package/dist/src/vocab/travel.yaml +0 -16
- package/dist/src/vocab/undo.yaml +0 -26
- package/dist/src/vocab/update.yaml +0 -58
- package/dist/src/vocab/video.yaml +0 -11
- package/dist/src/vocab/view.yaml +0 -13
- package/dist/testing/docloader.test.js +0 -24
- package/dist/type-B7_rMIU9.js +0 -42006
- 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.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 -3363
- package/dist/vocab-3Eie7Ze4.js +0 -246
- package/dist/vocab-SOE1ifCr.d.ts +0 -14634
- 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.d.ts +0 -6
- package/dist/webfinger/mod.js +0 -9
- package/dist/webfinger-C3GIyXIg.js +0 -4
- package/dist/x/cfworkers.d.ts +0 -61
- package/dist/x/cfworkers.js +0 -98
- package/dist/x/cfworkers.test.d.ts +0 -3
- package/dist/x/cfworkers.test.js +0 -179
- package/dist/x/hono.d.ts +0 -56
- package/dist/x/hono.js +0 -60
- package/dist/x/sveltekit.d.ts +0 -48
- package/dist/x/sveltekit.js +0 -68
- /package/dist/{assert_not_equals-f3m3epl3.js → assert_not_equals-C80BG-_5.js} +0 -0
- /package/dist/{collection-CSzG2j1P.js → collection-CcnIw1qY.js} +0 -0
- /package/dist/{nodeinfo/semver.test.d.ts → federation/idempotency.test.d.ts} +0 -0
- /package/dist/{runtime/authdocloader.test.d.ts → federation/negotiation.test.d.ts} +0 -0
- /package/dist/{runtime/docloader.test.d.ts → federation/webfinger.test.d.ts} +0 -0
- /package/dist/{mod-1pDWKvUL.d.ts → mod-1E3W847c.d.ts} +0 -0
- /package/dist/{runtime/key.test.d.ts → otel/exporter.test.d.ts} +0 -0
- /package/dist/{std__assert-X-_kMxKM.js → std__assert-DWivtrGR.js} +0 -0
- /package/dist/{testing → utils}/docloader.test.d.ts +0 -0
- /package/dist/{runtime/langstr.test.d.ts → utils/kv-cache.test.d.ts} +0 -0
|
@@ -3,45 +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 "../client-
|
|
14
|
-
import "../
|
|
15
|
-
import "../types-
|
|
16
|
-
import "../
|
|
17
|
-
import "../
|
|
18
|
-
import
|
|
19
|
-
import "../
|
|
20
|
-
import "../
|
|
21
|
-
import "../
|
|
22
|
-
import "../
|
|
23
|
-
import { InboxListenerSet } from "../inbox-
|
|
24
|
-
import "../builder-
|
|
25
|
-
import "../collection-
|
|
26
|
-
import "../keycache-
|
|
10
|
+
import { MemoryKvStore } from "../kv-QzKcOQgP.js";
|
|
11
|
+
import "../deno-CGe3r5lB.js";
|
|
12
|
+
import { createFederation, handleActor, handleCollection, handleCustomCollection, handleInbox, handleObject, respondWithObject, respondWithObjectIfAcceptable } from "../middleware-BpTxdimj.js";
|
|
13
|
+
import "../client-CgMTXmAD.js";
|
|
14
|
+
import "../router-D9eI0s4b.js";
|
|
15
|
+
import "../types-BEdCLHqP.js";
|
|
16
|
+
import "../key-fb8Ovh-p.js";
|
|
17
|
+
import { signRequest } from "../http-CN7c23sh.js";
|
|
18
|
+
import "../ld-9If_eMWm.js";
|
|
19
|
+
import "../owner-CCSlDz_P.js";
|
|
20
|
+
import "../proof-WPbBCoJ-.js";
|
|
21
|
+
import "../docloader-Bh4ZzxTs.js";
|
|
22
|
+
import "../kv-cache-BEeqyGER.js";
|
|
23
|
+
import { InboxListenerSet } from "../inbox-DLgz90Tj.js";
|
|
24
|
+
import "../builder-oZcZfn1d.js";
|
|
25
|
+
import "../collection-CcnIw1qY.js";
|
|
26
|
+
import "../keycache-DRxpZ5r9.js";
|
|
27
|
+
import "../negotiation-5NPJL6zp.js";
|
|
27
28
|
import "../retry-D4GJ670a.js";
|
|
28
|
-
import "../send-
|
|
29
|
-
import
|
|
30
|
-
import "../
|
|
31
|
-
import
|
|
32
|
-
import "../
|
|
33
|
-
import "../
|
|
34
|
-
import "../
|
|
35
|
-
import {
|
|
29
|
+
import "../send-DBgPrFik.js";
|
|
30
|
+
import "../std__assert-DWivtrGR.js";
|
|
31
|
+
import "../assert_rejects-Ce45JcFg.js";
|
|
32
|
+
import "../assert_throws-BNXdRGWP.js";
|
|
33
|
+
import "../assert_not_equals-C80BG-_5.js";
|
|
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";
|
|
36
37
|
|
|
37
38
|
//#region src/federation/handler.test.ts
|
|
38
|
-
test("acceptsJsonLd()", () => {
|
|
39
|
-
assert(acceptsJsonLd(new Request("https://example.com/", { headers: { Accept: "application/activity+json" } })));
|
|
40
|
-
assert(acceptsJsonLd(new Request("https://example.com/", { headers: { Accept: "application/ld+json" } })));
|
|
41
|
-
assert(acceptsJsonLd(new Request("https://example.com/", { headers: { Accept: "application/json" } })));
|
|
42
|
-
assertFalse(acceptsJsonLd(new Request("https://example.com/", { headers: { Accept: "application/ld+json; q=0.5, text/html; q=0.8" } })));
|
|
43
|
-
assertFalse(acceptsJsonLd(new Request("https://example.com/", { headers: { Accept: "application/ld+json; q=0.4, application/xhtml+xml; q=0.9" } })));
|
|
44
|
-
});
|
|
45
39
|
test("handleActor()", async () => {
|
|
46
40
|
const federation = createFederation({ kv: new MemoryKvStore() });
|
|
47
41
|
let context = createRequestContext({
|
|
@@ -64,11 +58,6 @@ test("handleActor()", async () => {
|
|
|
64
58
|
onNotFoundCalled = request;
|
|
65
59
|
return new Response("Not found", { status: 404 });
|
|
66
60
|
};
|
|
67
|
-
let onNotAcceptableCalled = null;
|
|
68
|
-
const onNotAcceptable = (request) => {
|
|
69
|
-
onNotAcceptableCalled = request;
|
|
70
|
-
return new Response("Not acceptable", { status: 406 });
|
|
71
|
-
};
|
|
72
61
|
let onUnauthorizedCalled = null;
|
|
73
62
|
const onUnauthorized = (request) => {
|
|
74
63
|
onUnauthorizedCalled = request;
|
|
@@ -78,44 +67,21 @@ test("handleActor()", async () => {
|
|
|
78
67
|
context,
|
|
79
68
|
identifier: "someone",
|
|
80
69
|
onNotFound,
|
|
81
|
-
onNotAcceptable,
|
|
82
70
|
onUnauthorized
|
|
83
71
|
});
|
|
84
72
|
assertEquals(response.status, 404);
|
|
85
73
|
assertEquals(onNotFoundCalled, context.request);
|
|
86
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
87
74
|
assertEquals(onUnauthorizedCalled, null);
|
|
88
75
|
onNotFoundCalled = null;
|
|
89
|
-
context = createRequestContext({
|
|
90
|
-
...context,
|
|
91
|
-
getActor(handle) {
|
|
92
|
-
return Promise.resolve(actorDispatcher(context, handle));
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
response = await handleActor(context.request, {
|
|
96
|
-
context,
|
|
97
|
-
identifier: "someone",
|
|
98
|
-
actorDispatcher,
|
|
99
|
-
onNotFound,
|
|
100
|
-
onNotAcceptable,
|
|
101
|
-
onUnauthorized
|
|
102
|
-
});
|
|
103
|
-
assertEquals(response.status, 406);
|
|
104
|
-
assertEquals(onNotFoundCalled, null);
|
|
105
|
-
assertEquals(onNotAcceptableCalled, context.request);
|
|
106
|
-
assertEquals(onUnauthorizedCalled, null);
|
|
107
|
-
onNotAcceptableCalled = null;
|
|
108
76
|
response = await handleActor(context.request, {
|
|
109
77
|
context,
|
|
110
78
|
identifier: "no-one",
|
|
111
79
|
actorDispatcher,
|
|
112
80
|
onNotFound,
|
|
113
|
-
onNotAcceptable,
|
|
114
81
|
onUnauthorized
|
|
115
82
|
});
|
|
116
83
|
assertEquals(response.status, 404);
|
|
117
84
|
assertEquals(onNotFoundCalled, context.request);
|
|
118
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
119
85
|
assertEquals(onUnauthorizedCalled, null);
|
|
120
86
|
onNotFoundCalled = null;
|
|
121
87
|
context = createRequestContext({
|
|
@@ -127,7 +93,6 @@ test("handleActor()", async () => {
|
|
|
127
93
|
identifier: "someone",
|
|
128
94
|
actorDispatcher,
|
|
129
95
|
onNotFound,
|
|
130
|
-
onNotAcceptable,
|
|
131
96
|
onUnauthorized
|
|
132
97
|
});
|
|
133
98
|
assertEquals(response.status, 200);
|
|
@@ -176,19 +141,16 @@ test("handleActor()", async () => {
|
|
|
176
141
|
name: "Someone"
|
|
177
142
|
});
|
|
178
143
|
assertEquals(onNotFoundCalled, null);
|
|
179
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
180
144
|
assertEquals(onUnauthorizedCalled, null);
|
|
181
145
|
response = await handleActor(context.request, {
|
|
182
146
|
context,
|
|
183
147
|
identifier: "no-one",
|
|
184
148
|
actorDispatcher,
|
|
185
149
|
onNotFound,
|
|
186
|
-
onNotAcceptable,
|
|
187
150
|
onUnauthorized
|
|
188
151
|
});
|
|
189
152
|
assertEquals(response.status, 404);
|
|
190
153
|
assertEquals(onNotFoundCalled, context.request);
|
|
191
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
192
154
|
assertEquals(onUnauthorizedCalled, null);
|
|
193
155
|
onNotFoundCalled = null;
|
|
194
156
|
response = await handleActor(context.request, {
|
|
@@ -197,12 +159,10 @@ test("handleActor()", async () => {
|
|
|
197
159
|
actorDispatcher,
|
|
198
160
|
authorizePredicate: (_ctx, _handle, signedKey, signedKeyOwner) => signedKey != null && signedKeyOwner != null,
|
|
199
161
|
onNotFound,
|
|
200
|
-
onNotAcceptable,
|
|
201
162
|
onUnauthorized
|
|
202
163
|
});
|
|
203
164
|
assertEquals(response.status, 401);
|
|
204
165
|
assertEquals(onNotFoundCalled, null);
|
|
205
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
206
166
|
assertEquals(onUnauthorizedCalled, context.request);
|
|
207
167
|
onUnauthorizedCalled = null;
|
|
208
168
|
context = createRequestContext({
|
|
@@ -216,7 +176,6 @@ test("handleActor()", async () => {
|
|
|
216
176
|
actorDispatcher,
|
|
217
177
|
authorizePredicate: (_ctx, _handle, signedKey, signedKeyOwner) => signedKey != null && signedKeyOwner != null,
|
|
218
178
|
onNotFound,
|
|
219
|
-
onNotAcceptable,
|
|
220
179
|
onUnauthorized
|
|
221
180
|
});
|
|
222
181
|
assertEquals(response.status, 200);
|
|
@@ -265,7 +224,6 @@ test("handleActor()", async () => {
|
|
|
265
224
|
name: "Someone"
|
|
266
225
|
});
|
|
267
226
|
assertEquals(onNotFoundCalled, null);
|
|
268
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
269
227
|
assertEquals(onUnauthorizedCalled, null);
|
|
270
228
|
});
|
|
271
229
|
test("handleObject()", async () => {
|
|
@@ -290,11 +248,6 @@ test("handleObject()", async () => {
|
|
|
290
248
|
onNotFoundCalled = request;
|
|
291
249
|
return new Response("Not found", { status: 404 });
|
|
292
250
|
};
|
|
293
|
-
let onNotAcceptableCalled = null;
|
|
294
|
-
const onNotAcceptable = (request) => {
|
|
295
|
-
onNotAcceptableCalled = request;
|
|
296
|
-
return new Response("Not acceptable", { status: 406 });
|
|
297
|
-
};
|
|
298
251
|
let onUnauthorizedCalled = null;
|
|
299
252
|
const onUnauthorized = (request) => {
|
|
300
253
|
onUnauthorizedCalled = request;
|
|
@@ -307,12 +260,10 @@ test("handleObject()", async () => {
|
|
|
307
260
|
id: "123"
|
|
308
261
|
},
|
|
309
262
|
onNotFound,
|
|
310
|
-
onNotAcceptable,
|
|
311
263
|
onUnauthorized
|
|
312
264
|
});
|
|
313
265
|
assertEquals(response.status, 404);
|
|
314
266
|
assertEquals(onNotFoundCalled, context.request);
|
|
315
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
316
267
|
assertEquals(onUnauthorizedCalled, null);
|
|
317
268
|
onNotFoundCalled = null;
|
|
318
269
|
response = await handleObject(context.request, {
|
|
@@ -323,14 +274,11 @@ test("handleObject()", async () => {
|
|
|
323
274
|
},
|
|
324
275
|
objectDispatcher,
|
|
325
276
|
onNotFound,
|
|
326
|
-
onNotAcceptable,
|
|
327
277
|
onUnauthorized
|
|
328
278
|
});
|
|
329
|
-
assertEquals(response.status,
|
|
279
|
+
assertEquals(response.status, 200);
|
|
330
280
|
assertEquals(onNotFoundCalled, null);
|
|
331
|
-
assertEquals(onNotAcceptableCalled, context.request);
|
|
332
281
|
assertEquals(onUnauthorizedCalled, null);
|
|
333
|
-
onNotAcceptableCalled = null;
|
|
334
282
|
response = await handleObject(context.request, {
|
|
335
283
|
context,
|
|
336
284
|
values: {
|
|
@@ -339,12 +287,10 @@ test("handleObject()", async () => {
|
|
|
339
287
|
},
|
|
340
288
|
objectDispatcher,
|
|
341
289
|
onNotFound,
|
|
342
|
-
onNotAcceptable,
|
|
343
290
|
onUnauthorized
|
|
344
291
|
});
|
|
345
292
|
assertEquals(response.status, 404);
|
|
346
293
|
assertEquals(onNotFoundCalled, context.request);
|
|
347
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
348
294
|
assertEquals(onUnauthorizedCalled, null);
|
|
349
295
|
onNotFoundCalled = null;
|
|
350
296
|
response = await handleObject(context.request, {
|
|
@@ -355,12 +301,10 @@ test("handleObject()", async () => {
|
|
|
355
301
|
},
|
|
356
302
|
objectDispatcher,
|
|
357
303
|
onNotFound,
|
|
358
|
-
onNotAcceptable,
|
|
359
304
|
onUnauthorized
|
|
360
305
|
});
|
|
361
306
|
assertEquals(response.status, 404);
|
|
362
307
|
assertEquals(onNotFoundCalled, context.request);
|
|
363
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
364
308
|
assertEquals(onUnauthorizedCalled, null);
|
|
365
309
|
onNotFoundCalled = null;
|
|
366
310
|
context = createRequestContext({
|
|
@@ -375,7 +319,6 @@ test("handleObject()", async () => {
|
|
|
375
319
|
},
|
|
376
320
|
objectDispatcher,
|
|
377
321
|
onNotFound,
|
|
378
|
-
onNotAcceptable,
|
|
379
322
|
onUnauthorized
|
|
380
323
|
});
|
|
381
324
|
assertEquals(response.status, 200);
|
|
@@ -405,7 +348,6 @@ test("handleObject()", async () => {
|
|
|
405
348
|
type: "Note"
|
|
406
349
|
});
|
|
407
350
|
assertEquals(onNotFoundCalled, null);
|
|
408
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
409
351
|
assertEquals(onUnauthorizedCalled, null);
|
|
410
352
|
response = await handleObject(context.request, {
|
|
411
353
|
context,
|
|
@@ -415,12 +357,10 @@ test("handleObject()", async () => {
|
|
|
415
357
|
},
|
|
416
358
|
objectDispatcher,
|
|
417
359
|
onNotFound,
|
|
418
|
-
onNotAcceptable,
|
|
419
360
|
onUnauthorized
|
|
420
361
|
});
|
|
421
362
|
assertEquals(response.status, 404);
|
|
422
363
|
assertEquals(onNotFoundCalled, context.request);
|
|
423
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
424
364
|
assertEquals(onUnauthorizedCalled, null);
|
|
425
365
|
onNotFoundCalled = null;
|
|
426
366
|
response = await handleObject(context.request, {
|
|
@@ -431,12 +371,10 @@ test("handleObject()", async () => {
|
|
|
431
371
|
},
|
|
432
372
|
objectDispatcher,
|
|
433
373
|
onNotFound,
|
|
434
|
-
onNotAcceptable,
|
|
435
374
|
onUnauthorized
|
|
436
375
|
});
|
|
437
376
|
assertEquals(response.status, 404);
|
|
438
377
|
assertEquals(onNotFoundCalled, context.request);
|
|
439
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
440
378
|
assertEquals(onUnauthorizedCalled, null);
|
|
441
379
|
onNotFoundCalled = null;
|
|
442
380
|
response = await handleObject(context.request, {
|
|
@@ -448,12 +386,10 @@ test("handleObject()", async () => {
|
|
|
448
386
|
objectDispatcher,
|
|
449
387
|
authorizePredicate: (_ctx, _values, signedKey, signedKeyOwner) => signedKey != null && signedKeyOwner != null,
|
|
450
388
|
onNotFound,
|
|
451
|
-
onNotAcceptable,
|
|
452
389
|
onUnauthorized
|
|
453
390
|
});
|
|
454
391
|
assertEquals(response.status, 401);
|
|
455
392
|
assertEquals(onNotFoundCalled, null);
|
|
456
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
457
393
|
assertEquals(onUnauthorizedCalled, context.request);
|
|
458
394
|
onUnauthorizedCalled = null;
|
|
459
395
|
context = createRequestContext({
|
|
@@ -470,7 +406,6 @@ test("handleObject()", async () => {
|
|
|
470
406
|
objectDispatcher,
|
|
471
407
|
authorizePredicate: (_ctx, _values, signedKey, signedKeyOwner) => signedKey != null && signedKeyOwner != null,
|
|
472
408
|
onNotFound,
|
|
473
|
-
onNotAcceptable,
|
|
474
409
|
onUnauthorized
|
|
475
410
|
});
|
|
476
411
|
assertEquals(response.status, 200);
|
|
@@ -500,7 +435,6 @@ test("handleObject()", async () => {
|
|
|
500
435
|
type: "Note"
|
|
501
436
|
});
|
|
502
437
|
assertEquals(onNotFoundCalled, null);
|
|
503
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
504
438
|
assertEquals(onUnauthorizedCalled, null);
|
|
505
439
|
});
|
|
506
440
|
test("handleCollection()", async () => {
|
|
@@ -538,11 +472,6 @@ test("handleCollection()", async () => {
|
|
|
538
472
|
onNotFoundCalled = request;
|
|
539
473
|
return new Response("Not found", { status: 404 });
|
|
540
474
|
};
|
|
541
|
-
let onNotAcceptableCalled = null;
|
|
542
|
-
const onNotAcceptable = (request) => {
|
|
543
|
-
onNotAcceptableCalled = request;
|
|
544
|
-
return new Response("Not acceptable", { status: 406 });
|
|
545
|
-
};
|
|
546
475
|
let onUnauthorizedCalled = null;
|
|
547
476
|
const onUnauthorized = (request) => {
|
|
548
477
|
onUnauthorizedCalled = request;
|
|
@@ -556,12 +485,10 @@ test("handleCollection()", async () => {
|
|
|
556
485
|
return new URL(`https://example.com/users/${identifier}`);
|
|
557
486
|
},
|
|
558
487
|
onNotFound,
|
|
559
|
-
onNotAcceptable,
|
|
560
488
|
onUnauthorized
|
|
561
489
|
});
|
|
562
490
|
assertEquals(response.status, 404);
|
|
563
491
|
assertEquals(onNotFoundCalled, context.request);
|
|
564
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
565
492
|
assertEquals(onUnauthorizedCalled, null);
|
|
566
493
|
onNotFoundCalled = null;
|
|
567
494
|
response = await handleCollection(context.request, {
|
|
@@ -573,14 +500,11 @@ test("handleCollection()", async () => {
|
|
|
573
500
|
},
|
|
574
501
|
collectionCallbacks: { dispatcher },
|
|
575
502
|
onNotFound,
|
|
576
|
-
onNotAcceptable,
|
|
577
503
|
onUnauthorized
|
|
578
504
|
});
|
|
579
|
-
assertEquals(response.status,
|
|
505
|
+
assertEquals(response.status, 200);
|
|
580
506
|
assertEquals(onNotFoundCalled, null);
|
|
581
|
-
assertEquals(onNotAcceptableCalled, context.request);
|
|
582
507
|
assertEquals(onUnauthorizedCalled, null);
|
|
583
|
-
onNotAcceptableCalled = null;
|
|
584
508
|
response = await handleCollection(context.request, {
|
|
585
509
|
context,
|
|
586
510
|
name: "collection",
|
|
@@ -590,12 +514,10 @@ test("handleCollection()", async () => {
|
|
|
590
514
|
},
|
|
591
515
|
collectionCallbacks: { dispatcher },
|
|
592
516
|
onNotFound,
|
|
593
|
-
onNotAcceptable,
|
|
594
517
|
onUnauthorized
|
|
595
518
|
});
|
|
596
519
|
assertEquals(response.status, 404);
|
|
597
520
|
assertEquals(onNotFoundCalled, context.request);
|
|
598
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
599
521
|
assertEquals(onUnauthorizedCalled, null);
|
|
600
522
|
onNotFoundCalled = null;
|
|
601
523
|
context = createRequestContext({
|
|
@@ -611,12 +533,10 @@ test("handleCollection()", async () => {
|
|
|
611
533
|
},
|
|
612
534
|
collectionCallbacks: { dispatcher },
|
|
613
535
|
onNotFound,
|
|
614
|
-
onNotAcceptable,
|
|
615
536
|
onUnauthorized
|
|
616
537
|
});
|
|
617
538
|
assertEquals(response.status, 404);
|
|
618
539
|
assertEquals(onNotFoundCalled, context.request);
|
|
619
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
620
540
|
assertEquals(onUnauthorizedCalled, null);
|
|
621
541
|
onNotFoundCalled = null;
|
|
622
542
|
response = await handleCollection(context.request, {
|
|
@@ -628,7 +548,6 @@ test("handleCollection()", async () => {
|
|
|
628
548
|
},
|
|
629
549
|
collectionCallbacks: { dispatcher },
|
|
630
550
|
onNotFound,
|
|
631
|
-
onNotAcceptable,
|
|
632
551
|
onUnauthorized
|
|
633
552
|
});
|
|
634
553
|
assertEquals(response.status, 200);
|
|
@@ -701,7 +620,6 @@ test("handleCollection()", async () => {
|
|
|
701
620
|
]
|
|
702
621
|
});
|
|
703
622
|
assertEquals(onNotFoundCalled, null);
|
|
704
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
705
623
|
assertEquals(onUnauthorizedCalled, null);
|
|
706
624
|
response = await handleCollection(context.request, {
|
|
707
625
|
context,
|
|
@@ -715,12 +633,10 @@ test("handleCollection()", async () => {
|
|
|
715
633
|
authorizePredicate: (_ctx, _handle, key, keyOwner) => key != null && keyOwner != null
|
|
716
634
|
},
|
|
717
635
|
onNotFound,
|
|
718
|
-
onNotAcceptable,
|
|
719
636
|
onUnauthorized
|
|
720
637
|
});
|
|
721
638
|
assertEquals(response.status, 401);
|
|
722
639
|
assertEquals(onNotFoundCalled, null);
|
|
723
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
724
640
|
assertEquals(onUnauthorizedCalled, context.request);
|
|
725
641
|
onUnauthorizedCalled = null;
|
|
726
642
|
context = createRequestContext({
|
|
@@ -740,7 +656,6 @@ test("handleCollection()", async () => {
|
|
|
740
656
|
authorizePredicate: (_ctx, _handle, key, keyOwner) => key != null && keyOwner != null
|
|
741
657
|
},
|
|
742
658
|
onNotFound,
|
|
743
|
-
onNotAcceptable,
|
|
744
659
|
onUnauthorized
|
|
745
660
|
});
|
|
746
661
|
assertEquals(response.status, 200);
|
|
@@ -788,7 +703,6 @@ test("handleCollection()", async () => {
|
|
|
788
703
|
]
|
|
789
704
|
});
|
|
790
705
|
assertEquals(onNotFoundCalled, null);
|
|
791
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
792
706
|
assertEquals(onUnauthorizedCalled, null);
|
|
793
707
|
response = await handleCollection(context.request, {
|
|
794
708
|
context,
|
|
@@ -804,7 +718,6 @@ test("handleCollection()", async () => {
|
|
|
804
718
|
lastCursor
|
|
805
719
|
},
|
|
806
720
|
onNotFound,
|
|
807
|
-
onNotAcceptable,
|
|
808
721
|
onUnauthorized
|
|
809
722
|
});
|
|
810
723
|
assertEquals(response.status, 200);
|
|
@@ -838,7 +751,6 @@ test("handleCollection()", async () => {
|
|
|
838
751
|
last: "https://example.com/?cursor=2"
|
|
839
752
|
});
|
|
840
753
|
assertEquals(onNotFoundCalled, null);
|
|
841
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
842
754
|
assertEquals(onUnauthorizedCalled, null);
|
|
843
755
|
let url = new URL("https://example.com/?cursor=0");
|
|
844
756
|
context = createRequestContext({
|
|
@@ -860,7 +772,6 @@ test("handleCollection()", async () => {
|
|
|
860
772
|
lastCursor
|
|
861
773
|
},
|
|
862
774
|
onNotFound,
|
|
863
|
-
onNotAcceptable,
|
|
864
775
|
onUnauthorized
|
|
865
776
|
});
|
|
866
777
|
assertEquals(response.status, 200);
|
|
@@ -898,7 +809,6 @@ test("handleCollection()", async () => {
|
|
|
898
809
|
}]
|
|
899
810
|
});
|
|
900
811
|
assertEquals(onNotFoundCalled, null);
|
|
901
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
902
812
|
assertEquals(onUnauthorizedCalled, null);
|
|
903
813
|
url = new URL("https://example.com/?cursor=2");
|
|
904
814
|
context = createRequestContext({
|
|
@@ -920,7 +830,6 @@ test("handleCollection()", async () => {
|
|
|
920
830
|
lastCursor
|
|
921
831
|
},
|
|
922
832
|
onNotFound,
|
|
923
|
-
onNotAcceptable,
|
|
924
833
|
onUnauthorized
|
|
925
834
|
});
|
|
926
835
|
assertEquals(response.status, 200);
|
|
@@ -958,7 +867,6 @@ test("handleCollection()", async () => {
|
|
|
958
867
|
}]
|
|
959
868
|
});
|
|
960
869
|
assertEquals(onNotFoundCalled, null);
|
|
961
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
962
870
|
assertEquals(onUnauthorizedCalled, null);
|
|
963
871
|
});
|
|
964
872
|
test("handleInbox()", async () => {
|
|
@@ -1330,11 +1238,6 @@ test("handleCustomCollection()", async () => {
|
|
|
1330
1238
|
onNotFoundCalled = request;
|
|
1331
1239
|
return new Response("Not found", { status: 404 });
|
|
1332
1240
|
};
|
|
1333
|
-
let onNotAcceptableCalled = null;
|
|
1334
|
-
const onNotAcceptable = (request) => {
|
|
1335
|
-
onNotAcceptableCalled = request;
|
|
1336
|
-
return new Response("Not acceptable", { status: 406 });
|
|
1337
|
-
};
|
|
1338
1241
|
let onUnauthorizedCalled = null;
|
|
1339
1242
|
const onUnauthorized = (request) => {
|
|
1340
1243
|
onUnauthorizedCalled = request;
|
|
@@ -1342,7 +1245,6 @@ test("handleCustomCollection()", async () => {
|
|
|
1342
1245
|
};
|
|
1343
1246
|
const errorHandlers = {
|
|
1344
1247
|
onNotFound,
|
|
1345
|
-
onNotAcceptable,
|
|
1346
1248
|
onUnauthorized
|
|
1347
1249
|
};
|
|
1348
1250
|
let response = await handleCustomCollection(context.request, {
|
|
@@ -1353,21 +1255,7 @@ test("handleCustomCollection()", async () => {
|
|
|
1353
1255
|
});
|
|
1354
1256
|
assertEquals(response.status, 404);
|
|
1355
1257
|
assertEquals(onNotFoundCalled, context.request);
|
|
1356
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
1357
|
-
assertEquals(onUnauthorizedCalled, null);
|
|
1358
|
-
onNotFoundCalled = null;
|
|
1359
|
-
response = await handleCustomCollection(context.request, {
|
|
1360
|
-
context,
|
|
1361
|
-
name: "custom collection",
|
|
1362
|
-
values: { handle: "someone" },
|
|
1363
|
-
collectionCallbacks: { dispatcher },
|
|
1364
|
-
...errorHandlers
|
|
1365
|
-
});
|
|
1366
|
-
assertEquals(response.status, 406);
|
|
1367
|
-
assertEquals(onNotFoundCalled, null);
|
|
1368
|
-
assertEquals(onNotAcceptableCalled, context.request);
|
|
1369
1258
|
assertEquals(onUnauthorizedCalled, null);
|
|
1370
|
-
onNotAcceptableCalled = null;
|
|
1371
1259
|
context = createRequestContext({
|
|
1372
1260
|
...context,
|
|
1373
1261
|
request: new Request(context.url, { headers: { Accept: "application/activity+json" } })
|
|
@@ -1381,7 +1269,6 @@ test("handleCustomCollection()", async () => {
|
|
|
1381
1269
|
});
|
|
1382
1270
|
assertEquals(response.status, 404);
|
|
1383
1271
|
assertEquals(onNotFoundCalled, context.request);
|
|
1384
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
1385
1272
|
assertEquals(onUnauthorizedCalled, null);
|
|
1386
1273
|
onNotFoundCalled = null;
|
|
1387
1274
|
response = await handleCustomCollection(context.request, {
|
|
@@ -1462,7 +1349,6 @@ test("handleCustomCollection()", async () => {
|
|
|
1462
1349
|
]
|
|
1463
1350
|
});
|
|
1464
1351
|
assertEquals(onNotFoundCalled, null);
|
|
1465
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
1466
1352
|
assertEquals(onUnauthorizedCalled, null);
|
|
1467
1353
|
response = await handleCustomCollection(context.request, {
|
|
1468
1354
|
context,
|
|
@@ -1476,7 +1362,6 @@ test("handleCustomCollection()", async () => {
|
|
|
1476
1362
|
});
|
|
1477
1363
|
assertEquals(response.status, 401);
|
|
1478
1364
|
assertEquals(onNotFoundCalled, null);
|
|
1479
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
1480
1365
|
assertEquals(onUnauthorizedCalled, context.request);
|
|
1481
1366
|
onUnauthorizedCalled = null;
|
|
1482
1367
|
context = createRequestContext({
|
|
@@ -1519,7 +1404,6 @@ test("handleCustomCollection()", async () => {
|
|
|
1519
1404
|
]
|
|
1520
1405
|
});
|
|
1521
1406
|
assertEquals(onNotFoundCalled, null);
|
|
1522
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
1523
1407
|
assertEquals(onUnauthorizedCalled, null);
|
|
1524
1408
|
response = await handleCustomCollection(context.request, {
|
|
1525
1409
|
context,
|
|
@@ -1539,7 +1423,6 @@ test("handleCustomCollection()", async () => {
|
|
|
1539
1423
|
last: "https://example.com/?cursor=2"
|
|
1540
1424
|
});
|
|
1541
1425
|
assertEquals(onNotFoundCalled, null);
|
|
1542
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
1543
1426
|
assertEquals(onUnauthorizedCalled, null);
|
|
1544
1427
|
let url = new URL("https://example.com/?cursor=0");
|
|
1545
1428
|
context = createRequestContext({
|
|
@@ -1569,7 +1452,6 @@ test("handleCustomCollection()", async () => {
|
|
|
1569
1452
|
}
|
|
1570
1453
|
});
|
|
1571
1454
|
assertEquals(onNotFoundCalled, null);
|
|
1572
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
1573
1455
|
assertEquals(onUnauthorizedCalled, null);
|
|
1574
1456
|
url = new URL("https://example.com/?cursor=2");
|
|
1575
1457
|
context = createRequestContext({
|
|
@@ -1599,8 +1481,93 @@ test("handleCustomCollection()", async () => {
|
|
|
1599
1481
|
}
|
|
1600
1482
|
});
|
|
1601
1483
|
assertEquals(onNotFoundCalled, null);
|
|
1602
|
-
assertEquals(onNotAcceptableCalled, null);
|
|
1603
1484
|
assertEquals(onUnauthorizedCalled, null);
|
|
1604
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
|
+
});
|
|
1605
1572
|
|
|
1606
1573
|
//#endregion
|