@fedify/fedify 2.1.28 → 2.1.30

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.
Files changed (62) hide show
  1. package/dist/{assert_rejects-B-qJtC9Z.mjs → assert_rejects-WyYSTDDX.mjs} +2 -20
  2. package/dist/{assert_throws-4NwKEy2q.mjs → assert_throws-D4DNWrux.mjs} +19 -1
  3. package/dist/{builder-CW1BrLbm.mjs → builder-CTpfuuVp.mjs} +3 -3
  4. package/dist/compat/transformers.test.mjs +1 -1
  5. package/dist/{deno-CJgU2mcr.mjs → deno-BATJ1hq6.mjs} +1 -1
  6. package/dist/{docloader-o3fCIlIa.mjs → docloader-OLWc7P2D.mjs} +6 -2
  7. package/dist/federation/builder.test.mjs +3 -3
  8. package/dist/federation/collection.test.mjs +1 -1
  9. package/dist/federation/handler.test.mjs +262 -9
  10. package/dist/federation/idempotency.test.mjs +3 -3
  11. package/dist/federation/inbox.test.mjs +25 -2
  12. package/dist/federation/keycache.test.mjs +18 -7
  13. package/dist/federation/kv.test.mjs +1 -1
  14. package/dist/federation/middleware.test.mjs +128 -10
  15. package/dist/federation/mod.cjs +1 -1
  16. package/dist/federation/mod.js +1 -1
  17. package/dist/federation/mq.test.mjs +2 -2
  18. package/dist/federation/negotiation.test.mjs +2 -2
  19. package/dist/federation/retry.test.mjs +1 -1
  20. package/dist/federation/router.test.mjs +2 -3
  21. package/dist/federation/send.test.mjs +7 -6
  22. package/dist/federation/temporal.test.mjs +3 -3
  23. package/dist/federation/webfinger.test.mjs +2 -2
  24. package/dist/{http-Dcj1ulAh.mjs → http-Bjd6I92u.mjs} +2 -2
  25. package/dist/{http-EEfKB8Qb.cjs → http-BoR1M3W7.cjs} +17 -3
  26. package/dist/{http-DtypHuuK.js → http-CK3efjgM.js} +17 -3
  27. package/dist/{inbox-CVYVJI0M.mjs → inbox-9MlBGgs9.mjs} +23 -10
  28. package/dist/{key-DRLvwDTh.mjs → key-ClQh9Qqh.mjs} +17 -3
  29. package/dist/{keycache-RFlZObU3.mjs → keycache-DahCaG_m.mjs} +1 -1
  30. package/dist/{kv-cache-BWVKAAmc.cjs → kv-cache-BxSx_Iyp.cjs} +5 -1
  31. package/dist/{kv-cache-CEJCaF4E.js → kv-cache-ImApO425.js} +5 -1
  32. package/dist/{ld-C5BZ98YK.mjs → ld-Crg0Xmwr.mjs} +2 -2
  33. package/dist/{middleware-CqQoREZ9.mjs → middleware-Bi5D6DBT.mjs} +1 -1
  34. package/dist/{middleware-wCgWm4Eh.js → middleware-C2AJFk8W.js} +96 -26
  35. package/dist/{middleware-SSrXiJIV.mjs → middleware-CE0b69gj.mjs} +83 -26
  36. package/dist/{middleware-Dw9sPiec.cjs → middleware-CmD3lpy4.cjs} +97 -27
  37. package/dist/{middleware-DZxmsbPB.cjs → middleware-jL9p9V9G.cjs} +1 -1
  38. package/dist/mod.cjs +4 -4
  39. package/dist/mod.js +4 -4
  40. package/dist/nodeinfo/client.test.mjs +1 -1
  41. package/dist/nodeinfo/handler.test.mjs +2 -2
  42. package/dist/nodeinfo/types.test.mjs +2 -2
  43. package/dist/otel/exporter.test.mjs +1 -1
  44. package/dist/{owner-cPOoPvmr.mjs → owner-BRoKojK1.mjs} +2 -2
  45. package/dist/{proof-DPU3poip.js → proof-7R4s10TJ.js} +1 -1
  46. package/dist/{proof-De1y2j-e.cjs → proof-CHXVlsH_.cjs} +1 -1
  47. package/dist/{proof-BTknCsN7.mjs → proof-DMIAezxz.mjs} +2 -2
  48. package/dist/{send-DDuHNgHz.mjs → send-BHIt_8ia.mjs} +2 -2
  49. package/dist/sig/http.test.mjs +6 -6
  50. package/dist/sig/key.test.mjs +199 -5
  51. package/dist/sig/ld.test.mjs +49 -4
  52. package/dist/sig/mod.cjs +2 -2
  53. package/dist/sig/mod.js +2 -2
  54. package/dist/sig/owner.test.mjs +48 -3
  55. package/dist/sig/proof.test.mjs +54 -3
  56. package/dist/{std__assert-BUOJXi-Z.mjs → std__assert-DflMZha5.mjs} +2 -2
  57. package/dist/{temporal-CxXY--ZL.mjs → temporal-DR0JahMu.mjs} +1 -1
  58. package/dist/utils/docloader.test.mjs +178 -39
  59. package/dist/utils/mod.cjs +1 -1
  60. package/dist/utils/mod.js +1 -1
  61. package/package.json +5 -5
  62. /package/dist/{assert_not_equals--wG9hV7u.mjs → assert_not_equals-BkxW5QJI.mjs} +0 -0
