@fedify/fedify 1.7.12 → 1.7.14
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/dist/{actor-CPpvuBKU.d.ts → actor-Dx5YX74F.d.ts} +3 -3
- package/dist/{actor-GZRoTRqg.js → actor-OYVgkiZG.js} +329 -465
- package/dist/{actor-TYqJGdVq.js → actor-y7shp0CR.js} +6 -6
- package/dist/{assert-LOEeCUK5.js → assert-C-mZuSQl.js} +2 -2
- package/dist/{assert_equals-B44MxcIj.js → assert_equals-Dy0MG_Zw.js} +16 -16
- package/dist/{assert_instance_of-XtuFevV_.js → assert_instance_of-lS0Jr2iu.js} +2 -2
- package/dist/{assert_is_error-BTlryvT0.js → assert_is_error-CIYFACrT.js} +2 -2
- package/dist/{assert_not_equals-C685gKx6.js → assert_not_equals-C1azCAB0.js} +3 -6
- package/dist/{assert_rejects-DWQ4jaf9.js → assert_rejects-Bkh5lA1a.js} +3 -3
- package/dist/{assert_throws-YetpVSc-.js → assert_throws-CmpfkWEM.js} +3 -3
- package/dist/{authdocloader-hiFSyM7V.js → authdocloader-C0JcfxUs.js} +7 -9
- package/dist/{authdocloader-BopfyipD.js → authdocloader-C2krvRo1.js} +6 -8
- package/dist/{builder-mi6RdzNE.js → builder-DaECqbbT.js} +7 -7
- package/dist/{chunk-Cx8LTkjm.js → chunk-DvTpRkcT.js} +22 -15
- package/dist/{client-DuUKk4pk.js → client-dfu57WLy.js} +3 -3
- package/dist/{client-DvtwXO7t.d.ts → client-wKLuY12i.d.ts} +2 -2
- package/dist/{collection-Dfb0TPno.js → collection-XNLQhehO.js} +2 -3
- package/dist/{mod-DFncUgcE.d.ts → compat/mod-Bwqav33K.d.ts} +3 -3
- package/dist/compat/mod.js +1 -2
- package/dist/compat/transformers.test.js +34 -38
- package/dist/{context-OBWjptjU.d.ts → context-CW_8R4BH.d.ts} +11 -11
- package/dist/{context-RMU32mk4.js → context-nxDPfAiA.js} +5 -5
- package/dist/{docloader-09nVWLAZ.js → docloader-BDSHZfTJ.js} +1 -1
- package/dist/{docloader-DJxET2fN.js → docloader-BU25UQLB.js} +31 -151
- package/dist/{docloader-Q42SMRIB.d.ts → docloader-D_MGP37Q.d.ts} +2 -2
- package/dist/{docloader-bgBm1Hd1.js → docloader-sGz4vcrK.js} +32 -152
- package/dist/{esm-DO9PrujO.js → esm-BRXvTSrx.js} +36 -22
- package/dist/federation/builder.test.js +20 -26
- package/dist/federation/collection.test.js +11 -16
- package/dist/federation/handler.test.js +41 -48
- package/dist/federation/inbox.test.js +11 -11
- package/dist/federation/keycache.test.js +12 -11
- package/dist/federation/kv.test.js +8 -10
- package/dist/federation/middleware.test.js +105 -134
- package/dist/federation/mod-DvlLc8Ru.d.ts +6 -0
- package/dist/federation/mod.js +206 -12
- package/dist/federation/mq.test.js +12 -17
- package/dist/federation/retry.test.js +5 -4
- package/dist/federation/router.test.js +9 -10
- package/dist/federation/send.test.js +23 -24
- package/dist/{http-D2DkwsjA.js → http-BhES0Sg9.js} +23 -30
- package/dist/{http-DMTrO3Ye.d.ts → http-DFZRNfDP.d.ts} +3 -3
- package/dist/{http-vqMAvOVs.js → http-DRePVWfE.js} +23 -30
- package/dist/{inbox-DAAZZl2k.js → inbox-Z_QlSGYN.js} +5 -5
- package/dist/key-CJuc1GE1.js +10 -0
- package/dist/{key-DmqJj57e.js → key-D2HZrCxh.js} +4 -4
- package/dist/{key-KVhaUM92.js → key-bMrDyA2T.js} +5 -5
- package/dist/key-eP5Yk7hl.js +16 -0
- package/dist/{keycache-C1pEuRyQ.js → keycache-B5Rr8Lbc.js} +2 -2
- package/dist/{keys-C4XQHW5_.js → keys-DK4k1R8e.js} +2 -2
- package/dist/{kv-DRaeSXco.d.ts → kv-CKqSUxHd.d.ts} +1 -1
- package/dist/{kv-BMY6Qf_A.js → kv-QeuZ51go.js} +1 -1
- package/dist/{langstr-DbWheeIS.js → langstr-pFHBDU4y.js} +1 -1
- package/dist/{ld-DzlJ_IpT.js → ld--auFISy7.js} +9 -12
- package/dist/{lookup-CSngxuWm.js → lookup-4uc2jh52.js} +3 -3
- package/dist/{lookup-DL62q3Xh.js → lookup-Bq8vhIG4.js} +4 -4
- package/dist/{lookup-Bf-K85bV.d.ts → lookup-CqI9jhXo.d.ts} +2 -2
- package/dist/{lookup-D0je8AqR.js → lookup-cHV4n1IB.js} +6 -6
- package/dist/middleware-72Tuh6Iw.js +17 -0
- package/dist/{middleware-3wVT6S9E.js → middleware-B7p-onxQ.js} +35 -39
- package/dist/middleware-DB3BUysJ.js +32 -0
- package/dist/{middleware-DlDXugwZ.js → middleware-QJjRfjjc.js} +38 -43
- package/dist/{mod-CCL2cvnI.d.ts → mod-BEZy4WHZ.d.ts} +4 -4
- package/dist/mod-DMn4Bxyg.d.ts +20 -0
- package/dist/{mod-CDzlVCUF.d.ts → mod-DjGYGrBd.d.ts} +3 -3
- package/dist/mod.js +17 -17
- package/dist/{mq-DYKDDJmp.d.ts → mq-Cgfbl44M.d.ts} +1 -1
- package/dist/{multibase-CnLHszip.js → multibase-DBcKTV2a.js} +1 -1
- package/dist/nodeinfo/client.test.js +19 -28
- package/dist/nodeinfo/handler.test.js +37 -44
- package/dist/nodeinfo/mod--upgPcaX.d.ts +4 -0
- package/dist/nodeinfo/mod.js +2 -3
- package/dist/nodeinfo/semver.test.js +13 -21
- package/dist/nodeinfo/types.test.js +9 -11
- package/dist/{owner-D0cOz8R5.d.ts → owner-CewLNqWO.d.ts} +4 -4
- package/dist/{owner-81ey_76X.js → owner-DkTRLQAV.js} +4 -4
- package/dist/{proof-DlI7QNdn.js → proof-D4HXHDPz.js} +14 -19
- package/dist/{proof-BlULDH4H.js → proof-DT_xxRPF.js} +11 -13
- package/dist/{retry-BiIhZWgD.js → retry-BQet39_l.js} +1 -1
- package/dist/{router-D_aVZZUc.js → router-BuDkN4RQ.js} +1 -1
- package/dist/runtime/authdocloader.test.js +22 -26
- package/dist/runtime/docloader.test.js +56 -56
- package/dist/runtime/key.test.js +31 -53
- package/dist/runtime/langstr.test.js +8 -10
- package/dist/{mod-qFMzZ3iF.d.ts → runtime/mod-BaH1vtHp.d.ts} +4 -3
- package/dist/runtime/mod.js +6 -7
- package/dist/runtime/multibase/multibase.test.js +12 -18
- package/dist/runtime/url.test.js +7 -6
- package/dist/{semver-BNrOOAs9.js → semver-D9d-VO-_.js} +7 -17
- package/dist/{send-DdxfTHo6.js → send-axIyQX2p.js} +4 -4
- package/dist/sig/http.test.js +104 -168
- package/dist/sig/key.test.js +17 -20
- package/dist/sig/ld.test.js +28 -35
- package/dist/sig/mod-BmJQTnPT.d.ts +6 -0
- package/dist/sig/mod.js +6 -7
- package/dist/sig/owner.test.js +24 -30
- package/dist/sig/proof.test.js +24 -29
- package/dist/{std__assert-o_r9vqm1.js → std__assert-BdP_WkD-.js} +7 -13
- package/dist/testing/docloader.test.js +9 -12
- package/dist/testing/mod.js +2 -1
- package/dist/{testing-DLyvtiiW.js → testing-qaAD4B0t.js} +2 -2
- package/dist/{transformers-ghwJuzGY.js → transformers-CFSWUhNi.js} +1 -1
- package/dist/{type-CFuiGLz9.js → type-DFsmi-p1.js} +1 -1
- package/dist/{types-CmVV9LT1.js → types-Bk4b1bGc.js} +8 -18
- package/dist/{types-CJHS5pXl.js → types-CB_2uuCA.js} +2 -2
- package/dist/{url-C2xuoQD1.js → url-BdNvnK9P.js} +1 -1
- package/dist/vocab/actor.test.js +76 -128
- package/dist/vocab/lookup.test.js +19 -23
- package/dist/vocab/mod-BkXGAYkx.d.ts +6 -0
- package/dist/vocab/mod.js +4 -4
- package/dist/vocab/type.test.js +10 -10
- package/dist/vocab/vocab.test.js +109 -105
- package/dist/{vocab-DFlq4Wa6.js → vocab-DCHRuBGF.js} +328 -464
- package/dist/{vocab-CzEfWQk2.d.ts → vocab-DoBcp8ow.d.ts} +2 -2
- package/dist/{vocab-BebR0kAy.js → vocab-sMuiKIWm.js} +5 -5
- package/dist/webfinger/handler.test.js +40 -48
- package/dist/webfinger/lookup.test.js +12 -15
- package/dist/webfinger/mod-B1UhCvlL.d.ts +4 -0
- package/dist/webfinger/mod.js +2 -3
- package/dist/x/{cfworkers.d.ts → cfworkers-BIcR64Sf.d.ts} +2 -2
- package/dist/x/cfworkers.test.js +7 -9
- package/dist/x/{hono.d.ts → hono-DmQmp8wi.d.ts} +2 -11
- package/dist/x/{sveltekit.d.ts → sveltekit-Cvh0XnN4.d.ts} +2 -11
- package/package.json +1 -1
- package/dist/compat/mod.d.ts +0 -15
- package/dist/compat-Bb5myD13.js +0 -4
- package/dist/federation/mod.d.ts +0 -15
- package/dist/federation-B0aljx0V.js +0 -203
- package/dist/key-5ssHQ67E.js +0 -16
- package/dist/key-DSJGnD10.js +0 -10
- package/dist/middleware-CxFoFBD8.js +0 -33
- package/dist/middleware-w7_U3fFi.js +0 -17
- package/dist/mod-1pDWKvUL.d.ts +0 -2
- package/dist/mod-GIh5OYxW.d.ts +0 -2
- package/dist/mod-g0xFzAP9.d.ts +0 -2
- package/dist/mod.d.ts +0 -20
- package/dist/nodeinfo/mod.d.ts +0 -7
- package/dist/nodeinfo-CyEbLjHs.js +0 -4
- package/dist/runtime/mod.d.ts +0 -8
- package/dist/runtime-BSkOVUWM.js +0 -4
- package/dist/sig/mod.d.ts +0 -10
- package/dist/sig-BXJO--F9.js +0 -4
- package/dist/vocab/mod.d.ts +0 -8
- package/dist/webfinger/mod.d.ts +0 -7
- package/dist/webfinger-C3GIyXIg.js +0 -4
- /package/dist/compat/{transformers.test.d.ts → transformers.test-DnJbd34u.d.ts} +0 -0
- /package/dist/{denokv-CvROlGYX.js → denokv-NcJeZ6rP.js} +0 -0
- /package/dist/federation/{builder.test.d.ts → builder.test-Bpt6NOZ6.d.ts} +0 -0
- /package/dist/federation/{collection.test.d.ts → collection.test-DKJ6JOZz.d.ts} +0 -0
- /package/dist/federation/{handler.test.d.ts → handler.test-BMT7uLC0.d.ts} +0 -0
- /package/dist/federation/{inbox.test.d.ts → inbox.test-Do6i02Qp.d.ts} +0 -0
- /package/dist/federation/{keycache.test.d.ts → keycache.test-BT83IPZY.d.ts} +0 -0
- /package/dist/federation/{kv.test.d.ts → kv.test-kFzzF2VN.d.ts} +0 -0
- /package/dist/federation/{middleware.test.d.ts → middleware.test-B1R4_e3-.d.ts} +0 -0
- /package/dist/federation/{mq.test.d.ts → mq.test-l79EQQOe.d.ts} +0 -0
- /package/dist/federation/{retry.test.d.ts → retry.test-BqS50VCX.d.ts} +0 -0
- /package/dist/federation/{router.test.d.ts → router.test-CYQl4po-.d.ts} +0 -0
- /package/dist/federation/{send.test.d.ts → send.test-COUnNUzv.d.ts} +0 -0
- /package/dist/nodeinfo/{client.test.d.ts → client.test-CZLe79hL.d.ts} +0 -0
- /package/dist/nodeinfo/{handler.test.d.ts → handler.test-B-EDZ_hK.d.ts} +0 -0
- /package/dist/nodeinfo/{semver.test.d.ts → semver.test-BEuuQSEM.d.ts} +0 -0
- /package/dist/nodeinfo/{types.test.d.ts → types.test-B5AT89WV.d.ts} +0 -0
- /package/dist/runtime/{authdocloader.test.d.ts → authdocloader.test-hCRKzn9v.d.ts} +0 -0
- /package/dist/runtime/{docloader.test.d.ts → docloader.test-CVd7i_5h.d.ts} +0 -0
- /package/dist/runtime/{key.test.d.ts → key.test-DBsILYSD.d.ts} +0 -0
- /package/dist/runtime/{langstr.test.d.ts → langstr.test-CiKxuuRY.d.ts} +0 -0
- /package/dist/runtime/multibase/{multibase.test.d.ts → multibase.test-Brh6gPBP.d.ts} +0 -0
- /package/dist/runtime/{url.test.d.ts → url.test-DlRqkU2j.d.ts} +0 -0
- /package/dist/sig/{http.test.d.ts → http.test-BpXNAWNI.d.ts} +0 -0
- /package/dist/sig/{key.test.d.ts → key.test-B2iLIugy.d.ts} +0 -0
- /package/dist/sig/{ld.test.d.ts → ld.test-D-cI70Gw.d.ts} +0 -0
- /package/dist/sig/{owner.test.d.ts → owner.test-B_YRjMPj.d.ts} +0 -0
- /package/dist/sig/{proof.test.d.ts → proof.test-BagEM_-4.d.ts} +0 -0
- /package/dist/testing/{docloader.test.d.ts → docloader.test-lrzf6sDZ.d.ts} +0 -0
- /package/dist/testing/{mod.d.ts → mod-3uM8ZvS7.d.ts} +0 -0
- /package/dist/vocab/{actor.test.d.ts → actor.test-ClC-iVWk.d.ts} +0 -0
- /package/dist/vocab/{lookup.test.d.ts → lookup.test-Cq1I-27w.d.ts} +0 -0
- /package/dist/vocab/{type.test.d.ts → type.test-bfFiYGcs.d.ts} +0 -0
- /package/dist/vocab/{vocab.test.d.ts → vocab.test-h-ZTisfu.d.ts} +0 -0
- /package/dist/webfinger/{handler.test.d.ts → handler.test-DiUeEDDD.d.ts} +0 -0
- /package/dist/webfinger/{lookup.test.d.ts → lookup.test-D9onm3U3.d.ts} +0 -0
- /package/dist/x/{cfworkers.test.d.ts → cfworkers.test-KXHlJ29z.d.ts} +0 -0
|
@@ -3,110 +3,99 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import "../
|
|
13
|
-
import "../
|
|
14
|
-
import "../
|
|
15
|
-
import
|
|
16
|
-
import "../
|
|
17
|
-
import "../
|
|
18
|
-
import
|
|
19
|
-
import "../
|
|
20
|
-
import "../
|
|
21
|
-
import
|
|
22
|
-
import "../
|
|
23
|
-
import "../
|
|
24
|
-
import
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import "../
|
|
31
|
-
import "../
|
|
32
|
-
import "../
|
|
33
|
-
import "../
|
|
34
|
-
import "../
|
|
35
|
-
import "../send-
|
|
36
|
-
import { test } from "../testing-
|
|
37
|
-
import { assertStrictEquals } from "../std__assert-
|
|
38
|
-
import { assertFalse, assertRejects } from "../assert_rejects-
|
|
39
|
-
import "../assert_is_error-
|
|
40
|
-
import { assertNotEquals } from "../assert_not_equals-
|
|
41
|
-
import { assertThrows } from "../assert_throws-
|
|
42
|
-
import { mockDocumentLoader } from "../docloader-
|
|
43
|
-
import {
|
|
44
|
-
import { esm_default } from "../esm-
|
|
6
|
+
import "../chunk-DvTpRkcT.js";
|
|
7
|
+
import { t as assertEquals } from "../assert_equals-Dy0MG_Zw.js";
|
|
8
|
+
import { t as assert } from "../assert-C-mZuSQl.js";
|
|
9
|
+
import { t as assertInstanceOf } from "../assert_instance_of-lS0Jr2iu.js";
|
|
10
|
+
import { t as MemoryKvStore } from "../kv-QeuZ51go.js";
|
|
11
|
+
import { a as createFederation, i as KvSpecDeterminer, n as FederationImpl, r as InboxContextImpl, t as ContextImpl } from "../middleware-B7p-onxQ.js";
|
|
12
|
+
import { r as fetchDocumentLoader, t as FetchError } from "../docloader-sGz4vcrK.js";
|
|
13
|
+
import "../url-BdNvnK9P.js";
|
|
14
|
+
import "../semver-D9d-VO-_.js";
|
|
15
|
+
import "../client-dfu57WLy.js";
|
|
16
|
+
import { n as RouterError } from "../router-BuDkN4RQ.js";
|
|
17
|
+
import "../types-CB_2uuCA.js";
|
|
18
|
+
import "../multibase-DBcKTV2a.js";
|
|
19
|
+
import { S as Person, _ as Object$1, a as Create, g as Note, h as Multikey, n as Announce, p as Invite, t as Activity, v as Offer } from "../vocab-DCHRuBGF.js";
|
|
20
|
+
import "../langstr-pFHBDU4y.js";
|
|
21
|
+
import "../lookup-Bq8vhIG4.js";
|
|
22
|
+
import { t as getTypeId } from "../type-DFsmi-p1.js";
|
|
23
|
+
import "../actor-y7shp0CR.js";
|
|
24
|
+
import "../key-bMrDyA2T.js";
|
|
25
|
+
import { l as verifyRequest, s as signRequest } from "../http-BhES0Sg9.js";
|
|
26
|
+
import { t as getAuthenticatedDocumentLoader } from "../authdocloader-C0JcfxUs.js";
|
|
27
|
+
import { a as signJsonLd, o as verifyJsonLd, r as detachSignature } from "../ld--auFISy7.js";
|
|
28
|
+
import { t as doesActorOwnKey } from "../owner-DkTRLQAV.js";
|
|
29
|
+
import { n as signObject, r as verifyObject } from "../proof-DT_xxRPF.js";
|
|
30
|
+
import { t as lookupObject } from "../lookup-cHV4n1IB.js";
|
|
31
|
+
import "../inbox-Z_QlSGYN.js";
|
|
32
|
+
import "../builder-DaECqbbT.js";
|
|
33
|
+
import "../collection-XNLQhehO.js";
|
|
34
|
+
import "../keycache-B5Rr8Lbc.js";
|
|
35
|
+
import "../send-axIyQX2p.js";
|
|
36
|
+
import { t as test } from "../testing-qaAD4B0t.js";
|
|
37
|
+
import { n as assertStrictEquals } from "../std__assert-BdP_WkD-.js";
|
|
38
|
+
import { n as assertFalse, t as assertRejects } from "../assert_rejects-Bkh5lA1a.js";
|
|
39
|
+
import "../assert_is_error-CIYFACrT.js";
|
|
40
|
+
import { t as assertNotEquals } from "../assert_not_equals-C1azCAB0.js";
|
|
41
|
+
import { t as assertThrows } from "../assert_throws-CmpfkWEM.js";
|
|
42
|
+
import { t as mockDocumentLoader } from "../docloader-BDSHZfTJ.js";
|
|
43
|
+
import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DK4k1R8e.js";
|
|
44
|
+
import { t as esm_default } from "../esm-BRXvTSrx.js";
|
|
45
45
|
|
|
46
46
|
//#region testing/fixtures/example.com/person.json
|
|
47
|
-
var __context$1 = ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"];
|
|
48
|
-
var id$1 = "https://example.com/person";
|
|
49
|
-
var type$1 = "Person";
|
|
50
|
-
var name$1 = "John Doe";
|
|
51
|
-
var publicKey$1 = [{
|
|
52
|
-
"id": "https://example.com/key",
|
|
53
|
-
"owner": "https://example.com/person",
|
|
54
|
-
"type": "CryptographicKey",
|
|
55
|
-
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyIB9rotX8G6r6/6toT+x\n24BUiQ/HaPH1Em9dOt4c94s+OPFoEdH7DY7Iym9A8LlH4JaGF8KD38bLHWe1S4x0\njV3gHJKhK7veJfGZCKUENcQecBZ+YWUs5HWvUIX1vVB//0luHrg6BQKGOrSOE+WI\nAxyr0qsWCFfZzQrvSnUD2yvg1arJX2xhms14uxoRd5Kg9efKSCmmQaNEapicARUm\nFWrIEpGFa/nUUnqimssAGw1eZFqf3wA4TjhsuARBhGaJtv/3KEa016eMZxy3kDlO\njZnXZTaTgWkXdodwUvy8563fes3Al6BlcS2iJ9qbtha8rSm0FHqoUKH73JsLPKQI\nwQIDAQAB\n-----END PUBLIC KEY-----"
|
|
56
|
-
}, {
|
|
57
|
-
"id": "https://example.com/key2",
|
|
58
|
-
"type": "CryptographicKey",
|
|
59
|
-
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoRmBtnxbdFutoRd1GLGw\nwGTrsqlRRWUe11hHQaoRLGf5LwQ0tIc6I9q+dynliw+2kxYsLn9SH2je6HcTYOol\ngW7F/cOWXZQN04b+OiYcU1ConAhLjmn4k1uKawJ614y0ScPNd8PQ+CljsnlPxbq9\nofaCMe2BV3B6y09aCuGFJ0nxn1/ubjmIBIWWFTAznoz1J9BhJDGyt3IO3ABy3f9z\nDVlR32L/n5VIkXnxkjUKdzMAOzYb62kuKOp1iznRTPrV71SNtivJMwSh/LVgBrmZ\njtIn/oim+KyX/fdLU3tQ7VClyqmJzyAjccOH6Qj6nFTPh+vX07gqN8IlLT2uye4w\nawIDAQAB\n-----END PUBLIC KEY-----"
|
|
60
|
-
}];
|
|
61
47
|
var person_default = {
|
|
62
|
-
"@context":
|
|
63
|
-
id:
|
|
64
|
-
type:
|
|
65
|
-
name:
|
|
66
|
-
publicKey:
|
|
48
|
+
"@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
|
|
49
|
+
id: "https://example.com/person",
|
|
50
|
+
type: "Person",
|
|
51
|
+
name: "John Doe",
|
|
52
|
+
publicKey: [{
|
|
53
|
+
"id": "https://example.com/key",
|
|
54
|
+
"owner": "https://example.com/person",
|
|
55
|
+
"type": "CryptographicKey",
|
|
56
|
+
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyIB9rotX8G6r6/6toT+x\n24BUiQ/HaPH1Em9dOt4c94s+OPFoEdH7DY7Iym9A8LlH4JaGF8KD38bLHWe1S4x0\njV3gHJKhK7veJfGZCKUENcQecBZ+YWUs5HWvUIX1vVB//0luHrg6BQKGOrSOE+WI\nAxyr0qsWCFfZzQrvSnUD2yvg1arJX2xhms14uxoRd5Kg9efKSCmmQaNEapicARUm\nFWrIEpGFa/nUUnqimssAGw1eZFqf3wA4TjhsuARBhGaJtv/3KEa016eMZxy3kDlO\njZnXZTaTgWkXdodwUvy8563fes3Al6BlcS2iJ9qbtha8rSm0FHqoUKH73JsLPKQI\nwQIDAQAB\n-----END PUBLIC KEY-----"
|
|
57
|
+
}, {
|
|
58
|
+
"id": "https://example.com/key2",
|
|
59
|
+
"type": "CryptographicKey",
|
|
60
|
+
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoRmBtnxbdFutoRd1GLGw\nwGTrsqlRRWUe11hHQaoRLGf5LwQ0tIc6I9q+dynliw+2kxYsLn9SH2je6HcTYOol\ngW7F/cOWXZQN04b+OiYcU1ConAhLjmn4k1uKawJ614y0ScPNd8PQ+CljsnlPxbq9\nofaCMe2BV3B6y09aCuGFJ0nxn1/ubjmIBIWWFTAznoz1J9BhJDGyt3IO3ABy3f9z\nDVlR32L/n5VIkXnxkjUKdzMAOzYb62kuKOp1iznRTPrV71SNtivJMwSh/LVgBrmZ\njtIn/oim+KyX/fdLU3tQ7VClyqmJzyAjccOH6Qj6nFTPh+vX07gqN8IlLT2uye4w\nawIDAQAB\n-----END PUBLIC KEY-----"
|
|
61
|
+
}]
|
|
67
62
|
};
|
|
68
63
|
|
|
69
64
|
//#endregion
|
|
70
65
|
//#region testing/fixtures/example.com/person2.json
|
|
71
|
-
var __context = [
|
|
72
|
-
"https://www.w3.org/ns/activitystreams",
|
|
73
|
-
"https://w3id.org/security/v1",
|
|
74
|
-
"https://w3id.org/security/multikey/v1",
|
|
75
|
-
"https://w3id.org/security/data-integrity/v1",
|
|
76
|
-
"https://www.w3.org/ns/did/v1"
|
|
77
|
-
];
|
|
78
|
-
var id = "https://example.com/person2";
|
|
79
|
-
var type = "Person";
|
|
80
|
-
var name = "Jane Doe";
|
|
81
|
-
var publicKey = [{
|
|
82
|
-
"id": "https://example.com/person2#key3",
|
|
83
|
-
"type": "CryptographicKey",
|
|
84
|
-
"owner": "https://example.com/person2",
|
|
85
|
-
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA4GUqWgdiYlN3Su5Gr4l6\ni+xRS8gDDVKZ718vpGk6eIpvqs33q430nRbHIzbHRXRaAhc/1++rUBcK0V4/kjZl\nCSzVtRgGU6HMkmjcD+uE56a8XbTczfltbEDj7afoEuB2F3UhQEWrSz+QJ29DPXaL\nMIa1Yv61NR2vxGqNbdtoMjDORMBYtg77CYbcFkiJHw65PDa7+f/yjLxuCRPye5L7\nhncN0UZuuFoRJmHNRLSg5omBad9WTvQXmSyXEhEdk9fHwlI022AqAzlWbT79hldc\nDSKGGLLbQIs1c3JZIG8G5i6Uh5Vy0Z7tSNBcxbhqoI9i9je4f/x/OPIVc19f04BE\n1LgWuHsftZzRgW9Sdqz53W83XxVdxlyHeywXOnstSWT11f8dkLyQUcHKTH+E6urb\nH+aiPLiRpYK8W7D9KTQA9kZ5JXaEuveBd5vJX7wakhbzAn8pWJU7GYIHNY38Ycok\nmivkU5pY8S2cKFMwY0b7ade3MComlir5P3ZYSjF+n6gRVsT96P+9mNfCu9gXt/f8\nXCyjKlH89kGwuJ7HhR8CuVdm0l+jYozVt6GsDy0hHYyn79NCCAEzP7ZbhBMR0T5V\nrkl+TIGXoJH9WFiz4VxO+NnglF6dNQjDS5IzYLoFRXIK1f3cmQiEB4FZmL70l9HL\nrgwR+Xys83xia79OqFDRezMCAwEAAQ==\n-----END PUBLIC KEY-----\n"
|
|
86
|
-
}, {
|
|
87
|
-
"id": "https://example.com/person2#key4",
|
|
88
|
-
"type": "CryptographicKey",
|
|
89
|
-
"owner": "https://example.com/person2",
|
|
90
|
-
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEALR8epAGDe+cVq5p2Tx49CCfphpk1rNhkNoY9i+XEUfg=\n-----END PUBLIC KEY-----\n"
|
|
91
|
-
}];
|
|
92
|
-
var assertionMethod = [{
|
|
93
|
-
"id": "https://example.com/peson2#key3",
|
|
94
|
-
"type": "Multikey",
|
|
95
|
-
"controller": "https://example.com/person2",
|
|
96
|
-
"publicKeyMultibase": "zgghBUVkqmWS8e1j4aN2yowLAEkJC6wowB9wWmLRACYCok7UzstWcTBp3waKiDUM7wqL9bbBD9W9FvNaXEK2KPCZ9ffhvd5dxChJL9bdPQSrMwa28FEYMGDtcF1uocrYNmZm2dBBMaWrCu8U3s4PpVVhn4hsWDL8GLuE466pkJs9Hy8xmECoaaVgAZLiYDw2gwrjHDiX2i7aDHKfE7aSZWUWmC8nAGNZ7DX5pXoyXK3pxuaCWxNxXwPmaFwgKDyy9uhtBJ8znp9NZXkXHBTQe5uAi8GFwHY5asvqCmYPrAGWxcT6pdbZaJHdWkM7nw6apBHfakKs42oMqdBoJ2WkkresoT1qHrX2GW7gNP9PLtveF4vfEd6cwgHKQCdYgayG3muGfZiPvML75cyfkNrjkctvuQUfMxY9umbd2TG3V3mPnLrvQnqHpuRMZYtCn3nX1qfZaqFhTwT4NFPqVNLqvgR6k9vcuGXn6Ndaumhd5xtTK64jk3e2gPBit9iq6MrFUSoxNsbTty4kqcHAodtkK8CMSxUxbFP1kK3nyy8ZfeMgDCts1KboBcT2m5FMpQpYxKtNBfvhTuyeDDC34uhbY8itmTAnDwSr5mKrniwwDUGPZFejda51TYs1N9D9Ejzaw5Mvr8qN6wahHmsDBWTbWwV6YKVMD1MjAhJBUopWJWB5x6mEBAX25MssKfAEhJyDtqYWjq63uQHUJCsPJp"
|
|
97
|
-
}, {
|
|
98
|
-
"id": "https://example.com/person2#key4",
|
|
99
|
-
"type": "Multikey",
|
|
100
|
-
"controller": "https://example.com/person2",
|
|
101
|
-
"publicKeyMultibase": "z6MkhVPuyvgG1RkMv67azDqDCDERPXVrUg1i3qchXY5EACE3"
|
|
102
|
-
}];
|
|
103
66
|
var person2_default = {
|
|
104
|
-
"@context":
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
67
|
+
"@context": [
|
|
68
|
+
"https://www.w3.org/ns/activitystreams",
|
|
69
|
+
"https://w3id.org/security/v1",
|
|
70
|
+
"https://w3id.org/security/multikey/v1",
|
|
71
|
+
"https://w3id.org/security/data-integrity/v1",
|
|
72
|
+
"https://www.w3.org/ns/did/v1"
|
|
73
|
+
],
|
|
74
|
+
id: "https://example.com/person2",
|
|
75
|
+
type: "Person",
|
|
76
|
+
name: "Jane Doe",
|
|
77
|
+
publicKey: [{
|
|
78
|
+
"id": "https://example.com/person2#key3",
|
|
79
|
+
"type": "CryptographicKey",
|
|
80
|
+
"owner": "https://example.com/person2",
|
|
81
|
+
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA4GUqWgdiYlN3Su5Gr4l6\ni+xRS8gDDVKZ718vpGk6eIpvqs33q430nRbHIzbHRXRaAhc/1++rUBcK0V4/kjZl\nCSzVtRgGU6HMkmjcD+uE56a8XbTczfltbEDj7afoEuB2F3UhQEWrSz+QJ29DPXaL\nMIa1Yv61NR2vxGqNbdtoMjDORMBYtg77CYbcFkiJHw65PDa7+f/yjLxuCRPye5L7\nhncN0UZuuFoRJmHNRLSg5omBad9WTvQXmSyXEhEdk9fHwlI022AqAzlWbT79hldc\nDSKGGLLbQIs1c3JZIG8G5i6Uh5Vy0Z7tSNBcxbhqoI9i9je4f/x/OPIVc19f04BE\n1LgWuHsftZzRgW9Sdqz53W83XxVdxlyHeywXOnstSWT11f8dkLyQUcHKTH+E6urb\nH+aiPLiRpYK8W7D9KTQA9kZ5JXaEuveBd5vJX7wakhbzAn8pWJU7GYIHNY38Ycok\nmivkU5pY8S2cKFMwY0b7ade3MComlir5P3ZYSjF+n6gRVsT96P+9mNfCu9gXt/f8\nXCyjKlH89kGwuJ7HhR8CuVdm0l+jYozVt6GsDy0hHYyn79NCCAEzP7ZbhBMR0T5V\nrkl+TIGXoJH9WFiz4VxO+NnglF6dNQjDS5IzYLoFRXIK1f3cmQiEB4FZmL70l9HL\nrgwR+Xys83xia79OqFDRezMCAwEAAQ==\n-----END PUBLIC KEY-----\n"
|
|
82
|
+
}, {
|
|
83
|
+
"id": "https://example.com/person2#key4",
|
|
84
|
+
"type": "CryptographicKey",
|
|
85
|
+
"owner": "https://example.com/person2",
|
|
86
|
+
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEALR8epAGDe+cVq5p2Tx49CCfphpk1rNhkNoY9i+XEUfg=\n-----END PUBLIC KEY-----\n"
|
|
87
|
+
}],
|
|
88
|
+
assertionMethod: [{
|
|
89
|
+
"id": "https://example.com/peson2#key3",
|
|
90
|
+
"type": "Multikey",
|
|
91
|
+
"controller": "https://example.com/person2",
|
|
92
|
+
"publicKeyMultibase": "zgghBUVkqmWS8e1j4aN2yowLAEkJC6wowB9wWmLRACYCok7UzstWcTBp3waKiDUM7wqL9bbBD9W9FvNaXEK2KPCZ9ffhvd5dxChJL9bdPQSrMwa28FEYMGDtcF1uocrYNmZm2dBBMaWrCu8U3s4PpVVhn4hsWDL8GLuE466pkJs9Hy8xmECoaaVgAZLiYDw2gwrjHDiX2i7aDHKfE7aSZWUWmC8nAGNZ7DX5pXoyXK3pxuaCWxNxXwPmaFwgKDyy9uhtBJ8znp9NZXkXHBTQe5uAi8GFwHY5asvqCmYPrAGWxcT6pdbZaJHdWkM7nw6apBHfakKs42oMqdBoJ2WkkresoT1qHrX2GW7gNP9PLtveF4vfEd6cwgHKQCdYgayG3muGfZiPvML75cyfkNrjkctvuQUfMxY9umbd2TG3V3mPnLrvQnqHpuRMZYtCn3nX1qfZaqFhTwT4NFPqVNLqvgR6k9vcuGXn6Ndaumhd5xtTK64jk3e2gPBit9iq6MrFUSoxNsbTty4kqcHAodtkK8CMSxUxbFP1kK3nyy8ZfeMgDCts1KboBcT2m5FMpQpYxKtNBfvhTuyeDDC34uhbY8itmTAnDwSr5mKrniwwDUGPZFejda51TYs1N9D9Ejzaw5Mvr8qN6wahHmsDBWTbWwV6YKVMD1MjAhJBUopWJWB5x6mEBAX25MssKfAEhJyDtqYWjq63uQHUJCsPJp"
|
|
93
|
+
}, {
|
|
94
|
+
"id": "https://example.com/person2#key4",
|
|
95
|
+
"type": "Multikey",
|
|
96
|
+
"controller": "https://example.com/person2",
|
|
97
|
+
"publicKeyMultibase": "z6MkhVPuyvgG1RkMv67azDqDCDERPXVrUg1i3qchXY5EACE3"
|
|
98
|
+
}]
|
|
110
99
|
};
|
|
111
100
|
|
|
112
101
|
//#endregion
|
|
@@ -332,23 +321,20 @@ test("Federation.createContext()", async (t) => {
|
|
|
332
321
|
publicKey: ed25519PublicKey.publicKey
|
|
333
322
|
})
|
|
334
323
|
}]);
|
|
335
|
-
|
|
336
|
-
assertEquals(await loader("https://example.com/object"), {
|
|
324
|
+
assertEquals(await (await ctx.getDocumentLoader({ identifier: "handle" }))("https://example.com/object"), {
|
|
337
325
|
contextUrl: null,
|
|
338
326
|
documentUrl: "https://example.com/object",
|
|
339
327
|
document: true
|
|
340
328
|
});
|
|
341
|
-
|
|
342
|
-
assertEquals(await loader2("https://example.com/object"), {
|
|
329
|
+
assertEquals(await (await ctx.getDocumentLoader({ username: "HANDLE" }))("https://example.com/object"), {
|
|
343
330
|
contextUrl: null,
|
|
344
331
|
documentUrl: "https://example.com/object",
|
|
345
332
|
document: true
|
|
346
333
|
});
|
|
347
|
-
|
|
334
|
+
assertEquals(await ctx.getDocumentLoader({
|
|
348
335
|
keyId: new URL("https://example.com/key2"),
|
|
349
336
|
privateKey: rsaPrivateKey2
|
|
350
|
-
})
|
|
351
|
-
assertEquals(await loader3("https://example.com/object"), {
|
|
337
|
+
})("https://example.com/object"), {
|
|
352
338
|
contextUrl: null,
|
|
353
339
|
documentUrl: "https://example.com/object",
|
|
354
340
|
document: true
|
|
@@ -356,12 +342,11 @@ test("Federation.createContext()", async (t) => {
|
|
|
356
342
|
assertEquals(await ctx.lookupObject("https://example.com/object"), null);
|
|
357
343
|
await assertRejects(() => ctx.sendActivity({ identifier: "handle" }, [], new Create({})), TypeError, "The activity to send must have at least one actor property.");
|
|
358
344
|
await ctx.sendActivity({ identifier: "handle" }, [], new Create({ actor: new URL("https://example.com/users/handle") }));
|
|
359
|
-
|
|
345
|
+
assertEquals(await createFederation({
|
|
360
346
|
kv,
|
|
361
347
|
documentLoader: mockDocumentLoader,
|
|
362
348
|
contextLoader: mockDocumentLoader
|
|
363
|
-
}).createContext(new URL("https://example.com/"), 123)
|
|
364
|
-
assertEquals(await ctx2.lookupObject("https://example.com/object"), new Object$1({
|
|
349
|
+
}).createContext(new URL("https://example.com/"), 123).lookupObject("https://example.com/object"), new Object$1({
|
|
365
350
|
id: new URL("https://example.com/object"),
|
|
366
351
|
name: "Fetched object"
|
|
367
352
|
}));
|
|
@@ -656,8 +641,7 @@ test("Federation.createContext()", async (t) => {
|
|
|
656
641
|
kv,
|
|
657
642
|
userAgent: "CustomUserAgent/1.2.3"
|
|
658
643
|
}).createContext(new URL("https://example.com/"), 123);
|
|
659
|
-
|
|
660
|
-
assertEquals(nodeInfo, {
|
|
644
|
+
assertEquals(await ctx.lookupNodeInfo("https://example.com/"), {
|
|
661
645
|
software: {
|
|
662
646
|
name: "foo",
|
|
663
647
|
version: {
|
|
@@ -675,8 +659,7 @@ test("Federation.createContext()", async (t) => {
|
|
|
675
659
|
localComments: 456
|
|
676
660
|
}
|
|
677
661
|
});
|
|
678
|
-
|
|
679
|
-
assertEquals(rawNodeInfo, {
|
|
662
|
+
assertEquals(await ctx.lookupNodeInfo("https://example.com/", { parse: "none" }), {
|
|
680
663
|
software: {
|
|
681
664
|
name: "foo",
|
|
682
665
|
version: "1.2.3"
|
|
@@ -1000,9 +983,8 @@ test("FederationImpl.sendActivity()", async (t) => {
|
|
|
1000
983
|
if (verified.length > 0) return new Response(null, { status: 202 });
|
|
1001
984
|
return new Response(null, { status: 401 });
|
|
1002
985
|
});
|
|
1003
|
-
const kv = new MemoryKvStore();
|
|
1004
986
|
const federation = new FederationImpl({
|
|
1005
|
-
kv,
|
|
987
|
+
kv: new MemoryKvStore(),
|
|
1006
988
|
contextLoader: mockDocumentLoader
|
|
1007
989
|
});
|
|
1008
990
|
const context = federation.createContext(new URL("https://example.com/"));
|
|
@@ -1230,11 +1212,10 @@ test("ContextImpl.lookupObject()", async (t) => {
|
|
|
1230
1212
|
assertEquals(result.preferredUsername, "test");
|
|
1231
1213
|
});
|
|
1232
1214
|
await t.step("allowPrivateAddress: false", async () => {
|
|
1233
|
-
|
|
1215
|
+
assertEquals(await createFederation({
|
|
1234
1216
|
kv: new MemoryKvStore(),
|
|
1235
1217
|
allowPrivateAddress: false
|
|
1236
|
-
}).createContext(new URL("https://example.com/")).lookupObject("@test@localhost");
|
|
1237
|
-
assertEquals(result, null);
|
|
1218
|
+
}).createContext(new URL("https://example.com/")).lookupObject("@test@localhost"), null);
|
|
1238
1219
|
});
|
|
1239
1220
|
esm_default.hardReset();
|
|
1240
1221
|
});
|
|
@@ -1630,9 +1611,8 @@ test("InboxContextImpl.forwardActivity()", async (t) => {
|
|
|
1630
1611
|
if (verified.length > 0) return new Response(null, { status: 202 });
|
|
1631
1612
|
return new Response(null, { status: 401 });
|
|
1632
1613
|
});
|
|
1633
|
-
const kv = new MemoryKvStore();
|
|
1634
1614
|
const federation = new FederationImpl({
|
|
1635
|
-
kv,
|
|
1615
|
+
kv: new MemoryKvStore(),
|
|
1636
1616
|
contextLoader: mockDocumentLoader
|
|
1637
1617
|
});
|
|
1638
1618
|
await t.step("skip", async () => {
|
|
@@ -1702,13 +1682,12 @@ test("InboxContextImpl.forwardActivity()", async (t) => {
|
|
|
1702
1682
|
assertEquals(verified, ["proof"]);
|
|
1703
1683
|
});
|
|
1704
1684
|
await t.step("LD Signatures", async () => {
|
|
1705
|
-
|
|
1685
|
+
await new InboxContextImpl(null, await signJsonLd({
|
|
1706
1686
|
"@context": "https://www.w3.org/ns/activitystreams",
|
|
1707
1687
|
"type": "Create",
|
|
1708
1688
|
"id": "https://example.com/activity",
|
|
1709
1689
|
"actor": "https://example.com/person2"
|
|
1710
|
-
}, rsaPrivateKey3, rsaPublicKey3.id, { contextLoader: mockDocumentLoader })
|
|
1711
|
-
await new InboxContextImpl(null, activity, "https://example.com/activity", "https://www.w3.org/ns/activitystreams#Create", {
|
|
1690
|
+
}, rsaPrivateKey3, rsaPublicKey3.id, { contextLoader: mockDocumentLoader }), "https://example.com/activity", "https://www.w3.org/ns/activitystreams#Create", {
|
|
1712
1691
|
data: void 0,
|
|
1713
1692
|
federation,
|
|
1714
1693
|
url: new URL("https://example.com/"),
|
|
@@ -1727,27 +1706,19 @@ test("InboxContextImpl.forwardActivity()", async (t) => {
|
|
|
1727
1706
|
});
|
|
1728
1707
|
test("KvSpecDeterminer", async (t) => {
|
|
1729
1708
|
await t.step("should use default spec when not found in KV", async () => {
|
|
1730
|
-
|
|
1731
|
-
const spec = await new KvSpecDeterminer(kv, ["test", "spec"]).determineSpec("example.com");
|
|
1732
|
-
assertEquals(spec, "rfc9421");
|
|
1709
|
+
assertEquals(await new KvSpecDeterminer(new MemoryKvStore(), ["test", "spec"]).determineSpec("example.com"), "rfc9421");
|
|
1733
1710
|
});
|
|
1734
1711
|
await t.step("should use custom default spec", async () => {
|
|
1735
|
-
|
|
1736
|
-
const spec = await new KvSpecDeterminer(kv, ["test", "spec"], "draft-cavage-http-signatures-12").determineSpec("example.com");
|
|
1737
|
-
assertEquals(spec, "draft-cavage-http-signatures-12");
|
|
1712
|
+
assertEquals(await new KvSpecDeterminer(new MemoryKvStore(), ["test", "spec"], "draft-cavage-http-signatures-12").determineSpec("example.com"), "draft-cavage-http-signatures-12");
|
|
1738
1713
|
});
|
|
1739
1714
|
await t.step("should remember and retrieve spec from KV", async () => {
|
|
1740
|
-
const
|
|
1741
|
-
const determiner = new KvSpecDeterminer(kv, ["test", "spec"]);
|
|
1715
|
+
const determiner = new KvSpecDeterminer(new MemoryKvStore(), ["test", "spec"]);
|
|
1742
1716
|
await determiner.rememberSpec("example.com", "draft-cavage-http-signatures-12");
|
|
1743
|
-
|
|
1744
|
-
assertEquals(
|
|
1745
|
-
const defaultSpec = await determiner.determineSpec("other.com");
|
|
1746
|
-
assertEquals(defaultSpec, "rfc9421");
|
|
1717
|
+
assertEquals(await determiner.determineSpec("example.com"), "draft-cavage-http-signatures-12");
|
|
1718
|
+
assertEquals(await determiner.determineSpec("other.com"), "rfc9421");
|
|
1747
1719
|
});
|
|
1748
1720
|
await t.step("should override remembered spec", async () => {
|
|
1749
|
-
const
|
|
1750
|
-
const determiner = new KvSpecDeterminer(kv, ["test", "spec"]);
|
|
1721
|
+
const determiner = new KvSpecDeterminer(new MemoryKvStore(), ["test", "spec"]);
|
|
1751
1722
|
await determiner.rememberSpec("example.com", "draft-cavage-http-signatures-12");
|
|
1752
1723
|
let spec = await determiner.determineSpec("example.com");
|
|
1753
1724
|
assertEquals(spec, "draft-cavage-http-signatures-12");
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
+
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
+
import { i as MemoryKvStore, n as KvStore, r as KvStoreSetOptions, t as KvKey } from "../kv-CKqSUxHd.js";
|
|
4
|
+
import { $ as SharedInboxKeyDispatcher, A as Message, B as ActorDispatcher, C as FederationOrigin, D as RetryContext, E as CreateExponentialBackoffPolicyOptions, F as RouterRouteResult, G as CollectionCursor, H as ActorKeyPairsDispatcher, I as RespondWithObjectOptions, J as InboxListener, K as CollectionDispatcher, L as respondWithObject, M as Router, N as RouterError, O as RetryPolicy, P as RouterOptions, Q as OutboxErrorHandler, R as respondWithObjectIfAcceptable, S as FederationKvPrefixes, T as createFederation, U as AuthorizePredicate, V as ActorHandleMapper, W as CollectionCounter, X as ObjectAuthorizePredicate, Y as NodeInfoDispatcher, Z as ObjectDispatcher, _ as FederationOptions, a as InboxContext, b as ObjectCallbackSetters, c as RouteActivityOptions, d as ActorCallbackSetters, et as SenderKeyPair, f as CollectionCallbackSetters, g as FederationFetchOptions, h as FederationBuilder, i as GetSignedKeyOptions, j as createFederationBuilder, k as createExponentialBackoffPolicy, l as SendActivityOptions, m as Federation, n as Context, nt as buildCollectionSynchronizationHeader, o as ParseUriResult, p as Federatable, q as InboxErrorHandler, r as ForwardActivityOptions, rt as digest, s as RequestContext, t as ActorKeyPair, tt as PageItems, u as SendActivityOptionsForCollection, v as FederationStartQueueOptions, w as FederationQueueOptions, x as CreateFederationOptions, y as InboxListenerSetters, z as ActorAliasMapper } from "../context-CW_8R4BH.js";
|
|
5
|
+
import { a as MessageQueueListenOptions, i as MessageQueueEnqueueOptions, n as InProcessMessageQueueOptions, o as ParallelMessageQueue, r as MessageQueue, t as InProcessMessageQueue } from "../mq-Cgfbl44M.js";
|
|
6
|
+
export { ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, Context, CreateExponentialBackoffPolicyOptions, type CreateFederationOptions, Federatable, Federation, FederationBuilder, FederationFetchOptions, type FederationKvPrefixes, FederationOptions, type FederationOrigin, type FederationQueueOptions, FederationStartQueueOptions, ForwardActivityOptions, GetSignedKeyOptions, InProcessMessageQueue, InProcessMessageQueueOptions, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, KvKey, KvStore, KvStoreSetOptions, MemoryKvStore, type Message, MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxErrorHandler, PageItems, ParallelMessageQueue, ParseUriResult, RequestContext, type RespondWithObjectOptions, RetryContext, RetryPolicy, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityOptions, SendActivityOptionsForCollection, type SenderKeyPair, SharedInboxKeyDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable };
|
package/dist/federation/mod.js
CHANGED
|
@@ -2,17 +2,211 @@
|
|
|
2
2
|
import { Temporal } from "@js-temporal/polyfill";
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
|
|
5
|
-
import "../transformers-
|
|
6
|
-
import "../docloader-
|
|
7
|
-
import "../actor-
|
|
8
|
-
import {
|
|
9
|
-
import "../lookup-
|
|
10
|
-
import "../key-
|
|
11
|
-
import "../http-
|
|
12
|
-
import "../proof-
|
|
13
|
-
import
|
|
14
|
-
import "../
|
|
15
|
-
import "../
|
|
16
|
-
import "../vocab-BebR0kAy.js";
|
|
5
|
+
import "../transformers-CFSWUhNi.js";
|
|
6
|
+
import "../docloader-BU25UQLB.js";
|
|
7
|
+
import "../actor-OYVgkiZG.js";
|
|
8
|
+
import { a as createFederation, c as respondWithObjectIfAcceptable, d as createFederationBuilder, f as Router, l as buildCollectionSynchronizationHeader, o as createExponentialBackoffPolicy, p as RouterError, s as respondWithObject, u as digest } from "../middleware-QJjRfjjc.js";
|
|
9
|
+
import "../lookup-4uc2jh52.js";
|
|
10
|
+
import "../key-D2HZrCxh.js";
|
|
11
|
+
import "../http-DRePVWfE.js";
|
|
12
|
+
import "../proof-D4HXHDPz.js";
|
|
13
|
+
import "../types-Bk4b1bGc.js";
|
|
14
|
+
import "../authdocloader-C2krvRo1.js";
|
|
15
|
+
import "../vocab-sMuiKIWm.js";
|
|
17
16
|
|
|
17
|
+
//#region federation/kv.ts
|
|
18
|
+
/**
|
|
19
|
+
* A key–value store that stores values in memory.
|
|
20
|
+
* Do not use this in production as it does not persist values.
|
|
21
|
+
*
|
|
22
|
+
* @since 0.5.0
|
|
23
|
+
*/
|
|
24
|
+
var MemoryKvStore = class {
|
|
25
|
+
#values = {};
|
|
26
|
+
#encodeKey(key) {
|
|
27
|
+
return JSON.stringify(key);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* {@inheritDoc KvStore.get}
|
|
31
|
+
*/
|
|
32
|
+
get(key) {
|
|
33
|
+
const encodedKey = this.#encodeKey(key);
|
|
34
|
+
const entry = this.#values[encodedKey];
|
|
35
|
+
if (entry == null) return Promise.resolve(void 0);
|
|
36
|
+
const [value, expiration] = entry;
|
|
37
|
+
if (expiration != null && Temporal.Now.instant().until(expiration).sign < 0) {
|
|
38
|
+
delete this.#values[encodedKey];
|
|
39
|
+
return Promise.resolve(void 0);
|
|
40
|
+
}
|
|
41
|
+
return Promise.resolve(value);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* {@inheritDoc KvStore.set}
|
|
45
|
+
*/
|
|
46
|
+
set(key, value, options) {
|
|
47
|
+
const encodedKey = this.#encodeKey(key);
|
|
48
|
+
const expiration = options?.ttl == null ? null : Temporal.Now.instant().add(options.ttl.round({ largestUnit: "hour" }));
|
|
49
|
+
this.#values[encodedKey] = [value, expiration];
|
|
50
|
+
return Promise.resolve();
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* {@inheritDoc KvStore.delete}
|
|
54
|
+
*/
|
|
55
|
+
delete(key) {
|
|
56
|
+
const encodedKey = this.#encodeKey(key);
|
|
57
|
+
delete this.#values[encodedKey];
|
|
58
|
+
return Promise.resolve();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region federation/mq.ts
|
|
64
|
+
/**
|
|
65
|
+
* A message queue that processes messages in the same process.
|
|
66
|
+
* Do not use this in production as it does neither persist messages nor
|
|
67
|
+
* distribute them across multiple processes.
|
|
68
|
+
*
|
|
69
|
+
* @since 0.5.0
|
|
70
|
+
*/
|
|
71
|
+
var InProcessMessageQueue = class {
|
|
72
|
+
#messages;
|
|
73
|
+
#monitors;
|
|
74
|
+
#pollIntervalMs;
|
|
75
|
+
/**
|
|
76
|
+
* In-process message queue does not provide native retry mechanisms.
|
|
77
|
+
* @since 1.7.0
|
|
78
|
+
*/
|
|
79
|
+
nativeRetrial = false;
|
|
80
|
+
/**
|
|
81
|
+
* Constructs a new {@link InProcessMessageQueue} with the given options.
|
|
82
|
+
* @param options Additional options for the in-process message queue.
|
|
83
|
+
*/
|
|
84
|
+
constructor(options = {}) {
|
|
85
|
+
this.#messages = [];
|
|
86
|
+
this.#monitors = {};
|
|
87
|
+
this.#pollIntervalMs = Temporal.Duration.from(options.pollInterval ?? { seconds: 5 }).total("millisecond");
|
|
88
|
+
}
|
|
89
|
+
enqueue(message, options) {
|
|
90
|
+
const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
|
|
91
|
+
if (delay > 0) {
|
|
92
|
+
setTimeout(() => this.enqueue(message, {
|
|
93
|
+
...options,
|
|
94
|
+
delay: void 0
|
|
95
|
+
}), delay);
|
|
96
|
+
return Promise.resolve();
|
|
97
|
+
}
|
|
98
|
+
this.#messages.push(message);
|
|
99
|
+
for (const monitorId in this.#monitors) this.#monitors[monitorId]();
|
|
100
|
+
return Promise.resolve();
|
|
101
|
+
}
|
|
102
|
+
enqueueMany(messages, options) {
|
|
103
|
+
if (messages.length === 0) return Promise.resolve();
|
|
104
|
+
const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
|
|
105
|
+
if (delay > 0) {
|
|
106
|
+
setTimeout(() => this.enqueueMany(messages, {
|
|
107
|
+
...options,
|
|
108
|
+
delay: void 0
|
|
109
|
+
}), delay);
|
|
110
|
+
return Promise.resolve();
|
|
111
|
+
}
|
|
112
|
+
this.#messages.push(...messages);
|
|
113
|
+
for (const monitorId in this.#monitors) this.#monitors[monitorId]();
|
|
114
|
+
return Promise.resolve();
|
|
115
|
+
}
|
|
116
|
+
async listen(handler, options = {}) {
|
|
117
|
+
const signal = options.signal;
|
|
118
|
+
while (signal == null || !signal.aborted) {
|
|
119
|
+
while (this.#messages.length > 0) await handler(this.#messages.shift());
|
|
120
|
+
await this.#wait(this.#pollIntervalMs, signal);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
#wait(ms, signal) {
|
|
124
|
+
let timer = null;
|
|
125
|
+
return Promise.any([new Promise((resolve) => {
|
|
126
|
+
signal?.addEventListener("abort", () => {
|
|
127
|
+
if (timer != null) clearTimeout(timer);
|
|
128
|
+
resolve();
|
|
129
|
+
}, { once: true });
|
|
130
|
+
const monitorId = crypto.randomUUID();
|
|
131
|
+
this.#monitors[monitorId] = () => {
|
|
132
|
+
delete this.#monitors[monitorId];
|
|
133
|
+
if (timer != null) clearTimeout(timer);
|
|
134
|
+
resolve();
|
|
135
|
+
};
|
|
136
|
+
}), new Promise((resolve) => timer = setTimeout(resolve, ms))]);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* A message queue that processes messages in parallel. It takes another
|
|
141
|
+
* {@link MessageQueue}, and processes messages in parallel up to a certain
|
|
142
|
+
* number of workers.
|
|
143
|
+
*
|
|
144
|
+
* Actually, it's rather a decorator than a queue itself.
|
|
145
|
+
*
|
|
146
|
+
* Note that the workers do not run in truly parallel, in the sense that they
|
|
147
|
+
* are not running in separate threads or processes. They are running in the
|
|
148
|
+
* same process, but are scheduled to run in parallel. Hence, this is useful
|
|
149
|
+
* for I/O-bound tasks, but not for CPU-bound tasks, which is okay for Fedify's
|
|
150
|
+
* workloads.
|
|
151
|
+
*
|
|
152
|
+
* @since 1.0.0
|
|
153
|
+
*/
|
|
154
|
+
var ParallelMessageQueue = class ParallelMessageQueue {
|
|
155
|
+
queue;
|
|
156
|
+
workers;
|
|
157
|
+
/**
|
|
158
|
+
* Inherits the native retry capability from the wrapped queue.
|
|
159
|
+
* @since 1.7.0
|
|
160
|
+
*/
|
|
161
|
+
nativeRetrial;
|
|
162
|
+
/**
|
|
163
|
+
* Constructs a new {@link ParallelMessageQueue} with the given queue and
|
|
164
|
+
* number of workers.
|
|
165
|
+
* @param queue The message queue to use under the hood. Note that
|
|
166
|
+
* {@link ParallelMessageQueue} cannot be nested.
|
|
167
|
+
* @param workers The number of workers to process messages in parallel.
|
|
168
|
+
* @throws {TypeError} If the given queue is an instance of
|
|
169
|
+
* {@link ParallelMessageQueue}.
|
|
170
|
+
*/
|
|
171
|
+
constructor(queue, workers) {
|
|
172
|
+
if (queue instanceof ParallelMessageQueue) throw new TypeError("Cannot nest ParallelMessageQueue.");
|
|
173
|
+
this.queue = queue;
|
|
174
|
+
this.workers = workers;
|
|
175
|
+
this.nativeRetrial = queue.nativeRetrial;
|
|
176
|
+
}
|
|
177
|
+
enqueue(message, options) {
|
|
178
|
+
return this.queue.enqueue(message, options);
|
|
179
|
+
}
|
|
180
|
+
async enqueueMany(messages, options) {
|
|
181
|
+
if (this.queue.enqueueMany == null) {
|
|
182
|
+
const errors = (await Promise.allSettled(messages.map((message) => this.queue.enqueue(message, options)))).filter((r) => r.status === "rejected").map((r) => r.reason);
|
|
183
|
+
if (errors.length > 1) throw new AggregateError(errors, "Failed to enqueue messages.");
|
|
184
|
+
else if (errors.length === 1) throw errors[0];
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
await this.queue.enqueueMany(messages, options);
|
|
188
|
+
}
|
|
189
|
+
listen(handler, options = {}) {
|
|
190
|
+
const workers = /* @__PURE__ */ new Map();
|
|
191
|
+
return this.queue.listen(async (message) => {
|
|
192
|
+
while (workers.size >= this.workers) {
|
|
193
|
+
const consumedId = await Promise.any(workers.values());
|
|
194
|
+
workers.delete(consumedId);
|
|
195
|
+
}
|
|
196
|
+
const workerId = crypto.randomUUID();
|
|
197
|
+
const promise = this.#work(workerId, handler, message);
|
|
198
|
+
workers.set(workerId, promise);
|
|
199
|
+
}, options);
|
|
200
|
+
}
|
|
201
|
+
async #work(workerId, handler, message) {
|
|
202
|
+
await this.#sleep(0);
|
|
203
|
+
await handler(message);
|
|
204
|
+
return workerId;
|
|
205
|
+
}
|
|
206
|
+
#sleep(ms) {
|
|
207
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
//#endregion
|
|
18
212
|
export { InProcessMessageQueue, MemoryKvStore, ParallelMessageQueue, Router, RouterError, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable };
|
|
@@ -3,15 +3,14 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import "../
|
|
9
|
-
import { test } from "../testing-
|
|
10
|
-
import {
|
|
11
|
-
import { assertFalse } from "../assert_rejects-
|
|
12
|
-
import "../assert_is_error-
|
|
13
|
-
import "../
|
|
14
|
-
import "../assert_throws-YetpVSc-.js";
|
|
6
|
+
import "../chunk-DvTpRkcT.js";
|
|
7
|
+
import { t as assertEquals } from "../assert_equals-Dy0MG_Zw.js";
|
|
8
|
+
import { t as assert } from "../assert-C-mZuSQl.js";
|
|
9
|
+
import { t as test } from "../testing-qaAD4B0t.js";
|
|
10
|
+
import { i as assertGreaterOrEqual, r as assertGreater } from "../std__assert-BdP_WkD-.js";
|
|
11
|
+
import { n as assertFalse } from "../assert_rejects-Bkh5lA1a.js";
|
|
12
|
+
import "../assert_is_error-CIYFACrT.js";
|
|
13
|
+
import "../assert_throws-CmpfkWEM.js";
|
|
15
14
|
import { delay } from "@es-toolkit/es-toolkit";
|
|
16
15
|
|
|
17
16
|
//#region federation/mq.ts
|
|
@@ -70,10 +69,7 @@ var InProcessMessageQueue = class {
|
|
|
70
69
|
async listen(handler, options = {}) {
|
|
71
70
|
const signal = options.signal;
|
|
72
71
|
while (signal == null || !signal.aborted) {
|
|
73
|
-
while (this.#messages.length > 0)
|
|
74
|
-
const message = this.#messages.shift();
|
|
75
|
-
await handler(message);
|
|
76
|
-
}
|
|
72
|
+
while (this.#messages.length > 0) await handler(this.#messages.shift());
|
|
77
73
|
await this.#wait(this.#pollIntervalMs, signal);
|
|
78
74
|
}
|
|
79
75
|
}
|
|
@@ -224,7 +220,7 @@ test("InProcessMessageQueue", async (t) => {
|
|
|
224
220
|
});
|
|
225
221
|
test("MessageQueue.nativeRetrial", async (t) => {
|
|
226
222
|
if ("Deno" in globalThis && "openKv" in globalThis.Deno && typeof globalThis.Deno.openKv === "function") await t.step("DenoKvMessageQueue", async () => {
|
|
227
|
-
const { DenoKvMessageQueue } = await import("../denokv-
|
|
223
|
+
const { DenoKvMessageQueue } = await import("../denokv-NcJeZ6rP.js");
|
|
228
224
|
const mq = new DenoKvMessageQueue(await globalThis.Deno.openKv(":memory:"));
|
|
229
225
|
assert(mq.nativeRetrial);
|
|
230
226
|
if (Symbol.dispose in mq) {
|
|
@@ -257,13 +253,12 @@ test("MessageQueue.nativeRetrial", async (t) => {
|
|
|
257
253
|
throw new TypeError("WorkersMessageQueue does not support listen()");
|
|
258
254
|
}
|
|
259
255
|
}
|
|
260
|
-
|
|
261
|
-
assert(mq.nativeRetrial);
|
|
256
|
+
assert(new TestWorkersMessageQueue(new MockQueue()).nativeRetrial);
|
|
262
257
|
});
|
|
263
258
|
});
|
|
264
259
|
const queues = { InProcessMessageQueue: () => Promise.resolve(new InProcessMessageQueue()) };
|
|
265
260
|
if ("Deno" in globalThis && "openKv" in globalThis.Deno && typeof globalThis.Deno.openKv === "function") {
|
|
266
|
-
const { DenoKvMessageQueue } = await import("../denokv-
|
|
261
|
+
const { DenoKvMessageQueue } = await import("../denokv-NcJeZ6rP.js");
|
|
267
262
|
queues.DenoKvMessageQueue = async () => new DenoKvMessageQueue(await globalThis.Deno.openKv(":memory:"));
|
|
268
263
|
}
|
|
269
264
|
for (const mqName in queues) test({
|