@fedify/fedify 1.10.10 → 1.10.12

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 (103) hide show
  1. package/dist/{actor-q2gTvEOg.js → actor-BojFQubG.js} +187 -187
  2. package/dist/{actor-DZtfiGD5.mjs → actor-C9uF9rDY.mjs} +1 -1
  3. package/dist/{actor-yCME0Muf.cjs → actor-U7L0GWq5.cjs} +187 -187
  4. package/dist/{authdocloader-Dxs4mL_P.mjs → authdocloader-Bzj36aN0.mjs} +3 -3
  5. package/dist/{authdocloader-CjcVKv5l.js → authdocloader-CHdPmjrz.js} +3 -3
  6. package/dist/{authdocloader-C9ucnURr.cjs → authdocloader-hnKNsDdH.cjs} +3 -3
  7. package/dist/{builder-DBBCeuJN.mjs → builder-Bdf32cY2.mjs} +4 -4
  8. package/dist/{client-DfSKNItx.mjs → client-DACpcUfJ.mjs} +63 -5
  9. package/dist/compat/mod.cjs +1 -1
  10. package/dist/compat/transformers.test.mjs +3 -3
  11. package/dist/{docloader-D8qb26Gj.js → docloader-C7Hk8BRD.js} +121 -13
  12. package/dist/{docloader-DR98w4wL.cjs → docloader-VJ0pkUIi.cjs} +121 -13
  13. package/dist/{esm-onODA711.mjs → esm-D-9VAGKG.mjs} +1 -1
  14. package/dist/federation/builder.test.mjs +3 -3
  15. package/dist/federation/collection.test.mjs +1 -1
  16. package/dist/federation/handler.test.mjs +7 -7
  17. package/dist/federation/idempotency.test.mjs +5 -5
  18. package/dist/federation/inbox.test.mjs +3 -3
  19. package/dist/federation/keycache.test.mjs +3 -3
  20. package/dist/federation/kv.test.mjs +1 -1
  21. package/dist/federation/middleware.test.mjs +11 -11
  22. package/dist/federation/mod.cjs +2 -2
  23. package/dist/federation/mod.js +1 -1
  24. package/dist/federation/mq.test.mjs +1 -1
  25. package/dist/federation/retry.test.mjs +1 -1
  26. package/dist/federation/router.test.mjs +2 -2
  27. package/dist/federation/send.test.mjs +7 -7
  28. package/dist/federation/temporal.test.mjs +2 -2
  29. package/dist/{http-DyCX-dN3.mjs → http-B7ppDy7F.mjs} +2 -2
  30. package/dist/{http-mdiWJYia.cjs → http-BvdC0WpM.cjs} +3 -3
  31. package/dist/{http-D6Qz3p20.js → http-DOLmvrYy.js} +3 -3
  32. package/dist/{inbox-BZN50kyQ.mjs → inbox-BtX2yRj2.mjs} +1 -1
  33. package/dist/{key-TRp8WTUL.js → key-BHH7odYU.js} +2 -2
  34. package/dist/{key-DXUAJBZu.mjs → key-CHBIITWw.mjs} +1 -1
  35. package/dist/{key-DRfL8gil.cjs → key-CiP-0NDL.cjs} +2 -2
  36. package/dist/{key-CSH0Pfat.mjs → key-CvS3OKm_.mjs} +2 -2
  37. package/dist/{key-DPzMtgeE.cjs → key-LHWWSWcX.cjs} +1 -1
  38. package/dist/{keycache-DETDxpbh.mjs → keycache-Bgm-3VZ1.mjs} +1 -1
  39. package/dist/{keys-8FIoKqmB.mjs → keys-BkXWqCAE.mjs} +1 -1
  40. package/dist/{ld-BaJmhpEa.mjs → ld-BJtgkkBN.mjs} +2 -2
  41. package/dist/{lookup-C6wM-gq1.js → lookup-BRKVwJc1.js} +1 -1
  42. package/dist/{lookup-CX2yfN-X.mjs → lookup-D1kdVIs5.mjs} +1 -1
  43. package/dist/{lookup-B7TLaXFf.cjs → lookup-PjDK1BMX.cjs} +1 -1
  44. package/dist/{middleware-BXc5M6YG.js → middleware-BPwhaRyh.js} +8 -8
  45. package/dist/{middleware-BJ7otoEC.mjs → middleware-BmYq8xCJ.mjs} +1 -1
  46. package/dist/{middleware-BQ6evC7E.mjs → middleware-C26Vj2UM.mjs} +15 -15
  47. package/dist/{middleware-cNynSnF6.cjs → middleware-DhHhj1FR.cjs} +1 -1
  48. package/dist/{middleware-DpVqFb2x.cjs → middleware-Fq0SOUBc.cjs} +10 -10
  49. package/dist/mod.cjs +10 -10
  50. package/dist/mod.js +9 -9
  51. package/dist/nodeinfo/client.test.mjs +63 -3
  52. package/dist/nodeinfo/handler.test.mjs +2 -2
  53. package/dist/nodeinfo/mod.cjs +1 -1
  54. package/dist/nodeinfo/mod.js +1 -1
  55. package/dist/nodeinfo/semver.test.mjs +1 -1
  56. package/dist/nodeinfo/types.test.mjs +1 -1
  57. package/dist/otel/exporter.test.mjs +1 -1
  58. package/dist/otel/mod.cjs +1 -1
  59. package/dist/{owner-CLGVwm9P.mjs → owner-LW_PkCQl.mjs} +3 -3
  60. package/dist/{proof-DxQL08gJ.js → proof-AdZX_HYz.js} +3 -3
  61. package/dist/{proof-CAOvY-AP.mjs → proof-B5uyl0iN.mjs} +2 -2
  62. package/dist/{proof-BVB37JmB.cjs → proof-BuZbhU4B.cjs} +3 -3
  63. package/dist/runtime/authdocloader.test.mjs +6 -6
  64. package/dist/runtime/docloader.test.mjs +3 -3
  65. package/dist/runtime/key.test.mjs +3 -3
  66. package/dist/runtime/langstr.test.mjs +2 -2
  67. package/dist/runtime/link.test.mjs +2 -2
  68. package/dist/runtime/mod.cjs +3 -3
  69. package/dist/runtime/mod.js +3 -3
  70. package/dist/runtime/multibase/multibase.test.mjs +2 -2
  71. package/dist/runtime/url.test.mjs +53 -2
  72. package/dist/{send-BFClgq8T.mjs → send-bU0ThH5V.mjs} +2 -2
  73. package/dist/sig/http.test.mjs +6 -6
  74. package/dist/sig/key.test.mjs +4 -4
  75. package/dist/sig/ld.test.mjs +5 -5
  76. package/dist/sig/mod.cjs +3 -3
  77. package/dist/sig/mod.js +3 -3
  78. package/dist/sig/owner.test.mjs +5 -5
  79. package/dist/sig/proof.test.mjs +4 -4
  80. package/dist/{temporal-lmewfA7Y.mjs → temporal-DURtbYTr.mjs} +1 -1
  81. package/dist/testing/docloader.test.mjs +1 -1
  82. package/dist/testing/mod.mjs +1 -1
  83. package/dist/{testing-B9FmxxlI.mjs → testing-BQeTO4ss.mjs} +2 -2
  84. package/dist/{transformers-KRl8YJCO.cjs → transformers-C1GEQMFT.cjs} +1 -1
  85. package/dist/{types-B0aIcMDF.js → types--FAljwt0.js} +63 -5
  86. package/dist/{types-DPWiFqle.cjs → types-DU73__Ms.cjs} +63 -5
  87. package/dist/vocab/actor.test.mjs +4 -4
  88. package/dist/vocab/cjs.test.mjs +1 -1
  89. package/dist/vocab/lookup.test.mjs +4 -4
  90. package/dist/vocab/mod.cjs +3 -3
  91. package/dist/vocab/mod.js +3 -3
  92. package/dist/vocab/type.test.mjs +2 -2
  93. package/dist/vocab/vocab.test.mjs +3 -3
  94. package/dist/{vocab-DP9A9TjH.mjs → vocab-C5EUmVTj.mjs} +306 -198
  95. package/dist/webfinger/handler.test.mjs +3 -3
  96. package/dist/webfinger/lookup.test.mjs +3 -3
  97. package/dist/webfinger/mod.cjs +1 -1
  98. package/dist/webfinger/mod.js +1 -1
  99. package/dist/x/cfworkers.cjs +1 -1
  100. package/dist/x/cfworkers.test.mjs +1 -1
  101. package/dist/x/hono.cjs +1 -1
  102. package/dist/x/sveltekit.cjs +1 -1
  103. package/package.json +1 -1