@@ -4,19 +4,19 @@ globalThis.addEventListener = () => {};
4
4
  import { t as esm_default } from "../esm-DVILvP5e.mjs";
5
5
  import { n as RouterError } from "../router-CrMLXoOr.mjs";
6
6
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
7
- import { n as assertStrictEquals } from "../std__assert-BUOJXi-Z.mjs";
8
- import { n as assertFalse, t as assertRejects } from "../assert_rejects-B-qJtC9Z.mjs";
7
+ import { n as assertStrictEquals } from "../std__assert-DflMZha5.mjs";
8
+ import { r as assertFalse, t as assertThrows } from "../assert_throws-D4DNWrux.mjs";
9
9
  import { n as assertInstanceOf, t as assert } from "../assert-BhQd8QHP.mjs";
10
- import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
11
- import { t as assertNotEquals } from "../assert_not_equals--wG9hV7u.mjs";
12
- import { l as verifyRequest, s as signRequest } from "../http-Dcj1ulAh.mjs";
10
+ import { t as assertNotEquals } from "../assert_not_equals-BkxW5QJI.mjs";
11
+ import { t as assertRejects } from "../assert_rejects-WyYSTDDX.mjs";
12
+ import { l as verifyRequest, s as signRequest } from "../http-Bjd6I92u.mjs";
13
13
  import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-CtZLJq76.mjs";
14
- import { t as getAuthenticatedDocumentLoader } from "../docloader-o3fCIlIa.mjs";
14
+ import { t as getAuthenticatedDocumentLoader } from "../docloader-OLWc7P2D.mjs";
15
15
  import { t as MemoryKvStore } from "../kv-HvthQAHr.mjs";
16
- import { a as compactJsonLd, f as signJsonLd, m as verifyJsonLd, s as detachSignature } from "../ld-C5BZ98YK.mjs";
17
- import { t as doesActorOwnKey } from "../owner-cPOoPvmr.mjs";
18
- import { n as signObject, r as verifyObject } from "../proof-BTknCsN7.mjs";
19
- import { a as createFederation, i as KvSpecDeterminer, n as FederationImpl, r as InboxContextImpl, t as ContextImpl } from "../middleware-SSrXiJIV.mjs";
16
+ import { a as compactJsonLd, f as signJsonLd, m as verifyJsonLd, s as detachSignature } from "../ld-Crg0Xmwr.mjs";
17
+ import { t as doesActorOwnKey } from "../owner-BRoKojK1.mjs";
18
+ import { n as signObject, r as verifyObject } from "../proof-DMIAezxz.mjs";
19
+ import { a as createFederation, i as KvSpecDeterminer, n as FederationImpl, r as InboxContextImpl, t as ContextImpl } from "../middleware-CE0b69gj.mjs";
20
20
  import { mockDocumentLoader, test } from "@fedify/fixture";
21
21
  import * as vocab from "@fedify/vocab";
22
22
  import { Create, Offer, Person, getTypeId, lookupObject } from "@fedify/vocab";
@@ -3900,6 +3900,124 @@ test("ContextImpl.routeActivity() marks queued signed activities as non-LDS", as
3900
3900
  assertEquals(inboxMessage.ldSignatureVerified, false);
3901
3901
  assertEquals(inboxMessage.normalizedActivity, void 0);
3902
3902
  });
