@fedify/fedify 2.0.0-dev.1485 → 2.0.0-dev.150
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 +38 -18
- package/dist/actor-Bhc5FasL.cjs +42079 -0
- package/dist/{actor-7ivEf1H3.js → actor-C6cDxaJJ.js} +4 -1
- package/dist/{actor-DXTdNCfp.js → actor-DPvScYuz.js} +7058 -2722
- package/dist/{actor-C22bXuuC.d.ts → actor-DqFajh9s.d.ts} +2 -2
- package/dist/actor-f2NtjyCg.d.cts +128 -0
- package/dist/{assert-MZs1qjMx.js → assert-Dp5_aoAs.js} +1 -1
- package/dist/{assert_instance_of-DHz7EHNU.js → assert_instance_of-D1m8F7x0.js} +1 -1
- package/dist/{assert_not_equals-f3m3epl3.js → assert_not_equals-B2R_8p36.js} +1 -1
- package/dist/{assert_rejects-DiIiJbZn.js → assert_rejects-BoKYY0g1.js} +2 -2
- package/dist/{assert_is_error-BPGph1Jx.js → assert_throws-DjkXin1a.js} +32 -2
- package/dist/{builder-BPGqEvtB.js → builder-DcDoTCBH.js} +20 -8
- package/dist/chunk-DqRYRqnO.cjs +34 -0
- package/dist/chunk-HsBuZ-b2.js +41 -0
- package/dist/client-94iWEfQa.d.cts +222 -0
- package/dist/{client-DF8anIB5.d.ts → client-BsGzbnV-.d.ts} +3 -75
- package/dist/{client-g2FDBoeY.js → client-CD87uCL_.js} +4 -23
- package/dist/compat/mod.cjs +10 -0
- package/dist/compat/mod.d.cts +11 -0
- package/dist/compat/mod.d.ts +10 -12
- package/dist/compat/mod.js +5 -5
- package/dist/compat/transformers.test.js +29 -24
- package/dist/compat-DmDDELst.cjs +4 -0
- package/dist/compat-nxUqe4Z-.js +4 -0
- package/dist/context-DBQ7nMCw.d.cts +2449 -0
- package/dist/context-DpN-0qNU.js +109 -0
- package/dist/{context-DmlbRh9p.d.ts → context-mM0Nu5yo.d.ts} +335 -134
- package/dist/deno-DHmnBq8X.js +131 -0
- package/dist/{testing-BG_8Fyas.js → dist-lStjlyET.js} +73 -114
- package/dist/{authdocloader-D_IvQE4z.js → docloader-C2QNrF7j.js} +17 -8
- package/dist/{esm-CPZhxxGc.js → esm-B52TuumP.js} +32 -17
- package/dist/federation/builder.test.js +16 -16
- package/dist/federation/collection.test.js +9 -12
- package/dist/federation/handler.test.js +123 -152
- package/dist/federation/idempotency.test.js +206 -0
- package/dist/federation/inbox.test.js +7 -7
- package/dist/federation/keycache.test.js +7 -8
- package/dist/federation/kv.test.js +64 -12
- package/dist/federation/middleware.test.js +281 -99
- package/dist/federation/mod.cjs +27 -0
- package/dist/federation/mod.d.cts +11 -0
- package/dist/federation/mod.d.ts +11 -13
- package/dist/federation/mod.js +13 -15
- package/dist/federation/mq.test.js +12 -13
- package/dist/federation/negotiation.test.js +25 -0
- package/dist/federation/retry.test.js +4 -6
- package/dist/federation/router.test.js +9 -11
- package/dist/federation/send.test.js +61 -18
- package/dist/federation-CoW-KDKv.cjs +266 -0
- package/dist/{federation-CMX7WzeL.js → federation-D0hkM4T7.js} +25 -3
- package/dist/{http-zsOxPKCt.js → http-B1d-Jhbj.js} +260 -10
- package/dist/{http-DqSNLFNY.d.ts → http-BbO0ejuk.d.ts} +2 -2
- package/dist/http-CS6iqtXa.cjs +1106 -0
- package/dist/http-M8k5mKc0.d.cts +253 -0
- package/dist/{http-C7rxW7Kh.js → http-b10BrywC.js} +4 -3
- package/dist/{inbox-eK2W2MF3.js → inbox-gPnuScsy.js} +26 -7
- package/dist/{key-CYOcZ9G5.js → key-W6YaI4J_.js} +4 -2
- package/dist/{keycache-BLq6GT4_.js → keycache-DkTZcjkH.js} +1 -1
- package/dist/{keys-BIwlbtMN.js → keys-CfcSjjys.js} +2 -1
- package/dist/{kv-C7sopW2E.d.ts → kv-BpJND1Hr.d.ts} +30 -1
- package/dist/{kv-CRZrzyXm.js → kv-DaWUKuhD.js} +22 -0
- package/dist/kv-cD_d4hg-.d.cts +110 -0
- package/dist/kv-cache-C6NrTtII.js +107 -0
- package/dist/kv-cache-DhRe6qxQ.js +122 -0
- package/dist/kv-cache-a7LD3ze0.cjs +134 -0
- package/dist/{ld-DWwLYT4e.js → ld-UYagkye9.js} +7 -4
- package/dist/lookup-C-ajaa9S.js +256 -0
- package/dist/{lookup-DNQyH8UQ.js → lookup-CjgzNtAk.js} +33 -125
- package/dist/lookup-DI7YTXtl.cjs +268 -0
- package/dist/{lookup-BHYMosdS.js → lookup-DP8Hm9oD.js} +3 -1
- package/dist/middleware-Botvlnr6.js +31 -0
- package/dist/{middleware-DakCaqXu.js → middleware-C2V0Hmj1.js} +105 -188
- package/dist/middleware-D5o8ITlx.cjs +4237 -0
- package/dist/middleware-ESmU0CBL.cjs +15 -0
- package/dist/middleware-JqrIzuk6.js +15 -0
- package/dist/{middleware-BcVqlHyD.js → middleware-V7PNM-lv.js} +143 -136
- package/dist/mod-B-hUPT2N.d.cts +1 -0
- package/dist/{mod-Cxt4Kpf6.d.ts → mod-BlVovdcy.d.ts} +20 -2
- package/dist/mod-BxRCHTz-.d.cts +307 -0
- package/dist/mod-C58MZ7Wx.d.cts +113 -0
- package/dist/mod-CAdoBu0x.d.ts +109 -0
- package/dist/mod-CcDPcLJW.d.cts +1 -0
- package/dist/{mod-Drmz72EK.d.ts → mod-D5Z2tISD.d.ts} +3 -3
- package/dist/mod-DgxG-byT.d.cts +266 -0
- package/dist/{lookup-3czM5mmU.d.ts → mod-Ds0mpFZU.d.ts} +9 -2
- package/dist/mod-Dy2fJtmN.d.cts +80 -0
- package/dist/{mod-0EysZ-dJ.d.ts → mod-GetHzY6F.d.ts} +2 -2
- package/dist/mod-fxr25Gv7.d.cts +107 -0
- package/dist/mod.cjs +137 -0
- package/dist/mod.d.cts +15 -0
- package/dist/mod.d.ts +15 -18
- package/dist/mod.js +19 -21
- package/dist/negotiation-B4NJHk1f.js +71 -0
- package/dist/nodeinfo/client.test.js +32 -114
- package/dist/nodeinfo/handler.test.js +35 -30
- package/dist/nodeinfo/mod.cjs +10 -0
- package/dist/nodeinfo/mod.d.cts +3 -0
- package/dist/nodeinfo/mod.d.ts +3 -5
- package/dist/nodeinfo/mod.js +6 -7
- package/dist/nodeinfo/types.test.js +10 -18
- package/dist/nodeinfo-BnthBobC.js +4 -0
- package/dist/nodeinfo-CdN0rEnZ.cjs +4 -0
- package/dist/otel/exporter.test.js +899 -0
- package/dist/otel/mod.cjs +262 -0
- package/dist/otel/mod.d.cts +230 -0
- package/dist/otel/mod.d.ts +232 -0
- package/dist/otel/mod.js +261 -0
- package/dist/owner-B4HbyP8s.d.cts +67 -0
- package/dist/{owner-smArESGi.js → owner-DgNCw_Z-.js} +46 -8
- package/dist/{owner-CQPnQVtf.d.ts → owner-kQRGVXG1.d.ts} +3 -3
- package/dist/{proof-C6z-uqeO.js → proof-BwleRoo3.js} +5 -3
- package/dist/proof-M11sS3Oq.cjs +710 -0
- package/dist/{proof-CT1SITRP.js → proof-TlLZC_r7.js} +53 -16
- package/dist/router-CVRQXlZi.js +118 -0
- package/dist/{send-1zdmNlUo.js → send-BMU9B7Sm.js} +9 -4
- package/dist/sig/http.test.js +19 -17
- package/dist/sig/key.test.js +15 -14
- package/dist/sig/ld.test.js +13 -12
- package/dist/sig/mod.cjs +28 -0
- package/dist/sig/mod.d.cts +6 -0
- package/dist/sig/mod.d.ts +5 -7
- package/dist/sig/mod.js +8 -10
- package/dist/sig/owner.test.js +40 -15
- package/dist/sig/proof.test.js +19 -17
- package/dist/sig-C34-oHBl.js +4 -0
- package/dist/sig-YYj5tCnr.cjs +4 -0
- package/dist/{std__assert-X-_kMxKM.js → std__assert-Cm-MfI66.js} +1 -1
- package/dist/testing/mod.d.ts +410 -232
- package/dist/testing/mod.js +9 -4
- package/dist/{transformers-Dna8Fg7k.js → transformers-BFT6d7J5.js} +3 -3
- package/dist/transformers-CoBS-oFG.cjs +116 -0
- package/dist/type-BSNcIxTd.js +14 -0
- package/dist/{types-BzyGRkRt.js → types-BtUjyi5y.js} +9 -170
- package/dist/types-CWgzGaqk.cjs +315 -0
- package/dist/{types-BIgY6c-l.js → types-D2jhK2VG.js} +1 -3
- package/dist/{runtime/authdocloader.test.js → utils/docloader.test.js} +20 -18
- package/dist/utils/kv-cache.test.js +211 -0
- package/dist/utils/mod.cjs +12 -0
- package/dist/utils/mod.d.cts +5 -0
- package/dist/utils/mod.d.ts +7 -0
- package/dist/utils/mod.js +11 -0
- package/dist/utils-D-Va7aXC.js +4 -0
- package/dist/utils-DyRU1gdZ.cjs +4 -0
- package/dist/vocab/actor.test.js +15 -13
- package/dist/vocab/lookup.test.js +285 -12
- package/dist/vocab/mod.cjs +86 -0
- package/dist/vocab/mod.d.cts +4 -0
- package/dist/vocab/mod.d.ts +3 -5
- package/dist/vocab/mod.js +6 -7
- package/dist/vocab/type.test.js +4 -4
- package/dist/vocab/vocab.test.js +8058 -1987
- package/dist/{vocab-SOE1ifCr.d.ts → vocab-BCWe1Ih5.d.ts} +292 -21
- package/dist/vocab-CeDBzu-f.d.cts +14903 -0
- package/dist/{type-I68qwqmo.js → vocab-Durhw0Gx.js} +6947 -7381
- package/dist/{vocab-Bg1J3mu4.js → vocab-NOF1dCjQ.js} +32 -18
- package/dist/vocab-Vw1RxMp6.cjs +296 -0
- package/dist/webfinger/handler.test.js +62 -29
- package/dist/webfinger/lookup.test.js +11 -12
- package/dist/webfinger/mod.cjs +8 -0
- package/dist/webfinger/mod.d.cts +2 -0
- package/dist/webfinger/mod.d.ts +1 -4
- package/dist/webfinger/mod.js +5 -6
- package/dist/webfinger-C72Y8lrh.js +4 -0
- package/dist/webfinger-vAtLmxOF.cjs +4 -0
- package/package.json +81 -45
- package/dist/assert_throws-BOO88avQ.js +0 -39
- package/dist/authdocloader-Bq0gEHRj.js +0 -52
- package/dist/compat-Bb5myD13.js +0 -4
- package/dist/denokv-Bv33Xxea.js +0 -57
- package/dist/docloader-BlVueewg.js +0 -4615
- package/dist/docloader-CxWcuWqQ.d.ts +0 -221
- package/dist/fixtures/activitypub.academy/users/brauca_darradiul.json +0 -83
- package/dist/fixtures/example.com/announce.json +0 -6
- package/dist/fixtures/example.com/collection.json +0 -19
- package/dist/fixtures/example.com/create.json +0 -6
- package/dist/fixtures/example.com/cross-origin-actor.json +0 -6
- package/dist/fixtures/example.com/hong-gildong.json +0 -11
- package/dist/fixtures/example.com/invite.json +0 -7
- package/dist/fixtures/example.com/key.json +0 -7
- package/dist/fixtures/example.com/key2.json +0 -6
- package/dist/fixtures/example.com/object.json +0 -6
- package/dist/fixtures/example.com/orderedcollectionpage.json +0 -24
- package/dist/fixtures/example.com/paged/a.json +0 -13
- package/dist/fixtures/example.com/paged/b.json +0 -16
- package/dist/fixtures/example.com/paged-collection.json +0 -6
- package/dist/fixtures/example.com/person.json +0 -22
- package/dist/fixtures/example.com/person2.json +0 -40
- package/dist/fixtures/example.com/test.json +0 -5
- package/dist/fixtures/example.com/users/handle.json +0 -16
- package/dist/fixtures/example.com/wrong-type.json +0 -3
- package/dist/fixtures/oeee.cafe/ap/users/3609fd4e-d51d-4db8-9f04-4189815864dd.json +0 -24
- package/dist/fixtures/remote.domain/users/bob.json +0 -20
- package/dist/fixtures/server.example/users/alice.json +0 -20
- package/dist/fixtures/w3id.org/identity/v1.json +0 -152
- package/dist/fixtures/w3id.org/security/data-integrity/v1.json +0 -74
- package/dist/fixtures/w3id.org/security/multikey/v1.json +0 -35
- package/dist/fixtures/w3id.org/security/v1.json +0 -50
- package/dist/fixtures/wizard.casa/users/hongminhee.json +0 -69
- package/dist/fixtures/www.w3.org/ns/activitystreams.json +0 -379
- package/dist/fixtures/www.w3.org/ns/did/v1.json +0 -58
- package/dist/key-Dn7Lram-.js +0 -260
- package/dist/key-S7WllAWz.js +0 -10
- package/dist/key-rRCUafNm.js +0 -10
- package/dist/middleware-CWbGhXnl.js +0 -26
- package/dist/middleware-D-OlNiyj.js +0 -17
- package/dist/mod-TFoH2Ql8.d.ts +0 -104
- package/dist/mod-g0xFzAP9.d.ts +0 -2
- package/dist/mq-CRGm1e_F.d.ts +0 -143
- package/dist/nodeinfo/semver.test.js +0 -143
- package/dist/nodeinfo-CyEbLjHs.js +0 -4
- package/dist/runtime/docloader.test.js +0 -522
- package/dist/runtime/key.test.js +0 -103
- package/dist/runtime/langstr.test.d.ts +0 -3
- package/dist/runtime/langstr.test.js +0 -39
- package/dist/runtime/mod.d.ts +0 -8
- package/dist/runtime/mod.js +0 -13
- package/dist/runtime/multibase/multibase.test.d.ts +0 -3
- package/dist/runtime/multibase/multibase.test.js +0 -358
- package/dist/runtime/url.test.d.ts +0 -3
- package/dist/runtime/url.test.js +0 -45
- package/dist/runtime-BSkOVUWM.js +0 -4
- package/dist/semver-dArNLkR9.js +0 -149
- package/dist/sig-BXJO--F9.js +0 -4
- package/dist/src/vocab/accept.yaml +0 -15
- package/dist/src/vocab/activity.yaml +0 -98
- package/dist/src/vocab/add.yaml +0 -16
- package/dist/src/vocab/announce.yaml +0 -30
- package/dist/src/vocab/application.yaml +0 -324
- package/dist/src/vocab/arrive.yaml +0 -15
- package/dist/src/vocab/article.yaml +0 -46
- package/dist/src/vocab/audio.yaml +0 -11
- package/dist/src/vocab/block.yaml +0 -16
- package/dist/src/vocab/chatmessage.yaml +0 -50
- package/dist/src/vocab/collection.yaml +0 -154
- package/dist/src/vocab/collectionpage.yaml +0 -55
- package/dist/src/vocab/create.yaml +0 -28
- package/dist/src/vocab/dataintegrityproof.yaml +0 -56
- package/dist/src/vocab/delete.yaml +0 -27
- package/dist/src/vocab/didservice.yaml +0 -22
- package/dist/src/vocab/dislike.yaml +0 -14
- package/dist/src/vocab/document.yaml +0 -31
- package/dist/src/vocab/emoji.yaml +0 -12
- package/dist/src/vocab/emojireact.yaml +0 -17
- package/dist/src/vocab/endpoints.yaml +0 -85
- package/dist/src/vocab/event.yaml +0 -11
- package/dist/src/vocab/export.yaml +0 -9
- package/dist/src/vocab/flag.yaml +0 -15
- package/dist/src/vocab/follow.yaml +0 -19
- package/dist/src/vocab/group.yaml +0 -324
- package/dist/src/vocab/hashtag.yaml +0 -14
- package/dist/src/vocab/ignore.yaml +0 -14
- package/dist/src/vocab/image.yaml +0 -9
- package/dist/src/vocab/intransitiveactivity.yaml +0 -15
- package/dist/src/vocab/invite.yaml +0 -14
- package/dist/src/vocab/join.yaml +0 -14
- package/dist/src/vocab/key.yaml +0 -28
- package/dist/src/vocab/leave.yaml +0 -14
- package/dist/src/vocab/like.yaml +0 -16
- package/dist/src/vocab/link.yaml +0 -101
- package/dist/src/vocab/listen.yaml +0 -12
- package/dist/src/vocab/mention.yaml +0 -9
- package/dist/src/vocab/move.yaml +0 -15
- package/dist/src/vocab/multikey.yaml +0 -36
- package/dist/src/vocab/note.yaml +0 -48
- package/dist/src/vocab/object.yaml +0 -404
- package/dist/src/vocab/offer.yaml +0 -15
- package/dist/src/vocab/orderedcollection.yaml +0 -39
- package/dist/src/vocab/orderedcollectionpage.yaml +0 -50
- package/dist/src/vocab/organization.yaml +0 -324
- package/dist/src/vocab/page.yaml +0 -11
- package/dist/src/vocab/person.yaml +0 -324
- package/dist/src/vocab/place.yaml +0 -75
- package/dist/src/vocab/profile.yaml +0 -26
- package/dist/src/vocab/propertyvalue.yaml +0 -32
- package/dist/src/vocab/question.yaml +0 -103
- package/dist/src/vocab/read.yaml +0 -13
- package/dist/src/vocab/reject.yaml +0 -14
- package/dist/src/vocab/relationship.yaml +0 -52
- package/dist/src/vocab/remove.yaml +0 -14
- package/dist/src/vocab/service.yaml +0 -324
- package/dist/src/vocab/source.yaml +0 -26
- package/dist/src/vocab/tentativeaccept.yaml +0 -14
- package/dist/src/vocab/tentativereject.yaml +0 -14
- package/dist/src/vocab/tombstone.yaml +0 -24
- package/dist/src/vocab/travel.yaml +0 -16
- package/dist/src/vocab/undo.yaml +0 -26
- package/dist/src/vocab/update.yaml +0 -58
- package/dist/src/vocab/video.yaml +0 -11
- package/dist/src/vocab/view.yaml +0 -13
- package/dist/testing/docloader.test.js +0 -24
- package/dist/vocab/schema.yaml +0 -247
- package/dist/webfinger-C3GIyXIg.js +0 -4
- package/dist/x/cfworkers.d.ts +0 -61
- package/dist/x/cfworkers.js +0 -98
- package/dist/x/cfworkers.test.d.ts +0 -3
- package/dist/x/cfworkers.test.js +0 -179
- package/dist/x/hono.d.ts +0 -56
- package/dist/x/hono.js +0 -60
- package/dist/x/sveltekit.d.ts +0 -48
- package/dist/x/sveltekit.js +0 -68
- /package/dist/{assert_equals-DSbWqCm3.js → assert_equals-Gbplq4lg.js} +0 -0
- /package/dist/{collection-CSzG2j1P.js → collection-CrkRM5Ep.js} +0 -0
- /package/dist/{nodeinfo/semver.test.d.ts → federation/idempotency.test.d.ts} +0 -0
- /package/dist/{runtime/authdocloader.test.d.ts → federation/negotiation.test.d.ts} +0 -0
- /package/dist/{mod-1pDWKvUL.d.ts → mod-CVgZgliM.d.ts} +0 -0
- /package/dist/{mod-GIh5OYxW.d.ts → mod-bjzj5QIb.d.ts} +0 -0
- /package/dist/{runtime/docloader.test.d.ts → otel/exporter.test.d.ts} +0 -0
- /package/dist/{retry-D4GJ670a.js → retry-Bz5pP75o.js} +0 -0
- /package/dist/{testing → utils}/docloader.test.d.ts +0 -0
- /package/dist/{runtime/key.test.d.ts → utils/kv-cache.test.d.ts} +0 -0
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { getDefaultActivityTransformers } from "./transformers-
|
|
6
|
-
import { deno_default,
|
|
7
|
-
import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, getTypeId } from "./actor-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { getAuthenticatedDocumentLoader } from "./authdocloader-Bq0gEHRj.js";
|
|
14
|
-
import { lookupObject, traverseCollection } from "./vocab-Bg1J3mu4.js";
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
|
4
|
+
|
|
5
|
+
import { getDefaultActivityTransformers } from "./transformers-BFT6d7J5.js";
|
|
6
|
+
import { deno_default, lookupWebFinger } from "./lookup-C-ajaa9S.js";
|
|
7
|
+
import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, getTypeId } from "./actor-DPvScYuz.js";
|
|
8
|
+
import { doubleKnock, exportJwk, importJwk, validateCryptoKey, verifyRequest } from "./http-B1d-Jhbj.js";
|
|
9
|
+
import { detachSignature, doesActorOwnKey, getKeyOwner, hasSignature, signJsonLd, signObject, verifyJsonLd, verifyObject } from "./proof-TlLZC_r7.js";
|
|
10
|
+
import { getNodeInfo, nodeInfoToJson } from "./types-BtUjyi5y.js";
|
|
11
|
+
import { getAuthenticatedDocumentLoader, kvCache } from "./kv-cache-DhRe6qxQ.js";
|
|
12
|
+
import { lookupObject, traverseCollection } from "./vocab-NOF1dCjQ.js";
|
|
15
13
|
import { getLogger, withContext } from "@logtape/logtape";
|
|
16
14
|
import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
|
|
17
|
-
import {
|
|
15
|
+
import { getDocumentLoader } from "@fedify/vocab-runtime";
|
|
18
16
|
import { cloneDeep } from "es-toolkit";
|
|
19
17
|
import { Router } from "uri-template-router";
|
|
20
18
|
import { parseTemplate } from "url-template";
|
|
19
|
+
import { encodeHex } from "byte-encodings/hex";
|
|
21
20
|
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";
|
|
22
21
|
import { domainToASCII } from "node:url";
|
|
23
22
|
|
|
@@ -55,17 +54,34 @@ var InboxListenerSet = class InboxListenerSet {
|
|
|
55
54
|
return this.dispatchWithClass(activity)?.listener ?? null;
|
|
56
55
|
}
|
|
57
56
|
};
|
|
58
|
-
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 }) {
|
|
59
58
|
const logger$1 = getLogger([
|
|
60
59
|
"fedify",
|
|
61
60
|
"federation",
|
|
62
61
|
"inbox"
|
|
63
62
|
]);
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
let cacheKey = null;
|
|
64
|
+
if (activity.id != null) {
|
|
65
|
+
const inboxContext = inboxContextFactory(recipient, json, activity.id?.href, 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
|
+
}
|
|
69
85
|
if (cacheKey != null) {
|
|
70
86
|
const cached = await kv.get(cacheKey);
|
|
71
87
|
if (cached === true) {
|
|
@@ -293,6 +309,7 @@ var FederationBuilderImpl = class {
|
|
|
293
309
|
router;
|
|
294
310
|
actorCallbacks;
|
|
295
311
|
nodeInfoDispatcher;
|
|
312
|
+
webFingerLinksDispatcher;
|
|
296
313
|
objectCallbacks;
|
|
297
314
|
objectTypeIds;
|
|
298
315
|
inboxPath;
|
|
@@ -306,6 +323,7 @@ var FederationBuilderImpl = class {
|
|
|
306
323
|
inboxListeners;
|
|
307
324
|
inboxErrorHandler;
|
|
308
325
|
sharedInboxKeyDispatcher;
|
|
326
|
+
idempotencyStrategy;
|
|
309
327
|
collectionTypeIds;
|
|
310
328
|
collectionCallbacks;
|
|
311
329
|
/**
|
|
@@ -320,7 +338,7 @@ var FederationBuilderImpl = class {
|
|
|
320
338
|
this.collectionTypeIds = {};
|
|
321
339
|
}
|
|
322
340
|
async build(options) {
|
|
323
|
-
const { FederationImpl: FederationImpl$1 } = await import("./middleware-
|
|
341
|
+
const { FederationImpl: FederationImpl$1 } = await import("./middleware-JqrIzuk6.js");
|
|
324
342
|
const f = new FederationImpl$1(options);
|
|
325
343
|
const trailingSlashInsensitiveValue = f.router.trailingSlashInsensitive;
|
|
326
344
|
f.router = this.router.clone();
|
|
@@ -328,6 +346,7 @@ var FederationBuilderImpl = class {
|
|
|
328
346
|
f._initializeRouter();
|
|
329
347
|
f.actorCallbacks = this.actorCallbacks == null ? void 0 : { ...this.actorCallbacks };
|
|
330
348
|
f.nodeInfoDispatcher = this.nodeInfoDispatcher;
|
|
349
|
+
f.webFingerLinksDispatcher = this.webFingerLinksDispatcher;
|
|
331
350
|
f.objectCallbacks = { ...this.objectCallbacks };
|
|
332
351
|
f.objectTypeIds = { ...this.objectTypeIds };
|
|
333
352
|
f.inboxPath = this.inboxPath;
|
|
@@ -341,6 +360,7 @@ var FederationBuilderImpl = class {
|
|
|
341
360
|
f.inboxListeners = this.inboxListeners?.clone();
|
|
342
361
|
f.inboxErrorHandler = this.inboxErrorHandler;
|
|
343
362
|
f.sharedInboxKeyDispatcher = this.sharedInboxKeyDispatcher;
|
|
363
|
+
f.idempotencyStrategy = this.idempotencyStrategy;
|
|
344
364
|
return f;
|
|
345
365
|
}
|
|
346
366
|
_getTracer() {
|
|
@@ -465,6 +485,9 @@ var FederationBuilderImpl = class {
|
|
|
465
485
|
if (variables.size !== 0) throw new RouterError("Path for NodeInfo dispatcher must have no variables.");
|
|
466
486
|
this.nodeInfoDispatcher = dispatcher;
|
|
467
487
|
}
|
|
488
|
+
setWebFingerLinksDispatcher(dispatcher) {
|
|
489
|
+
this.webFingerLinksDispatcher = dispatcher;
|
|
490
|
+
}
|
|
468
491
|
setObjectDispatcher(cls, path, dispatcher) {
|
|
469
492
|
const routeName = `object:${cls.typeId.href}`;
|
|
470
493
|
if (this.router.has(routeName)) throw new RouterError(`Object dispatcher for ${cls.name} already set.`);
|
|
@@ -760,15 +783,19 @@ var FederationBuilderImpl = class {
|
|
|
760
783
|
setSharedKeyDispatcher: (dispatcher) => {
|
|
761
784
|
this.sharedInboxKeyDispatcher = dispatcher;
|
|
762
785
|
return setters;
|
|
786
|
+
},
|
|
787
|
+
withIdempotency: (strategy) => {
|
|
788
|
+
this.idempotencyStrategy = strategy;
|
|
789
|
+
return setters;
|
|
763
790
|
}
|
|
764
791
|
};
|
|
765
792
|
return setters;
|
|
766
793
|
}
|
|
767
|
-
setCollectionDispatcher(name,
|
|
768
|
-
return this.#setCustomCollectionDispatcher(name, "collection",
|
|
794
|
+
setCollectionDispatcher(name, itemType, path, dispatcher) {
|
|
795
|
+
return this.#setCustomCollectionDispatcher(name, "collection", itemType, path, dispatcher);
|
|
769
796
|
}
|
|
770
|
-
setOrderedCollectionDispatcher(name,
|
|
771
|
-
return this.#setCustomCollectionDispatcher(name, "orderedCollection",
|
|
797
|
+
setOrderedCollectionDispatcher(name, itemType, path, dispatcher) {
|
|
798
|
+
return this.#setCustomCollectionDispatcher(name, "orderedCollection", itemType, path, dispatcher);
|
|
772
799
|
}
|
|
773
800
|
#setCustomCollectionDispatcher(name, collectionType, itemType, path, dispatcher) {
|
|
774
801
|
const strName = String(name);
|
|
@@ -974,9 +1001,6 @@ function preferredMediaTypes(accept) {
|
|
|
974
1001
|
const accepts = parseAccept(accept === void 0 ? "*/*" : accept ?? "");
|
|
975
1002
|
return accepts.filter(isQuality).sort(compareSpecs).map(getFullType);
|
|
976
1003
|
}
|
|
977
|
-
|
|
978
|
-
//#endregion
|
|
979
|
-
//#region src/federation/handler.ts
|
|
980
1004
|
function acceptsJsonLd(request) {
|
|
981
1005
|
const accept = request.headers.get("Accept");
|
|
982
1006
|
const types = accept ? preferredMediaTypes(accept) : ["*/*"];
|
|
@@ -984,6 +1008,9 @@ function acceptsJsonLd(request) {
|
|
|
984
1008
|
if (types[0] === "text/html" || types[0] === "application/xhtml+xml") return false;
|
|
985
1009
|
return types.includes("application/activity+json") || types.includes("application/ld+json") || types.includes("application/json");
|
|
986
1010
|
}
|
|
1011
|
+
|
|
1012
|
+
//#endregion
|
|
1013
|
+
//#region src/federation/handler.ts
|
|
987
1014
|
/**
|
|
988
1015
|
* Handles an actor request.
|
|
989
1016
|
* @template TContextData The context data to pass to the context.
|
|
@@ -991,7 +1018,7 @@ function acceptsJsonLd(request) {
|
|
|
991
1018
|
* @param parameters The parameters for handling the actor.
|
|
992
1019
|
* @returns A promise that resolves to an HTTP response.
|
|
993
1020
|
*/
|
|
994
|
-
async function handleActor(request, { identifier, context: context$1, actorDispatcher, authorizePredicate, onNotFound,
|
|
1021
|
+
async function handleActor(request, { identifier, context: context$1, actorDispatcher, authorizePredicate, onNotFound, onUnauthorized }) {
|
|
995
1022
|
const logger$1 = getLogger([
|
|
996
1023
|
"fedify",
|
|
997
1024
|
"federation",
|
|
@@ -1006,7 +1033,6 @@ async function handleActor(request, { identifier, context: context$1, actorDispa
|
|
|
1006
1033
|
logger$1.debug("Actor {identifier} not found.", { identifier });
|
|
1007
1034
|
return await onNotFound(request);
|
|
1008
1035
|
}
|
|
1009
|
-
if (!acceptsJsonLd(request)) return await onNotAcceptable(request);
|
|
1010
1036
|
if (authorizePredicate != null) {
|
|
1011
1037
|
let key = await context$1.getSignedKey();
|
|
1012
1038
|
key = key?.clone({}, { $warning: {
|
|
@@ -1041,11 +1067,10 @@ async function handleActor(request, { identifier, context: context$1, actorDispa
|
|
|
1041
1067
|
* @param parameters The parameters for handling the object.
|
|
1042
1068
|
* @returns A promise that resolves to an HTTP response.
|
|
1043
1069
|
*/
|
|
1044
|
-
async function handleObject(request, { values, context: context$1, objectDispatcher, authorizePredicate, onNotFound,
|
|
1070
|
+
async function handleObject(request, { values, context: context$1, objectDispatcher, authorizePredicate, onNotFound, onUnauthorized }) {
|
|
1045
1071
|
if (objectDispatcher == null) return await onNotFound(request);
|
|
1046
1072
|
const object = await objectDispatcher(context$1, values);
|
|
1047
1073
|
if (object == null) return await onNotFound(request);
|
|
1048
|
-
if (!acceptsJsonLd(request)) return await onNotAcceptable(request);
|
|
1049
1074
|
if (authorizePredicate != null) {
|
|
1050
1075
|
let key = await context$1.getSignedKey();
|
|
1051
1076
|
key = key?.clone({}, { $warning: {
|
|
@@ -1083,7 +1108,7 @@ async function handleObject(request, { values, context: context$1, objectDispatc
|
|
|
1083
1108
|
* @param parameters The parameters for handling the collection.
|
|
1084
1109
|
* @returns A promise that resolves to an HTTP response.
|
|
1085
1110
|
*/
|
|
1086
|
-
async function handleCollection(request, { name, identifier, uriGetter, filter, filterPredicate, context: context$1, collectionCallbacks, tracerProvider, onUnauthorized, onNotFound
|
|
1111
|
+
async function handleCollection(request, { name, identifier, uriGetter, filter, filterPredicate, context: context$1, collectionCallbacks, tracerProvider, onUnauthorized, onNotFound }) {
|
|
1087
1112
|
const spanName = name.trim().replace(/\s+/g, "_");
|
|
1088
1113
|
tracerProvider = tracerProvider ?? trace.getTracerProvider();
|
|
1089
1114
|
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
@@ -1196,7 +1221,6 @@ async function handleCollection(request, { name, identifier, uriGetter, filter,
|
|
|
1196
1221
|
partOf
|
|
1197
1222
|
});
|
|
1198
1223
|
}
|
|
1199
|
-
if (!acceptsJsonLd(request)) return await onNotAcceptable(request);
|
|
1200
1224
|
if (collectionCallbacks.authorizePredicate != null) {
|
|
1201
1225
|
let key = await context$1.getSignedKey();
|
|
1202
1226
|
key = key?.clone({}, { $warning: {
|
|
@@ -1291,7 +1315,8 @@ async function handleInbox(request, options) {
|
|
|
1291
1315
|
* @param span The OpenTelemetry span for tracing.
|
|
1292
1316
|
* @returns A promise that resolves to an HTTP response.
|
|
1293
1317
|
*/
|
|
1294
|
-
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;
|
|
1295
1320
|
const logger$1 = getLogger([
|
|
1296
1321
|
"fedify",
|
|
1297
1322
|
"federation",
|
|
@@ -1465,6 +1490,13 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
|
|
|
1465
1490
|
}
|
|
1466
1491
|
if (activity.id != null) span.setAttribute("activitypub.activity.id", activity.id.href);
|
|
1467
1492
|
span.setAttribute("activitypub.activity.type", 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
|
+
});
|
|
1468
1500
|
if (httpSigKey != null && !await doesActorOwnKey(activity, httpSigKey, ctx)) {
|
|
1469
1501
|
logger$1.error("The signer ({keyId}) and the actor ({actorId}) do not match.", {
|
|
1470
1502
|
activity: json,
|
|
@@ -1493,7 +1525,8 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
|
|
|
1493
1525
|
kvPrefixes,
|
|
1494
1526
|
queue,
|
|
1495
1527
|
span,
|
|
1496
|
-
tracerProvider
|
|
1528
|
+
tracerProvider,
|
|
1529
|
+
idempotencyStrategy: parameters.idempotencyStrategy
|
|
1497
1530
|
});
|
|
1498
1531
|
if (routeResult === "alreadyProcessed") return new Response(`Activity <${activity.id}> has already been processed.`, {
|
|
1499
1532
|
status: 202,
|
|
@@ -1523,7 +1556,7 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
|
|
|
1523
1556
|
/**
|
|
1524
1557
|
* Handles a custom collection request.
|
|
1525
1558
|
* @template TItem The type of items in the collection.
|
|
1526
|
-
* @template
|
|
1559
|
+
* @template TParam The parameter names of the requested URL.
|
|
1527
1560
|
* @template TContext The type of the context, extending {@link RequestContext}.
|
|
1528
1561
|
* @template TContextData The context data to pass to the `TContext`.
|
|
1529
1562
|
* @param request The HTTP request.
|
|
@@ -1534,7 +1567,6 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
|
|
|
1534
1567
|
const handleCustomCollection = exceptWrapper(_handleCustomCollection);
|
|
1535
1568
|
async function _handleCustomCollection(request, { name, values, context: context$1, tracerProvider, collectionCallbacks: callbacks, filterPredicate }) {
|
|
1536
1569
|
verifyDefined(callbacks);
|
|
1537
|
-
verifyJsonLdRequest(request);
|
|
1538
1570
|
await authIfNeeded(context$1, values, callbacks);
|
|
1539
1571
|
const cursor = new URL(request.url).searchParams.get("cursor");
|
|
1540
1572
|
return await new CustomCollectionHandler(name, values, context$1, callbacks, tracerProvider, Collection, CollectionPage, filterPredicate).fetchCollection(cursor).toJsonLd().then(respondAsActivity);
|
|
@@ -1542,7 +1574,7 @@ async function _handleCustomCollection(request, { name, values, context: context
|
|
|
1542
1574
|
/**
|
|
1543
1575
|
* Handles an ordered collection request.
|
|
1544
1576
|
* @template TItem The type of items in the collection.
|
|
1545
|
-
* @template
|
|
1577
|
+
* @template TParam The parameter names of the requested URL.
|
|
1546
1578
|
* @template TContext The type of the context, extending {@link RequestContext}.
|
|
1547
1579
|
* @template TContextData The context data to pass to the `TContext`.
|
|
1548
1580
|
* @param request The HTTP request.
|
|
@@ -1553,7 +1585,6 @@ async function _handleCustomCollection(request, { name, values, context: context
|
|
|
1553
1585
|
const handleOrderedCollection = exceptWrapper(_handleOrderedCollection);
|
|
1554
1586
|
async function _handleOrderedCollection(request, { name, values, context: context$1, tracerProvider, collectionCallbacks: callbacks, filterPredicate }) {
|
|
1555
1587
|
verifyDefined(callbacks);
|
|
1556
|
-
verifyJsonLdRequest(request);
|
|
1557
1588
|
await authIfNeeded(context$1, values, callbacks);
|
|
1558
1589
|
const cursor = new URL(request.url).searchParams.get("cursor");
|
|
1559
1590
|
return await new CustomCollectionHandler(name, values, context$1, callbacks, tracerProvider, OrderedCollection, OrderedCollectionPage, filterPredicate).fetchCollection(cursor).toJsonLd().then(respondAsActivity);
|
|
@@ -1563,7 +1594,7 @@ async function _handleOrderedCollection(request, { name, values, context: contex
|
|
|
1563
1594
|
* The main flow is on `getCollection`, `dispatch`.
|
|
1564
1595
|
*
|
|
1565
1596
|
* @template TItem The type of items in the collection.
|
|
1566
|
-
* @template
|
|
1597
|
+
* @template TParam The parameter names of the requested URL.
|
|
1567
1598
|
* @template TContext The type of the context. {@link Context} or {@link RequestContext}.
|
|
1568
1599
|
* @template TContextData The context data to pass to the `TContext`.
|
|
1569
1600
|
* @template TCollection The type of the collection, extending {@link Collection}.
|
|
@@ -1597,14 +1628,14 @@ var CustomCollectionHandler = class {
|
|
|
1597
1628
|
#collection = null;
|
|
1598
1629
|
/**
|
|
1599
1630
|
* Creates a new CustomCollection instance.
|
|
1600
|
-
* @param
|
|
1601
|
-
* @param
|
|
1602
|
-
* @param
|
|
1603
|
-
* @param
|
|
1604
|
-
* @param
|
|
1605
|
-
* @param
|
|
1606
|
-
* @param
|
|
1607
|
-
* @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.
|
|
1608
1639
|
*/
|
|
1609
1640
|
constructor(name, values, context$1, callbacks, tracerProvider = trace.getTracerProvider(), Collection$1, CollectionPage$1, filterPredicate) {
|
|
1610
1641
|
this.name = name;
|
|
@@ -1729,7 +1760,7 @@ var CustomCollectionHandler = class {
|
|
|
1729
1760
|
/**
|
|
1730
1761
|
* Creates a function to wrap the dispatcher so tracing can be applied.
|
|
1731
1762
|
* @param params Parameters including cursor and total items.
|
|
1732
|
-
* @returns
|
|
1763
|
+
* @returns A function that handles the span operation.
|
|
1733
1764
|
*/
|
|
1734
1765
|
spanPages = ({ totalItems = null, cursor = null }) => async (span) => {
|
|
1735
1766
|
try {
|
|
@@ -1750,23 +1781,23 @@ var CustomCollectionHandler = class {
|
|
|
1750
1781
|
};
|
|
1751
1782
|
/**
|
|
1752
1783
|
* Dispatches the collection request to get items.
|
|
1753
|
-
* @param
|
|
1754
|
-
* @returns
|
|
1784
|
+
* @param cursor The cursor for pagination, or null for the first page.
|
|
1785
|
+
* @returns A promise that resolves to the page items.
|
|
1755
1786
|
*/
|
|
1756
1787
|
async dispatch(cursor = null) {
|
|
1757
1788
|
return await this.#dispatcher(this.context, this.values, cursor) ?? new ItemsNotFoundError().throw();
|
|
1758
1789
|
}
|
|
1759
1790
|
/**
|
|
1760
1791
|
* Filters the items in the collection.
|
|
1761
|
-
* @param
|
|
1762
|
-
* @returns
|
|
1792
|
+
* @param items The items to filter.
|
|
1793
|
+
* @returns The filtered items.
|
|
1763
1794
|
*/
|
|
1764
1795
|
filterItems(items) {
|
|
1765
1796
|
return filterCollectionItems(items, this.name, this.filterPredicate);
|
|
1766
1797
|
}
|
|
1767
1798
|
/**
|
|
1768
1799
|
* Appends a cursor to the URL if it exists.
|
|
1769
|
-
* @param
|
|
1800
|
+
* @param cursor The cursor to append, or null/undefined.
|
|
1770
1801
|
* @returns The URL with cursor appended, or null if cursor is null/undefined.
|
|
1771
1802
|
*/
|
|
1772
1803
|
appendToUrl(cursor) {
|
|
@@ -1774,8 +1805,7 @@ var CustomCollectionHandler = class {
|
|
|
1774
1805
|
}
|
|
1775
1806
|
/**
|
|
1776
1807
|
* Gets the stored collection or collection page.
|
|
1777
|
-
* @returns
|
|
1778
|
-
the collection or collection page.
|
|
1808
|
+
* @returns A promise that resolves to the collection or collection page.
|
|
1779
1809
|
*/
|
|
1780
1810
|
get collection() {
|
|
1781
1811
|
if (this.#collection === null) this.#collection = this.getCollection();
|
|
@@ -1783,8 +1813,8 @@ var CustomCollectionHandler = class {
|
|
|
1783
1813
|
}
|
|
1784
1814
|
/**
|
|
1785
1815
|
* Gets the total number of items in the collection.
|
|
1786
|
-
* @returns
|
|
1787
|
-
|
|
1816
|
+
* @returns A promise that resolves to the total items count,
|
|
1817
|
+
* or null if not available.
|
|
1788
1818
|
*/
|
|
1789
1819
|
get totalItems() {
|
|
1790
1820
|
if (this.#totalItems === void 0) this.totalItems = this.callbacks.counter?.(this.context, this.values);
|
|
@@ -1800,8 +1830,8 @@ var CustomCollectionHandler = class {
|
|
|
1800
1830
|
}
|
|
1801
1831
|
/**
|
|
1802
1832
|
* Gets the first cursor for pagination.
|
|
1803
|
-
* @returns
|
|
1804
|
-
or null if not available.
|
|
1833
|
+
* @returns A promise that resolves to the first cursor,
|
|
1834
|
+
* or null if not available.
|
|
1805
1835
|
*/
|
|
1806
1836
|
get firstCursor() {
|
|
1807
1837
|
const cursor = this.callbacks.firstCursor?.(this.context, this.values);
|
|
@@ -1831,10 +1861,9 @@ function exceptWrapper(handler) {
|
|
|
1831
1861
|
try {
|
|
1832
1862
|
return await handler(request, handlerParams);
|
|
1833
1863
|
} catch (error) {
|
|
1834
|
-
const { onNotFound,
|
|
1864
|
+
const { onNotFound, onUnauthorized } = handlerParams;
|
|
1835
1865
|
switch (error?.constructor) {
|
|
1836
1866
|
case ItemsNotFoundError: return await onNotFound(request);
|
|
1837
|
-
case NotAcceptableError: return await onNotAcceptable(request);
|
|
1838
1867
|
case UnauthorizedError: return await onUnauthorized(request);
|
|
1839
1868
|
default: throw error;
|
|
1840
1869
|
}
|
|
@@ -1852,15 +1881,6 @@ const verifyDefined = (callbacks) => {
|
|
|
1852
1881
|
if (callbacks === void 0) throw new ItemsNotFoundError();
|
|
1853
1882
|
};
|
|
1854
1883
|
/**
|
|
1855
|
-
* Verifies that a request accepts JSON-LD content type.
|
|
1856
|
-
* @param request The HTTP request to verify.
|
|
1857
|
-
* @throws {NotAcceptableError} If the request doesn't accept JSON-LD.
|
|
1858
|
-
* @since 1.8.0
|
|
1859
|
-
*/
|
|
1860
|
-
const verifyJsonLdRequest = (request) => {
|
|
1861
|
-
if (!acceptsJsonLd(request)) throw new NotAcceptableError();
|
|
1862
|
-
};
|
|
1863
|
-
/**
|
|
1864
1884
|
* Performs authorization if needed based on the authorization predicate.
|
|
1865
1885
|
* @template TContextData The context data type.
|
|
1866
1886
|
* @param {RequestContext<TContextData>} context The request context.
|
|
@@ -1944,15 +1964,6 @@ var ItemsNotFoundError = class extends HandlerError {
|
|
|
1944
1964
|
}
|
|
1945
1965
|
};
|
|
1946
1966
|
/**
|
|
1947
|
-
* Error thrown when the request is not acceptable (e.g., wrong content type).
|
|
1948
|
-
* @since 1.8.0
|
|
1949
|
-
*/
|
|
1950
|
-
var NotAcceptableError = class extends HandlerError {
|
|
1951
|
-
constructor() {
|
|
1952
|
-
super("The request is not acceptable.");
|
|
1953
|
-
}
|
|
1954
|
-
};
|
|
1955
|
-
/**
|
|
1956
1967
|
* Error thrown when access to a collection is unauthorized.
|
|
1957
1968
|
* @since 1.8.0
|
|
1958
1969
|
*/
|
|
@@ -2058,7 +2069,7 @@ async function handleWebFinger(request, options) {
|
|
|
2058
2069
|
}
|
|
2059
2070
|
});
|
|
2060
2071
|
}
|
|
2061
|
-
async function handleWebFingerInternal(request, { context: context$1, host, actorDispatcher, actorHandleMapper, actorAliasMapper, onNotFound, span }) {
|
|
2072
|
+
async function handleWebFingerInternal(request, { context: context$1, host, actorDispatcher, actorHandleMapper, actorAliasMapper, onNotFound, span, webFingerLinksDispatcher }) {
|
|
2062
2073
|
if (actorDispatcher == null) {
|
|
2063
2074
|
logger.error("Actor dispatcher is not set.");
|
|
2064
2075
|
return await onNotFound(request);
|
|
@@ -2134,6 +2145,10 @@ async function handleWebFingerInternal(request, { context: context$1, host, acto
|
|
|
2134
2145
|
if (image.mediaType != null) link.type = image.mediaType;
|
|
2135
2146
|
links.push(link);
|
|
2136
2147
|
}
|
|
2148
|
+
if (webFingerLinksDispatcher != null) {
|
|
2149
|
+
const customLinks = await webFingerLinksDispatcher(context$1, resourceUrl);
|
|
2150
|
+
if (customLinks != null) for (const link of customLinks) links.push(link);
|
|
2151
|
+
}
|
|
2137
2152
|
const aliases = [];
|
|
2138
2153
|
if (resourceUrl.protocol != "acct:" && actor.preferredUsername != null) {
|
|
2139
2154
|
aliases.push(`acct:${actor.preferredUsername}@${host ?? context$1.url.host}`);
|
|
@@ -2234,7 +2249,7 @@ function sendActivity(options) {
|
|
|
2234
2249
|
await sendActivityInternal({
|
|
2235
2250
|
...options,
|
|
2236
2251
|
tracerProvider
|
|
2237
|
-
});
|
|
2252
|
+
}, span);
|
|
2238
2253
|
} catch (e) {
|
|
2239
2254
|
span.setStatus({
|
|
2240
2255
|
code: SpanStatusCode.ERROR,
|
|
@@ -2246,7 +2261,7 @@ function sendActivity(options) {
|
|
|
2246
2261
|
}
|
|
2247
2262
|
});
|
|
2248
2263
|
}
|
|
2249
|
-
async function sendActivityInternal({ activity, activityId, keys, inbox, headers, specDeterminer, tracerProvider }) {
|
|
2264
|
+
async function sendActivityInternal({ activity, activityId, keys, inbox, headers, specDeterminer, tracerProvider }, span) {
|
|
2250
2265
|
const logger$1 = getLogger([
|
|
2251
2266
|
"fedify",
|
|
2252
2267
|
"federation",
|
|
@@ -2301,6 +2316,11 @@ async function sendActivityInternal({ activity, activityId, keys, inbox, headers
|
|
|
2301
2316
|
});
|
|
2302
2317
|
throw new Error(`Failed to send activity ${activityId} to ${inbox.href} (${response.status} ${response.statusText}):\n${error}`);
|
|
2303
2318
|
}
|
|
2319
|
+
span.addEvent("activitypub.activity.sent", {
|
|
2320
|
+
"activitypub.activity.json": JSON.stringify(activity),
|
|
2321
|
+
"activitypub.inbox.url": inbox.href,
|
|
2322
|
+
"activitypub.activity.id": activityId ?? ""
|
|
2323
|
+
});
|
|
2304
2324
|
}
|
|
2305
2325
|
|
|
2306
2326
|
//#endregion
|
|
@@ -2340,7 +2360,6 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2340
2360
|
firstKnock;
|
|
2341
2361
|
constructor(options) {
|
|
2342
2362
|
super();
|
|
2343
|
-
const logger$1 = getLogger(["fedify", "federation"]);
|
|
2344
2363
|
this.kv = options.kv;
|
|
2345
2364
|
this.kvPrefixes = {
|
|
2346
2365
|
activityIdempotence: ["_fedify", "activityIdempotence"],
|
|
@@ -2388,17 +2407,13 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2388
2407
|
this.router.trailingSlashInsensitive = options.trailingSlashInsensitive ?? false;
|
|
2389
2408
|
this._initializeRouter();
|
|
2390
2409
|
if (options.allowPrivateAddress || options.userAgent != null) {
|
|
2391
|
-
if (options.
|
|
2392
|
-
|
|
2393
|
-
|
|
2410
|
+
if (options.documentLoaderFactory != null) throw new TypeError("Cannot set documentLoaderFactory with allowPrivateAddress or userAgent options.");
|
|
2411
|
+
if (options.contextLoaderFactory != null) throw new TypeError("Cannot set contextLoaderFactory with allowPrivateAddress or userAgent options.");
|
|
2412
|
+
if (options.authenticatedDocumentLoaderFactory != null) throw new TypeError("Cannot set authenticatedDocumentLoaderFactory with allowPrivateAddress or userAgent options.");
|
|
2394
2413
|
}
|
|
2395
2414
|
const { allowPrivateAddress, userAgent } = options;
|
|
2396
2415
|
this.allowPrivateAddress = allowPrivateAddress ?? false;
|
|
2397
|
-
|
|
2398
|
-
if (options.documentLoaderFactory != null) throw new TypeError("Cannot set both documentLoader and documentLoaderFactory options at a time; use documentLoaderFactory only.");
|
|
2399
|
-
this.documentLoaderFactory = () => options.documentLoader;
|
|
2400
|
-
logger$1.warn("The documentLoader option is deprecated; use documentLoaderFactory option instead.");
|
|
2401
|
-
} else this.documentLoaderFactory = options.documentLoaderFactory ?? ((opts) => {
|
|
2416
|
+
this.documentLoaderFactory = options.documentLoaderFactory ?? ((opts) => {
|
|
2402
2417
|
return kvCache({
|
|
2403
2418
|
loader: getDocumentLoader({
|
|
2404
2419
|
allowPrivateAddress: opts?.allowPrivateAddress ?? allowPrivateAddress,
|
|
@@ -2408,11 +2423,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2408
2423
|
prefix: this.kvPrefixes.remoteDocument
|
|
2409
2424
|
});
|
|
2410
2425
|
});
|
|
2411
|
-
|
|
2412
|
-
if (options.contextLoaderFactory != null) throw new TypeError("Cannot set both contextLoader and contextLoaderFactory options at a time; use contextLoaderFactory only.");
|
|
2413
|
-
this.contextLoaderFactory = () => options.contextLoader;
|
|
2414
|
-
logger$1.warn("The contextLoader option is deprecated; use contextLoaderFactory option instead.");
|
|
2415
|
-
} else this.contextLoaderFactory = options.contextLoaderFactory ?? this.documentLoaderFactory;
|
|
2426
|
+
this.contextLoaderFactory = options.contextLoaderFactory ?? this.documentLoaderFactory;
|
|
2416
2427
|
this.authenticatedDocumentLoaderFactory = options.authenticatedDocumentLoaderFactory ?? ((identity) => getAuthenticatedDocumentLoader(identity, {
|
|
2417
2428
|
allowPrivateAddress,
|
|
2418
2429
|
userAgent,
|
|
@@ -2951,6 +2962,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2951
2962
|
span,
|
|
2952
2963
|
tracer
|
|
2953
2964
|
});
|
|
2965
|
+
if (acceptsJsonLd(request)) response.headers.set("Vary", "Accept");
|
|
2954
2966
|
} catch (error) {
|
|
2955
2967
|
span.setStatus({
|
|
2956
2968
|
code: SpanStatusCode.ERROR,
|
|
@@ -3005,6 +3017,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3005
3017
|
actorDispatcher: this.actorCallbacks?.dispatcher,
|
|
3006
3018
|
actorHandleMapper: this.actorCallbacks?.handleMapper,
|
|
3007
3019
|
actorAliasMapper: this.actorCallbacks?.aliasMapper,
|
|
3020
|
+
webFingerLinksDispatcher: this.webFingerLinksDispatcher,
|
|
3008
3021
|
onNotFound,
|
|
3009
3022
|
tracer
|
|
3010
3023
|
});
|
|
@@ -3013,6 +3026,9 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3013
3026
|
context: context$1,
|
|
3014
3027
|
nodeInfoDispatcher: this.nodeInfoDispatcher
|
|
3015
3028
|
});
|
|
3029
|
+
}
|
|
3030
|
+
if (request.method !== "POST" && !acceptsJsonLd(request)) return await onNotAcceptable(request);
|
|
3031
|
+
switch (routeName) {
|
|
3016
3032
|
case "actor":
|
|
3017
3033
|
context$1 = this.#createContext(request, contextData, { invokedFromActorDispatcher: { identifier: route.values.identifier ?? route.values.handle } });
|
|
3018
3034
|
return await handleActor(request, {
|
|
@@ -3021,8 +3037,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3021
3037
|
actorDispatcher: this.actorCallbacks?.dispatcher,
|
|
3022
3038
|
authorizePredicate: this.actorCallbacks?.authorizePredicate,
|
|
3023
3039
|
onUnauthorized,
|
|
3024
|
-
onNotFound
|
|
3025
|
-
onNotAcceptable
|
|
3040
|
+
onNotFound
|
|
3026
3041
|
});
|
|
3027
3042
|
case "object": {
|
|
3028
3043
|
const typeId = route.name.replace(/^object:/, "");
|
|
@@ -3038,8 +3053,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3038
3053
|
objectDispatcher: callbacks?.dispatcher,
|
|
3039
3054
|
authorizePredicate: callbacks?.authorizePredicate,
|
|
3040
3055
|
onUnauthorized,
|
|
3041
|
-
onNotFound
|
|
3042
|
-
onNotAcceptable
|
|
3056
|
+
onNotFound
|
|
3043
3057
|
});
|
|
3044
3058
|
}
|
|
3045
3059
|
case "outbox": return await handleCollection(request, {
|
|
@@ -3050,8 +3064,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3050
3064
|
collectionCallbacks: this.outboxCallbacks,
|
|
3051
3065
|
tracerProvider: this.tracerProvider,
|
|
3052
3066
|
onUnauthorized,
|
|
3053
|
-
onNotFound
|
|
3054
|
-
onNotAcceptable
|
|
3067
|
+
onNotFound
|
|
3055
3068
|
});
|
|
3056
3069
|
case "inbox":
|
|
3057
3070
|
if (request.method !== "POST") return await handleCollection(request, {
|
|
@@ -3062,8 +3075,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3062
3075
|
collectionCallbacks: this.inboxCallbacks,
|
|
3063
3076
|
tracerProvider: this.tracerProvider,
|
|
3064
3077
|
onUnauthorized,
|
|
3065
|
-
onNotFound
|
|
3066
|
-
onNotAcceptable
|
|
3078
|
+
onNotFound
|
|
3067
3079
|
});
|
|
3068
3080
|
context$1 = this.#createContext(request, contextData, { documentLoader: await context$1.getDocumentLoader({ identifier: route.values.identifier ?? route.values.handle }) });
|
|
3069
3081
|
case "sharedInbox":
|
|
@@ -3085,7 +3097,8 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3085
3097
|
onNotFound,
|
|
3086
3098
|
signatureTimeWindow: this.signatureTimeWindow,
|
|
3087
3099
|
skipSignatureVerification: this.skipSignatureVerification,
|
|
3088
|
-
tracerProvider: this.tracerProvider
|
|
3100
|
+
tracerProvider: this.tracerProvider,
|
|
3101
|
+
idempotencyStrategy: this.idempotencyStrategy
|
|
3089
3102
|
});
|
|
3090
3103
|
case "following": return await handleCollection(request, {
|
|
3091
3104
|
name: "following",
|
|
@@ -3095,8 +3108,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3095
3108
|
collectionCallbacks: this.followingCallbacks,
|
|
3096
3109
|
tracerProvider: this.tracerProvider,
|
|
3097
3110
|
onUnauthorized,
|
|
3098
|
-
onNotFound
|
|
3099
|
-
onNotAcceptable
|
|
3111
|
+
onNotFound
|
|
3100
3112
|
});
|
|
3101
3113
|
case "followers": {
|
|
3102
3114
|
let baseUrl = url.searchParams.get("base-url");
|
|
@@ -3119,8 +3131,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3119
3131
|
collectionCallbacks: this.followersCallbacks,
|
|
3120
3132
|
tracerProvider: this.tracerProvider,
|
|
3121
3133
|
onUnauthorized,
|
|
3122
|
-
onNotFound
|
|
3123
|
-
onNotAcceptable
|
|
3134
|
+
onNotFound
|
|
3124
3135
|
});
|
|
3125
3136
|
}
|
|
3126
3137
|
case "liked": return await handleCollection(request, {
|
|
@@ -3131,8 +3142,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3131
3142
|
collectionCallbacks: this.likedCallbacks,
|
|
3132
3143
|
tracerProvider: this.tracerProvider,
|
|
3133
3144
|
onUnauthorized,
|
|
3134
|
-
onNotFound
|
|
3135
|
-
onNotAcceptable
|
|
3145
|
+
onNotFound
|
|
3136
3146
|
});
|
|
3137
3147
|
case "featured": return await handleCollection(request, {
|
|
3138
3148
|
name: "featured",
|
|
@@ -3142,8 +3152,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3142
3152
|
collectionCallbacks: this.featuredCallbacks,
|
|
3143
3153
|
tracerProvider: this.tracerProvider,
|
|
3144
3154
|
onUnauthorized,
|
|
3145
|
-
onNotFound
|
|
3146
|
-
onNotAcceptable
|
|
3155
|
+
onNotFound
|
|
3147
3156
|
});
|
|
3148
3157
|
case "featuredTags": return await handleCollection(request, {
|
|
3149
3158
|
name: "featured tags",
|
|
@@ -3153,8 +3162,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3153
3162
|
collectionCallbacks: this.featuredTagsCallbacks,
|
|
3154
3163
|
tracerProvider: this.tracerProvider,
|
|
3155
3164
|
onUnauthorized,
|
|
3156
|
-
onNotFound
|
|
3157
|
-
onNotAcceptable
|
|
3165
|
+
onNotFound
|
|
3158
3166
|
});
|
|
3159
3167
|
case "collection": {
|
|
3160
3168
|
const name = route.name.replace(/^collection:/, "");
|
|
@@ -3166,8 +3174,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3166
3174
|
collectionCallbacks: callbacks,
|
|
3167
3175
|
tracerProvider: this.tracerProvider,
|
|
3168
3176
|
onUnauthorized,
|
|
3169
|
-
onNotFound
|
|
3170
|
-
onNotAcceptable
|
|
3177
|
+
onNotFound
|
|
3171
3178
|
});
|
|
3172
3179
|
}
|
|
3173
3180
|
case "orderedCollection": {
|
|
@@ -3180,8 +3187,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3180
3187
|
collectionCallbacks: callbacks,
|
|
3181
3188
|
tracerProvider: this.tracerProvider,
|
|
3182
3189
|
onUnauthorized,
|
|
3183
|
-
onNotFound
|
|
3184
|
-
onNotAcceptable
|
|
3190
|
+
onNotFound
|
|
3185
3191
|
});
|
|
3186
3192
|
}
|
|
3187
3193
|
default: {
|
|
@@ -3476,15 +3482,16 @@ var ContextImpl = class ContextImpl {
|
|
|
3476
3482
|
"actor"
|
|
3477
3483
|
]);
|
|
3478
3484
|
if (this.federation.actorCallbacks?.keyPairsDispatcher == null) throw new Error("No actor key pairs dispatcher registered.");
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
})
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3485
|
+
let actorUri;
|
|
3486
|
+
try {
|
|
3487
|
+
actorUri = this.getActorUri(identifier);
|
|
3488
|
+
} catch (error) {
|
|
3489
|
+
if (error instanceof RouterError) {
|
|
3490
|
+
logger$1.warn(error.message);
|
|
3491
|
+
return [];
|
|
3492
|
+
}
|
|
3493
|
+
throw error;
|
|
3486
3494
|
}
|
|
3487
|
-
const actorUri = new URL(path, this.canonicalOrigin);
|
|
3488
3495
|
const keyPairs = await this.federation.actorCallbacks?.keyPairsDispatcher(new ContextImpl({
|
|
3489
3496
|
...this,
|
|
3490
3497
|
invokedFromActorKeyPairsDispatcher: { identifier }
|
|
@@ -3645,12 +3652,11 @@ var ContextImpl = class ContextImpl {
|
|
|
3645
3652
|
if (identifier == null) throw new Error("If recipients is \"followers\", sender must be an actor identifier or username.");
|
|
3646
3653
|
expandedRecipients = [];
|
|
3647
3654
|
for await (const recipient of this.getFollowers(identifier)) expandedRecipients.push(recipient);
|
|
3648
|
-
if (options.syncCollection) {
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
opts.collectionSync = collectionId == null ? void 0 : new URL(collectionId, this.canonicalOrigin).href;
|
|
3655
|
+
if (options.syncCollection) try {
|
|
3656
|
+
opts.collectionSync = this.getFollowersUri(identifier).href;
|
|
3657
|
+
} catch (error) {
|
|
3658
|
+
if (error instanceof RouterError) opts.collectionSync = void 0;
|
|
3659
|
+
else throw error;
|
|
3654
3660
|
}
|
|
3655
3661
|
} else expandedRecipients = [recipients];
|
|
3656
3662
|
span.setAttribute("activitypub.inboxes", expandedRecipients.length);
|
|
@@ -3835,7 +3841,8 @@ var ContextImpl = class ContextImpl {
|
|
|
3835
3841
|
kvPrefixes: this.federation.kvPrefixes,
|
|
3836
3842
|
queue: this.federation.inboxQueue,
|
|
3837
3843
|
span,
|
|
3838
|
-
tracerProvider: options.tracerProvider ?? this.tracerProvider
|
|
3844
|
+
tracerProvider: options.tracerProvider ?? this.tracerProvider,
|
|
3845
|
+
idempotencyStrategy: this.federation.idempotencyStrategy
|
|
3839
3846
|
});
|
|
3840
3847
|
return routeResult === "alreadyProcessed" || routeResult === "enqueued" || routeResult === "unsupportedActivity" || routeResult === "success";
|
|
3841
3848
|
}
|