@fedify/fedify 2.0.0-dev.1641 → 2.0.0-dev.167
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +66 -30
- package/dist/{assert_rejects-7UF4R_Qs.js → assert_rejects-Ce45JcFg.js} +1 -1
- package/dist/{assert_is_error-B035L3om.js → assert_throws-BNXdRGWP.js} +31 -1
- package/dist/{builder-E2Icrl_a.js → builder-CRQGVq_N.js} +15 -8
- package/dist/{client-bgSdkFa2.d.ts → client-CUTUGgvJ.d.ts} +19 -19
- package/dist/{client-BW4V0OJx.js → client-Dg7OfUDA.js} +28 -23
- package/dist/{client-CegPX0Rn.d.cts → client-by-PEGAJ.d.cts} +19 -19
- package/dist/compat/mod.cjs +1 -1
- package/dist/compat/mod.d.cts +6 -12
- package/dist/compat/mod.d.ts +6 -12
- package/dist/compat/mod.js +1 -1
- package/dist/compat/transformers.test.js +21 -19
- package/dist/context-Bns6uTJq.js +109 -0
- package/dist/{context-CDSZdQHD.d.ts → context-C7vzWilY.d.ts} +374 -182
- package/dist/{context-Dq8aCtMH.d.cts → context-CrB9RFy5.d.cts} +374 -182
- package/dist/deno-Bvf4AA-X.js +117 -0
- package/dist/{testing-ByQmUvf-.js → dist-B5f6a8Tt.js} +90 -111
- package/dist/{authdocloader-BkIZCKQv.js → docloader-2gNKaklf.js} +17 -8
- package/dist/{esm-mtx3XJAD.js → esm-DGl7uK1r.js} +32 -17
- package/dist/federation/builder.test.js +9 -9
- package/dist/federation/collection.test.js +3 -6
- package/dist/federation/handler.test.js +113 -145
- package/dist/federation/idempotency.test.js +202 -0
- package/dist/federation/inbox.test.js +5 -6
- package/dist/federation/keycache.test.js +4 -5
- package/dist/federation/kv.test.js +58 -7
- package/dist/federation/middleware.test.js +306 -111
- package/dist/federation/mod.cjs +8 -12
- package/dist/federation/mod.d.cts +7 -13
- package/dist/federation/mod.d.ts +7 -13
- package/dist/federation/mod.js +8 -13
- package/dist/federation/mq.test.js +7 -8
- package/dist/federation/negotiation.test.js +25 -0
- package/dist/federation/retry.test.js +2 -4
- package/dist/federation/router.test.js +4 -6
- package/dist/federation/send.test.js +53 -13
- package/dist/{webfinger/handler.test.js → federation/webfinger.test.js} +25 -23
- package/dist/{federation-H2_En3j5.cjs → federation-B431K2gm.cjs} +22 -0
- package/dist/{federation-D1U8YY9t.js → federation-BbZwNNWj.js} +28 -6
- package/dist/{http-C7uYFcBo.js → http-0lpbWrFT.js} +371 -11
- package/dist/{http-BS6766zs.d.cts → http-ClB3pLcL.d.cts} +2 -2
- package/dist/{http-DqSNLFNY.d.ts → http-DLBDPal9.d.ts} +2 -2
- package/dist/{http-Cox5GsED.js → http-DP374h--.js} +3 -2
- package/dist/{http-ZhcoaYEa.cjs → http-d_vxukl7.cjs} +410 -14
- package/dist/{inbox-BDdRbWNI.js → inbox-Dv3k4z7l.js} +25 -7
- package/dist/{key-CfiBDu3o.js → key-t0uDOx8t.js} +3 -2
- package/dist/{keycache-CVBjz3xi.js → keycache-DRxpZ5r9.js} +1 -1
- package/dist/{keys-CBKbYaJA.js → keys-ZbcByPg9.js} +2 -1
- package/dist/{kv-63Cil1MD.d.cts → kv-B4vFhIYL.d.cts} +30 -1
- package/dist/{kv-C7sopW2E.d.ts → kv-CYySNrsn.d.ts} +30 -1
- package/dist/{kv-CRZrzyXm.js → kv-QzKcOQgP.js} +22 -0
- package/dist/kv-cache-BEeqyGER.js +107 -0
- package/dist/kv-cache-KFREoRaI.cjs +134 -0
- package/dist/kv-cache-aVS_ypNU.js +122 -0
- package/dist/{ld-CxgmnSO3.js → ld-CpXPfqRW.js} +4 -2
- package/dist/middleware-6Nb3n763.js +12 -0
- package/dist/{middleware-LyCG_YVM.cjs → middleware-Clcecst5.cjs} +309 -303
- package/dist/{middleware-DXidHY4N.js → middleware-DEy7WEOy.js} +254 -254
- package/dist/{middleware-ByPnvMMS.js → middleware-DLaPtWGX.js} +215 -313
- package/dist/middleware-DRg9fmN1.js +26 -0
- package/dist/middleware-lkdHuEk5.cjs +12 -0
- package/dist/mod-0p9zUdzg.d.cts +107 -0
- package/dist/mod-0qnPv4EC.d.cts +62 -0
- package/dist/{mod-BClfg3ej.d.cts → mod-BrS8tiad.d.cts} +3 -3
- package/dist/mod-C3SOvTD1.d.ts +64 -0
- package/dist/{mod-BhMnAkFX.d.cts → mod-D6pS5_xJ.d.cts} +4 -4
- package/dist/{mod-Drmz72EK.d.ts → mod-jOa7W503.d.ts} +3 -3
- package/dist/{mod-RI3-KvUI.d.ts → mod-waqu-BL_.d.ts} +4 -4
- package/dist/mod-xc20HhMD.d.ts +109 -0
- package/dist/mod.cjs +17 -112
- package/dist/mod.d.cts +11 -17
- package/dist/mod.d.ts +11 -17
- package/dist/mod.js +11 -17
- package/dist/negotiation-5NPJL6zp.js +71 -0
- package/dist/nodeinfo/client.test.js +5 -8
- package/dist/nodeinfo/handler.test.js +23 -22
- package/dist/nodeinfo/mod.cjs +2 -3
- package/dist/nodeinfo/mod.d.cts +2 -4
- package/dist/nodeinfo/mod.d.ts +2 -4
- package/dist/nodeinfo/mod.js +2 -3
- package/dist/nodeinfo/types.test.js +4 -7
- package/dist/otel/exporter.test.js +893 -0
- package/dist/otel/mod.cjs +256 -0
- package/dist/otel/mod.d.cts +230 -0
- package/dist/otel/mod.d.ts +232 -0
- package/dist/otel/mod.js +255 -0
- package/dist/{owner-Cxob5_PK.js → owner-BaG2jUgZ.js} +45 -8
- package/dist/{owner-CQPnQVtf.d.ts → owner-BgI8C-VY.d.ts} +2 -3
- package/dist/{owner-B-7Ptt_m.d.cts → owner-C-zfmVAD.d.cts} +2 -3
- package/dist/{proof-DkxwMaWE.js → proof-ClXweyp2.js} +47 -11
- package/dist/{proof-2Gcor0_N.cjs → proof-Cy-QcHCv.cjs} +69 -33
- package/dist/{proof-BiSQNUmQ.js → proof-D8bfMlig.js} +3 -2
- package/dist/router-D9eI0s4b.js +118 -0
- package/dist/{send-DSEhWIYD.js → send-BLogwy3G.js} +9 -4
- package/dist/sig/http.test.js +9 -11
- package/dist/sig/key.test.js +7 -9
- package/dist/sig/ld.test.js +8 -10
- package/dist/sig/mod.cjs +7 -11
- package/dist/sig/mod.d.cts +3 -7
- package/dist/sig/mod.d.ts +3 -7
- package/dist/sig/mod.js +3 -7
- package/dist/sig/owner.test.js +31 -10
- package/dist/sig/proof.test.js +11 -12
- package/dist/testing/mod.d.ts +243 -6982
- package/dist/testing/mod.js +4 -4
- package/dist/{transformers-CoBS-oFG.cjs → transformers-BjBg6Lag.cjs} +2 -2
- package/dist/{transformers-BFT6d7J5.js → transformers-N_ip_y4P.js} +2 -2
- package/dist/{types-l2uh_ZhP.js → types-8l28uC8o.js} +31 -26
- package/dist/{types-Bqt2EgP0.cjs → types-B6z6CqIz.cjs} +33 -28
- package/dist/{types-BSuWJsOm.js → types-CPz01LGH.js} +3 -3
- package/dist/{runtime/authdocloader.test.js → utils/docloader.test.js} +11 -13
- package/dist/utils/kv-cache.test.js +211 -0
- package/dist/utils/mod.cjs +10 -0
- package/dist/utils/mod.d.cts +4 -0
- package/dist/utils/mod.d.ts +6 -0
- package/dist/utils/mod.js +9 -0
- package/package.json +34 -75
- package/dist/actor-C22bXuuC.d.ts +0 -130
- package/dist/actor-CP03csrm.cjs +0 -37786
- package/dist/actor-DMgu-ZjT.d.cts +0 -128
- package/dist/actor-DU511yTk.js +0 -37312
- package/dist/actor-DVpsNXhn.js +0 -146
- package/dist/assert_throws-53_pKeP3.js +0 -39
- package/dist/authdocloader-BnsFSERg.cjs +0 -58
- package/dist/authdocloader-DCgMyo82.js +0 -52
- package/dist/denokv-jZ0Z2h0M.js +0 -57
- package/dist/docloader-BtqIh1OE.js +0 -4795
- package/dist/docloader-CxWcuWqQ.d.ts +0 -221
- package/dist/docloader-D-MrRyHl.d.cts +0 -219
- package/dist/docloader-kae6M-GI.cjs +0 -4861
- package/dist/fixtures/activitypub.academy/users/brauca_darradiul.json +0 -83
- package/dist/fixtures/example.com/announce.json +0 -6
- package/dist/fixtures/example.com/collection.json +0 -19
- package/dist/fixtures/example.com/create.json +0 -6
- package/dist/fixtures/example.com/cross-origin-actor.json +0 -6
- package/dist/fixtures/example.com/hong-gildong.json +0 -11
- package/dist/fixtures/example.com/invite.json +0 -7
- package/dist/fixtures/example.com/key.json +0 -7
- package/dist/fixtures/example.com/key2.json +0 -6
- package/dist/fixtures/example.com/object.json +0 -6
- package/dist/fixtures/example.com/orderedcollectionpage.json +0 -24
- package/dist/fixtures/example.com/paged/a.json +0 -13
- package/dist/fixtures/example.com/paged/b.json +0 -16
- package/dist/fixtures/example.com/paged-collection.json +0 -6
- package/dist/fixtures/example.com/person.json +0 -22
- package/dist/fixtures/example.com/person2.json +0 -40
- package/dist/fixtures/example.com/test.json +0 -5
- package/dist/fixtures/example.com/users/handle.json +0 -16
- package/dist/fixtures/example.com/wrong-type.json +0 -3
- package/dist/fixtures/oeee.cafe/ap/users/3609fd4e-d51d-4db8-9f04-4189815864dd.json +0 -24
- package/dist/fixtures/remote.domain/users/bob.json +0 -20
- package/dist/fixtures/server.example/users/alice.json +0 -20
- package/dist/fixtures/w3id.org/identity/v1.json +0 -152
- package/dist/fixtures/w3id.org/security/data-integrity/v1.json +0 -74
- package/dist/fixtures/w3id.org/security/multikey/v1.json +0 -35
- package/dist/fixtures/w3id.org/security/v1.json +0 -50
- package/dist/fixtures/wizard.casa/users/hongminhee.json +0 -69
- package/dist/fixtures/www.w3.org/ns/activitystreams.json +0 -379
- package/dist/fixtures/www.w3.org/ns/did/v1.json +0 -58
- package/dist/key-B9Z5ZuX9.js +0 -10
- package/dist/key-Cc0JlcKe.js +0 -260
- package/dist/key-CgwCzDC4.js +0 -10
- package/dist/key-D-7DPHNl.cjs +0 -10
- package/dist/key-HqzOCwDc.cjs +0 -290
- package/dist/lookup-CiU3QxQz.js +0 -322
- package/dist/lookup-NuT9cCSl.js +0 -131
- package/dist/lookup-QHjmy4Og.cjs +0 -137
- package/dist/middleware-BHboQ4BE.js +0 -25
- package/dist/middleware-Bp3I9z8r.js +0 -17
- package/dist/middleware-oYqSU5ky.cjs +0 -17
- package/dist/mod-Cxt4Kpf6.d.ts +0 -291
- package/dist/mod-DBzN0aCM.d.ts +0 -115
- package/dist/mod-Dc_-mf8s.d.cts +0 -102
- package/dist/mod-FZd39qVq.d.cts +0 -1
- package/dist/mod-TFoH2Ql8.d.ts +0 -104
- package/dist/mod-evzlRVZq.d.cts +0 -289
- package/dist/mod-g0xFzAP9.d.ts +0 -2
- package/dist/mod-jQ4OODsl.d.cts +0 -113
- package/dist/mq-B7R1Q-M5.d.cts +0 -140
- package/dist/mq-CRGm1e_F.d.ts +0 -143
- package/dist/runtime/docloader.test.js +0 -522
- package/dist/runtime/key.test.js +0 -103
- package/dist/runtime/langstr.test.js +0 -39
- package/dist/runtime/link.test.js +0 -61
- package/dist/runtime/mod.cjs +0 -25
- package/dist/runtime/mod.d.cts +0 -6
- package/dist/runtime/mod.d.ts +0 -8
- package/dist/runtime/mod.js +0 -13
- package/dist/runtime/multibase/multibase.test.d.ts +0 -3
- package/dist/runtime/multibase/multibase.test.js +0 -358
- package/dist/runtime/url.test.d.ts +0 -3
- package/dist/runtime/url.test.js +0 -45
- package/dist/src/vocab/accept.yaml +0 -15
- package/dist/src/vocab/activity.yaml +0 -98
- package/dist/src/vocab/add.yaml +0 -16
- package/dist/src/vocab/announce.yaml +0 -30
- package/dist/src/vocab/application.yaml +0 -324
- package/dist/src/vocab/arrive.yaml +0 -15
- package/dist/src/vocab/article.yaml +0 -46
- package/dist/src/vocab/audio.yaml +0 -11
- package/dist/src/vocab/block.yaml +0 -16
- package/dist/src/vocab/chatmessage.yaml +0 -50
- package/dist/src/vocab/collection.yaml +0 -154
- package/dist/src/vocab/collectionpage.yaml +0 -55
- package/dist/src/vocab/create.yaml +0 -28
- package/dist/src/vocab/dataintegrityproof.yaml +0 -56
- package/dist/src/vocab/delete.yaml +0 -27
- package/dist/src/vocab/didservice.yaml +0 -22
- package/dist/src/vocab/dislike.yaml +0 -14
- package/dist/src/vocab/document.yaml +0 -31
- package/dist/src/vocab/emoji.yaml +0 -12
- package/dist/src/vocab/emojireact.yaml +0 -17
- package/dist/src/vocab/endpoints.yaml +0 -85
- package/dist/src/vocab/event.yaml +0 -11
- package/dist/src/vocab/export.yaml +0 -9
- package/dist/src/vocab/flag.yaml +0 -15
- package/dist/src/vocab/follow.yaml +0 -19
- package/dist/src/vocab/group.yaml +0 -324
- package/dist/src/vocab/hashtag.yaml +0 -14
- package/dist/src/vocab/ignore.yaml +0 -14
- package/dist/src/vocab/image.yaml +0 -9
- package/dist/src/vocab/intransitiveactivity.yaml +0 -15
- package/dist/src/vocab/invite.yaml +0 -14
- package/dist/src/vocab/join.yaml +0 -14
- package/dist/src/vocab/key.yaml +0 -28
- package/dist/src/vocab/leave.yaml +0 -14
- package/dist/src/vocab/like.yaml +0 -16
- package/dist/src/vocab/link.yaml +0 -101
- package/dist/src/vocab/listen.yaml +0 -12
- package/dist/src/vocab/mention.yaml +0 -9
- package/dist/src/vocab/move.yaml +0 -15
- package/dist/src/vocab/multikey.yaml +0 -36
- package/dist/src/vocab/note.yaml +0 -48
- package/dist/src/vocab/object.yaml +0 -404
- package/dist/src/vocab/offer.yaml +0 -15
- package/dist/src/vocab/orderedcollection.yaml +0 -39
- package/dist/src/vocab/orderedcollectionpage.yaml +0 -50
- package/dist/src/vocab/organization.yaml +0 -324
- package/dist/src/vocab/page.yaml +0 -11
- package/dist/src/vocab/person.yaml +0 -324
- package/dist/src/vocab/place.yaml +0 -75
- package/dist/src/vocab/profile.yaml +0 -26
- package/dist/src/vocab/propertyvalue.yaml +0 -32
- package/dist/src/vocab/question.yaml +0 -103
- package/dist/src/vocab/read.yaml +0 -13
- package/dist/src/vocab/reject.yaml +0 -14
- package/dist/src/vocab/relationship.yaml +0 -52
- package/dist/src/vocab/remove.yaml +0 -14
- package/dist/src/vocab/service.yaml +0 -324
- package/dist/src/vocab/source.yaml +0 -26
- package/dist/src/vocab/tentativeaccept.yaml +0 -14
- package/dist/src/vocab/tentativereject.yaml +0 -14
- package/dist/src/vocab/tombstone.yaml +0 -24
- package/dist/src/vocab/travel.yaml +0 -16
- package/dist/src/vocab/undo.yaml +0 -26
- package/dist/src/vocab/update.yaml +0 -58
- package/dist/src/vocab/video.yaml +0 -11
- package/dist/src/vocab/view.yaml +0 -13
- package/dist/testing/docloader.test.js +0 -24
- package/dist/type-B4NJkfVg.js +0 -42187
- package/dist/vocab/actor.test.d.ts +0 -3
- package/dist/vocab/actor.test.js +0 -5965
- package/dist/vocab/lookup.test.d.ts +0 -3
- package/dist/vocab/lookup.test.js +0 -206
- package/dist/vocab/mod.cjs +0 -87
- package/dist/vocab/mod.d.cts +0 -6
- package/dist/vocab/mod.d.ts +0 -8
- package/dist/vocab/mod.js +0 -10
- package/dist/vocab/schema.yaml +0 -247
- package/dist/vocab/type.test.d.ts +0 -3
- package/dist/vocab/type.test.js +0 -25
- package/dist/vocab/vocab.test.d.ts +0 -3
- package/dist/vocab/vocab.test.js +0 -3398
- package/dist/vocab-B0-5a8pw.cjs +0 -282
- package/dist/vocab-DJTYMqyU.d.cts +0 -14632
- package/dist/vocab-SOE1ifCr.d.ts +0 -14634
- package/dist/vocab-lBFcVxVF.js +0 -246
- package/dist/webfinger/handler.test.d.ts +0 -3
- package/dist/webfinger/lookup.test.d.ts +0 -3
- package/dist/webfinger/lookup.test.js +0 -195
- package/dist/webfinger/mod.cjs +0 -9
- package/dist/webfinger/mod.d.cts +0 -4
- package/dist/webfinger/mod.d.ts +0 -6
- package/dist/webfinger/mod.js +0 -9
- package/dist/webfinger-BjOEdFPs.cjs +0 -4
- package/dist/webfinger-De_bU0iE.js +0 -4
- package/dist/x/cfworkers.cjs +0 -100
- package/dist/x/cfworkers.d.cts +0 -59
- package/dist/x/cfworkers.d.ts +0 -61
- package/dist/x/cfworkers.js +0 -98
- package/dist/x/cfworkers.test.d.ts +0 -3
- package/dist/x/cfworkers.test.js +0 -179
- package/dist/x/hono.cjs +0 -61
- package/dist/x/hono.d.cts +0 -54
- package/dist/x/hono.d.ts +0 -56
- package/dist/x/hono.js +0 -60
- package/dist/x/sveltekit.cjs +0 -69
- package/dist/x/sveltekit.d.cts +0 -46
- package/dist/x/sveltekit.d.ts +0 -48
- package/dist/x/sveltekit.js +0 -68
- /package/dist/{runtime/authdocloader.test.d.ts → federation/idempotency.test.d.ts} +0 -0
- /package/dist/{runtime/docloader.test.d.ts → federation/negotiation.test.d.ts} +0 -0
- /package/dist/{runtime/key.test.d.ts → federation/webfinger.test.d.ts} +0 -0
- /package/dist/{mod-1pDWKvUL.d.ts → mod-1E3W847c.d.ts} +0 -0
- /package/dist/{mod-C2tOeRkN.d.cts → mod-C81L6_lQ.d.cts} +0 -0
- /package/dist/{nodeinfo-DfycQ8Wf.js → nodeinfo-BlLsRSiT.js} +0 -0
- /package/dist/{nodeinfo-Co9lJrWl.cjs → nodeinfo-DuMYTpbZ.cjs} +0 -0
- /package/dist/{runtime/langstr.test.d.ts → otel/exporter.test.d.ts} +0 -0
- /package/dist/{retry-CfF8Gn4d.js → retry-D4GJ670a.js} +0 -0
- /package/dist/{runtime-DPYEDf-o.js → sig-CwuONEzF.js} +0 -0
- /package/dist/{runtime-C58AJWSv.cjs → sig-DeXX2xnj.cjs} +0 -0
- /package/dist/{testing → utils}/docloader.test.d.ts +0 -0
- /package/dist/{runtime/link.test.d.ts → utils/kv-cache.test.d.ts} +0 -0
- /package/dist/{sig-ByHXzqUi.cjs → utils-Db0ZmjcD.cjs} +0 -0
- /package/dist/{sig-Cj3tk-ig.js → utils-Wranxuoe.js} +0 -0
|
@@ -3,23 +3,21 @@
|
|
|
3
3
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
4
4
|
|
|
5
5
|
const require_chunk = require('./chunk-DqRYRqnO.cjs');
|
|
6
|
-
const require_transformers = require('./transformers-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const require_http = require('./http-ZhcoaYEa.cjs');
|
|
12
|
-
const require_proof = require('./proof-2Gcor0_N.cjs');
|
|
13
|
-
const require_types = require('./types-Bqt2EgP0.cjs');
|
|
14
|
-
const require_authdocloader = require('./authdocloader-BnsFSERg.cjs');
|
|
15
|
-
const require_vocab = require('./vocab-B0-5a8pw.cjs');
|
|
6
|
+
const require_transformers = require('./transformers-BjBg6Lag.cjs');
|
|
7
|
+
const require_http = require('./http-d_vxukl7.cjs');
|
|
8
|
+
const require_proof = require('./proof-Cy-QcHCv.cjs');
|
|
9
|
+
const require_types = require('./types-B6z6CqIz.cjs');
|
|
10
|
+
const require_kv_cache = require('./kv-cache-KFREoRaI.cjs');
|
|
16
11
|
const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
|
|
12
|
+
const __fedify_vocab = require_chunk.__toESM(require("@fedify/vocab"));
|
|
17
13
|
const __opentelemetry_api = require_chunk.__toESM(require("@opentelemetry/api"));
|
|
18
|
-
const byte_encodings_hex = require_chunk.__toESM(require("byte-encodings/hex"));
|
|
19
14
|
const es_toolkit = require_chunk.__toESM(require("es-toolkit"));
|
|
20
15
|
const uri_template_router = require_chunk.__toESM(require("uri-template-router"));
|
|
21
16
|
const url_template = require_chunk.__toESM(require("url-template"));
|
|
17
|
+
const byte_encodings_hex = require_chunk.__toESM(require("byte-encodings/hex"));
|
|
22
18
|
const __opentelemetry_semantic_conventions = require_chunk.__toESM(require("@opentelemetry/semantic-conventions"));
|
|
19
|
+
const __fedify_vocab_runtime = require_chunk.__toESM(require("@fedify/vocab-runtime"));
|
|
20
|
+
const __fedify_webfinger = require_chunk.__toESM(require("@fedify/webfinger"));
|
|
23
21
|
const node_url = require_chunk.__toESM(require("node:url"));
|
|
24
22
|
|
|
25
23
|
//#region src/federation/inbox.ts
|
|
@@ -43,7 +41,7 @@ var InboxListenerSet = class InboxListenerSet {
|
|
|
43
41
|
if (inboxListeners == null) return null;
|
|
44
42
|
while (true) {
|
|
45
43
|
if (inboxListeners.has(cls)) break;
|
|
46
|
-
if (cls ===
|
|
44
|
+
if (cls === __fedify_vocab.Activity) return null;
|
|
47
45
|
cls = globalThis.Object.getPrototypeOf(cls);
|
|
48
46
|
}
|
|
49
47
|
const listener = inboxListeners.get(cls);
|
|
@@ -56,17 +54,34 @@ var InboxListenerSet = class InboxListenerSet {
|
|
|
56
54
|
return this.dispatchWithClass(activity)?.listener ?? null;
|
|
57
55
|
}
|
|
58
56
|
};
|
|
59
|
-
async function routeActivity({ context: ctx, json, activity, recipient, inboxListeners, inboxContextFactory, inboxErrorHandler, kv, kvPrefixes, queue, span, tracerProvider }) {
|
|
57
|
+
async function routeActivity({ context: ctx, json, activity, recipient, inboxListeners, inboxContextFactory, inboxErrorHandler, kv, kvPrefixes, queue, span, tracerProvider, idempotencyStrategy }) {
|
|
60
58
|
const logger$1 = (0, __logtape_logtape.getLogger)([
|
|
61
59
|
"fedify",
|
|
62
60
|
"federation",
|
|
63
61
|
"inbox"
|
|
64
62
|
]);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
let cacheKey = null;
|
|
64
|
+
if (activity.id != null) {
|
|
65
|
+
const inboxContext = inboxContextFactory(recipient, json, activity.id?.href, (0, __fedify_vocab.getTypeId)(activity).href);
|
|
66
|
+
const strategy = idempotencyStrategy ?? "per-inbox";
|
|
67
|
+
let keyString;
|
|
68
|
+
if (typeof strategy === "function") {
|
|
69
|
+
const result = await strategy(inboxContext, activity);
|
|
70
|
+
keyString = result;
|
|
71
|
+
} else switch (strategy) {
|
|
72
|
+
case "global":
|
|
73
|
+
keyString = activity.id.href;
|
|
74
|
+
break;
|
|
75
|
+
case "per-origin":
|
|
76
|
+
keyString = `${ctx.origin}\n${activity.id.href}`;
|
|
77
|
+
break;
|
|
78
|
+
case "per-inbox":
|
|
79
|
+
keyString = `${ctx.origin}\n${activity.id.href}\n${recipient == null ? "sharedInbox" : `inbox\n${recipient}`}`;
|
|
80
|
+
break;
|
|
81
|
+
default: keyString = `${ctx.origin}\n${activity.id.href}`;
|
|
82
|
+
}
|
|
83
|
+
if (keyString != null) cacheKey = [...kvPrefixes.activityIdempotence, keyString];
|
|
84
|
+
}
|
|
70
85
|
if (cacheKey != null) {
|
|
71
86
|
const cached = await kv.get(cacheKey);
|
|
72
87
|
if (cached === true) {
|
|
@@ -126,7 +141,7 @@ async function routeActivity({ context: ctx, json, activity, recipient, inboxLis
|
|
|
126
141
|
return "enqueued";
|
|
127
142
|
}
|
|
128
143
|
tracerProvider = tracerProvider ?? __opentelemetry_api.trace.getTracerProvider();
|
|
129
|
-
const tracer = tracerProvider.getTracer(
|
|
144
|
+
const tracer = tracerProvider.getTracer(require_http.deno_default.name, require_http.deno_default.version);
|
|
130
145
|
return await tracer.startActiveSpan("activitypub.dispatch_inbox_listener", { kind: __opentelemetry_api.SpanKind.INTERNAL }, async (span$1) => {
|
|
131
146
|
const dispatched = inboxListeners?.dispatchWithClass(activity);
|
|
132
147
|
if (dispatched == null) {
|
|
@@ -136,7 +151,7 @@ async function routeActivity({ context: ctx, json, activity, recipient, inboxLis
|
|
|
136
151
|
});
|
|
137
152
|
span$1.setStatus({
|
|
138
153
|
code: __opentelemetry_api.SpanStatusCode.UNSET,
|
|
139
|
-
message: `Unsupported activity type: ${
|
|
154
|
+
message: `Unsupported activity type: ${(0, __fedify_vocab.getTypeId)(activity).href}`
|
|
140
155
|
});
|
|
141
156
|
span$1.end();
|
|
142
157
|
return "unsupportedActivity";
|
|
@@ -144,7 +159,7 @@ async function routeActivity({ context: ctx, json, activity, recipient, inboxLis
|
|
|
144
159
|
const { class: cls, listener } = dispatched;
|
|
145
160
|
span$1.updateName(`activitypub.dispatch_inbox_listener ${cls.name}`);
|
|
146
161
|
try {
|
|
147
|
-
await listener(inboxContextFactory(recipient, json, activity?.id?.href,
|
|
162
|
+
await listener(inboxContextFactory(recipient, json, activity?.id?.href, (0, __fedify_vocab.getTypeId)(activity).href), activity);
|
|
148
163
|
} catch (error) {
|
|
149
164
|
try {
|
|
150
165
|
await inboxErrorHandler?.(ctx, error);
|
|
@@ -308,6 +323,7 @@ var FederationBuilderImpl = class {
|
|
|
308
323
|
inboxListeners;
|
|
309
324
|
inboxErrorHandler;
|
|
310
325
|
sharedInboxKeyDispatcher;
|
|
326
|
+
idempotencyStrategy;
|
|
311
327
|
collectionTypeIds;
|
|
312
328
|
collectionCallbacks;
|
|
313
329
|
/**
|
|
@@ -322,7 +338,7 @@ var FederationBuilderImpl = class {
|
|
|
322
338
|
this.collectionTypeIds = {};
|
|
323
339
|
}
|
|
324
340
|
async build(options) {
|
|
325
|
-
const { FederationImpl: FederationImpl$1 } = await Promise.resolve().then(() => require("./middleware-
|
|
341
|
+
const { FederationImpl: FederationImpl$1 } = await Promise.resolve().then(() => require("./middleware-lkdHuEk5.cjs"));
|
|
326
342
|
const f = new FederationImpl$1(options);
|
|
327
343
|
const trailingSlashInsensitiveValue = f.router.trailingSlashInsensitive;
|
|
328
344
|
f.router = this.router.clone();
|
|
@@ -344,10 +360,11 @@ var FederationBuilderImpl = class {
|
|
|
344
360
|
f.inboxListeners = this.inboxListeners?.clone();
|
|
345
361
|
f.inboxErrorHandler = this.inboxErrorHandler;
|
|
346
362
|
f.sharedInboxKeyDispatcher = this.sharedInboxKeyDispatcher;
|
|
363
|
+
f.idempotencyStrategy = this.idempotencyStrategy;
|
|
347
364
|
return f;
|
|
348
365
|
}
|
|
349
366
|
_getTracer() {
|
|
350
|
-
return __opentelemetry_api.trace.getTracer(
|
|
367
|
+
return __opentelemetry_api.trace.getTracer(require_http.deno_default.name, require_http.deno_default.version);
|
|
351
368
|
}
|
|
352
369
|
setActorDispatcher(path, dispatcher) {
|
|
353
370
|
if (this.router.has("actor")) throw new RouterError("Actor dispatcher already set.");
|
|
@@ -367,7 +384,7 @@ var FederationBuilderImpl = class {
|
|
|
367
384
|
const actor$1 = await dispatcher(context$2, identifier);
|
|
368
385
|
span.setAttribute("activitypub.actor.id", (actor$1?.id ?? context$2.getActorUri(identifier)).href);
|
|
369
386
|
if (actor$1 == null) span.setStatus({ code: __opentelemetry_api.SpanStatusCode.ERROR });
|
|
370
|
-
else span.setAttribute("activitypub.actor.type",
|
|
387
|
+
else span.setAttribute("activitypub.actor.type", (0, __fedify_vocab.getTypeId)(actor$1).href);
|
|
371
388
|
return actor$1;
|
|
372
389
|
} catch (error) {
|
|
373
390
|
span.setStatus({
|
|
@@ -490,7 +507,7 @@ var FederationBuilderImpl = class {
|
|
|
490
507
|
const object = await dispatcher(ctx, values);
|
|
491
508
|
span.setAttribute("activitypub.object.id", (object?.id ?? ctx.getObjectUri(cls, values)).href);
|
|
492
509
|
if (object == null) span.setStatus({ code: __opentelemetry_api.SpanStatusCode.ERROR });
|
|
493
|
-
else span.setAttribute("activitypub.object.type",
|
|
510
|
+
else span.setAttribute("activitypub.object.type", (0, __fedify_vocab.getTypeId)(object).href);
|
|
494
511
|
return object;
|
|
495
512
|
} catch (e) {
|
|
496
513
|
span.setStatus({
|
|
@@ -766,15 +783,19 @@ var FederationBuilderImpl = class {
|
|
|
766
783
|
setSharedKeyDispatcher: (dispatcher) => {
|
|
767
784
|
this.sharedInboxKeyDispatcher = dispatcher;
|
|
768
785
|
return setters;
|
|
786
|
+
},
|
|
787
|
+
withIdempotency: (strategy) => {
|
|
788
|
+
this.idempotencyStrategy = strategy;
|
|
789
|
+
return setters;
|
|
769
790
|
}
|
|
770
791
|
};
|
|
771
792
|
return setters;
|
|
772
793
|
}
|
|
773
|
-
setCollectionDispatcher(name,
|
|
774
|
-
return this.#setCustomCollectionDispatcher(name, "collection",
|
|
794
|
+
setCollectionDispatcher(name, itemType, path, dispatcher) {
|
|
795
|
+
return this.#setCustomCollectionDispatcher(name, "collection", itemType, path, dispatcher);
|
|
775
796
|
}
|
|
776
|
-
setOrderedCollectionDispatcher(name,
|
|
777
|
-
return this.#setCustomCollectionDispatcher(name, "orderedCollection",
|
|
797
|
+
setOrderedCollectionDispatcher(name, itemType, path, dispatcher) {
|
|
798
|
+
return this.#setCustomCollectionDispatcher(name, "orderedCollection", itemType, path, dispatcher);
|
|
778
799
|
}
|
|
779
800
|
#setCustomCollectionDispatcher(name, collectionType, itemType, path, dispatcher) {
|
|
780
801
|
const strName = String(name);
|
|
@@ -901,10 +922,10 @@ var KvKeyCache = class {
|
|
|
901
922
|
const serialized = await this.kv.get([...this.prefix, keyId.href]);
|
|
902
923
|
if (serialized == null) return void 0;
|
|
903
924
|
try {
|
|
904
|
-
return await
|
|
925
|
+
return await __fedify_vocab.CryptographicKey.fromJsonLd(serialized, this.options);
|
|
905
926
|
} catch {
|
|
906
927
|
try {
|
|
907
|
-
return await
|
|
928
|
+
return await __fedify_vocab.Multikey.fromJsonLd(serialized, this.options);
|
|
908
929
|
} catch {
|
|
909
930
|
await this.kv.delete([...this.prefix, keyId.href]);
|
|
910
931
|
return void 0;
|
|
@@ -980,9 +1001,6 @@ function preferredMediaTypes(accept) {
|
|
|
980
1001
|
const accepts = parseAccept(accept === void 0 ? "*/*" : accept ?? "");
|
|
981
1002
|
return accepts.filter(isQuality).sort(compareSpecs).map(getFullType);
|
|
982
1003
|
}
|
|
983
|
-
|
|
984
|
-
//#endregion
|
|
985
|
-
//#region src/federation/handler.ts
|
|
986
1004
|
function acceptsJsonLd(request) {
|
|
987
1005
|
const accept = request.headers.get("Accept");
|
|
988
1006
|
const types = accept ? preferredMediaTypes(accept) : ["*/*"];
|
|
@@ -990,6 +1008,9 @@ function acceptsJsonLd(request) {
|
|
|
990
1008
|
if (types[0] === "text/html" || types[0] === "application/xhtml+xml") return false;
|
|
991
1009
|
return types.includes("application/activity+json") || types.includes("application/ld+json") || types.includes("application/json");
|
|
992
1010
|
}
|
|
1011
|
+
|
|
1012
|
+
//#endregion
|
|
1013
|
+
//#region src/federation/handler.ts
|
|
993
1014
|
/**
|
|
994
1015
|
* Handles an actor request.
|
|
995
1016
|
* @template TContextData The context data to pass to the context.
|
|
@@ -997,7 +1018,7 @@ function acceptsJsonLd(request) {
|
|
|
997
1018
|
* @param parameters The parameters for handling the actor.
|
|
998
1019
|
* @returns A promise that resolves to an HTTP response.
|
|
999
1020
|
*/
|
|
1000
|
-
async function handleActor(request, { identifier, context: context$2, actorDispatcher, authorizePredicate, onNotFound,
|
|
1021
|
+
async function handleActor(request, { identifier, context: context$2, actorDispatcher, authorizePredicate, onNotFound, onUnauthorized }) {
|
|
1001
1022
|
const logger$1 = (0, __logtape_logtape.getLogger)([
|
|
1002
1023
|
"fedify",
|
|
1003
1024
|
"federation",
|
|
@@ -1012,7 +1033,6 @@ async function handleActor(request, { identifier, context: context$2, actorDispa
|
|
|
1012
1033
|
logger$1.debug("Actor {identifier} not found.", { identifier });
|
|
1013
1034
|
return await onNotFound(request);
|
|
1014
1035
|
}
|
|
1015
|
-
if (!acceptsJsonLd(request)) return await onNotAcceptable(request);
|
|
1016
1036
|
if (authorizePredicate != null) {
|
|
1017
1037
|
let key = await context$2.getSignedKey();
|
|
1018
1038
|
key = key?.clone({}, { $warning: {
|
|
@@ -1047,11 +1067,10 @@ async function handleActor(request, { identifier, context: context$2, actorDispa
|
|
|
1047
1067
|
* @param parameters The parameters for handling the object.
|
|
1048
1068
|
* @returns A promise that resolves to an HTTP response.
|
|
1049
1069
|
*/
|
|
1050
|
-
async function handleObject(request, { values, context: context$2, objectDispatcher, authorizePredicate, onNotFound,
|
|
1070
|
+
async function handleObject(request, { values, context: context$2, objectDispatcher, authorizePredicate, onNotFound, onUnauthorized }) {
|
|
1051
1071
|
if (objectDispatcher == null) return await onNotFound(request);
|
|
1052
1072
|
const object = await objectDispatcher(context$2, values);
|
|
1053
1073
|
if (object == null) return await onNotFound(request);
|
|
1054
|
-
if (!acceptsJsonLd(request)) return await onNotAcceptable(request);
|
|
1055
1074
|
if (authorizePredicate != null) {
|
|
1056
1075
|
let key = await context$2.getSignedKey();
|
|
1057
1076
|
key = key?.clone({}, { $warning: {
|
|
@@ -1089,10 +1108,10 @@ async function handleObject(request, { values, context: context$2, objectDispatc
|
|
|
1089
1108
|
* @param parameters The parameters for handling the collection.
|
|
1090
1109
|
* @returns A promise that resolves to an HTTP response.
|
|
1091
1110
|
*/
|
|
1092
|
-
async function handleCollection(request, { name, identifier, uriGetter, filter, filterPredicate, context: context$2, collectionCallbacks, tracerProvider, onUnauthorized, onNotFound
|
|
1111
|
+
async function handleCollection(request, { name, identifier, uriGetter, filter, filterPredicate, context: context$2, collectionCallbacks, tracerProvider, onUnauthorized, onNotFound }) {
|
|
1093
1112
|
const spanName = name.trim().replace(/\s+/g, "_");
|
|
1094
1113
|
tracerProvider = tracerProvider ?? __opentelemetry_api.trace.getTracerProvider();
|
|
1095
|
-
const tracer = tracerProvider.getTracer(
|
|
1114
|
+
const tracer = tracerProvider.getTracer(require_http.deno_default.name, require_http.deno_default.version);
|
|
1096
1115
|
const url = new URL(request.url);
|
|
1097
1116
|
const cursor = url.searchParams.get("cursor");
|
|
1098
1117
|
if (collectionCallbacks == null) return await onNotFound(request);
|
|
@@ -1106,7 +1125,7 @@ async function handleCollection(request, { name, identifier, uriGetter, filter,
|
|
|
1106
1125
|
kind: __opentelemetry_api.SpanKind.SERVER,
|
|
1107
1126
|
attributes: {
|
|
1108
1127
|
"activitypub.collection.id": baseUri.href,
|
|
1109
|
-
"activitypub.collection.type":
|
|
1128
|
+
"activitypub.collection.type": __fedify_vocab.OrderedCollection.typeId.href
|
|
1110
1129
|
}
|
|
1111
1130
|
}, async (span) => {
|
|
1112
1131
|
if (totalItems != null) span.setAttribute("activitypub.collection.total_items", Number(totalItems));
|
|
@@ -1130,7 +1149,7 @@ async function handleCollection(request, { name, identifier, uriGetter, filter,
|
|
|
1130
1149
|
}
|
|
1131
1150
|
});
|
|
1132
1151
|
if (itemsOrResponse instanceof Response) return itemsOrResponse;
|
|
1133
|
-
collection = new
|
|
1152
|
+
collection = new __fedify_vocab.OrderedCollection({
|
|
1134
1153
|
id: baseUri,
|
|
1135
1154
|
totalItems: totalItems == null ? null : Number(totalItems),
|
|
1136
1155
|
items: filterCollectionItems(itemsOrResponse, name, filterPredicate)
|
|
@@ -1144,7 +1163,7 @@ async function handleCollection(request, { name, identifier, uriGetter, filter,
|
|
|
1144
1163
|
last = new URL(context$2.url);
|
|
1145
1164
|
last.searchParams.set("cursor", lastCursor);
|
|
1146
1165
|
}
|
|
1147
|
-
collection = new
|
|
1166
|
+
collection = new __fedify_vocab.OrderedCollection({
|
|
1148
1167
|
id: baseUri,
|
|
1149
1168
|
totalItems: totalItems == null ? null : Number(totalItems),
|
|
1150
1169
|
first,
|
|
@@ -1158,7 +1177,7 @@ async function handleCollection(request, { name, identifier, uriGetter, filter,
|
|
|
1158
1177
|
kind: __opentelemetry_api.SpanKind.SERVER,
|
|
1159
1178
|
attributes: {
|
|
1160
1179
|
"activitypub.collection.id": uri.href,
|
|
1161
|
-
"activitypub.collection.type":
|
|
1180
|
+
"activitypub.collection.type": __fedify_vocab.OrderedCollectionPage.typeId.href,
|
|
1162
1181
|
"fedify.collection.cursor": cursor
|
|
1163
1182
|
}
|
|
1164
1183
|
}, async (span) => {
|
|
@@ -1194,7 +1213,7 @@ async function handleCollection(request, { name, identifier, uriGetter, filter,
|
|
|
1194
1213
|
}
|
|
1195
1214
|
const partOf = new URL(context$2.url);
|
|
1196
1215
|
partOf.searchParams.delete("cursor");
|
|
1197
|
-
collection = new
|
|
1216
|
+
collection = new __fedify_vocab.OrderedCollectionPage({
|
|
1198
1217
|
id: uri,
|
|
1199
1218
|
prev,
|
|
1200
1219
|
next,
|
|
@@ -1202,7 +1221,6 @@ async function handleCollection(request, { name, identifier, uriGetter, filter,
|
|
|
1202
1221
|
partOf
|
|
1203
1222
|
});
|
|
1204
1223
|
}
|
|
1205
|
-
if (!acceptsJsonLd(request)) return await onNotAcceptable(request);
|
|
1206
1224
|
if (collectionCallbacks.authorizePredicate != null) {
|
|
1207
1225
|
let key = await context$2.getSignedKey();
|
|
1208
1226
|
key = key?.clone({}, { $warning: {
|
|
@@ -1243,7 +1261,7 @@ function filterCollectionItems(items, collectionName, filterPredicate) {
|
|
|
1243
1261
|
let logged = false;
|
|
1244
1262
|
for (const item of items) {
|
|
1245
1263
|
let mappedItem;
|
|
1246
|
-
if (item instanceof
|
|
1264
|
+
if (item instanceof __fedify_vocab.Object || item instanceof __fedify_vocab.Link || item instanceof URL) mappedItem = item;
|
|
1247
1265
|
else if (item.id == null) continue;
|
|
1248
1266
|
else mappedItem = item.id;
|
|
1249
1267
|
if (filterPredicate != null && !filterPredicate(item)) {
|
|
@@ -1270,7 +1288,7 @@ function filterCollectionItems(items, collectionName, filterPredicate) {
|
|
|
1270
1288
|
*/
|
|
1271
1289
|
async function handleInbox(request, options) {
|
|
1272
1290
|
const tracerProvider = options.tracerProvider ?? __opentelemetry_api.trace.getTracerProvider();
|
|
1273
|
-
const tracer = tracerProvider.getTracer(
|
|
1291
|
+
const tracer = tracerProvider.getTracer(require_http.deno_default.name, require_http.deno_default.version);
|
|
1274
1292
|
return await tracer.startActiveSpan("activitypub.inbox", {
|
|
1275
1293
|
kind: options.queue == null ? __opentelemetry_api.SpanKind.SERVER : __opentelemetry_api.SpanKind.PRODUCER,
|
|
1276
1294
|
attributes: { "activitypub.shared_inbox": options.recipient == null }
|
|
@@ -1297,7 +1315,8 @@ async function handleInbox(request, options) {
|
|
|
1297
1315
|
* @param span The OpenTelemetry span for tracing.
|
|
1298
1316
|
* @returns A promise that resolves to an HTTP response.
|
|
1299
1317
|
*/
|
|
1300
|
-
async function handleInboxInternal(request,
|
|
1318
|
+
async function handleInboxInternal(request, parameters, span) {
|
|
1319
|
+
const { recipient, context: ctx, inboxContextFactory, kv, kvPrefixes, queue, actorDispatcher, inboxListeners, inboxErrorHandler, onNotFound, signatureTimeWindow, skipSignatureVerification, tracerProvider } = parameters;
|
|
1301
1320
|
const logger$1 = (0, __logtape_logtape.getLogger)([
|
|
1302
1321
|
"fedify",
|
|
1303
1322
|
"federation",
|
|
@@ -1397,14 +1416,14 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
|
|
|
1397
1416
|
recipient,
|
|
1398
1417
|
json
|
|
1399
1418
|
});
|
|
1400
|
-
activity = await
|
|
1419
|
+
activity = await __fedify_vocab.Activity.fromJsonLd(jsonWithoutSig, ctx);
|
|
1401
1420
|
} else {
|
|
1402
1421
|
logger$1.debug("Linked Data Signatures are not verified.", {
|
|
1403
1422
|
recipient,
|
|
1404
1423
|
json
|
|
1405
1424
|
});
|
|
1406
1425
|
try {
|
|
1407
|
-
activity = await require_proof.verifyObject(
|
|
1426
|
+
activity = await require_proof.verifyObject(__fedify_vocab.Activity, jsonWithoutSig, {
|
|
1408
1427
|
contextLoader: ctx.contextLoader,
|
|
1409
1428
|
documentLoader: ctx.documentLoader,
|
|
1410
1429
|
keyCache,
|
|
@@ -1467,10 +1486,17 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
|
|
|
1467
1486
|
} else logger$1.debug("HTTP Signatures are verified.", { recipient });
|
|
1468
1487
|
httpSigKey = key;
|
|
1469
1488
|
}
|
|
1470
|
-
activity = await
|
|
1489
|
+
activity = await __fedify_vocab.Activity.fromJsonLd(jsonWithoutSig, ctx);
|
|
1471
1490
|
}
|
|
1472
1491
|
if (activity.id != null) span.setAttribute("activitypub.activity.id", activity.id.href);
|
|
1473
|
-
span.setAttribute("activitypub.activity.type",
|
|
1492
|
+
span.setAttribute("activitypub.activity.type", (0, __fedify_vocab.getTypeId)(activity).href);
|
|
1493
|
+
span.addEvent("activitypub.activity.received", {
|
|
1494
|
+
"activitypub.activity.json": JSON.stringify(json),
|
|
1495
|
+
"activitypub.activity.verified": activity != null,
|
|
1496
|
+
"ld_signatures.verified": ldSigVerified,
|
|
1497
|
+
"http_signatures.verified": httpSigKey != null,
|
|
1498
|
+
"http_signatures.key_id": httpSigKey?.id?.href ?? ""
|
|
1499
|
+
});
|
|
1474
1500
|
if (httpSigKey != null && !await require_proof.doesActorOwnKey(activity, httpSigKey, ctx)) {
|
|
1475
1501
|
logger$1.error("The signer ({keyId}) and the actor ({actorId}) do not match.", {
|
|
1476
1502
|
activity: json,
|
|
@@ -1499,7 +1525,8 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
|
|
|
1499
1525
|
kvPrefixes,
|
|
1500
1526
|
queue,
|
|
1501
1527
|
span,
|
|
1502
|
-
tracerProvider
|
|
1528
|
+
tracerProvider,
|
|
1529
|
+
idempotencyStrategy: parameters.idempotencyStrategy
|
|
1503
1530
|
});
|
|
1504
1531
|
if (routeResult === "alreadyProcessed") return new Response(`Activity <${activity.id}> has already been processed.`, {
|
|
1505
1532
|
status: 202,
|
|
@@ -1529,7 +1556,7 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
|
|
|
1529
1556
|
/**
|
|
1530
1557
|
* Handles a custom collection request.
|
|
1531
1558
|
* @template TItem The type of items in the collection.
|
|
1532
|
-
* @template
|
|
1559
|
+
* @template TParam The parameter names of the requested URL.
|
|
1533
1560
|
* @template TContext The type of the context, extending {@link RequestContext}.
|
|
1534
1561
|
* @template TContextData The context data to pass to the `TContext`.
|
|
1535
1562
|
* @param request The HTTP request.
|
|
@@ -1540,15 +1567,14 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
|
|
|
1540
1567
|
const handleCustomCollection = exceptWrapper(_handleCustomCollection);
|
|
1541
1568
|
async function _handleCustomCollection(request, { name, values, context: context$2, tracerProvider, collectionCallbacks: callbacks, filterPredicate }) {
|
|
1542
1569
|
verifyDefined(callbacks);
|
|
1543
|
-
verifyJsonLdRequest(request);
|
|
1544
1570
|
await authIfNeeded(context$2, values, callbacks);
|
|
1545
1571
|
const cursor = new URL(request.url).searchParams.get("cursor");
|
|
1546
|
-
return await new CustomCollectionHandler(name, values, context$2, callbacks, tracerProvider,
|
|
1572
|
+
return await new CustomCollectionHandler(name, values, context$2, callbacks, tracerProvider, __fedify_vocab.Collection, __fedify_vocab.CollectionPage, filterPredicate).fetchCollection(cursor).toJsonLd().then(respondAsActivity);
|
|
1547
1573
|
}
|
|
1548
1574
|
/**
|
|
1549
1575
|
* Handles an ordered collection request.
|
|
1550
1576
|
* @template TItem The type of items in the collection.
|
|
1551
|
-
* @template
|
|
1577
|
+
* @template TParam The parameter names of the requested URL.
|
|
1552
1578
|
* @template TContext The type of the context, extending {@link RequestContext}.
|
|
1553
1579
|
* @template TContextData The context data to pass to the `TContext`.
|
|
1554
1580
|
* @param request The HTTP request.
|
|
@@ -1559,17 +1585,16 @@ async function _handleCustomCollection(request, { name, values, context: context
|
|
|
1559
1585
|
const handleOrderedCollection = exceptWrapper(_handleOrderedCollection);
|
|
1560
1586
|
async function _handleOrderedCollection(request, { name, values, context: context$2, tracerProvider, collectionCallbacks: callbacks, filterPredicate }) {
|
|
1561
1587
|
verifyDefined(callbacks);
|
|
1562
|
-
verifyJsonLdRequest(request);
|
|
1563
1588
|
await authIfNeeded(context$2, values, callbacks);
|
|
1564
1589
|
const cursor = new URL(request.url).searchParams.get("cursor");
|
|
1565
|
-
return await new CustomCollectionHandler(name, values, context$2, callbacks, tracerProvider,
|
|
1590
|
+
return await new CustomCollectionHandler(name, values, context$2, callbacks, tracerProvider, __fedify_vocab.OrderedCollection, __fedify_vocab.OrderedCollectionPage, filterPredicate).fetchCollection(cursor).toJsonLd().then(respondAsActivity);
|
|
1566
1591
|
}
|
|
1567
1592
|
/**
|
|
1568
1593
|
* Handling custom collections with support for pagination and filtering.
|
|
1569
1594
|
* The main flow is on `getCollection`, `dispatch`.
|
|
1570
1595
|
*
|
|
1571
1596
|
* @template TItem The type of items in the collection.
|
|
1572
|
-
* @template
|
|
1597
|
+
* @template TParam The parameter names of the requested URL.
|
|
1573
1598
|
* @template TContext The type of the context. {@link Context} or {@link RequestContext}.
|
|
1574
1599
|
* @template TContextData The context data to pass to the `TContext`.
|
|
1575
1600
|
* @template TCollection The type of the collection, extending {@link Collection}.
|
|
@@ -1603,14 +1628,14 @@ var CustomCollectionHandler = class {
|
|
|
1603
1628
|
#collection = null;
|
|
1604
1629
|
/**
|
|
1605
1630
|
* Creates a new CustomCollection instance.
|
|
1606
|
-
* @param
|
|
1607
|
-
* @param
|
|
1608
|
-
* @param
|
|
1609
|
-
* @param
|
|
1610
|
-
* @param
|
|
1611
|
-
* @param
|
|
1612
|
-
* @param
|
|
1613
|
-
* @param
|
|
1631
|
+
* @param name The name of the collection.
|
|
1632
|
+
* @param values The parameter values for the collection.
|
|
1633
|
+
* @param context The request context.
|
|
1634
|
+
* @param callbacks The collection callbacks.
|
|
1635
|
+
* @param tracerProvider The tracer provider for telemetry.
|
|
1636
|
+
* @param Collection The Collection constructor.
|
|
1637
|
+
* @param CollectionPage The CollectionPage constructor.
|
|
1638
|
+
* @param filterPredicate Optional filter predicate for items.
|
|
1614
1639
|
*/
|
|
1615
1640
|
constructor(name, values, context$2, callbacks, tracerProvider = __opentelemetry_api.trace.getTracerProvider(), Collection$1, CollectionPage$1, filterPredicate) {
|
|
1616
1641
|
this.name = name;
|
|
@@ -1622,7 +1647,7 @@ var CustomCollectionHandler = class {
|
|
|
1622
1647
|
this.CollectionPage = CollectionPage$1;
|
|
1623
1648
|
this.filterPredicate = filterPredicate;
|
|
1624
1649
|
this.name = this.name.trim().replace(/\s+/g, "_");
|
|
1625
|
-
this.#tracer = this.tracerProvider.getTracer(
|
|
1650
|
+
this.#tracer = this.tracerProvider.getTracer(require_http.deno_default.name, require_http.deno_default.version);
|
|
1626
1651
|
this.#id = new URL(this.context.url);
|
|
1627
1652
|
this.#dispatcher = callbacks.dispatcher.bind(callbacks);
|
|
1628
1653
|
}
|
|
@@ -1735,7 +1760,7 @@ var CustomCollectionHandler = class {
|
|
|
1735
1760
|
/**
|
|
1736
1761
|
* Creates a function to wrap the dispatcher so tracing can be applied.
|
|
1737
1762
|
* @param params Parameters including cursor and total items.
|
|
1738
|
-
* @returns
|
|
1763
|
+
* @returns A function that handles the span operation.
|
|
1739
1764
|
*/
|
|
1740
1765
|
spanPages = ({ totalItems = null, cursor = null }) => async (span) => {
|
|
1741
1766
|
try {
|
|
@@ -1756,23 +1781,23 @@ var CustomCollectionHandler = class {
|
|
|
1756
1781
|
};
|
|
1757
1782
|
/**
|
|
1758
1783
|
* Dispatches the collection request to get items.
|
|
1759
|
-
* @param
|
|
1760
|
-
* @returns
|
|
1784
|
+
* @param cursor The cursor for pagination, or null for the first page.
|
|
1785
|
+
* @returns A promise that resolves to the page items.
|
|
1761
1786
|
*/
|
|
1762
1787
|
async dispatch(cursor = null) {
|
|
1763
1788
|
return await this.#dispatcher(this.context, this.values, cursor) ?? new ItemsNotFoundError().throw();
|
|
1764
1789
|
}
|
|
1765
1790
|
/**
|
|
1766
1791
|
* Filters the items in the collection.
|
|
1767
|
-
* @param
|
|
1768
|
-
* @returns
|
|
1792
|
+
* @param items The items to filter.
|
|
1793
|
+
* @returns The filtered items.
|
|
1769
1794
|
*/
|
|
1770
1795
|
filterItems(items) {
|
|
1771
1796
|
return filterCollectionItems(items, this.name, this.filterPredicate);
|
|
1772
1797
|
}
|
|
1773
1798
|
/**
|
|
1774
1799
|
* Appends a cursor to the URL if it exists.
|
|
1775
|
-
* @param
|
|
1800
|
+
* @param cursor The cursor to append, or null/undefined.
|
|
1776
1801
|
* @returns The URL with cursor appended, or null if cursor is null/undefined.
|
|
1777
1802
|
*/
|
|
1778
1803
|
appendToUrl(cursor) {
|
|
@@ -1780,8 +1805,7 @@ var CustomCollectionHandler = class {
|
|
|
1780
1805
|
}
|
|
1781
1806
|
/**
|
|
1782
1807
|
* Gets the stored collection or collection page.
|
|
1783
|
-
* @returns
|
|
1784
|
-
the collection or collection page.
|
|
1808
|
+
* @returns A promise that resolves to the collection or collection page.
|
|
1785
1809
|
*/
|
|
1786
1810
|
get collection() {
|
|
1787
1811
|
if (this.#collection === null) this.#collection = this.getCollection();
|
|
@@ -1789,8 +1813,8 @@ var CustomCollectionHandler = class {
|
|
|
1789
1813
|
}
|
|
1790
1814
|
/**
|
|
1791
1815
|
* Gets the total number of items in the collection.
|
|
1792
|
-
* @returns
|
|
1793
|
-
|
|
1816
|
+
* @returns A promise that resolves to the total items count,
|
|
1817
|
+
* or null if not available.
|
|
1794
1818
|
*/
|
|
1795
1819
|
get totalItems() {
|
|
1796
1820
|
if (this.#totalItems === void 0) this.totalItems = this.callbacks.counter?.(this.context, this.values);
|
|
@@ -1806,8 +1830,8 @@ var CustomCollectionHandler = class {
|
|
|
1806
1830
|
}
|
|
1807
1831
|
/**
|
|
1808
1832
|
* Gets the first cursor for pagination.
|
|
1809
|
-
* @returns
|
|
1810
|
-
or null if not available.
|
|
1833
|
+
* @returns A promise that resolves to the first cursor,
|
|
1834
|
+
* or null if not available.
|
|
1811
1835
|
*/
|
|
1812
1836
|
get firstCursor() {
|
|
1813
1837
|
const cursor = this.callbacks.firstCursor?.(this.context, this.values);
|
|
@@ -1837,10 +1861,9 @@ function exceptWrapper(handler) {
|
|
|
1837
1861
|
try {
|
|
1838
1862
|
return await handler(request, handlerParams);
|
|
1839
1863
|
} catch (error) {
|
|
1840
|
-
const { onNotFound,
|
|
1864
|
+
const { onNotFound, onUnauthorized } = handlerParams;
|
|
1841
1865
|
switch (error?.constructor) {
|
|
1842
1866
|
case ItemsNotFoundError: return await onNotFound(request);
|
|
1843
|
-
case NotAcceptableError: return await onNotAcceptable(request);
|
|
1844
1867
|
case UnauthorizedError: return await onUnauthorized(request);
|
|
1845
1868
|
default: throw error;
|
|
1846
1869
|
}
|
|
@@ -1858,15 +1881,6 @@ const verifyDefined = (callbacks) => {
|
|
|
1858
1881
|
if (callbacks === void 0) throw new ItemsNotFoundError();
|
|
1859
1882
|
};
|
|
1860
1883
|
/**
|
|
1861
|
-
* Verifies that a request accepts JSON-LD content type.
|
|
1862
|
-
* @param request The HTTP request to verify.
|
|
1863
|
-
* @throws {NotAcceptableError} If the request doesn't accept JSON-LD.
|
|
1864
|
-
* @since 1.8.0
|
|
1865
|
-
*/
|
|
1866
|
-
const verifyJsonLdRequest = (request) => {
|
|
1867
|
-
if (!acceptsJsonLd(request)) throw new NotAcceptableError();
|
|
1868
|
-
};
|
|
1869
|
-
/**
|
|
1870
1884
|
* Performs authorization if needed based on the authorization predicate.
|
|
1871
1885
|
* @template TContextData The context data type.
|
|
1872
1886
|
* @param {RequestContext<TContextData>} context The request context.
|
|
@@ -1950,15 +1964,6 @@ var ItemsNotFoundError = class extends HandlerError {
|
|
|
1950
1964
|
}
|
|
1951
1965
|
};
|
|
1952
1966
|
/**
|
|
1953
|
-
* Error thrown when the request is not acceptable (e.g., wrong content type).
|
|
1954
|
-
* @since 1.8.0
|
|
1955
|
-
*/
|
|
1956
|
-
var NotAcceptableError = class extends HandlerError {
|
|
1957
|
-
constructor() {
|
|
1958
|
-
super("The request is not acceptable.");
|
|
1959
|
-
}
|
|
1960
|
-
};
|
|
1961
|
-
/**
|
|
1962
1967
|
* Error thrown when access to a collection is unauthorized.
|
|
1963
1968
|
* @since 1.8.0
|
|
1964
1969
|
*/
|
|
@@ -2032,139 +2037,6 @@ function handleNodeInfoJrd(_request, context$2) {
|
|
|
2032
2037
|
return Promise.resolve(response);
|
|
2033
2038
|
}
|
|
2034
2039
|
|
|
2035
|
-
//#endregion
|
|
2036
|
-
//#region src/webfinger/handler.ts
|
|
2037
|
-
const logger = (0, __logtape_logtape.getLogger)([
|
|
2038
|
-
"fedify",
|
|
2039
|
-
"webfinger",
|
|
2040
|
-
"server"
|
|
2041
|
-
]);
|
|
2042
|
-
/**
|
|
2043
|
-
* Handles a WebFinger request. You would not typically call this function
|
|
2044
|
-
* directly, but instead use {@link Federation.fetch} method.
|
|
2045
|
-
* @param request The WebFinger request to handle.
|
|
2046
|
-
* @param parameters The parameters for handling the request.
|
|
2047
|
-
* @returns The response to the request.
|
|
2048
|
-
*/
|
|
2049
|
-
async function handleWebFinger(request, options) {
|
|
2050
|
-
if (options.tracer == null) return await handleWebFingerInternal(request, options);
|
|
2051
|
-
return await options.tracer.startActiveSpan("webfinger.handle", { kind: __opentelemetry_api.SpanKind.SERVER }, async (span) => {
|
|
2052
|
-
try {
|
|
2053
|
-
const response = await handleWebFingerInternal(request, options);
|
|
2054
|
-
span.setStatus({ code: response.ok ? __opentelemetry_api.SpanStatusCode.UNSET : __opentelemetry_api.SpanStatusCode.ERROR });
|
|
2055
|
-
return response;
|
|
2056
|
-
} catch (error) {
|
|
2057
|
-
span.setStatus({
|
|
2058
|
-
code: __opentelemetry_api.SpanStatusCode.ERROR,
|
|
2059
|
-
message: String(error)
|
|
2060
|
-
});
|
|
2061
|
-
throw error;
|
|
2062
|
-
} finally {
|
|
2063
|
-
span.end();
|
|
2064
|
-
}
|
|
2065
|
-
});
|
|
2066
|
-
}
|
|
2067
|
-
async function handleWebFingerInternal(request, { context: context$2, host, actorDispatcher, actorHandleMapper, actorAliasMapper, onNotFound, span, webFingerLinksDispatcher }) {
|
|
2068
|
-
if (actorDispatcher == null) {
|
|
2069
|
-
logger.error("Actor dispatcher is not set.");
|
|
2070
|
-
return await onNotFound(request);
|
|
2071
|
-
}
|
|
2072
|
-
const resource = context$2.url.searchParams.get("resource");
|
|
2073
|
-
if (resource == null) return new Response("Missing resource parameter.", { status: 400 });
|
|
2074
|
-
span?.setAttribute("webfinger.resource", resource);
|
|
2075
|
-
let resourceUrl;
|
|
2076
|
-
try {
|
|
2077
|
-
resourceUrl = new URL(resource);
|
|
2078
|
-
} catch (e) {
|
|
2079
|
-
if (e instanceof TypeError) return new Response("Invalid resource URL.", { status: 400 });
|
|
2080
|
-
throw e;
|
|
2081
|
-
}
|
|
2082
|
-
span?.setAttribute("webfinger.resource.scheme", resourceUrl.protocol.replace(/:$/, ""));
|
|
2083
|
-
async function mapUsernameToIdentifier(username) {
|
|
2084
|
-
if (actorHandleMapper == null) {
|
|
2085
|
-
logger.error("No actor handle mapper is set; use the WebFinger username {username} as the actor's internal identifier.", { username });
|
|
2086
|
-
return username;
|
|
2087
|
-
}
|
|
2088
|
-
const identifier$1 = await actorHandleMapper(context$2, username);
|
|
2089
|
-
if (identifier$1 == null) {
|
|
2090
|
-
logger.error("Actor {username} not found.", { username });
|
|
2091
|
-
return null;
|
|
2092
|
-
}
|
|
2093
|
-
return identifier$1;
|
|
2094
|
-
}
|
|
2095
|
-
let identifier = null;
|
|
2096
|
-
const uriParsed = context$2.parseUri(resourceUrl);
|
|
2097
|
-
if (uriParsed?.type != "actor") {
|
|
2098
|
-
const match = /^acct:([^@]+)@([^@]+)$/.exec(resource);
|
|
2099
|
-
if (match == null) {
|
|
2100
|
-
const result = await actorAliasMapper?.(context$2, resourceUrl);
|
|
2101
|
-
if (result == null) return await onNotFound(request);
|
|
2102
|
-
if ("identifier" in result) identifier = result.identifier;
|
|
2103
|
-
else identifier = await mapUsernameToIdentifier(result.username);
|
|
2104
|
-
} else {
|
|
2105
|
-
const portMatch = /:\d+$/.exec(match[2]);
|
|
2106
|
-
const normalizedHost = portMatch == null ? (0, node_url.domainToASCII)(match[2].toLowerCase()) : (0, node_url.domainToASCII)(match[2].substring(0, portMatch.index).toLowerCase()) + portMatch[0];
|
|
2107
|
-
if (normalizedHost != context$2.url.host && normalizedHost != host) return await onNotFound(request);
|
|
2108
|
-
else {
|
|
2109
|
-
identifier = await mapUsernameToIdentifier(match[1]);
|
|
2110
|
-
resourceUrl = new URL(`acct:${match[1]}@${normalizedHost}`);
|
|
2111
|
-
}
|
|
2112
|
-
}
|
|
2113
|
-
} else identifier = uriParsed.identifier;
|
|
2114
|
-
if (identifier == null) return await onNotFound(request);
|
|
2115
|
-
const actor = await actorDispatcher(context$2, identifier);
|
|
2116
|
-
if (actor == null) {
|
|
2117
|
-
logger.error("Actor {identifier} not found.", { identifier });
|
|
2118
|
-
return await onNotFound(request);
|
|
2119
|
-
}
|
|
2120
|
-
const links = [{
|
|
2121
|
-
rel: "self",
|
|
2122
|
-
href: context$2.getActorUri(identifier).href,
|
|
2123
|
-
type: "application/activity+json"
|
|
2124
|
-
}];
|
|
2125
|
-
for (const url of actor.urls) if (url instanceof require_actor.Link && url.href != null) links.push({
|
|
2126
|
-
rel: url.rel ?? "http://webfinger.net/rel/profile-page",
|
|
2127
|
-
href: url.href.href,
|
|
2128
|
-
type: url.mediaType == null ? void 0 : url.mediaType
|
|
2129
|
-
});
|
|
2130
|
-
else if (url instanceof URL) links.push({
|
|
2131
|
-
rel: "http://webfinger.net/rel/profile-page",
|
|
2132
|
-
href: url.href
|
|
2133
|
-
});
|
|
2134
|
-
for await (const image of actor.getIcons()) {
|
|
2135
|
-
if (image.url?.href == null) continue;
|
|
2136
|
-
const link = {
|
|
2137
|
-
rel: "http://webfinger.net/rel/avatar",
|
|
2138
|
-
href: image.url.href.toString()
|
|
2139
|
-
};
|
|
2140
|
-
if (image.mediaType != null) link.type = image.mediaType;
|
|
2141
|
-
links.push(link);
|
|
2142
|
-
}
|
|
2143
|
-
if (webFingerLinksDispatcher != null) {
|
|
2144
|
-
const customLinks = await webFingerLinksDispatcher(context$2, resourceUrl);
|
|
2145
|
-
if (customLinks != null) for (const link of customLinks) links.push(link);
|
|
2146
|
-
}
|
|
2147
|
-
const aliases = [];
|
|
2148
|
-
if (resourceUrl.protocol != "acct:" && actor.preferredUsername != null) {
|
|
2149
|
-
aliases.push(`acct:${actor.preferredUsername}@${host ?? context$2.url.host}`);
|
|
2150
|
-
if (host != null && host !== context$2.url.host) aliases.push(`acct:${actor.preferredUsername}@${context$2.url.host}`);
|
|
2151
|
-
}
|
|
2152
|
-
if (resourceUrl.href !== context$2.getActorUri(identifier).href) aliases.push(context$2.getActorUri(identifier).href);
|
|
2153
|
-
if (resourceUrl.protocol === "acct:" && host != null && host !== context$2.url.host && !resourceUrl.href.endsWith(`@${host}`)) {
|
|
2154
|
-
const username = resourceUrl.href.replace(/^acct:/, "").replace(/@.*$/, "");
|
|
2155
|
-
aliases.push(`acct:${username}@${host}`);
|
|
2156
|
-
}
|
|
2157
|
-
const jrd = {
|
|
2158
|
-
subject: resourceUrl.href,
|
|
2159
|
-
aliases,
|
|
2160
|
-
links
|
|
2161
|
-
};
|
|
2162
|
-
return new Response(JSON.stringify(jrd), { headers: {
|
|
2163
|
-
"Content-Type": "application/jrd+json",
|
|
2164
|
-
"Access-Control-Allow-Origin": "*"
|
|
2165
|
-
} });
|
|
2166
|
-
}
|
|
2167
|
-
|
|
2168
2040
|
//#endregion
|
|
2169
2041
|
//#region src/federation/retry.ts
|
|
2170
2042
|
/**
|
|
@@ -2233,7 +2105,7 @@ function extractInboxes({ recipients, preferSharedInbox, excludeBaseUris }) {
|
|
|
2233
2105
|
*/
|
|
2234
2106
|
function sendActivity(options) {
|
|
2235
2107
|
const tracerProvider = options.tracerProvider ?? __opentelemetry_api.trace.getTracerProvider();
|
|
2236
|
-
const tracer = tracerProvider.getTracer(
|
|
2108
|
+
const tracer = tracerProvider.getTracer(require_http.deno_default.name, require_http.deno_default.version);
|
|
2237
2109
|
return tracer.startActiveSpan("activitypub.send_activity", {
|
|
2238
2110
|
kind: __opentelemetry_api.SpanKind.CLIENT,
|
|
2239
2111
|
attributes: { "activitypub.shared_inbox": options.sharedInbox ?? false }
|
|
@@ -2244,7 +2116,7 @@ function sendActivity(options) {
|
|
|
2244
2116
|
await sendActivityInternal({
|
|
2245
2117
|
...options,
|
|
2246
2118
|
tracerProvider
|
|
2247
|
-
});
|
|
2119
|
+
}, span);
|
|
2248
2120
|
} catch (e) {
|
|
2249
2121
|
span.setStatus({
|
|
2250
2122
|
code: __opentelemetry_api.SpanStatusCode.ERROR,
|
|
@@ -2256,7 +2128,7 @@ function sendActivity(options) {
|
|
|
2256
2128
|
}
|
|
2257
2129
|
});
|
|
2258
2130
|
}
|
|
2259
|
-
async function sendActivityInternal({ activity, activityId, keys, inbox, headers, specDeterminer, tracerProvider }) {
|
|
2131
|
+
async function sendActivityInternal({ activity, activityId, keys, inbox, headers, specDeterminer, tracerProvider }, span) {
|
|
2260
2132
|
const logger$1 = (0, __logtape_logtape.getLogger)([
|
|
2261
2133
|
"fedify",
|
|
2262
2134
|
"federation",
|
|
@@ -2311,6 +2183,143 @@ async function sendActivityInternal({ activity, activityId, keys, inbox, headers
|
|
|
2311
2183
|
});
|
|
2312
2184
|
throw new Error(`Failed to send activity ${activityId} to ${inbox.href} (${response.status} ${response.statusText}):\n${error}`);
|
|
2313
2185
|
}
|
|
2186
|
+
span.addEvent("activitypub.activity.sent", {
|
|
2187
|
+
"activitypub.activity.json": JSON.stringify(activity),
|
|
2188
|
+
"activitypub.inbox.url": inbox.href,
|
|
2189
|
+
"activitypub.activity.id": activityId ?? ""
|
|
2190
|
+
});
|
|
2191
|
+
}
|
|
2192
|
+
|
|
2193
|
+
//#endregion
|
|
2194
|
+
//#region src/federation/webfinger.ts
|
|
2195
|
+
const logger = (0, __logtape_logtape.getLogger)([
|
|
2196
|
+
"fedify",
|
|
2197
|
+
"webfinger",
|
|
2198
|
+
"server"
|
|
2199
|
+
]);
|
|
2200
|
+
/**
|
|
2201
|
+
* Handles a WebFinger request. You would not typically call this function
|
|
2202
|
+
* directly, but instead use {@link Federation.fetch} method.
|
|
2203
|
+
* @param request The WebFinger request to handle.
|
|
2204
|
+
* @param parameters The parameters for handling the request.
|
|
2205
|
+
* @returns The response to the request.
|
|
2206
|
+
*/
|
|
2207
|
+
async function handleWebFinger(request, options) {
|
|
2208
|
+
if (options.tracer == null) return await handleWebFingerInternal(request, options);
|
|
2209
|
+
return await options.tracer.startActiveSpan("webfinger.handle", { kind: __opentelemetry_api.SpanKind.SERVER }, async (span) => {
|
|
2210
|
+
try {
|
|
2211
|
+
const response = await handleWebFingerInternal(request, options);
|
|
2212
|
+
span.setStatus({ code: response.ok ? __opentelemetry_api.SpanStatusCode.UNSET : __opentelemetry_api.SpanStatusCode.ERROR });
|
|
2213
|
+
return response;
|
|
2214
|
+
} catch (error) {
|
|
2215
|
+
span.setStatus({
|
|
2216
|
+
code: __opentelemetry_api.SpanStatusCode.ERROR,
|
|
2217
|
+
message: String(error)
|
|
2218
|
+
});
|
|
2219
|
+
throw error;
|
|
2220
|
+
} finally {
|
|
2221
|
+
span.end();
|
|
2222
|
+
}
|
|
2223
|
+
});
|
|
2224
|
+
}
|
|
2225
|
+
async function handleWebFingerInternal(request, { context: context$2, host, actorDispatcher, actorHandleMapper, actorAliasMapper, onNotFound, span, webFingerLinksDispatcher }) {
|
|
2226
|
+
if (actorDispatcher == null) {
|
|
2227
|
+
logger.error("Actor dispatcher is not set.");
|
|
2228
|
+
return await onNotFound(request);
|
|
2229
|
+
}
|
|
2230
|
+
const resource = context$2.url.searchParams.get("resource");
|
|
2231
|
+
if (resource == null) return new Response("Missing resource parameter.", { status: 400 });
|
|
2232
|
+
span?.setAttribute("webfinger.resource", resource);
|
|
2233
|
+
let resourceUrl;
|
|
2234
|
+
try {
|
|
2235
|
+
resourceUrl = new URL(resource);
|
|
2236
|
+
} catch (e) {
|
|
2237
|
+
if (e instanceof TypeError) return new Response("Invalid resource URL.", { status: 400 });
|
|
2238
|
+
throw e;
|
|
2239
|
+
}
|
|
2240
|
+
span?.setAttribute("webfinger.resource.scheme", resourceUrl.protocol.replace(/:$/, ""));
|
|
2241
|
+
async function mapUsernameToIdentifier(username) {
|
|
2242
|
+
if (actorHandleMapper == null) {
|
|
2243
|
+
logger.error("No actor handle mapper is set; use the WebFinger username {username} as the actor's internal identifier.", { username });
|
|
2244
|
+
return username;
|
|
2245
|
+
}
|
|
2246
|
+
const identifier$1 = await actorHandleMapper(context$2, username);
|
|
2247
|
+
if (identifier$1 == null) {
|
|
2248
|
+
logger.error("Actor {username} not found.", { username });
|
|
2249
|
+
return null;
|
|
2250
|
+
}
|
|
2251
|
+
return identifier$1;
|
|
2252
|
+
}
|
|
2253
|
+
let identifier = null;
|
|
2254
|
+
const uriParsed = context$2.parseUri(resourceUrl);
|
|
2255
|
+
if (uriParsed?.type != "actor") {
|
|
2256
|
+
const match = /^acct:([^@]+)@([^@]+)$/.exec(resource);
|
|
2257
|
+
if (match == null) {
|
|
2258
|
+
const result = await actorAliasMapper?.(context$2, resourceUrl);
|
|
2259
|
+
if (result == null) return await onNotFound(request);
|
|
2260
|
+
if ("identifier" in result) identifier = result.identifier;
|
|
2261
|
+
else identifier = await mapUsernameToIdentifier(result.username);
|
|
2262
|
+
} else {
|
|
2263
|
+
const portMatch = /:\d+$/.exec(match[2]);
|
|
2264
|
+
const normalizedHost = portMatch == null ? (0, node_url.domainToASCII)(match[2].toLowerCase()) : (0, node_url.domainToASCII)(match[2].substring(0, portMatch.index).toLowerCase()) + portMatch[0];
|
|
2265
|
+
if (normalizedHost != context$2.url.host && normalizedHost != host) return await onNotFound(request);
|
|
2266
|
+
else {
|
|
2267
|
+
identifier = await mapUsernameToIdentifier(match[1]);
|
|
2268
|
+
resourceUrl = new URL(`acct:${match[1]}@${normalizedHost}`);
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
} else identifier = uriParsed.identifier;
|
|
2272
|
+
if (identifier == null) return await onNotFound(request);
|
|
2273
|
+
const actor = await actorDispatcher(context$2, identifier);
|
|
2274
|
+
if (actor == null) {
|
|
2275
|
+
logger.error("Actor {identifier} not found.", { identifier });
|
|
2276
|
+
return await onNotFound(request);
|
|
2277
|
+
}
|
|
2278
|
+
const links = [{
|
|
2279
|
+
rel: "self",
|
|
2280
|
+
href: context$2.getActorUri(identifier).href,
|
|
2281
|
+
type: "application/activity+json"
|
|
2282
|
+
}];
|
|
2283
|
+
for (const url of actor.urls) if (url instanceof __fedify_vocab.Link && url.href != null) links.push({
|
|
2284
|
+
rel: url.rel ?? "http://webfinger.net/rel/profile-page",
|
|
2285
|
+
href: url.href.href,
|
|
2286
|
+
type: url.mediaType == null ? void 0 : url.mediaType
|
|
2287
|
+
});
|
|
2288
|
+
else if (url instanceof URL) links.push({
|
|
2289
|
+
rel: "http://webfinger.net/rel/profile-page",
|
|
2290
|
+
href: url.href
|
|
2291
|
+
});
|
|
2292
|
+
for await (const image of actor.getIcons()) {
|
|
2293
|
+
if (image.url?.href == null) continue;
|
|
2294
|
+
links.push({
|
|
2295
|
+
rel: "http://webfinger.net/rel/avatar",
|
|
2296
|
+
href: image.url.href.toString(),
|
|
2297
|
+
...image.mediaType != null && { type: image.mediaType }
|
|
2298
|
+
});
|
|
2299
|
+
}
|
|
2300
|
+
if (webFingerLinksDispatcher != null) {
|
|
2301
|
+
const customLinks = await webFingerLinksDispatcher(context$2, resourceUrl);
|
|
2302
|
+
if (customLinks != null) for (const link of customLinks) links.push(link);
|
|
2303
|
+
}
|
|
2304
|
+
const aliases = [];
|
|
2305
|
+
if (resourceUrl.protocol != "acct:" && actor.preferredUsername != null) {
|
|
2306
|
+
aliases.push(`acct:${actor.preferredUsername}@${host ?? context$2.url.host}`);
|
|
2307
|
+
if (host != null && host !== context$2.url.host) aliases.push(`acct:${actor.preferredUsername}@${context$2.url.host}`);
|
|
2308
|
+
}
|
|
2309
|
+
if (resourceUrl.href !== context$2.getActorUri(identifier).href) aliases.push(context$2.getActorUri(identifier).href);
|
|
2310
|
+
if (resourceUrl.protocol === "acct:" && host != null && host !== context$2.url.host && !resourceUrl.href.endsWith(`@${host}`)) {
|
|
2311
|
+
const username = resourceUrl.href.replace(/^acct:/, "").replace(/@.*$/, "");
|
|
2312
|
+
aliases.push(`acct:${username}@${host}`);
|
|
2313
|
+
}
|
|
2314
|
+
const jrd = {
|
|
2315
|
+
subject: resourceUrl.href,
|
|
2316
|
+
aliases,
|
|
2317
|
+
links
|
|
2318
|
+
};
|
|
2319
|
+
return new Response(JSON.stringify(jrd), { headers: {
|
|
2320
|
+
"Content-Type": "application/jrd+json",
|
|
2321
|
+
"Access-Control-Allow-Origin": "*"
|
|
2322
|
+
} });
|
|
2314
2323
|
}
|
|
2315
2324
|
|
|
2316
2325
|
//#endregion
|
|
@@ -2350,7 +2359,6 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2350
2359
|
firstKnock;
|
|
2351
2360
|
constructor(options) {
|
|
2352
2361
|
super();
|
|
2353
|
-
const logger$1 = (0, __logtape_logtape.getLogger)(["fedify", "federation"]);
|
|
2354
2362
|
this.kv = options.kv;
|
|
2355
2363
|
this.kvPrefixes = {
|
|
2356
2364
|
activityIdempotence: ["_fedify", "activityIdempotence"],
|
|
@@ -2398,14 +2406,15 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2398
2406
|
this.router.trailingSlashInsensitive = options.trailingSlashInsensitive ?? false;
|
|
2399
2407
|
this._initializeRouter();
|
|
2400
2408
|
if (options.allowPrivateAddress || options.userAgent != null) {
|
|
2401
|
-
if (options.
|
|
2402
|
-
|
|
2409
|
+
if (options.documentLoaderFactory != null) throw new TypeError("Cannot set documentLoaderFactory with allowPrivateAddress or userAgent options.");
|
|
2410
|
+
if (options.contextLoaderFactory != null) throw new TypeError("Cannot set contextLoaderFactory with allowPrivateAddress or userAgent options.");
|
|
2411
|
+
if (options.authenticatedDocumentLoaderFactory != null) throw new TypeError("Cannot set authenticatedDocumentLoaderFactory with allowPrivateAddress or userAgent options.");
|
|
2403
2412
|
}
|
|
2404
2413
|
const { allowPrivateAddress, userAgent } = options;
|
|
2405
2414
|
this.allowPrivateAddress = allowPrivateAddress ?? false;
|
|
2406
2415
|
this.documentLoaderFactory = options.documentLoaderFactory ?? ((opts) => {
|
|
2407
|
-
return
|
|
2408
|
-
loader:
|
|
2416
|
+
return require_kv_cache.kvCache({
|
|
2417
|
+
loader: (0, __fedify_vocab_runtime.getDocumentLoader)({
|
|
2409
2418
|
allowPrivateAddress: opts?.allowPrivateAddress ?? allowPrivateAddress,
|
|
2410
2419
|
userAgent: opts?.userAgent ?? userAgent
|
|
2411
2420
|
}),
|
|
@@ -2413,12 +2422,8 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2413
2422
|
prefix: this.kvPrefixes.remoteDocument
|
|
2414
2423
|
});
|
|
2415
2424
|
});
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
this.contextLoaderFactory = () => options.contextLoader;
|
|
2419
|
-
logger$1.warn("The contextLoader option is deprecated; use contextLoaderFactory option instead.");
|
|
2420
|
-
} else this.contextLoaderFactory = options.contextLoaderFactory ?? this.documentLoaderFactory;
|
|
2421
|
-
this.authenticatedDocumentLoaderFactory = options.authenticatedDocumentLoaderFactory ?? ((identity) => require_authdocloader.getAuthenticatedDocumentLoader(identity, {
|
|
2425
|
+
this.contextLoaderFactory = options.contextLoaderFactory ?? this.documentLoaderFactory;
|
|
2426
|
+
this.authenticatedDocumentLoaderFactory = options.authenticatedDocumentLoaderFactory ?? ((identity) => require_kv_cache.getAuthenticatedDocumentLoader(identity, {
|
|
2422
2427
|
allowPrivateAddress,
|
|
2423
2428
|
userAgent,
|
|
2424
2429
|
specDeterminer: new KvSpecDeterminer(this.kv, this.kvPrefixes.httpMessageSignaturesSpec, options.firstKnock),
|
|
@@ -2439,7 +2444,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2439
2444
|
this.router.add("/.well-known/nodeinfo", "nodeInfoJrd");
|
|
2440
2445
|
}
|
|
2441
2446
|
_getTracer() {
|
|
2442
|
-
return this.tracerProvider.getTracer(
|
|
2447
|
+
return this.tracerProvider.getTracer(require_http.deno_default.name, require_http.deno_default.version);
|
|
2443
2448
|
}
|
|
2444
2449
|
async _startQueueInternal(ctxData, signal, queue) {
|
|
2445
2450
|
if (this.inboxQueue == null && this.outboxQueue == null) return;
|
|
@@ -2537,9 +2542,9 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2537
2542
|
});
|
|
2538
2543
|
const keys = await Promise.all(message.keys.map(async ({ keyId, privateKey }) => ({
|
|
2539
2544
|
keyId: new URL(keyId),
|
|
2540
|
-
privateKey: await
|
|
2545
|
+
privateKey: await require_http.importJwk(privateKey, "private")
|
|
2541
2546
|
})));
|
|
2542
|
-
const activity = await
|
|
2547
|
+
const activity = await __fedify_vocab.Activity.fromJsonLd(message.activity, {
|
|
2543
2548
|
contextLoader: this.contextLoaderFactory({
|
|
2544
2549
|
allowPrivateAddress: this.allowPrivateAddress,
|
|
2545
2550
|
userAgent: this.userAgent
|
|
@@ -2578,7 +2583,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2578
2583
|
for (const { keyId, privateKey } of message.keys) {
|
|
2579
2584
|
const pair = {
|
|
2580
2585
|
keyId: new URL(keyId),
|
|
2581
|
-
privateKey: await
|
|
2586
|
+
privateKey: await require_http.importJwk(privateKey, "private")
|
|
2582
2587
|
};
|
|
2583
2588
|
if (rsaKeyPair == null && pair.privateKey.algorithm.name === "RSASSA-PKCS1-v1_5") rsaKeyPair = pair;
|
|
2584
2589
|
keys.push(pair);
|
|
@@ -2601,7 +2606,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2601
2606
|
message: String(error)
|
|
2602
2607
|
});
|
|
2603
2608
|
const loaderOptions = this.#getLoaderOptions(message.baseUrl);
|
|
2604
|
-
const activity = await
|
|
2609
|
+
const activity = await __fedify_vocab.Activity.fromJsonLd(message.activity, {
|
|
2605
2610
|
contextLoader: this.contextLoaderFactory(loaderOptions),
|
|
2606
2611
|
documentLoader: rsaKeyPair == null ? this.documentLoaderFactory(loaderOptions) : this.authenticatedDocumentLoaderFactory(rsaKeyPair, loaderOptions),
|
|
2607
2612
|
tracerProvider: this.tracerProvider
|
|
@@ -2655,8 +2660,8 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2655
2660
|
const identity = await this.sharedInboxKeyDispatcher(context$2);
|
|
2656
2661
|
if (identity != null) context$2 = this.#createContext(baseUrl, ctxData, { documentLoader: "identifier" in identity || "username" in identity || "handle" in identity ? await context$2.getDocumentLoader(identity) : context$2.getDocumentLoader(identity) });
|
|
2657
2662
|
}
|
|
2658
|
-
const activity = await
|
|
2659
|
-
span.setAttribute("activitypub.activity.type",
|
|
2663
|
+
const activity = await __fedify_vocab.Activity.fromJsonLd(message.activity, context$2);
|
|
2664
|
+
span.setAttribute("activitypub.activity.type", (0, __fedify_vocab.getTypeId)(activity).href);
|
|
2660
2665
|
if (activity.id != null) span.setAttribute("activitypub.activity.id", activity.id.href);
|
|
2661
2666
|
const cacheKey = activity.id == null ? null : [
|
|
2662
2667
|
...this.kvPrefixes.activityIdempotence,
|
|
@@ -2685,7 +2690,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2685
2690
|
});
|
|
2686
2691
|
span$1.setStatus({
|
|
2687
2692
|
code: __opentelemetry_api.SpanStatusCode.ERROR,
|
|
2688
|
-
message: `Unsupported activity type: ${
|
|
2693
|
+
message: `Unsupported activity type: ${(0, __fedify_vocab.getTypeId)(activity).href}`
|
|
2689
2694
|
});
|
|
2690
2695
|
span$1.end();
|
|
2691
2696
|
return;
|
|
@@ -2693,7 +2698,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2693
2698
|
const { class: cls, listener } = dispatched;
|
|
2694
2699
|
span$1.updateName(`activitypub.dispatch_inbox_listener ${cls.name}`);
|
|
2695
2700
|
try {
|
|
2696
|
-
await listener(context$2.toInboxContext(message.identifier, message.activity, activity.id?.href,
|
|
2701
|
+
await listener(context$2.toInboxContext(message.identifier, message.activity, activity.id?.href, (0, __fedify_vocab.getTypeId)(activity).href), activity);
|
|
2697
2702
|
} catch (error) {
|
|
2698
2703
|
try {
|
|
2699
2704
|
await this.inboxErrorHandler?.(context$2, error);
|
|
@@ -2813,7 +2818,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2813
2818
|
let proofCreated = false;
|
|
2814
2819
|
let rsaKey = null;
|
|
2815
2820
|
for (const { keyId, privateKey } of keys) {
|
|
2816
|
-
|
|
2821
|
+
require_http.validateCryptoKey(privateKey, "private");
|
|
2817
2822
|
if (rsaKey == null && privateKey.algorithm.name === "RSASSA-PKCS1-v1_5") {
|
|
2818
2823
|
rsaKey = {
|
|
2819
2824
|
keyId,
|
|
@@ -2865,7 +2870,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2865
2870
|
keys,
|
|
2866
2871
|
activity: jsonLd,
|
|
2867
2872
|
activityId: activity.id?.href,
|
|
2868
|
-
activityType:
|
|
2873
|
+
activityType: (0, __fedify_vocab.getTypeId)(activity).href,
|
|
2869
2874
|
inbox: new URL(inbox),
|
|
2870
2875
|
sharedInbox: inboxes[inbox].sharedInbox,
|
|
2871
2876
|
headers: collectionSync == null ? void 0 : new Headers({ "Collection-Synchronization": await buildCollectionSynchronizationHeader(collectionSync, inboxes[inbox].actorIds) }),
|
|
@@ -2881,7 +2886,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2881
2886
|
});
|
|
2882
2887
|
const keyJwkPairs = [];
|
|
2883
2888
|
for (const { keyId, privateKey } of keys) {
|
|
2884
|
-
const privateKeyJwk = await
|
|
2889
|
+
const privateKeyJwk = await require_http.exportJwk(privateKey);
|
|
2885
2890
|
keyJwkPairs.push({
|
|
2886
2891
|
keyId: keyId.href,
|
|
2887
2892
|
privateKey: privateKeyJwk
|
|
@@ -2899,7 +2904,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2899
2904
|
keys: keyJwkPairs,
|
|
2900
2905
|
activity: jsonLd,
|
|
2901
2906
|
activityId: activity.id?.href,
|
|
2902
|
-
activityType:
|
|
2907
|
+
activityType: (0, __fedify_vocab.getTypeId)(activity).href,
|
|
2903
2908
|
inbox,
|
|
2904
2909
|
sharedInbox: inboxes[inbox].sharedInbox,
|
|
2905
2910
|
started: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -2956,6 +2961,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2956
2961
|
span,
|
|
2957
2962
|
tracer
|
|
2958
2963
|
});
|
|
2964
|
+
if (acceptsJsonLd(request)) response.headers.set("Vary", "Accept");
|
|
2959
2965
|
} catch (error) {
|
|
2960
2966
|
span.setStatus({
|
|
2961
2967
|
code: __opentelemetry_api.SpanStatusCode.ERROR,
|
|
@@ -3019,6 +3025,9 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3019
3025
|
context: context$2,
|
|
3020
3026
|
nodeInfoDispatcher: this.nodeInfoDispatcher
|
|
3021
3027
|
});
|
|
3028
|
+
}
|
|
3029
|
+
if (request.method !== "POST" && !acceptsJsonLd(request)) return await onNotAcceptable(request);
|
|
3030
|
+
switch (routeName) {
|
|
3022
3031
|
case "actor":
|
|
3023
3032
|
context$2 = this.#createContext(request, contextData, { invokedFromActorDispatcher: { identifier: route.values.identifier ?? route.values.handle } });
|
|
3024
3033
|
return await handleActor(request, {
|
|
@@ -3027,8 +3036,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3027
3036
|
actorDispatcher: this.actorCallbacks?.dispatcher,
|
|
3028
3037
|
authorizePredicate: this.actorCallbacks?.authorizePredicate,
|
|
3029
3038
|
onUnauthorized,
|
|
3030
|
-
onNotFound
|
|
3031
|
-
onNotAcceptable
|
|
3039
|
+
onNotFound
|
|
3032
3040
|
});
|
|
3033
3041
|
case "object": {
|
|
3034
3042
|
const typeId = route.name.replace(/^object:/, "");
|
|
@@ -3044,8 +3052,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3044
3052
|
objectDispatcher: callbacks?.dispatcher,
|
|
3045
3053
|
authorizePredicate: callbacks?.authorizePredicate,
|
|
3046
3054
|
onUnauthorized,
|
|
3047
|
-
onNotFound
|
|
3048
|
-
onNotAcceptable
|
|
3055
|
+
onNotFound
|
|
3049
3056
|
});
|
|
3050
3057
|
}
|
|
3051
3058
|
case "outbox": return await handleCollection(request, {
|
|
@@ -3056,8 +3063,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3056
3063
|
collectionCallbacks: this.outboxCallbacks,
|
|
3057
3064
|
tracerProvider: this.tracerProvider,
|
|
3058
3065
|
onUnauthorized,
|
|
3059
|
-
onNotFound
|
|
3060
|
-
onNotAcceptable
|
|
3066
|
+
onNotFound
|
|
3061
3067
|
});
|
|
3062
3068
|
case "inbox":
|
|
3063
3069
|
if (request.method !== "POST") return await handleCollection(request, {
|
|
@@ -3068,8 +3074,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3068
3074
|
collectionCallbacks: this.inboxCallbacks,
|
|
3069
3075
|
tracerProvider: this.tracerProvider,
|
|
3070
3076
|
onUnauthorized,
|
|
3071
|
-
onNotFound
|
|
3072
|
-
onNotAcceptable
|
|
3077
|
+
onNotFound
|
|
3073
3078
|
});
|
|
3074
3079
|
context$2 = this.#createContext(request, contextData, { documentLoader: await context$2.getDocumentLoader({ identifier: route.values.identifier ?? route.values.handle }) });
|
|
3075
3080
|
case "sharedInbox":
|
|
@@ -3091,7 +3096,8 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3091
3096
|
onNotFound,
|
|
3092
3097
|
signatureTimeWindow: this.signatureTimeWindow,
|
|
3093
3098
|
skipSignatureVerification: this.skipSignatureVerification,
|
|
3094
|
-
tracerProvider: this.tracerProvider
|
|
3099
|
+
tracerProvider: this.tracerProvider,
|
|
3100
|
+
idempotencyStrategy: this.idempotencyStrategy
|
|
3095
3101
|
});
|
|
3096
3102
|
case "following": return await handleCollection(request, {
|
|
3097
3103
|
name: "following",
|
|
@@ -3101,8 +3107,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3101
3107
|
collectionCallbacks: this.followingCallbacks,
|
|
3102
3108
|
tracerProvider: this.tracerProvider,
|
|
3103
3109
|
onUnauthorized,
|
|
3104
|
-
onNotFound
|
|
3105
|
-
onNotAcceptable
|
|
3110
|
+
onNotFound
|
|
3106
3111
|
});
|
|
3107
3112
|
case "followers": {
|
|
3108
3113
|
let baseUrl = url.searchParams.get("base-url");
|
|
@@ -3125,8 +3130,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3125
3130
|
collectionCallbacks: this.followersCallbacks,
|
|
3126
3131
|
tracerProvider: this.tracerProvider,
|
|
3127
3132
|
onUnauthorized,
|
|
3128
|
-
onNotFound
|
|
3129
|
-
onNotAcceptable
|
|
3133
|
+
onNotFound
|
|
3130
3134
|
});
|
|
3131
3135
|
}
|
|
3132
3136
|
case "liked": return await handleCollection(request, {
|
|
@@ -3137,8 +3141,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3137
3141
|
collectionCallbacks: this.likedCallbacks,
|
|
3138
3142
|
tracerProvider: this.tracerProvider,
|
|
3139
3143
|
onUnauthorized,
|
|
3140
|
-
onNotFound
|
|
3141
|
-
onNotAcceptable
|
|
3144
|
+
onNotFound
|
|
3142
3145
|
});
|
|
3143
3146
|
case "featured": return await handleCollection(request, {
|
|
3144
3147
|
name: "featured",
|
|
@@ -3148,8 +3151,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3148
3151
|
collectionCallbacks: this.featuredCallbacks,
|
|
3149
3152
|
tracerProvider: this.tracerProvider,
|
|
3150
3153
|
onUnauthorized,
|
|
3151
|
-
onNotFound
|
|
3152
|
-
onNotAcceptable
|
|
3154
|
+
onNotFound
|
|
3153
3155
|
});
|
|
3154
3156
|
case "featuredTags": return await handleCollection(request, {
|
|
3155
3157
|
name: "featured tags",
|
|
@@ -3159,8 +3161,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3159
3161
|
collectionCallbacks: this.featuredTagsCallbacks,
|
|
3160
3162
|
tracerProvider: this.tracerProvider,
|
|
3161
3163
|
onUnauthorized,
|
|
3162
|
-
onNotFound
|
|
3163
|
-
onNotAcceptable
|
|
3164
|
+
onNotFound
|
|
3164
3165
|
});
|
|
3165
3166
|
case "collection": {
|
|
3166
3167
|
const name = route.name.replace(/^collection:/, "");
|
|
@@ -3172,8 +3173,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3172
3173
|
collectionCallbacks: callbacks,
|
|
3173
3174
|
tracerProvider: this.tracerProvider,
|
|
3174
3175
|
onUnauthorized,
|
|
3175
|
-
onNotFound
|
|
3176
|
-
onNotAcceptable
|
|
3176
|
+
onNotFound
|
|
3177
3177
|
});
|
|
3178
3178
|
}
|
|
3179
3179
|
case "orderedCollection": {
|
|
@@ -3186,8 +3186,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3186
3186
|
collectionCallbacks: callbacks,
|
|
3187
3187
|
tracerProvider: this.tracerProvider,
|
|
3188
3188
|
onUnauthorized,
|
|
3189
|
-
onNotFound
|
|
3190
|
-
onNotAcceptable
|
|
3189
|
+
onNotFound
|
|
3191
3190
|
});
|
|
3192
3191
|
}
|
|
3193
3192
|
default: {
|
|
@@ -3460,12 +3459,12 @@ var ContextImpl = class ContextImpl {
|
|
|
3460
3459
|
for (const keyPair of keyPairs) {
|
|
3461
3460
|
const newPair = {
|
|
3462
3461
|
...keyPair,
|
|
3463
|
-
cryptographicKey: new
|
|
3462
|
+
cryptographicKey: new __fedify_vocab.CryptographicKey({
|
|
3464
3463
|
id: keyPair.keyId,
|
|
3465
3464
|
owner,
|
|
3466
3465
|
publicKey: keyPair.publicKey
|
|
3467
3466
|
}),
|
|
3468
|
-
multikey: new
|
|
3467
|
+
multikey: new __fedify_vocab.Multikey({
|
|
3469
3468
|
id: keyPair.keyId,
|
|
3470
3469
|
controller: owner,
|
|
3471
3470
|
publicKey: keyPair.publicKey
|
|
@@ -3551,7 +3550,7 @@ var ContextImpl = class ContextImpl {
|
|
|
3551
3550
|
return this.federation.authenticatedDocumentLoaderFactory(identity);
|
|
3552
3551
|
}
|
|
3553
3552
|
lookupObject(identifier, options = {}) {
|
|
3554
|
-
return
|
|
3553
|
+
return (0, __fedify_vocab.lookupObject)(identifier, {
|
|
3555
3554
|
...options,
|
|
3556
3555
|
documentLoader: options.documentLoader ?? this.documentLoader,
|
|
3557
3556
|
contextLoader: options.contextLoader ?? this.contextLoader,
|
|
@@ -3561,7 +3560,7 @@ var ContextImpl = class ContextImpl {
|
|
|
3561
3560
|
});
|
|
3562
3561
|
}
|
|
3563
3562
|
traverseCollection(collection, options = {}) {
|
|
3564
|
-
return
|
|
3563
|
+
return (0, __fedify_vocab.traverseCollection)(collection, {
|
|
3565
3564
|
...options,
|
|
3566
3565
|
documentLoader: options.documentLoader ?? this.documentLoader,
|
|
3567
3566
|
contextLoader: options.contextLoader ?? this.contextLoader
|
|
@@ -3579,7 +3578,7 @@ var ContextImpl = class ContextImpl {
|
|
|
3579
3578
|
});
|
|
3580
3579
|
}
|
|
3581
3580
|
lookupWebFinger(resource, options = {}) {
|
|
3582
|
-
return
|
|
3581
|
+
return (0, __fedify_webfinger.lookupWebFinger)(resource, {
|
|
3583
3582
|
...options,
|
|
3584
3583
|
userAgent: options.userAgent ?? this.federation.userAgent,
|
|
3585
3584
|
tracerProvider: options.tracerProvider ?? this.tracerProvider,
|
|
@@ -3587,11 +3586,11 @@ var ContextImpl = class ContextImpl {
|
|
|
3587
3586
|
});
|
|
3588
3587
|
}
|
|
3589
3588
|
sendActivity(sender, recipients, activity, options = {}) {
|
|
3590
|
-
const tracer = this.tracerProvider.getTracer(
|
|
3589
|
+
const tracer = this.tracerProvider.getTracer(require_http.deno_default.name, require_http.deno_default.version);
|
|
3591
3590
|
return tracer.startActiveSpan(this.federation.outboxQueue == null || options.immediate ? "activitypub.outbox" : "activitypub.fanout", {
|
|
3592
3591
|
kind: this.federation.outboxQueue == null || options.immediate ? __opentelemetry_api.SpanKind.CLIENT : __opentelemetry_api.SpanKind.PRODUCER,
|
|
3593
3592
|
attributes: {
|
|
3594
|
-
"activitypub.activity.type":
|
|
3593
|
+
"activitypub.activity.type": (0, __fedify_vocab.getTypeId)(activity).href,
|
|
3595
3594
|
"activitypub.activity.to": activity.toIds.map((to) => to.href),
|
|
3596
3595
|
"activitypub.activity.cc": activity.toIds.map((cc) => cc.href),
|
|
3597
3596
|
"activitypub.activity.bto": activity.btoIds.map((bto) => bto.href),
|
|
@@ -3644,7 +3643,7 @@ var ContextImpl = class ContextImpl {
|
|
|
3644
3643
|
keys = sender;
|
|
3645
3644
|
} else keys = [sender];
|
|
3646
3645
|
if (keys.length < 1) throw new TypeError("The sender's keys must not be empty.");
|
|
3647
|
-
for (const { privateKey } of keys)
|
|
3646
|
+
for (const { privateKey } of keys) require_http.validateCryptoKey(privateKey, "private");
|
|
3648
3647
|
const opts = { context: this };
|
|
3649
3648
|
let expandedRecipients;
|
|
3650
3649
|
if (Array.isArray(recipients)) expandedRecipients = recipients;
|
|
@@ -3685,7 +3684,7 @@ var ContextImpl = class ContextImpl {
|
|
|
3685
3684
|
}
|
|
3686
3685
|
const keyJwkPairs = await Promise.all(keys.map(async ({ keyId, privateKey }) => ({
|
|
3687
3686
|
keyId: keyId.href,
|
|
3688
|
-
privateKey: await
|
|
3687
|
+
privateKey: await require_http.exportJwk(privateKey)
|
|
3689
3688
|
})));
|
|
3690
3689
|
const carrier = {};
|
|
3691
3690
|
__opentelemetry_api.propagation.inject(__opentelemetry_api.context.active(), carrier);
|
|
@@ -3703,7 +3702,7 @@ var ContextImpl = class ContextImpl {
|
|
|
3703
3702
|
contextLoader: this.contextLoader
|
|
3704
3703
|
}),
|
|
3705
3704
|
activityId: activity.id?.href,
|
|
3706
|
-
activityType:
|
|
3705
|
+
activityType: (0, __fedify_vocab.getTypeId)(activity).href,
|
|
3707
3706
|
collectionSync: opts.collectionSync,
|
|
3708
3707
|
traceContext: carrier
|
|
3709
3708
|
};
|
|
@@ -3733,10 +3732,10 @@ var ContextImpl = class ContextImpl {
|
|
|
3733
3732
|
}
|
|
3734
3733
|
routeActivity(recipient, activity, options = {}) {
|
|
3735
3734
|
const tracerProvider = this.tracerProvider ?? this.tracerProvider;
|
|
3736
|
-
const tracer = tracerProvider.getTracer(
|
|
3735
|
+
const tracer = tracerProvider.getTracer(require_http.deno_default.name, require_http.deno_default.version);
|
|
3737
3736
|
return tracer.startActiveSpan("activitypub.inbox", {
|
|
3738
3737
|
kind: this.federation.inboxQueue == null || options.immediate ? __opentelemetry_api.SpanKind.INTERNAL : __opentelemetry_api.SpanKind.PRODUCER,
|
|
3739
|
-
attributes: { "activitypub.activity.type":
|
|
3738
|
+
attributes: { "activitypub.activity.type": (0, __fedify_vocab.getTypeId)(activity).href }
|
|
3740
3739
|
}, async (span) => {
|
|
3741
3740
|
if (activity.id != null) span.setAttribute("activitypub.activity.id", activity.id.href);
|
|
3742
3741
|
if (activity.toIds.length > 0) span.setAttribute("activitypub.activity.to", activity.toIds.map((to) => to.href));
|
|
@@ -3770,7 +3769,7 @@ var ContextImpl = class ContextImpl {
|
|
|
3770
3769
|
const contextLoader = options.contextLoader ?? this.contextLoader;
|
|
3771
3770
|
const json = await activity.toJsonLd({ contextLoader });
|
|
3772
3771
|
const keyCache = new KvKeyCache(this.federation.kv, this.federation.kvPrefixes.publicKey, this);
|
|
3773
|
-
const verified = await require_proof.verifyObject(
|
|
3772
|
+
const verified = await require_proof.verifyObject(__fedify_vocab.Activity, json, {
|
|
3774
3773
|
contextLoader,
|
|
3775
3774
|
documentLoader: options.documentLoader ?? this.documentLoader,
|
|
3776
3775
|
tracerProvider: options.tracerProvider ?? this.tracerProvider,
|
|
@@ -3796,7 +3795,7 @@ var ContextImpl = class ContextImpl {
|
|
|
3796
3795
|
activityId: activity.id.href
|
|
3797
3796
|
});
|
|
3798
3797
|
return false;
|
|
3799
|
-
} else if (!(fetched instanceof
|
|
3798
|
+
} else if (!(fetched instanceof __fedify_vocab.Activity)) {
|
|
3800
3799
|
logger$1.debug("Fetched object is not an Activity.", {
|
|
3801
3800
|
recipient,
|
|
3802
3801
|
activity: await fetched.toJsonLd({ contextLoader })
|
|
@@ -3841,7 +3840,8 @@ var ContextImpl = class ContextImpl {
|
|
|
3841
3840
|
kvPrefixes: this.federation.kvPrefixes,
|
|
3842
3841
|
queue: this.federation.inboxQueue,
|
|
3843
3842
|
span,
|
|
3844
|
-
tracerProvider: options.tracerProvider ?? this.tracerProvider
|
|
3843
|
+
tracerProvider: options.tracerProvider ?? this.tracerProvider,
|
|
3844
|
+
idempotencyStrategy: this.federation.idempotencyStrategy
|
|
3845
3845
|
});
|
|
3846
3846
|
return routeResult === "alreadyProcessed" || routeResult === "enqueued" || routeResult === "unsupportedActivity" || routeResult === "success";
|
|
3847
3847
|
}
|
|
@@ -3950,7 +3950,7 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
|
|
|
3950
3950
|
});
|
|
3951
3951
|
}
|
|
3952
3952
|
forwardActivity(forwarder, recipients, options) {
|
|
3953
|
-
const tracer = this.tracerProvider.getTracer(
|
|
3953
|
+
const tracer = this.tracerProvider.getTracer(require_http.deno_default.name, require_http.deno_default.version);
|
|
3954
3954
|
return tracer.startActiveSpan("activitypub.outbox", {
|
|
3955
3955
|
kind: this.federation.outboxQueue == null || options?.immediate ? __opentelemetry_api.SpanKind.CLIENT : __opentelemetry_api.SpanKind.PRODUCER,
|
|
3956
3956
|
attributes: { "activitypub.activity.type": this.activityType }
|
|
@@ -4002,7 +4002,7 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
|
|
|
4002
4002
|
if (!require_proof.hasSignature(this.activity)) {
|
|
4003
4003
|
let hasProof;
|
|
4004
4004
|
try {
|
|
4005
|
-
const activity = await
|
|
4005
|
+
const activity = await __fedify_vocab.Activity.fromJsonLd(this.activity, this);
|
|
4006
4006
|
hasProof = await activity.getProof() != null;
|
|
4007
4007
|
} catch {
|
|
4008
4008
|
hasProof = false;
|
|
@@ -4051,7 +4051,7 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
|
|
|
4051
4051
|
});
|
|
4052
4052
|
const keyJwkPairs = [];
|
|
4053
4053
|
for (const { keyId, privateKey } of keys) {
|
|
4054
|
-
const privateKeyJwk = await
|
|
4054
|
+
const privateKeyJwk = await require_http.exportJwk(privateKey);
|
|
4055
4055
|
keyJwkPairs.push({
|
|
4056
4056
|
keyId: keyId.href,
|
|
4057
4057
|
privateKey: privateKeyJwk
|
|
@@ -4221,6 +4221,12 @@ Object.defineProperty(exports, 'digest', {
|
|
|
4221
4221
|
return digest;
|
|
4222
4222
|
}
|
|
4223
4223
|
});
|
|
4224
|
+
Object.defineProperty(exports, 'handleWebFinger', {
|
|
4225
|
+
enumerable: true,
|
|
4226
|
+
get: function () {
|
|
4227
|
+
return handleWebFinger;
|
|
4228
|
+
}
|
|
4229
|
+
});
|
|
4224
4230
|
Object.defineProperty(exports, 'respondWithObject', {
|
|
4225
4231
|
enumerable: true,
|
|
4226
4232
|
get: function () {
|