3903
+ for (const queued of [false, true]) test(`ContextImpl.routeActivity() rejects a proof-signed cross-origin ID (queued: ${queued})`, async () => {
3904
+ const messages = [];
3905
+ const queue = {
3906
+ enqueue(message) {
3907
+ messages.push(message);
3908
+ return Promise.resolve();
3909
+ },
3910
+ async listen() {}
3911
+ };
3912
+ const federation = createFederation({
3913
+ kv: new MemoryKvStore(),
3914
+ documentLoaderFactory: () => mockDocumentLoader,
3915
+ contextLoaderFactory: () => mockDocumentLoader,
3916
+ queue: queued ? {
3917
+ inbox: queue,
3918
+ outbox: queue
3919
+ } : void 0,
3920
+ manuallyStartQueue: true
3921
+ });
3922
+ let listenerCalls = 0;
3923
+ federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(Create, () => {
3924
+ listenerCalls++;
3925
+ });
3926
+ const signed = await signObject(new Create({
3927
+ id: new URL("https://victim.example/activities/1"),
3928
+ actor: ed25519Multikey.controllerId
3929
+ }), ed25519PrivateKey, ed25519Multikey.id, {
3930
+ contextLoader: mockDocumentLoader,
3931
+ documentLoader: mockDocumentLoader
3932
+ });
3933
+ assertFalse(await federation.createContext(new URL("https://local.example/")).routeActivity(null, signed));
3934
+ assertEquals(listenerCalls, 0);
3935
+ assertEquals(messages, []);
3936
+ });
3937
+ test("ContextImpl.routeActivity() rejects a missing actor before routing", async () => {
3938
+ const federation = createFederation({
3939
+ kv: new MemoryKvStore(),
3940
+ documentLoaderFactory: () => mockDocumentLoader,
3941
+ contextLoaderFactory: () => mockDocumentLoader
3942
+ });
3943
+ let listenerCalls = 0;
3944
+ federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(Create, () => {
3945
+ listenerCalls++;
3946
+ });
3947
+ assertFalse(await federation.createContext(new URL("https://local.example/")).routeActivity(null, new Create({ id: new URL("https://remote.example/activities/1") })));
3948
+ assertEquals(listenerCalls, 0);
3949
+ });
3950
+ test("FederationImpl.processQueuedTask() rejects untrusted activity origins before KV access", async () => {
3951
+ class TrackingKvStore extends MemoryKvStore {
3952
+ reads = 0;
3953
+ writes = 0;
3954
+ get(key) {
3955
+ this.reads++;
3956
+ return super.get(key);
3957
+ }
3958
+ set(key, value, options) {
3959
+ this.writes++;
3960
+ return super.set(key, value, options);
3961
+ }
3962
+ }
3963
+ for (const activity of [{
3964
+ "@context": "https://www.w3.org/ns/activitystreams",
3965
+ id: "https://victim.example/activities/1",
3966
+ type: "Create",
3967
+ actor: "https://attacker.example/actor"
3968
+ }, {
3969
+ "@context": "https://www.w3.org/ns/activitystreams",
3970
+ id: "https://victim.example/activities/2",
3971
+ type: "Create"
3972
+ }]) {
3973
+ const kv = new TrackingKvStore();
3974
+ const federation = new FederationImpl({ kv });
3975
+ let listenerCalls = 0;
3976
+ federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(Create, () => {
3977
+ listenerCalls++;
3978
+ });
3979
+ await federation.processQueuedTask(void 0, {
3980
+ type: "inbox",
3981
+ id: crypto.randomUUID(),
3982
+ baseUrl: "https://local.example",
3983
+ activity,
3984
+ started: (/* @__PURE__ */ new Date()).toISOString(),
3985
+ attempt: 0,
3986
+ identifier: null,
3987
+ traceContext: {}
3988
+ });
3989
+ assertEquals(listenerCalls, 0);
3990
+ assertEquals(kv.reads, 0);
3991
+ assertEquals(kv.writes, 0);
3992
+ }
3993
+ const kv = new TrackingKvStore();
3994
+ const federation = new FederationImpl({
3995
+ kv,
3996
+ skipSignatureVerification: true
3997
+ });
3998
+ let listenerCalls = 0;
3999
+ federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(Create, () => {
4000
+ listenerCalls++;
4001
+ });
4002
+ await federation.processQueuedTask(void 0, {
4003
+ type: "inbox",
4004
+ id: crypto.randomUUID(),
4005
+ baseUrl: "https://local.example",
4006
+ activity: {
4007
+ "@context": "https://www.w3.org/ns/activitystreams",
4008
+ id: "https://victim.example/activities/opt-out",
4009
+ type: "Create",
4010
+ actor: "https://attacker.example/actor"
4011
+ },
4012
+ started: (/* @__PURE__ */ new Date()).toISOString(),
4013
+ attempt: 0,
4014
+ identifier: null,
4015
+ traceContext: {}
4016
+ });
4017
+ assertEquals(listenerCalls, 1);
4018
+ assertEquals(kv.reads, 1);
4019
+ assertEquals(kv.writes, 1);
4020
+ });
3903
4021
  test("ContextImpl.getCollectionUri()", () => {
3904
4022
  const federation = new FederationImpl({ kv: new MemoryKvStore() });
3905
4023
  const base = "https://example.com";
@@ -2,7 +2,7 @@ const { Temporal } = require("@js-temporal/polyfill");
2
2
  const { URLPattern } = require("urlpattern-polyfill");
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
4
  require("../chunk-DDcVe30Y.cjs");
5
- const require_middleware = require("../middleware-Dw9sPiec.cjs");
5
+ const require_middleware = require("../middleware-CmD3lpy4.cjs");
6
6
  let es_toolkit = require("es-toolkit");
7
7
  //#region src/federation/kv.ts
8
8
  /**
@@ -1,6 +1,6 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { a as createExponentialBackoffPolicy, c as buildCollectionSynchronizationHeader, d as Router, f as RouterError, i as SendActivityError, l as digest, o as respondWithObject, r as handleWebFinger, s as respondWithObjectIfAcceptable, t as createFederation, u as createFederationBuilder } from "../middleware-wCgWm4Eh.js";
3
+ import { a as createExponentialBackoffPolicy, c as buildCollectionSynchronizationHeader, d as Router, f as RouterError, i as SendActivityError, l as digest, o as respondWithObject, r as handleWebFinger, s as respondWithObjectIfAcceptable, t as createFederation, u as createFederationBuilder } from "../middleware-C2AJFk8W.js";
4
4
  import { isEqual } from "es-toolkit";
5
5
  //#region src/federation/kv.ts
6
6
  /**
@@ -2,8 +2,8 @@ import { Temporal } from "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
- import { r as assertGreaterOrEqual } from "../std__assert-BUOJXi-Z.mjs";
6
- import { n as assertFalse } from "../assert_rejects-B-qJtC9Z.mjs";
5
+ import { r as assertGreaterOrEqual } from "../std__assert-DflMZha5.mjs";
6
+ import { r as assertFalse } from "../assert_throws-D4DNWrux.mjs";
7
7
  import { t as assert } from "../assert-BhQd8QHP.mjs";
8
8
  import { test } from "@fedify/fixture";
9
9
  import { delay } from "es-toolkit";
@@ -1,8 +1,8 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import "../std__assert-BUOJXi-Z.mjs";
5
- import { n as assertFalse } from "../assert_rejects-B-qJtC9Z.mjs";
4
+ import "../std__assert-DflMZha5.mjs";
5
+ import { r as assertFalse } from "../assert_throws-D4DNWrux.mjs";
6
6
  import { t as assert } from "../assert-BhQd8QHP.mjs";
7
7
  import { t as acceptsJsonLd } from "../negotiation-BehA2uul.mjs";
8
8
  import { test } from "@fedify/fixture";
@@ -2,7 +2,7 @@ import { Temporal } from "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { l as AssertionError, t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
- import { t as assertNotEquals } from "../assert_not_equals--wG9hV7u.mjs";
5
+ import { t as assertNotEquals } from "../assert_not_equals-BkxW5QJI.mjs";
6
6
  import { t as createExponentialBackoffPolicy } from "../retry-B_E3V_Dx.mjs";
7
7
  import { test } from "@fedify/fixture";
8
8
  //#region src/federation/retry.test.ts
@@ -3,10 +3,9 @@ import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { n as RouterError, t as Router } from "../router-CrMLXoOr.mjs";
5
5
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
6
- import "../std__assert-BUOJXi-Z.mjs";
7
- import { n as assertFalse } from "../assert_rejects-B-qJtC9Z.mjs";
6
+ import "../std__assert-DflMZha5.mjs";
7
+ import { r as assertFalse, t as assertThrows } from "../assert_throws-D4DNWrux.mjs";
8
8
  import { t as assert } from "../assert-BhQd8QHP.mjs";
9
- import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
10
9
  import { test } from "@fedify/fixture";
11
10
  //#region src/federation/router.test.ts
12
11
  function setUp(options = {}) {
@@ -3,14 +3,15 @@ import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { t as esm_default } from "../esm-DVILvP5e.mjs";
5
5
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
6
- import "../std__assert-BUOJXi-Z.mjs";
7
- import { n as assertFalse, t as assertRejects } from "../assert_rejects-B-qJtC9Z.mjs";
6
+ import "../std__assert-DflMZha5.mjs";
7
+ import { r as assertFalse } from "../assert_throws-D4DNWrux.mjs";
8
8
  import { n as assertInstanceOf, t as assert } from "../assert-BhQd8QHP.mjs";
9
- import { t as assertNotEquals } from "../assert_not_equals--wG9hV7u.mjs";
10
- import { l as verifyRequest } from "../http-Dcj1ulAh.mjs";
9
+ import { t as assertNotEquals } from "../assert_not_equals-BkxW5QJI.mjs";
10
+ import { t as assertRejects } from "../assert_rejects-WyYSTDDX.mjs";
11
+ import { l as verifyRequest } from "../http-Bjd6I92u.mjs";
11
12
  import { i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-CtZLJq76.mjs";
12
- import { t as doesActorOwnKey } from "../owner-cPOoPvmr.mjs";
13
- import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "../send-DDuHNgHz.mjs";
13
+ import { t as doesActorOwnKey } from "../owner-BRoKojK1.mjs";
14
+ import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "../send-BHIt_8ia.mjs";
14
15
  import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
15
16
  import { Activity, Application, Endpoints, Group, Person, Service } from "@fedify/vocab";
16
17
  import { FetchError, UrlError } from "@fedify/vocab-runtime";
@@ -1,10 +1,10 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import "../std__assert-BUOJXi-Z.mjs";
5
- import { n as assertFalse } from "../assert_rejects-B-qJtC9Z.mjs";
4
+ import "../std__assert-DflMZha5.mjs";
5
+ import { r as assertFalse } from "../assert_throws-D4DNWrux.mjs";
6
6
  import { t as assert } from "../assert-BhQd8QHP.mjs";
7
- import { t as hasMalformedKnownTemporalLiteral } from "../temporal-CxXY--ZL.mjs";
7
+ import { t as hasMalformedKnownTemporalLiteral } from "../temporal-DR0JahMu.mjs";
8
8
  import { test } from "@fedify/fixture";
9
9
  //#region src/federation/temporal.test.ts
10
10
  test("hasMalformedKnownTemporalLiteral() detects expanded proof timestamps", async () => {
@@ -3,9 +3,9 @@ import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { n as createRequestContext } from "../context-Juj6bdHC.mjs";
5
5
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
6
- import "../std__assert-BUOJXi-Z.mjs";
6
+ import "../std__assert-DflMZha5.mjs";
7
7
  import { t as MemoryKvStore } from "../kv-HvthQAHr.mjs";
8
- import { a as createFederation, o as handleWebFinger } from "../middleware-SSrXiJIV.mjs";
8
+ import { a as createFederation, o as handleWebFinger } from "../middleware-CE0b69gj.mjs";
9
9
  import { test } from "@fedify/fixture";
10
10
  import { Image, Link, Person } from "@fedify/vocab";
11
11
  //#region src/federation/webfinger.test.ts
@@ -1,9 +1,9 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-CJgU2mcr.mjs";
4
+ import { n as version, t as name } from "./deno-BATJ1hq6.mjs";
5
5
  import { i as validateAcceptSignature, n as fulfillAcceptSignature, r as parseAcceptSignature } from "./accept-BavzedPB.mjs";
6
- import { i as fetchKeyDetailed, s as validateCryptoKey } from "./key-DRLvwDTh.mjs";
6
+ import { i as fetchKeyDetailed, s as validateCryptoKey } from "./key-ClQh9Qqh.mjs";
7
7
  import { CryptographicKey } from "@fedify/vocab";
8
8
  import { SpanStatusCode, trace } from "@opentelemetry/api";
9
9
  import { FetchError } from "@fedify/vocab-runtime";
@@ -11,7 +11,7 @@ let _opentelemetry_semantic_conventions = require("@opentelemetry/semantic-conve
11
11
  let byte_encodings_base64 = require("byte-encodings/base64");
12
12
  //#region deno.json
13
13
  var name = "@fedify/fedify";
14
- var version = "2.1.28";
14
+ var version = "2.1.30";
15
15
  //#endregion
16
16
  //#region src/sig/accept.ts
17
17
  /**
@@ -292,16 +292,23 @@ async function importJwk(jwk, type) {
292
292
  /**
293
293
  * Fetches the document that the given actor URI dereferences to, and returns
294
294
  * the actor only if the host that served the document is authoritative for
295
- * the id the document claims.
295
+ * the id the document claims, and that id is the actor that was asked for.
296
296
  *
297
297
  * Only the origin that serves an actor id can speak for it. Without that
298
298
  * rule any host could serve a document describing somebody else's actor—and
299
299
  * listing its own keys as that actor's.
300
300
  *
301
+ * The returned actor always has exactly the requested `actorId` as its `id`.
302
+ * A document loader follows redirects and alternate document links, so the
303
+ * document an actor id leads to may describe a different actor altogether,
304
+ * on the same origin or on another; accepting it would attribute that other
305
+ * actor's keys to the requested one. See GHSA-8863-8468-7hq7.
306
+ *
301
307
  * @param actorId The URI of the actor to fetch.
302
308
  * @param options Options for fetching the document.
303
309
  * @returns The actor, or `null` if the document cannot be fetched, is not an
304
- * actor, or belongs to another origin.
310
+ * actor, belongs to another origin, or describes an actor other
311
+ * than the requested one.
305
312
  * @internal
306
313
  */
307
314
  async function fetchActorDocument(actorId, options = {}) {
@@ -356,6 +363,13 @@ async function fetchActorDocumentInternal(actorId, options, propagateContextFetc
356
363
  });
357
364
  return null;
358
365
  }
366
+ if (object.id.href !== actorId.href) {
367
+ logger.debug("The document fetched for the actor {actorId} is the actor {documentActorId} instead; refusing to treat it as the requested actor's document.", {
368
+ actorId: actorId.href,
369
+ documentActorId: object.id.href
370
+ });
371
+ return null;
372
+ }
359
373
  return object;
360
374
  }