@@ -1,9 +1,9 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { $ as UrlError, K as createRequest, Q as logRequest, Y as getRemoteDocument, rt as validatePublicUrl } from "./vocab-DP9A9TjH.mjs";
5
- import { a as validateCryptoKey } from "./key-CSH0Pfat.mjs";
6
- import { n as doubleKnock } from "./http-DyCX-dN3.mjs";
4
+ import { $ as UrlError, K as createRequest, Q as logRequest, Y as getRemoteDocument, rt as validatePublicUrl } from "./vocab-C5EUmVTj.mjs";
5
+ import { a as validateCryptoKey } from "./key-CvS3OKm_.mjs";
6
+ import { n as doubleKnock } from "./http-B7ppDy7F.mjs";
7
7
  import { getLogger } from "@logtape/logtape";
8
8
  //#region src/runtime/authdocloader.ts
9
9
  const logger = getLogger([
@@ -1,8 +1,8 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
- import { a as getRemoteDocument, c as logRequest, l as UrlError, n as createRequest, u as validatePublicUrl } from "./docloader-D8qb26Gj.js";
4
- import { o as validateCryptoKey } from "./key-TRp8WTUL.js";
5
- import { t as doubleKnock } from "./http-D6Qz3p20.js";
3
+ import { a as getRemoteDocument, c as logRequest, l as UrlError, n as createRequest, u as validatePublicUrl } from "./docloader-C7Hk8BRD.js";
4
+ import { o as validateCryptoKey } from "./key-BHH7odYU.js";
5
+ import { t as doubleKnock } from "./http-DOLmvrYy.js";
6
6
  import { getLogger } from "@logtape/logtape";
7
7
  //#region src/runtime/authdocloader.ts
8
8
  const logger = getLogger([
@@ -1,8 +1,8 @@
1
1
  const { Temporal } = require("@js-temporal/polyfill");
2
2
  const { URLPattern } = require("urlpattern-polyfill");
3
- const require_docloader = require("./docloader-DR98w4wL.cjs");
4
- const require_key = require("./key-DRfL8gil.cjs");
5
- const require_http = require("./http-mdiWJYia.cjs");
3
+ const require_docloader = require("./docloader-VJ0pkUIi.cjs");
4
+ const require_key = require("./key-CiP-0NDL.cjs");
5
+ const require_http = require("./http-BvdC0WpM.cjs");
6
6
  //#region src/runtime/authdocloader.ts
7
7
  const logger = (0, require("@logtape/logtape").getLogger)([
8
8
  "fedify",
@@ -1,9 +1,9 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { U as getTypeId, ot as name, st as version } from "./vocab-DP9A9TjH.mjs";
5
- import { i as RouterError, r as Router } from "./lookup-CX2yfN-X.mjs";
6
- import { t as InboxListenerSet } from "./inbox-BZN50kyQ.mjs";
4
+ import { U as getTypeId, ot as name, st as version } from "./vocab-C5EUmVTj.mjs";
5
+ import { i as RouterError, r as Router } from "./lookup-D1kdVIs5.mjs";
6
+ import { t as InboxListenerSet } from "./inbox-BtX2yRj2.mjs";
7
7
  import { getLogger } from "@logtape/logtape";
8
8
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
9
9
  //#region src/federation/builder.ts
@@ -40,7 +40,7 @@ var FederationBuilderImpl = class {
40
40
  this.collectionTypeIds = {};
41
41
  }
42
42
  async build(options) {
43
- const { FederationImpl } = await import("./middleware-BJ7otoEC.mjs");
43
+ const { FederationImpl } = await import("./middleware-BmYq8xCJ.mjs");
44
44
  const f = new FederationImpl(options);
45
45
  const trailingSlashInsensitiveValue = f.router.trailingSlashInsensitive;
46
46
  f.router = this.router.clone();
@@ -1,7 +1,7 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { X as getUserAgent } from "./vocab-DP9A9TjH.mjs";
4
+ import { $ as UrlError, X as getUserAgent, rt as validatePublicUrl } from "./vocab-C5EUmVTj.mjs";
5
5
  import { n as parseSemVer } from "./semver-CgD82xxg.mjs";
6
6
  import { getLogger } from "@logtape/logtape";
7
7
  //#region src/nodeinfo/client.ts
@@ -10,15 +10,72 @@ const logger = getLogger([
10
10
  "nodeinfo",
11
11
  "client"
12
12
  ]);
13
+ const DEFAULT_MAX_REDIRECTION = 5;
14
+ /**
15
+ * Fetches a URL while guarding against SSRF. Before every request—including
16
+ * each redirect hop—the destination is validated with
17
+ * {@link validatePublicUrl}, so that loopback, link-local, and private
18
+ * addresses, as well as non-HTTP(S) schemes such as `data:`, are rejected.
19
+ * Redirects are followed manually with a cap, so that a public URL cannot
20
+ * bounce the request to an internal address.
21
+ * @param url The URL to fetch.
22
+ * @param headers The request headers.
23
+ * @returns The final response, or `null` if the URL is disallowed or there
24
+ * are too many redirects.
25
+ */
26
+ async function fetchPublicUrl(url, headers) {
27
+ let current = url instanceof URL ? url : new URL(url);
28
+ let redirected = 0;
29
+ while (true) {
30
+ try {
31
+ await validatePublicUrl(current.href);
32
+ } catch (e) {
33
+ if (e instanceof UrlError) {
34
+ logger.error("Refused to fetch a private or invalid URL {url}: {error}", {
35
+ url: current.href,
36
+ error: e
37
+ });
38
+ return null;
39
+ }
40
+ throw e;
41
+ }
42
+ const response = await fetch(current, {
43
+ headers,
44
+ redirect: "manual"
45
+ });
46
+ if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
47
+ redirected++;
48
+ if (redirected >= DEFAULT_MAX_REDIRECTION) {
49
+ logger.error("Too many redirections ({redirections}) while fetching {url}.", {
50
+ redirections: redirected,
51
+ url: current.href
52
+ });
53
+ return null;
54
+ }
55
+ const next = new URL(response.headers.get("Location"), response.url == null || response.url === "" ? current : response.url);
56
+ if (next.protocol !== current.protocol) {
57
+ logger.error("Refused a redirect to a different protocol ({protocol} to {redirectedProtocol}) while fetching NodeInfo.", {
58
+ protocol: current.protocol,
59
+ redirectedProtocol: next.protocol
60
+ });
61
+ return null;
62
+ }
63
+ current = next;
64
+ continue;
65
+ }
66
+ return response;
67
+ }
68
+ }
13
69
  async function getNodeInfo(url, options = {}) {
14
70
  try {
15
71
  let nodeInfoUrl = url;
16
72
  if (!options.direct) {
17
73
  const wellKnownUrl = new URL("/.well-known/nodeinfo", url);
18
- const wellKnownResponse = await fetch(wellKnownUrl, { headers: {
74
+ const wellKnownResponse = await fetchPublicUrl(wellKnownUrl, {
19
75
  Accept: "application/json",
20
76
  "User-Agent": typeof options.userAgent === "string" ? options.userAgent : getUserAgent(options.userAgent)
21
- } });
77
+ });
78
+ if (wellKnownResponse == null) return void 0;
22
79
  if (!wellKnownResponse.ok) {
23
80
  logger.error("Failed to fetch {url}: {status} {statusText}", {
24
81
  url: wellKnownUrl.href,
@@ -38,10 +95,11 @@ async function getNodeInfo(url, options = {}) {
38
95
  }
39
96
  nodeInfoUrl = link.href;
40
97
  }
41
- const response = await fetch(nodeInfoUrl, { headers: {
98
+ const response = await fetchPublicUrl(nodeInfoUrl, {
42
99
  Accept: "application/json",
43
100
  "User-Agent": typeof options.userAgent === "string" ? options.userAgent : getUserAgent(options.userAgent)
44
- } });
101
+ });
102
+ if (response == null) return void 0;
45
103
  if (!response.ok) {
46
104
  logger.error("Failed to fetch NodeInfo document from {url}: {status} {statusText}", {
47
105
  url: nodeInfoUrl.toString(),
@@ -1,7 +1,7 @@
1
1
  const { Temporal } = require("@js-temporal/polyfill");
2
2
  const { URLPattern } = require("urlpattern-polyfill");
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
- const require_transformers = require("../transformers-KRl8YJCO.cjs");
4
+ const require_transformers = require("../transformers-C1GEQMFT.cjs");
5
5
  exports.actorDehydrator = require_transformers.actorDehydrator;
6
6
  exports.autoIdAssigner = require_transformers.autoIdAssigner;
7
7
  exports.getDefaultActivityTransformers = require_transformers.getDefaultActivityTransformers;
@@ -1,13 +1,13 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { C as Person, u as Follow } from "../vocab-DP9A9TjH.mjs";
5
- import { t as test } from "../testing-B9FmxxlI.mjs";
4
+ import { C as Person, u as Follow } from "../vocab-C5EUmVTj.mjs";
5
+ import { t as test } from "../testing-BQeTO4ss.mjs";
6
6
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
7
7
  import { t as assertInstanceOf } from "../assert_instance_of-C4Ri6VuN.mjs";
8
8
  import { t as assert } from "../assert-DikXweDx.mjs";
9
9
  import { t as MemoryKvStore } from "../kv-OuT2IU64.mjs";
10
- import { _ as actorDehydrator, n as FederationImpl, v as autoIdAssigner } from "../middleware-BQ6evC7E.mjs";
10
+ import { _ as actorDehydrator, n as FederationImpl, v as autoIdAssigner } from "../middleware-C26Vj2UM.mjs";
11
11
  //#region src/compat/transformers.test.ts
12
12
  const context = new FederationImpl({ kv: new MemoryKvStore() }).createContext(new URL("http://example.com/"));
13
13
  test("autoIdAssigner", async () => {
@@ -7,7 +7,7 @@ import { lookup } from "node:dns/promises";
7
7
  import { isIP } from "node:net";
8
8
  //#region deno.json
9
9
  var name = "@fedify/fedify";
10
- var version = "1.10.10";
10
+ var version = "1.10.12";
11
11
  //#endregion
12
12
  //#region src/runtime/contexts.ts
13
13
  const preloadedContexts = {
@@ -4453,29 +4453,137 @@ function validatePublicIpAddress(address, family) {
4453
4453
  throw new UrlError(`Invalid or private address: ${address}`);
4454
4454
  }
4455
4455
  function isValidPublicIPv4Address(address) {
4456
- const parts = address.split(".");
4457
- const first = parseInt(parts[0]);
4458
- if (first === 0 || first === 10 || first === 127) return false;
4459
- const second = parseInt(parts[1]);
4460
- if (first === 169 && second === 254) return false;
4461
- if (first === 172 && second >= 16 && second <= 31) return false;
4462
- if (first === 192 && second === 168) return false;
4463
- return true;
4456
+ const parts = parseIPv4Address(address);
4457
+ if (parts == null) return false;
4458
+ const value = ipv4PartsToNumber(parts);
4459
+ return !nonPublicIPv4Prefixes.some(({ base, prefix }) => matchesIPv4Prefix(value, base, prefix));
4464
4460
  }
4465
4461
  function isValidPublicIPv6Address(address) {
4466
- address = expandIPv6Address(address);
4467
- if (address.at(4) !== ":") return false;
4468
- const firstWord = parseInt(address.substring(0, 4), 16);
4469
- return !(firstWord >= 64512 && firstWord <= 65023 || firstWord >= 65152 && firstWord <= 65215 || firstWord === 0 || firstWord >= 65280);
4462
+ const words = parseIPv6Address(address);
4463
+ if (words == null) return false;
4464
+ if (nonPublicIPv6Prefixes.some(({ words: prefixWords, prefix }) => matchesIPv6Prefix(words, prefixWords, prefix))) return false;
4465
+ for (const { extractIPv4, prefix, words: prefixWords } of ipv6WithIPv4Prefixes) {
4466
+ if (!matchesIPv6Prefix(words, prefixWords, prefix)) continue;
4467
+ const ipv4Address = extractIPv4(words);
4468
+ if (ipv4Address != null && !isValidPublicIPv4Address(ipv4Address)) return false;
4469
+ }
4470
+ return true;
4470
4471
  }
4471
4472
  function expandIPv6Address(address) {
4472
4473
  address = address.toLowerCase();
4474
+ const ipv4Delimiter = address.lastIndexOf(":");
4475
+ if (address.includes(".") && ipv4Delimiter >= 0) {
4476
+ const ipv4Parts = parseIPv4Address(address.substring(ipv4Delimiter + 1));
4477
+ if (ipv4Parts == null) return address;
4478
+ const high = (ipv4Parts[0] << 8) + ipv4Parts[1];
4479
+ const low = (ipv4Parts[2] << 8) + ipv4Parts[3];
4480
+ address = address.substring(0, ipv4Delimiter + 1) + high.toString(16) + ":" + low.toString(16);
4481
+ }
4473
4482
  if (address === "::") return "0000:0000:0000:0000:0000:0000:0000:0000";
4474
4483
  if (address.startsWith("::")) address = "0000" + address;
4475
4484
  if (address.endsWith("::")) address = address + "0000";
4476
4485
  address = address.replace("::", ":0000".repeat(8 - (address.match(/:/g) || []).length) + ":");
4477
4486
  return address.split(":").map((part) => part.padStart(4, "0")).join(":");
4478
4487
  }
4488
+ const nonPublicIPv4Prefixes = [
4489
+ ipv4Prefix("0.0.0.0/8", "RFC 6890"),
4490
+ ipv4Prefix("10.0.0.0/8", "RFC 1918"),
4491
+ ipv4Prefix("100.64.0.0/10", "RFC 6598"),
4492
+ ipv4Prefix("127.0.0.0/8", "RFC 1122"),
4493
+ ipv4Prefix("169.254.0.0/16", "RFC 3927"),
4494
+ ipv4Prefix("172.16.0.0/12", "RFC 1918"),
4495
+ ipv4Prefix("192.0.0.0/24", "RFC 6890"),
4496
+ ipv4Prefix("192.0.2.0/24", "RFC 5737"),
4497
+ ipv4Prefix("192.88.99.0/24", "RFC 7526"),
4498
+ ipv4Prefix("192.168.0.0/16", "RFC 1918"),
4499
+ ipv4Prefix("198.18.0.0/15", "RFC 2544"),
4500
+ ipv4Prefix("198.51.100.0/24", "RFC 5737"),
4501
+ ipv4Prefix("203.0.113.0/24", "RFC 5737"),
4502
+ ipv4Prefix("224.0.0.0/4", "RFC 5771"),
4503
+ ipv4Prefix("240.0.0.0/4", "RFC 1112")
4504
+ ];
4505
+ const nonPublicIPv6Prefixes = [
4506
+ ipv6Prefix("::/16", "RFC 4291"),
4507
+ ipv6Prefix("2001::/32", "RFC 4380"),
4508
+ ipv6Prefix("2002::/16", "RFC 3056"),
4509
+ ipv6Prefix("64:ff9b:1::/48", "RFC 8215"),
4510
+ ipv6Prefix("fc00::/7", "RFC 4193"),
4511
+ ipv6Prefix("fe80::/10", "RFC 4291"),
4512
+ ipv6Prefix("ff00::/8", "RFC 4291")
4513
+ ];
4514
+ const ipv6WithIPv4Prefixes = [{
4515
+ ...ipv6Prefix("64:ff9b::/96", "RFC 6052"),
4516
+ extractIPv4: (words) => ipv4FromWords(words[6], words[7])
4517
+ }];
4518
+ function ipv4Prefix(cidr, rfc) {
4519
+ const [address, prefixText] = cidr.split("/");
4520
+ const prefix = parseInt(prefixText, 10);
4521
+ const parts = parseIPv4Address(address);
4522
+ if (parts == null || !Number.isInteger(prefix) || prefix < 0 || prefix > 32) throw new Error(`Invalid IPv4 prefix: ${cidr}`);
4523
+ return {
4524
+ cidr,
4525
+ base: ipv4PartsToNumber(parts),
4526
+ prefix,
4527
+ rfc
4528
+ };
4529
+ }
4530
+ function ipv6Prefix(cidr, rfc) {
4531
+ const [address, prefixText] = cidr.split("/");
4532
+ const prefix = parseInt(prefixText, 10);
4533
+ const words = parseIPv6Address(address);
4534
+ if (words == null || !Number.isInteger(prefix) || prefix < 0 || prefix > 128) throw new Error(`Invalid IPv6 prefix: ${cidr}`);
4535
+ return {
4536
+ cidr,
4537
+ words,
4538
+ prefix,
4539
+ rfc
4540
+ };
4541
+ }
4542
+ function parseIPv4Address(address) {
4543
+ const parts = address.split(".").map((part) => {
4544
+ if (!/^\d+$/.test(part)) return NaN;
4545
+ return parseInt(part, 10);
4546
+ });
4547
+ if (parts.length !== 4 || parts.some((part) => !Number.isInteger(part) || part < 0 || part > 255)) return null;
4548
+ return parts;
4549
+ }
4550
+ function parseIPv6Address(address) {
4551
+ const parts = expandIPv6Address(address).split(":");
4552
+ if (parts.length !== 8) return null;
4553
+ const words = parts.map((part) => {
4554
+ if (!/^[0-9a-f]{1,4}$/i.test(part)) return NaN;
4555
+ return parseInt(part, 16);
4556
+ });
4557
+ if (words.some((word) => !Number.isInteger(word) || word < 0 || word > 65535)) return null;
4558
+ return words;
4559
+ }
4560
+ function ipv4PartsToNumber(parts) {
4561
+ return parts[0] * 2 ** 24 + parts[1] * 2 ** 16 + parts[2] * 2 ** 8 + parts[3];
4562
+ }
4563
+ function ipv4FromWords(highWord, lowWord) {
4564
+ return [
4565
+ highWord >> 8,
4566
+ highWord & 255,
4567
+ lowWord >> 8,
4568
+ lowWord & 255
4569
+ ].join(".");
4570
+ }
4571
+ function matchesIPv4Prefix(address, prefixBase, prefixLength) {
4572
+ const blockSize = 2 ** (32 - prefixLength);
4573
+ return Math.floor(address / blockSize) === Math.floor(prefixBase / blockSize);
4574
+ }
4575
+ function matchesIPv6Prefix(address, prefixWords, prefixLength) {
4576
+ let remaining = prefixLength;
4577
+ for (let i = 0; i < 8 && remaining > 0; i++) if (remaining >= 16) {
4578
+ if (address[i] !== prefixWords[i]) return false;
4579
+ remaining -= 16;
4580
+ } else {
4581
+ const mask = 65535 << 16 - remaining & 65535;
4582
+ if ((address[i] & mask) !== (prefixWords[i] & mask)) return false;
4583
+ remaining = 0;
4584
+ }
4585
+ return true;
4586
+ }
4479
4587
  //#endregion
4480
4588
  //#region src/runtime/docloader.ts
4481
4589
  const logger = getLogger([
@@ -30,7 +30,7 @@ let node_dns_promises = require("node:dns/promises");
30
30
  let node_net = require("node:net");
31
31
  //#region deno.json
32
32
  var name = "@fedify/fedify";
33
- var version = "1.10.10";
33
+ var version = "1.10.12";
34
34
  //#endregion
35
35
  //#region src/runtime/contexts.ts
36
36
  const preloadedContexts = {
@@ -4476,29 +4476,137 @@ function validatePublicIpAddress(address, family) {
4476
4476
  throw new UrlError(`Invalid or private address: ${address}`);
4477
4477
  }
4478
4478
  function isValidPublicIPv4Address(address) {
4479
- const parts = address.split(".");
4480
- const first = parseInt(parts[0]);
4481
- if (first === 0 || first === 10 || first === 127) return false;
4482
- const second = parseInt(parts[1]);
4483
- if (first === 169 && second === 254) return false;
4484
- if (first === 172 && second >= 16 && second <= 31) return false;
4485
- if (first === 192 && second === 168) return false;
4486
- return true;
4479
+ const parts = parseIPv4Address(address);
4480
+ if (parts == null) return false;
4481
+ const value = ipv4PartsToNumber(parts);
4482
+ return !nonPublicIPv4Prefixes.some(({ base, prefix }) => matchesIPv4Prefix(value, base, prefix));
4487
4483
  }
4488
4484
  function isValidPublicIPv6Address(address) {
4489
- address = expandIPv6Address(address);
4490
- if (address.at(4) !== ":") return false;
4491
- const firstWord = parseInt(address.substring(0, 4), 16);
4492
- return !(firstWord >= 64512 && firstWord <= 65023 || firstWord >= 65152 && firstWord <= 65215 || firstWord === 0 || firstWord >= 65280);
4485
+ const words = parseIPv6Address(address);
4486
+ if (words == null) return false;
4487
+ if (nonPublicIPv6Prefixes.some(({ words: prefixWords, prefix }) => matchesIPv6Prefix(words, prefixWords, prefix))) return false;
4488
+ for (const { extractIPv4, prefix, words: prefixWords } of ipv6WithIPv4Prefixes) {
4489
+ if (!matchesIPv6Prefix(words, prefixWords, prefix)) continue;
4490
+ const ipv4Address = extractIPv4(words);
4491
+ if (ipv4Address != null && !isValidPublicIPv4Address(ipv4Address)) return false;
4492
+ }
4493
+ return true;
4493
4494
  }
4494
4495
  function expandIPv6Address(address) {
4495
4496
  address = address.toLowerCase();
4497
+ const ipv4Delimiter = address.lastIndexOf(":");
4498
+ if (address.includes(".") && ipv4Delimiter >= 0) {
4499
+ const ipv4Parts = parseIPv4Address(address.substring(ipv4Delimiter + 1));
4500
+ if (ipv4Parts == null) return address;
4501
+ const high = (ipv4Parts[0] << 8) + ipv4Parts[1];
4502
+ const low = (ipv4Parts[2] << 8) + ipv4Parts[3];
4503
+ address = address.substring(0, ipv4Delimiter + 1) + high.toString(16) + ":" + low.toString(16);
4504
+ }
4496
4505
  if (address === "::") return "0000:0000:0000:0000:0000:0000:0000:0000";
4497
4506
  if (address.startsWith("::")) address = "0000" + address;
4498
4507
  if (address.endsWith("::")) address = address + "0000";
4499
4508
  address = address.replace("::", ":0000".repeat(8 - (address.match(/:/g) || []).length) + ":");
4500
4509
  return address.split(":").map((part) => part.padStart(4, "0")).join(":");
4501
4510
  }
4511
+ const nonPublicIPv4Prefixes = [
4512
+ ipv4Prefix("0.0.0.0/8", "RFC 6890"),
4513
+ ipv4Prefix("10.0.0.0/8", "RFC 1918"),
4514
+ ipv4Prefix("100.64.0.0/10", "RFC 6598"),
4515
+ ipv4Prefix("127.0.0.0/8", "RFC 1122"),
4516
+ ipv4Prefix("169.254.0.0/16", "RFC 3927"),
4517
+ ipv4Prefix("172.16.0.0/12", "RFC 1918"),
4518
+ ipv4Prefix("192.0.0.0/24", "RFC 6890"),
4519
+ ipv4Prefix("192.0.2.0/24", "RFC 5737"),
4520
+ ipv4Prefix("192.88.99.0/24", "RFC 7526"),
4521
+ ipv4Prefix("192.168.0.0/16", "RFC 1918"),
4522
+ ipv4Prefix("198.18.0.0/15", "RFC 2544"),
4523
+ ipv4Prefix("198.51.100.0/24", "RFC 5737"),
4524
+ ipv4Prefix("203.0.113.0/24", "RFC 5737"),
4525
+ ipv4Prefix("224.0.0.0/4", "RFC 5771"),
4526
+ ipv4Prefix("240.0.0.0/4", "RFC 1112")
4527
+ ];
4528
+ const nonPublicIPv6Prefixes = [
4529
+ ipv6Prefix("::/16", "RFC 4291"),
4530
+ ipv6Prefix("2001::/32", "RFC 4380"),
4531
+ ipv6Prefix("2002::/16", "RFC 3056"),
4532
+ ipv6Prefix("64:ff9b:1::/48", "RFC 8215"),
4533
+ ipv6Prefix("fc00::/7", "RFC 4193"),
4534
+ ipv6Prefix("fe80::/10", "RFC 4291"),
4535
+ ipv6Prefix("ff00::/8", "RFC 4291")
4536
+ ];
4537
+ const ipv6WithIPv4Prefixes = [{
4538
+ ...ipv6Prefix("64:ff9b::/96", "RFC 6052"),
4539
+ extractIPv4: (words) => ipv4FromWords(words[6], words[7])
4540
+ }];
4541
+ function ipv4Prefix(cidr, rfc) {
4542
+ const [address, prefixText] = cidr.split("/");
4543
+ const prefix = parseInt(prefixText, 10);
4544
+ const parts = parseIPv4Address(address);
4545
+ if (parts == null || !Number.isInteger(prefix) || prefix < 0 || prefix > 32) throw new Error(`Invalid IPv4 prefix: ${cidr}`);
4546
+ return {
4547
+ cidr,
4548
+ base: ipv4PartsToNumber(parts),
4549
+ prefix,
4550
+ rfc
4551
+ };
4552
+ }
4553
+ function ipv6Prefix(cidr, rfc) {
4554
+ const [address, prefixText] = cidr.split("/");
4555
+ const prefix = parseInt(prefixText, 10);
4556
+ const words = parseIPv6Address(address);
4557
+ if (words == null || !Number.isInteger(prefix) || prefix < 0 || prefix > 128) throw new Error(`Invalid IPv6 prefix: ${cidr}`);
4558
+ return {
4559
+ cidr,
4560
+ words,
4561
+ prefix,
4562
+ rfc
4563
+ };
4564
+ }
4565
+ function parseIPv4Address(address) {
4566
+ const parts = address.split(".").map((part) => {
4567
+ if (!/^\d+$/.test(part)) return NaN;
4568
+ return parseInt(part, 10);
4569
+ });
4570
+ if (parts.length !== 4 || parts.some((part) => !Number.isInteger(part) || part < 0 || part > 255)) return null;
4571
+ return parts;
4572
+ }
4573
+ function parseIPv6Address(address) {
4574
+ const parts = expandIPv6Address(address).split(":");
4575
+ if (parts.length !== 8) return null;
4576
+ const words = parts.map((part) => {
4577
+ if (!/^[0-9a-f]{1,4}$/i.test(part)) return NaN;
4578
+ return parseInt(part, 16);
4579
+ });
4580
+ if (words.some((word) => !Number.isInteger(word) || word < 0 || word > 65535)) return null;
4581
+ return words;
4582
+ }
4583
+ function ipv4PartsToNumber(parts) {
4584
+ return parts[0] * 2 ** 24 + parts[1] * 2 ** 16 + parts[2] * 2 ** 8 + parts[3];
4585
+ }
4586
+ function ipv4FromWords(highWord, lowWord) {
4587
+ return [
4588
+ highWord >> 8,
4589
+ highWord & 255,
4590
+ lowWord >> 8,
4591
+ lowWord & 255
4592
+ ].join(".");
4593
+ }
4594
+ function matchesIPv4Prefix(address, prefixBase, prefixLength) {
4595
+ const blockSize = 2 ** (32 - prefixLength);
4596
+ return Math.floor(address / blockSize) === Math.floor(prefixBase / blockSize);
4597
+ }
4598
+ function matchesIPv6Prefix(address, prefixWords, prefixLength) {
4599
+ let remaining = prefixLength;
4600
+ for (let i = 0; i < 8 && remaining > 0; i++) if (remaining >= 16) {
4601
+ if (address[i] !== prefixWords[i]) return false;
4602
+ remaining -= 16;
4603
+ } else {
4604
+ const mask = 65535 << 16 - remaining & 65535;
4605
+ if ((address[i] & mask) !== (prefixWords[i] & mask)) return false;
4606
+ remaining = 0;
4607
+ }
4608
+ return true;
4609
+ }
4502
4610
  //#endregion
4503
4611
  //#region src/runtime/docloader.ts
4504
4612
  const logger = (0, _logtape_logtape.getLogger)([
@@ -1,7 +1,7 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { ct as __commonJSMin, dt as __toESM } from "./vocab-DP9A9TjH.mjs";
4
+ import { ct as __commonJSMin, dt as __toESM } from "./vocab-C5EUmVTj.mjs";
5
5
  //#region ../../node_modules/.pnpm/glob-to-regexp@0.4.1/node_modules/glob-to-regexp/index.js
6
6
  var require_glob_to_regexp = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7
7
  module.exports = function(glob, opts) {
@@ -1,14 +1,14 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { C as Person, _ as Note, t as Activity } from "../vocab-DP9A9TjH.mjs";
5
- import { t as test } from "../testing-B9FmxxlI.mjs";
4
+ import { C as Person, _ as Note, t as Activity } from "../vocab-C5EUmVTj.mjs";
5
+ import { t as test } from "../testing-BQeTO4ss.mjs";
6
6
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
7
7
  import { a as assertExists } from "../std__assert-2v7gYiZp.mjs";
8
8
  import { t as assertThrows } from "../assert_throws-BIL7gChy.mjs";
9
9
  import { t as MemoryKvStore } from "../kv-OuT2IU64.mjs";
10
10
  import { n as parseSemVer } from "../semver-CgD82xxg.mjs";
11
- import { n as createFederationBuilder } from "../builder-DBBCeuJN.mjs";
11
+ import { n as createFederationBuilder } from "../builder-Bdf32cY2.mjs";
12
12
  //#region src/federation/builder.test.ts
13
13
  test("FederationBuilder", async (t) => {
14
14
  await t.step("should build a Federation object with registered components", async () => {
@@ -1,7 +1,7 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { t as test } from "../testing-B9FmxxlI.mjs";
4
+ import { t as test } from "../testing-BQeTO4ss.mjs";
5
5
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
6
6
  import "../std__assert-2v7gYiZp.mjs";
7
7
  import { n as digest, t as buildCollectionSynchronizationHeader } from "../collection-BD6-SZ6O.mjs";
@@ -1,19 +1,19 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { C as Person, _ as Note, o as Create } from "../vocab-DP9A9TjH.mjs";
5
- import { a as mockDocumentLoader, i as createRequestContext, r as createInboxContext, t as test } from "../testing-B9FmxxlI.mjs";
4
+ import { C as Person, _ as Note, o as Create } from "../vocab-C5EUmVTj.mjs";
5
+ import { a as mockDocumentLoader, i as createRequestContext, r as createInboxContext, t as test } from "../testing-BQeTO4ss.mjs";
6
6
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
7
7
  import "../std__assert-2v7gYiZp.mjs";
8
8
  import { n as assertFalse, t as assertRejects } from "../assert_rejects-CJC9ThS-.mjs";
9
9
  import { t as assert } from "../assert-DikXweDx.mjs";
10
10
  import { t as MemoryKvStore } from "../kv-OuT2IU64.mjs";
11
- import { a as createFederation, c as handleCollection, d as handleObject, f as respondWithObject, l as handleCustomCollection, o as acceptsJsonLd, p as respondWithObjectIfAcceptable, s as handleActor, u as handleInbox } from "../middleware-BQ6evC7E.mjs";
12
- import { s as signRequest } from "../http-DyCX-dN3.mjs";
13
- import { a as compactJsonLd, f as signJsonLd } from "../ld-BaJmhpEa.mjs";
14
- import { t as InboxListenerSet } from "../inbox-BZN50kyQ.mjs";
11
+ import { a as createFederation, c as handleCollection, d as handleObject, f as respondWithObject, l as handleCustomCollection, o as acceptsJsonLd, p as respondWithObjectIfAcceptable, s as handleActor, u as handleInbox } from "../middleware-C26Vj2UM.mjs";
12
+ import { s as signRequest } from "../http-B7ppDy7F.mjs";
13
+ import { a as compactJsonLd, f as signJsonLd } from "../ld-BJtgkkBN.mjs";
14
+ import { t as InboxListenerSet } from "../inbox-BtX2yRj2.mjs";
15
15
  import { t as createTestTracerProvider } from "../otel-D00WjYJ1.mjs";
16
- import { a as rsaPrivateKey3, c as rsaPublicKey3, s as rsaPublicKey2 } from "../keys-8FIoKqmB.mjs";
16
+ import { a as rsaPrivateKey3, c as rsaPublicKey3, s as rsaPublicKey2 } from "../keys-BkXWqCAE.mjs";
17
17
  //#region src/federation/handler.test.ts
18
18
  test("acceptsJsonLd()", () => {
19
19
  assert(acceptsJsonLd(new Request("https://example.com/", { headers: { Accept: "application/activity+json" } })));
@@ -1,14 +1,14 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { C as Person, o as Create, u as Follow } from "../vocab-DP9A9TjH.mjs";
5
- import { a as mockDocumentLoader, t as test } from "../testing-B9FmxxlI.mjs";
4
+ import { C as Person, o as Create, u as Follow } from "../vocab-C5EUmVTj.mjs";
5
+ import { a as mockDocumentLoader, t as test } from "../testing-BQeTO4ss.mjs";
6
6
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
7
7
  import "../std__assert-2v7gYiZp.mjs";
8
8
  import { t as MemoryKvStore } from "../kv-OuT2IU64.mjs";
9
- import { a as createFederation } from "../middleware-BQ6evC7E.mjs";
10
- import { n as signObject } from "../proof-CAOvY-AP.mjs";
11
- import { n as ed25519PrivateKey, r as ed25519PublicKey, t as ed25519Multikey } from "../keys-8FIoKqmB.mjs";
9
+ import { a as createFederation } from "../middleware-C26Vj2UM.mjs";
10
+ import { n as signObject } from "../proof-B5uyl0iN.mjs";
11
+ import { n as ed25519PrivateKey, r as ed25519PublicKey, t as ed25519Multikey } from "../keys-BkXWqCAE.mjs";
12
12
  //#region src/federation/idempotency.test.ts
13
13
  const kv = new MemoryKvStore();
14
14
  const federationOptions = {
@@ -1,11 +1,11 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { O as Update, m as Invite, o as Create, t as Activity, y as Offer } from "../vocab-DP9A9TjH.mjs";
5
- import { t as test } from "../testing-B9FmxxlI.mjs";
4
+ import { O as Update, m as Invite, o as Create, t as Activity, y as Offer } from "../vocab-C5EUmVTj.mjs";
5
+ import { t as test } from "../testing-BQeTO4ss.mjs";
6
6
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
7
7
  import { t as assertThrows } from "../assert_throws-BIL7gChy.mjs";
8
- import { t as InboxListenerSet } from "../inbox-BZN50kyQ.mjs";
8
+ import { t as InboxListenerSet } from "../inbox-BtX2yRj2.mjs";
9
9
  //#region src/federation/inbox.test.ts
10
10
  test("InboxListenerSet", () => {
11
11
  const listeners = new InboxListenerSet();
@@ -1,13 +1,13 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { g as Multikey, s as CryptographicKey } from "../vocab-DP9A9TjH.mjs";
5
- import { t as test } from "../testing-B9FmxxlI.mjs";
4
+ import { g as Multikey, s as CryptographicKey } from "../vocab-C5EUmVTj.mjs";
5
+ import { t as test } from "../testing-BQeTO4ss.mjs";
6
6
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
7
7
  import { t as assertInstanceOf } from "../assert_instance_of-C4Ri6VuN.mjs";
8
8
  import { t as assert } from "../assert-DikXweDx.mjs";
9
9
  import { t as MemoryKvStore } from "../kv-OuT2IU64.mjs";
10
- import { t as KvKeyCache } from "../keycache-DETDxpbh.mjs";
10
+ import { t as KvKeyCache } from "../keycache-Bgm-3VZ1.mjs";
11
11
  //#region src/federation/keycache.test.ts
12
12
  test("KvKeyCache.set()", async () => {
13
13
  const kv = new MemoryKvStore();
@@ -1,7 +1,7 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { t as test } from "../testing-B9FmxxlI.mjs";
4
+ import { t as test } from "../testing-BQeTO4ss.mjs";
5
5
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
6
6
  import "../std__assert-2v7gYiZp.mjs";
7
7
  import { t as MemoryKvStore } from "../kv-OuT2IU64.mjs";