@fedify/fedify 1.9.6 → 1.9.8
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-CEGEmRll.js → actor-BTA45fXF.js} +1205 -2768
- package/dist/{actor-Ydzhc8dj.d.cts → actor-Be-68iJP.d.cts} +3 -3
- package/dist/{actor-C1Euqngb.d.ts → actor-C5AY0Tno.d.ts} +3 -3
- package/dist/{actor-DbpZ6pzg.js → actor-DGa1EWaV.mjs} +8 -15
- package/dist/{actor-DlS-Q8hE.cjs → actor-DxfJk4lY.cjs} +3112 -4674
- package/dist/{assert-MZs1qjMx.js → assert-DikXweDx.mjs} +5 -9
- package/dist/{assert_equals-DSbWqCm3.js → assert_equals-Ew3jOFa3.mjs} +55 -69
- package/dist/{assert_instance_of-DHz7EHNU.js → assert_instance_of-C4Ri6VuN.mjs} +5 -9
- package/dist/{assert_is_error-BPGph1Jx.js → assert_is_error-C50x8tnw.mjs} +5 -9
- package/dist/{assert_not_equals-f3m3epl3.js → assert_not_equals--wG9hV7u.mjs} +6 -13
- package/dist/{assert_rejects-DiIiJbZn.js → assert_rejects-CJC9ThS-.mjs} +6 -11
- package/dist/{assert_throws-BOO88avQ.js → assert_throws-BIL7gChy.mjs} +6 -10
- package/dist/{authdocloader-DUQcOTRS.js → authdocloader-BC2rYCy1.mjs} +9 -14
- package/dist/{authdocloader-CT_V4Z7G.cjs → authdocloader-BrhFB421.cjs} +14 -22
- package/dist/{authdocloader-BLqMyboS.js → authdocloader-CqtNsX_N.js} +8 -15
- package/dist/{builder-BO61xeXE.js → builder-CIkAhIGC.mjs} +31 -40
- package/dist/{client-DF8anIB5.d.ts → client-D8OSiPBT.d.ts} +2 -2
- package/dist/{client-UG5wpNhG.js → client-MXqit6c-.mjs} +11 -15
- package/dist/{client-DjT_tegg.d.cts → client-T0VFOdMw.d.cts} +2 -2
- package/dist/{collection-CSzG2j1P.js → collection-BD6-SZ6O.mjs} +7 -12
- package/dist/compat/mod.cjs +5 -8
- package/dist/compat/mod.d.cts +78 -12
- package/dist/compat/mod.d.ts +78 -12
- package/dist/compat/mod.js +4 -8
- package/dist/compat/transformers.test.mjs +62 -0
- package/dist/{context-CwUAkopp.d.cts → context-CACMqDzl.d.cts} +33 -26
- package/dist/{context-CXUibY4L.d.ts → context-K4cCphQj.d.ts} +33 -26
- package/dist/{denokv-Bv33Xxea.js → denokv-CoSB_Eps.mjs} +22 -11
- package/dist/{docloader-BIFI3OS7.cjs → docloader-BVuUhBLI.cjs} +112 -212
- package/dist/{docloader-fJgJeqiX.js → docloader-BoXhusJ1.js} +17 -151
- package/dist/{docloader-CxWcuWqQ.d.ts → docloader-DSaLRXEA.d.ts} +2 -7
- package/dist/{docloader-D-MrRyHl.d.cts → docloader-DpGRDZrn.d.cts} +2 -7
- package/dist/{esm-C1EfGjSS.js → esm-BHJ7sdNg.mjs} +49 -85
- package/dist/federation/{builder.test.js → builder.test.mjs} +22 -41
- package/dist/federation/collection.test.d.mts +2 -0
- package/dist/federation/collection.test.mjs +21 -0
- package/dist/federation/handler.test.d.mts +2 -0
- package/dist/federation/{handler.test.js → handler.test.mjs} +22 -49
- package/dist/federation/idempotency.test.d.mts +2 -0
- package/dist/federation/{idempotency.test.js → idempotency.test.mjs} +29 -59
- package/dist/federation/inbox.test.d.mts +2 -0
- package/dist/federation/{inbox.test.js → inbox.test.mjs} +10 -15
- package/dist/federation/keycache.test.d.mts +2 -0
- package/dist/federation/{keycache.test.js → keycache.test.mjs} +13 -18
- package/dist/federation/kv.test.d.mts +2 -0
- package/dist/federation/{kv.test.js → kv.test.mjs} +9 -20
- package/dist/federation/middleware.test.d.mts +2 -0
- package/dist/federation/{middleware.test.js → middleware.test.mjs} +182 -197
- package/dist/federation/mod.cjs +223 -21
- package/dist/federation/mod.d.cts +4 -13
- package/dist/federation/mod.d.ts +4 -13
- package/dist/federation/mod.js +218 -18
- package/dist/federation/mq.test.d.mts +2 -0
- package/dist/federation/{mq.test.js → mq.test.mjs} +23 -38
- package/dist/federation/retry.test.d.mts +2 -0
- package/dist/federation/{retry.test.js → retry.test.mjs} +9 -14
- package/dist/federation/router.test.d.mts +2 -0
- package/dist/federation/{router.test.js → router.test.mjs} +12 -19
- package/dist/federation/send.test.d.mts +2 -0
- package/dist/federation/{send.test.js → send.test.mjs} +17 -26
- package/dist/{http-wsGR6KkT.d.ts → http-BZpls--H.d.ts} +5 -9
- package/dist/{http-CR-Eg1Uq.js → http-Bu5ZNlhZ.mjs} +16 -32
- package/dist/{http-B1_DzfAU.d.cts → http-C7WoprmE.d.cts} +5 -9
- package/dist/{http-BgopPF-8.cjs → http-DKw-O_VY.cjs} +51 -68
- package/dist/{http-05HxN-lp.js → http-VJbz6sKD.js} +17 -33
- package/dist/{inbox-DcJN1cxM.js → inbox-DkbTULXE.mjs} +17 -25
- package/dist/key-4fu6v0Jf.mjs +5 -0
- package/dist/{key-DjS1X9TG.cjs → key-B-wFdaPB.cjs} +42 -50
- package/dist/{key-ibMO03_0.js → key-BNMK_IVr.mjs} +12 -18
- package/dist/key-CancShOo.cjs +4 -0
- package/dist/{key-CPJcJjp-.js → key-DK3o0FEH.js} +19 -19
- package/dist/{keycache-CMUfqYqr.js → keycache-D-Vj8z88.mjs} +6 -10
- package/dist/{keys-IZ5050fT.js → keys-B27nVeIs.mjs} +6 -10
- package/dist/{kv-C7sopW2E.d.ts → kv-Bq9QLKm5.d.ts} +1 -1
- package/dist/{kv-CRZrzyXm.js → kv-DM1zFCtL.mjs} +6 -10
- package/dist/{kv-63Cil1MD.d.cts → kv-GIrOktyG.d.cts} +1 -1
- package/dist/{ld-DHNA2RSQ.js → ld-6jAVu3jV.mjs} +17 -31
- package/dist/{lookup-CKZfuyxA.js → lookup-BaU75j-d.js} +5 -11
- package/dist/{lookup-C4_dVYz7.cjs → lookup-BiIPmTwB.cjs} +16 -23
- package/dist/{lookup-BMAWLsP2.js → lookup-DmeJ8WUw.mjs} +8 -17
- package/dist/middleware-9ByEpBvV.cjs +4 -0
- package/dist/{middleware-CGbvIGvy.cjs → middleware-C188G4Go.cjs} +494 -547
- package/dist/{middleware-DrhEvfTo.js → middleware-Db1yZQaT.mjs} +276 -321
- package/dist/{middleware-ODfDRN3q.js → middleware-Do06X21v.js} +349 -393
- package/dist/middleware-DrfZEjyc.mjs +5 -0
- package/dist/{mod-CDObsV1d.d.ts → mod-BSwc3_rD.d.ts} +3 -3
- package/dist/{mod-DBzN0aCM.d.ts → mod-BTNpXcPj.d.ts} +2 -2
- package/dist/{mod-fjqfsrty.d.cts → mod-Chb_NKPp.d.cts} +4 -4
- package/dist/{mod-DgcYoyZK.d.ts → mod-DHoc3toL.d.ts} +4 -4
- package/dist/{mod-jQ4OODsl.d.cts → mod-DIMx6YjJ.d.cts} +2 -2
- package/dist/{mod-BUbqxBev.d.cts → mod-HElaq2UB.d.cts} +3 -3
- package/dist/mod.cjs +31 -33
- package/dist/mod.d.cts +15 -17
- package/dist/mod.d.ts +15 -17
- package/dist/mod.js +20 -23
- package/dist/{mq-B7R1Q-M5.d.cts → mq-CrItclRD.d.cts} +1 -1
- package/dist/{mq-CRGm1e_F.d.ts → mq-D_ZZRdby.d.ts} +1 -1
- package/dist/nodeinfo/client.test.d.mts +2 -0
- package/dist/nodeinfo/{client.test.js → client.test.mjs} +23 -45
- package/dist/nodeinfo/handler.test.d.mts +2 -0
- package/dist/nodeinfo/{handler.test.js → handler.test.mjs} +14 -43
- package/dist/nodeinfo/mod.cjs +5 -9
- package/dist/nodeinfo/mod.d.cts +2 -5
- package/dist/nodeinfo/mod.d.ts +2 -5
- package/dist/nodeinfo/mod.js +4 -9
- package/dist/nodeinfo/semver.test.d.mts +2 -0
- package/dist/nodeinfo/{semver.test.js → semver.test.mjs} +28 -51
- package/dist/nodeinfo/types.test.d.mts +2 -0
- package/dist/nodeinfo/{types.test.js → types.test.mjs} +10 -21
- package/dist/{owner-DDHsHYQO.js → owner-CKuGt_T9.mjs} +10 -13
- package/dist/{owner-BbeUDvOu.d.ts → owner-DPAPnB0R.d.ts} +4 -4
- package/dist/{owner-6KSEp9eV.d.cts → owner-_rFs0ik_.d.cts} +4 -4
- package/dist/{proof-V1uQaB2y.js → proof-CmTtG_t-.js} +33 -57
- package/dist/{proof-CX7ujFFX.cjs → proof-DLOy7HYU.cjs} +112 -135
- package/dist/{proof-exgGRW88.js → proof-mJLL2gSA.mjs} +20 -32
- package/dist/{retry-D4GJ670a.js → retry-Ddbq3AcK.mjs} +4 -7
- package/dist/rolldown-runtime-C7fyD9f2.js +15 -0
- package/dist/runtime/authdocloader.test.d.mts +2 -0
- package/dist/runtime/{authdocloader.test.js → authdocloader.test.mjs} +16 -28
- package/dist/runtime/docloader.test.d.mts +2 -0
- package/dist/runtime/{docloader.test.js → docloader.test.mjs} +52 -72
- package/dist/runtime/key.test.d.mts +2 -0
- package/dist/runtime/{key.test.js → key.test.mjs} +27 -57
- package/dist/runtime/langstr.test.d.mts +2 -0
- package/dist/runtime/{langstr.test.js → langstr.test.mjs} +9 -19
- package/dist/runtime/link.test.d.mts +2 -0
- package/dist/runtime/{link.test.js → link.test.mjs} +7 -11
- package/dist/runtime/mod.cjs +7 -13
- package/dist/runtime/mod.d.cts +103 -6
- package/dist/runtime/mod.d.ts +103 -6
- package/dist/runtime/mod.js +6 -13
- package/dist/runtime/multibase/multibase.test.d.mts +2 -0
- package/dist/runtime/multibase/{multibase.test.js → multibase.test.mjs} +16 -33
- package/dist/runtime/url.test.d.mts +2 -0
- package/dist/runtime/{url.test.js → url.test.mjs} +10 -15
- package/dist/{semver-dArNLkR9.js → semver-CgD82xxg.mjs} +13 -28
- package/dist/{send-BfMYakUE.js → send-BsQbGuw4.mjs} +7 -12
- package/dist/sig/http.test.d.mts +2 -0
- package/dist/sig/{http.test.js → http.test.mjs} +119 -203
- package/dist/sig/key.test.d.mts +2 -0
- package/dist/sig/{key.test.js → key.test.mjs} +13 -22
- package/dist/sig/ld.test.d.mts +2 -0
- package/dist/sig/{ld.test.js → ld.test.mjs} +24 -39
- package/dist/sig/mod.cjs +7 -13
- package/dist/sig/mod.d.cts +3 -7
- package/dist/sig/mod.d.ts +3 -7
- package/dist/sig/mod.js +6 -13
- package/dist/sig/owner.test.d.mts +2 -0
- package/dist/sig/owner.test.mjs +39 -0
- package/dist/sig/proof.test.d.mts +2 -0
- package/dist/sig/{proof.test.js → proof.test.mjs} +18 -31
- package/dist/{std__assert-X-_kMxKM.js → std__assert-2v7gYiZp.mjs} +13 -24
- package/dist/testing/docloader.test.d.mts +2 -0
- package/dist/testing/docloader.test.mjs +12 -0
- package/dist/testing/{mod.d.ts → mod.d.mts} +371 -541
- package/dist/testing/mod.mjs +5 -0
- package/dist/{testing-RPOc_gVG.js → testing-DS3gcq8V.mjs} +27 -35
- package/dist/{transformers-CoBS-oFG.cjs → transformers-BM0M8hnW.cjs} +20 -25
- package/dist/{transformers-BFT6d7J5.js → transformers-BV4OeK9o.js} +3 -7
- package/dist/{types-Cptev2nt.js → types-BXfL-dsX.js} +18 -36
- package/dist/{types-BIgY6c-l.js → types-CAnkAQGM.mjs} +5 -9
- package/dist/{types-CGnM1vft.cjs → types-DpM4FhjW.cjs} +45 -64
- package/dist/vocab/actor.test.d.mts +2 -0
- package/dist/vocab/{actor.test.js → actor.test.mjs} +308 -550
- package/dist/vocab/cjs.test.d.mts +2 -0
- package/dist/vocab/cjs.test.mjs +14 -0
- package/dist/vocab/lookup.test.d.mts +2 -0
- package/dist/vocab/{lookup.test.js → lookup.test.mjs} +29 -45
- package/dist/vocab/mod.cjs +251 -16
- package/dist/vocab/mod.d.cts +3 -5
- package/dist/vocab/mod.d.ts +3 -5
- package/dist/vocab/mod.js +244 -10
- package/dist/vocab/type.test.d.mts +2 -0
- package/dist/vocab/type.test.mjs +16 -0
- package/dist/vocab/vocab.test.d.mts +2 -0
- package/dist/vocab/{vocab.test.js → vocab.test.mjs} +178 -311
- package/dist/{vocab-CDHNj5zp.d.ts → vocab-BLvSEtuz.d.cts} +2 -4
- package/dist/{type-COPv6pMi.js → vocab-DuW9rL1h.mjs} +1177 -2871
- package/dist/{vocab-Cfs0937i.d.cts → vocab-lhCS9lzq.d.ts} +4 -2
- package/dist/webfinger/handler.test.d.mts +2 -0
- package/dist/webfinger/{handler.test.js → handler.test.mjs} +23 -56
- package/dist/webfinger/lookup.test.d.mts +2 -0
- package/dist/webfinger/{lookup.test.js → lookup.test.mjs} +13 -27
- package/dist/webfinger/mod.cjs +5 -9
- package/dist/webfinger/mod.d.cts +1 -3
- package/dist/webfinger/mod.d.ts +1 -3
- package/dist/webfinger/mod.js +4 -9
- package/dist/x/cfworkers.cjs +25 -14
- package/dist/x/cfworkers.d.cts +33 -6
- package/dist/x/cfworkers.d.ts +33 -6
- package/dist/x/cfworkers.js +22 -12
- package/dist/x/cfworkers.test.d.mts +2 -0
- package/dist/x/{cfworkers.test.js → cfworkers.test.mjs} +28 -26
- package/dist/x/hono.cjs +25 -14
- package/dist/x/hono.d.cts +1 -11
- package/dist/x/hono.d.ts +1 -11
- package/dist/x/hono.js +22 -12
- package/dist/x/sveltekit.cjs +23 -12
- package/dist/x/sveltekit.d.cts +1 -11
- package/dist/x/sveltekit.d.ts +1 -11
- package/dist/x/sveltekit.js +20 -10
- package/package.json +2 -2
- package/dist/chunk-DqRYRqnO.cjs +0 -34
- package/dist/compat/transformers.test.d.ts +0 -3
- package/dist/compat/transformers.test.js +0 -86
- package/dist/compat-DmDDELst.cjs +0 -4
- package/dist/compat-nxUqe4Z-.js +0 -4
- package/dist/federation/builder.test.d.ts +0 -3
- package/dist/federation/collection.test.d.ts +0 -3
- package/dist/federation/collection.test.js +0 -35
- package/dist/federation/handler.test.d.ts +0 -3
- package/dist/federation/idempotency.test.d.ts +0 -3
- package/dist/federation/inbox.test.d.ts +0 -3
- package/dist/federation/keycache.test.d.ts +0 -3
- package/dist/federation/kv.test.d.ts +0 -3
- package/dist/federation/middleware.test.d.ts +0 -3
- package/dist/federation/mq.test.d.ts +0 -3
- package/dist/federation/retry.test.d.ts +0 -3
- package/dist/federation/router.test.d.ts +0 -3
- package/dist/federation/send.test.d.ts +0 -3
- package/dist/federation-D1U8YY9t.js +0 -226
- package/dist/federation-H2_En3j5.cjs +0 -244
- package/dist/key-BCUd8FWp.js +0 -10
- package/dist/key-BUardnTH.cjs +0 -10
- package/dist/key-Dr6H_e3K.js +0 -10
- package/dist/middleware-BJ83veqi.js +0 -26
- package/dist/middleware-CJ4W2ir5.cjs +0 -17
- package/dist/middleware-Ve2mHJgo.js +0 -17
- package/dist/mod-BcObK1Lz.d.ts +0 -82
- package/dist/mod-C2tOeRkN.d.cts +0 -1
- package/dist/mod-CIbqfZW0.d.ts +0 -104
- package/dist/mod-Dt-G9ZOS.d.cts +0 -102
- package/dist/mod-FZd39qVq.d.cts +0 -1
- package/dist/mod-mXx9V0q5.d.cts +0 -80
- package/dist/nodeinfo/client.test.d.ts +0 -3
- package/dist/nodeinfo/handler.test.d.ts +0 -3
- package/dist/nodeinfo/semver.test.d.ts +0 -3
- package/dist/nodeinfo/types.test.d.ts +0 -3
- package/dist/nodeinfo-Co9lJrWl.cjs +0 -4
- package/dist/nodeinfo-DfycQ8Wf.js +0 -4
- package/dist/runtime/authdocloader.test.d.ts +0 -3
- package/dist/runtime/docloader.test.d.ts +0 -3
- package/dist/runtime/key.test.d.ts +0 -3
- package/dist/runtime/langstr.test.d.ts +0 -3
- package/dist/runtime/link.test.d.ts +0 -3
- package/dist/runtime/multibase/multibase.test.d.ts +0 -3
- package/dist/runtime/url.test.d.ts +0 -3
- package/dist/runtime-C58AJWSv.cjs +0 -4
- package/dist/runtime-DPYEDf-o.js +0 -4
- package/dist/sig/http.test.d.ts +0 -3
- package/dist/sig/key.test.d.ts +0 -3
- package/dist/sig/ld.test.d.ts +0 -3
- package/dist/sig/owner.test.d.ts +0 -3
- package/dist/sig/owner.test.js +0 -52
- package/dist/sig/proof.test.d.ts +0 -3
- package/dist/sig-ByHXzqUi.cjs +0 -4
- package/dist/sig-Cj3tk-ig.js +0 -4
- package/dist/testing/docloader.test.d.ts +0 -3
- package/dist/testing/docloader.test.js +0 -24
- package/dist/testing/mod.js +0 -10
- package/dist/vocab/actor.test.d.ts +0 -3
- package/dist/vocab/lookup.test.d.ts +0 -3
- 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-BFy1CS5L.cjs +0 -289
- package/dist/vocab-BPFiQ650.js +0 -253
- package/dist/webfinger/handler.test.d.ts +0 -3
- package/dist/webfinger/lookup.test.d.ts +0 -3
- package/dist/webfinger-BjOEdFPs.cjs +0 -4
- package/dist/webfinger-De_bU0iE.js +0 -4
- package/dist/x/cfworkers.test.d.ts +0 -3
- /package/dist/{mod-1pDWKvUL.d.ts → compat/transformers.test.d.mts} +0 -0
- /package/dist/{mod-g0xFzAP9.d.ts → federation/builder.test.d.mts} +0 -0
|
@@ -1,29 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 { extractInboxes, sendActivity } from "./send-BfMYakUE.js";
|
|
1
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
globalThis.addEventListener = () => {};
|
|
4
|
+
import { J as getDocumentLoader, U as getTypeId, W as lookupWebFinger, Z as kvCache, a as CollectionPage, b as OrderedCollection, g as Multikey, h as Link, i as Collection, ot as name, s as CryptographicKey, st as version, t as Activity, v as Object$1, x as OrderedCollectionPage } from "./vocab-DuW9rL1h.mjs";
|
|
5
|
+
import { i as RouterError, n as traverseCollection, t as lookupObject } from "./lookup-DmeJ8WUw.mjs";
|
|
6
|
+
import { t as getNodeInfo } from "./client-MXqit6c-.mjs";
|
|
7
|
+
import { t as nodeInfoToJson } from "./types-CAnkAQGM.mjs";
|
|
8
|
+
import "./actor-DGa1EWaV.mjs";
|
|
9
|
+
import { a as validateCryptoKey, i as importJwk, t as exportJwk } from "./key-BNMK_IVr.mjs";
|
|
10
|
+
import { l as verifyRequest } from "./http-Bu5ZNlhZ.mjs";
|
|
11
|
+
import { t as getAuthenticatedDocumentLoader } from "./authdocloader-BC2rYCy1.mjs";
|
|
12
|
+
import { a as signJsonLd, i as hasSignature, o as verifyJsonLd, r as detachSignature } from "./ld-6jAVu3jV.mjs";
|
|
13
|
+
import { n as getKeyOwner, t as doesActorOwnKey } from "./owner-CKuGt_T9.mjs";
|
|
14
|
+
import { n as signObject, r as verifyObject } from "./proof-mJLL2gSA.mjs";
|
|
15
|
+
import { n as routeActivity } from "./inbox-DkbTULXE.mjs";
|
|
16
|
+
import { t as FederationBuilderImpl } from "./builder-CIkAhIGC.mjs";
|
|
17
|
+
import { t as buildCollectionSynchronizationHeader } from "./collection-BD6-SZ6O.mjs";
|
|
18
|
+
import { t as KvKeyCache } from "./keycache-D-Vj8z88.mjs";
|
|
19
|
+
import { t as createExponentialBackoffPolicy } from "./retry-Ddbq3AcK.mjs";
|
|
20
|
+
import { n as sendActivity, t as extractInboxes } from "./send-BsQbGuw4.mjs";
|
|
22
21
|
import { getLogger, withContext } from "@logtape/logtape";
|
|
23
22
|
import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
|
|
24
23
|
import { ATTR_HTTP_REQUEST_HEADER, ATTR_HTTP_REQUEST_METHOD, ATTR_HTTP_RESPONSE_HEADER, ATTR_HTTP_RESPONSE_STATUS_CODE, ATTR_URL_FULL } from "@opentelemetry/semantic-conventions";
|
|
25
24
|
import { domainToASCII } from "node:url";
|
|
26
|
-
|
|
27
25
|
//#region src/compat/transformers.ts
|
|
28
26
|
const logger$1 = getLogger([
|
|
29
27
|
"fedify",
|
|
@@ -48,9 +46,9 @@ const logger$1 = getLogger([
|
|
|
48
46
|
* @return The activity with an ID assigned.
|
|
49
47
|
* @since 1.4.0
|
|
50
48
|
*/
|
|
51
|
-
function autoIdAssigner(activity, context
|
|
49
|
+
function autoIdAssigner(activity, context) {
|
|
52
50
|
if (activity.id != null) return activity;
|
|
53
|
-
const id = new URL(`/#${activity.constructor.name}/${crypto.randomUUID()}`, context
|
|
51
|
+
const id = new URL(`/#${activity.constructor.name}/${crypto.randomUUID()}`, context.origin);
|
|
54
52
|
logger$1.warn("As the activity to send does not have an id, a new id {id} has been generated for it. However, it is recommended to explicitly set the id for the activity.", { id: id.href });
|
|
55
53
|
return activity.clone({ id });
|
|
56
54
|
}
|
|
@@ -113,7 +111,6 @@ function actorDehydrator(activity, _context) {
|
|
|
113
111
|
function getDefaultActivityTransformers() {
|
|
114
112
|
return [autoIdAssigner, actorDehydrator];
|
|
115
113
|
}
|
|
116
|
-
|
|
117
114
|
//#endregion
|
|
118
115
|
//#region src/nodeinfo/handler.ts
|
|
119
116
|
/**
|
|
@@ -123,10 +120,9 @@ function getDefaultActivityTransformers() {
|
|
|
123
120
|
* @param parameters The parameters for handling the request.
|
|
124
121
|
* @returns The response to the request.
|
|
125
122
|
*/
|
|
126
|
-
async function handleNodeInfo(_request, { context
|
|
127
|
-
const promise = nodeInfoDispatcher(context
|
|
128
|
-
const
|
|
129
|
-
const json = nodeInfoToJson(nodeInfo);
|
|
123
|
+
async function handleNodeInfo(_request, { context, nodeInfoDispatcher }) {
|
|
124
|
+
const promise = nodeInfoDispatcher(context);
|
|
125
|
+
const json = nodeInfoToJson(promise instanceof Promise ? await promise : promise);
|
|
130
126
|
return new Response(JSON.stringify(json), { headers: { "Content-Type": "application/json; profile=\"http://nodeinfo.diaspora.software/ns/schema/2.1#\"" } });
|
|
131
127
|
}
|
|
132
128
|
/**
|
|
@@ -136,34 +132,21 @@ async function handleNodeInfo(_request, { context: context$1, nodeInfoDispatcher
|
|
|
136
132
|
* @param context The request context.
|
|
137
133
|
* @returns The response to the request.
|
|
138
134
|
*/
|
|
139
|
-
function handleNodeInfoJrd(_request, context
|
|
135
|
+
function handleNodeInfoJrd(_request, context) {
|
|
140
136
|
const links = [];
|
|
141
137
|
try {
|
|
142
138
|
links.push({
|
|
143
139
|
rel: "http://nodeinfo.diaspora.software/ns/schema/2.1",
|
|
144
|
-
href: context
|
|
140
|
+
href: context.getNodeInfoUri().href,
|
|
145
141
|
type: "application/json; profile=\"http://nodeinfo.diaspora.software/ns/schema/2.1#\""
|
|
146
142
|
});
|
|
147
143
|
} catch (e) {
|
|
148
144
|
if (!(e instanceof RouterError)) throw e;
|
|
149
145
|
}
|
|
150
|
-
const
|
|
151
|
-
const response = new Response(JSON.stringify(jrd), { headers: { "Content-Type": "application/jrd+json" } });
|
|
146
|
+
const response = new Response(JSON.stringify({ links }), { headers: { "Content-Type": "application/jrd+json" } });
|
|
152
147
|
return Promise.resolve(response);
|
|
153
148
|
}
|
|
154
|
-
|
|
155
|
-
//#endregion
|
|
156
|
-
//#region src/vocab/constants.ts
|
|
157
|
-
/**
|
|
158
|
-
* The special public collection for [public addressing]. *Do not mutate this
|
|
159
|
-
* object.*
|
|
160
|
-
*
|
|
161
|
-
* [public addressing]: https://www.w3.org/TR/activitypub/#public-addressing
|
|
162
|
-
*
|
|
163
|
-
* @since 0.7.0
|
|
164
|
-
*/
|
|
165
|
-
const PUBLIC_COLLECTION = new URL("https://www.w3.org/ns/activitystreams#Public");
|
|
166
|
-
|
|
149
|
+
new URL("https://www.w3.org/ns/activitystreams#Public");
|
|
167
150
|
//#endregion
|
|
168
151
|
//#region src/webfinger/handler.ts
|
|
169
152
|
const logger = getLogger([
|
|
@@ -196,12 +179,12 @@ async function handleWebFinger(request, options) {
|
|
|
196
179
|
}
|
|
197
180
|
});
|
|
198
181
|
}
|
|
199
|
-
async function handleWebFingerInternal(request, { context
|
|
182
|
+
async function handleWebFingerInternal(request, { context, host, actorDispatcher, actorHandleMapper, actorAliasMapper, onNotFound, span, webFingerLinksDispatcher }) {
|
|
200
183
|
if (actorDispatcher == null) {
|
|
201
184
|
logger.error("Actor dispatcher is not set.");
|
|
202
185
|
return await onNotFound(request);
|
|
203
186
|
}
|
|
204
|
-
const resource = context
|
|
187
|
+
const resource = context.url.searchParams.get("resource");
|
|
205
188
|
if (resource == null) return new Response("Missing resource parameter.", { status: 400 });
|
|
206
189
|
span?.setAttribute("webfinger.resource", resource);
|
|
207
190
|
let resourceUrl;
|
|
@@ -217,26 +200,26 @@ async function handleWebFingerInternal(request, { context: context$1, host, acto
|
|
|
217
200
|
logger.error("No actor handle mapper is set; use the WebFinger username {username} as the actor's internal identifier.", { username });
|
|
218
201
|
return username;
|
|
219
202
|
}
|
|
220
|
-
const identifier
|
|
221
|
-
if (identifier
|
|
203
|
+
const identifier = await actorHandleMapper(context, username);
|
|
204
|
+
if (identifier == null) {
|
|
222
205
|
logger.error("Actor {username} not found.", { username });
|
|
223
206
|
return null;
|
|
224
207
|
}
|
|
225
|
-
return identifier
|
|
208
|
+
return identifier;
|
|
226
209
|
}
|
|
227
210
|
let identifier = null;
|
|
228
|
-
const uriParsed = context
|
|
211
|
+
const uriParsed = context.parseUri(resourceUrl);
|
|
229
212
|
if (uriParsed?.type != "actor") {
|
|
230
213
|
const match = /^acct:([^@]+)@([^@]+)$/.exec(resource);
|
|
231
214
|
if (match == null) {
|
|
232
|
-
const result = await actorAliasMapper?.(context
|
|
215
|
+
const result = await actorAliasMapper?.(context, resourceUrl);
|
|
233
216
|
if (result == null) return await onNotFound(request);
|
|
234
217
|
if ("identifier" in result) identifier = result.identifier;
|
|
235
218
|
else identifier = await mapUsernameToIdentifier(result.username);
|
|
236
219
|
} else {
|
|
237
220
|
const portMatch = /:\d+$/.exec(match[2]);
|
|
238
221
|
const normalizedHost = portMatch == null ? domainToASCII(match[2].toLowerCase()) : domainToASCII(match[2].substring(0, portMatch.index).toLowerCase()) + portMatch[0];
|
|
239
|
-
if (normalizedHost != context
|
|
222
|
+
if (normalizedHost != context.url.host && normalizedHost != host) return await onNotFound(request);
|
|
240
223
|
else {
|
|
241
224
|
identifier = await mapUsernameToIdentifier(match[1]);
|
|
242
225
|
resourceUrl = new URL(`acct:${match[1]}@${normalizedHost}`);
|
|
@@ -244,14 +227,14 @@ async function handleWebFingerInternal(request, { context: context$1, host, acto
|
|
|
244
227
|
}
|
|
245
228
|
} else identifier = uriParsed.identifier;
|
|
246
229
|
if (identifier == null) return await onNotFound(request);
|
|
247
|
-
const actor = await actorDispatcher(context
|
|
230
|
+
const actor = await actorDispatcher(context, identifier);
|
|
248
231
|
if (actor == null) {
|
|
249
232
|
logger.error("Actor {identifier} not found.", { identifier });
|
|
250
233
|
return await onNotFound(request);
|
|
251
234
|
}
|
|
252
235
|
const links = [{
|
|
253
236
|
rel: "self",
|
|
254
|
-
href: context
|
|
237
|
+
href: context.getActorUri(identifier).href,
|
|
255
238
|
type: "application/activity+json"
|
|
256
239
|
}];
|
|
257
240
|
for (const url of actor.urls) if (url instanceof Link && url.href != null) links.push({
|
|
@@ -273,16 +256,16 @@ async function handleWebFingerInternal(request, { context: context$1, host, acto
|
|
|
273
256
|
links.push(link);
|
|
274
257
|
}
|
|
275
258
|
if (webFingerLinksDispatcher != null) {
|
|
276
|
-
const customLinks = await webFingerLinksDispatcher(context
|
|
259
|
+
const customLinks = await webFingerLinksDispatcher(context, resourceUrl);
|
|
277
260
|
if (customLinks != null) for (const link of customLinks) links.push(link);
|
|
278
261
|
}
|
|
279
262
|
const aliases = [];
|
|
280
263
|
if (resourceUrl.protocol != "acct:" && actor.preferredUsername != null) {
|
|
281
|
-
aliases.push(`acct:${actor.preferredUsername}@${host ?? context
|
|
282
|
-
if (host != null && host !== context
|
|
264
|
+
aliases.push(`acct:${actor.preferredUsername}@${host ?? context.url.host}`);
|
|
265
|
+
if (host != null && host !== context.url.host) aliases.push(`acct:${actor.preferredUsername}@${context.url.host}`);
|
|
283
266
|
}
|
|
284
|
-
if (resourceUrl.href !== context
|
|
285
|
-
if (resourceUrl.protocol === "acct:" && host != null && host !== context
|
|
267
|
+
if (resourceUrl.href !== context.getActorUri(identifier).href) aliases.push(context.getActorUri(identifier).href);
|
|
268
|
+
if (resourceUrl.protocol === "acct:" && host != null && host !== context.url.host && !resourceUrl.href.endsWith(`@${host}`)) {
|
|
286
269
|
const username = resourceUrl.href.replace(/^acct:/, "").replace(/@.*$/, "");
|
|
287
270
|
aliases.push(`acct:${username}@${host}`);
|
|
288
271
|
}
|
|
@@ -296,7 +279,6 @@ async function handleWebFingerInternal(request, { context: context$1, host, acto
|
|
|
296
279
|
"Access-Control-Allow-Origin": "*"
|
|
297
280
|
} });
|
|
298
281
|
}
|
|
299
|
-
|
|
300
282
|
//#endregion
|
|
301
283
|
//#region src/federation/negotiation.ts
|
|
302
284
|
function compareSpecs(a, b) {
|
|
@@ -341,8 +323,8 @@ function parseMediaType(str, i) {
|
|
|
341
323
|
function parseAccept(accept) {
|
|
342
324
|
const accepts = accept.split(",").map((p) => p.trim());
|
|
343
325
|
const mediaTypes = [];
|
|
344
|
-
for (const [index, accept
|
|
345
|
-
const mediaType = parseMediaType(accept
|
|
326
|
+
for (const [index, accept] of accepts.entries()) {
|
|
327
|
+
const mediaType = parseMediaType(accept.trim(), index);
|
|
346
328
|
if (mediaType) mediaTypes.push(mediaType);
|
|
347
329
|
}
|
|
348
330
|
return mediaTypes;
|
|
@@ -351,10 +333,8 @@ function getFullType(spec) {
|
|
|
351
333
|
return `${spec.type}/${spec.subtype}`;
|
|
352
334
|
}
|
|
353
335
|
function preferredMediaTypes(accept) {
|
|
354
|
-
|
|
355
|
-
return accepts.filter(isQuality).sort(compareSpecs).map(getFullType);
|
|
336
|
+
return parseAccept(accept === void 0 ? "*/*" : accept ?? "").filter(isQuality).sort(compareSpecs).map(getFullType);
|
|
356
337
|
}
|
|
357
|
-
|
|
358
338
|
//#endregion
|
|
359
339
|
//#region src/federation/handler.ts
|
|
360
340
|
function acceptsJsonLd(request) {
|
|
@@ -371,24 +351,24 @@ function acceptsJsonLd(request) {
|
|
|
371
351
|
* @param parameters The parameters for handling the actor.
|
|
372
352
|
* @returns A promise that resolves to an HTTP response.
|
|
373
353
|
*/
|
|
374
|
-
async function handleActor(request, { identifier, context
|
|
375
|
-
const logger
|
|
354
|
+
async function handleActor(request, { identifier, context, actorDispatcher, authorizePredicate, onNotFound, onNotAcceptable, onUnauthorized }) {
|
|
355
|
+
const logger = getLogger([
|
|
376
356
|
"fedify",
|
|
377
357
|
"federation",
|
|
378
358
|
"actor"
|
|
379
359
|
]);
|
|
380
360
|
if (actorDispatcher == null) {
|
|
381
|
-
logger
|
|
361
|
+
logger.debug("Actor dispatcher is not set.", { identifier });
|
|
382
362
|
return await onNotFound(request);
|
|
383
363
|
}
|
|
384
|
-
const actor = await actorDispatcher(context
|
|
364
|
+
const actor = await actorDispatcher(context, identifier);
|
|
385
365
|
if (actor == null) {
|
|
386
|
-
logger
|
|
366
|
+
logger.debug("Actor {identifier} not found.", { identifier });
|
|
387
367
|
return await onNotFound(request);
|
|
388
368
|
}
|
|
389
369
|
if (!acceptsJsonLd(request)) return await onNotAcceptable(request);
|
|
390
370
|
if (authorizePredicate != null) {
|
|
391
|
-
let key = await context
|
|
371
|
+
let key = await context.getSignedKey();
|
|
392
372
|
key = key?.clone({}, { $warning: {
|
|
393
373
|
category: [
|
|
394
374
|
"fedify",
|
|
@@ -397,7 +377,7 @@ async function handleActor(request, { identifier, context: context$1, actorDispa
|
|
|
397
377
|
],
|
|
398
378
|
message: "The third parameter of AuthorizePredicate is deprecated in favor of RequestContext.getSignedKey() method. The third parameter will be removed in a future release."
|
|
399
379
|
} }) ?? null;
|
|
400
|
-
let keyOwner = await context
|
|
380
|
+
let keyOwner = await context.getSignedKeyOwner();
|
|
401
381
|
keyOwner = keyOwner?.clone({}, { $warning: {
|
|
402
382
|
category: [
|
|
403
383
|
"fedify",
|
|
@@ -406,9 +386,9 @@ async function handleActor(request, { identifier, context: context$1, actorDispa
|
|
|
406
386
|
],
|
|
407
387
|
message: "The fourth parameter of AuthorizePredicate is deprecated in favor of RequestContext.getSignedKeyOwner() method. The fourth parameter will be removed in a future release."
|
|
408
388
|
} }) ?? null;
|
|
409
|
-
if (!await authorizePredicate(context
|
|
389
|
+
if (!await authorizePredicate(context, identifier, key, keyOwner)) return await onUnauthorized(request);
|
|
410
390
|
}
|
|
411
|
-
const jsonLd = await actor.toJsonLd(context
|
|
391
|
+
const jsonLd = await actor.toJsonLd(context);
|
|
412
392
|
return new Response(JSON.stringify(jsonLd), { headers: {
|
|
413
393
|
"Content-Type": "application/activity+json",
|
|
414
394
|
Vary: "Accept"
|
|
@@ -421,13 +401,13 @@ async function handleActor(request, { identifier, context: context$1, actorDispa
|
|
|
421
401
|
* @param parameters The parameters for handling the object.
|
|
422
402
|
* @returns A promise that resolves to an HTTP response.
|
|
423
403
|
*/
|
|
424
|
-
async function handleObject(request, { values, context
|
|
404
|
+
async function handleObject(request, { values, context, objectDispatcher, authorizePredicate, onNotFound, onNotAcceptable, onUnauthorized }) {
|
|
425
405
|
if (objectDispatcher == null) return await onNotFound(request);
|
|
426
|
-
const object = await objectDispatcher(context
|
|
406
|
+
const object = await objectDispatcher(context, values);
|
|
427
407
|
if (object == null) return await onNotFound(request);
|
|
428
408
|
if (!acceptsJsonLd(request)) return await onNotAcceptable(request);
|
|
429
409
|
if (authorizePredicate != null) {
|
|
430
|
-
let key = await context
|
|
410
|
+
let key = await context.getSignedKey();
|
|
431
411
|
key = key?.clone({}, { $warning: {
|
|
432
412
|
category: [
|
|
433
413
|
"fedify",
|
|
@@ -436,7 +416,7 @@ async function handleObject(request, { values, context: context$1, objectDispatc
|
|
|
436
416
|
],
|
|
437
417
|
message: "The third parameter of ObjectAuthorizePredicate is deprecated in favor of RequestContext.getSignedKey() method. The third parameter will be removed in a future release."
|
|
438
418
|
} }) ?? null;
|
|
439
|
-
let keyOwner = await context
|
|
419
|
+
let keyOwner = await context.getSignedKeyOwner();
|
|
440
420
|
keyOwner = keyOwner?.clone({}, { $warning: {
|
|
441
421
|
category: [
|
|
442
422
|
"fedify",
|
|
@@ -445,9 +425,9 @@ async function handleObject(request, { values, context: context$1, objectDispatc
|
|
|
445
425
|
],
|
|
446
426
|
message: "The fourth parameter of ObjectAuthorizePredicate is deprecated in favor of RequestContext.getSignedKeyOwner() method. The fourth parameter will be removed in a future release."
|
|
447
427
|
} }) ?? null;
|
|
448
|
-
if (!await authorizePredicate(context
|
|
428
|
+
if (!await authorizePredicate(context, values, key, keyOwner)) return await onUnauthorized(request);
|
|
449
429
|
}
|
|
450
|
-
const jsonLd = await object.toJsonLd(context
|
|
430
|
+
const jsonLd = await object.toJsonLd(context);
|
|
451
431
|
return new Response(JSON.stringify(jsonLd), { headers: {
|
|
452
432
|
"Content-Type": "application/activity+json",
|
|
453
433
|
Vary: "Accept"
|
|
@@ -463,18 +443,17 @@ async function handleObject(request, { values, context: context$1, objectDispatc
|
|
|
463
443
|
* @param parameters The parameters for handling the collection.
|
|
464
444
|
* @returns A promise that resolves to an HTTP response.
|
|
465
445
|
*/
|
|
466
|
-
async function handleCollection(request, { name, identifier, uriGetter, filter, filterPredicate, context
|
|
467
|
-
const spanName = name.trim().replace(/\s+/g, "_");
|
|
446
|
+
async function handleCollection(request, { name: name$2, identifier, uriGetter, filter, filterPredicate, context, collectionCallbacks, tracerProvider, onUnauthorized, onNotFound, onNotAcceptable }) {
|
|
447
|
+
const spanName = name$2.trim().replace(/\s+/g, "_");
|
|
468
448
|
tracerProvider = tracerProvider ?? trace.getTracerProvider();
|
|
469
|
-
const tracer = tracerProvider.getTracer(
|
|
470
|
-
const
|
|
471
|
-
const cursor = url.searchParams.get("cursor");
|
|
449
|
+
const tracer = tracerProvider.getTracer(name, version);
|
|
450
|
+
const cursor = new URL(request.url).searchParams.get("cursor");
|
|
472
451
|
if (collectionCallbacks == null) return await onNotFound(request);
|
|
473
452
|
let collection;
|
|
474
453
|
const baseUri = uriGetter(identifier);
|
|
475
454
|
if (cursor == null) {
|
|
476
|
-
const firstCursor = await collectionCallbacks.firstCursor?.(context
|
|
477
|
-
const totalItems = filter == null ? await collectionCallbacks.counter?.(context
|
|
455
|
+
const firstCursor = await collectionCallbacks.firstCursor?.(context, identifier);
|
|
456
|
+
const totalItems = filter == null ? await collectionCallbacks.counter?.(context, identifier) : void 0;
|
|
478
457
|
if (firstCursor == null) {
|
|
479
458
|
const itemsOrResponse = await tracer.startActiveSpan(`activitypub.dispatch_collection ${spanName}`, {
|
|
480
459
|
kind: SpanKind.SERVER,
|
|
@@ -485,7 +464,7 @@ async function handleCollection(request, { name, identifier, uriGetter, filter,
|
|
|
485
464
|
}, async (span) => {
|
|
486
465
|
if (totalItems != null) span.setAttribute("activitypub.collection.total_items", Number(totalItems));
|
|
487
466
|
try {
|
|
488
|
-
const page = await collectionCallbacks.dispatcher(context
|
|
467
|
+
const page = await collectionCallbacks.dispatcher(context, identifier, null, filter);
|
|
489
468
|
if (page == null) {
|
|
490
469
|
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
491
470
|
return await onNotFound(request);
|
|
@@ -507,15 +486,15 @@ async function handleCollection(request, { name, identifier, uriGetter, filter,
|
|
|
507
486
|
collection = new OrderedCollection({
|
|
508
487
|
id: baseUri,
|
|
509
488
|
totalItems: totalItems == null ? null : Number(totalItems),
|
|
510
|
-
items: filterCollectionItems(itemsOrResponse, name, filterPredicate)
|
|
489
|
+
items: filterCollectionItems(itemsOrResponse, name$2, filterPredicate)
|
|
511
490
|
});
|
|
512
491
|
} else {
|
|
513
|
-
const lastCursor = await collectionCallbacks.lastCursor?.(context
|
|
514
|
-
const first = new URL(context
|
|
492
|
+
const lastCursor = await collectionCallbacks.lastCursor?.(context, identifier);
|
|
493
|
+
const first = new URL(context.url);
|
|
515
494
|
first.searchParams.set("cursor", firstCursor);
|
|
516
495
|
let last = null;
|
|
517
496
|
if (lastCursor != null) {
|
|
518
|
-
last = new URL(context
|
|
497
|
+
last = new URL(context.url);
|
|
519
498
|
last.searchParams.set("cursor", lastCursor);
|
|
520
499
|
}
|
|
521
500
|
collection = new OrderedCollection({
|
|
@@ -528,7 +507,7 @@ async function handleCollection(request, { name, identifier, uriGetter, filter,
|
|
|
528
507
|
} else {
|
|
529
508
|
const uri = new URL(baseUri);
|
|
530
509
|
uri.searchParams.set("cursor", cursor);
|
|
531
|
-
const pageOrResponse = await tracer.startActiveSpan(`activitypub.dispatch_collection_page ${name}`, {
|
|
510
|
+
const pageOrResponse = await tracer.startActiveSpan(`activitypub.dispatch_collection_page ${name$2}`, {
|
|
532
511
|
kind: SpanKind.SERVER,
|
|
533
512
|
attributes: {
|
|
534
513
|
"activitypub.collection.id": uri.href,
|
|
@@ -537,7 +516,7 @@ async function handleCollection(request, { name, identifier, uriGetter, filter,
|
|
|
537
516
|
}
|
|
538
517
|
}, async (span) => {
|
|
539
518
|
try {
|
|
540
|
-
const page = await collectionCallbacks.dispatcher(context
|
|
519
|
+
const page = await collectionCallbacks.dispatcher(context, identifier, cursor, filter);
|
|
541
520
|
if (page == null) {
|
|
542
521
|
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
543
522
|
return await onNotFound(request);
|
|
@@ -558,27 +537,27 @@ async function handleCollection(request, { name, identifier, uriGetter, filter,
|
|
|
558
537
|
const { items, prevCursor, nextCursor } = pageOrResponse;
|
|
559
538
|
let prev = null;
|
|
560
539
|
if (prevCursor != null) {
|
|
561
|
-
prev = new URL(context
|
|
540
|
+
prev = new URL(context.url);
|
|
562
541
|
prev.searchParams.set("cursor", prevCursor);
|
|
563
542
|
}
|
|
564
543
|
let next = null;
|
|
565
544
|
if (nextCursor != null) {
|
|
566
|
-
next = new URL(context
|
|
545
|
+
next = new URL(context.url);
|
|
567
546
|
next.searchParams.set("cursor", nextCursor);
|
|
568
547
|
}
|
|
569
|
-
const partOf = new URL(context
|
|
548
|
+
const partOf = new URL(context.url);
|
|
570
549
|
partOf.searchParams.delete("cursor");
|
|
571
550
|
collection = new OrderedCollectionPage({
|
|
572
551
|
id: uri,
|
|
573
552
|
prev,
|
|
574
553
|
next,
|
|
575
|
-
items: filterCollectionItems(items, name, filterPredicate),
|
|
554
|
+
items: filterCollectionItems(items, name$2, filterPredicate),
|
|
576
555
|
partOf
|
|
577
556
|
});
|
|
578
557
|
}
|
|
579
558
|
if (!acceptsJsonLd(request)) return await onNotAcceptable(request);
|
|
580
559
|
if (collectionCallbacks.authorizePredicate != null) {
|
|
581
|
-
let key = await context
|
|
560
|
+
let key = await context.getSignedKey();
|
|
582
561
|
key = key?.clone({}, { $warning: {
|
|
583
562
|
category: [
|
|
584
563
|
"fedify",
|
|
@@ -587,7 +566,7 @@ async function handleCollection(request, { name, identifier, uriGetter, filter,
|
|
|
587
566
|
],
|
|
588
567
|
message: "The third parameter of AuthorizePredicate is deprecated in favor of RequestContext.getSignedKey() method. The third parameter will be removed in a future release."
|
|
589
568
|
} }) ?? null;
|
|
590
|
-
let keyOwner = await context
|
|
569
|
+
let keyOwner = await context.getSignedKeyOwner();
|
|
591
570
|
keyOwner = keyOwner?.clone({}, { $warning: {
|
|
592
571
|
category: [
|
|
593
572
|
"fedify",
|
|
@@ -596,9 +575,9 @@ async function handleCollection(request, { name, identifier, uriGetter, filter,
|
|
|
596
575
|
],
|
|
597
576
|
message: "The fourth parameter of AuthorizePredicate is deprecated in favor of RequestContext.getSignedKeyOwner() method. The fourth parameter will be removed in a future release."
|
|
598
577
|
} }) ?? null;
|
|
599
|
-
if (!await collectionCallbacks.authorizePredicate(context
|
|
578
|
+
if (!await collectionCallbacks.authorizePredicate(context, identifier, key, keyOwner)) return await onUnauthorized(request);
|
|
600
579
|
}
|
|
601
|
-
const jsonLd = await collection.toJsonLd(context
|
|
580
|
+
const jsonLd = await collection.toJsonLd(context);
|
|
602
581
|
return new Response(JSON.stringify(jsonLd), { headers: {
|
|
603
582
|
"Content-Type": "application/activity+json",
|
|
604
583
|
Vary: "Accept"
|
|
@@ -643,9 +622,7 @@ function filterCollectionItems(items, collectionName, filterPredicate) {
|
|
|
643
622
|
* @returns A promise that resolves to an HTTP response.
|
|
644
623
|
*/
|
|
645
624
|
async function handleInbox(request, options) {
|
|
646
|
-
|
|
647
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
648
|
-
return await tracer.startActiveSpan("activitypub.inbox", {
|
|
625
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("activitypub.inbox", {
|
|
649
626
|
kind: options.queue == null ? SpanKind.SERVER : SpanKind.PRODUCER,
|
|
650
627
|
attributes: { "activitypub.shared_inbox": options.recipient == null }
|
|
651
628
|
}, async (span) => {
|
|
@@ -673,22 +650,21 @@ async function handleInbox(request, options) {
|
|
|
673
650
|
*/
|
|
674
651
|
async function handleInboxInternal(request, parameters, span) {
|
|
675
652
|
const { recipient, context: ctx, inboxContextFactory, kv, kvPrefixes, queue, actorDispatcher, inboxListeners, inboxErrorHandler, onNotFound, signatureTimeWindow, skipSignatureVerification, tracerProvider } = parameters;
|
|
676
|
-
const logger
|
|
653
|
+
const logger = getLogger([
|
|
677
654
|
"fedify",
|
|
678
655
|
"federation",
|
|
679
656
|
"inbox"
|
|
680
657
|
]);
|
|
681
658
|
if (actorDispatcher == null) {
|
|
682
|
-
logger
|
|
659
|
+
logger.error("Actor dispatcher is not set.", { recipient });
|
|
683
660
|
span.setStatus({
|
|
684
661
|
code: SpanStatusCode.ERROR,
|
|
685
662
|
message: "Actor dispatcher is not set."
|
|
686
663
|
});
|
|
687
664
|
return await onNotFound(request);
|
|
688
665
|
} else if (recipient != null) {
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
logger$2.error("Actor {recipient} not found.", { recipient });
|
|
666
|
+
if (await actorDispatcher(ctx, recipient) == null) {
|
|
667
|
+
logger.error("Actor {recipient} not found.", { recipient });
|
|
692
668
|
span.setStatus({
|
|
693
669
|
code: SpanStatusCode.ERROR,
|
|
694
670
|
message: `Actor ${recipient} not found.`
|
|
@@ -697,7 +673,7 @@ async function handleInboxInternal(request, parameters, span) {
|
|
|
697
673
|
}
|
|
698
674
|
}
|
|
699
675
|
if (request.bodyUsed) {
|
|
700
|
-
logger
|
|
676
|
+
logger.error("Request body has already been read.", { recipient });
|
|
701
677
|
span.setStatus({
|
|
702
678
|
code: SpanStatusCode.ERROR,
|
|
703
679
|
message: "Request body has already been read."
|
|
@@ -707,7 +683,7 @@ async function handleInboxInternal(request, parameters, span) {
|
|
|
707
683
|
headers: { "Content-Type": "text/plain; charset=utf-8" }
|
|
708
684
|
});
|
|
709
685
|
} else if (request.body?.locked) {
|
|
710
|
-
logger
|
|
686
|
+
logger.error("Request body is locked.", { recipient });
|
|
711
687
|
span.setStatus({
|
|
712
688
|
code: SpanStatusCode.ERROR,
|
|
713
689
|
message: "Request body is locked."
|
|
@@ -721,15 +697,15 @@ async function handleInboxInternal(request, parameters, span) {
|
|
|
721
697
|
try {
|
|
722
698
|
json = await request.clone().json();
|
|
723
699
|
} catch (error) {
|
|
724
|
-
logger
|
|
700
|
+
logger.error("Failed to parse JSON:\n{error}", {
|
|
725
701
|
recipient,
|
|
726
702
|
error
|
|
727
703
|
});
|
|
728
704
|
try {
|
|
729
705
|
await inboxErrorHandler?.(ctx, error);
|
|
730
|
-
} catch (error
|
|
731
|
-
logger
|
|
732
|
-
error
|
|
706
|
+
} catch (error) {
|
|
707
|
+
logger.error("An unexpected error occurred in inbox error handler:\n{error}", {
|
|
708
|
+
error,
|
|
733
709
|
activity: json,
|
|
734
710
|
recipient
|
|
735
711
|
});
|
|
@@ -754,7 +730,7 @@ async function handleInboxInternal(request, parameters, span) {
|
|
|
754
730
|
});
|
|
755
731
|
} catch (error) {
|
|
756
732
|
if (error instanceof Error && error.name === "jsonld.SyntaxError") {
|
|
757
|
-
logger
|
|
733
|
+
logger.error("Failed to parse JSON-LD:\n{error}", {
|
|
758
734
|
recipient,
|
|
759
735
|
error
|
|
760
736
|
});
|
|
@@ -768,13 +744,13 @@ async function handleInboxInternal(request, parameters, span) {
|
|
|
768
744
|
const jsonWithoutSig = detachSignature(json);
|
|
769
745
|
let activity = null;
|
|
770
746
|
if (ldSigVerified) {
|
|
771
|
-
logger
|
|
747
|
+
logger.debug("Linked Data Signatures are verified.", {
|
|
772
748
|
recipient,
|
|
773
749
|
json
|
|
774
750
|
});
|
|
775
751
|
activity = await Activity.fromJsonLd(jsonWithoutSig, ctx);
|
|
776
752
|
} else {
|
|
777
|
-
logger
|
|
753
|
+
logger.debug("Linked Data Signatures are not verified.", {
|
|
778
754
|
recipient,
|
|
779
755
|
json
|
|
780
756
|
});
|
|
@@ -786,16 +762,16 @@ async function handleInboxInternal(request, parameters, span) {
|
|
|
786
762
|
tracerProvider
|
|
787
763
|
});
|
|
788
764
|
} catch (error) {
|
|
789
|
-
logger
|
|
765
|
+
logger.error("Failed to parse activity:\n{error}", {
|
|
790
766
|
recipient,
|
|
791
767
|
activity: json,
|
|
792
768
|
error
|
|
793
769
|
});
|
|
794
770
|
try {
|
|
795
771
|
await inboxErrorHandler?.(ctx, error);
|
|
796
|
-
} catch (error
|
|
797
|
-
logger
|
|
798
|
-
error
|
|
772
|
+
} catch (error) {
|
|
773
|
+
logger.error("An unexpected error occurred in inbox error handler:\n{error}", {
|
|
774
|
+
error,
|
|
799
775
|
activity: json,
|
|
800
776
|
recipient
|
|
801
777
|
});
|
|
@@ -809,11 +785,11 @@ async function handleInboxInternal(request, parameters, span) {
|
|
|
809
785
|
headers: { "Content-Type": "text/plain; charset=utf-8" }
|
|
810
786
|
});
|
|
811
787
|
}
|
|
812
|
-
if (activity == null) logger
|
|
788
|
+
if (activity == null) logger.debug("Object Integrity Proofs are not verified.", {
|
|
813
789
|
recipient,
|
|
814
790
|
activity: json
|
|
815
791
|
});
|
|
816
|
-
else logger
|
|
792
|
+
else logger.debug("Object Integrity Proofs are verified.", {
|
|
817
793
|
recipient,
|
|
818
794
|
activity: json
|
|
819
795
|
});
|
|
@@ -829,17 +805,16 @@ async function handleInboxInternal(request, parameters, span) {
|
|
|
829
805
|
tracerProvider
|
|
830
806
|
});
|
|
831
807
|
if (key == null) {
|
|
832
|
-
logger
|
|
808
|
+
logger.error("Failed to verify the request's HTTP Signatures.", { recipient });
|
|
833
809
|
span.setStatus({
|
|
834
810
|
code: SpanStatusCode.ERROR,
|
|
835
811
|
message: `Failed to verify the request's HTTP Signatures.`
|
|
836
812
|
});
|
|
837
|
-
|
|
813
|
+
return new Response("Failed to verify the request signature.", {
|
|
838
814
|
status: 401,
|
|
839
815
|
headers: { "Content-Type": "text/plain; charset=utf-8" }
|
|
840
816
|
});
|
|
841
|
-
|
|
842
|
-
} else logger$2.debug("HTTP Signatures are verified.", { recipient });
|
|
817
|
+
} else logger.debug("HTTP Signatures are verified.", { recipient });
|
|
843
818
|
httpSigKey = key;
|
|
844
819
|
}
|
|
845
820
|
activity = await Activity.fromJsonLd(jsonWithoutSig, ctx);
|
|
@@ -847,7 +822,7 @@ async function handleInboxInternal(request, parameters, span) {
|
|
|
847
822
|
if (activity.id != null) span.setAttribute("activitypub.activity.id", activity.id.href);
|
|
848
823
|
span.setAttribute("activitypub.activity.type", getTypeId(activity).href);
|
|
849
824
|
if (httpSigKey != null && !await doesActorOwnKey(activity, httpSigKey, ctx)) {
|
|
850
|
-
logger
|
|
825
|
+
logger.error("The signer ({keyId}) and the actor ({actorId}) do not match.", {
|
|
851
826
|
activity: json,
|
|
852
827
|
recipient,
|
|
853
828
|
keyId: httpSigKey.id?.href,
|
|
@@ -914,12 +889,12 @@ async function handleInboxInternal(request, parameters, span) {
|
|
|
914
889
|
* @since 1.8.0
|
|
915
890
|
*/
|
|
916
891
|
const handleCustomCollection = exceptWrapper(_handleCustomCollection);
|
|
917
|
-
async function _handleCustomCollection(request, { name, values, context
|
|
892
|
+
async function _handleCustomCollection(request, { name, values, context, tracerProvider, collectionCallbacks: callbacks, filterPredicate }) {
|
|
918
893
|
verifyDefined(callbacks);
|
|
919
894
|
verifyJsonLdRequest(request);
|
|
920
|
-
await authIfNeeded(context
|
|
895
|
+
await authIfNeeded(context, values, callbacks);
|
|
921
896
|
const cursor = new URL(request.url).searchParams.get("cursor");
|
|
922
|
-
return await new CustomCollectionHandler(name, values, context
|
|
897
|
+
return await new CustomCollectionHandler(name, values, context, callbacks, tracerProvider, Collection, CollectionPage, filterPredicate).fetchCollection(cursor).toJsonLd().then(respondAsActivity);
|
|
923
898
|
}
|
|
924
899
|
/**
|
|
925
900
|
* Handles an ordered collection request.
|
|
@@ -933,12 +908,12 @@ async function _handleCustomCollection(request, { name, values, context: context
|
|
|
933
908
|
* @since 1.8.0
|
|
934
909
|
*/
|
|
935
910
|
const handleOrderedCollection = exceptWrapper(_handleOrderedCollection);
|
|
936
|
-
async function _handleOrderedCollection(request, { name, values, context
|
|
911
|
+
async function _handleOrderedCollection(request, { name, values, context, tracerProvider, collectionCallbacks: callbacks, filterPredicate }) {
|
|
937
912
|
verifyDefined(callbacks);
|
|
938
913
|
verifyJsonLdRequest(request);
|
|
939
|
-
await authIfNeeded(context
|
|
914
|
+
await authIfNeeded(context, values, callbacks);
|
|
940
915
|
const cursor = new URL(request.url).searchParams.get("cursor");
|
|
941
|
-
return await new CustomCollectionHandler(name, values, context
|
|
916
|
+
return await new CustomCollectionHandler(name, values, context, callbacks, tracerProvider, OrderedCollection, OrderedCollectionPage, filterPredicate).fetchCollection(cursor).toJsonLd().then(respondAsActivity);
|
|
942
917
|
}
|
|
943
918
|
/**
|
|
944
919
|
* Handling custom collections with support for pagination and filtering.
|
|
@@ -988,17 +963,17 @@ var CustomCollectionHandler = class {
|
|
|
988
963
|
* @param CollectionPage The CollectionPage constructor.
|
|
989
964
|
* @param filterPredicate Optional filter predicate for items.
|
|
990
965
|
*/
|
|
991
|
-
constructor(name, values, context
|
|
992
|
-
this.name = name;
|
|
966
|
+
constructor(name$1, values, context, callbacks, tracerProvider = trace.getTracerProvider(), Collection, CollectionPage, filterPredicate) {
|
|
967
|
+
this.name = name$1;
|
|
993
968
|
this.values = values;
|
|
994
|
-
this.context = context
|
|
969
|
+
this.context = context;
|
|
995
970
|
this.callbacks = callbacks;
|
|
996
971
|
this.tracerProvider = tracerProvider;
|
|
997
|
-
this.Collection = Collection
|
|
998
|
-
this.CollectionPage = CollectionPage
|
|
972
|
+
this.Collection = Collection;
|
|
973
|
+
this.CollectionPage = CollectionPage;
|
|
999
974
|
this.filterPredicate = filterPredicate;
|
|
1000
975
|
this.name = this.name.trim().replace(/\s+/g, "_");
|
|
1001
|
-
this.#tracer = this.tracerProvider.getTracer(
|
|
976
|
+
this.#tracer = this.tracerProvider.getTracer(name, version);
|
|
1002
977
|
this.#id = new URL(this.context.url);
|
|
1003
978
|
this.#dispatcher = callbacks.dispatcher.bind(callbacks);
|
|
1004
979
|
}
|
|
@@ -1027,8 +1002,8 @@ var CustomCollectionHandler = class {
|
|
|
1027
1002
|
*/
|
|
1028
1003
|
async getCollection(cursor = null) {
|
|
1029
1004
|
if (cursor !== null) {
|
|
1030
|
-
const props
|
|
1031
|
-
return new this.CollectionPage(props
|
|
1005
|
+
const props = await this.getPageProps(cursor);
|
|
1006
|
+
return new this.CollectionPage(props);
|
|
1032
1007
|
}
|
|
1033
1008
|
const firstCursor = await this.firstCursor;
|
|
1034
1009
|
const props = typeof firstCursor === "string" ? await this.getProps(firstCursor) : await this.getPropsWithoutCursor();
|
|
@@ -1176,7 +1151,7 @@ var CustomCollectionHandler = class {
|
|
|
1176
1151
|
* @param value The total items count or a promise that resolves to it.
|
|
1177
1152
|
*/
|
|
1178
1153
|
set totalItems(value) {
|
|
1179
|
-
const toNumber = (value
|
|
1154
|
+
const toNumber = (value) => value == null ? null : Number(value);
|
|
1180
1155
|
this.#totalItems = value instanceof Promise ? value.then(toNumber) : Promise.resolve(toNumber(value));
|
|
1181
1156
|
}
|
|
1182
1157
|
/**
|
|
@@ -1250,11 +1225,9 @@ const verifyJsonLdRequest = (request) => {
|
|
|
1250
1225
|
* @throws {UnauthorizedError} If authorization fails.
|
|
1251
1226
|
* @since 1.8.0
|
|
1252
1227
|
*/
|
|
1253
|
-
const authIfNeeded = async (context
|
|
1228
|
+
const authIfNeeded = async (context, values, { authorizePredicate: authorize = void 0 }) => {
|
|
1254
1229
|
if (authorize === void 0) return;
|
|
1255
|
-
|
|
1256
|
-
const keyOwner = (await context$1.getSignedKeyOwner())?.clone({}, warning.keyOwner) ?? null;
|
|
1257
|
-
if (!await authorize(context$1, values, key, keyOwner)) throw new UnauthorizedError();
|
|
1230
|
+
if (!await authorize(context, values, (await context.getSignedKey())?.clone({}, warning.key) ?? null, (await context.getSignedKeyOwner())?.clone({}, warning.keyOwner) ?? null)) throw new UnauthorizedError();
|
|
1258
1231
|
};
|
|
1259
1232
|
/** Warning messages for `authIfNeeded`. */
|
|
1260
1233
|
const warning = {
|
|
@@ -1368,7 +1341,6 @@ async function respondWithObjectIfAcceptable(object, request, options) {
|
|
|
1368
1341
|
response.headers.set("Vary", "Accept");
|
|
1369
1342
|
return response;
|
|
1370
1343
|
}
|
|
1371
|
-
|
|
1372
1344
|
//#endregion
|
|
1373
1345
|
//#region src/federation/middleware.ts
|
|
1374
1346
|
/**
|
|
@@ -1406,7 +1378,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1406
1378
|
firstKnock;
|
|
1407
1379
|
constructor(options) {
|
|
1408
1380
|
super();
|
|
1409
|
-
const logger
|
|
1381
|
+
const logger = getLogger(["fedify", "federation"]);
|
|
1410
1382
|
this.kv = options.kv;
|
|
1411
1383
|
this.kvPrefixes = {
|
|
1412
1384
|
activityIdempotence: ["_fedify", "activityIdempotence"],
|
|
@@ -1463,7 +1435,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1463
1435
|
if (options.documentLoader != null) {
|
|
1464
1436
|
if (options.documentLoaderFactory != null) throw new TypeError("Cannot set both documentLoader and documentLoaderFactory options at a time; use documentLoaderFactory only.");
|
|
1465
1437
|
this.documentLoaderFactory = () => options.documentLoader;
|
|
1466
|
-
logger
|
|
1438
|
+
logger.warn("The documentLoader option is deprecated; use documentLoaderFactory option instead.");
|
|
1467
1439
|
} else this.documentLoaderFactory = options.documentLoaderFactory ?? ((opts) => {
|
|
1468
1440
|
return kvCache({
|
|
1469
1441
|
loader: getDocumentLoader({
|
|
@@ -1477,7 +1449,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1477
1449
|
if (options.contextLoader != null) {
|
|
1478
1450
|
if (options.contextLoaderFactory != null) throw new TypeError("Cannot set both contextLoader and contextLoaderFactory options at a time; use contextLoaderFactory only.");
|
|
1479
1451
|
this.contextLoaderFactory = () => options.contextLoader;
|
|
1480
|
-
logger
|
|
1452
|
+
logger.warn("The contextLoader option is deprecated; use contextLoaderFactory option instead.");
|
|
1481
1453
|
} else this.contextLoaderFactory = options.contextLoaderFactory ?? this.documentLoaderFactory;
|
|
1482
1454
|
this.authenticatedDocumentLoaderFactory = options.authenticatedDocumentLoaderFactory ?? ((identity) => getAuthenticatedDocumentLoader(identity, {
|
|
1483
1455
|
allowPrivateAddress,
|
|
@@ -1500,28 +1472,28 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1500
1472
|
this.router.add("/.well-known/nodeinfo", "nodeInfoJrd");
|
|
1501
1473
|
}
|
|
1502
1474
|
_getTracer() {
|
|
1503
|
-
return this.tracerProvider.getTracer(
|
|
1475
|
+
return this.tracerProvider.getTracer(name, version);
|
|
1504
1476
|
}
|
|
1505
1477
|
async _startQueueInternal(ctxData, signal, queue) {
|
|
1506
1478
|
if (this.inboxQueue == null && this.outboxQueue == null) return;
|
|
1507
|
-
const logger
|
|
1479
|
+
const logger = getLogger([
|
|
1508
1480
|
"fedify",
|
|
1509
1481
|
"federation",
|
|
1510
1482
|
"queue"
|
|
1511
1483
|
]);
|
|
1512
1484
|
const promises = [];
|
|
1513
1485
|
if (this.inboxQueue != null && (queue == null || queue === "inbox") && !this.inboxQueueStarted) {
|
|
1514
|
-
logger
|
|
1486
|
+
logger.debug("Starting an inbox task worker.");
|
|
1515
1487
|
this.inboxQueueStarted = true;
|
|
1516
1488
|
promises.push(this.inboxQueue.listen((msg) => this.processQueuedTask(ctxData, msg), { signal }));
|
|
1517
1489
|
}
|
|
1518
1490
|
if (this.outboxQueue != null && this.outboxQueue !== this.inboxQueue && (queue == null || queue === "outbox") && !this.outboxQueueStarted) {
|
|
1519
|
-
logger
|
|
1491
|
+
logger.debug("Starting an outbox task worker.");
|
|
1520
1492
|
this.outboxQueueStarted = true;
|
|
1521
1493
|
promises.push(this.outboxQueue.listen((msg) => this.processQueuedTask(ctxData, msg), { signal }));
|
|
1522
1494
|
}
|
|
1523
1495
|
if (this.fanoutQueue != null && this.fanoutQueue !== this.inboxQueue && this.fanoutQueue !== this.outboxQueue && (queue == null || queue === "fanout") && !this.fanoutQueueStarted) {
|
|
1524
|
-
logger
|
|
1496
|
+
logger.debug("Starting a fanout task worker.");
|
|
1525
1497
|
this.fanoutQueueStarted = true;
|
|
1526
1498
|
promises.push(this.fanoutQueue.listen((msg) => this.processQueuedTask(ctxData, msg), { signal }));
|
|
1527
1499
|
}
|
|
@@ -1587,12 +1559,11 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1587
1559
|
});
|
|
1588
1560
|
}
|
|
1589
1561
|
async #listenFanoutMessage(data, message) {
|
|
1590
|
-
|
|
1562
|
+
getLogger([
|
|
1591
1563
|
"fedify",
|
|
1592
1564
|
"federation",
|
|
1593
1565
|
"fanout"
|
|
1594
|
-
])
|
|
1595
|
-
logger$2.debug("Fanning out activity {activityId} to {inboxes} inbox(es)...", {
|
|
1566
|
+
]).debug("Fanning out activity {activityId} to {inboxes} inbox(es)...", {
|
|
1596
1567
|
activityId: message.activityId,
|
|
1597
1568
|
inboxes: globalThis.Object.keys(message.inboxes).length
|
|
1598
1569
|
});
|
|
@@ -1611,17 +1582,17 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1611
1582
|
}),
|
|
1612
1583
|
tracerProvider: this.tracerProvider
|
|
1613
1584
|
});
|
|
1614
|
-
const context
|
|
1585
|
+
const context = this.#createContext(new URL(message.baseUrl), data, { documentLoader: this.documentLoaderFactory({
|
|
1615
1586
|
allowPrivateAddress: this.allowPrivateAddress,
|
|
1616
1587
|
userAgent: this.userAgent
|
|
1617
1588
|
}) });
|
|
1618
1589
|
await this.sendActivity(keys, message.inboxes, activity, {
|
|
1619
1590
|
collectionSync: message.collectionSync,
|
|
1620
|
-
context
|
|
1591
|
+
context
|
|
1621
1592
|
});
|
|
1622
1593
|
}
|
|
1623
1594
|
async #listenOutboxMessage(_, message, span) {
|
|
1624
|
-
const logger
|
|
1595
|
+
const logger = getLogger([
|
|
1625
1596
|
"fedify",
|
|
1626
1597
|
"federation",
|
|
1627
1598
|
"outbox"
|
|
@@ -1669,14 +1640,14 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1669
1640
|
});
|
|
1670
1641
|
try {
|
|
1671
1642
|
this.onOutboxError?.(error, activity);
|
|
1672
|
-
} catch (error
|
|
1673
|
-
logger
|
|
1643
|
+
} catch (error) {
|
|
1644
|
+
logger.error("An unexpected error occurred in onError handler:\n{error}", {
|
|
1674
1645
|
...logData,
|
|
1675
|
-
error
|
|
1646
|
+
error
|
|
1676
1647
|
});
|
|
1677
1648
|
}
|
|
1678
1649
|
if (this.outboxQueue?.nativeRetrial) {
|
|
1679
|
-
logger
|
|
1650
|
+
logger.error("Failed to send activity {activityId} to {inbox}; backend will handle retry:\n{error}", {
|
|
1680
1651
|
...logData,
|
|
1681
1652
|
error
|
|
1682
1653
|
});
|
|
@@ -1687,7 +1658,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1687
1658
|
attempts: message.attempt
|
|
1688
1659
|
});
|
|
1689
1660
|
if (delay != null) {
|
|
1690
|
-
logger
|
|
1661
|
+
logger.error("Failed to send activity {activityId} to {inbox} (attempt #{attempt}); retry...:\n{error}", {
|
|
1691
1662
|
...logData,
|
|
1692
1663
|
error
|
|
1693
1664
|
});
|
|
@@ -1695,39 +1666,38 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1695
1666
|
...message,
|
|
1696
1667
|
attempt: message.attempt + 1
|
|
1697
1668
|
}, { delay: Temporal.Duration.compare(delay, { seconds: 0 }) < 0 ? Temporal.Duration.from({ seconds: 0 }) : delay });
|
|
1698
|
-
} else logger
|
|
1669
|
+
} else logger.error("Failed to send activity {activityId} to {inbox} after {attempt} attempts; giving up:\n{error}", {
|
|
1699
1670
|
...logData,
|
|
1700
1671
|
error
|
|
1701
1672
|
});
|
|
1702
1673
|
return;
|
|
1703
1674
|
}
|
|
1704
|
-
logger
|
|
1675
|
+
logger.info("Successfully sent activity {activityId} to {inbox}.", { ...logData });
|
|
1705
1676
|
}
|
|
1706
1677
|
async #listenInboxMessage(ctxData, message, span) {
|
|
1707
|
-
const logger
|
|
1678
|
+
const logger = getLogger([
|
|
1708
1679
|
"fedify",
|
|
1709
1680
|
"federation",
|
|
1710
1681
|
"inbox"
|
|
1711
1682
|
]);
|
|
1712
1683
|
const baseUrl = new URL(message.baseUrl);
|
|
1713
|
-
let context
|
|
1714
|
-
if (message.identifier != null) context
|
|
1684
|
+
let context = this.#createContext(baseUrl, ctxData);
|
|
1685
|
+
if (message.identifier != null) context = this.#createContext(baseUrl, ctxData, { documentLoader: await context.getDocumentLoader({ identifier: message.identifier }) });
|
|
1715
1686
|
else if (this.sharedInboxKeyDispatcher != null) {
|
|
1716
|
-
const identity = await this.sharedInboxKeyDispatcher(context
|
|
1717
|
-
if (identity != null) context
|
|
1687
|
+
const identity = await this.sharedInboxKeyDispatcher(context);
|
|
1688
|
+
if (identity != null) context = this.#createContext(baseUrl, ctxData, { documentLoader: "identifier" in identity || "username" in identity || "handle" in identity ? await context.getDocumentLoader(identity) : context.getDocumentLoader(identity) });
|
|
1718
1689
|
}
|
|
1719
|
-
const activity = await Activity.fromJsonLd(message.activity, context
|
|
1690
|
+
const activity = await Activity.fromJsonLd(message.activity, context);
|
|
1720
1691
|
span.setAttribute("activitypub.activity.type", getTypeId(activity).href);
|
|
1721
1692
|
if (activity.id != null) span.setAttribute("activitypub.activity.id", activity.id.href);
|
|
1722
1693
|
const cacheKey = activity.id == null ? null : [
|
|
1723
1694
|
...this.kvPrefixes.activityIdempotence,
|
|
1724
|
-
context
|
|
1695
|
+
context.origin,
|
|
1725
1696
|
activity.id.href
|
|
1726
1697
|
];
|
|
1727
1698
|
if (cacheKey != null) {
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
logger$2.debug("Activity {activityId} has already been processed.", {
|
|
1699
|
+
if (await this.kv.get(cacheKey) === true) {
|
|
1700
|
+
logger.debug("Activity {activityId} has already been processed.", {
|
|
1731
1701
|
activityId: activity.id?.href,
|
|
1732
1702
|
activity: message.activity,
|
|
1733
1703
|
recipient: message.identifier
|
|
@@ -1735,32 +1705,32 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1735
1705
|
return;
|
|
1736
1706
|
}
|
|
1737
1707
|
}
|
|
1738
|
-
await this._getTracer().startActiveSpan("activitypub.dispatch_inbox_listener", { kind: SpanKind.INTERNAL }, async (span
|
|
1708
|
+
await this._getTracer().startActiveSpan("activitypub.dispatch_inbox_listener", { kind: SpanKind.INTERNAL }, async (span) => {
|
|
1739
1709
|
const dispatched = this.inboxListeners?.dispatchWithClass(activity);
|
|
1740
1710
|
if (dispatched == null) {
|
|
1741
|
-
logger
|
|
1711
|
+
logger.error("Unsupported activity type:\n{activity}", {
|
|
1742
1712
|
activityId: activity.id?.href,
|
|
1743
1713
|
activity: message.activity,
|
|
1744
1714
|
recipient: message.identifier,
|
|
1745
1715
|
trial: message.attempt
|
|
1746
1716
|
});
|
|
1747
|
-
span
|
|
1717
|
+
span.setStatus({
|
|
1748
1718
|
code: SpanStatusCode.ERROR,
|
|
1749
1719
|
message: `Unsupported activity type: ${getTypeId(activity).href}`
|
|
1750
1720
|
});
|
|
1751
|
-
span
|
|
1721
|
+
span.end();
|
|
1752
1722
|
return;
|
|
1753
1723
|
}
|
|
1754
1724
|
const { class: cls, listener } = dispatched;
|
|
1755
|
-
span
|
|
1725
|
+
span.updateName(`activitypub.dispatch_inbox_listener ${cls.name}`);
|
|
1756
1726
|
try {
|
|
1757
|
-
await listener(context
|
|
1727
|
+
await listener(context.toInboxContext(message.identifier, message.activity, activity.id?.href, getTypeId(activity).href), activity);
|
|
1758
1728
|
} catch (error) {
|
|
1759
1729
|
try {
|
|
1760
|
-
await this.inboxErrorHandler?.(context
|
|
1761
|
-
} catch (error
|
|
1762
|
-
logger
|
|
1763
|
-
error
|
|
1730
|
+
await this.inboxErrorHandler?.(context, error);
|
|
1731
|
+
} catch (error) {
|
|
1732
|
+
logger.error("An unexpected error occurred in inbox error handler:\n{error}", {
|
|
1733
|
+
error,
|
|
1764
1734
|
trial: message.attempt,
|
|
1765
1735
|
activityId: activity.id?.href,
|
|
1766
1736
|
activity: message.activity,
|
|
@@ -1768,17 +1738,17 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1768
1738
|
});
|
|
1769
1739
|
}
|
|
1770
1740
|
if (this.inboxQueue?.nativeRetrial) {
|
|
1771
|
-
logger
|
|
1741
|
+
logger.error("Failed to process the incoming activity {activityId}; backend will handle retry:\n{error}", {
|
|
1772
1742
|
error,
|
|
1773
1743
|
activityId: activity.id?.href,
|
|
1774
1744
|
activity: message.activity,
|
|
1775
1745
|
recipient: message.identifier
|
|
1776
1746
|
});
|
|
1777
|
-
span
|
|
1747
|
+
span.setStatus({
|
|
1778
1748
|
code: SpanStatusCode.ERROR,
|
|
1779
1749
|
message: String(error)
|
|
1780
1750
|
});
|
|
1781
|
-
span
|
|
1751
|
+
span.end();
|
|
1782
1752
|
throw error;
|
|
1783
1753
|
}
|
|
1784
1754
|
const delay = this.inboxRetryPolicy({
|
|
@@ -1786,7 +1756,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1786
1756
|
attempts: message.attempt
|
|
1787
1757
|
});
|
|
1788
1758
|
if (delay != null) {
|
|
1789
|
-
logger
|
|
1759
|
+
logger.error("Failed to process the incoming activity {activityId} (attempt #{attempt}); retry...:\n{error}", {
|
|
1790
1760
|
error,
|
|
1791
1761
|
attempt: message.attempt,
|
|
1792
1762
|
activityId: activity.id?.href,
|
|
@@ -1797,26 +1767,26 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1797
1767
|
...message,
|
|
1798
1768
|
attempt: message.attempt + 1
|
|
1799
1769
|
}, { delay: Temporal.Duration.compare(delay, { seconds: 0 }) < 0 ? Temporal.Duration.from({ seconds: 0 }) : delay });
|
|
1800
|
-
} else logger
|
|
1770
|
+
} else logger.error("Failed to process the incoming activity {activityId} after {trial} attempts; giving up:\n{error}", {
|
|
1801
1771
|
error,
|
|
1802
1772
|
activityId: activity.id?.href,
|
|
1803
1773
|
activity: message.activity,
|
|
1804
1774
|
recipient: message.identifier
|
|
1805
1775
|
});
|
|
1806
|
-
span
|
|
1776
|
+
span.setStatus({
|
|
1807
1777
|
code: SpanStatusCode.ERROR,
|
|
1808
1778
|
message: String(error)
|
|
1809
1779
|
});
|
|
1810
|
-
span
|
|
1780
|
+
span.end();
|
|
1811
1781
|
return;
|
|
1812
1782
|
}
|
|
1813
1783
|
if (cacheKey != null) await this.kv.set(cacheKey, true, { ttl: Temporal.Duration.from({ days: 1 }) });
|
|
1814
|
-
logger
|
|
1784
|
+
logger.info("Activity {activityId} has been processed.", {
|
|
1815
1785
|
activityId: activity.id?.href,
|
|
1816
1786
|
activity: message.activity,
|
|
1817
1787
|
recipient: message.identifier
|
|
1818
1788
|
});
|
|
1819
|
-
span
|
|
1789
|
+
span.end();
|
|
1820
1790
|
});
|
|
1821
1791
|
}
|
|
1822
1792
|
startQueue(contextData, options = {}) {
|
|
@@ -1860,7 +1830,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1860
1830
|
};
|
|
1861
1831
|
}
|
|
1862
1832
|
async sendActivity(keys, inboxes, activity, options) {
|
|
1863
|
-
const logger
|
|
1833
|
+
const logger = getLogger([
|
|
1864
1834
|
"fedify",
|
|
1865
1835
|
"federation",
|
|
1866
1836
|
"outbox"
|
|
@@ -1894,7 +1864,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1894
1864
|
format: "compact",
|
|
1895
1865
|
contextLoader
|
|
1896
1866
|
});
|
|
1897
|
-
if (rsaKey == null) logger
|
|
1867
|
+
if (rsaKey == null) logger.warn("No supported key found to create a Linked Data signature for the activity {activityId}. The activity will be sent without a Linked Data signature. In order to create a Linked Data signature, at least one RSASSA-PKCS1-v1_5 key must be provided.", {
|
|
1898
1868
|
activityId,
|
|
1899
1869
|
keys: keys.map((pair) => ({
|
|
1900
1870
|
keyId: pair.keyId.href,
|
|
@@ -1905,7 +1875,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1905
1875
|
contextLoader,
|
|
1906
1876
|
tracerProvider: this.tracerProvider
|
|
1907
1877
|
});
|
|
1908
|
-
if (!proofCreated) logger
|
|
1878
|
+
if (!proofCreated) logger.warn("No supported key found to create a proof for the activity {activityId}. The activity will be sent without a proof. In order to create a proof, at least one Ed25519 key must be provided.", {
|
|
1909
1879
|
activityId,
|
|
1910
1880
|
keys: keys.map((pair) => ({
|
|
1911
1881
|
keyId: pair.keyId.href,
|
|
@@ -1913,11 +1883,11 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1913
1883
|
}))
|
|
1914
1884
|
});
|
|
1915
1885
|
if (immediate || this.outboxQueue == null) {
|
|
1916
|
-
if (immediate) logger
|
|
1886
|
+
if (immediate) logger.debug("Sending activity immediately without queue since immediate option is set.", {
|
|
1917
1887
|
activityId: activity.id.href,
|
|
1918
1888
|
activity: jsonLd
|
|
1919
1889
|
});
|
|
1920
|
-
else logger
|
|
1890
|
+
else logger.debug("Sending activity immediately without queue since queue is not set.", {
|
|
1921
1891
|
activityId: activity.id.href,
|
|
1922
1892
|
activity: jsonLd
|
|
1923
1893
|
});
|
|
@@ -1936,7 +1906,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1936
1906
|
await Promise.all(promises);
|
|
1937
1907
|
return;
|
|
1938
1908
|
}
|
|
1939
|
-
logger
|
|
1909
|
+
logger.debug("Enqueuing activity {activityId} to send later.", {
|
|
1940
1910
|
activityId: activity.id.href,
|
|
1941
1911
|
activity: jsonLd
|
|
1942
1912
|
});
|
|
@@ -1973,10 +1943,9 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1973
1943
|
const { outboxQueue } = this;
|
|
1974
1944
|
if (outboxQueue.enqueueMany == null) {
|
|
1975
1945
|
const promises = messages.map((m) => outboxQueue.enqueue(m));
|
|
1976
|
-
const
|
|
1977
|
-
const errors = results.filter((r) => r.status === "rejected").map((r) => r.reason);
|
|
1946
|
+
const errors = (await Promise.allSettled(promises)).filter((r) => r.status === "rejected").map((r) => r.reason);
|
|
1978
1947
|
if (errors.length > 0) {
|
|
1979
|
-
logger
|
|
1948
|
+
logger.error("Failed to enqueue activity {activityId} to send later: {errors}", {
|
|
1980
1949
|
activityId: activity.id.href,
|
|
1981
1950
|
errors
|
|
1982
1951
|
});
|
|
@@ -1986,7 +1955,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1986
1955
|
} else try {
|
|
1987
1956
|
await outboxQueue.enqueueMany(messages);
|
|
1988
1957
|
} catch (error) {
|
|
1989
|
-
logger
|
|
1958
|
+
logger.error("Failed to enqueue activity {activityId} to send later: {error}", {
|
|
1990
1959
|
activityId: activity.id.href,
|
|
1991
1960
|
error
|
|
1992
1961
|
});
|
|
@@ -1994,8 +1963,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1994
1963
|
}
|
|
1995
1964
|
}
|
|
1996
1965
|
fetch(request, options) {
|
|
1997
|
-
|
|
1998
|
-
return withContext({ requestId }, async () => {
|
|
1966
|
+
return withContext({ requestId: getRequestId(request) }, async () => {
|
|
1999
1967
|
const tracer = this._getTracer();
|
|
2000
1968
|
return await tracer.startActiveSpan(request.method, {
|
|
2001
1969
|
kind: SpanKind.SERVER,
|
|
@@ -2004,7 +1972,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2004
1972
|
[ATTR_URL_FULL]: request.url
|
|
2005
1973
|
}
|
|
2006
1974
|
}, async (span) => {
|
|
2007
|
-
const logger
|
|
1975
|
+
const logger = getLogger([
|
|
2008
1976
|
"fedify",
|
|
2009
1977
|
"federation",
|
|
2010
1978
|
"http"
|
|
@@ -2023,7 +1991,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2023
1991
|
message: `${error}`
|
|
2024
1992
|
});
|
|
2025
1993
|
span.end();
|
|
2026
|
-
logger
|
|
1994
|
+
logger.error("An error occurred while serving request {method} {url}: {error}", {
|
|
2027
1995
|
method: request.method,
|
|
2028
1996
|
url: request.url,
|
|
2029
1997
|
error
|
|
@@ -2047,9 +2015,9 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2047
2015
|
url: request.url,
|
|
2048
2016
|
status: response.status
|
|
2049
2017
|
};
|
|
2050
|
-
if (response.status >= 500) logger
|
|
2051
|
-
else if (response.status >= 400) logger
|
|
2052
|
-
else logger
|
|
2018
|
+
if (response.status >= 500) logger.error(logTpl, values);
|
|
2019
|
+
else if (response.status >= 400) logger.warn(logTpl, values);
|
|
2020
|
+
else logger.info(logTpl, values);
|
|
2053
2021
|
return response;
|
|
2054
2022
|
});
|
|
2055
2023
|
});
|
|
@@ -2062,11 +2030,11 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2062
2030
|
const route = this.router.route(url.pathname);
|
|
2063
2031
|
if (route == null) return await onNotFound(request);
|
|
2064
2032
|
span.updateName(`${request.method} ${route.template}`);
|
|
2065
|
-
let context
|
|
2033
|
+
let context = this.#createContext(request, contextData);
|
|
2066
2034
|
const routeName = route.name.replace(/:.*$/, "");
|
|
2067
2035
|
switch (routeName) {
|
|
2068
2036
|
case "webfinger": return await handleWebFinger(request, {
|
|
2069
|
-
context
|
|
2037
|
+
context,
|
|
2070
2038
|
host: this.origin?.handleHost,
|
|
2071
2039
|
actorDispatcher: this.actorCallbacks?.dispatcher,
|
|
2072
2040
|
actorHandleMapper: this.actorCallbacks?.handleMapper,
|
|
@@ -2075,16 +2043,16 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2075
2043
|
onNotFound,
|
|
2076
2044
|
tracer
|
|
2077
2045
|
});
|
|
2078
|
-
case "nodeInfoJrd": return await handleNodeInfoJrd(request, context
|
|
2046
|
+
case "nodeInfoJrd": return await handleNodeInfoJrd(request, context);
|
|
2079
2047
|
case "nodeInfo": return await handleNodeInfo(request, {
|
|
2080
|
-
context
|
|
2048
|
+
context,
|
|
2081
2049
|
nodeInfoDispatcher: this.nodeInfoDispatcher
|
|
2082
2050
|
});
|
|
2083
2051
|
case "actor":
|
|
2084
|
-
context
|
|
2052
|
+
context = this.#createContext(request, contextData, { invokedFromActorDispatcher: { identifier: route.values.identifier ?? route.values.handle } });
|
|
2085
2053
|
return await handleActor(request, {
|
|
2086
2054
|
identifier: route.values.identifier ?? route.values.handle,
|
|
2087
|
-
context
|
|
2055
|
+
context,
|
|
2088
2056
|
actorDispatcher: this.actorCallbacks?.dispatcher,
|
|
2089
2057
|
authorizePredicate: this.actorCallbacks?.authorizePredicate,
|
|
2090
2058
|
onUnauthorized,
|
|
@@ -2095,13 +2063,13 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2095
2063
|
const typeId = route.name.replace(/^object:/, "");
|
|
2096
2064
|
const callbacks = this.objectCallbacks[typeId];
|
|
2097
2065
|
const cls = this.objectTypeIds[typeId];
|
|
2098
|
-
context
|
|
2066
|
+
context = this.#createContext(request, contextData, { invokedFromObjectDispatcher: {
|
|
2099
2067
|
cls,
|
|
2100
2068
|
values: route.values
|
|
2101
2069
|
} });
|
|
2102
2070
|
return await handleObject(request, {
|
|
2103
2071
|
values: route.values,
|
|
2104
|
-
context
|
|
2072
|
+
context,
|
|
2105
2073
|
objectDispatcher: callbacks?.dispatcher,
|
|
2106
2074
|
authorizePredicate: callbacks?.authorizePredicate,
|
|
2107
2075
|
onUnauthorized,
|
|
@@ -2112,8 +2080,8 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2112
2080
|
case "outbox": return await handleCollection(request, {
|
|
2113
2081
|
name: "outbox",
|
|
2114
2082
|
identifier: route.values.identifier ?? route.values.handle,
|
|
2115
|
-
uriGetter: context
|
|
2116
|
-
context
|
|
2083
|
+
uriGetter: context.getOutboxUri.bind(context),
|
|
2084
|
+
context,
|
|
2117
2085
|
collectionCallbacks: this.outboxCallbacks,
|
|
2118
2086
|
tracerProvider: this.tracerProvider,
|
|
2119
2087
|
onUnauthorized,
|
|
@@ -2124,25 +2092,25 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2124
2092
|
if (request.method !== "POST") return await handleCollection(request, {
|
|
2125
2093
|
name: "inbox",
|
|
2126
2094
|
identifier: route.values.identifier ?? route.values.handle,
|
|
2127
|
-
uriGetter: context
|
|
2128
|
-
context
|
|
2095
|
+
uriGetter: context.getInboxUri.bind(context),
|
|
2096
|
+
context,
|
|
2129
2097
|
collectionCallbacks: this.inboxCallbacks,
|
|
2130
2098
|
tracerProvider: this.tracerProvider,
|
|
2131
2099
|
onUnauthorized,
|
|
2132
2100
|
onNotFound,
|
|
2133
2101
|
onNotAcceptable
|
|
2134
2102
|
});
|
|
2135
|
-
context
|
|
2103
|
+
context = this.#createContext(request, contextData, { documentLoader: await context.getDocumentLoader({ identifier: route.values.identifier ?? route.values.handle }) });
|
|
2136
2104
|
case "sharedInbox":
|
|
2137
2105
|
if (routeName !== "inbox" && this.sharedInboxKeyDispatcher != null) {
|
|
2138
|
-
const identity = await this.sharedInboxKeyDispatcher(context
|
|
2139
|
-
if (identity != null) context
|
|
2106
|
+
const identity = await this.sharedInboxKeyDispatcher(context);
|
|
2107
|
+
if (identity != null) context = this.#createContext(request, contextData, { documentLoader: "identifier" in identity || "username" in identity || "handle" in identity ? await context.getDocumentLoader(identity) : context.getDocumentLoader(identity) });
|
|
2140
2108
|
}
|
|
2141
2109
|
if (!this.manuallyStartQueue) this._startQueueInternal(contextData);
|
|
2142
2110
|
return await handleInbox(request, {
|
|
2143
2111
|
recipient: route.values.identifier ?? route.values.handle ?? null,
|
|
2144
|
-
context
|
|
2145
|
-
inboxContextFactory: context
|
|
2112
|
+
context,
|
|
2113
|
+
inboxContextFactory: context.toInboxContext.bind(context),
|
|
2146
2114
|
kv: this.kv,
|
|
2147
2115
|
kvPrefixes: this.kvPrefixes,
|
|
2148
2116
|
queue: this.inboxQueue,
|
|
@@ -2158,8 +2126,8 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2158
2126
|
case "following": return await handleCollection(request, {
|
|
2159
2127
|
name: "following",
|
|
2160
2128
|
identifier: route.values.identifier ?? route.values.handle,
|
|
2161
|
-
uriGetter: context
|
|
2162
|
-
context
|
|
2129
|
+
uriGetter: context.getFollowingUri.bind(context),
|
|
2130
|
+
context,
|
|
2163
2131
|
collectionCallbacks: this.followingCallbacks,
|
|
2164
2132
|
tracerProvider: this.tracerProvider,
|
|
2165
2133
|
onUnauthorized,
|
|
@@ -2176,14 +2144,14 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2176
2144
|
return await handleCollection(request, {
|
|
2177
2145
|
name: "followers",
|
|
2178
2146
|
identifier: route.values.identifier ?? route.values.handle,
|
|
2179
|
-
uriGetter: baseUrl == null ? context
|
|
2180
|
-
const uri = context
|
|
2147
|
+
uriGetter: baseUrl == null ? context.getFollowersUri.bind(context) : (identifier) => {
|
|
2148
|
+
const uri = context.getFollowersUri(identifier);
|
|
2181
2149
|
uri.searchParams.set("base-url", baseUrl);
|
|
2182
2150
|
return uri;
|
|
2183
2151
|
},
|
|
2184
|
-
context
|
|
2152
|
+
context,
|
|
2185
2153
|
filter: baseUrl != null ? new URL(baseUrl) : void 0,
|
|
2186
|
-
filterPredicate: baseUrl != null ? (i) => (i instanceof URL ? i.href : i.id?.href ?? "").startsWith(baseUrl) : void 0,
|
|
2154
|
+
filterPredicate: baseUrl != null ? ((i) => (i instanceof URL ? i.href : i.id?.href ?? "").startsWith(baseUrl)) : void 0,
|
|
2187
2155
|
collectionCallbacks: this.followersCallbacks,
|
|
2188
2156
|
tracerProvider: this.tracerProvider,
|
|
2189
2157
|
onUnauthorized,
|
|
@@ -2194,8 +2162,8 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2194
2162
|
case "liked": return await handleCollection(request, {
|
|
2195
2163
|
name: "liked",
|
|
2196
2164
|
identifier: route.values.identifier ?? route.values.handle,
|
|
2197
|
-
uriGetter: context
|
|
2198
|
-
context
|
|
2165
|
+
uriGetter: context.getLikedUri.bind(context),
|
|
2166
|
+
context,
|
|
2199
2167
|
collectionCallbacks: this.likedCallbacks,
|
|
2200
2168
|
tracerProvider: this.tracerProvider,
|
|
2201
2169
|
onUnauthorized,
|
|
@@ -2205,8 +2173,8 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2205
2173
|
case "featured": return await handleCollection(request, {
|
|
2206
2174
|
name: "featured",
|
|
2207
2175
|
identifier: route.values.identifier ?? route.values.handle,
|
|
2208
|
-
uriGetter: context
|
|
2209
|
-
context
|
|
2176
|
+
uriGetter: context.getFeaturedUri.bind(context),
|
|
2177
|
+
context,
|
|
2210
2178
|
collectionCallbacks: this.featuredCallbacks,
|
|
2211
2179
|
tracerProvider: this.tracerProvider,
|
|
2212
2180
|
onUnauthorized,
|
|
@@ -2216,8 +2184,8 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2216
2184
|
case "featuredTags": return await handleCollection(request, {
|
|
2217
2185
|
name: "featured tags",
|
|
2218
2186
|
identifier: route.values.identifier ?? route.values.handle,
|
|
2219
|
-
uriGetter: context
|
|
2220
|
-
context
|
|
2187
|
+
uriGetter: context.getFeaturedTagsUri.bind(context),
|
|
2188
|
+
context,
|
|
2221
2189
|
collectionCallbacks: this.featuredTagsCallbacks,
|
|
2222
2190
|
tracerProvider: this.tracerProvider,
|
|
2223
2191
|
onUnauthorized,
|
|
@@ -2229,7 +2197,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2229
2197
|
const callbacks = this.collectionCallbacks[name];
|
|
2230
2198
|
return await handleCustomCollection(request, {
|
|
2231
2199
|
name,
|
|
2232
|
-
context
|
|
2200
|
+
context,
|
|
2233
2201
|
values: route.values,
|
|
2234
2202
|
collectionCallbacks: callbacks,
|
|
2235
2203
|
tracerProvider: this.tracerProvider,
|
|
@@ -2243,7 +2211,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2243
2211
|
const callbacks = this.collectionCallbacks[name];
|
|
2244
2212
|
return await handleOrderedCollection(request, {
|
|
2245
2213
|
name,
|
|
2246
|
-
context
|
|
2214
|
+
context,
|
|
2247
2215
|
values: route.values,
|
|
2248
2216
|
collectionCallbacks: callbacks,
|
|
2249
2217
|
tracerProvider: this.tracerProvider,
|
|
@@ -2341,9 +2309,9 @@ var ContextImpl = class ContextImpl {
|
|
|
2341
2309
|
}
|
|
2342
2310
|
getInboxUri(identifier) {
|
|
2343
2311
|
if (identifier == null) {
|
|
2344
|
-
const path
|
|
2345
|
-
if (path
|
|
2346
|
-
return new URL(path
|
|
2312
|
+
const path = this.federation.router.build("sharedInbox", {});
|
|
2313
|
+
if (path == null) throw new RouterError("No shared inbox path registered.");
|
|
2314
|
+
return new URL(path, this.canonicalOrigin);
|
|
2347
2315
|
}
|
|
2348
2316
|
const path = this.federation.router.build("inbox", {
|
|
2349
2317
|
identifier,
|
|
@@ -2401,14 +2369,13 @@ var ContextImpl = class ContextImpl {
|
|
|
2401
2369
|
if (uri == null) return null;
|
|
2402
2370
|
if (uri.origin !== this.origin && uri.origin !== this.canonicalOrigin) return null;
|
|
2403
2371
|
const route = this.federation.router.route(uri.pathname);
|
|
2404
|
-
const logger
|
|
2372
|
+
const logger = getLogger(["fedify", "federation"]);
|
|
2405
2373
|
if (route == null) return null;
|
|
2406
2374
|
else if (route.name === "sharedInbox") return {
|
|
2407
2375
|
type: "inbox",
|
|
2408
2376
|
identifier: void 0,
|
|
2409
2377
|
get handle() {
|
|
2410
|
-
logger
|
|
2411
|
-
return void 0;
|
|
2378
|
+
logger.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
|
|
2412
2379
|
}
|
|
2413
2380
|
};
|
|
2414
2381
|
const identifier = "identifier" in route.values ? route.values.identifier : route.values.handle;
|
|
@@ -2416,7 +2383,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2416
2383
|
type: "actor",
|
|
2417
2384
|
identifier,
|
|
2418
2385
|
get handle() {
|
|
2419
|
-
logger
|
|
2386
|
+
logger.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
|
|
2420
2387
|
return identifier;
|
|
2421
2388
|
}
|
|
2422
2389
|
};
|
|
@@ -2432,7 +2399,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2432
2399
|
type: "inbox",
|
|
2433
2400
|
identifier,
|
|
2434
2401
|
get handle() {
|
|
2435
|
-
logger
|
|
2402
|
+
logger.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
|
|
2436
2403
|
return identifier;
|
|
2437
2404
|
}
|
|
2438
2405
|
};
|
|
@@ -2440,7 +2407,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2440
2407
|
type: "outbox",
|
|
2441
2408
|
identifier,
|
|
2442
2409
|
get handle() {
|
|
2443
|
-
logger
|
|
2410
|
+
logger.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
|
|
2444
2411
|
return identifier;
|
|
2445
2412
|
}
|
|
2446
2413
|
};
|
|
@@ -2448,7 +2415,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2448
2415
|
type: "following",
|
|
2449
2416
|
identifier,
|
|
2450
2417
|
get handle() {
|
|
2451
|
-
logger
|
|
2418
|
+
logger.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
|
|
2452
2419
|
return identifier;
|
|
2453
2420
|
}
|
|
2454
2421
|
};
|
|
@@ -2456,7 +2423,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2456
2423
|
type: "followers",
|
|
2457
2424
|
identifier,
|
|
2458
2425
|
get handle() {
|
|
2459
|
-
logger
|
|
2426
|
+
logger.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
|
|
2460
2427
|
return identifier;
|
|
2461
2428
|
}
|
|
2462
2429
|
};
|
|
@@ -2464,7 +2431,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2464
2431
|
type: "liked",
|
|
2465
2432
|
identifier,
|
|
2466
2433
|
get handle() {
|
|
2467
|
-
logger
|
|
2434
|
+
logger.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
|
|
2468
2435
|
return identifier;
|
|
2469
2436
|
}
|
|
2470
2437
|
};
|
|
@@ -2472,7 +2439,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2472
2439
|
type: "featured",
|
|
2473
2440
|
identifier,
|
|
2474
2441
|
get handle() {
|
|
2475
|
-
logger
|
|
2442
|
+
logger.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
|
|
2476
2443
|
return identifier;
|
|
2477
2444
|
}
|
|
2478
2445
|
};
|
|
@@ -2480,12 +2447,11 @@ var ContextImpl = class ContextImpl {
|
|
|
2480
2447
|
type: "featuredTags",
|
|
2481
2448
|
identifier,
|
|
2482
2449
|
get handle() {
|
|
2483
|
-
logger
|
|
2450
|
+
logger.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
|
|
2484
2451
|
return identifier;
|
|
2485
2452
|
}
|
|
2486
2453
|
};
|
|
2487
|
-
const
|
|
2488
|
-
const collectionRegex = /* @__PURE__ */ new RegExp(`^(${collectionTypes.join("|")}):(.*)$`);
|
|
2454
|
+
const collectionRegex = new RegExp(`^(${["collection", "orderedCollection"].join("|")}):(.*)$`);
|
|
2489
2455
|
const match = route.name.match(collectionRegex);
|
|
2490
2456
|
if (match !== null) {
|
|
2491
2457
|
const [, type, name] = match;
|
|
@@ -2501,12 +2467,12 @@ var ContextImpl = class ContextImpl {
|
|
|
2501
2467
|
return null;
|
|
2502
2468
|
}
|
|
2503
2469
|
async getActorKeyPairs(identifier) {
|
|
2504
|
-
const logger
|
|
2470
|
+
const logger = getLogger([
|
|
2505
2471
|
"fedify",
|
|
2506
2472
|
"federation",
|
|
2507
2473
|
"actor"
|
|
2508
2474
|
]);
|
|
2509
|
-
if (this.invokedFromActorKeyPairsDispatcher != null) logger
|
|
2475
|
+
if (this.invokedFromActorKeyPairsDispatcher != null) logger.warn("Context.getActorKeyPairs({getActorKeyPairsIdentifier}) method is invoked from the actor key pairs dispatcher ({actorKeyPairsDispatcherIdentifier}); this may cause an infinite loop.", {
|
|
2510
2476
|
getActorKeyPairsIdentifier: identifier,
|
|
2511
2477
|
actorKeyPairsDispatcherIdentifier: this.invokedFromActorKeyPairsDispatcher.identifier
|
|
2512
2478
|
});
|
|
@@ -2514,7 +2480,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2514
2480
|
try {
|
|
2515
2481
|
keyPairs = await this.getKeyPairsFromIdentifier(identifier);
|
|
2516
2482
|
} catch (_) {
|
|
2517
|
-
logger
|
|
2483
|
+
logger.warn("No actor key pairs dispatcher registered.");
|
|
2518
2484
|
return [];
|
|
2519
2485
|
}
|
|
2520
2486
|
const owner = this.getActorUri(identifier);
|
|
@@ -2538,7 +2504,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2538
2504
|
return result;
|
|
2539
2505
|
}
|
|
2540
2506
|
async getKeyPairsFromIdentifier(identifier) {
|
|
2541
|
-
const logger
|
|
2507
|
+
const logger = getLogger([
|
|
2542
2508
|
"fedify",
|
|
2543
2509
|
"federation",
|
|
2544
2510
|
"actor"
|
|
@@ -2549,7 +2515,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2549
2515
|
actorUri = this.getActorUri(identifier);
|
|
2550
2516
|
} catch (error) {
|
|
2551
2517
|
if (error instanceof RouterError) {
|
|
2552
|
-
logger
|
|
2518
|
+
logger.warn(error.message);
|
|
2553
2519
|
return [];
|
|
2554
2520
|
}
|
|
2555
2521
|
throw error;
|
|
@@ -2558,7 +2524,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2558
2524
|
...this,
|
|
2559
2525
|
invokedFromActorKeyPairsDispatcher: { identifier }
|
|
2560
2526
|
}), identifier);
|
|
2561
|
-
if (keyPairs.length < 1) logger
|
|
2527
|
+
if (keyPairs.length < 1) logger.warn("No key pairs found for actor {identifier}.", { identifier });
|
|
2562
2528
|
let i = 0;
|
|
2563
2529
|
const result = [];
|
|
2564
2530
|
for (const keyPair of keyPairs) {
|
|
@@ -2606,8 +2572,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2606
2572
|
} else identifierPromise = Promise.resolve(identity.identifier);
|
|
2607
2573
|
return identifierPromise.then((identifier) => {
|
|
2608
2574
|
if (identifier == null) return this.documentLoader;
|
|
2609
|
-
|
|
2610
|
-
return keyPair.then((pair) => pair == null ? this.documentLoader : this.federation.authenticatedDocumentLoaderFactory(pair));
|
|
2575
|
+
return this.getRsaKeyPairFromIdentifier(identifier).then((pair) => pair == null ? this.documentLoader : this.federation.authenticatedDocumentLoaderFactory(pair));
|
|
2611
2576
|
});
|
|
2612
2577
|
}
|
|
2613
2578
|
return this.federation.authenticatedDocumentLoaderFactory(identity);
|
|
@@ -2649,8 +2614,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2649
2614
|
});
|
|
2650
2615
|
}
|
|
2651
2616
|
sendActivity(sender, recipients, activity, options = {}) {
|
|
2652
|
-
|
|
2653
|
-
return tracer.startActiveSpan(this.federation.outboxQueue == null || options.immediate ? "activitypub.outbox" : "activitypub.fanout", {
|
|
2617
|
+
return this.tracerProvider.getTracer(name, version).startActiveSpan(this.federation.outboxQueue == null || options.immediate ? "activitypub.outbox" : "activitypub.fanout", {
|
|
2654
2618
|
kind: this.federation.outboxQueue == null || options.immediate ? SpanKind.CLIENT : SpanKind.PRODUCER,
|
|
2655
2619
|
attributes: {
|
|
2656
2620
|
"activitypub.activity.type": getTypeId(activity).href,
|
|
@@ -2675,7 +2639,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2675
2639
|
});
|
|
2676
2640
|
}
|
|
2677
2641
|
async sendActivityInternal(sender, recipients, activity, options, span) {
|
|
2678
|
-
const logger
|
|
2642
|
+
const logger = getLogger([
|
|
2679
2643
|
"fedify",
|
|
2680
2644
|
"federation",
|
|
2681
2645
|
"outbox"
|
|
@@ -2689,7 +2653,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2689
2653
|
if ("username" in sender) username = sender.username;
|
|
2690
2654
|
else {
|
|
2691
2655
|
username = sender.handle;
|
|
2692
|
-
logger
|
|
2656
|
+
logger.warn("The \"handle\" property for the sender parameter is deprecated; use \"identifier\" or \"username\" instead.", { sender });
|
|
2693
2657
|
}
|
|
2694
2658
|
if (this.federation.actorCallbacks?.handleMapper == null) identifier = username;
|
|
2695
2659
|
else {
|
|
@@ -2725,7 +2689,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2725
2689
|
for (const activityTransformer of this.federation.activityTransformers) activity = activityTransformer(activity, this);
|
|
2726
2690
|
span?.setAttribute("activitypub.activity.id", activity?.id?.href ?? "");
|
|
2727
2691
|
if (activity.actorId == null) {
|
|
2728
|
-
logger
|
|
2692
|
+
logger.error("Activity {activityId} to send does not have an actor.", {
|
|
2729
2693
|
activity,
|
|
2730
2694
|
activityId: activity?.id?.href
|
|
2731
2695
|
});
|
|
@@ -2736,7 +2700,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2736
2700
|
preferSharedInbox: options.preferSharedInbox,
|
|
2737
2701
|
excludeBaseUris: options.excludeBaseUris
|
|
2738
2702
|
});
|
|
2739
|
-
logger
|
|
2703
|
+
logger.debug("Sending activity {activityId} to inboxes:\n{inboxes}", {
|
|
2740
2704
|
inboxes: globalThis.Object.keys(inboxes),
|
|
2741
2705
|
activityId: activity.id?.href,
|
|
2742
2706
|
activity
|
|
@@ -2770,7 +2734,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2770
2734
|
traceContext: carrier
|
|
2771
2735
|
};
|
|
2772
2736
|
if (!this.federation.manuallyStartQueue) this.federation._startQueueInternal(this.data);
|
|
2773
|
-
this.federation.fanoutQueue.enqueue(message);
|
|
2737
|
+
await this.federation.fanoutQueue.enqueue(message);
|
|
2774
2738
|
}
|
|
2775
2739
|
async *getFollowers(identifier) {
|
|
2776
2740
|
if (this.federation.followersCallbacks == null) throw new Error("No followers collection dispatcher registered.");
|
|
@@ -2787,16 +2751,14 @@ var ContextImpl = class ContextImpl {
|
|
|
2787
2751
|
"outbox"
|
|
2788
2752
|
]).warn("Since the followers collection dispatcher returned null for no cursor (i.e., one-shot dispatcher), the pagination is used to fetch \"followers\". However, it is recommended to implement the one-shot dispatcher for better performance.", { identifier });
|
|
2789
2753
|
while (cursor != null) {
|
|
2790
|
-
const result
|
|
2791
|
-
if (result
|
|
2792
|
-
for (const recipient of result
|
|
2793
|
-
cursor = result
|
|
2754
|
+
const result = await this.federation.followersCallbacks.dispatcher(this, identifier, cursor);
|
|
2755
|
+
if (result == null) break;
|
|
2756
|
+
for (const recipient of result.items) yield recipient;
|
|
2757
|
+
cursor = result.nextCursor ?? null;
|
|
2794
2758
|
}
|
|
2795
2759
|
}
|
|
2796
2760
|
routeActivity(recipient, activity, options = {}) {
|
|
2797
|
-
|
|
2798
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
2799
|
-
return tracer.startActiveSpan("activitypub.inbox", {
|
|
2761
|
+
return (this.tracerProvider ?? this.tracerProvider).getTracer(name, version).startActiveSpan("activitypub.inbox", {
|
|
2800
2762
|
kind: this.federation.inboxQueue == null || options.immediate ? SpanKind.INTERNAL : SpanKind.PRODUCER,
|
|
2801
2763
|
attributes: { "activitypub.activity.type": getTypeId(activity).href }
|
|
2802
2764
|
}, async (span) => {
|
|
@@ -2824,7 +2786,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2824
2786
|
});
|
|
2825
2787
|
}
|
|
2826
2788
|
async routeActivityInternal(recipient, activity, options = {}, span) {
|
|
2827
|
-
const logger
|
|
2789
|
+
const logger = getLogger([
|
|
2828
2790
|
"fedify",
|
|
2829
2791
|
"federation",
|
|
2830
2792
|
"inbox"
|
|
@@ -2832,19 +2794,18 @@ var ContextImpl = class ContextImpl {
|
|
|
2832
2794
|
const contextLoader = options.contextLoader ?? this.contextLoader;
|
|
2833
2795
|
const json = await activity.toJsonLd({ contextLoader });
|
|
2834
2796
|
const keyCache = new KvKeyCache(this.federation.kv, this.federation.kvPrefixes.publicKey, this);
|
|
2835
|
-
|
|
2797
|
+
if (await verifyObject(Activity, json, {
|
|
2836
2798
|
contextLoader,
|
|
2837
2799
|
documentLoader: options.documentLoader ?? this.documentLoader,
|
|
2838
2800
|
tracerProvider: options.tracerProvider ?? this.tracerProvider,
|
|
2839
2801
|
keyCache
|
|
2840
|
-
})
|
|
2841
|
-
|
|
2842
|
-
logger$2.debug("Object Integrity Proofs are not verified.", {
|
|
2802
|
+
}) == null) {
|
|
2803
|
+
logger.debug("Object Integrity Proofs are not verified.", {
|
|
2843
2804
|
recipient,
|
|
2844
2805
|
activity: json
|
|
2845
2806
|
});
|
|
2846
2807
|
if (activity.id == null) {
|
|
2847
|
-
logger
|
|
2808
|
+
logger.debug("Activity is missing an ID; unable to fetch.", {
|
|
2848
2809
|
recipient,
|
|
2849
2810
|
activity: json
|
|
2850
2811
|
});
|
|
@@ -2852,26 +2813,26 @@ var ContextImpl = class ContextImpl {
|
|
|
2852
2813
|
}
|
|
2853
2814
|
const fetched = await this.lookupObject(activity.id, options);
|
|
2854
2815
|
if (fetched == null) {
|
|
2855
|
-
logger
|
|
2816
|
+
logger.debug("Failed to fetch the remote activity object {activityId}.", {
|
|
2856
2817
|
recipient,
|
|
2857
2818
|
activity: json,
|
|
2858
2819
|
activityId: activity.id.href
|
|
2859
2820
|
});
|
|
2860
2821
|
return false;
|
|
2861
2822
|
} else if (!(fetched instanceof Activity)) {
|
|
2862
|
-
logger
|
|
2823
|
+
logger.debug("Fetched object is not an Activity.", {
|
|
2863
2824
|
recipient,
|
|
2864
2825
|
activity: await fetched.toJsonLd({ contextLoader })
|
|
2865
2826
|
});
|
|
2866
2827
|
return false;
|
|
2867
2828
|
} else if (fetched.id?.href !== activity.id.href) {
|
|
2868
|
-
logger
|
|
2829
|
+
logger.debug("Fetched activity object has a different ID; failed to verify.", {
|
|
2869
2830
|
recipient,
|
|
2870
2831
|
activity: await fetched.toJsonLd({ contextLoader })
|
|
2871
2832
|
});
|
|
2872
2833
|
return false;
|
|
2873
2834
|
} else if (fetched.actorIds.length < 1) {
|
|
2874
|
-
logger
|
|
2835
|
+
logger.debug("Fetched activity object is missing an actor; unable to verify.", {
|
|
2875
2836
|
recipient,
|
|
2876
2837
|
activity: await fetched.toJsonLd({ contextLoader })
|
|
2877
2838
|
});
|
|
@@ -2879,15 +2840,15 @@ var ContextImpl = class ContextImpl {
|
|
|
2879
2840
|
}
|
|
2880
2841
|
const activityId = fetched.id;
|
|
2881
2842
|
if (!fetched.actorIds.every((actor) => actor.origin === activityId.origin)) {
|
|
2882
|
-
logger
|
|
2843
|
+
logger.debug("Fetched activity object has actors from different origins; unable to verify.", {
|
|
2883
2844
|
recipient,
|
|
2884
2845
|
activity: await fetched.toJsonLd({ contextLoader })
|
|
2885
2846
|
});
|
|
2886
2847
|
return false;
|
|
2887
2848
|
}
|
|
2888
|
-
logger
|
|
2849
|
+
logger.debug("Successfully fetched the remote activity object {activityId}; ignore the original activity and use the fetched one, which is trustworthy.");
|
|
2889
2850
|
activity = fetched;
|
|
2890
|
-
} else logger
|
|
2851
|
+
} else logger.debug("Object Integrity Proofs are verified.", {
|
|
2891
2852
|
recipient,
|
|
2892
2853
|
activity: json
|
|
2893
2854
|
});
|
|
@@ -3013,8 +2974,7 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
|
|
|
3013
2974
|
});
|
|
3014
2975
|
}
|
|
3015
2976
|
forwardActivity(forwarder, recipients, options) {
|
|
3016
|
-
|
|
3017
|
-
return tracer.startActiveSpan("activitypub.outbox", {
|
|
2977
|
+
return this.tracerProvider.getTracer(name, version).startActiveSpan("activitypub.outbox", {
|
|
3018
2978
|
kind: this.federation.outboxQueue == null || options?.immediate ? SpanKind.CLIENT : SpanKind.PRODUCER,
|
|
3019
2979
|
attributes: { "activitypub.activity.type": this.activityType }
|
|
3020
2980
|
}, async (span) => {
|
|
@@ -3033,7 +2993,7 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
|
|
|
3033
2993
|
});
|
|
3034
2994
|
}
|
|
3035
2995
|
async forwardActivityInternal(forwarder, recipients, options) {
|
|
3036
|
-
const logger
|
|
2996
|
+
const logger = getLogger([
|
|
3037
2997
|
"fedify",
|
|
3038
2998
|
"federation",
|
|
3039
2999
|
"inbox"
|
|
@@ -3047,7 +3007,7 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
|
|
|
3047
3007
|
if ("username" in forwarder) username = forwarder.username;
|
|
3048
3008
|
else {
|
|
3049
3009
|
username = forwarder.handle;
|
|
3050
|
-
logger
|
|
3010
|
+
logger.warn("The \"handle\" property for the forwarder parameter is deprecated; use \"identifier\" or \"username\" instead.", { forwarder });
|
|
3051
3011
|
}
|
|
3052
3012
|
if (this.federation.actorCallbacks?.handleMapper == null) identifier = username;
|
|
3053
3013
|
else {
|
|
@@ -3065,14 +3025,13 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
|
|
|
3065
3025
|
if (!hasSignature(this.activity)) {
|
|
3066
3026
|
let hasProof;
|
|
3067
3027
|
try {
|
|
3068
|
-
|
|
3069
|
-
hasProof = await activity.getProof() != null;
|
|
3028
|
+
hasProof = await (await Activity.fromJsonLd(this.activity, this)).getProof() != null;
|
|
3070
3029
|
} catch {
|
|
3071
3030
|
hasProof = false;
|
|
3072
3031
|
}
|
|
3073
3032
|
if (!hasProof) {
|
|
3074
3033
|
if (options?.skipIfUnsigned) return;
|
|
3075
|
-
logger
|
|
3034
|
+
logger.warn("The received activity {activityId} is not signed; even if it is forwarded to other servers as is, it may not be accepted by them due to the lack of a signature/proof.");
|
|
3076
3035
|
}
|
|
3077
3036
|
}
|
|
3078
3037
|
if (recipients === "followers") {
|
|
@@ -3086,14 +3045,14 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
|
|
|
3086
3045
|
preferSharedInbox: options?.preferSharedInbox,
|
|
3087
3046
|
excludeBaseUris: options?.excludeBaseUris
|
|
3088
3047
|
});
|
|
3089
|
-
logger
|
|
3048
|
+
logger.debug("Forwarding activity {activityId} to inboxes:\n{inboxes}", {
|
|
3090
3049
|
inboxes: globalThis.Object.keys(inboxes),
|
|
3091
3050
|
activityId: this.activityId,
|
|
3092
3051
|
activity: this.activity
|
|
3093
3052
|
});
|
|
3094
3053
|
if (options?.immediate || this.federation.outboxQueue == null) {
|
|
3095
|
-
if (options?.immediate) logger
|
|
3096
|
-
else logger
|
|
3054
|
+
if (options?.immediate) logger.debug("Forwarding activity immediately without queue since immediate option is set.");
|
|
3055
|
+
else logger.debug("Forwarding activity immediately without queue since queue is not set.");
|
|
3097
3056
|
const promises = [];
|
|
3098
3057
|
for (const inbox in inboxes) promises.push(sendActivity({
|
|
3099
3058
|
keys,
|
|
@@ -3108,7 +3067,7 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
|
|
|
3108
3067
|
await Promise.all(promises);
|
|
3109
3068
|
return;
|
|
3110
3069
|
}
|
|
3111
|
-
logger
|
|
3070
|
+
logger.debug("Enqueuing activity {activityId} to forward later.", {
|
|
3112
3071
|
activityId: this.activityId,
|
|
3113
3072
|
activity: this.activity
|
|
3114
3073
|
});
|
|
@@ -3144,10 +3103,9 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
|
|
|
3144
3103
|
const { outboxQueue } = this.federation;
|
|
3145
3104
|
if (outboxQueue.enqueueMany == null) {
|
|
3146
3105
|
const promises = messages.map((m) => outboxQueue.enqueue(m));
|
|
3147
|
-
const
|
|
3148
|
-
const errors = results.filter((r) => r.status === "rejected").map((r) => r.reason);
|
|
3106
|
+
const errors = (await Promise.allSettled(promises)).filter((r) => r.status === "rejected").map((r) => r.reason);
|
|
3149
3107
|
if (errors.length > 0) {
|
|
3150
|
-
logger
|
|
3108
|
+
logger.error("Failed to enqueue activity {activityId} to forward later:\n{errors}", {
|
|
3151
3109
|
activityId: this.activityId,
|
|
3152
3110
|
errors
|
|
3153
3111
|
});
|
|
@@ -3157,7 +3115,7 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
|
|
|
3157
3115
|
} else try {
|
|
3158
3116
|
await outboxQueue.enqueueMany(messages);
|
|
3159
3117
|
} catch (error) {
|
|
3160
|
-
logger
|
|
3118
|
+
logger.error("Failed to enqueue activity {activityId} to forward later:\n{error}", {
|
|
3161
3119
|
activityId: this.activityId,
|
|
3162
3120
|
error
|
|
3163
3121
|
});
|
|
@@ -3212,10 +3170,7 @@ function unauthorized(_request) {
|
|
|
3212
3170
|
function getRequestId(request) {
|
|
3213
3171
|
const traceId = request.headers.get("X-Request-Id") || request.headers.get("X-Correlation-Id") || request.headers.get("Traceparent")?.split("-")[1];
|
|
3214
3172
|
if (traceId != null) return traceId;
|
|
3215
|
-
|
|
3216
|
-
const random = Math.random().toString(36).slice(2, 8);
|
|
3217
|
-
return `req_${timestamp}${random}`;
|
|
3173
|
+
return `req_${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;
|
|
3218
3174
|
}
|
|
3219
|
-
|
|
3220
3175
|
//#endregion
|
|
3221
|
-
export {
|
|
3176
|
+
export { actorDehydrator as _, createFederation as a, handleCollection as c, handleObject as d, respondWithObject as f, handleNodeInfoJrd as g, handleNodeInfo as h, KvSpecDeterminer as i, handleCustomCollection as l, handleWebFinger as m, FederationImpl as n, acceptsJsonLd as o, respondWithObjectIfAcceptable as p, InboxContextImpl as r, handleActor as s, ContextImpl as t, handleInbox as u, autoIdAssigner as v };
|