361
375
  /**
@@ -10,7 +10,7 @@ import { ATTR_HTTP_REQUEST_HEADER, ATTR_HTTP_REQUEST_METHOD, ATTR_URL_FULL } fro
10
10
  import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
11
11
  //#region deno.json
12
12
  var name = "@fedify/fedify";
13
- var version = "2.1.28";
13
+ var version = "2.1.30";
14
14
  //#endregion
15
15
  //#region src/sig/accept.ts
16
16
  /**
@@ -291,16 +291,23 @@ async function importJwk(jwk, type) {
291
291
  /**
292
292
  * Fetches the document that the given actor URI dereferences to, and returns
293
293
  * the actor only if the host that served the document is authoritative for
294
- * the id the document claims.
294
+ * the id the document claims, and that id is the actor that was asked for.
295
295
  *
296
296
  * Only the origin that serves an actor id can speak for it. Without that
297
297
  * rule any host could serve a document describing somebody else's actor—and
298
298
  * listing its own keys as that actor's.
299
299
  *
300
+ * The returned actor always has exactly the requested `actorId` as its `id`.
301
+ * A document loader follows redirects and alternate document links, so the
302
+ * document an actor id leads to may describe a different actor altogether,
303
+ * on the same origin or on another; accepting it would attribute that other
304
+ * actor's keys to the requested one. See GHSA-8863-8468-7hq7.
305
+ *
300
306
  * @param actorId The URI of the actor to fetch.
301
307
  * @param options Options for fetching the document.
302
308
  * @returns The actor, or `null` if the document cannot be fetched, is not an
303
- * actor, or belongs to another origin.
309
+ * actor, belongs to another origin, or describes an actor other
310
+ * than the requested one.
304
311
  * @internal
305
312
  */
