@fedify/vocab-runtime 2.1.29 → 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.
package/deno.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/vocab-runtime",
3
- "version": "2.1.29",
3
+ "version": "2.1.30",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./src/mod.ts",
package/dist/mod.cjs CHANGED
@@ -4593,7 +4593,7 @@ const preloadedContexts = {
4593
4593
  //#endregion
4594
4594
  //#region deno.json
4595
4595
  var name = "@fedify/vocab-runtime";
4596
- var version = "2.1.29";
4596
+ var version = "2.1.30";
4597
4597
  //#endregion
4598
4598
  //#region src/request.ts
4599
4599
  /**
@@ -5255,6 +5255,7 @@ function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAge
5255
5255
  options?.signal?.throwIfAborted();
5256
5256
  const parsedUrl = new URL(url);
5257
5257
  if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") throw new UrlError(`Unsupported protocol: ${parsedUrl.protocol}`);
5258
+ if (parsedUrl.username !== "" || parsedUrl.password !== "") throw new UrlError("URLs with credentials are not allowed");
5258
5259
  const currentUrl = parsedUrl.href;
5259
5260
  if (!skipPreloadedContexts && currentUrl in preloadedContexts) {
5260
5261
  logger.debug("Using preloaded context: {url}.", { url: currentUrl });
package/dist/mod.js CHANGED
@@ -4588,7 +4588,7 @@ const preloadedContexts = {
4588
4588
  //#endregion
4589
4589
  //#region deno.json
4590
4590
  var name = "@fedify/vocab-runtime";
4591
- var version = "2.1.29";
4591
+ var version = "2.1.30";
4592
4592
  //#endregion
4593
4593
  //#region src/request.ts
4594
4594
  /**
@@ -5250,6 +5250,7 @@ function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAge
5250
5250
  options?.signal?.throwIfAborted();
5251
5251
  const parsedUrl = new URL(url);
5252
5252
  if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") throw new UrlError(`Unsupported protocol: ${parsedUrl.protocol}`);
5253
+ if (parsedUrl.username !== "" || parsedUrl.password !== "") throw new UrlError("URLs with credentials are not allowed");
5253
5254
  const currentUrl = parsedUrl.href;
5254
5255
  if (!skipPreloadedContexts && currentUrl in preloadedContexts) {
5255
5256
  logger.debug("Using preloaded context: {url}.", { url: currentUrl });
@@ -1,5 +1,5 @@
1
1
  require("./chunk-Do9eywBl.cjs");
2
- const require_request = require("./request-C_PrlGe_.cjs");
2
+ const require_request = require("./request-hHQ_KvBF.cjs");
3
3
  let _logtape_logtape = require("@logtape/logtape");
4
4
  //#region src/body.ts
5
5
  /** Decoded JSON body limit: 16 MiB. @internal */
@@ -1,4 +1,4 @@
1
- import { t as FetchError } from "./request-B9R4Y9qS.mjs";
1
+ import { t as FetchError } from "./request-Bri8X69i.mjs";
2
2
  import { getLogger } from "@logtape/logtape";
3
3
  //#region src/body.ts
4
4
  /** Decoded JSON body limit: 16 MiB. @internal */
@@ -1,5 +1,5 @@
1
1
  require("./chunk-Do9eywBl.cjs");
2
- const require_body = require("./body-BI7IK9DK.cjs");
2
+ const require_body = require("./body-Bda70xVu.cjs");
3
3
  let node_assert_strict = require("node:assert/strict");
4
4
  let node_test = require("node:test");
5
5
  let node_zlib = require("node:zlib");
@@ -1,4 +1,4 @@
1
- import { r as readBoundedText, t as BodyTooLargeError } from "./body-C-p-RXaQ.mjs";
1
+ import { r as readBoundedText, t as BodyTooLargeError } from "./body-C7C_CqNA.mjs";
2
2
  import { deepStrictEqual, ok, rejects } from "node:assert/strict";
3
3
  import { test } from "node:test";
4
4
  import { gunzipSync, gzipSync } from "node:zlib";
@@ -1,5 +1,5 @@
1
1
  require("./chunk-Do9eywBl.cjs");
2
- require("./docloader-Okt4FgM8.cjs");
2
+ require("./docloader-D5BTSARP.cjs");
3
3
  require("./url-vZTgkIZg.cjs");
4
4
  require("./key-BarKGLQz.cjs");
5
5
  require("./multibase-8zhYPa7o.cjs");
@@ -1,4 +1,4 @@
1
- import "./docloader-DVamy9FW.mjs";
1
+ import "./docloader-Bsosn1qB.mjs";
2
2
  import "./url-3fyJuqC0.mjs";
3
3
  import "./key-BDIsC6hV.mjs";
4
4
  import "./multibase-Ds75BvXs.mjs";
@@ -1,5 +1,5 @@
1
- import { a as name, i as logRequest, n as createActivityPubRequest, o as version, t as FetchError } from "./request-B9R4Y9qS.mjs";
2
- import { n as MAX_BODY_SIZE, r as readBoundedText } from "./body-C-p-RXaQ.mjs";
1
+ import { a as name, i as logRequest, n as createActivityPubRequest, o as version, t as FetchError } from "./request-Bri8X69i.mjs";
2
+ import { n as MAX_BODY_SIZE, r as readBoundedText } from "./body-C7C_CqNA.mjs";
3
3
  import { t as HttpHeaderLink } from "./link-CYszIegt.mjs";
4
4
  import { o as validatePublicUrl, t as UrlError } from "./url-3fyJuqC0.mjs";
5
5
  import { getLogger } from "@logtape/logtape";
@@ -4705,6 +4705,7 @@ function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAge
4705
4705
  options?.signal?.throwIfAborted();
4706
4706
  const parsedUrl = new URL(url);
4707
4707
  if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") throw new UrlError(`Unsupported protocol: ${parsedUrl.protocol}`);
4708
+ if (parsedUrl.username !== "" || parsedUrl.password !== "") throw new UrlError("URLs with credentials are not allowed");
4708
4709
  const currentUrl = parsedUrl.href;
4709
4710
  if (!skipPreloadedContexts && currentUrl in preloadedContexts) {
4710
4711
  logger.debug("Using preloaded context: {url}.", { url: currentUrl });
@@ -1,6 +1,6 @@
1
1
  require("./chunk-Do9eywBl.cjs");
2
- const require_request = require("./request-C_PrlGe_.cjs");
3
- const require_body = require("./body-BI7IK9DK.cjs");
2
+ const require_request = require("./request-hHQ_KvBF.cjs");
3
+ const require_body = require("./body-Bda70xVu.cjs");
4
4
  const require_link = require("./link-qDTmjPw_.cjs");
5
5
  const require_url = require("./url-vZTgkIZg.cjs");
6
6
  let _logtape_logtape = require("@logtape/logtape");
@@ -4706,6 +4706,7 @@ function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAge
4706
4706
  options?.signal?.throwIfAborted();
4707
4707
  const parsedUrl = new URL(url);
4708
4708
  if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") throw new require_url.UrlError(`Unsupported protocol: ${parsedUrl.protocol}`);
4709
+ if (parsedUrl.username !== "" || parsedUrl.password !== "") throw new require_url.UrlError("URLs with credentials are not allowed");
4709
4710
  const currentUrl = parsedUrl.href;
4710
4711
  if (!skipPreloadedContexts && currentUrl in preloadedContexts) {
4711
4712
  logger.debug("Using preloaded context: {url}.", { url: currentUrl });
@@ -1,6 +1,6 @@
1
1
  const require_chunk = require("./chunk-Do9eywBl.cjs");
2
- const require_request = require("./request-C_PrlGe_.cjs");
3
- const require_docloader = require("./docloader-Okt4FgM8.cjs");
2
+ const require_request = require("./request-hHQ_KvBF.cjs");
3
+ const require_docloader = require("./docloader-D5BTSARP.cjs");
4
4
  const require_url = require("./url-vZTgkIZg.cjs");
5
5
  let node_zlib = require("node:zlib");
6
6
  let _logtape_logtape = require("@logtape/logtape");
@@ -2008,6 +2008,52 @@ const unsupportedUrls = [
2008
2008
  "file:///collection",
2009
2009
  `data:application/ld+json,${encodeURIComponent(JSON.stringify({ id: "https://example.com/data" }))}`
2010
2010
  ];
2011
+ function isCredentialUrlError(error) {
2012
+ return error instanceof require_url.UrlError && error.reason === "disallowed" && error.message === "URLs with credentials are not allowed";
2013
+ }
2014
+ (0, _fedify_fixture.test)("getDocumentLoader() rejects URLs with credentials", async (t) => {
2015
+ const start = "https://8.8.8.8/start";
2016
+ const target = "https://user:pass@8.8.8.8/document";
2017
+ for (const allowPrivateAddress of [false, true]) {
2018
+ const loader = require_docloader.getDocumentLoader({ allowPrivateAddress });
2019
+ for (const path of [
2020
+ "direct",
2021
+ "redirect",
2022
+ "Link",
2023
+ "HTML"
2024
+ ]) await t.step(`${path}, allowPrivateAddress=${allowPrivateAddress}`, async () => {
2025
+ await withFetchStub((url) => {
2026
+ if (url !== start) return Response.json({});
2027
+ if (path === "redirect") return Response.redirect(target, 302);
2028
+ if (path === "HTML") return new Response(`<link rel="alternate" type="application/activity+json" href="${target}">`, { headers: { "Content-Type": "text/html" } });
2029
+ return new Response("", { headers: {
2030
+ "Content-Type": "text/plain",
2031
+ Link: `<${target}>; rel="alternate"; type="application/activity+json"`
2032
+ } });
2033
+ }, async (fetched) => {
2034
+ await (0, node_assert.rejects)(loader(path === "direct" ? target : start), isCredentialUrlError);
2035
+ (0, node_assert.deepStrictEqual)(fetched, path === "direct" ? [] : [start]);
2036
+ });
2037
+ });
2038
+ for (const url of [
2039
+ "https://user@8.8.8.8/document",
2040
+ "https://:pass@8.8.8.8/document",
2041
+ "https://%75ser:p%40ss@8.8.8.8/document",
2042
+ "http://user:pass@8.8.8.8/document"
2043
+ ]) await t.step(`${url}, allowPrivateAddress=${allowPrivateAddress}`, async () => {
2044
+ await withFetchStub(() => Response.json({}), async (fetched) => {
2045
+ await (0, node_assert.rejects)(loader(url), isCredentialUrlError);
2046
+ (0, node_assert.deepStrictEqual)(fetched, []);
2047
+ });
2048
+ });
2049
+ for (const url of ["https://:@8.8.8.8/document", "https://8.8.8.8/@user?q=@pass"]) await t.step(`allows ${url}, allowPrivateAddress=${allowPrivateAddress}`, async () => {
2050
+ await withFetchStub(() => Response.json({ done: true }), async (fetched) => {
2051
+ (0, node_assert.deepStrictEqual)((await loader(url)).document, { done: true });
2052
+ (0, node_assert.deepStrictEqual)(fetched, [new URL(url).href]);
2053
+ });
2054
+ });
2055
+ }
2056
+ });
2011
2057
  function isUnsupportedProtocolError(error, url) {
2012
2058
  return error instanceof require_url.UrlError && error.message === `Unsupported protocol: ${new URL(url).protocol}` && error.reason === "disallowed";
2013
2059
  }
@@ -1,5 +1,5 @@
1
- import { t as FetchError } from "./request-B9R4Y9qS.mjs";
2
- import { i as cid_v1_default, n as getRemoteDocument, r as preloadedContexts, t as getDocumentLoader } from "./docloader-DVamy9FW.mjs";
1
+ import { t as FetchError } from "./request-Bri8X69i.mjs";
2
+ import { i as cid_v1_default, n as getRemoteDocument, r as preloadedContexts, t as getDocumentLoader } from "./docloader-Bsosn1qB.mjs";
3
3
  import { t as UrlError } from "./url-3fyJuqC0.mjs";
4
4
  import { gzipSync } from "node:zlib";
5
5
  import { configure, reset } from "@logtape/logtape";
@@ -2025,6 +2025,52 @@ const unsupportedUrls = [
2025
2025
  "file:///collection",
2026
2026
  `data:application/ld+json,${encodeURIComponent(JSON.stringify({ id: "https://example.com/data" }))}`
2027
2027
  ];
2028
+ function isCredentialUrlError(error) {
2029
+ return error instanceof UrlError && error.reason === "disallowed" && error.message === "URLs with credentials are not allowed";
2030
+ }
2031
+ test("getDocumentLoader() rejects URLs with credentials", async (t) => {
2032
+ const start = "https://8.8.8.8/start";
2033
+ const target = "https://user:pass@8.8.8.8/document";
2034
+ for (const allowPrivateAddress of [false, true]) {
2035
+ const loader = getDocumentLoader({ allowPrivateAddress });
2036
+ for (const path of [
2037
+ "direct",
2038
+ "redirect",
2039
+ "Link",
2040
+ "HTML"
2041
+ ]) await t.step(`${path}, allowPrivateAddress=${allowPrivateAddress}`, async () => {
2042
+ await withFetchStub((url) => {
2043
+ if (url !== start) return Response.json({});
2044
+ if (path === "redirect") return Response.redirect(target, 302);
2045
+ if (path === "HTML") return new Response(`<link rel="alternate" type="application/activity+json" href="${target}">`, { headers: { "Content-Type": "text/html" } });
2046
+ return new Response("", { headers: {
2047
+ "Content-Type": "text/plain",
2048
+ Link: `<${target}>; rel="alternate"; type="application/activity+json"`
2049
+ } });
2050
+ }, async (fetched) => {
2051
+ await rejects(loader(path === "direct" ? target : start), isCredentialUrlError);
2052
+ deepStrictEqual(fetched, path === "direct" ? [] : [start]);
2053
+ });
2054
+ });
2055
+ for (const url of [
2056
+ "https://user@8.8.8.8/document",
2057
+ "https://:pass@8.8.8.8/document",
2058
+ "https://%75ser:p%40ss@8.8.8.8/document",
2059
+ "http://user:pass@8.8.8.8/document"
2060
+ ]) await t.step(`${url}, allowPrivateAddress=${allowPrivateAddress}`, async () => {
2061
+ await withFetchStub(() => Response.json({}), async (fetched) => {
2062
+ await rejects(loader(url), isCredentialUrlError);
2063
+ deepStrictEqual(fetched, []);
2064
+ });
2065
+ });
2066
+ for (const url of ["https://:@8.8.8.8/document", "https://8.8.8.8/@user?q=@pass"]) await t.step(`allows ${url}, allowPrivateAddress=${allowPrivateAddress}`, async () => {
2067
+ await withFetchStub(() => Response.json({ done: true }), async (fetched) => {
2068
+ deepStrictEqual((await loader(url)).document, { done: true });
2069
+ deepStrictEqual(fetched, [new URL(url).href]);
2070
+ });
2071
+ });
2072
+ }
2073
+ });
2028
2074
  function isUnsupportedProtocolError(error, url) {
2029
2075
  return error instanceof UrlError && error.message === `Unsupported protocol: ${new URL(url).protocol}` && error.reason === "disallowed";
2030
2076
  }
@@ -1,7 +1,7 @@
1
1
  import process from "node:process";
2
2
  //#region deno.json
3
3
  var name = "@fedify/vocab-runtime";
4
- var version = "2.1.29";
4
+ var version = "2.1.30";
5
5
  //#endregion
6
6
  //#region src/request.ts
7
7
  /**
@@ -3,7 +3,7 @@ let node_process = require("node:process");
3
3
  node_process = require_chunk.__toESM(node_process);
4
4
  //#region deno.json
5
5
  var name = "@fedify/vocab-runtime";
6
- var version = "2.1.29";
6
+ var version = "2.1.30";
7
7
  //#endregion
8
8
  //#region src/request.ts
9
9
  /**
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require("./chunk-Do9eywBl.cjs");
2
- const require_request = require("./request-C_PrlGe_.cjs");
2
+ const require_request = require("./request-hHQ_KvBF.cjs");
3
3
  let node_test = require("node:test");
4
4
  let node_process = require("node:process");
5
5
  node_process = require_chunk.__toESM(node_process);
@@ -1,4 +1,4 @@
1
- import { o as version, r as getUserAgent } from "./request-B9R4Y9qS.mjs";
1
+ import { o as version, r as getUserAgent } from "./request-Bri8X69i.mjs";
2
2
  import { test } from "node:test";
3
3
  import process from "node:process";
4
4
  import { deepStrictEqual } from "node:assert";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/vocab-runtime",
3
- "version": "2.1.29",
3
+ "version": "2.1.30",
4
4
  "homepage": "https://fedify.dev/",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1101,6 +1101,90 @@ const unsupportedUrls = [
1101
1101
  }`,
1102
1102
  ];
1103
1103
 
1104
+ function isCredentialUrlError(error: unknown): boolean {
1105
+ return error instanceof UrlError && error.reason === "disallowed" &&
1106
+ error.message === "URLs with credentials are not allowed";
1107
+ }
1108
+
1109
+ test("getDocumentLoader() rejects URLs with credentials", async (t) => {
1110
+ const start = "https://8.8.8.8/start";
1111
+ const target = "https://user:pass@8.8.8.8/document";
1112
+ for (const allowPrivateAddress of [false, true]) {
1113
+ const loader = getDocumentLoader({ allowPrivateAddress });
1114
+ for (const path of ["direct", "redirect", "Link", "HTML"]) {
1115
+ await t.step(
1116
+ `${path}, allowPrivateAddress=${allowPrivateAddress}`,
1117
+ async () => {
1118
+ await withFetchStub(
1119
+ (url) => {
1120
+ if (url !== start) return Response.json({});
1121
+ if (path === "redirect") return Response.redirect(target, 302);
1122
+ if (path === "HTML") {
1123
+ return new Response(
1124
+ `<link rel="alternate" type="application/activity+json" href="${target}">`,
1125
+ { headers: { "Content-Type": "text/html" } },
1126
+ );
1127
+ }
1128
+ return new Response("", {
1129
+ headers: {
1130
+ "Content-Type": "text/plain",
1131
+ Link:
1132
+ `<${target}>; rel="alternate"; type="application/activity+json"`,
1133
+ },
1134
+ });
1135
+ },
1136
+ async (fetched) => {
1137
+ await rejects(
1138
+ loader(path === "direct" ? target : start),
1139
+ isCredentialUrlError,
1140
+ );
1141
+ deepStrictEqual(fetched, path === "direct" ? [] : [start]);
1142
+ },
1143
+ );
1144
+ },
1145
+ );
1146
+ }
1147
+ for (
1148
+ const url of [
1149
+ "https://user@8.8.8.8/document",
1150
+ "https://:pass@8.8.8.8/document",
1151
+ "https://%75ser:p%40ss@8.8.8.8/document",
1152
+ "http://user:pass@8.8.8.8/document",
1153
+ ]
1154
+ ) {
1155
+ await t.step(
1156
+ `${url}, allowPrivateAddress=${allowPrivateAddress}`,
1157
+ async () => {
1158
+ await withFetchStub(() => Response.json({}), async (fetched) => {
1159
+ await rejects(loader(url), isCredentialUrlError);
1160
+ deepStrictEqual(fetched, []);
1161
+ });
1162
+ },
1163
+ );
1164
+ }
1165
+ for (
1166
+ const url of [
1167
+ "https://:@8.8.8.8/document",
1168
+ "https://8.8.8.8/@user?q=@pass",
1169
+ ]
1170
+ ) {
1171
+ await t.step(
1172
+ `allows ${url}, allowPrivateAddress=${allowPrivateAddress}`,
1173
+ async () => {
1174
+ await withFetchStub(
1175
+ () => Response.json({ done: true }),
1176
+ async (fetched) => {
1177
+ const document = await loader(url);
1178
+ deepStrictEqual(document.document, { done: true });
1179
+ deepStrictEqual(fetched, [new URL(url).href]);
1180
+ },
1181
+ );
1182
+ },
1183
+ );
1184
+ }
1185
+ }
1186
+ });
1187
+
1104
1188
  function isUnsupportedProtocolError(error: unknown, url: string): boolean {
1105
1189
  return error instanceof UrlError &&
1106
1190
  error.message === `Unsupported protocol: ${new URL(url).protocol}` &&
package/src/docloader.ts CHANGED
@@ -307,6 +307,11 @@ export function getDocumentLoader(
307
307
  if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") {
308
308
  throw new UrlError(`Unsupported protocol: ${parsedUrl.protocol}`);
309
309
  }
310
+ // When merging forward, keep this guard independent of allowPrivateAddress:
311
+ // private-address opt-in must not permit credentials on any followed URL.
312
+ if (parsedUrl.username !== "" || parsedUrl.password !== "") {
313
+ throw new UrlError("URLs with credentials are not allowed");
314
+ }
310
315
  const currentUrl = parsedUrl.href;
311
316
  if (!skipPreloadedContexts && currentUrl in preloadedContexts) {
312
317
  logger.debug("Using preloaded context: {url}.", { url: currentUrl });