@fedify/fedify 1.9.6-dev.2118 → 1.9.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{actor-CCg-pZae.js → actor-B3mkavdq.js} +1205 -2768
- package/dist/{actor-Ydzhc8dj.d.cts → actor-Be-68iJP.d.cts} +3 -3
- package/dist/{actor-C1Euqngb.d.ts → actor-C5AY0Tno.d.ts} +3 -3
- package/dist/{actor-C71CIMfC.cjs → actor-CsvteFj1.cjs} +3112 -4674
- package/dist/{actor-CNWkxCrC.js → actor-DeUOMMMQ.mjs} +8 -15
- package/dist/{assert-MZs1qjMx.js → assert-DikXweDx.mjs} +5 -9
- package/dist/{assert_equals-DSbWqCm3.js → assert_equals-Ew3jOFa3.mjs} +55 -69
- package/dist/{assert_instance_of-DHz7EHNU.js → assert_instance_of-C4Ri6VuN.mjs} +5 -9
- package/dist/{assert_is_error-BPGph1Jx.js → assert_is_error-C50x8tnw.mjs} +5 -9
- package/dist/{assert_not_equals-f3m3epl3.js → assert_not_equals--wG9hV7u.mjs} +6 -13
- package/dist/{assert_rejects-DiIiJbZn.js → assert_rejects-CJC9ThS-.mjs} +6 -11
- package/dist/{assert_throws-BOO88avQ.js → assert_throws-BIL7gChy.mjs} +6 -10
- package/dist/{authdocloader-DEGiIEaL.js → authdocloader-BKq994CV.mjs} +9 -14
- package/dist/{authdocloader-wQk3e7Ag.js → authdocloader-C3_-i4Zk.js} +8 -15
- package/dist/{authdocloader-CT1cPj97.cjs → authdocloader-tagnJZ6u.cjs} +14 -22
- package/dist/{builder-D0mOpo0N.js → builder-CnVAhip1.mjs} +31 -40
- package/dist/{client-BSRRCCF9.js → client-Bza9SeZS.mjs} +11 -15
- package/dist/{client-DF8anIB5.d.ts → client-D8OSiPBT.d.ts} +2 -2
- package/dist/{client-DjT_tegg.d.cts → client-T0VFOdMw.d.cts} +2 -2
- package/dist/{collection-CSzG2j1P.js → collection-BD6-SZ6O.mjs} +7 -12
- package/dist/compat/mod.cjs +5 -8
- package/dist/compat/mod.d.cts +78 -12
- package/dist/compat/mod.d.ts +78 -12
- package/dist/compat/mod.js +4 -8
- package/dist/compat/transformers.test.mjs +62 -0
- package/dist/{context-CwUAkopp.d.cts → context-CACMqDzl.d.cts} +33 -26
- package/dist/{context-CXUibY4L.d.ts → context-K4cCphQj.d.ts} +33 -26
- package/dist/{denokv-Bv33Xxea.js → denokv-CoSB_Eps.mjs} +22 -11
- package/dist/{docloader-OWdVzt6R.cjs → docloader-Co-tW1B6.cjs} +112 -212
- package/dist/{docloader-CxWcuWqQ.d.ts → docloader-DSaLRXEA.d.ts} +2 -7
- package/dist/{docloader-ENN4YgIF.js → docloader-Dlo9EMTn.js} +17 -151
- package/dist/{docloader-D-MrRyHl.d.cts → docloader-DpGRDZrn.d.cts} +2 -7
- package/dist/{esm-rU2ogNNz.js → esm-BLERAZrI.mjs} +49 -85
- package/dist/federation/{builder.test.js → builder.test.mjs} +22 -41
- package/dist/federation/collection.test.d.mts +2 -0
- package/dist/federation/collection.test.mjs +21 -0
- package/dist/federation/handler.test.d.mts +2 -0
- package/dist/federation/{handler.test.js → handler.test.mjs} +22 -49
- package/dist/federation/idempotency.test.d.mts +2 -0
- package/dist/federation/{idempotency.test.js → idempotency.test.mjs} +29 -59
- package/dist/federation/inbox.test.d.mts +2 -0
- package/dist/federation/{inbox.test.js → inbox.test.mjs} +10 -15
- package/dist/federation/keycache.test.d.mts +2 -0
- package/dist/federation/{keycache.test.js → keycache.test.mjs} +13 -18
- package/dist/federation/kv.test.d.mts +2 -0
- package/dist/federation/{kv.test.js → kv.test.mjs} +9 -20
- package/dist/federation/middleware.test.d.mts +2 -0
- package/dist/federation/{middleware.test.js → middleware.test.mjs} +128 -197
- package/dist/federation/mod.cjs +223 -21
- package/dist/federation/mod.d.cts +4 -13
- package/dist/federation/mod.d.ts +4 -13
- package/dist/federation/mod.js +218 -18
- package/dist/federation/mq.test.d.mts +2 -0
- package/dist/federation/{mq.test.js → mq.test.mjs} +23 -38
- package/dist/federation/retry.test.d.mts +2 -0
- package/dist/federation/{retry.test.js → retry.test.mjs} +9 -14
- package/dist/federation/router.test.d.mts +2 -0
- package/dist/federation/{router.test.js → router.test.mjs} +12 -19
- package/dist/federation/send.test.d.mts +2 -0
- package/dist/federation/{send.test.js → send.test.mjs} +17 -26
- package/dist/{http-wsGR6KkT.d.ts → http-BZpls--H.d.ts} +5 -9
- package/dist/{http-B1_DzfAU.d.cts → http-C7WoprmE.d.cts} +5 -9
- package/dist/{http-Bmn4CXIM.cjs → http-cvQMgiFd.cjs} +51 -68
- package/dist/{http-DAz2fpwK.js → http-hFXuPP4j.mjs} +16 -32
- package/dist/{http-LDjZxhgJ.js → http-z-J6i29D.js} +17 -33
- package/dist/{inbox-CLgNEczc.js → inbox-B0NdZv6Q.mjs} +17 -25
- package/dist/{key-C45K8q1u.cjs → key-B2ZqbGDP.cjs} +42 -50
- package/dist/key-BfH9JUMQ.cjs +4 -0
- package/dist/{key-VDAxfcre.js → key-ByblW_7f.mjs} +12 -18
- package/dist/{key-kD68vuX_.js → key-DPg0mibt.js} +19 -19
- package/dist/key-USCeSjWo.mjs +5 -0
- package/dist/{keycache-DtWOiAMc.js → keycache-qGjtNwWK.mjs} +6 -10
- package/dist/{keys-CJezjcJ9.js → keys-D48z4zQE.mjs} +6 -10
- package/dist/{kv-C7sopW2E.d.ts → kv-Bq9QLKm5.d.ts} +1 -1
- package/dist/{kv-CRZrzyXm.js → kv-DM1zFCtL.mjs} +6 -10
- package/dist/{kv-63Cil1MD.d.cts → kv-GIrOktyG.d.cts} +1 -1
- package/dist/{ld-DSD_uqio.js → ld-Bk-CiTUe.mjs} +17 -31
- package/dist/{lookup-B0Qds1Mq.js → lookup-B-LJhUtc.mjs} +8 -17
- package/dist/{lookup-Brpn8XFF.cjs → lookup-C6EHvNN7.cjs} +16 -23
- package/dist/{lookup-Dkw6PUQT.js → lookup-CuDOZqcB.js} +5 -11
- package/dist/{middleware-Cfia6iC-.js → middleware-Cns1QUI8.js} +348 -392
- package/dist/middleware-DYNDkDz7.mjs +5 -0
- package/dist/middleware-SP7rhp6I.cjs +4 -0
- package/dist/{middleware-DQ1ijTAg.cjs → middleware-UNqaTRBe.cjs} +493 -546
- package/dist/{middleware-Bn5wceGF.js → middleware-xIvAtsQ9.mjs} +275 -320
- package/dist/{mod-CDObsV1d.d.ts → mod-BSwc3_rD.d.ts} +3 -3
- package/dist/{mod-DBzN0aCM.d.ts → mod-BTNpXcPj.d.ts} +2 -2
- package/dist/{mod-fjqfsrty.d.cts → mod-Chb_NKPp.d.cts} +4 -4
- package/dist/{mod-DgcYoyZK.d.ts → mod-DHoc3toL.d.ts} +4 -4
- package/dist/{mod-jQ4OODsl.d.cts → mod-DIMx6YjJ.d.cts} +2 -2
- package/dist/{mod-BUbqxBev.d.cts → mod-HElaq2UB.d.cts} +3 -3
- package/dist/mod.cjs +31 -33
- package/dist/mod.d.cts +15 -17
- package/dist/mod.d.ts +15 -17
- package/dist/mod.js +20 -23
- package/dist/{mq-B7R1Q-M5.d.cts → mq-CrItclRD.d.cts} +1 -1
- package/dist/{mq-CRGm1e_F.d.ts → mq-D_ZZRdby.d.ts} +1 -1
- package/dist/nodeinfo/client.test.d.mts +2 -0
- package/dist/nodeinfo/{client.test.js → client.test.mjs} +23 -45
- package/dist/nodeinfo/handler.test.d.mts +2 -0
- package/dist/nodeinfo/{handler.test.js → handler.test.mjs} +14 -43
- package/dist/nodeinfo/mod.cjs +5 -9
- package/dist/nodeinfo/mod.d.cts +2 -5
- package/dist/nodeinfo/mod.d.ts +2 -5
- package/dist/nodeinfo/mod.js +4 -9
- package/dist/nodeinfo/semver.test.d.mts +2 -0
- package/dist/nodeinfo/{semver.test.js → semver.test.mjs} +28 -51
- package/dist/nodeinfo/types.test.d.mts +2 -0
- package/dist/nodeinfo/{types.test.js → types.test.mjs} +10 -21
- package/dist/{owner-CD3PoJME.js → owner-CkmuWs8s.mjs} +10 -13
- package/dist/{owner-BbeUDvOu.d.ts → owner-DPAPnB0R.d.ts} +4 -4
- package/dist/{owner-6KSEp9eV.d.cts → owner-_rFs0ik_.d.cts} +4 -4
- package/dist/{proof-Qv3fs4TE.js → proof-BBEQdN7B.js} +33 -57
- package/dist/{proof-fJIJMt-0.js → proof-DVFzuYOq.mjs} +20 -32
- package/dist/{proof-CKkQu1BL.cjs → proof-DiFRNymC.cjs} +112 -135
- package/dist/{retry-D4GJ670a.js → retry-Ddbq3AcK.mjs} +4 -7
- package/dist/rolldown-runtime-C7fyD9f2.js +15 -0
- package/dist/runtime/authdocloader.test.d.mts +2 -0
- package/dist/runtime/{authdocloader.test.js → authdocloader.test.mjs} +16 -28
- package/dist/runtime/docloader.test.d.mts +2 -0
- package/dist/runtime/{docloader.test.js → docloader.test.mjs} +52 -72
- package/dist/runtime/key.test.d.mts +2 -0
- package/dist/runtime/{key.test.js → key.test.mjs} +27 -57
- package/dist/runtime/langstr.test.d.mts +2 -0
- package/dist/runtime/{langstr.test.js → langstr.test.mjs} +9 -19
- package/dist/runtime/link.test.d.mts +2 -0
- package/dist/runtime/{link.test.js → link.test.mjs} +7 -11
- package/dist/runtime/mod.cjs +7 -13
- package/dist/runtime/mod.d.cts +103 -6
- package/dist/runtime/mod.d.ts +103 -6
- package/dist/runtime/mod.js +6 -13
- package/dist/runtime/multibase/multibase.test.d.mts +2 -0
- package/dist/runtime/multibase/{multibase.test.js → multibase.test.mjs} +16 -33
- package/dist/runtime/url.test.d.mts +2 -0
- package/dist/runtime/{url.test.js → url.test.mjs} +10 -15
- package/dist/{semver-dArNLkR9.js → semver-CgD82xxg.mjs} +13 -28
- package/dist/{send-KX74JBzu.js → send-BsKuGBh0.mjs} +7 -12
- package/dist/sig/http.test.d.mts +2 -0
- package/dist/sig/{http.test.js → http.test.mjs} +119 -203
- package/dist/sig/key.test.d.mts +2 -0
- package/dist/sig/{key.test.js → key.test.mjs} +13 -22
- package/dist/sig/ld.test.d.mts +2 -0
- package/dist/sig/{ld.test.js → ld.test.mjs} +24 -39
- package/dist/sig/mod.cjs +7 -13
- package/dist/sig/mod.d.cts +3 -7
- package/dist/sig/mod.d.ts +3 -7
- package/dist/sig/mod.js +6 -13
- package/dist/sig/owner.test.d.mts +2 -0
- package/dist/sig/owner.test.mjs +39 -0
- package/dist/sig/proof.test.d.mts +2 -0
- package/dist/sig/{proof.test.js → proof.test.mjs} +18 -31
- package/dist/{std__assert-X-_kMxKM.js → std__assert-2v7gYiZp.mjs} +13 -24
- package/dist/testing/docloader.test.d.mts +2 -0
- package/dist/testing/docloader.test.mjs +12 -0
- package/dist/testing/{mod.d.ts → mod.d.mts} +371 -541
- package/dist/testing/mod.mjs +5 -0
- package/dist/{testing-DlM9L2qY.js → testing-8TvaN83G.mjs} +27 -35
- package/dist/{transformers-BFT6d7J5.js → transformers-BV4OeK9o.js} +3 -7
- package/dist/{transformers-CoBS-oFG.cjs → transformers-C2P5eKUT.cjs} +20 -25
- package/dist/{types-CfuEksTX.js → types-BK9bojU0.js} +18 -36
- package/dist/{types-BIgY6c-l.js → types-CAnkAQGM.mjs} +5 -9
- package/dist/{types-Bq8MUNvK.cjs → types-D4VM3B7I.cjs} +45 -64
- package/dist/vocab/actor.test.d.mts +2 -0
- package/dist/vocab/{actor.test.js → actor.test.mjs} +308 -550
- package/dist/vocab/cjs.test.d.mts +2 -0
- package/dist/vocab/cjs.test.mjs +14 -0
- package/dist/vocab/lookup.test.d.mts +2 -0
- package/dist/vocab/{lookup.test.js → lookup.test.mjs} +29 -45
- package/dist/vocab/mod.cjs +251 -16
- package/dist/vocab/mod.d.cts +3 -5
- package/dist/vocab/mod.d.ts +3 -5
- package/dist/vocab/mod.js +244 -10
- package/dist/vocab/type.test.d.mts +2 -0
- package/dist/vocab/type.test.mjs +16 -0
- package/dist/vocab/vocab.test.d.mts +2 -0
- package/dist/vocab/{vocab.test.js → vocab.test.mjs} +178 -311
- package/dist/{vocab-CDHNj5zp.d.ts → vocab-BLvSEtuz.d.cts} +2 -4
- package/dist/{type-kdsaa4c5.js → vocab-DuJO9k13.mjs} +1177 -2871
- package/dist/{vocab-Cfs0937i.d.cts → vocab-lhCS9lzq.d.ts} +4 -2
- package/dist/webfinger/handler.test.d.mts +2 -0
- package/dist/webfinger/{handler.test.js → handler.test.mjs} +23 -56
- package/dist/webfinger/lookup.test.d.mts +2 -0
- package/dist/webfinger/{lookup.test.js → lookup.test.mjs} +13 -27
- package/dist/webfinger/mod.cjs +5 -9
- package/dist/webfinger/mod.d.cts +1 -3
- package/dist/webfinger/mod.d.ts +1 -3
- package/dist/webfinger/mod.js +4 -9
- package/dist/x/cfworkers.cjs +25 -14
- package/dist/x/cfworkers.d.cts +33 -6
- package/dist/x/cfworkers.d.ts +33 -6
- package/dist/x/cfworkers.js +22 -12
- package/dist/x/cfworkers.test.d.mts +2 -0
- package/dist/x/{cfworkers.test.js → cfworkers.test.mjs} +28 -26
- package/dist/x/hono.cjs +25 -14
- package/dist/x/hono.d.cts +1 -11
- package/dist/x/hono.d.ts +1 -11
- package/dist/x/hono.js +22 -12
- package/dist/x/sveltekit.cjs +23 -12
- package/dist/x/sveltekit.d.cts +1 -11
- package/dist/x/sveltekit.d.ts +1 -11
- package/dist/x/sveltekit.js +20 -10
- package/package.json +2 -2
- package/dist/chunk-DqRYRqnO.cjs +0 -34
- package/dist/compat/transformers.test.d.ts +0 -3
- package/dist/compat/transformers.test.js +0 -86
- package/dist/compat-DmDDELst.cjs +0 -4
- package/dist/compat-nxUqe4Z-.js +0 -4
- package/dist/federation/builder.test.d.ts +0 -3
- package/dist/federation/collection.test.d.ts +0 -3
- package/dist/federation/collection.test.js +0 -35
- package/dist/federation/handler.test.d.ts +0 -3
- package/dist/federation/idempotency.test.d.ts +0 -3
- package/dist/federation/inbox.test.d.ts +0 -3
- package/dist/federation/keycache.test.d.ts +0 -3
- package/dist/federation/kv.test.d.ts +0 -3
- package/dist/federation/middleware.test.d.ts +0 -3
- package/dist/federation/mq.test.d.ts +0 -3
- package/dist/federation/retry.test.d.ts +0 -3
- package/dist/federation/router.test.d.ts +0 -3
- package/dist/federation/send.test.d.ts +0 -3
- package/dist/federation-D1U8YY9t.js +0 -226
- package/dist/federation-H2_En3j5.cjs +0 -244
- package/dist/key-Bsm-uoaE.js +0 -10
- package/dist/key-Bv9soVGW.cjs +0 -10
- package/dist/key-C6dA6KgH.js +0 -10
- package/dist/middleware-BJbqjuUV.js +0 -17
- package/dist/middleware-BVltQrGG.cjs +0 -17
- package/dist/middleware-NDh5Vgwn.js +0 -26
- package/dist/mod-BcObK1Lz.d.ts +0 -82
- package/dist/mod-C2tOeRkN.d.cts +0 -1
- package/dist/mod-CIbqfZW0.d.ts +0 -104
- package/dist/mod-Dt-G9ZOS.d.cts +0 -102
- package/dist/mod-FZd39qVq.d.cts +0 -1
- package/dist/mod-mXx9V0q5.d.cts +0 -80
- package/dist/nodeinfo/client.test.d.ts +0 -3
- package/dist/nodeinfo/handler.test.d.ts +0 -3
- package/dist/nodeinfo/semver.test.d.ts +0 -3
- package/dist/nodeinfo/types.test.d.ts +0 -3
- package/dist/nodeinfo-Co9lJrWl.cjs +0 -4
- package/dist/nodeinfo-DfycQ8Wf.js +0 -4
- package/dist/runtime/authdocloader.test.d.ts +0 -3
- package/dist/runtime/docloader.test.d.ts +0 -3
- package/dist/runtime/key.test.d.ts +0 -3
- package/dist/runtime/langstr.test.d.ts +0 -3
- package/dist/runtime/link.test.d.ts +0 -3
- package/dist/runtime/multibase/multibase.test.d.ts +0 -3
- package/dist/runtime/url.test.d.ts +0 -3
- package/dist/runtime-C58AJWSv.cjs +0 -4
- package/dist/runtime-DPYEDf-o.js +0 -4
- package/dist/sig/http.test.d.ts +0 -3
- package/dist/sig/key.test.d.ts +0 -3
- package/dist/sig/ld.test.d.ts +0 -3
- package/dist/sig/owner.test.d.ts +0 -3
- package/dist/sig/owner.test.js +0 -52
- package/dist/sig/proof.test.d.ts +0 -3
- package/dist/sig-ByHXzqUi.cjs +0 -4
- package/dist/sig-Cj3tk-ig.js +0 -4
- package/dist/testing/docloader.test.d.ts +0 -3
- package/dist/testing/docloader.test.js +0 -24
- package/dist/testing/mod.js +0 -10
- package/dist/vocab/actor.test.d.ts +0 -3
- package/dist/vocab/lookup.test.d.ts +0 -3
- package/dist/vocab/type.test.d.ts +0 -3
- package/dist/vocab/type.test.js +0 -25
- package/dist/vocab/vocab.test.d.ts +0 -3
- package/dist/vocab-DBzzAvtf.cjs +0 -289
- package/dist/vocab-cxfw8FFj.js +0 -253
- package/dist/webfinger/handler.test.d.ts +0 -3
- package/dist/webfinger/lookup.test.d.ts +0 -3
- package/dist/webfinger-BjOEdFPs.cjs +0 -4
- package/dist/webfinger-De_bU0iE.js +0 -4
- package/dist/x/cfworkers.test.d.ts +0 -3
- /package/dist/{mod-1pDWKvUL.d.ts → compat/transformers.test.d.mts} +0 -0
- /package/dist/{mod-g0xFzAP9.d.ts → federation/builder.test.d.mts} +0 -0
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
import { Router, RouterError } from "./lookup-B0Qds1Mq.js";
|
|
8
|
-
import { InboxListenerSet } from "./inbox-CLgNEczc.js";
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
globalThis.addEventListener = () => {};
|
|
4
|
+
import { U as getTypeId, ot as name, st as version } from "./vocab-DuJO9k13.mjs";
|
|
5
|
+
import { i as RouterError, r as Router } from "./lookup-B-LJhUtc.mjs";
|
|
6
|
+
import { t as InboxListenerSet } from "./inbox-B0NdZv6Q.mjs";
|
|
9
7
|
import { getLogger } from "@logtape/logtape";
|
|
10
8
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
11
|
-
|
|
12
9
|
//#region src/federation/builder.ts
|
|
13
10
|
var FederationBuilderImpl = class {
|
|
14
11
|
router;
|
|
@@ -43,7 +40,7 @@ var FederationBuilderImpl = class {
|
|
|
43
40
|
this.collectionTypeIds = {};
|
|
44
41
|
}
|
|
45
42
|
async build(options) {
|
|
46
|
-
const { FederationImpl } = await import("./middleware-
|
|
43
|
+
const { FederationImpl } = await import("./middleware-DYNDkDz7.mjs");
|
|
47
44
|
const f = new FederationImpl(options);
|
|
48
45
|
const trailingSlashInsensitiveValue = f.router.trailingSlashInsensitive;
|
|
49
46
|
f.router = this.router.clone();
|
|
@@ -69,7 +66,7 @@ var FederationBuilderImpl = class {
|
|
|
69
66
|
return f;
|
|
70
67
|
}
|
|
71
68
|
_getTracer() {
|
|
72
|
-
return trace.getTracer(
|
|
69
|
+
return trace.getTracer(name, version);
|
|
73
70
|
}
|
|
74
71
|
setActorDispatcher(path, dispatcher) {
|
|
75
72
|
if (this.router.has("actor")) throw new RouterError("Actor dispatcher already set.");
|
|
@@ -80,17 +77,17 @@ var FederationBuilderImpl = class {
|
|
|
80
77
|
"federation",
|
|
81
78
|
"actor"
|
|
82
79
|
]).warn("The {{handle}} variable in the actor dispatcher path is deprecated. Use {{identifier}} instead.");
|
|
83
|
-
const callbacks = { dispatcher: async (context
|
|
80
|
+
const callbacks = { dispatcher: async (context, identifier) => {
|
|
84
81
|
const actor = await this._getTracer().startActiveSpan("activitypub.dispatch_actor", {
|
|
85
82
|
kind: SpanKind.SERVER,
|
|
86
83
|
attributes: { "fedify.actor.identifier": identifier }
|
|
87
84
|
}, async (span) => {
|
|
88
85
|
try {
|
|
89
|
-
const actor
|
|
90
|
-
span.setAttribute("activitypub.actor.id", (actor
|
|
91
|
-
if (actor
|
|
92
|
-
else span.setAttribute("activitypub.actor.type", getTypeId(actor
|
|
93
|
-
return actor
|
|
86
|
+
const actor = await dispatcher(context, identifier);
|
|
87
|
+
span.setAttribute("activitypub.actor.id", (actor?.id ?? context.getActorUri(identifier)).href);
|
|
88
|
+
if (actor == null) span.setStatus({ code: SpanStatusCode.ERROR });
|
|
89
|
+
else span.setAttribute("activitypub.actor.type", getTypeId(actor).href);
|
|
90
|
+
return actor;
|
|
94
91
|
} catch (error) {
|
|
95
92
|
span.setStatus({
|
|
96
93
|
code: SpanStatusCode.ERROR,
|
|
@@ -108,36 +105,36 @@ var FederationBuilderImpl = class {
|
|
|
108
105
|
"actor"
|
|
109
106
|
]);
|
|
110
107
|
if (actor.id == null) logger.warn("Actor dispatcher returned an actor without an id property. Set the property with Context.getActorUri(identifier).");
|
|
111
|
-
else if (actor.id.href != context
|
|
108
|
+
else if (actor.id.href != context.getActorUri(identifier).href) logger.warn("Actor dispatcher returned an actor with an id property that does not match the actor URI. Set the property with Context.getActorUri(identifier).");
|
|
112
109
|
if (this.followingCallbacks != null && this.followingCallbacks.dispatcher != null) {
|
|
113
110
|
if (actor.followingId == null) logger.warn("You configured a following collection dispatcher, but the actor does not have a following property. Set the property with Context.getFollowingUri(identifier).");
|
|
114
|
-
else if (actor.followingId.href != context
|
|
111
|
+
else if (actor.followingId.href != context.getFollowingUri(identifier).href) logger.warn("You configured a following collection dispatcher, but the actor's following property does not match the following collection URI. Set the property with Context.getFollowingUri(identifier).");
|
|
115
112
|
}
|
|
116
113
|
if (this.followersCallbacks != null && this.followersCallbacks.dispatcher != null) {
|
|
117
114
|
if (actor.followersId == null) logger.warn("You configured a followers collection dispatcher, but the actor does not have a followers property. Set the property with Context.getFollowersUri(identifier).");
|
|
118
|
-
else if (actor.followersId.href != context
|
|
115
|
+
else if (actor.followersId.href != context.getFollowersUri(identifier).href) logger.warn("You configured a followers collection dispatcher, but the actor's followers property does not match the followers collection URI. Set the property with Context.getFollowersUri(identifier).");
|
|
119
116
|
}
|
|
120
117
|
if (this.outboxCallbacks != null && this.outboxCallbacks.dispatcher != null) {
|
|
121
118
|
if (actor?.outboxId == null) logger.warn("You configured an outbox collection dispatcher, but the actor does not have an outbox property. Set the property with Context.getOutboxUri(identifier).");
|
|
122
|
-
else if (actor.outboxId.href != context
|
|
119
|
+
else if (actor.outboxId.href != context.getOutboxUri(identifier).href) logger.warn("You configured an outbox collection dispatcher, but the actor's outbox property does not match the outbox collection URI. Set the property with Context.getOutboxUri(identifier).");
|
|
123
120
|
}
|
|
124
121
|
if (this.likedCallbacks != null && this.likedCallbacks.dispatcher != null) {
|
|
125
122
|
if (actor?.likedId == null) logger.warn("You configured a liked collection dispatcher, but the actor does not have a liked property. Set the property with Context.getLikedUri(identifier).");
|
|
126
|
-
else if (actor.likedId.href != context
|
|
123
|
+
else if (actor.likedId.href != context.getLikedUri(identifier).href) logger.warn("You configured a liked collection dispatcher, but the actor's liked property does not match the liked collection URI. Set the property with Context.getLikedUri(identifier).");
|
|
127
124
|
}
|
|
128
125
|
if (this.featuredCallbacks != null && this.featuredCallbacks.dispatcher != null) {
|
|
129
126
|
if (actor?.featuredId == null) logger.warn("You configured a featured collection dispatcher, but the actor does not have a featured property. Set the property with Context.getFeaturedUri(identifier).");
|
|
130
|
-
else if (actor.featuredId.href != context
|
|
127
|
+
else if (actor.featuredId.href != context.getFeaturedUri(identifier).href) logger.warn("You configured a featured collection dispatcher, but the actor's featured property does not match the featured collection URI. Set the property with Context.getFeaturedUri(identifier).");
|
|
131
128
|
}
|
|
132
129
|
if (this.featuredTagsCallbacks != null && this.featuredTagsCallbacks.dispatcher != null) {
|
|
133
130
|
if (actor?.featuredTagsId == null) logger.warn("You configured a featured tags collection dispatcher, but the actor does not have a featuredTags property. Set the property with Context.getFeaturedTagsUri(identifier).");
|
|
134
|
-
else if (actor.featuredTagsId.href != context
|
|
131
|
+
else if (actor.featuredTagsId.href != context.getFeaturedTagsUri(identifier).href) logger.warn("You configured a featured tags collection dispatcher, but the actor's featuredTags property does not match the featured tags collection URI. Set the property with Context.getFeaturedTagsUri(identifier).");
|
|
135
132
|
}
|
|
136
133
|
if (this.router.has("inbox")) {
|
|
137
134
|
if (actor.inboxId == null) logger.warn("You configured inbox listeners, but the actor does not have an inbox property. Set the property with Context.getInboxUri(identifier).");
|
|
138
|
-
else if (actor.inboxId.href != context
|
|
135
|
+
else if (actor.inboxId.href != context.getInboxUri(identifier).href) logger.warn("You configured inbox listeners, but the actor's inbox property does not match the inbox URI. Set the property with Context.getInboxUri(identifier).");
|
|
139
136
|
if (actor.endpoints == null || actor.endpoints.sharedInbox == null) logger.warn("You configured inbox listeners, but the actor does not have a endpoints.sharedInbox property. Set the property with Context.getInboxUri().");
|
|
140
|
-
else if (actor.endpoints.sharedInbox.href != context
|
|
137
|
+
else if (actor.endpoints.sharedInbox.href != context.getInboxUri().href) logger.warn("You configured inbox listeners, but the actor's endpoints.sharedInbox property does not match the shared inbox URI. Set the property with Context.getInboxUri().");
|
|
141
138
|
}
|
|
142
139
|
if (callbacks.keyPairsDispatcher != null) {
|
|
143
140
|
if (actor.publicKeyId == null) logger.warn("You configured a key pairs dispatcher, but the actor does not have a publicKey property. Set the property with Context.getActorKeyPairs(identifier).");
|
|
@@ -147,7 +144,7 @@ var FederationBuilderImpl = class {
|
|
|
147
144
|
} };
|
|
148
145
|
this.actorCallbacks = callbacks;
|
|
149
146
|
const setters = {
|
|
150
|
-
setKeyPairsDispatcher: (dispatcher
|
|
147
|
+
setKeyPairsDispatcher: (dispatcher) => {
|
|
151
148
|
callbacks.keyPairsDispatcher = (ctx, identifier) => this._getTracer().startActiveSpan("activitypub.dispatch_actor_key_pairs", {
|
|
152
149
|
kind: SpanKind.SERVER,
|
|
153
150
|
attributes: {
|
|
@@ -156,7 +153,7 @@ var FederationBuilderImpl = class {
|
|
|
156
153
|
}
|
|
157
154
|
}, async (span) => {
|
|
158
155
|
try {
|
|
159
|
-
return await dispatcher
|
|
156
|
+
return await dispatcher(ctx, identifier);
|
|
160
157
|
} catch (e) {
|
|
161
158
|
span.setStatus({
|
|
162
159
|
code: SpanStatusCode.ERROR,
|
|
@@ -186,8 +183,7 @@ var FederationBuilderImpl = class {
|
|
|
186
183
|
}
|
|
187
184
|
setNodeInfoDispatcher(path, dispatcher) {
|
|
188
185
|
if (this.router.has("nodeInfo")) throw new RouterError("NodeInfo dispatcher already set.");
|
|
189
|
-
|
|
190
|
-
if (variables.size !== 0) throw new RouterError("Path for NodeInfo dispatcher must have no variables.");
|
|
186
|
+
if (this.router.add(path, "nodeInfo").size !== 0) throw new RouterError("Path for NodeInfo dispatcher must have no variables.");
|
|
191
187
|
this.nodeInfoDispatcher = dispatcher;
|
|
192
188
|
}
|
|
193
189
|
setWebFingerLinksDispatcher(dispatcher) {
|
|
@@ -200,8 +196,7 @@ var FederationBuilderImpl = class {
|
|
|
200
196
|
if (variables.size < 1) throw new RouterError("Path for object dispatcher must have at least one variable.");
|
|
201
197
|
const callbacks = {
|
|
202
198
|
dispatcher: (ctx, values) => {
|
|
203
|
-
|
|
204
|
-
return tracer.startActiveSpan("activitypub.dispatch_object", {
|
|
199
|
+
return this._getTracer().startActiveSpan("activitypub.dispatch_object", {
|
|
205
200
|
kind: SpanKind.SERVER,
|
|
206
201
|
attributes: {
|
|
207
202
|
"fedify.object.type": cls.typeId.href,
|
|
@@ -472,8 +467,7 @@ var FederationBuilderImpl = class {
|
|
|
472
467
|
]).warn("The {{handle}} variable in the inbox path is deprecated. Use {{identifier}} instead.");
|
|
473
468
|
}
|
|
474
469
|
if (sharedInboxPath != null) {
|
|
475
|
-
|
|
476
|
-
if (siVars.size !== 0) throw new RouterError("Path for shared inbox must have no variables.");
|
|
470
|
+
if (this.router.add(sharedInboxPath, "sharedInbox").size !== 0) throw new RouterError("Path for shared inbox must have no variables.");
|
|
477
471
|
}
|
|
478
472
|
const listeners = this.inboxListeners = new InboxListenerSet();
|
|
479
473
|
const setters = {
|
|
@@ -507,8 +501,7 @@ var FederationBuilderImpl = class {
|
|
|
507
501
|
const routeName = `${collectionType}:${this.#uniqueCollectionId(name)}`;
|
|
508
502
|
if (this.router.has(routeName)) throw new RouterError(`Collection dispatcher for ${strName} already set.`);
|
|
509
503
|
if (this.collectionCallbacks[name] != null) throw new RouterError(`Collection dispatcher for ${strName} already set.`);
|
|
510
|
-
|
|
511
|
-
if (variables.size < 1) throw new RouterError("Path for collection dispatcher must have at least one variable.");
|
|
504
|
+
if (this.router.add(path, routeName).size < 1) throw new RouterError("Path for collection dispatcher must have at least one variable.");
|
|
512
505
|
const callbacks = { dispatcher };
|
|
513
506
|
this.collectionCallbacks[name] = callbacks;
|
|
514
507
|
this.collectionTypeIds[name] = itemType;
|
|
@@ -543,8 +536,7 @@ var FederationBuilderImpl = class {
|
|
|
543
536
|
getCollectionPath(name, values) {
|
|
544
537
|
if (!(name in this.collectionCallbacks)) return null;
|
|
545
538
|
const routeName = this.#uniqueCollectionId(name);
|
|
546
|
-
|
|
547
|
-
return path;
|
|
539
|
+
return this.router.build(`collection:${routeName}`, values) ?? this.router.build(`orderedCollection:${routeName}`, values);
|
|
548
540
|
}
|
|
549
541
|
/**
|
|
550
542
|
* Converts a name (string or symbol) to a unique string identifier.
|
|
@@ -567,6 +559,5 @@ var FederationBuilderImpl = class {
|
|
|
567
559
|
function createFederationBuilder() {
|
|
568
560
|
return new FederationBuilderImpl();
|
|
569
561
|
}
|
|
570
|
-
|
|
571
562
|
//#endregion
|
|
572
|
-
export {
|
|
563
|
+
export { createFederationBuilder as n, FederationBuilderImpl as t };
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { getUserAgent } from "./type-kdsaa4c5.js";
|
|
7
|
-
import { parseSemVer } from "./semver-dArNLkR9.js";
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
globalThis.addEventListener = () => {};
|
|
4
|
+
import { X as getUserAgent } from "./vocab-DuJO9k13.mjs";
|
|
5
|
+
import { n as parseSemVer } from "./semver-CgD82xxg.mjs";
|
|
8
6
|
import { getLogger } from "@logtape/logtape";
|
|
9
|
-
|
|
10
7
|
//#region src/nodeinfo/client.ts
|
|
11
8
|
const logger = getLogger([
|
|
12
9
|
"fedify",
|
|
@@ -28,16 +25,16 @@ async function getNodeInfo(url, options = {}) {
|
|
|
28
25
|
status: wellKnownResponse.status,
|
|
29
26
|
statusText: wellKnownResponse.statusText
|
|
30
27
|
});
|
|
31
|
-
return
|
|
28
|
+
return;
|
|
32
29
|
}
|
|
33
30
|
const wellKnownRd = await wellKnownResponse.json();
|
|
34
|
-
const link = wellKnownRd?.links?.find((link
|
|
31
|
+
const link = wellKnownRd?.links?.find((link) => link != null && "rel" in link && (link.rel === "http://nodeinfo.diaspora.software/ns/schema/2.0" || link.rel === "http://nodeinfo.diaspora.software/ns/schema/2.1") && "href" in link && link.href != null);
|
|
35
32
|
if (link == null || link.href == null) {
|
|
36
33
|
logger.error("Failed to find a NodeInfo document link from {url}: {resourceDescriptor}", {
|
|
37
34
|
url: wellKnownUrl.href,
|
|
38
35
|
resourceDescriptor: wellKnownRd
|
|
39
36
|
});
|
|
40
|
-
return
|
|
37
|
+
return;
|
|
41
38
|
}
|
|
42
39
|
nodeInfoUrl = link.href;
|
|
43
40
|
}
|
|
@@ -51,7 +48,7 @@ async function getNodeInfo(url, options = {}) {
|
|
|
51
48
|
status: response.status,
|
|
52
49
|
statusText: response.statusText
|
|
53
50
|
});
|
|
54
|
-
return
|
|
51
|
+
return;
|
|
55
52
|
}
|
|
56
53
|
const data = await response.json();
|
|
57
54
|
if (options.parse === "none") return data;
|
|
@@ -61,7 +58,7 @@ async function getNodeInfo(url, options = {}) {
|
|
|
61
58
|
url: url.toString(),
|
|
62
59
|
error
|
|
63
60
|
});
|
|
64
|
-
return
|
|
61
|
+
return;
|
|
65
62
|
}
|
|
66
63
|
}
|
|
67
64
|
/**
|
|
@@ -269,6 +266,5 @@ function parseUsage(data, options = {}) {
|
|
|
269
266
|
localComments
|
|
270
267
|
};
|
|
271
268
|
}
|
|
272
|
-
|
|
273
269
|
//#endregion
|
|
274
|
-
export {
|
|
270
|
+
export { parseProtocol as a, parseUsage as c, parseOutboundService as i, parseInboundService as n, parseServices as o, parseNodeInfo as r, parseSoftware as s, getNodeInfo as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import { GetUserAgentOptions } from "./docloader-
|
|
3
|
+
import { s as GetUserAgentOptions } from "./docloader-DSaLRXEA.js";
|
|
4
4
|
|
|
5
5
|
//#region src/nodeinfo/semver.d.ts
|
|
6
6
|
/**
|
|
@@ -293,4 +293,4 @@ interface ParseNodeInfoOptions {
|
|
|
293
293
|
*/
|
|
294
294
|
declare function parseNodeInfo(data: unknown, options?: ParseNodeInfoOptions): NodeInfo | null;
|
|
295
295
|
//#endregion
|
|
296
|
-
export {
|
|
296
|
+
export { InboundService as a, OutboundService as c, Software as d, Usage as f, parseSemVer as g, formatSemVer as h, parseNodeInfo as i, Protocol as l, SemVer as m, ParseNodeInfoOptions as n, JsonValue as o, nodeInfoToJson as p, getNodeInfo as r, NodeInfo as s, GetNodeInfoOptions as t, Services as u };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GetUserAgentOptions } from "./docloader-
|
|
1
|
+
import { s as GetUserAgentOptions } from "./docloader-DpGRDZrn.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/nodeinfo/semver.d.ts
|
|
4
4
|
/**
|
|
@@ -291,4 +291,4 @@ interface ParseNodeInfoOptions {
|
|
|
291
291
|
*/
|
|
292
292
|
declare function parseNodeInfo(data: unknown, options?: ParseNodeInfoOptions): NodeInfo | null;
|
|
293
293
|
//#endregion
|
|
294
|
-
export {
|
|
294
|
+
export { InboundService as a, OutboundService as c, Software as d, Usage as f, parseSemVer as g, formatSemVer as h, parseNodeInfo as i, Protocol as l, SemVer as m, ParseNodeInfoOptions as n, JsonValue as o, nodeInfoToJson as p, getNodeInfo as r, NodeInfo as s, GetNodeInfoOptions as t, Services as u };
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
globalThis.addEventListener = () => {};
|
|
5
|
-
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
globalThis.addEventListener = () => {};
|
|
6
4
|
import { encodeHex } from "byte-encodings/hex";
|
|
7
|
-
|
|
8
5
|
//#region src/federation/collection.ts
|
|
9
6
|
/**
|
|
10
7
|
* Calculates the [partial follower collection digest][1].
|
|
@@ -22,8 +19,8 @@ async function digest(uris) {
|
|
|
22
19
|
if (processed.has(u)) continue;
|
|
23
20
|
processed.add(u);
|
|
24
21
|
const encoded = encoder.encode(u);
|
|
25
|
-
const digest
|
|
26
|
-
for (let i = 0; i < 32; i++) result[i] ^= digest
|
|
22
|
+
const digest = new Uint8Array(await crypto.subtle.digest("SHA-256", encoded));
|
|
23
|
+
for (let i = 0; i < 32; i++) result[i] ^= digest[i];
|
|
27
24
|
}
|
|
28
25
|
return result;
|
|
29
26
|
}
|
|
@@ -41,9 +38,7 @@ async function buildCollectionSynchronizationHeader(collectionId, actorIds) {
|
|
|
41
38
|
const baseUrl = new URL(anyActorId);
|
|
42
39
|
const url = new URL(collectionId);
|
|
43
40
|
url.searchParams.set("base-url", `${baseUrl.origin}/`);
|
|
44
|
-
|
|
45
|
-
return `collectionId="${collectionId}", url="${url}", digest="${hash}"`;
|
|
41
|
+
return `collectionId="${collectionId}", url="${url}", digest="${encodeHex(await digest(actorIds))}"`;
|
|
46
42
|
}
|
|
47
|
-
|
|
48
43
|
//#endregion
|
|
49
|
-
export {
|
|
44
|
+
export { digest as n, buildCollectionSynchronizationHeader as t };
|
package/dist/compat/mod.cjs
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const require_transformers = require('../transformers-CoBS-oFG.cjs');
|
|
6
|
-
require('../compat-DmDDELst.cjs');
|
|
7
|
-
|
|
1
|
+
const { Temporal } = require("@js-temporal/polyfill");
|
|
2
|
+
const { URLPattern } = require("urlpattern-polyfill");
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const require_transformers = require("../transformers-C2P5eKUT.cjs");
|
|
8
5
|
exports.actorDehydrator = require_transformers.actorDehydrator;
|
|
9
6
|
exports.autoIdAssigner = require_transformers.autoIdAssigner;
|
|
10
|
-
exports.getDefaultActivityTransformers = require_transformers.getDefaultActivityTransformers;
|
|
7
|
+
exports.getDefaultActivityTransformers = require_transformers.getDefaultActivityTransformers;
|
package/dist/compat/mod.d.cts
CHANGED
|
@@ -1,13 +1,79 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import "../
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { n as Activity } from "../vocab-BLvSEtuz.cjs";
|
|
2
|
+
import { n as Context, pt as ActivityTransformer } from "../context-CACMqDzl.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/compat/transformers.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* An activity transformer that assigns a new random ID to an activity if it
|
|
7
|
+
* does not already have one. This is useful for ensuring that activities
|
|
8
|
+
* have an ID before they are sent to other servers.
|
|
9
|
+
*
|
|
10
|
+
* The generated ID is an origin URI with a fragment which contains an activity
|
|
11
|
+
* type name with a random UUID:
|
|
12
|
+
*
|
|
13
|
+
* ```
|
|
14
|
+
* https://example.com/#Follow/12345678-1234-5678-1234-567812345678
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @template TContextData The type of the context data.
|
|
18
|
+
* @param activity The activity to assign an ID to.
|
|
19
|
+
* @param context The context of the activity.
|
|
20
|
+
* @return The activity with an ID assigned.
|
|
21
|
+
* @since 1.4.0
|
|
22
|
+
*/
|
|
23
|
+
declare function autoIdAssigner<TContextData>(activity: Activity, context: Context<TContextData>): Activity;
|
|
24
|
+
/**
|
|
25
|
+
* An activity transformer that dehydrates the actor property of an activity
|
|
26
|
+
* so that it only contains the actor's URI. For example, suppose we have an
|
|
27
|
+
* activity like this:
|
|
28
|
+
*
|
|
29
|
+
* ```typescript
|
|
30
|
+
* import { Follow, Person } from "@fedify/fedify/vocab";
|
|
31
|
+
* const input = new Follow({
|
|
32
|
+
* id: new URL("http://example.com/activities/1"),
|
|
33
|
+
* actor: new Person({
|
|
34
|
+
* id: new URL("http://example.com/actors/1"),
|
|
35
|
+
* name: "Alice",
|
|
36
|
+
* preferredUsername: "alice",
|
|
37
|
+
* }),
|
|
38
|
+
* object: new Person({
|
|
39
|
+
* id: new URL("http://example.com/actors/2"),
|
|
40
|
+
* name: "Bob",
|
|
41
|
+
* preferredUsername: "bob",
|
|
42
|
+
* }),
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* The result of applying this transformer would be:
|
|
47
|
+
*
|
|
48
|
+
* ```typescript
|
|
49
|
+
* import { Follow, Person } from "@fedify/fedify/vocab";
|
|
50
|
+
* const output = new Follow({
|
|
51
|
+
* id: new URL("http://example.com/activities/1"),
|
|
52
|
+
* actor: new URL("http://example.com/actors/1"),
|
|
53
|
+
* object: new Person({
|
|
54
|
+
* id: new URL("http://example.com/actors/2"),
|
|
55
|
+
* name: "Bob",
|
|
56
|
+
* preferredUsername: "bob",
|
|
57
|
+
* }),
|
|
58
|
+
* });
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* As some ActivityPub implementations like Threads fail to deal with inlined
|
|
62
|
+
* actor objects, this transformer can be used to work around this issue.
|
|
63
|
+
* @template TContextData The type of the context data.
|
|
64
|
+
* @param activity The activity to dehydrate the actor property of.
|
|
65
|
+
* @param context The context of the activity.
|
|
66
|
+
* @returns The dehydrated activity.
|
|
67
|
+
* @since 1.4.0
|
|
68
|
+
*/
|
|
69
|
+
declare function actorDehydrator<TContextData>(activity: Activity, _context: Context<TContextData>): Activity;
|
|
70
|
+
/**
|
|
71
|
+
* Gets the default activity transformers that are applied to all outgoing
|
|
72
|
+
* activities.
|
|
73
|
+
* @template TContextData The type of the context data.
|
|
74
|
+
* @returns The default activity transformers.
|
|
75
|
+
* @since 1.4.0
|
|
76
|
+
*/
|
|
77
|
+
declare function getDefaultActivityTransformers<TContextData>(): readonly ActivityTransformer<TContextData>[];
|
|
78
|
+
//#endregion
|
|
13
79
|
export { ActivityTransformer, actorDehydrator, autoIdAssigner, getDefaultActivityTransformers };
|
package/dist/compat/mod.d.ts
CHANGED
|
@@ -1,15 +1,81 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import "../
|
|
4
|
-
import "../
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
3
|
+
import { n as Activity } from "../vocab-lhCS9lzq.js";
|
|
4
|
+
import { n as Context, pt as ActivityTransformer } from "../context-K4cCphQj.js";
|
|
5
|
+
|
|
6
|
+
//#region src/compat/transformers.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* An activity transformer that assigns a new random ID to an activity if it
|
|
9
|
+
* does not already have one. This is useful for ensuring that activities
|
|
10
|
+
* have an ID before they are sent to other servers.
|
|
11
|
+
*
|
|
12
|
+
* The generated ID is an origin URI with a fragment which contains an activity
|
|
13
|
+
* type name with a random UUID:
|
|
14
|
+
*
|
|
15
|
+
* ```
|
|
16
|
+
* https://example.com/#Follow/12345678-1234-5678-1234-567812345678
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @template TContextData The type of the context data.
|
|
20
|
+
* @param activity The activity to assign an ID to.
|
|
21
|
+
* @param context The context of the activity.
|
|
22
|
+
* @return The activity with an ID assigned.
|
|
23
|
+
* @since 1.4.0
|
|
24
|
+
*/
|
|
25
|
+
declare function autoIdAssigner<TContextData>(activity: Activity, context: Context<TContextData>): Activity;
|
|
26
|
+
/**
|
|
27
|
+
* An activity transformer that dehydrates the actor property of an activity
|
|
28
|
+
* so that it only contains the actor's URI. For example, suppose we have an
|
|
29
|
+
* activity like this:
|
|
30
|
+
*
|
|
31
|
+
* ```typescript
|
|
32
|
+
* import { Follow, Person } from "@fedify/fedify/vocab";
|
|
33
|
+
* const input = new Follow({
|
|
34
|
+
* id: new URL("http://example.com/activities/1"),
|
|
35
|
+
* actor: new Person({
|
|
36
|
+
* id: new URL("http://example.com/actors/1"),
|
|
37
|
+
* name: "Alice",
|
|
38
|
+
* preferredUsername: "alice",
|
|
39
|
+
* }),
|
|
40
|
+
* object: new Person({
|
|
41
|
+
* id: new URL("http://example.com/actors/2"),
|
|
42
|
+
* name: "Bob",
|
|
43
|
+
* preferredUsername: "bob",
|
|
44
|
+
* }),
|
|
45
|
+
* });
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* The result of applying this transformer would be:
|
|
49
|
+
*
|
|
50
|
+
* ```typescript
|
|
51
|
+
* import { Follow, Person } from "@fedify/fedify/vocab";
|
|
52
|
+
* const output = new Follow({
|
|
53
|
+
* id: new URL("http://example.com/activities/1"),
|
|
54
|
+
* actor: new URL("http://example.com/actors/1"),
|
|
55
|
+
* object: new Person({
|
|
56
|
+
* id: new URL("http://example.com/actors/2"),
|
|
57
|
+
* name: "Bob",
|
|
58
|
+
* preferredUsername: "bob",
|
|
59
|
+
* }),
|
|
60
|
+
* });
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* As some ActivityPub implementations like Threads fail to deal with inlined
|
|
64
|
+
* actor objects, this transformer can be used to work around this issue.
|
|
65
|
+
* @template TContextData The type of the context data.
|
|
66
|
+
* @param activity The activity to dehydrate the actor property of.
|
|
67
|
+
* @param context The context of the activity.
|
|
68
|
+
* @returns The dehydrated activity.
|
|
69
|
+
* @since 1.4.0
|
|
70
|
+
*/
|
|
71
|
+
declare function actorDehydrator<TContextData>(activity: Activity, _context: Context<TContextData>): Activity;
|
|
72
|
+
/**
|
|
73
|
+
* Gets the default activity transformers that are applied to all outgoing
|
|
74
|
+
* activities.
|
|
75
|
+
* @template TContextData The type of the context data.
|
|
76
|
+
* @returns The default activity transformers.
|
|
77
|
+
* @since 1.4.0
|
|
78
|
+
*/
|
|
79
|
+
declare function getDefaultActivityTransformers<TContextData>(): readonly ActivityTransformer<TContextData>[];
|
|
80
|
+
//#endregion
|
|
15
81
|
export { ActivityTransformer, actorDehydrator, autoIdAssigner, getDefaultActivityTransformers };
|
package/dist/compat/mod.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { actorDehydrator, autoIdAssigner, getDefaultActivityTransformers } from "../transformers-BFT6d7J5.js";
|
|
6
|
-
import "../compat-nxUqe4Z-.js";
|
|
7
|
-
|
|
8
|
-
export { actorDehydrator, autoIdAssigner, getDefaultActivityTransformers };
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
import { n as autoIdAssigner, r as getDefaultActivityTransformers, t as actorDehydrator } from "../transformers-BV4OeK9o.js";
|
|
4
|
+
export { actorDehydrator, autoIdAssigner, getDefaultActivityTransformers };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
globalThis.addEventListener = () => {};
|
|
4
|
+
import { C as Person, u as Follow } from "../vocab-DuJO9k13.mjs";
|
|
5
|
+
import { t as test } from "../testing-8TvaN83G.mjs";
|
|
6
|
+
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
7
|
+
import { t as assertInstanceOf } from "../assert_instance_of-C4Ri6VuN.mjs";
|
|
8
|
+
import { t as assert } from "../assert-DikXweDx.mjs";
|
|
9
|
+
import { t as MemoryKvStore } from "../kv-DM1zFCtL.mjs";
|
|
10
|
+
import { _ as actorDehydrator, n as FederationImpl, v as autoIdAssigner } from "../middleware-xIvAtsQ9.mjs";
|
|
11
|
+
//#region src/compat/transformers.test.ts
|
|
12
|
+
const context = new FederationImpl({ kv: new MemoryKvStore() }).createContext(new URL("http://example.com/"));
|
|
13
|
+
test("autoIdAssigner", async () => {
|
|
14
|
+
const result = autoIdAssigner(new Follow({
|
|
15
|
+
actor: new URL("http://example.com/actors/1"),
|
|
16
|
+
object: new Person({
|
|
17
|
+
id: new URL("http://example.com/actors/2"),
|
|
18
|
+
name: "Bob",
|
|
19
|
+
preferredUsername: "bob"
|
|
20
|
+
})
|
|
21
|
+
}), context);
|
|
22
|
+
const { id } = result;
|
|
23
|
+
assertInstanceOf(id, URL);
|
|
24
|
+
assertEquals(id.origin, "http://example.com");
|
|
25
|
+
assertEquals(id.pathname, "/");
|
|
26
|
+
assertEquals(id.search, "");
|
|
27
|
+
assert(id.hash.match(/^#Follow\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/));
|
|
28
|
+
assertEquals(await result.toJsonLd(), await new Follow({
|
|
29
|
+
id,
|
|
30
|
+
actor: new URL("http://example.com/actors/1"),
|
|
31
|
+
object: new Person({
|
|
32
|
+
id: new URL("http://example.com/actors/2"),
|
|
33
|
+
name: "Bob",
|
|
34
|
+
preferredUsername: "bob"
|
|
35
|
+
})
|
|
36
|
+
}).toJsonLd());
|
|
37
|
+
});
|
|
38
|
+
test("actorDehydrator()", async () => {
|
|
39
|
+
assertEquals(await actorDehydrator(new Follow({
|
|
40
|
+
id: new URL("http://example.com/activities/1"),
|
|
41
|
+
actor: new Person({
|
|
42
|
+
id: new URL("http://example.com/actors/1"),
|
|
43
|
+
name: "Alice",
|
|
44
|
+
preferredUsername: "alice"
|
|
45
|
+
}),
|
|
46
|
+
object: new Person({
|
|
47
|
+
id: new URL("http://example.com/actors/2"),
|
|
48
|
+
name: "Bob",
|
|
49
|
+
preferredUsername: "bob"
|
|
50
|
+
})
|
|
51
|
+
}), context).toJsonLd(), await new Follow({
|
|
52
|
+
id: new URL("http://example.com/activities/1"),
|
|
53
|
+
actor: new URL("http://example.com/actors/1"),
|
|
54
|
+
object: new Person({
|
|
55
|
+
id: new URL("http://example.com/actors/2"),
|
|
56
|
+
name: "Bob",
|
|
57
|
+
preferredUsername: "bob"
|
|
58
|
+
})
|
|
59
|
+
}).toJsonLd());
|
|
60
|
+
});
|
|
61
|
+
//#endregion
|
|
62
|
+
export {};
|