306
313
  async function fetchActorDocument(actorId, options = {}) {
@@ -355,6 +362,13 @@ async function fetchActorDocumentInternal(actorId, options, propagateContextFetc
355
362
  });
356
363
  return null;
357
364
  }
365
+ if (object.id.href !== actorId.href) {
366
+ logger.debug("The document fetched for the actor {actorId} is the actor {documentActorId} instead; refusing to treat it as the requested actor's document.", {
367
+ actorId: actorId.href,
368
+ documentActorId: object.id.href
369
+ });
370
+ return null;
371
+ }
358
372
  return object;
359
373
  }
360
374
  /**
@@ -1,7 +1,7 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-CJgU2mcr.mjs";
4
+ import { n as version, t as name } from "./deno-BATJ1hq6.mjs";
5
5
  import { Activity, getTypeId } from "@fedify/vocab";
6
6
  import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
7
7
  import { getLogger } from "@logtape/logtape";
@@ -39,12 +39,33 @@ var InboxListenerSet = class InboxListenerSet {
39
39
  return this.dispatchWithClass(activity)?.listener ?? null;
40
40
  }
41
41
  };
42
+ /**
43
+ * Checks whether an activity's ID and all of its actor IDs have the same
44
+ * non-opaque origin. Activities without an ID have no origin to authenticate.
45
+ *
46
+ * The caller is responsible for rejecting a missing primary actor ID before
47
+ * relying on this check.
48
+ * @internal
49
+ */
50
+ function actorsHaveSameOrigin(activity) {
51
+ if (activity.id == null) return true;
52
+ const origin = activity.id.origin;
53
+ return origin !== "null" && activity.actorIds.every((actor) => actor.origin === origin);
54
+ }
42
55
  async function routeActivity({ context: ctx, json, originalJson, normalizedActivity, ldSignatureVerified, activity, recipient, inboxListeners, inboxContextFactory, listenerInboxContextFactory, inboxErrorHandler, kv, kvPrefixes, queue, span, tracerProvider, idempotencyStrategy }) {
43
56
  const logger = getLogger([
44
57
  "fedify",
45
58
  "federation",
46
59
  "inbox"
47
60
  ]);
61
+ if (activity.actorId == null) {
62
+ logger.error("Missing actor.", { activity: json });
63
+ span.setStatus({
64
+ code: SpanStatusCode.ERROR,
65
+ message: "Missing actor."
66
+ });
67
+ return "missingActor";
68
+ }
48
69
  let cacheKey = null;
49
70
  if (activity.id != null) {
50
71
  const inboxContext = inboxContextFactory(recipient, json, activity.id?.href, getTypeId(activity).href);
@@ -79,14 +100,6 @@ async function routeActivity({ context: ctx, json, originalJson, normalizedActiv
79
100
  return "alreadyProcessed";
80
101
  }
81
102
  }
82
- if (activity.actorId == null) {
83
- logger.error("Missing actor.", { activity: json });
84
- span.setStatus({
85
- code: SpanStatusCode.ERROR,
86
- message: "Missing actor."
87
- });
88
- return "missingActor";
89
- }
90
103
  span.setAttribute("activitypub.actor.id", activity.actorId.href);
91
104
  if (queue != null) {
92
105
  const carrier = {};
@@ -179,4 +192,4 @@ async function routeActivity({ context: ctx, json, originalJson, normalizedActiv
179
192
  });
180
193
  }
181
194
  //#endregion
182
- export { routeActivity as n, InboxListenerSet as t };
195
+ export { actorsHaveSameOrigin as n, routeActivity as r, InboxListenerSet as t };
@@ -1,7 +1,7 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-CJgU2mcr.mjs";
4
+ import { n as version, t as name } from "./deno-BATJ1hq6.mjs";
5
5
  import { CryptographicKey, Object as Object$1, isActor } from "@fedify/vocab";
6
6
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
7
7
  import { FetchError, UrlError, getDocumentLoader } from "@fedify/vocab-runtime";
@@ -146,16 +146,23 @@ async function importJwk(jwk, type) {
146
146
  /**
147
147
  * Fetches the document that the given actor URI dereferences to, and returns
148
148
  * the actor only if the host that served the document is authoritative for
149
- * the id the document claims.
149
+ * the id the document claims, and that id is the actor that was asked for.
150
150
  *
151
151
  * Only the origin that serves an actor id can speak for it. Without that
152
152
  * rule any host could serve a document describing somebody else's actor—and
153
153
  * listing its own keys as that actor's.
154
154
  *
155
+ * The returned actor always has exactly the requested `actorId` as its `id`.
156
+ * A document loader follows redirects and alternate document links, so the
157
+ * document an actor id leads to may describe a different actor altogether,
158
+ * on the same origin or on another; accepting it would attribute that other
159
+ * actor's keys to the requested one. See GHSA-8863-8468-7hq7.
160
+ *
155
161
  * @param actorId The URI of the actor to fetch.
156
162
  * @param options Options for fetching the document.
157
163
  * @returns The actor, or `null` if the document cannot be fetched, is not an
158
- * actor, or belongs to another origin.
164
+ * actor, belongs to another origin, or describes an actor other
165
+ * than the requested one.
159
166
  * @internal
160
167
  */
161
168
  async function fetchActorDocument(actorId, options = {}) {
@@ -210,6 +217,13 @@ async function fetchActorDocumentInternal(actorId, options, propagateContextFetc
210
217
  });
211
218
  return null;
212
219
  }
220
+ if (object.id.href !== actorId.href) {
221
+ logger.debug("The document fetched for the actor {actorId} is the actor {documentActorId} instead; refusing to treat it as the requested actor's document.", {
222
+ actorId: actorId.href,
223
+ documentActorId: object.id.href
224
+ });
225
+ return null;
226
+ }
213
227
  return object;
214
228
  }
215
229
  /**
@@ -4,7 +4,7 @@ globalThis.addEventListener = () => {};
4
4
  import { CryptographicKey, Multikey } from "@fedify/vocab";
5
5
  import { FetchError, UrlError } from "@fedify/vocab-runtime";
6
6
  //#region src/federation/keycache.ts
7
- const KEY_CACHE_GENERATION = "2";
7
+ const KEY_CACHE_GENERATION = "3";
8
8
  var KvKeyCache = class {
9
9
  kv;
10
10
  prefix;
@@ -1,7 +1,7 @@
1
1
  const { Temporal } = require("@js-temporal/polyfill");
2
2
  const { URLPattern } = require("urlpattern-polyfill");
3
3
  require("./chunk-DDcVe30Y.cjs");
4
- const require_http = require("./http-EEfKB8Qb.cjs");
4
+ const require_http = require("./http-BoR1M3W7.cjs");
5
5
  let _logtape_logtape = require("@logtape/logtape");
6
6
  let es_toolkit = require("es-toolkit");
7
7
  let _fedify_vocab_runtime = require("@fedify/vocab-runtime");
@@ -57,6 +57,10 @@ function getAuthenticatedDocumentLoader(identity, { allowPrivateAddress, userAge
57
57
  });
58
58
  }
59
59
  async function validateUrl(url) {
60
+ const parsedUrl = new URL(url);
61
+ const protocol = parsedUrl.protocol;
62
+ if (protocol !== "http:" && protocol !== "https:") throw new _fedify_vocab_runtime.UrlError(`Unsupported protocol: ${protocol}`);
63
+ if (parsedUrl.username !== "" || parsedUrl.password !== "") throw new _fedify_vocab_runtime.UrlError("URLs with credentials are not allowed");
60
64
  if (!allowPrivateAddress) try {
61
65
  await (0, _fedify_vocab_runtime.validatePublicUrl)(url);
62
66
  } catch (error) {
@@ -1,6 +1,6 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { f as validateCryptoKey, t as doubleKnock } from "./http-DtypHuuK.js";
3
+ import { f as validateCryptoKey, t as doubleKnock } from "./http-CK3efjgM.js";
4
4
  import { getLogger } from "@logtape/logtape";
5
5
  import { curry } from "es-toolkit";
6
6
  import { FetchError, UrlError, createActivityPubRequest, getRemoteDocument, logRequest, preloadedContexts, validatePublicUrl } from "@fedify/vocab-runtime";
@@ -56,6 +56,10 @@ function getAuthenticatedDocumentLoader(identity, { allowPrivateAddress, userAge
56
56
  });
57
57
  }
58
58
  async function validateUrl(url) {
59
+ const parsedUrl = new URL(url);
60
+ const protocol = parsedUrl.protocol;
61
+ if (protocol !== "http:" && protocol !== "https:") throw new UrlError(`Unsupported protocol: ${protocol}`);
62
+ if (parsedUrl.username !== "" || parsedUrl.password !== "") throw new UrlError("URLs with credentials are not allowed");
59
63
  if (!allowPrivateAddress) try {
60
64
  await validatePublicUrl(url);
61
65
  } catch (error) {
@@ -1,8 +1,8 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-CJgU2mcr.mjs";
5
- import { r as fetchKey, s as validateCryptoKey } from "./key-DRLvwDTh.mjs";
4
+ import { n as version, t as name } from "./deno-BATJ1hq6.mjs";
5
+ import { r as fetchKey, s as validateCryptoKey } from "./key-ClQh9Qqh.mjs";
6
6
  import { Activity, CryptographicKey, Object as Object$1, getTypeId } from "@fedify/vocab";
7
7
  import { SpanStatusCode, trace } from "@opentelemetry/api";
8
8
  import { getDocumentLoader } from "@fedify/vocab-runtime";
@@ -1,5 +1,5 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as FederationImpl } from "./middleware-SSrXiJIV.mjs";
4
+ import { n as FederationImpl } from "./middleware-CE0b69gj.mjs";
5
5
  export { FederationImpl };