@fedify/fedify 1.10.5 → 1.10.7
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-CjkHF7Cj.cjs → actor-BGIAXtRd.cjs} +3112 -4674
- package/dist/{actor-Ch9BTg3N.js → actor-C-_2S5Mn.mjs} +8 -15
- package/dist/{actor-CQdxP8N-.js → actor-Cujbx4Zv.js} +1205 -2768
- package/dist/{actor-eeONG_sv.d.ts → actor-DXwwgFeR.d.ts} +3 -3
- package/dist/{actor-D190nbTD.d.cts → actor-DxvGbmjm.d.cts} +3 -3
- 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-fR-Fqcpa.js → authdocloader-1Sk2bqFx.mjs} +9 -14
- package/dist/{authdocloader-COFZT9Wh.js → authdocloader-D4Y6iyTF.js} +8 -15
- package/dist/{authdocloader-zc5ibOmU.cjs → authdocloader-DQfruCir.cjs} +14 -22
- package/dist/{builder-YD0q32nG.js → builder-CZbrDRl7.mjs} +31 -40
- package/dist/{client-B3mQJNO7.d.ts → client-D7t26_op.d.ts} +2 -2
- package/dist/{client-BgCucCG7.js → client-Dyb8MI3u.mjs} +11 -15
- package/dist/{client-n6L4GtQL.d.cts → client-yc0Z0P6Y.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-Cr5DIxq_.d.ts → context-C6n2yrj0.d.ts} +33 -26
- package/dist/{context-WJoO0SQs.d.cts → context-PfghnHYj.d.cts} +33 -26
- package/dist/{denokv-D0nfNQ1x.js → denokv-NJPMXyK0.mjs} +22 -11
- package/dist/{docloader-BucCRHZI.d.ts → docloader-D7k5A9JP.d.ts} +2 -7
- package/dist/{docloader-ChxNLZAA.d.cts → docloader-DbM94pGY.d.cts} +2 -7
- package/dist/{docloader-BETPdM09.js → docloader-Dtaju6oI.js} +18 -156
- package/dist/{docloader-irBWMSOZ.cjs → docloader-Q3DfzuUi.cjs} +116 -220
- package/dist/{esm-iGH0sRsE.js → esm-DOJg552-.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} +29 -58
- 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} +12 -26
- 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 +245 -21
- package/dist/federation/mod.d.cts +4 -13
- package/dist/federation/mod.d.ts +4 -13
- package/dist/federation/mod.js +240 -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} +24 -34
- package/dist/{http-PgdBoDIj.js → http-BRwSVBn1.mjs} +16 -32
- package/dist/{http-DS9z_HzB.d.ts → http-BYXQvoZQ.d.ts} +5 -9
- package/dist/{http-C_1RU1U_.d.cts → http-CMzg-A9P.d.cts} +5 -9
- package/dist/{http-CQAqR_vx.cjs → http-DCrun8ql.cjs} +51 -68
- package/dist/{http-CxiIW4rD.js → http-DRnRwr3i.js} +17 -33
- package/dist/{inbox-DcDIqTbR.js → inbox-pD1nbb_5.mjs} +17 -25
- package/dist/key-Cmbps6xt.cjs +4 -0
- package/dist/{key-dNFkodH5.cjs → key-DEYIxAFs.cjs} +42 -50
- package/dist/key-DMO0TgTa.mjs +5 -0
- package/dist/{key-I-ibyaZH.js → key-DdL5Oc59.mjs} +12 -18
- package/dist/{key-Cg0kO4dA.js → key-vIzWPiil.js} +19 -19
- package/dist/{keycache-hSs_XFSb.js → keycache-BVR9f06Y.mjs} +6 -10
- package/dist/{keys-CElJez9H.js → keys-Co-0pK8a.mjs} +6 -10
- package/dist/{kv-DipCBaw2.d.ts → kv-C6UC8M9S.d.ts} +1 -1
- package/dist/{kv-BqEOXcZv.d.cts → kv-ClC9WJh5.d.cts} +1 -1
- package/dist/{kv-QzKcOQgP.js → kv-OuT2IU64.mjs} +6 -10
- package/dist/{ld-b16r91YS.js → ld-BFaDk5gX.mjs} +17 -31
- package/dist/{lookup-CySNcNcC.js → lookup-CMYXdjVH.mjs} +8 -17
- package/dist/{lookup-Bfq9Jpm0.cjs → lookup-CZGJqSjm.cjs} +16 -23
- package/dist/{lookup-CiSAeWJl.js → lookup-jlmCTRsO.js} +5 -11
- package/dist/middleware-BWlZ-wms.cjs +4 -0
- package/dist/{middleware-C5emnCh-.js → middleware-BXD5WJbj.mjs} +276 -321
- package/dist/{middleware-Dxo56yae.cjs → middleware-BhMQrJXH.cjs} +494 -547
- package/dist/{middleware-Bs4xDuXR.js → middleware-CmA2E9Bu.js} +349 -393
- package/dist/middleware-H3Ce7yn3.mjs +5 -0
- package/dist/{mod-D5rfgGFE.d.cts → mod-BQ3lrlXU.d.cts} +3 -3
- package/dist/{mod-Dz5Y15Uy.d.cts → mod-C72agZIN.d.cts} +4 -4
- package/dist/{mod-CxMBb_dd.d.cts → mod-CDbqB60V.d.cts} +2 -2
- package/dist/{mod-DS4kJskR.d.ts → mod-Lj0W1nnG.d.ts} +3 -3
- package/dist/{mod-BZfdiPBo.d.ts → mod-_HNKaczF.d.ts} +4 -4
- package/dist/{mod-ChbckRnC.d.ts → mod-lHd-Zdd_.d.ts} +2 -2
- 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/otel/exporter.test.d.mts +2 -0
- package/dist/otel/{exporter.test.js → exporter.test.mjs} +122 -180
- package/dist/otel/mod.cjs +16 -22
- package/dist/otel/mod.d.cts +2 -2
- package/dist/otel/mod.d.ts +2 -2
- package/dist/otel/mod.js +9 -16
- package/dist/{otel-Chy5T2Xh.js → otel-0v4Zy01l.mjs} +5 -10
- package/dist/{owner-AcrG3Xz1.d.cts → owner-0yNTyGMb.d.cts} +4 -4
- package/dist/{owner-Bs-sPbHX.js → owner-CNdS8zxf.mjs} +11 -16
- package/dist/{owner-8NMhXwJd.d.ts → owner-CPEbNpnZ.d.ts} +4 -4
- package/dist/{proof-SgRikE_Y.js → proof-Co7YmDpv.mjs} +20 -32
- package/dist/{proof-flD2DeA-.js → proof-DHPbi_Mx.js} +34 -60
- package/dist/{proof-BvQS195q.cjs → proof-DcPdtve2.cjs} +115 -140
- 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} +55 -77
- 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-C0gFHa2i.js → send-BRCWNcMa.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.js → owner.test.mjs} +23 -39
- 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-C1GIraJh.js → testing-BLIh1cXz.mjs} +27 -35
- package/dist/{transformers-BFT6d7J5.js → transformers-BV4OeK9o.js} +3 -7
- package/dist/{transformers-CoBS-oFG.cjs → transformers-CLtJ5H8o.cjs} +20 -25
- package/dist/{types-BgUCCngg.cjs → types-B34v-m2N.cjs} +45 -64
- package/dist/{types-BIgY6c-l.js → types-CAnkAQGM.mjs} +5 -9
- package/dist/{types-Bu-epI-z.js → types-CXZk86AG.js} +18 -36
- 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} +34 -51
- package/dist/vocab/mod.cjs +256 -16
- package/dist/vocab/mod.d.cts +3 -5
- package/dist/vocab/mod.d.ts +3 -5
- package/dist/vocab/mod.js +249 -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-BASuuzcJ.d.ts → vocab-DaT4UsJF.d.ts} +2 -2
- package/dist/{vocab-DPMmFPJ1.d.cts → vocab-DnlmNyXi.d.cts} +2 -2
- package/dist/{type-DUhon7qK.js → vocab-rT_94Pke.mjs} +1178 -2876
- 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-C15gGOh1.cjs +0 -266
- package/dist/federation-K-xsO03l.js +0 -248
- package/dist/key-Bnod5wJl.js +0 -10
- package/dist/key-C6swTX71.js +0 -10
- package/dist/key-_Uq8gkmM.cjs +0 -10
- package/dist/middleware-BWsOtDIF.cjs +0 -17
- package/dist/middleware-Bm4bJzjg.js +0 -26
- package/dist/middleware-BvODpE_U.js +0 -17
- package/dist/mod-C2tOeRkN.d.cts +0 -1
- package/dist/mod-CD7gfdq3.d.ts +0 -104
- package/dist/mod-CnULG6Aa.d.ts +0 -82
- package/dist/mod-FZd39qVq.d.cts +0 -1
- package/dist/mod-JUhOKMHj.d.cts +0 -102
- package/dist/mod-OQfb33eH.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/otel/exporter.test.d.ts +0 -3
- 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/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-5i6DEIi6.cjs +0 -294
- package/dist/vocab-CBavAdew.js +0 -258
- 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-C0gFHa2i.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-rT_94Pke.mjs";
|
|
5
|
+
import { i as RouterError, n as traverseCollection, t as lookupObject } from "./lookup-CMYXdjVH.mjs";
|
|
6
|
+
import { t as getNodeInfo } from "./client-Dyb8MI3u.mjs";
|
|
7
|
+
import { t as nodeInfoToJson } from "./types-CAnkAQGM.mjs";
|
|
8
|
+
import "./actor-C-_2S5Mn.mjs";
|
|
9
|
+
import { a as validateCryptoKey, i as importJwk, t as exportJwk } from "./key-DdL5Oc59.mjs";
|
|
10
|
+
import { l as verifyRequest } from "./http-BRwSVBn1.mjs";
|
|
11
|
+
import { t as getAuthenticatedDocumentLoader } from "./authdocloader-1Sk2bqFx.mjs";
|
|
12
|
+
import { a as signJsonLd, i as hasSignature, o as verifyJsonLd, r as detachSignature } from "./ld-BFaDk5gX.mjs";
|
|
13
|
+
import { n as getKeyOwner, t as doesActorOwnKey } from "./owner-CNdS8zxf.mjs";
|
|
14
|
+
import { n as signObject, r as verifyObject } from "./proof-Co7YmDpv.mjs";
|
|
15
|
+
import { n as routeActivity } from "./inbox-pD1nbb_5.mjs";
|
|
16
|
+
import { t as FederationBuilderImpl } from "./builder-CZbrDRl7.mjs";
|
|
17
|
+
import { t as buildCollectionSynchronizationHeader } from "./collection-BD6-SZ6O.mjs";
|
|
18
|
+
import { t as KvKeyCache } from "./keycache-BVR9f06Y.mjs";
|
|
19
|
+
import { t as createExponentialBackoffPolicy } from "./retry-Ddbq3AcK.mjs";
|
|
20
|
+
import { n as sendActivity, t as extractInboxes } from "./send-BRCWNcMa.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);
|
|
@@ -854,7 +829,7 @@ async function handleInboxInternal(request, parameters, span) {
|
|
|
854
829
|
"http_signatures.key_id": httpSigKey?.id?.href ?? ""
|
|
855
830
|
});
|
|
856
831
|
if (httpSigKey != null && !await doesActorOwnKey(activity, httpSigKey, ctx)) {
|
|
857
|
-
logger
|
|
832
|
+
logger.error("The signer ({keyId}) and the actor ({actorId}) do not match.", {
|
|
858
833
|
activity: json,
|
|
859
834
|
recipient,
|
|
860
835
|
keyId: httpSigKey.id?.href,
|
|
@@ -921,12 +896,12 @@ async function handleInboxInternal(request, parameters, span) {
|
|
|
921
896
|
* @since 1.8.0
|
|
922
897
|
*/
|
|
923
898
|
const handleCustomCollection = exceptWrapper(_handleCustomCollection);
|
|
924
|
-
async function _handleCustomCollection(request, { name, values, context
|
|
899
|
+
async function _handleCustomCollection(request, { name, values, context, tracerProvider, collectionCallbacks: callbacks, filterPredicate }) {
|
|
925
900
|
verifyDefined(callbacks);
|
|
926
901
|
verifyJsonLdRequest(request);
|
|
927
|
-
await authIfNeeded(context
|
|
902
|
+
await authIfNeeded(context, values, callbacks);
|
|
928
903
|
const cursor = new URL(request.url).searchParams.get("cursor");
|
|
929
|
-
return await new CustomCollectionHandler(name, values, context
|
|
904
|
+
return await new CustomCollectionHandler(name, values, context, callbacks, tracerProvider, Collection, CollectionPage, filterPredicate).fetchCollection(cursor).toJsonLd().then(respondAsActivity);
|
|
930
905
|
}
|
|
931
906
|
/**
|
|
932
907
|
* Handles an ordered collection request.
|
|
@@ -940,12 +915,12 @@ async function _handleCustomCollection(request, { name, values, context: context
|
|
|
940
915
|
* @since 1.8.0
|
|
941
916
|
*/
|
|
942
917
|
const handleOrderedCollection = exceptWrapper(_handleOrderedCollection);
|
|
943
|
-
async function _handleOrderedCollection(request, { name, values, context
|
|
918
|
+
async function _handleOrderedCollection(request, { name, values, context, tracerProvider, collectionCallbacks: callbacks, filterPredicate }) {
|
|
944
919
|
verifyDefined(callbacks);
|
|
945
920
|
verifyJsonLdRequest(request);
|
|
946
|
-
await authIfNeeded(context
|
|
921
|
+
await authIfNeeded(context, values, callbacks);
|
|
947
922
|
const cursor = new URL(request.url).searchParams.get("cursor");
|
|
948
|
-
return await new CustomCollectionHandler(name, values, context
|
|
923
|
+
return await new CustomCollectionHandler(name, values, context, callbacks, tracerProvider, OrderedCollection, OrderedCollectionPage, filterPredicate).fetchCollection(cursor).toJsonLd().then(respondAsActivity);
|
|
949
924
|
}
|
|
950
925
|
/**
|
|
951
926
|
* Handling custom collections with support for pagination and filtering.
|
|
@@ -995,17 +970,17 @@ var CustomCollectionHandler = class {
|
|
|
995
970
|
* @param CollectionPage The CollectionPage constructor.
|
|
996
971
|
* @param filterPredicate Optional filter predicate for items.
|
|
997
972
|
*/
|
|
998
|
-
constructor(name, values, context
|
|
999
|
-
this.name = name;
|
|
973
|
+
constructor(name$1, values, context, callbacks, tracerProvider = trace.getTracerProvider(), Collection, CollectionPage, filterPredicate) {
|
|
974
|
+
this.name = name$1;
|
|
1000
975
|
this.values = values;
|
|
1001
|
-
this.context = context
|
|
976
|
+
this.context = context;
|
|
1002
977
|
this.callbacks = callbacks;
|
|
1003
978
|
this.tracerProvider = tracerProvider;
|
|
1004
|
-
this.Collection = Collection
|
|
1005
|
-
this.CollectionPage = CollectionPage
|
|
979
|
+
this.Collection = Collection;
|
|
980
|
+
this.CollectionPage = CollectionPage;
|
|
1006
981
|
this.filterPredicate = filterPredicate;
|
|
1007
982
|
this.name = this.name.trim().replace(/\s+/g, "_");
|
|
1008
|
-
this.#tracer = this.tracerProvider.getTracer(
|
|
983
|
+
this.#tracer = this.tracerProvider.getTracer(name, version);
|
|
1009
984
|
this.#id = new URL(this.context.url);
|
|
1010
985
|
this.#dispatcher = callbacks.dispatcher.bind(callbacks);
|
|
1011
986
|
}
|
|
@@ -1034,8 +1009,8 @@ var CustomCollectionHandler = class {
|
|
|
1034
1009
|
*/
|
|
1035
1010
|
async getCollection(cursor = null) {
|
|
1036
1011
|
if (cursor !== null) {
|
|
1037
|
-
const props
|
|
1038
|
-
return new this.CollectionPage(props
|
|
1012
|
+
const props = await this.getPageProps(cursor);
|
|
1013
|
+
return new this.CollectionPage(props);
|
|
1039
1014
|
}
|
|
1040
1015
|
const firstCursor = await this.firstCursor;
|
|
1041
1016
|
const props = typeof firstCursor === "string" ? await this.getProps(firstCursor) : await this.getPropsWithoutCursor();
|
|
@@ -1183,7 +1158,7 @@ var CustomCollectionHandler = class {
|
|
|
1183
1158
|
* @param value The total items count or a promise that resolves to it.
|
|
1184
1159
|
*/
|
|
1185
1160
|
set totalItems(value) {
|
|
1186
|
-
const toNumber = (value
|
|
1161
|
+
const toNumber = (value) => value == null ? null : Number(value);
|
|
1187
1162
|
this.#totalItems = value instanceof Promise ? value.then(toNumber) : Promise.resolve(toNumber(value));
|
|
1188
1163
|
}
|
|
1189
1164
|
/**
|
|
@@ -1257,11 +1232,9 @@ const verifyJsonLdRequest = (request) => {
|
|
|
1257
1232
|
* @throws {UnauthorizedError} If authorization fails.
|
|
1258
1233
|
* @since 1.8.0
|
|
1259
1234
|
*/
|
|
1260
|
-
const authIfNeeded = async (context
|
|
1235
|
+
const authIfNeeded = async (context, values, { authorizePredicate: authorize = void 0 }) => {
|
|
1261
1236
|
if (authorize === void 0) return;
|
|
1262
|
-
|
|
1263
|
-
const keyOwner = (await context$1.getSignedKeyOwner())?.clone({}, warning.keyOwner) ?? null;
|
|
1264
|
-
if (!await authorize(context$1, values, key, keyOwner)) throw new UnauthorizedError();
|
|
1237
|
+
if (!await authorize(context, values, (await context.getSignedKey())?.clone({}, warning.key) ?? null, (await context.getSignedKeyOwner())?.clone({}, warning.keyOwner) ?? null)) throw new UnauthorizedError();
|
|
1265
1238
|
};
|
|
1266
1239
|
/** Warning messages for `authIfNeeded`. */
|
|
1267
1240
|
const warning = {
|
|
@@ -1375,7 +1348,6 @@ async function respondWithObjectIfAcceptable(object, request, options) {
|
|
|
1375
1348
|
response.headers.set("Vary", "Accept");
|
|
1376
1349
|
return response;
|
|
1377
1350
|
}
|
|
1378
|
-
|
|
1379
1351
|
//#endregion
|
|
1380
1352
|
//#region src/federation/middleware.ts
|
|
1381
1353
|
/**
|
|
@@ -1413,7 +1385,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1413
1385
|
firstKnock;
|
|
1414
1386
|
constructor(options) {
|
|
1415
1387
|
super();
|
|
1416
|
-
const logger
|
|
1388
|
+
const logger = getLogger(["fedify", "federation"]);
|
|
1417
1389
|
this.kv = options.kv;
|
|
1418
1390
|
this.kvPrefixes = {
|
|
1419
1391
|
activityIdempotence: ["_fedify", "activityIdempotence"],
|
|
@@ -1470,7 +1442,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1470
1442
|
if (options.documentLoader != null) {
|
|
1471
1443
|
if (options.documentLoaderFactory != null) throw new TypeError("Cannot set both documentLoader and documentLoaderFactory options at a time; use documentLoaderFactory only.");
|
|
1472
1444
|
this.documentLoaderFactory = () => options.documentLoader;
|
|
1473
|
-
logger
|
|
1445
|
+
logger.warn("The documentLoader option is deprecated; use documentLoaderFactory option instead.");
|
|
1474
1446
|
} else this.documentLoaderFactory = options.documentLoaderFactory ?? ((opts) => {
|
|
1475
1447
|
return kvCache({
|
|
1476
1448
|
loader: getDocumentLoader({
|
|
@@ -1484,7 +1456,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1484
1456
|
if (options.contextLoader != null) {
|
|
1485
1457
|
if (options.contextLoaderFactory != null) throw new TypeError("Cannot set both contextLoader and contextLoaderFactory options at a time; use contextLoaderFactory only.");
|
|
1486
1458
|
this.contextLoaderFactory = () => options.contextLoader;
|
|
1487
|
-
logger
|
|
1459
|
+
logger.warn("The contextLoader option is deprecated; use contextLoaderFactory option instead.");
|
|
1488
1460
|
} else this.contextLoaderFactory = options.contextLoaderFactory ?? this.documentLoaderFactory;
|
|
1489
1461
|
this.authenticatedDocumentLoaderFactory = options.authenticatedDocumentLoaderFactory ?? ((identity) => getAuthenticatedDocumentLoader(identity, {
|
|
1490
1462
|
allowPrivateAddress,
|
|
@@ -1507,28 +1479,28 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1507
1479
|
this.router.add("/.well-known/nodeinfo", "nodeInfoJrd");
|
|
1508
1480
|
}
|
|
1509
1481
|
_getTracer() {
|
|
1510
|
-
return this.tracerProvider.getTracer(
|
|
1482
|
+
return this.tracerProvider.getTracer(name, version);
|
|
1511
1483
|
}
|
|
1512
1484
|
async _startQueueInternal(ctxData, signal, queue) {
|
|
1513
1485
|
if (this.inboxQueue == null && this.outboxQueue == null) return;
|
|
1514
|
-
const logger
|
|
1486
|
+
const logger = getLogger([
|
|
1515
1487
|
"fedify",
|
|
1516
1488
|
"federation",
|
|
1517
1489
|
"queue"
|
|
1518
1490
|
]);
|
|
1519
1491
|
const promises = [];
|
|
1520
1492
|
if (this.inboxQueue != null && (queue == null || queue === "inbox") && !this.inboxQueueStarted) {
|
|
1521
|
-
logger
|
|
1493
|
+
logger.debug("Starting an inbox task worker.");
|
|
1522
1494
|
this.inboxQueueStarted = true;
|
|
1523
1495
|
promises.push(this.inboxQueue.listen((msg) => this.processQueuedTask(ctxData, msg), { signal }));
|
|
1524
1496
|
}
|
|
1525
1497
|
if (this.outboxQueue != null && this.outboxQueue !== this.inboxQueue && (queue == null || queue === "outbox") && !this.outboxQueueStarted) {
|
|
1526
|
-
logger
|
|
1498
|
+
logger.debug("Starting an outbox task worker.");
|
|
1527
1499
|
this.outboxQueueStarted = true;
|
|
1528
1500
|
promises.push(this.outboxQueue.listen((msg) => this.processQueuedTask(ctxData, msg), { signal }));
|
|
1529
1501
|
}
|
|
1530
1502
|
if (this.fanoutQueue != null && this.fanoutQueue !== this.inboxQueue && this.fanoutQueue !== this.outboxQueue && (queue == null || queue === "fanout") && !this.fanoutQueueStarted) {
|
|
1531
|
-
logger
|
|
1503
|
+
logger.debug("Starting a fanout task worker.");
|
|
1532
1504
|
this.fanoutQueueStarted = true;
|
|
1533
1505
|
promises.push(this.fanoutQueue.listen((msg) => this.processQueuedTask(ctxData, msg), { signal }));
|
|
1534
1506
|
}
|
|
@@ -1594,12 +1566,11 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1594
1566
|
});
|
|
1595
1567
|
}
|
|
1596
1568
|
async #listenFanoutMessage(data, message) {
|
|
1597
|
-
|
|
1569
|
+
getLogger([
|
|
1598
1570
|
"fedify",
|
|
1599
1571
|
"federation",
|
|
1600
1572
|
"fanout"
|
|
1601
|
-
])
|
|
1602
|
-
logger$2.debug("Fanning out activity {activityId} to {inboxes} inbox(es)...", {
|
|
1573
|
+
]).debug("Fanning out activity {activityId} to {inboxes} inbox(es)...", {
|
|
1603
1574
|
activityId: message.activityId,
|
|
1604
1575
|
inboxes: globalThis.Object.keys(message.inboxes).length
|
|
1605
1576
|
});
|
|
@@ -1618,17 +1589,17 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1618
1589
|
}),
|
|
1619
1590
|
tracerProvider: this.tracerProvider
|
|
1620
1591
|
});
|
|
1621
|
-
const context
|
|
1592
|
+
const context = this.#createContext(new URL(message.baseUrl), data, { documentLoader: this.documentLoaderFactory({
|
|
1622
1593
|
allowPrivateAddress: this.allowPrivateAddress,
|
|
1623
1594
|
userAgent: this.userAgent
|
|
1624
1595
|
}) });
|
|
1625
1596
|
await this.sendActivity(keys, message.inboxes, activity, {
|
|
1626
1597
|
collectionSync: message.collectionSync,
|
|
1627
|
-
context
|
|
1598
|
+
context
|
|
1628
1599
|
});
|
|
1629
1600
|
}
|
|
1630
1601
|
async #listenOutboxMessage(_, message, span) {
|
|
1631
|
-
const logger
|
|
1602
|
+
const logger = getLogger([
|
|
1632
1603
|
"fedify",
|
|
1633
1604
|
"federation",
|
|
1634
1605
|
"outbox"
|
|
@@ -1676,14 +1647,14 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1676
1647
|
});
|
|
1677
1648
|
try {
|
|
1678
1649
|
this.onOutboxError?.(error, activity);
|
|
1679
|
-
} catch (error
|
|
1680
|
-
logger
|
|
1650
|
+
} catch (error) {
|
|
1651
|
+
logger.error("An unexpected error occurred in onError handler:\n{error}", {
|
|
1681
1652
|
...logData,
|
|
1682
|
-
error
|
|
1653
|
+
error
|
|
1683
1654
|
});
|
|
1684
1655
|
}
|
|
1685
1656
|
if (this.outboxQueue?.nativeRetrial) {
|
|
1686
|
-
logger
|
|
1657
|
+
logger.error("Failed to send activity {activityId} to {inbox}; backend will handle retry:\n{error}", {
|
|
1687
1658
|
...logData,
|
|
1688
1659
|
error
|
|
1689
1660
|
});
|
|
@@ -1694,7 +1665,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1694
1665
|
attempts: message.attempt
|
|
1695
1666
|
});
|
|
1696
1667
|
if (delay != null) {
|
|
1697
|
-
logger
|
|
1668
|
+
logger.error("Failed to send activity {activityId} to {inbox} (attempt #{attempt}); retry...:\n{error}", {
|
|
1698
1669
|
...logData,
|
|
1699
1670
|
error
|
|
1700
1671
|
});
|
|
@@ -1702,39 +1673,38 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1702
1673
|
...message,
|
|
1703
1674
|
attempt: message.attempt + 1
|
|
1704
1675
|
}, { delay: Temporal.Duration.compare(delay, { seconds: 0 }) < 0 ? Temporal.Duration.from({ seconds: 0 }) : delay });
|
|
1705
|
-
} else logger
|
|
1676
|
+
} else logger.error("Failed to send activity {activityId} to {inbox} after {attempt} attempts; giving up:\n{error}", {
|
|
1706
1677
|
...logData,
|
|
1707
1678
|
error
|
|
1708
1679
|
});
|
|
1709
1680
|
return;
|
|
1710
1681
|
}
|
|
1711
|
-
logger
|
|
1682
|
+
logger.info("Successfully sent activity {activityId} to {inbox}.", { ...logData });
|
|
1712
1683
|
}
|
|
1713
1684
|
async #listenInboxMessage(ctxData, message, span) {
|
|
1714
|
-
const logger
|
|
1685
|
+
const logger = getLogger([
|
|
1715
1686
|
"fedify",
|
|
1716
1687
|
"federation",
|
|
1717
1688
|
"inbox"
|
|
1718
1689
|
]);
|
|
1719
1690
|
const baseUrl = new URL(message.baseUrl);
|
|
1720
|
-
let context
|
|
1721
|
-
if (message.identifier != null) context
|
|
1691
|
+
let context = this.#createContext(baseUrl, ctxData);
|
|
1692
|
+
if (message.identifier != null) context = this.#createContext(baseUrl, ctxData, { documentLoader: await context.getDocumentLoader({ identifier: message.identifier }) });
|
|
1722
1693
|
else if (this.sharedInboxKeyDispatcher != null) {
|
|
1723
|
-
const identity = await this.sharedInboxKeyDispatcher(context
|
|
1724
|
-
if (identity != null) context
|
|
1694
|
+
const identity = await this.sharedInboxKeyDispatcher(context);
|
|
1695
|
+
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) });
|
|
1725
1696
|
}
|
|
1726
|
-
const activity = await Activity.fromJsonLd(message.activity, context
|
|
1697
|
+
const activity = await Activity.fromJsonLd(message.activity, context);
|
|
1727
1698
|
span.setAttribute("activitypub.activity.type", getTypeId(activity).href);
|
|
1728
1699
|
if (activity.id != null) span.setAttribute("activitypub.activity.id", activity.id.href);
|
|
1729
1700
|
const cacheKey = activity.id == null ? null : [
|
|
1730
1701
|
...this.kvPrefixes.activityIdempotence,
|
|
1731
|
-
context
|
|
1702
|
+
context.origin,
|
|
1732
1703
|
activity.id.href
|
|
1733
1704
|
];
|
|
1734
1705
|
if (cacheKey != null) {
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
logger$2.debug("Activity {activityId} has already been processed.", {
|
|
1706
|
+
if (await this.kv.get(cacheKey) === true) {
|
|
1707
|
+
logger.debug("Activity {activityId} has already been processed.", {
|
|
1738
1708
|
activityId: activity.id?.href,
|
|
1739
1709
|
activity: message.activity,
|
|
1740
1710
|
recipient: message.identifier
|
|
@@ -1742,32 +1712,32 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1742
1712
|
return;
|
|
1743
1713
|
}
|
|
1744
1714
|
}
|
|
1745
|
-
await this._getTracer().startActiveSpan("activitypub.dispatch_inbox_listener", { kind: SpanKind.INTERNAL }, async (span
|
|
1715
|
+
await this._getTracer().startActiveSpan("activitypub.dispatch_inbox_listener", { kind: SpanKind.INTERNAL }, async (span) => {
|
|
1746
1716
|
const dispatched = this.inboxListeners?.dispatchWithClass(activity);
|
|
1747
1717
|
if (dispatched == null) {
|
|
1748
|
-
logger
|
|
1718
|
+
logger.error("Unsupported activity type:\n{activity}", {
|
|
1749
1719
|
activityId: activity.id?.href,
|
|
1750
1720
|
activity: message.activity,
|
|
1751
1721
|
recipient: message.identifier,
|
|
1752
1722
|
trial: message.attempt
|
|
1753
1723
|
});
|
|
1754
|
-
span
|
|
1724
|
+
span.setStatus({
|
|
1755
1725
|
code: SpanStatusCode.ERROR,
|
|
1756
1726
|
message: `Unsupported activity type: ${getTypeId(activity).href}`
|
|
1757
1727
|
});
|
|
1758
|
-
span
|
|
1728
|
+
span.end();
|
|
1759
1729
|
return;
|
|
1760
1730
|
}
|
|
1761
1731
|
const { class: cls, listener } = dispatched;
|
|
1762
|
-
span
|
|
1732
|
+
span.updateName(`activitypub.dispatch_inbox_listener ${cls.name}`);
|
|
1763
1733
|
try {
|
|
1764
|
-
await listener(context
|
|
1734
|
+
await listener(context.toInboxContext(message.identifier, message.activity, activity.id?.href, getTypeId(activity).href), activity);
|
|
1765
1735
|
} catch (error) {
|
|
1766
1736
|
try {
|
|
1767
|
-
await this.inboxErrorHandler?.(context
|
|
1768
|
-
} catch (error
|
|
1769
|
-
logger
|
|
1770
|
-
error
|
|
1737
|
+
await this.inboxErrorHandler?.(context, error);
|
|
1738
|
+
} catch (error) {
|
|
1739
|
+
logger.error("An unexpected error occurred in inbox error handler:\n{error}", {
|
|
1740
|
+
error,
|
|
1771
1741
|
trial: message.attempt,
|
|
1772
1742
|
activityId: activity.id?.href,
|
|
1773
1743
|
activity: message.activity,
|
|
@@ -1775,17 +1745,17 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1775
1745
|
});
|
|
1776
1746
|
}
|
|
1777
1747
|
if (this.inboxQueue?.nativeRetrial) {
|
|
1778
|
-
logger
|
|
1748
|
+
logger.error("Failed to process the incoming activity {activityId}; backend will handle retry:\n{error}", {
|
|
1779
1749
|
error,
|
|
1780
1750
|
activityId: activity.id?.href,
|
|
1781
1751
|
activity: message.activity,
|
|
1782
1752
|
recipient: message.identifier
|
|
1783
1753
|
});
|
|
1784
|
-
span
|
|
1754
|
+
span.setStatus({
|
|
1785
1755
|
code: SpanStatusCode.ERROR,
|
|
1786
1756
|
message: String(error)
|
|
1787
1757
|
});
|
|
1788
|
-
span
|
|
1758
|
+
span.end();
|
|
1789
1759
|
throw error;
|
|
1790
1760
|
}
|
|
1791
1761
|
const delay = this.inboxRetryPolicy({
|
|
@@ -1793,7 +1763,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1793
1763
|
attempts: message.attempt
|
|
1794
1764
|
});
|
|
1795
1765
|
if (delay != null) {
|
|
1796
|
-
logger
|
|
1766
|
+
logger.error("Failed to process the incoming activity {activityId} (attempt #{attempt}); retry...:\n{error}", {
|
|
1797
1767
|
error,
|
|
1798
1768
|
attempt: message.attempt,
|
|
1799
1769
|
activityId: activity.id?.href,
|
|
@@ -1804,26 +1774,26 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1804
1774
|
...message,
|
|
1805
1775
|
attempt: message.attempt + 1
|
|
1806
1776
|
}, { delay: Temporal.Duration.compare(delay, { seconds: 0 }) < 0 ? Temporal.Duration.from({ seconds: 0 }) : delay });
|
|
1807
|
-
} else logger
|
|
1777
|
+
} else logger.error("Failed to process the incoming activity {activityId} after {trial} attempts; giving up:\n{error}", {
|
|
1808
1778
|
error,
|
|
1809
1779
|
activityId: activity.id?.href,
|
|
1810
1780
|
activity: message.activity,
|
|
1811
1781
|
recipient: message.identifier
|
|
1812
1782
|
});
|
|
1813
|
-
span
|
|
1783
|
+
span.setStatus({
|
|
1814
1784
|
code: SpanStatusCode.ERROR,
|
|
1815
1785
|
message: String(error)
|
|
1816
1786
|
});
|
|
1817
|
-
span
|
|
1787
|
+
span.end();
|
|
1818
1788
|
return;
|
|
1819
1789
|
}
|
|
1820
1790
|
if (cacheKey != null) await this.kv.set(cacheKey, true, { ttl: Temporal.Duration.from({ days: 1 }) });
|
|
1821
|
-
logger
|
|
1791
|
+
logger.info("Activity {activityId} has been processed.", {
|
|
1822
1792
|
activityId: activity.id?.href,
|
|
1823
1793
|
activity: message.activity,
|
|
1824
1794
|
recipient: message.identifier
|
|
1825
1795
|
});
|
|
1826
|
-
span
|
|
1796
|
+
span.end();
|
|
1827
1797
|
});
|
|
1828
1798
|
}
|
|
1829
1799
|
startQueue(contextData, options = {}) {
|
|
@@ -1867,7 +1837,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1867
1837
|
};
|
|
1868
1838
|
}
|
|
1869
1839
|
async sendActivity(keys, inboxes, activity, options) {
|
|
1870
|
-
const logger
|
|
1840
|
+
const logger = getLogger([
|
|
1871
1841
|
"fedify",
|
|
1872
1842
|
"federation",
|
|
1873
1843
|
"outbox"
|
|
@@ -1901,7 +1871,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1901
1871
|
format: "compact",
|
|
1902
1872
|
contextLoader
|
|
1903
1873
|
});
|
|
1904
|
-
if (rsaKey == null) logger
|
|
1874
|
+
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.", {
|
|
1905
1875
|
activityId,
|
|
1906
1876
|
keys: keys.map((pair) => ({
|
|
1907
1877
|
keyId: pair.keyId.href,
|
|
@@ -1912,7 +1882,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1912
1882
|
contextLoader,
|
|
1913
1883
|
tracerProvider: this.tracerProvider
|
|
1914
1884
|
});
|
|
1915
|
-
if (!proofCreated) logger
|
|
1885
|
+
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.", {
|
|
1916
1886
|
activityId,
|
|
1917
1887
|
keys: keys.map((pair) => ({
|
|
1918
1888
|
keyId: pair.keyId.href,
|
|
@@ -1920,11 +1890,11 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1920
1890
|
}))
|
|
1921
1891
|
});
|
|
1922
1892
|
if (immediate || this.outboxQueue == null) {
|
|
1923
|
-
if (immediate) logger
|
|
1893
|
+
if (immediate) logger.debug("Sending activity immediately without queue since immediate option is set.", {
|
|
1924
1894
|
activityId: activity.id.href,
|
|
1925
1895
|
activity: jsonLd
|
|
1926
1896
|
});
|
|
1927
|
-
else logger
|
|
1897
|
+
else logger.debug("Sending activity immediately without queue since queue is not set.", {
|
|
1928
1898
|
activityId: activity.id.href,
|
|
1929
1899
|
activity: jsonLd
|
|
1930
1900
|
});
|
|
@@ -1943,7 +1913,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1943
1913
|
await Promise.all(promises);
|
|
1944
1914
|
return;
|
|
1945
1915
|
}
|
|
1946
|
-
logger
|
|
1916
|
+
logger.debug("Enqueuing activity {activityId} to send later.", {
|
|
1947
1917
|
activityId: activity.id.href,
|
|
1948
1918
|
activity: jsonLd
|
|
1949
1919
|
});
|
|
@@ -1980,10 +1950,9 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1980
1950
|
const { outboxQueue } = this;
|
|
1981
1951
|
if (outboxQueue.enqueueMany == null) {
|
|
1982
1952
|
const promises = messages.map((m) => outboxQueue.enqueue(m));
|
|
1983
|
-
const
|
|
1984
|
-
const errors = results.filter((r) => r.status === "rejected").map((r) => r.reason);
|
|
1953
|
+
const errors = (await Promise.allSettled(promises)).filter((r) => r.status === "rejected").map((r) => r.reason);
|
|
1985
1954
|
if (errors.length > 0) {
|
|
1986
|
-
logger
|
|
1955
|
+
logger.error("Failed to enqueue activity {activityId} to send later: {errors}", {
|
|
1987
1956
|
activityId: activity.id.href,
|
|
1988
1957
|
errors
|
|
1989
1958
|
});
|
|
@@ -1993,7 +1962,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
1993
1962
|
} else try {
|
|
1994
1963
|
await outboxQueue.enqueueMany(messages);
|
|
1995
1964
|
} catch (error) {
|
|
1996
|
-
logger
|
|
1965
|
+
logger.error("Failed to enqueue activity {activityId} to send later: {error}", {
|
|
1997
1966
|
activityId: activity.id.href,
|
|
1998
1967
|
error
|
|
1999
1968
|
});
|
|
@@ -2001,8 +1970,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2001
1970
|
}
|
|
2002
1971
|
}
|
|
2003
1972
|
fetch(request, options) {
|
|
2004
|
-
|
|
2005
|
-
return withContext({ requestId }, async () => {
|
|
1973
|
+
return withContext({ requestId: getRequestId(request) }, async () => {
|
|
2006
1974
|
const tracer = this._getTracer();
|
|
2007
1975
|
return await tracer.startActiveSpan(request.method, {
|
|
2008
1976
|
kind: SpanKind.SERVER,
|
|
@@ -2011,7 +1979,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2011
1979
|
[ATTR_URL_FULL]: request.url
|
|
2012
1980
|
}
|
|
2013
1981
|
}, async (span) => {
|
|
2014
|
-
const logger
|
|
1982
|
+
const logger = getLogger([
|
|
2015
1983
|
"fedify",
|
|
2016
1984
|
"federation",
|
|
2017
1985
|
"http"
|
|
@@ -2030,7 +1998,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2030
1998
|
message: `${error}`
|
|
2031
1999
|
});
|
|
2032
2000
|
span.end();
|
|
2033
|
-
logger
|
|
2001
|
+
logger.error("An error occurred while serving request {method} {url}: {error}", {
|
|
2034
2002
|
method: request.method,
|
|
2035
2003
|
url: request.url,
|
|
2036
2004
|
error
|
|
@@ -2054,9 +2022,9 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2054
2022
|
url: request.url,
|
|
2055
2023
|
status: response.status
|
|
2056
2024
|
};
|
|
2057
|
-
if (response.status >= 500) logger
|
|
2058
|
-
else if (response.status >= 400) logger
|
|
2059
|
-
else logger
|
|
2025
|
+
if (response.status >= 500) logger.error(logTpl, values);
|
|
2026
|
+
else if (response.status >= 400) logger.warn(logTpl, values);
|
|
2027
|
+
else logger.info(logTpl, values);
|
|
2060
2028
|
return response;
|
|
2061
2029
|
});
|
|
2062
2030
|
});
|
|
@@ -2069,11 +2037,11 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2069
2037
|
const route = this.router.route(url.pathname);
|
|
2070
2038
|
if (route == null) return await onNotFound(request);
|
|
2071
2039
|
span.updateName(`${request.method} ${route.template}`);
|
|
2072
|
-
let context
|
|
2040
|
+
let context = this.#createContext(request, contextData);
|
|
2073
2041
|
const routeName = route.name.replace(/:.*$/, "");
|
|
2074
2042
|
switch (routeName) {
|
|
2075
2043
|
case "webfinger": return await handleWebFinger(request, {
|
|
2076
|
-
context
|
|
2044
|
+
context,
|
|
2077
2045
|
host: this.origin?.handleHost,
|
|
2078
2046
|
actorDispatcher: this.actorCallbacks?.dispatcher,
|
|
2079
2047
|
actorHandleMapper: this.actorCallbacks?.handleMapper,
|
|
@@ -2082,16 +2050,16 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2082
2050
|
onNotFound,
|
|
2083
2051
|
tracer
|
|
2084
2052
|
});
|
|
2085
|
-
case "nodeInfoJrd": return await handleNodeInfoJrd(request, context
|
|
2053
|
+
case "nodeInfoJrd": return await handleNodeInfoJrd(request, context);
|
|
2086
2054
|
case "nodeInfo": return await handleNodeInfo(request, {
|
|
2087
|
-
context
|
|
2055
|
+
context,
|
|
2088
2056
|
nodeInfoDispatcher: this.nodeInfoDispatcher
|
|
2089
2057
|
});
|
|
2090
2058
|
case "actor":
|
|
2091
|
-
context
|
|
2059
|
+
context = this.#createContext(request, contextData, { invokedFromActorDispatcher: { identifier: route.values.identifier ?? route.values.handle } });
|
|
2092
2060
|
return await handleActor(request, {
|
|
2093
2061
|
identifier: route.values.identifier ?? route.values.handle,
|
|
2094
|
-
context
|
|
2062
|
+
context,
|
|
2095
2063
|
actorDispatcher: this.actorCallbacks?.dispatcher,
|
|
2096
2064
|
authorizePredicate: this.actorCallbacks?.authorizePredicate,
|
|
2097
2065
|
onUnauthorized,
|
|
@@ -2102,13 +2070,13 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2102
2070
|
const typeId = route.name.replace(/^object:/, "");
|
|
2103
2071
|
const callbacks = this.objectCallbacks[typeId];
|
|
2104
2072
|
const cls = this.objectTypeIds[typeId];
|
|
2105
|
-
context
|
|
2073
|
+
context = this.#createContext(request, contextData, { invokedFromObjectDispatcher: {
|
|
2106
2074
|
cls,
|
|
2107
2075
|
values: route.values
|
|
2108
2076
|
} });
|
|
2109
2077
|
return await handleObject(request, {
|
|
2110
2078
|
values: route.values,
|
|
2111
|
-
context
|
|
2079
|
+
context,
|
|
2112
2080
|
objectDispatcher: callbacks?.dispatcher,
|
|
2113
2081
|
authorizePredicate: callbacks?.authorizePredicate,
|
|
2114
2082
|
onUnauthorized,
|
|
@@ -2119,8 +2087,8 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2119
2087
|
case "outbox": return await handleCollection(request, {
|
|
2120
2088
|
name: "outbox",
|
|
2121
2089
|
identifier: route.values.identifier ?? route.values.handle,
|
|
2122
|
-
uriGetter: context
|
|
2123
|
-
context
|
|
2090
|
+
uriGetter: context.getOutboxUri.bind(context),
|
|
2091
|
+
context,
|
|
2124
2092
|
collectionCallbacks: this.outboxCallbacks,
|
|
2125
2093
|
tracerProvider: this.tracerProvider,
|
|
2126
2094
|
onUnauthorized,
|
|
@@ -2131,25 +2099,25 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2131
2099
|
if (request.method !== "POST") return await handleCollection(request, {
|
|
2132
2100
|
name: "inbox",
|
|
2133
2101
|
identifier: route.values.identifier ?? route.values.handle,
|
|
2134
|
-
uriGetter: context
|
|
2135
|
-
context
|
|
2102
|
+
uriGetter: context.getInboxUri.bind(context),
|
|
2103
|
+
context,
|
|
2136
2104
|
collectionCallbacks: this.inboxCallbacks,
|
|
2137
2105
|
tracerProvider: this.tracerProvider,
|
|
2138
2106
|
onUnauthorized,
|
|
2139
2107
|
onNotFound,
|
|
2140
2108
|
onNotAcceptable
|
|
2141
2109
|
});
|
|
2142
|
-
context
|
|
2110
|
+
context = this.#createContext(request, contextData, { documentLoader: await context.getDocumentLoader({ identifier: route.values.identifier ?? route.values.handle }) });
|
|
2143
2111
|
case "sharedInbox":
|
|
2144
2112
|
if (routeName !== "inbox" && this.sharedInboxKeyDispatcher != null) {
|
|
2145
|
-
const identity = await this.sharedInboxKeyDispatcher(context
|
|
2146
|
-
if (identity != null) context
|
|
2113
|
+
const identity = await this.sharedInboxKeyDispatcher(context);
|
|
2114
|
+
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) });
|
|
2147
2115
|
}
|
|
2148
2116
|
if (!this.manuallyStartQueue) this._startQueueInternal(contextData);
|
|
2149
2117
|
return await handleInbox(request, {
|
|
2150
2118
|
recipient: route.values.identifier ?? route.values.handle ?? null,
|
|
2151
|
-
context
|
|
2152
|
-
inboxContextFactory: context
|
|
2119
|
+
context,
|
|
2120
|
+
inboxContextFactory: context.toInboxContext.bind(context),
|
|
2153
2121
|
kv: this.kv,
|
|
2154
2122
|
kvPrefixes: this.kvPrefixes,
|
|
2155
2123
|
queue: this.inboxQueue,
|
|
@@ -2165,8 +2133,8 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2165
2133
|
case "following": return await handleCollection(request, {
|
|
2166
2134
|
name: "following",
|
|
2167
2135
|
identifier: route.values.identifier ?? route.values.handle,
|
|
2168
|
-
uriGetter: context
|
|
2169
|
-
context
|
|
2136
|
+
uriGetter: context.getFollowingUri.bind(context),
|
|
2137
|
+
context,
|
|
2170
2138
|
collectionCallbacks: this.followingCallbacks,
|
|
2171
2139
|
tracerProvider: this.tracerProvider,
|
|
2172
2140
|
onUnauthorized,
|
|
@@ -2183,14 +2151,14 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2183
2151
|
return await handleCollection(request, {
|
|
2184
2152
|
name: "followers",
|
|
2185
2153
|
identifier: route.values.identifier ?? route.values.handle,
|
|
2186
|
-
uriGetter: baseUrl == null ? context
|
|
2187
|
-
const uri = context
|
|
2154
|
+
uriGetter: baseUrl == null ? context.getFollowersUri.bind(context) : (identifier) => {
|
|
2155
|
+
const uri = context.getFollowersUri(identifier);
|
|
2188
2156
|
uri.searchParams.set("base-url", baseUrl);
|
|
2189
2157
|
return uri;
|
|
2190
2158
|
},
|
|
2191
|
-
context
|
|
2159
|
+
context,
|
|
2192
2160
|
filter: baseUrl != null ? new URL(baseUrl) : void 0,
|
|
2193
|
-
filterPredicate: baseUrl != null ? (i) => (i instanceof URL ? i.href : i.id?.href ?? "").startsWith(baseUrl) : void 0,
|
|
2161
|
+
filterPredicate: baseUrl != null ? ((i) => (i instanceof URL ? i.href : i.id?.href ?? "").startsWith(baseUrl)) : void 0,
|
|
2194
2162
|
collectionCallbacks: this.followersCallbacks,
|
|
2195
2163
|
tracerProvider: this.tracerProvider,
|
|
2196
2164
|
onUnauthorized,
|
|
@@ -2201,8 +2169,8 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2201
2169
|
case "liked": return await handleCollection(request, {
|
|
2202
2170
|
name: "liked",
|
|
2203
2171
|
identifier: route.values.identifier ?? route.values.handle,
|
|
2204
|
-
uriGetter: context
|
|
2205
|
-
context
|
|
2172
|
+
uriGetter: context.getLikedUri.bind(context),
|
|
2173
|
+
context,
|
|
2206
2174
|
collectionCallbacks: this.likedCallbacks,
|
|
2207
2175
|
tracerProvider: this.tracerProvider,
|
|
2208
2176
|
onUnauthorized,
|
|
@@ -2212,8 +2180,8 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2212
2180
|
case "featured": return await handleCollection(request, {
|
|
2213
2181
|
name: "featured",
|
|
2214
2182
|
identifier: route.values.identifier ?? route.values.handle,
|
|
2215
|
-
uriGetter: context
|
|
2216
|
-
context
|
|
2183
|
+
uriGetter: context.getFeaturedUri.bind(context),
|
|
2184
|
+
context,
|
|
2217
2185
|
collectionCallbacks: this.featuredCallbacks,
|
|
2218
2186
|
tracerProvider: this.tracerProvider,
|
|
2219
2187
|
onUnauthorized,
|
|
@@ -2223,8 +2191,8 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2223
2191
|
case "featuredTags": return await handleCollection(request, {
|
|
2224
2192
|
name: "featured tags",
|
|
2225
2193
|
identifier: route.values.identifier ?? route.values.handle,
|
|
2226
|
-
uriGetter: context
|
|
2227
|
-
context
|
|
2194
|
+
uriGetter: context.getFeaturedTagsUri.bind(context),
|
|
2195
|
+
context,
|
|
2228
2196
|
collectionCallbacks: this.featuredTagsCallbacks,
|
|
2229
2197
|
tracerProvider: this.tracerProvider,
|
|
2230
2198
|
onUnauthorized,
|
|
@@ -2236,7 +2204,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2236
2204
|
const callbacks = this.collectionCallbacks[name];
|
|
2237
2205
|
return await handleCustomCollection(request, {
|
|
2238
2206
|
name,
|
|
2239
|
-
context
|
|
2207
|
+
context,
|
|
2240
2208
|
values: route.values,
|
|
2241
2209
|
collectionCallbacks: callbacks,
|
|
2242
2210
|
tracerProvider: this.tracerProvider,
|
|
@@ -2250,7 +2218,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2250
2218
|
const callbacks = this.collectionCallbacks[name];
|
|
2251
2219
|
return await handleOrderedCollection(request, {
|
|
2252
2220
|
name,
|
|
2253
|
-
context
|
|
2221
|
+
context,
|
|
2254
2222
|
values: route.values,
|
|
2255
2223
|
collectionCallbacks: callbacks,
|
|
2256
2224
|
tracerProvider: this.tracerProvider,
|
|
@@ -2348,9 +2316,9 @@ var ContextImpl = class ContextImpl {
|
|
|
2348
2316
|
}
|
|
2349
2317
|
getInboxUri(identifier) {
|
|
2350
2318
|
if (identifier == null) {
|
|
2351
|
-
const path
|
|
2352
|
-
if (path
|
|
2353
|
-
return new URL(path
|
|
2319
|
+
const path = this.federation.router.build("sharedInbox", {});
|
|
2320
|
+
if (path == null) throw new RouterError("No shared inbox path registered.");
|
|
2321
|
+
return new URL(path, this.canonicalOrigin);
|
|
2354
2322
|
}
|
|
2355
2323
|
const path = this.federation.router.build("inbox", {
|
|
2356
2324
|
identifier,
|
|
@@ -2408,14 +2376,13 @@ var ContextImpl = class ContextImpl {
|
|
|
2408
2376
|
if (uri == null) return null;
|
|
2409
2377
|
if (uri.origin !== this.origin && uri.origin !== this.canonicalOrigin) return null;
|
|
2410
2378
|
const route = this.federation.router.route(uri.pathname);
|
|
2411
|
-
const logger
|
|
2379
|
+
const logger = getLogger(["fedify", "federation"]);
|
|
2412
2380
|
if (route == null) return null;
|
|
2413
2381
|
else if (route.name === "sharedInbox") return {
|
|
2414
2382
|
type: "inbox",
|
|
2415
2383
|
identifier: void 0,
|
|
2416
2384
|
get handle() {
|
|
2417
|
-
logger
|
|
2418
|
-
return void 0;
|
|
2385
|
+
logger.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
|
|
2419
2386
|
}
|
|
2420
2387
|
};
|
|
2421
2388
|
const identifier = "identifier" in route.values ? route.values.identifier : route.values.handle;
|
|
@@ -2423,7 +2390,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2423
2390
|
type: "actor",
|
|
2424
2391
|
identifier,
|
|
2425
2392
|
get handle() {
|
|
2426
|
-
logger
|
|
2393
|
+
logger.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
|
|
2427
2394
|
return identifier;
|
|
2428
2395
|
}
|
|
2429
2396
|
};
|
|
@@ -2439,7 +2406,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2439
2406
|
type: "inbox",
|
|
2440
2407
|
identifier,
|
|
2441
2408
|
get handle() {
|
|
2442
|
-
logger
|
|
2409
|
+
logger.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
|
|
2443
2410
|
return identifier;
|
|
2444
2411
|
}
|
|
2445
2412
|
};
|
|
@@ -2447,7 +2414,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2447
2414
|
type: "outbox",
|
|
2448
2415
|
identifier,
|
|
2449
2416
|
get handle() {
|
|
2450
|
-
logger
|
|
2417
|
+
logger.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
|
|
2451
2418
|
return identifier;
|
|
2452
2419
|
}
|
|
2453
2420
|
};
|
|
@@ -2455,7 +2422,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2455
2422
|
type: "following",
|
|
2456
2423
|
identifier,
|
|
2457
2424
|
get handle() {
|
|
2458
|
-
logger
|
|
2425
|
+
logger.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
|
|
2459
2426
|
return identifier;
|
|
2460
2427
|
}
|
|
2461
2428
|
};
|
|
@@ -2463,7 +2430,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2463
2430
|
type: "followers",
|
|
2464
2431
|
identifier,
|
|
2465
2432
|
get handle() {
|
|
2466
|
-
logger
|
|
2433
|
+
logger.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
|
|
2467
2434
|
return identifier;
|
|
2468
2435
|
}
|
|
2469
2436
|
};
|
|
@@ -2471,7 +2438,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2471
2438
|
type: "liked",
|
|
2472
2439
|
identifier,
|
|
2473
2440
|
get handle() {
|
|
2474
|
-
logger
|
|
2441
|
+
logger.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
|
|
2475
2442
|
return identifier;
|
|
2476
2443
|
}
|
|
2477
2444
|
};
|
|
@@ -2479,7 +2446,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2479
2446
|
type: "featured",
|
|
2480
2447
|
identifier,
|
|
2481
2448
|
get handle() {
|
|
2482
|
-
logger
|
|
2449
|
+
logger.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
|
|
2483
2450
|
return identifier;
|
|
2484
2451
|
}
|
|
2485
2452
|
};
|
|
@@ -2487,12 +2454,11 @@ var ContextImpl = class ContextImpl {
|
|
|
2487
2454
|
type: "featuredTags",
|
|
2488
2455
|
identifier,
|
|
2489
2456
|
get handle() {
|
|
2490
|
-
logger
|
|
2457
|
+
logger.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
|
|
2491
2458
|
return identifier;
|
|
2492
2459
|
}
|
|
2493
2460
|
};
|
|
2494
|
-
const
|
|
2495
|
-
const collectionRegex = /* @__PURE__ */ new RegExp(`^(${collectionTypes.join("|")}):(.*)$`);
|
|
2461
|
+
const collectionRegex = new RegExp(`^(${["collection", "orderedCollection"].join("|")}):(.*)$`);
|
|
2496
2462
|
const match = route.name.match(collectionRegex);
|
|
2497
2463
|
if (match !== null) {
|
|
2498
2464
|
const [, type, name] = match;
|
|
@@ -2508,12 +2474,12 @@ var ContextImpl = class ContextImpl {
|
|
|
2508
2474
|
return null;
|
|
2509
2475
|
}
|
|
2510
2476
|
async getActorKeyPairs(identifier) {
|
|
2511
|
-
const logger
|
|
2477
|
+
const logger = getLogger([
|
|
2512
2478
|
"fedify",
|
|
2513
2479
|
"federation",
|
|
2514
2480
|
"actor"
|
|
2515
2481
|
]);
|
|
2516
|
-
if (this.invokedFromActorKeyPairsDispatcher != null) logger
|
|
2482
|
+
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.", {
|
|
2517
2483
|
getActorKeyPairsIdentifier: identifier,
|
|
2518
2484
|
actorKeyPairsDispatcherIdentifier: this.invokedFromActorKeyPairsDispatcher.identifier
|
|
2519
2485
|
});
|
|
@@ -2521,7 +2487,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2521
2487
|
try {
|
|
2522
2488
|
keyPairs = await this.getKeyPairsFromIdentifier(identifier);
|
|
2523
2489
|
} catch (_) {
|
|
2524
|
-
logger
|
|
2490
|
+
logger.warn("No actor key pairs dispatcher registered.");
|
|
2525
2491
|
return [];
|
|
2526
2492
|
}
|
|
2527
2493
|
const owner = this.getActorUri(identifier);
|
|
@@ -2545,7 +2511,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2545
2511
|
return result;
|
|
2546
2512
|
}
|
|
2547
2513
|
async getKeyPairsFromIdentifier(identifier) {
|
|
2548
|
-
const logger
|
|
2514
|
+
const logger = getLogger([
|
|
2549
2515
|
"fedify",
|
|
2550
2516
|
"federation",
|
|
2551
2517
|
"actor"
|
|
@@ -2556,7 +2522,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2556
2522
|
actorUri = this.getActorUri(identifier);
|
|
2557
2523
|
} catch (error) {
|
|
2558
2524
|
if (error instanceof RouterError) {
|
|
2559
|
-
logger
|
|
2525
|
+
logger.warn(error.message);
|
|
2560
2526
|
return [];
|
|
2561
2527
|
}
|
|
2562
2528
|
throw error;
|
|
@@ -2565,7 +2531,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2565
2531
|
...this,
|
|
2566
2532
|
invokedFromActorKeyPairsDispatcher: { identifier }
|
|
2567
2533
|
}), identifier);
|
|
2568
|
-
if (keyPairs.length < 1) logger
|
|
2534
|
+
if (keyPairs.length < 1) logger.warn("No key pairs found for actor {identifier}.", { identifier });
|
|
2569
2535
|
let i = 0;
|
|
2570
2536
|
const result = [];
|
|
2571
2537
|
for (const keyPair of keyPairs) {
|
|
@@ -2613,8 +2579,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2613
2579
|
} else identifierPromise = Promise.resolve(identity.identifier);
|
|
2614
2580
|
return identifierPromise.then((identifier) => {
|
|
2615
2581
|
if (identifier == null) return this.documentLoader;
|
|
2616
|
-
|
|
2617
|
-
return keyPair.then((pair) => pair == null ? this.documentLoader : this.federation.authenticatedDocumentLoaderFactory(pair));
|
|
2582
|
+
return this.getRsaKeyPairFromIdentifier(identifier).then((pair) => pair == null ? this.documentLoader : this.federation.authenticatedDocumentLoaderFactory(pair));
|
|
2618
2583
|
});
|
|
2619
2584
|
}
|
|
2620
2585
|
return this.federation.authenticatedDocumentLoaderFactory(identity);
|
|
@@ -2656,8 +2621,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2656
2621
|
});
|
|
2657
2622
|
}
|
|
2658
2623
|
sendActivity(sender, recipients, activity, options = {}) {
|
|
2659
|
-
|
|
2660
|
-
return tracer.startActiveSpan(this.federation.outboxQueue == null || options.immediate ? "activitypub.outbox" : "activitypub.fanout", {
|
|
2624
|
+
return this.tracerProvider.getTracer(name, version).startActiveSpan(this.federation.outboxQueue == null || options.immediate ? "activitypub.outbox" : "activitypub.fanout", {
|
|
2661
2625
|
kind: this.federation.outboxQueue == null || options.immediate ? SpanKind.CLIENT : SpanKind.PRODUCER,
|
|
2662
2626
|
attributes: {
|
|
2663
2627
|
"activitypub.activity.type": getTypeId(activity).href,
|
|
@@ -2682,7 +2646,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2682
2646
|
});
|
|
2683
2647
|
}
|
|
2684
2648
|
async sendActivityInternal(sender, recipients, activity, options, span) {
|
|
2685
|
-
const logger
|
|
2649
|
+
const logger = getLogger([
|
|
2686
2650
|
"fedify",
|
|
2687
2651
|
"federation",
|
|
2688
2652
|
"outbox"
|
|
@@ -2696,7 +2660,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2696
2660
|
if ("username" in sender) username = sender.username;
|
|
2697
2661
|
else {
|
|
2698
2662
|
username = sender.handle;
|
|
2699
|
-
logger
|
|
2663
|
+
logger.warn("The \"handle\" property for the sender parameter is deprecated; use \"identifier\" or \"username\" instead.", { sender });
|
|
2700
2664
|
}
|
|
2701
2665
|
if (this.federation.actorCallbacks?.handleMapper == null) identifier = username;
|
|
2702
2666
|
else {
|
|
@@ -2732,7 +2696,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2732
2696
|
for (const activityTransformer of this.federation.activityTransformers) activity = activityTransformer(activity, this);
|
|
2733
2697
|
span?.setAttribute("activitypub.activity.id", activity?.id?.href ?? "");
|
|
2734
2698
|
if (activity.actorId == null) {
|
|
2735
|
-
logger
|
|
2699
|
+
logger.error("Activity {activityId} to send does not have an actor.", {
|
|
2736
2700
|
activity,
|
|
2737
2701
|
activityId: activity?.id?.href
|
|
2738
2702
|
});
|
|
@@ -2743,7 +2707,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2743
2707
|
preferSharedInbox: options.preferSharedInbox,
|
|
2744
2708
|
excludeBaseUris: options.excludeBaseUris
|
|
2745
2709
|
});
|
|
2746
|
-
logger
|
|
2710
|
+
logger.debug("Sending activity {activityId} to inboxes:\n{inboxes}", {
|
|
2747
2711
|
inboxes: globalThis.Object.keys(inboxes),
|
|
2748
2712
|
activityId: activity.id?.href,
|
|
2749
2713
|
activity
|
|
@@ -2777,7 +2741,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2777
2741
|
traceContext: carrier
|
|
2778
2742
|
};
|
|
2779
2743
|
if (!this.federation.manuallyStartQueue) this.federation._startQueueInternal(this.data);
|
|
2780
|
-
this.federation.fanoutQueue.enqueue(message);
|
|
2744
|
+
await this.federation.fanoutQueue.enqueue(message);
|
|
2781
2745
|
}
|
|
2782
2746
|
async *getFollowers(identifier) {
|
|
2783
2747
|
if (this.federation.followersCallbacks == null) throw new Error("No followers collection dispatcher registered.");
|
|
@@ -2794,16 +2758,14 @@ var ContextImpl = class ContextImpl {
|
|
|
2794
2758
|
"outbox"
|
|
2795
2759
|
]).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 });
|
|
2796
2760
|
while (cursor != null) {
|
|
2797
|
-
const result
|
|
2798
|
-
if (result
|
|
2799
|
-
for (const recipient of result
|
|
2800
|
-
cursor = result
|
|
2761
|
+
const result = await this.federation.followersCallbacks.dispatcher(this, identifier, cursor);
|
|
2762
|
+
if (result == null) break;
|
|
2763
|
+
for (const recipient of result.items) yield recipient;
|
|
2764
|
+
cursor = result.nextCursor ?? null;
|
|
2801
2765
|
}
|
|
2802
2766
|
}
|
|
2803
2767
|
routeActivity(recipient, activity, options = {}) {
|
|
2804
|
-
|
|
2805
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
2806
|
-
return tracer.startActiveSpan("activitypub.inbox", {
|
|
2768
|
+
return (this.tracerProvider ?? this.tracerProvider).getTracer(name, version).startActiveSpan("activitypub.inbox", {
|
|
2807
2769
|
kind: this.federation.inboxQueue == null || options.immediate ? SpanKind.INTERNAL : SpanKind.PRODUCER,
|
|
2808
2770
|
attributes: { "activitypub.activity.type": getTypeId(activity).href }
|
|
2809
2771
|
}, async (span) => {
|
|
@@ -2831,7 +2793,7 @@ var ContextImpl = class ContextImpl {
|
|
|
2831
2793
|
});
|
|
2832
2794
|
}
|
|
2833
2795
|
async routeActivityInternal(recipient, activity, options = {}, span) {
|
|
2834
|
-
const logger
|
|
2796
|
+
const logger = getLogger([
|
|
2835
2797
|
"fedify",
|
|
2836
2798
|
"federation",
|
|
2837
2799
|
"inbox"
|
|
@@ -2839,19 +2801,18 @@ var ContextImpl = class ContextImpl {
|
|
|
2839
2801
|
const contextLoader = options.contextLoader ?? this.contextLoader;
|
|
2840
2802
|
const json = await activity.toJsonLd({ contextLoader });
|
|
2841
2803
|
const keyCache = new KvKeyCache(this.federation.kv, this.federation.kvPrefixes.publicKey, this);
|
|
2842
|
-
|
|
2804
|
+
if (await verifyObject(Activity, json, {
|
|
2843
2805
|
contextLoader,
|
|
2844
2806
|
documentLoader: options.documentLoader ?? this.documentLoader,
|
|
2845
2807
|
tracerProvider: options.tracerProvider ?? this.tracerProvider,
|
|
2846
2808
|
keyCache
|
|
2847
|
-
})
|
|
2848
|
-
|
|
2849
|
-
logger$2.debug("Object Integrity Proofs are not verified.", {
|
|
2809
|
+
}) == null) {
|
|
2810
|
+
logger.debug("Object Integrity Proofs are not verified.", {
|
|
2850
2811
|
recipient,
|
|
2851
2812
|
activity: json
|
|
2852
2813
|
});
|
|
2853
2814
|
if (activity.id == null) {
|
|
2854
|
-
logger
|
|
2815
|
+
logger.debug("Activity is missing an ID; unable to fetch.", {
|
|
2855
2816
|
recipient,
|
|
2856
2817
|
activity: json
|
|
2857
2818
|
});
|
|
@@ -2859,26 +2820,26 @@ var ContextImpl = class ContextImpl {
|
|
|
2859
2820
|
}
|
|
2860
2821
|
const fetched = await this.lookupObject(activity.id, options);
|
|
2861
2822
|
if (fetched == null) {
|
|
2862
|
-
logger
|
|
2823
|
+
logger.debug("Failed to fetch the remote activity object {activityId}.", {
|
|
2863
2824
|
recipient,
|
|
2864
2825
|
activity: json,
|
|
2865
2826
|
activityId: activity.id.href
|
|
2866
2827
|
});
|
|
2867
2828
|
return false;
|
|
2868
2829
|
} else if (!(fetched instanceof Activity)) {
|
|
2869
|
-
logger
|
|
2830
|
+
logger.debug("Fetched object is not an Activity.", {
|
|
2870
2831
|
recipient,
|
|
2871
2832
|
activity: await fetched.toJsonLd({ contextLoader })
|
|
2872
2833
|
});
|
|
2873
2834
|
return false;
|
|
2874
2835
|
} else if (fetched.id?.href !== activity.id.href) {
|
|
2875
|
-
logger
|
|
2836
|
+
logger.debug("Fetched activity object has a different ID; failed to verify.", {
|
|
2876
2837
|
recipient,
|
|
2877
2838
|
activity: await fetched.toJsonLd({ contextLoader })
|
|
2878
2839
|
});
|
|
2879
2840
|
return false;
|
|
2880
2841
|
} else if (fetched.actorIds.length < 1) {
|
|
2881
|
-
logger
|
|
2842
|
+
logger.debug("Fetched activity object is missing an actor; unable to verify.", {
|
|
2882
2843
|
recipient,
|
|
2883
2844
|
activity: await fetched.toJsonLd({ contextLoader })
|
|
2884
2845
|
});
|
|
@@ -2886,15 +2847,15 @@ var ContextImpl = class ContextImpl {
|
|
|
2886
2847
|
}
|
|
2887
2848
|
const activityId = fetched.id;
|
|
2888
2849
|
if (!fetched.actorIds.every((actor) => actor.origin === activityId.origin)) {
|
|
2889
|
-
logger
|
|
2850
|
+
logger.debug("Fetched activity object has actors from different origins; unable to verify.", {
|
|
2890
2851
|
recipient,
|
|
2891
2852
|
activity: await fetched.toJsonLd({ contextLoader })
|
|
2892
2853
|
});
|
|
2893
2854
|
return false;
|
|
2894
2855
|
}
|
|
2895
|
-
logger
|
|
2856
|
+
logger.debug("Successfully fetched the remote activity object {activityId}; ignore the original activity and use the fetched one, which is trustworthy.");
|
|
2896
2857
|
activity = fetched;
|
|
2897
|
-
} else logger
|
|
2858
|
+
} else logger.debug("Object Integrity Proofs are verified.", {
|
|
2898
2859
|
recipient,
|
|
2899
2860
|
activity: json
|
|
2900
2861
|
});
|
|
@@ -3020,8 +2981,7 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
|
|
|
3020
2981
|
});
|
|
3021
2982
|
}
|
|
3022
2983
|
forwardActivity(forwarder, recipients, options) {
|
|
3023
|
-
|
|
3024
|
-
return tracer.startActiveSpan("activitypub.outbox", {
|
|
2984
|
+
return this.tracerProvider.getTracer(name, version).startActiveSpan("activitypub.outbox", {
|
|
3025
2985
|
kind: this.federation.outboxQueue == null || options?.immediate ? SpanKind.CLIENT : SpanKind.PRODUCER,
|
|
3026
2986
|
attributes: { "activitypub.activity.type": this.activityType }
|
|
3027
2987
|
}, async (span) => {
|
|
@@ -3040,7 +3000,7 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
|
|
|
3040
3000
|
});
|
|
3041
3001
|
}
|
|
3042
3002
|
async forwardActivityInternal(forwarder, recipients, options) {
|
|
3043
|
-
const logger
|
|
3003
|
+
const logger = getLogger([
|
|
3044
3004
|
"fedify",
|
|
3045
3005
|
"federation",
|
|
3046
3006
|
"inbox"
|
|
@@ -3054,7 +3014,7 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
|
|
|
3054
3014
|
if ("username" in forwarder) username = forwarder.username;
|
|
3055
3015
|
else {
|
|
3056
3016
|
username = forwarder.handle;
|
|
3057
|
-
logger
|
|
3017
|
+
logger.warn("The \"handle\" property for the forwarder parameter is deprecated; use \"identifier\" or \"username\" instead.", { forwarder });
|
|
3058
3018
|
}
|
|
3059
3019
|
if (this.federation.actorCallbacks?.handleMapper == null) identifier = username;
|
|
3060
3020
|
else {
|
|
@@ -3072,14 +3032,13 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
|
|
|
3072
3032
|
if (!hasSignature(this.activity)) {
|
|
3073
3033
|
let hasProof;
|
|
3074
3034
|
try {
|
|
3075
|
-
|
|
3076
|
-
hasProof = await activity.getProof() != null;
|
|
3035
|
+
hasProof = await (await Activity.fromJsonLd(this.activity, this)).getProof() != null;
|
|
3077
3036
|
} catch {
|
|
3078
3037
|
hasProof = false;
|
|
3079
3038
|
}
|
|
3080
3039
|
if (!hasProof) {
|
|
3081
3040
|
if (options?.skipIfUnsigned) return;
|
|
3082
|
-
logger
|
|
3041
|
+
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.");
|
|
3083
3042
|
}
|
|
3084
3043
|
}
|
|
3085
3044
|
if (recipients === "followers") {
|
|
@@ -3093,14 +3052,14 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
|
|
|
3093
3052
|
preferSharedInbox: options?.preferSharedInbox,
|
|
3094
3053
|
excludeBaseUris: options?.excludeBaseUris
|
|
3095
3054
|
});
|
|
3096
|
-
logger
|
|
3055
|
+
logger.debug("Forwarding activity {activityId} to inboxes:\n{inboxes}", {
|
|
3097
3056
|
inboxes: globalThis.Object.keys(inboxes),
|
|
3098
3057
|
activityId: this.activityId,
|
|
3099
3058
|
activity: this.activity
|
|
3100
3059
|
});
|
|
3101
3060
|
if (options?.immediate || this.federation.outboxQueue == null) {
|
|
3102
|
-
if (options?.immediate) logger
|
|
3103
|
-
else logger
|
|
3061
|
+
if (options?.immediate) logger.debug("Forwarding activity immediately without queue since immediate option is set.");
|
|
3062
|
+
else logger.debug("Forwarding activity immediately without queue since queue is not set.");
|
|
3104
3063
|
const promises = [];
|
|
3105
3064
|
for (const inbox in inboxes) promises.push(sendActivity({
|
|
3106
3065
|
keys,
|
|
@@ -3115,7 +3074,7 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
|
|
|
3115
3074
|
await Promise.all(promises);
|
|
3116
3075
|
return;
|
|
3117
3076
|
}
|
|
3118
|
-
logger
|
|
3077
|
+
logger.debug("Enqueuing activity {activityId} to forward later.", {
|
|
3119
3078
|
activityId: this.activityId,
|
|
3120
3079
|
activity: this.activity
|
|
3121
3080
|
});
|
|
@@ -3151,10 +3110,9 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
|
|
|
3151
3110
|
const { outboxQueue } = this.federation;
|
|
3152
3111
|
if (outboxQueue.enqueueMany == null) {
|
|
3153
3112
|
const promises = messages.map((m) => outboxQueue.enqueue(m));
|
|
3154
|
-
const
|
|
3155
|
-
const errors = results.filter((r) => r.status === "rejected").map((r) => r.reason);
|
|
3113
|
+
const errors = (await Promise.allSettled(promises)).filter((r) => r.status === "rejected").map((r) => r.reason);
|
|
3156
3114
|
if (errors.length > 0) {
|
|
3157
|
-
logger
|
|
3115
|
+
logger.error("Failed to enqueue activity {activityId} to forward later:\n{errors}", {
|
|
3158
3116
|
activityId: this.activityId,
|
|
3159
3117
|
errors
|
|
3160
3118
|
});
|
|
@@ -3164,7 +3122,7 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
|
|
|
3164
3122
|
} else try {
|
|
3165
3123
|
await outboxQueue.enqueueMany(messages);
|
|
3166
3124
|
} catch (error) {
|
|
3167
|
-
logger
|
|
3125
|
+
logger.error("Failed to enqueue activity {activityId} to forward later:\n{error}", {
|
|
3168
3126
|
activityId: this.activityId,
|
|
3169
3127
|
error
|
|
3170
3128
|
});
|
|
@@ -3219,10 +3177,7 @@ function unauthorized(_request) {
|
|
|
3219
3177
|
function getRequestId(request) {
|
|
3220
3178
|
const traceId = request.headers.get("X-Request-Id") || request.headers.get("X-Correlation-Id") || request.headers.get("Traceparent")?.split("-")[1];
|
|
3221
3179
|
if (traceId != null) return traceId;
|
|
3222
|
-
|
|
3223
|
-
const random = Math.random().toString(36).slice(2, 8);
|
|
3224
|
-
return `req_${timestamp}${random}`;
|
|
3180
|
+
return `req_${Date.now().toString(36)}${Math.random().toString(36).slice(2, 8)}`;
|
|
3225
3181
|
}
|
|
3226
|
-
|
|
3227
3182
|
//#endregion
|
|
3228
|
-
export {
|
|
3183
|
+
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 };
|