@fedify/fedify 2.0.0-dev.1593 → 2.0.0-dev.160
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-BgzJcrpt.js → builder-C9n2ExVv.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-CpxFv8ft.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-B74l3pXN.js +117 -0
- package/dist/{testing-D4xRiVJV.js → dist-B5f6a8Tt.js} +90 -111
- package/dist/{authdocloader-DJtdyVPc.js → docloader-eucHnjj4.js} +17 -8
- package/dist/{esm-5nsZYnVB.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-ClB3pLcL.d.cts +253 -0
- package/dist/{http-CQulyTuw.js → http-CrnYJYhM.js} +3 -2
- package/dist/{http-BqklewFY.js → http-DJ7KWfiN.js} +374 -14
- package/dist/{http-DqSNLFNY.d.ts → http-DLBDPal9.d.ts} +2 -2
- package/dist/http-DtRqZZgP.cjs +1222 -0
- package/dist/{inbox-B97Wrppe.js → inbox-6-2rtCJf.js} +25 -7
- package/dist/{key-D-s3dQbK.js → key-pYEsD-IB.js} +3 -2
- package/dist/{keycache-Br0-hsD5.js → keycache-DRxpZ5r9.js} +1 -1
- package/dist/{keys-DSk2aqlj.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-BEeqyGER.js +107 -0
- package/dist/kv-cache-Cr66Hw1w.js +122 -0
- package/dist/kv-cache-jKJ4ZH0U.cjs +134 -0
- package/dist/{ld-CYUQO1l4.js → ld-Bmrvt1KE.js} +4 -2
- package/dist/middleware-BUywt3CE.cjs +4242 -0
- package/dist/middleware-Ba1Pxx8r.js +26 -0
- package/dist/{middleware-tfSiCl9w.js → middleware-ByNAm2-S.js} +272 -271
- package/dist/middleware-D6QDOyQU.cjs +12 -0
- package/dist/{middleware-CovCqg8w.js → middleware-D9L8QWDP.js} +230 -327
- package/dist/middleware-jJYYmbt6.js +12 -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-CBeUJR68.js → owner-vFiFLWHR.js} +45 -8
- package/dist/{proof-CHQnDg0z.js → proof-C-k7brtD.js} +3 -2
- package/dist/proof-CLwK-TXL.cjs +709 -0
- package/dist/{proof-D436ezTT.js → proof-Dp6V6HEi.js} +50 -14
- package/dist/router-D9eI0s4b.js +118 -0
- package/dist/{send-Bc0QdRlp.js → send-BVXXc0Cn.js} +9 -4
- package/dist/sig/http.test.js +11 -13
- 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-RbpvCErq.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-Bj1Vq2XG.js +0 -146
- package/dist/actor-C22bXuuC.d.ts +0 -130
- package/dist/actor-DNwcqwPT.js +0 -37312
- package/dist/assert_throws-BOO88avQ.js +0 -39
- package/dist/authdocloader-qkvj_KZY.js +0 -52
- package/dist/compat-Bb5myD13.js +0 -4
- package/dist/denokv-Bv33Xxea.js +0 -57
- package/dist/docloader-9_osWaaH.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-3jGPh5To.js +0 -10
- package/dist/key-C3CEOTh7.js +0 -10
- package/dist/key-CNCeen0u.js +0 -260
- package/dist/lookup-BNFlahf3.js +0 -131
- package/dist/lookup-CnJK1NUl.js +0 -322
- package/dist/middleware-CJbNYdw9.js +0 -17
- package/dist/middleware-zDdNBo-m.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-qs0mWLTm.js +0 -42007
- 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-SOE1ifCr.d.ts +0 -14634
- package/dist/vocab-r-I1_ZmK.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.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,39 +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 "../client-
|
|
14
|
-
import { RouterError
|
|
15
|
-
import "../types-
|
|
16
|
-
import "../
|
|
17
|
-
import "../
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import
|
|
23
|
-
import "../inbox-
|
|
24
|
-
import "../builder-
|
|
25
|
-
import "../collection-
|
|
26
|
-
import "../keycache-
|
|
10
|
+
import { MemoryKvStore } from "../kv-QzKcOQgP.js";
|
|
11
|
+
import "../deno-B74l3pXN.js";
|
|
12
|
+
import { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer, createFederation } from "../middleware-D9L8QWDP.js";
|
|
13
|
+
import "../client-CgMTXmAD.js";
|
|
14
|
+
import { RouterError } from "../router-D9eI0s4b.js";
|
|
15
|
+
import "../types-BEdCLHqP.js";
|
|
16
|
+
import "../key-pYEsD-IB.js";
|
|
17
|
+
import { signRequest, verifyRequest } from "../http-CrnYJYhM.js";
|
|
18
|
+
import { detachSignature, signJsonLd, verifyJsonLd } from "../ld-Bmrvt1KE.js";
|
|
19
|
+
import { doesActorOwnKey } from "../owner-vFiFLWHR.js";
|
|
20
|
+
import { signObject, verifyObject } from "../proof-C-k7brtD.js";
|
|
21
|
+
import { fetchDocumentLoader, getAuthenticatedDocumentLoader } from "../docloader-eucHnjj4.js";
|
|
22
|
+
import "../kv-cache-BEeqyGER.js";
|
|
23
|
+
import "../inbox-6-2rtCJf.js";
|
|
24
|
+
import "../builder-C9n2ExVv.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
|
|
36
|
-
import {
|
|
29
|
+
import "../send-BVXXc0Cn.js";
|
|
30
|
+
import { assertStrictEquals } from "../std__assert-DWivtrGR.js";
|
|
31
|
+
import { assertFalse, assertRejects } from "../assert_rejects-Ce45JcFg.js";
|
|
32
|
+
import { assertThrows } from "../assert_throws-BNXdRGWP.js";
|
|
33
|
+
import { assertNotEquals } from "../assert_not_equals-C80BG-_5.js";
|
|
34
|
+
import { ed25519Multikey, ed25519PrivateKey, ed25519PublicKey, rsaPrivateKey2, rsaPrivateKey3, rsaPublicKey2, rsaPublicKey3 } from "../keys-ZbcByPg9.js";
|
|
35
|
+
import { esm_default } from "../esm-DGl7uK1r.js";
|
|
36
|
+
import * as vocab from "@fedify/vocab";
|
|
37
|
+
import { getTypeId, lookupObject } from "@fedify/vocab";
|
|
37
38
|
|
|
38
|
-
//#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
|
|
39
53
|
var __context$1 = ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"];
|
|
40
54
|
var id$1 = "https://example.com/person";
|
|
41
55
|
var type$1 = "Person";
|
|
@@ -59,7 +73,7 @@ var person_default = {
|
|
|
59
73
|
};
|
|
60
74
|
|
|
61
75
|
//#endregion
|
|
62
|
-
//#region src/
|
|
76
|
+
//#region ../fixture/src/fixtures/example.com/person2.json
|
|
63
77
|
var __context = [
|
|
64
78
|
"https://www.w3.org/ns/activitystreams",
|
|
65
79
|
"https://w3id.org/security/v1",
|
|
@@ -108,7 +122,7 @@ test("createFederation()", async (t) => {
|
|
|
108
122
|
await t.step("allowPrivateAddress", () => {
|
|
109
123
|
assertThrows(() => createFederation({
|
|
110
124
|
kv,
|
|
111
|
-
|
|
125
|
+
contextLoaderFactory: () => mockDocumentLoader,
|
|
112
126
|
allowPrivateAddress: true
|
|
113
127
|
}), TypeError);
|
|
114
128
|
assertThrows(() => createFederation({
|
|
@@ -245,7 +259,7 @@ test({
|
|
|
245
259
|
assertStrictEquals(ctx.federation, federation);
|
|
246
260
|
assertThrows(() => ctx.getNodeInfoUri(), RouterError);
|
|
247
261
|
assertThrows(() => ctx.getActorUri("handle"), RouterError);
|
|
248
|
-
assertThrows(() => ctx.getObjectUri(Note, {
|
|
262
|
+
assertThrows(() => ctx.getObjectUri(vocab.Note, {
|
|
249
263
|
handle: "handle",
|
|
250
264
|
id: "id"
|
|
251
265
|
}), RouterError);
|
|
@@ -262,15 +276,11 @@ test({
|
|
|
262
276
|
assertEquals(ctx.parseUri(null), null);
|
|
263
277
|
assertEquals(await ctx.getActorKeyPairs("handle"), []);
|
|
264
278
|
await assertRejects(() => ctx.getDocumentLoader({ identifier: "handle" }), Error, "No actor key pairs dispatcher registered");
|
|
265
|
-
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");
|
|
266
280
|
federation.setNodeInfoDispatcher("/nodeinfo/2.1", () => ({
|
|
267
281
|
software: {
|
|
268
282
|
name: "Example",
|
|
269
|
-
version:
|
|
270
|
-
major: 1,
|
|
271
|
-
minor: 2,
|
|
272
|
-
patch: 3
|
|
273
|
-
}
|
|
283
|
+
version: "1.2.3"
|
|
274
284
|
},
|
|
275
285
|
protocols: ["activitypub"],
|
|
276
286
|
usage: {
|
|
@@ -281,7 +291,7 @@ test({
|
|
|
281
291
|
}));
|
|
282
292
|
ctx = federation.createContext(new URL("https://example.com/"), 123);
|
|
283
293
|
assertEquals(ctx.getNodeInfoUri(), new URL("https://example.com/nodeinfo/2.1"));
|
|
284
|
-
federation.setActorDispatcher("/users/{identifier}", () => new Person({})).setKeyPairsDispatcher(() => [{
|
|
294
|
+
federation.setActorDispatcher("/users/{identifier}", () => new vocab.Person({})).setKeyPairsDispatcher(() => [{
|
|
285
295
|
privateKey: rsaPrivateKey2,
|
|
286
296
|
publicKey: rsaPublicKey2.publicKey
|
|
287
297
|
}, {
|
|
@@ -305,7 +315,7 @@ test({
|
|
|
305
315
|
id: new URL("https://example.com/users/handle#main-key"),
|
|
306
316
|
owner: new URL("https://example.com/users/handle")
|
|
307
317
|
}),
|
|
308
|
-
multikey: new Multikey({
|
|
318
|
+
multikey: new vocab.Multikey({
|
|
309
319
|
id: new URL("https://example.com/users/handle#main-key"),
|
|
310
320
|
controller: new URL("https://example.com/users/handle"),
|
|
311
321
|
publicKey: rsaPublicKey2.publicKey
|
|
@@ -318,7 +328,7 @@ test({
|
|
|
318
328
|
id: new URL("https://example.com/users/handle#key-2"),
|
|
319
329
|
owner: new URL("https://example.com/users/handle")
|
|
320
330
|
}),
|
|
321
|
-
multikey: new Multikey({
|
|
331
|
+
multikey: new vocab.Multikey({
|
|
322
332
|
id: new URL("https://example.com/users/handle#key-2"),
|
|
323
333
|
controller: new URL("https://example.com/users/handle"),
|
|
324
334
|
publicKey: ed25519PublicKey.publicKey
|
|
@@ -346,8 +356,8 @@ test({
|
|
|
346
356
|
document: true
|
|
347
357
|
});
|
|
348
358
|
assertEquals(await ctx.lookupObject("https://example.com/object"), null);
|
|
349
|
-
await assertRejects(() => ctx.sendActivity({ identifier: "handle" }, [], new Create({})), TypeError, "The activity to send must have at least one actor property.");
|
|
350
|
-
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") }));
|
|
351
361
|
esm_default.get("https://example.com/object", () => new Response(JSON.stringify({
|
|
352
362
|
"@context": "https://www.w3.org/ns/activitystreams",
|
|
353
363
|
type: "Object",
|
|
@@ -360,21 +370,21 @@ test({
|
|
|
360
370
|
contextLoaderFactory: () => mockDocumentLoader
|
|
361
371
|
});
|
|
362
372
|
const ctx2 = federation2.createContext(new URL("https://example.com/"), 123);
|
|
363
|
-
assertEquals(await ctx2.lookupObject("https://example.com/object"), new Object
|
|
373
|
+
assertEquals(await ctx2.lookupObject("https://example.com/object"), new vocab.Object({
|
|
364
374
|
id: new URL("https://example.com/object"),
|
|
365
375
|
name: "Fetched object"
|
|
366
376
|
}));
|
|
367
|
-
federation.setObjectDispatcher(Note, "/users/{identifier}/notes/{id}", (_ctx, values) => {
|
|
368
|
-
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}` });
|
|
369
379
|
});
|
|
370
380
|
ctx = federation.createContext(new URL("https://example.com/"), 123);
|
|
371
|
-
assertEquals(ctx.getObjectUri(Note, {
|
|
381
|
+
assertEquals(ctx.getObjectUri(vocab.Note, {
|
|
372
382
|
identifier: "john",
|
|
373
383
|
id: "123"
|
|
374
384
|
}), new URL("https://example.com/users/john/notes/123"));
|
|
375
385
|
assertEquals(ctx.parseUri(new URL("https://example.com/users/john/notes/123")), {
|
|
376
386
|
type: "object",
|
|
377
|
-
class: Note,
|
|
387
|
+
class: vocab.Note,
|
|
378
388
|
typeId: new URL("https://www.w3.org/ns/activitystreams#Note"),
|
|
379
389
|
values: {
|
|
380
390
|
identifier: "john",
|
|
@@ -457,7 +467,7 @@ test({
|
|
|
457
467
|
kv,
|
|
458
468
|
origin: "https://ap.example.com",
|
|
459
469
|
documentLoaderFactory: () => mockDocumentLoader,
|
|
460
|
-
|
|
470
|
+
contextLoaderFactory: () => mockDocumentLoader
|
|
461
471
|
});
|
|
462
472
|
const ctx = federation.createContext(new URL("https://example.com:1234/"));
|
|
463
473
|
assertEquals(ctx.origin, "https://example.com:1234");
|
|
@@ -467,11 +477,7 @@ test({
|
|
|
467
477
|
federation.setNodeInfoDispatcher("/nodeinfo/2.1", () => ({
|
|
468
478
|
software: {
|
|
469
479
|
name: "Example",
|
|
470
|
-
version:
|
|
471
|
-
major: 1,
|
|
472
|
-
minor: 2,
|
|
473
|
-
patch: 3
|
|
474
|
-
}
|
|
480
|
+
version: "1.2.3"
|
|
475
481
|
},
|
|
476
482
|
protocols: ["activitypub"],
|
|
477
483
|
usage: {
|
|
@@ -481,7 +487,7 @@ test({
|
|
|
481
487
|
}
|
|
482
488
|
}));
|
|
483
489
|
assertEquals(ctx.getNodeInfoUri(), new URL("https://ap.example.com/nodeinfo/2.1"));
|
|
484
|
-
federation.setActorDispatcher("/users/{identifier}", () => new Person({}));
|
|
490
|
+
federation.setActorDispatcher("/users/{identifier}", () => new vocab.Person({}));
|
|
485
491
|
assertEquals(ctx.getActorUri("handle"), new URL("https://ap.example.com/users/handle"));
|
|
486
492
|
assertEquals(ctx.parseUri(new URL("https://ap.example.com/users/handle")), {
|
|
487
493
|
type: "actor",
|
|
@@ -493,16 +499,16 @@ test({
|
|
|
493
499
|
handle: "handle",
|
|
494
500
|
identifier: "handle"
|
|
495
501
|
});
|
|
496
|
-
federation.setObjectDispatcher(Note, "/users/{identifier}/notes/{id}", (_ctx, values) => {
|
|
497
|
-
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}` });
|
|
498
504
|
});
|
|
499
|
-
assertEquals(ctx.getObjectUri(Note, {
|
|
505
|
+
assertEquals(ctx.getObjectUri(vocab.Note, {
|
|
500
506
|
identifier: "john",
|
|
501
507
|
id: "123"
|
|
502
508
|
}), new URL("https://ap.example.com/users/john/notes/123"));
|
|
503
509
|
assertEquals(ctx.parseUri(new URL("https://ap.example.com/users/john/notes/123")), {
|
|
504
510
|
type: "object",
|
|
505
|
-
class: Note,
|
|
511
|
+
class: vocab.Note,
|
|
506
512
|
typeId: new URL("https://www.w3.org/ns/activitystreams#Note"),
|
|
507
513
|
values: {
|
|
508
514
|
identifier: "john",
|
|
@@ -511,7 +517,7 @@ test({
|
|
|
511
517
|
});
|
|
512
518
|
assertEquals(ctx.parseUri(new URL("https://example.com:1234/users/john/notes/123")), {
|
|
513
519
|
type: "object",
|
|
514
|
-
class: Note,
|
|
520
|
+
class: vocab.Note,
|
|
515
521
|
typeId: new URL("https://www.w3.org/ns/activitystreams#Note"),
|
|
516
522
|
values: {
|
|
517
523
|
identifier: "john",
|
|
@@ -661,13 +667,7 @@ test({
|
|
|
661
667
|
assertEquals(nodeInfo, {
|
|
662
668
|
software: {
|
|
663
669
|
name: "foo",
|
|
664
|
-
version:
|
|
665
|
-
major: 1,
|
|
666
|
-
minor: 2,
|
|
667
|
-
patch: 3,
|
|
668
|
-
build: [],
|
|
669
|
-
prerelease: []
|
|
670
|
-
}
|
|
670
|
+
version: "1.2.3"
|
|
671
671
|
},
|
|
672
672
|
protocols: ["activitypub", "diaspora"],
|
|
673
673
|
usage: {
|
|
@@ -695,7 +695,7 @@ test({
|
|
|
695
695
|
kv,
|
|
696
696
|
documentLoaderFactory: () => mockDocumentLoader
|
|
697
697
|
});
|
|
698
|
-
const req = new Request("https://example.com/");
|
|
698
|
+
const req = new Request("https://example.com/", { headers: { "accept": "application/ld+json" } });
|
|
699
699
|
const ctx = federation.createContext(req, 123);
|
|
700
700
|
assertEquals(ctx.request, req);
|
|
701
701
|
assertEquals(ctx.url, new URL("https://example.com/"));
|
|
@@ -704,7 +704,7 @@ test({
|
|
|
704
704
|
assertEquals(ctx.hostname, "example.com");
|
|
705
705
|
assertEquals(ctx.data, 123);
|
|
706
706
|
await assertRejects(() => ctx.getActor("someone"), Error);
|
|
707
|
-
await assertRejects(() => ctx.getObject(Note, {
|
|
707
|
+
await assertRejects(() => ctx.getObject(vocab.Note, {
|
|
708
708
|
handle: "someone",
|
|
709
709
|
id: "123"
|
|
710
710
|
}), Error);
|
|
@@ -713,7 +713,7 @@ test({
|
|
|
713
713
|
assertEquals(await ctx.getSignedKey(), null);
|
|
714
714
|
assertEquals(await ctx.getSignedKeyOwner(), null);
|
|
715
715
|
await assertRejects(() => ctx.getActor("someone"), Error, "No actor dispatcher registered");
|
|
716
|
-
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);
|
|
717
717
|
const signedCtx = federation.createContext(signedReq, 456);
|
|
718
718
|
assertEquals(signedCtx.request, signedReq);
|
|
719
719
|
assertEquals(signedCtx.url, new URL("https://example.com/"));
|
|
@@ -722,7 +722,7 @@ test({
|
|
|
722
722
|
assertEquals(await signedCtx.getSignedKeyOwner(), null);
|
|
723
723
|
assertEquals(await signedCtx.getSignedKey(), rsaPublicKey2);
|
|
724
724
|
assertEquals(await signedCtx.getSignedKeyOwner(), null);
|
|
725
|
-
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);
|
|
726
726
|
const signedCtx2 = federation.createContext(signedReq2, 456);
|
|
727
727
|
assertEquals(signedCtx2.request, signedReq2);
|
|
728
728
|
assertEquals(signedCtx2.url, new URL("https://example.com/"));
|
|
@@ -735,27 +735,27 @@ test({
|
|
|
735
735
|
assertEquals(await signedCtx2.getSignedKeyOwner(), expectedOwner);
|
|
736
736
|
assertEquals(await signedCtx2.getSignedKey(), rsaPublicKey3);
|
|
737
737
|
assertEquals(await signedCtx2.getSignedKeyOwner(), expectedOwner);
|
|
738
|
-
federation.setActorDispatcher("/users/{identifier}", (_ctx, identifier) => new Person({ preferredUsername: identifier }));
|
|
738
|
+
federation.setActorDispatcher("/users/{identifier}", (_ctx, identifier) => new vocab.Person({ preferredUsername: identifier }));
|
|
739
739
|
const ctx2 = federation.createContext(req, 789);
|
|
740
740
|
assertEquals(ctx2.request, req);
|
|
741
741
|
assertEquals(ctx2.url, new URL("https://example.com/"));
|
|
742
742
|
assertEquals(ctx2.data, 789);
|
|
743
|
-
assertEquals(await ctx2.getActor("john"), new Person({ preferredUsername: "john" }));
|
|
744
|
-
federation.setObjectDispatcher(Note, "/users/{identifier}/notes/{id}", (_ctx, values) => {
|
|
745
|
-
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}` });
|
|
746
746
|
});
|
|
747
747
|
const ctx3 = federation.createContext(req, 123);
|
|
748
748
|
assertEquals(ctx3.request, req);
|
|
749
749
|
assertEquals(ctx3.url, new URL("https://example.com/"));
|
|
750
750
|
assertEquals(ctx3.data, 123);
|
|
751
|
-
assertEquals(await ctx2.getObject(Note, {
|
|
751
|
+
assertEquals(await ctx2.getObject(vocab.Note, {
|
|
752
752
|
identifier: "john",
|
|
753
753
|
id: "123"
|
|
754
|
-
}), new Note({ summary: "Note 123 by john" }));
|
|
754
|
+
}), new vocab.Note({ summary: "Note 123 by john" }));
|
|
755
755
|
});
|
|
756
756
|
await t.step("RequestContext.clone()", () => {
|
|
757
757
|
const federation = createFederation({ kv });
|
|
758
|
-
const req = new Request("https://example.com/");
|
|
758
|
+
const req = new Request("https://example.com/", { headers: { "accept": "application/ld+json" } });
|
|
759
759
|
const ctx = federation.createContext(req, 123);
|
|
760
760
|
const clone = ctx.clone(456);
|
|
761
761
|
assertStrictEquals(clone.request, ctx.request);
|
|
@@ -771,6 +771,157 @@ test({
|
|
|
771
771
|
esm_default.hardReset();
|
|
772
772
|
}
|
|
773
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
|
+
});
|
|
774
925
|
test("Federation.setInboxListeners()", async (t) => {
|
|
775
926
|
const kv = new MemoryKvStore();
|
|
776
927
|
esm_default.spyGlobal();
|
|
@@ -820,13 +971,16 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
820
971
|
}
|
|
821
972
|
});
|
|
822
973
|
const inbox = [];
|
|
823
|
-
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(Create, (ctx, create) => {
|
|
974
|
+
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(vocab.Create, (ctx, create) => {
|
|
824
975
|
inbox.push([ctx, create]);
|
|
825
976
|
});
|
|
826
|
-
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 });
|
|
827
981
|
assertEquals(inbox, []);
|
|
828
982
|
assertEquals(response.status, 404);
|
|
829
|
-
federation.setActorDispatcher("/users/{identifier}", (_, identifier) => identifier === "john" ? new Person({}) : null).setKeyPairsDispatcher(() => [{
|
|
983
|
+
federation.setActorDispatcher("/users/{identifier}", (_, identifier) => identifier === "john" ? new vocab.Person({}) : null).setKeyPairsDispatcher(() => [{
|
|
830
984
|
privateKey: rsaPrivateKey2,
|
|
831
985
|
publicKey: rsaPublicKey2.publicKey
|
|
832
986
|
}]);
|
|
@@ -834,29 +988,43 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
834
988
|
documentLoader: mockDocumentLoader,
|
|
835
989
|
contextLoader: mockDocumentLoader
|
|
836
990
|
};
|
|
837
|
-
const activity = () => new Create({
|
|
991
|
+
const activity = () => new vocab.Create({
|
|
838
992
|
id: new URL("https://example.com/activities/" + crypto.randomUUID()),
|
|
839
993
|
actor: new URL("https://example.com/person2")
|
|
840
994
|
});
|
|
841
995
|
response = await federation.fetch(new Request("https://example.com/inbox", {
|
|
842
996
|
method: "POST",
|
|
843
|
-
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
|
+
}
|
|
844
1002
|
}), { contextData: void 0 });
|
|
845
1003
|
assertEquals(inbox, []);
|
|
846
1004
|
assertEquals(response.status, 401);
|
|
847
|
-
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 });
|
|
848
1009
|
assertEquals(inbox, []);
|
|
849
1010
|
assertEquals(response.status, 404);
|
|
850
1011
|
response = await federation.fetch(new Request("https://example.com/users/john/inbox", {
|
|
851
1012
|
method: "POST",
|
|
852
|
-
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
|
+
}
|
|
853
1018
|
}), { contextData: void 0 });
|
|
854
1019
|
assertEquals(inbox, []);
|
|
855
1020
|
assertEquals(response.status, 401);
|
|
856
1021
|
const activityPayload = await activity().toJsonLd(options);
|
|
857
1022
|
let request = new Request("https://example.com/users/john/inbox", {
|
|
858
1023
|
method: "POST",
|
|
859
|
-
headers: {
|
|
1024
|
+
headers: {
|
|
1025
|
+
"Content-Type": "application/activity+json",
|
|
1026
|
+
accept: "application/ld+json"
|
|
1027
|
+
},
|
|
860
1028
|
body: JSON.stringify(activityPayload)
|
|
861
1029
|
});
|
|
862
1030
|
request = await signRequest(request, rsaPrivateKey3, new URL("https://example.com/person2#key3"));
|
|
@@ -873,7 +1041,10 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
873
1041
|
inbox.shift();
|
|
874
1042
|
request = new Request("https://another.host/users/john/inbox", {
|
|
875
1043
|
method: "POST",
|
|
876
|
-
headers: {
|
|
1044
|
+
headers: {
|
|
1045
|
+
"Content-Type": "application/activity+json",
|
|
1046
|
+
"accept": "application/ld+json"
|
|
1047
|
+
},
|
|
877
1048
|
body: JSON.stringify(activityPayload)
|
|
878
1049
|
});
|
|
879
1050
|
request = await signRequest(request, rsaPrivateKey3, new URL("https://example.com/person2#key3"));
|
|
@@ -888,7 +1059,10 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
888
1059
|
inbox.shift();
|
|
889
1060
|
request = new Request("https://example.com/inbox", {
|
|
890
1061
|
method: "POST",
|
|
891
|
-
headers: {
|
|
1062
|
+
headers: {
|
|
1063
|
+
"Content-Type": "application/activity+json",
|
|
1064
|
+
"accept": "application/ld+json"
|
|
1065
|
+
},
|
|
892
1066
|
body: JSON.stringify(await activity().toJsonLd(options))
|
|
893
1067
|
});
|
|
894
1068
|
request = await signRequest(request, rsaPrivateKey3, new URL("https://example.com/person2#key3"));
|
|
@@ -903,7 +1077,10 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
903
1077
|
inbox.shift();
|
|
904
1078
|
request = new Request("https://example.com/users/john/inbox", {
|
|
905
1079
|
method: "POST",
|
|
906
|
-
headers: {
|
|
1080
|
+
headers: {
|
|
1081
|
+
"Content-Type": "application/activity+json",
|
|
1082
|
+
"accept": "application/ld+json"
|
|
1083
|
+
},
|
|
907
1084
|
body: JSON.stringify(await (await signObject(activity(), ed25519PrivateKey, ed25519Multikey.id, options)).toJsonLd(options))
|
|
908
1085
|
});
|
|
909
1086
|
response = await federation.fetch(request, { contextData: void 0 });
|
|
@@ -928,21 +1105,24 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
928
1105
|
};
|
|
929
1106
|
}
|
|
930
1107
|
});
|
|
931
|
-
federation.setActorDispatcher("/users/{identifier}", (_, identifier) => identifier === "john" ? new Person({}) : null).setKeyPairsDispatcher(() => [{
|
|
1108
|
+
federation.setActorDispatcher("/users/{identifier}", (_, identifier) => identifier === "john" ? new vocab.Person({}) : null).setKeyPairsDispatcher(() => [{
|
|
932
1109
|
privateKey: rsaPrivateKey2,
|
|
933
1110
|
publicKey: rsaPublicKey2.publicKey
|
|
934
1111
|
}]);
|
|
935
1112
|
const error = /* @__PURE__ */ new Error("test");
|
|
936
1113
|
const errors = [];
|
|
937
|
-
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(Create, () => {
|
|
1114
|
+
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(vocab.Create, () => {
|
|
938
1115
|
throw error;
|
|
939
1116
|
}).onError((_, e) => {
|
|
940
1117
|
errors.push(e);
|
|
941
1118
|
});
|
|
942
|
-
const activity = new Create({ actor: new URL("https://example.com/person") });
|
|
1119
|
+
const activity = new vocab.Create({ actor: new URL("https://example.com/person") });
|
|
943
1120
|
let request = new Request("https://example.com/users/john/inbox", {
|
|
944
1121
|
method: "POST",
|
|
945
|
-
headers: {
|
|
1122
|
+
headers: {
|
|
1123
|
+
"Content-Type": "application/activity+json",
|
|
1124
|
+
"Accept": "application/activity+json"
|
|
1125
|
+
},
|
|
946
1126
|
body: JSON.stringify(await activity.toJsonLd({ contextLoader: mockDocumentLoader }))
|
|
947
1127
|
});
|
|
948
1128
|
request = await signRequest(request, rsaPrivateKey2, new URL("https://example.com/key2"));
|
|
@@ -995,8 +1175,8 @@ test("FederationImpl.sendActivity()", async (t) => {
|
|
|
995
1175
|
let json = await cl.request.json();
|
|
996
1176
|
if (await verifyJsonLd(json, options)) verified.push("ld");
|
|
997
1177
|
json = detachSignature(json);
|
|
998
|
-
let activity = await verifyObject(Activity, json, options);
|
|
999
|
-
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);
|
|
1000
1180
|
else verified.push("proof");
|
|
1001
1181
|
const key = await verifyRequest(request, options);
|
|
1002
1182
|
if (key != null && await doesActorOwnKey(activity, key, options)) verified.push("http");
|
|
@@ -1006,11 +1186,11 @@ test("FederationImpl.sendActivity()", async (t) => {
|
|
|
1006
1186
|
const kv = new MemoryKvStore();
|
|
1007
1187
|
const federation = new FederationImpl({
|
|
1008
1188
|
kv,
|
|
1009
|
-
|
|
1189
|
+
contextLoaderFactory: () => mockDocumentLoader
|
|
1010
1190
|
});
|
|
1011
1191
|
const context = federation.createContext(new URL("https://example.com/"));
|
|
1012
1192
|
await t.step("success", async () => {
|
|
1013
|
-
const activity = new Create({
|
|
1193
|
+
const activity = new vocab.Create({
|
|
1014
1194
|
id: new URL("https://example.com/activity/1"),
|
|
1015
1195
|
actor: new URL("https://example.com/person")
|
|
1016
1196
|
});
|
|
@@ -1085,7 +1265,7 @@ test("FederationImpl.processQueuedTask()", async (t) => {
|
|
|
1085
1265
|
kv,
|
|
1086
1266
|
queue
|
|
1087
1267
|
});
|
|
1088
|
-
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(Create, () => {
|
|
1268
|
+
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(vocab.Create, () => {
|
|
1089
1269
|
throw new Error("Intended error for testing");
|
|
1090
1270
|
});
|
|
1091
1271
|
await assertRejects(() => federation.processQueuedTask(void 0, {
|
|
@@ -1147,7 +1327,7 @@ test("FederationImpl.processQueuedTask()", async (t) => {
|
|
|
1147
1327
|
kv,
|
|
1148
1328
|
queue
|
|
1149
1329
|
});
|
|
1150
|
-
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(Create, () => {
|
|
1330
|
+
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(vocab.Create, () => {
|
|
1151
1331
|
throw new Error("Intended error for testing");
|
|
1152
1332
|
});
|
|
1153
1333
|
const outboxMessage = {
|
|
@@ -1232,7 +1412,7 @@ test("ContextImpl.lookupObject()", async (t) => {
|
|
|
1232
1412
|
});
|
|
1233
1413
|
const ctx = federation.createContext(new URL("https://example.com/"));
|
|
1234
1414
|
const result = await ctx.lookupObject("@test@localhost");
|
|
1235
|
-
assertInstanceOf(result, Person);
|
|
1415
|
+
assertInstanceOf(result, vocab.Person);
|
|
1236
1416
|
assertEquals(result.id, new URL("https://localhost/actor"));
|
|
1237
1417
|
assertEquals(result.preferredUsername, "test");
|
|
1238
1418
|
});
|
|
@@ -1258,7 +1438,7 @@ test("ContextImpl.sendActivity()", async (t) => {
|
|
|
1258
1438
|
collectionSyncHeader = cl.request.headers.get("Collection-Synchronization");
|
|
1259
1439
|
const options = {
|
|
1260
1440
|
async documentLoader(url) {
|
|
1261
|
-
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 });
|
|
1262
1442
|
if (response.ok) return {
|
|
1263
1443
|
contextUrl: null,
|
|
1264
1444
|
document: await response.json(),
|
|
@@ -1281,8 +1461,8 @@ test("ContextImpl.sendActivity()", async (t) => {
|
|
|
1281
1461
|
let json = await cl.request.json();
|
|
1282
1462
|
if (await verifyJsonLd(json, options)) verified.push("ld");
|
|
1283
1463
|
json = detachSignature(json);
|
|
1284
|
-
let activity = await verifyObject(Activity, json, options);
|
|
1285
|
-
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);
|
|
1286
1466
|
else verified.push("proof");
|
|
1287
1467
|
const key = await verifyRequest(request, options);
|
|
1288
1468
|
if (key != null && await doesActorOwnKey(activity, key, options)) verified.push("http");
|
|
@@ -1292,12 +1472,12 @@ test("ContextImpl.sendActivity()", async (t) => {
|
|
|
1292
1472
|
const kv = new MemoryKvStore();
|
|
1293
1473
|
const federation = new FederationImpl({
|
|
1294
1474
|
kv,
|
|
1295
|
-
|
|
1475
|
+
contextLoaderFactory: () => mockDocumentLoader
|
|
1296
1476
|
});
|
|
1297
1477
|
federation.setActorDispatcher("/{identifier}", async (ctx, identifier) => {
|
|
1298
1478
|
if (identifier !== "1") return null;
|
|
1299
1479
|
const keys = await ctx.getActorKeyPairs(identifier);
|
|
1300
|
-
return new Person({
|
|
1480
|
+
return new vocab.Person({
|
|
1301
1481
|
id: ctx.getActorUri(identifier),
|
|
1302
1482
|
preferredUsername: "john",
|
|
1303
1483
|
publicKey: keys[0].cryptographicKey,
|
|
@@ -1318,7 +1498,7 @@ test("ContextImpl.sendActivity()", async (t) => {
|
|
|
1318
1498
|
inboxId: new URL("https://example.com/inbox")
|
|
1319
1499
|
}] }));
|
|
1320
1500
|
await t.step("success", async () => {
|
|
1321
|
-
const activity = new Create({ actor: new URL("https://example.com/person") });
|
|
1501
|
+
const activity = new vocab.Create({ actor: new URL("https://example.com/person") });
|
|
1322
1502
|
const ctx = new ContextImpl({
|
|
1323
1503
|
data: void 0,
|
|
1324
1504
|
federation,
|
|
@@ -1401,13 +1581,13 @@ test("ContextImpl.sendActivity()", async (t) => {
|
|
|
1401
1581
|
};
|
|
1402
1582
|
const federation2 = new FederationImpl({
|
|
1403
1583
|
kv,
|
|
1404
|
-
|
|
1584
|
+
contextLoaderFactory: () => mockDocumentLoader,
|
|
1405
1585
|
queue
|
|
1406
1586
|
});
|
|
1407
1587
|
federation2.setActorDispatcher("/{identifier}", async (ctx, identifier) => {
|
|
1408
1588
|
if (identifier !== "john") return null;
|
|
1409
1589
|
const keys = await ctx.getActorKeyPairs(identifier);
|
|
1410
|
-
return new Person({
|
|
1590
|
+
return new vocab.Person({
|
|
1411
1591
|
id: ctx.getActorUri(identifier),
|
|
1412
1592
|
preferredUsername: "john",
|
|
1413
1593
|
publicKey: keys[0].cryptographicKey,
|
|
@@ -1431,7 +1611,7 @@ test("ContextImpl.sendActivity()", async (t) => {
|
|
|
1431
1611
|
contextLoader: fetchDocumentLoader
|
|
1432
1612
|
});
|
|
1433
1613
|
await t.step("fanout: \"force\"", async () => {
|
|
1434
|
-
const activity = new Create({
|
|
1614
|
+
const activity = new vocab.Create({
|
|
1435
1615
|
id: new URL("https://example.com/activity/1"),
|
|
1436
1616
|
actor: new URL("https://example.com/person")
|
|
1437
1617
|
});
|
|
@@ -1460,7 +1640,7 @@ test("ContextImpl.sendActivity()", async (t) => {
|
|
|
1460
1640
|
});
|
|
1461
1641
|
queue.clear();
|
|
1462
1642
|
await t.step("fanout: \"skip\"", async () => {
|
|
1463
|
-
const activity = new Create({
|
|
1643
|
+
const activity = new vocab.Create({
|
|
1464
1644
|
id: new URL("https://example.com/activity/1"),
|
|
1465
1645
|
actor: new URL("https://example.com/person")
|
|
1466
1646
|
});
|
|
@@ -1475,7 +1655,7 @@ test("ContextImpl.sendActivity()", async (t) => {
|
|
|
1475
1655
|
});
|
|
1476
1656
|
queue.clear();
|
|
1477
1657
|
await t.step("fanout: \"auto\"", async () => {
|
|
1478
|
-
const activity = new Create({
|
|
1658
|
+
const activity = new vocab.Create({
|
|
1479
1659
|
id: new URL("https://example.com/activity/1"),
|
|
1480
1660
|
actor: new URL("https://example.com/person")
|
|
1481
1661
|
});
|
|
@@ -1524,7 +1704,7 @@ test("ContextImpl.sendActivity()", async (t) => {
|
|
|
1524
1704
|
documentLoader: fetchDocumentLoader,
|
|
1525
1705
|
contextLoader: fetchDocumentLoader
|
|
1526
1706
|
});
|
|
1527
|
-
const activity = new Create({
|
|
1707
|
+
const activity = new vocab.Create({
|
|
1528
1708
|
id: new URL("https://example.com/activity/1"),
|
|
1529
1709
|
actor: ctx.getActorUri("1"),
|
|
1530
1710
|
to: ctx.getFollowersUri("1")
|
|
@@ -1541,7 +1721,7 @@ test("ContextImpl.sendActivity()", async (t) => {
|
|
|
1541
1721
|
documentLoader: fetchDocumentLoader,
|
|
1542
1722
|
contextLoader: fetchDocumentLoader
|
|
1543
1723
|
});
|
|
1544
|
-
const activity = new Create({
|
|
1724
|
+
const activity = new vocab.Create({
|
|
1545
1725
|
id: new URL("https://example.com/activity/2"),
|
|
1546
1726
|
actor: ctx.getActorUri("1"),
|
|
1547
1727
|
to: ctx.getFollowersUri("1")
|
|
@@ -1563,7 +1743,7 @@ test({
|
|
|
1563
1743
|
async fn() {
|
|
1564
1744
|
const federation = new FederationImpl({ kv: new MemoryKvStore() });
|
|
1565
1745
|
const activities = [];
|
|
1566
|
-
federation.setInboxListeners("/u/{identifier}/i", "/i").on(Offer, (ctx$1, offer) => {
|
|
1746
|
+
federation.setInboxListeners("/u/{identifier}/i", "/i").on(vocab.Offer, (ctx$1, offer) => {
|
|
1567
1747
|
activities.push([ctx$1.recipient, offer]);
|
|
1568
1748
|
});
|
|
1569
1749
|
const ctx = new ContextImpl({
|
|
@@ -1573,52 +1753,52 @@ test({
|
|
|
1573
1753
|
documentLoader: mockDocumentLoader,
|
|
1574
1754
|
contextLoader: fetchDocumentLoader
|
|
1575
1755
|
});
|
|
1576
|
-
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") })));
|
|
1577
1757
|
assertEquals(activities, []);
|
|
1578
|
-
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);
|
|
1579
1759
|
assert(await ctx.routeActivity(null, signedOffer));
|
|
1580
1760
|
assertEquals(activities, [[null, signedOffer]]);
|
|
1581
|
-
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);
|
|
1582
1762
|
assert(await ctx.routeActivity("id", signedInvite));
|
|
1583
1763
|
assertEquals(activities, [[null, signedOffer], ["id", signedInvite]]);
|
|
1584
|
-
assertFalse(await ctx.routeActivity(null, new Create({
|
|
1764
|
+
assertFalse(await ctx.routeActivity(null, new vocab.Create({
|
|
1585
1765
|
id: new URL("https://example.com/not-found"),
|
|
1586
1766
|
actor: new URL("https://example.com/person")
|
|
1587
1767
|
})));
|
|
1588
1768
|
assertEquals(activities, [[null, signedOffer], ["id", signedInvite]]);
|
|
1589
|
-
assertFalse(await ctx.routeActivity(null, new Create({
|
|
1769
|
+
assertFalse(await ctx.routeActivity(null, new vocab.Create({
|
|
1590
1770
|
id: new URL("https://example.com/person"),
|
|
1591
1771
|
actor: new URL("https://example.com/person")
|
|
1592
1772
|
})));
|
|
1593
1773
|
assertEquals(activities, [[null, signedOffer], ["id", signedInvite]]);
|
|
1594
|
-
assertFalse(await ctx.routeActivity(null, new Announce({
|
|
1774
|
+
assertFalse(await ctx.routeActivity(null, new vocab.Announce({
|
|
1595
1775
|
id: new URL("https://example.com/announce#diffrent-id"),
|
|
1596
1776
|
actor: new URL("https://example.com/person")
|
|
1597
1777
|
})));
|
|
1598
1778
|
assertEquals(activities, [[null, signedOffer], ["id", signedInvite]]);
|
|
1599
|
-
assertFalse(await ctx.routeActivity(null, new Announce({
|
|
1779
|
+
assertFalse(await ctx.routeActivity(null, new vocab.Announce({
|
|
1600
1780
|
id: new URL("https://example.com/announce"),
|
|
1601
1781
|
actor: new URL("https://example.com/person")
|
|
1602
1782
|
})));
|
|
1603
1783
|
assertEquals(activities, [[null, signedOffer], ["id", signedInvite]]);
|
|
1604
|
-
assertFalse(await ctx.routeActivity(null, new Create({
|
|
1784
|
+
assertFalse(await ctx.routeActivity(null, new vocab.Create({
|
|
1605
1785
|
id: new URL("https://example.com/cross-origin-actor"),
|
|
1606
1786
|
actor: new URL("https://cross-origin.com/actor")
|
|
1607
1787
|
})));
|
|
1608
1788
|
assertEquals(activities, [[null, signedOffer], ["id", signedInvite]]);
|
|
1609
|
-
assert(await ctx.routeActivity(null, new Create({
|
|
1789
|
+
assert(await ctx.routeActivity(null, new vocab.Create({
|
|
1610
1790
|
id: new URL("https://example.com/create"),
|
|
1611
1791
|
actor: new URL("https://example.com/person")
|
|
1612
1792
|
})));
|
|
1613
1793
|
assertEquals(activities, [[null, signedOffer], ["id", signedInvite]]);
|
|
1614
|
-
assert(await ctx.routeActivity(null, new Invite({
|
|
1794
|
+
assert(await ctx.routeActivity(null, new vocab.Invite({
|
|
1615
1795
|
id: new URL("https://example.com/invite"),
|
|
1616
1796
|
actor: new URL("https://example.com/person")
|
|
1617
1797
|
})));
|
|
1618
1798
|
assertEquals(activities, [
|
|
1619
1799
|
[null, signedOffer],
|
|
1620
1800
|
["id", signedInvite],
|
|
1621
|
-
[null, new Invite({
|
|
1801
|
+
[null, new vocab.Invite({
|
|
1622
1802
|
id: new URL("https://example.com/invite"),
|
|
1623
1803
|
actor: new URL("https://example.com/person"),
|
|
1624
1804
|
object: new URL("https://example.com/object")
|
|
@@ -1640,15 +1820,15 @@ test("ContextImpl.getCollectionUri()", () => {
|
|
|
1640
1820
|
const dispatcher = (_ctx, _values) => ({ items: [] });
|
|
1641
1821
|
let url;
|
|
1642
1822
|
const strName = "registered";
|
|
1643
|
-
federation.setCollectionDispatcher(strName, Object
|
|
1823
|
+
federation.setCollectionDispatcher(strName, vocab.Object, "/string-route/{id}", dispatcher);
|
|
1644
1824
|
url = ctx.getCollectionUri(strName, values);
|
|
1645
1825
|
assertEquals(url.href, `${base}/string-route/123`);
|
|
1646
1826
|
const unnamedSymName = Symbol(strName);
|
|
1647
|
-
federation.setCollectionDispatcher(unnamedSymName, Object
|
|
1827
|
+
federation.setCollectionDispatcher(unnamedSymName, vocab.Object, "/symbol-route/{id}", dispatcher);
|
|
1648
1828
|
url = ctx.getCollectionUri(unnamedSymName, values);
|
|
1649
1829
|
assertEquals(url.href, `${base}/symbol-route/123`);
|
|
1650
1830
|
const namedSymName = Symbol.for(strName);
|
|
1651
|
-
federation.setCollectionDispatcher(namedSymName, Object
|
|
1831
|
+
federation.setCollectionDispatcher(namedSymName, vocab.Object, "/named-symbol-route/{id}", dispatcher);
|
|
1652
1832
|
url = ctx.getCollectionUri(namedSymName, values);
|
|
1653
1833
|
assertEquals(url.href, `${base}/named-symbol-route/123`);
|
|
1654
1834
|
const notReg = "not-registered";
|
|
@@ -1670,8 +1850,8 @@ test("InboxContextImpl.forwardActivity()", async (t) => {
|
|
|
1670
1850
|
let json = await cl.request.json();
|
|
1671
1851
|
if (await verifyJsonLd(json, options)) verified.push("ld");
|
|
1672
1852
|
json = detachSignature(json);
|
|
1673
|
-
let activity = await verifyObject(Activity, json, options);
|
|
1674
|
-
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);
|
|
1675
1855
|
else verified.push("proof");
|
|
1676
1856
|
const key = await verifyRequest(request, options);
|
|
1677
1857
|
if (key != null && await doesActorOwnKey(activity, key, options)) verified.push("http");
|
|
@@ -1681,7 +1861,7 @@ test("InboxContextImpl.forwardActivity()", async (t) => {
|
|
|
1681
1861
|
const kv = new MemoryKvStore();
|
|
1682
1862
|
const federation = new FederationImpl({
|
|
1683
1863
|
kv,
|
|
1684
|
-
|
|
1864
|
+
contextLoaderFactory: () => mockDocumentLoader
|
|
1685
1865
|
});
|
|
1686
1866
|
await t.step("skip", async () => {
|
|
1687
1867
|
const activity = {
|
|
@@ -1730,7 +1910,7 @@ test("InboxContextImpl.forwardActivity()", async (t) => {
|
|
|
1730
1910
|
assertEquals(verified, []);
|
|
1731
1911
|
});
|
|
1732
1912
|
await t.step("Object Integrity Proofs", async () => {
|
|
1733
|
-
const activity = await signObject(new Create({
|
|
1913
|
+
const activity = await signObject(new vocab.Create({
|
|
1734
1914
|
id: new URL("https://example.com/activity"),
|
|
1735
1915
|
actor: new URL("https://example.com/person2")
|
|
1736
1916
|
}), ed25519PrivateKey, ed25519Multikey.id, {
|