@fedify/fedify 2.3.1 → 2.3.2
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/README.md +11 -8
- package/dist/{builder-hivpmhlD.mjs → builder-Dx4EI2YS.mjs} +4 -2
- package/dist/{circuit-breaker-CSWsyoef.mjs → circuit-breaker-DLS_n1x5.mjs} +190 -7
- package/dist/circuit-breaker-test-utils-BVnv3T76.mjs +14 -0
- package/dist/{client-ByXmQhYD.mjs → client-D1KuWxjH.mjs} +63 -5
- package/dist/compat/mod.d.cts +1 -1
- package/dist/compat/mod.d.ts +1 -1
- package/dist/compat/transformers.test.mjs +1 -1
- package/dist/{context-BBVLF7lx.d.cts → context-Bjswu3eC.d.cts} +18 -1
- package/dist/{context-BU6jSQdo.d.ts → context-COxc_O-c.d.ts} +18 -1
- package/dist/{deno-C8RG0HM3.mjs → deno-B8lcQ4Ms.mjs} +1 -1
- package/dist/{docloader-YZA0m_3O.mjs → docloader-BMjxpyJD.mjs} +2 -2
- package/dist/federation/builder.test.mjs +13 -1
- package/dist/federation/circuit-breaker.test.mjs +622 -3
- package/dist/federation/handler.test.mjs +3 -3
- package/dist/federation/idempotency.test.mjs +2 -2
- package/dist/federation/metrics.test.mjs +1 -1
- package/dist/federation/middleware.test.mjs +16 -8
- package/dist/federation/mod.cjs +1 -1
- package/dist/federation/mod.d.cts +2 -2
- package/dist/federation/mod.d.ts +2 -2
- package/dist/federation/mod.js +1 -1
- package/dist/federation/send.test.mjs +3 -3
- package/dist/federation/temporal.test.mjs +1 -1
- package/dist/federation/webfinger.test.mjs +69 -7
- package/dist/{http-BajqV0pH.cjs → http-CpdQD2ke.cjs} +1 -1
- package/dist/{http-DPOMa1DD.js → http-DVZxcZEr.js} +1 -1
- package/dist/{http-PCt0862M.mjs → http-DlSQMJsb.mjs} +3 -3
- package/dist/{key-BKYwmbur.mjs → key-BqT9YrM3.mjs} +2 -2
- package/dist/{kv-cache-IjRceERu.js → kv-cache-B52kTPj4.js} +1 -1
- package/dist/{kv-cache-CVG3m2_-.cjs → kv-cache-B8gm4cVB.cjs} +1 -1
- package/dist/{kv-cache-Ceg0c1wh.mjs → kv-cache-BD6BgCTF.mjs} +1 -1
- package/dist/{ld-Dcw2skfn.mjs → ld-hwRDfZqq.mjs} +3 -3
- package/dist/{metrics-Pue1x4ta.mjs → metrics-DxJzdAgZ.mjs} +1 -1
- package/dist/{middleware-By8lqc18.js → middleware-B2rDMvhv.js} +231 -29
- package/dist/{middleware-WU_5fbGS.mjs → middleware-CubmqVku.mjs} +49 -32
- package/dist/{middleware-BiXEAbn2.cjs → middleware-D2F1jSer.cjs} +231 -29
- package/dist/{middleware-CyxqoeW9.mjs → middleware-DxCKBFFT.mjs} +1 -1
- package/dist/{mod-C0F6kvgS.d.cts → mod-0bIqGrKQ.d.cts} +1 -1
- package/dist/{mod-vPYVoa5n.d.ts → mod-3H9Gym5G.d.ts} +1 -1
- package/dist/mod.cjs +5 -5
- package/dist/mod.d.cts +2 -2
- package/dist/mod.d.ts +2 -2
- package/dist/mod.js +5 -5
- package/dist/nodeinfo/client.test.mjs +61 -1
- package/dist/nodeinfo/handler.test.mjs +1 -1
- package/dist/nodeinfo/mod.cjs +1 -1
- package/dist/nodeinfo/mod.js +1 -1
- package/dist/{owner-pVJ0Twi7.mjs → owner-Btzxz2vj.mjs} +2 -2
- package/dist/{proof-HzavUYxN.cjs → proof-BdnNZ9OM.cjs} +1 -1
- package/dist/{proof-DA8Kbchf.js → proof-C_kcg7vF.js} +1 -1
- package/dist/{proof-pXYODmNV.mjs → proof-D2Z0Wa9X.mjs} +3 -3
- package/dist/{send-BfAp60BJ.mjs → send-BljvjEOa.mjs} +3 -3
- package/dist/sig/http.test.mjs +2 -2
- package/dist/sig/key.test.mjs +1 -1
- package/dist/sig/ld.test.mjs +2 -2
- package/dist/sig/mod.cjs +2 -2
- package/dist/sig/mod.js +2 -2
- package/dist/sig/owner.test.mjs +1 -1
- package/dist/sig/proof.test.mjs +1 -1
- package/dist/{temporal-HZHBbbk4.mjs → temporal-Dg8Hb3lz.mjs} +1 -1
- package/dist/{types-CAY3OdLq.js → types-DTONwNqL.js} +63 -5
- package/dist/{types-KC4QAoxe.cjs → types-m8u9L86X.cjs} +62 -4
- package/dist/utils/docloader.test.mjs +2 -2
- package/dist/utils/kv-cache.test.mjs +1 -1
- package/dist/utils/mod.cjs +1 -1
- package/dist/utils/mod.js +1 -1
- package/package.json +6 -6
- package/skills/fedify/SKILL.md +462 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { Temporal } = require("@js-temporal/polyfill");
|
|
2
2
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
3
3
|
const require_chunk = require("./chunk-DDcVe30Y.cjs");
|
|
4
|
-
const require_http = require("./http-
|
|
4
|
+
const require_http = require("./http-CpdQD2ke.cjs");
|
|
5
5
|
let _logtape_logtape = require("@logtape/logtape");
|
|
6
6
|
let _fedify_vocab = require("@fedify/vocab");
|
|
7
7
|
let _opentelemetry_api = require("@opentelemetry/api");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import { F as version, P as name, _ as measureSignatureKeyFetch, d as validateCryptoKey, f as getDurationMs, p as getFederationMetrics, s as fetchKey } from "./http-
|
|
3
|
+
import { F as version, P as name, _ as measureSignatureKeyFetch, d as validateCryptoKey, f as getDurationMs, p as getFederationMetrics, s as fetchKey } from "./http-DVZxcZEr.js";
|
|
4
4
|
import { getLogger } from "@logtape/logtape";
|
|
5
5
|
import { Activity, CryptographicKey, DataIntegrityProof, Multikey, Object as Object$1, PUBLIC_COLLECTION, getTypeId, isActor } from "@fedify/vocab";
|
|
6
6
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
@@ -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-
|
|
5
|
-
import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-
|
|
6
|
-
import { n as fetchKey, o as validateCryptoKey } from "./key-
|
|
4
|
+
import { n as version, t as name } from "./deno-B8lcQ4Ms.mjs";
|
|
5
|
+
import { n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch } from "./metrics-DxJzdAgZ.mjs";
|
|
6
|
+
import { n as fetchKey, o as validateCryptoKey } from "./key-BqT9YrM3.mjs";
|
|
7
7
|
import { n as preloadedOnlyDocumentLoader } from "./public-audience-Cvbr2Gzt.mjs";
|
|
8
8
|
import { r as normalizeOutgoingActivityJsonLd } from "./outgoing-jsonld-L_DbOaFe.mjs";
|
|
9
9
|
import { getLogger } from "@logtape/logtape";
|
|
@@ -1,9 +1,9 @@
|
|
|
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-
|
|
5
|
-
import { n as getDurationMs, r as getFederationMetrics } from "./metrics-
|
|
6
|
-
import { n as doubleKnock } from "./http-
|
|
4
|
+
import { n as version, t as name } from "./deno-B8lcQ4Ms.mjs";
|
|
5
|
+
import { n as getDurationMs, r as getFederationMetrics } from "./metrics-DxJzdAgZ.mjs";
|
|
6
|
+
import { n as doubleKnock } from "./http-DlSQMJsb.mjs";
|
|
7
7
|
import { getLogger } from "@logtape/logtape";
|
|
8
8
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
9
9
|
import { FetchError } from "@fedify/vocab-runtime";
|
package/dist/sig/http.test.mjs
CHANGED
|
@@ -7,8 +7,8 @@ import { r as assertExists, t as assertStringIncludes } from "../std__assert-BBj
|
|
|
7
7
|
import { n as assertGreaterOrEqual, r as assertFalse, t as assertRejects } from "../assert_rejects-DN60FHPX.mjs";
|
|
8
8
|
import { t as assertThrows } from "../assert_throws-BOkhLGYc.mjs";
|
|
9
9
|
import { t as assert } from "../assert-OguE97r2.mjs";
|
|
10
|
-
import { t as exportJwk } from "../key-
|
|
11
|
-
import { a as parseRfc9421Signature, c as timingSafeEqual, i as formatRfc9421SignatureParameters, l as verifyRequest, n as doubleKnock, o as parseRfc9421SignatureInput, r as formatRfc9421Signature, s as signRequest, t as createRfc9421SignatureBase, u as verifyRequestDetailed } from "../http-
|
|
10
|
+
import { t as exportJwk } from "../key-BqT9YrM3.mjs";
|
|
11
|
+
import { a as parseRfc9421Signature, c as timingSafeEqual, i as formatRfc9421SignatureParameters, l as verifyRequest, n as doubleKnock, o as parseRfc9421SignatureInput, r as formatRfc9421Signature, s as signRequest, t as createRfc9421SignatureBase, u as verifyRequestDetailed } from "../http-DlSQMJsb.mjs";
|
|
12
12
|
import { i as rsaPrivateKey2, l as rsaPublicKey5, o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-DGu1NFwu.mjs";
|
|
13
13
|
import { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
14
14
|
import { FetchError, exportSpki } from "@fedify/vocab-runtime";
|
package/dist/sig/key.test.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
|
5
5
|
import "../std__assert-BBjXFNOb.mjs";
|
|
6
6
|
import { t as assertRejects } from "../assert_rejects-DN60FHPX.mjs";
|
|
7
7
|
import { t as assertThrows } from "../assert_throws-BOkhLGYc.mjs";
|
|
8
|
-
import { a as importJwk, i as generateCryptoKeyPair, n as fetchKey, o as validateCryptoKey, r as fetchKeyDetailed, t as exportJwk } from "../key-
|
|
8
|
+
import { a as importJwk, i as generateCryptoKeyPair, n as fetchKey, o as validateCryptoKey, r as fetchKeyDetailed, t as exportJwk } from "../key-BqT9YrM3.mjs";
|
|
9
9
|
import { c as rsaPublicKey3, i as rsaPrivateKey2, o as rsaPublicKey1, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DGu1NFwu.mjs";
|
|
10
10
|
import { CryptographicKey, Multikey } from "@fedify/vocab";
|
|
11
11
|
import { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
package/dist/sig/ld.test.mjs
CHANGED
|
@@ -5,9 +5,9 @@ import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
|
5
5
|
import { n as assertGreaterOrEqual, r as assertFalse, t as assertRejects } from "../assert_rejects-DN60FHPX.mjs";
|
|
6
6
|
import { t as assertThrows } from "../assert_throws-BOkhLGYc.mjs";
|
|
7
7
|
import { t as assert } from "../assert-OguE97r2.mjs";
|
|
8
|
-
import { i as generateCryptoKeyPair } from "../key-
|
|
8
|
+
import { i as generateCryptoKeyPair } from "../key-BqT9YrM3.mjs";
|
|
9
9
|
import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DGu1NFwu.mjs";
|
|
10
|
-
import { a as compactJsonLd, f as isInvalidUrlTypeError, g as verifySignature, h as verifyJsonLd, i as attachSignature, n as UnsafeJsonLdError, o as createSignature, p as signJsonLd, s as detachSignature, u as hasSignatureLike } from "../ld-
|
|
10
|
+
import { a as compactJsonLd, f as isInvalidUrlTypeError, g as verifySignature, h as verifyJsonLd, i as attachSignature, n as UnsafeJsonLdError, o as createSignature, p as signJsonLd, s as detachSignature, u as hasSignatureLike } from "../ld-hwRDfZqq.mjs";
|
|
11
11
|
import { CryptographicKey } from "@fedify/vocab";
|
|
12
12
|
import { createTestMeterProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
13
13
|
import { encodeBase64 } from "byte-encodings/base64";
|
package/dist/sig/mod.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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_http = require("../http-
|
|
5
|
-
const require_proof = require("../proof-
|
|
4
|
+
const require_http = require("../http-CpdQD2ke.cjs");
|
|
5
|
+
const require_proof = require("../proof-BdnNZ9OM.cjs");
|
|
6
6
|
exports.attachSignature = require_proof.attachSignature;
|
|
7
7
|
exports.createProof = require_proof.createProof;
|
|
8
8
|
exports.createSignature = require_proof.createSignature;
|
package/dist/sig/mod.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import { A as formatAcceptSignature, M as parseAcceptSignature, N as validateAcceptSignature, a as verifyRequestDetailed, c as fetchKeyDetailed, i as verifyRequest, j as fulfillAcceptSignature, l as generateCryptoKeyPair, o as exportJwk, r as signRequest, s as fetchKey, u as importJwk } from "../http-
|
|
4
|
-
import { C as verifySignature, S as verifyJsonLd, _ as hasSignatureLike, a as verifyProof, b as signJsonLd, c as getKeyOwner, d as attachSignature, i as verifyObject, m as detachSignature, n as hasProofLike, p as createSignature, r as signObject, s as doesActorOwnKey, t as createProof } from "../proof-
|
|
3
|
+
import { A as formatAcceptSignature, M as parseAcceptSignature, N as validateAcceptSignature, a as verifyRequestDetailed, c as fetchKeyDetailed, i as verifyRequest, j as fulfillAcceptSignature, l as generateCryptoKeyPair, o as exportJwk, r as signRequest, s as fetchKey, u as importJwk } from "../http-DVZxcZEr.js";
|
|
4
|
+
import { C as verifySignature, S as verifyJsonLd, _ as hasSignatureLike, a as verifyProof, b as signJsonLd, c as getKeyOwner, d as attachSignature, i as verifyObject, m as detachSignature, n as hasProofLike, p as createSignature, r as signObject, s as doesActorOwnKey, t as createProof } from "../proof-C_kcg7vF.js";
|
|
5
5
|
export { attachSignature, createProof, createSignature, detachSignature, doesActorOwnKey, exportJwk, fetchKey, fetchKeyDetailed, formatAcceptSignature, fulfillAcceptSignature, generateCryptoKeyPair, getKeyOwner, hasProofLike, hasSignatureLike, importJwk, parseAcceptSignature, signJsonLd, signObject, signRequest, validateAcceptSignature, verifyJsonLd, verifyObject, verifyProof, verifyRequest, verifyRequestDetailed, verifySignature };
|
package/dist/sig/owner.test.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import "../std__assert-BBjXFNOb.mjs";
|
|
|
6
6
|
import { r as assertFalse } from "../assert_rejects-DN60FHPX.mjs";
|
|
7
7
|
import { t as assert } from "../assert-OguE97r2.mjs";
|
|
8
8
|
import { o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-DGu1NFwu.mjs";
|
|
9
|
-
import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-
|
|
9
|
+
import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-Btzxz2vj.mjs";
|
|
10
10
|
import { Create, CryptographicKey, lookupObject } from "@fedify/vocab";
|
|
11
11
|
import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
12
12
|
//#region src/sig/owner.test.ts
|
package/dist/sig/proof.test.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { t as assertInstanceOf } from "../assert_instance_of-DBC5X09g.mjs";
|
|
|
8
8
|
import { t as assert } from "../assert-OguE97r2.mjs";
|
|
9
9
|
import { i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-DGu1NFwu.mjs";
|
|
10
10
|
import { r as normalizeOutgoingActivityJsonLd } from "../outgoing-jsonld-L_DbOaFe.mjs";
|
|
11
|
-
import { a as verifyProof, i as verifyObject, n as hasProofLike, r as signObject, t as createProof } from "../proof-
|
|
11
|
+
import { a as verifyProof, i as verifyObject, n as hasProofLike, r as signObject, t as createProof } from "../proof-D2Z0Wa9X.mjs";
|
|
12
12
|
import { Create, DataIntegrityProof, Document, Multikey, Note, PUBLIC_COLLECTION, Place } from "@fedify/vocab";
|
|
13
13
|
import { createTestMeterProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
14
14
|
import { decodeMultibase, importMultibaseKey } from "@fedify/vocab-runtime";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { c as getNormalizationContextLoader } from "./ld-
|
|
4
|
+
import { c as getNormalizationContextLoader } from "./ld-hwRDfZqq.mjs";
|
|
5
5
|
import jsonld from "@fedify/vocab-runtime/jsonld";
|
|
6
6
|
//#region src/federation/temporal.ts
|
|
7
7
|
function isPlainObject(value) {
|
|
@@ -1,22 +1,79 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
3
|
import { getLogger } from "@logtape/logtape";
|
|
4
|
-
import { getUserAgent } from "@fedify/vocab-runtime";
|
|
4
|
+
import { UrlError, getUserAgent, validatePublicUrl } from "@fedify/vocab-runtime";
|
|
5
5
|
//#region src/nodeinfo/client.ts
|
|
6
6
|
const logger = getLogger([
|
|
7
7
|
"fedify",
|
|
8
8
|
"nodeinfo",
|
|
9
9
|
"client"
|
|
10
10
|
]);
|
|
11
|
+
const DEFAULT_MAX_REDIRECTION = 5;
|
|
12
|
+
/**
|
|
13
|
+
* Fetches a URL while guarding against SSRF. Before every request—including
|
|
14
|
+
* each redirect hop—the destination is validated with
|
|
15
|
+
* {@link validatePublicUrl}, so that loopback, link-local, and private
|
|
16
|
+
* addresses, as well as non-HTTP(S) schemes such as `data:`, are rejected.
|
|
17
|
+
* Redirects are followed manually with a cap, so that a public URL cannot
|
|
18
|
+
* bounce the request to an internal address.
|
|
19
|
+
* @param url The URL to fetch.
|
|
20
|
+
* @param headers The request headers.
|
|
21
|
+
* @returns The final response, or `null` if the URL is disallowed or there
|
|
22
|
+
* are too many redirects.
|
|
23
|
+
*/
|
|
24
|
+
async function fetchPublicUrl(url, headers) {
|
|
25
|
+
let current = url instanceof URL ? url : new URL(url);
|
|
26
|
+
let redirected = 0;
|
|
27
|
+
while (true) {
|
|
28
|
+
try {
|
|
29
|
+
await validatePublicUrl(current.href);
|
|
30
|
+
} catch (e) {
|
|
31
|
+
if (e instanceof UrlError) {
|
|
32
|
+
logger.error("Refused to fetch a private or invalid URL {url}: {error}", {
|
|
33
|
+
url: current.href,
|
|
34
|
+
error: e
|
|
35
|
+
});
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
throw e;
|
|
39
|
+
}
|
|
40
|
+
const response = await fetch(current, {
|
|
41
|
+
headers,
|
|
42
|
+
redirect: "manual"
|
|
43
|
+
});
|
|
44
|
+
if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
|
|
45
|
+
redirected++;
|
|
46
|
+
if (redirected >= DEFAULT_MAX_REDIRECTION) {
|
|
47
|
+
logger.error("Too many redirections ({redirections}) while fetching {url}.", {
|
|
48
|
+
redirections: redirected,
|
|
49
|
+
url: current.href
|
|
50
|
+
});
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
const next = new URL(response.headers.get("Location"), response.url == null || response.url === "" ? current : response.url);
|
|
54
|
+
if (next.protocol !== current.protocol) {
|
|
55
|
+
logger.error("Refused a redirect to a different protocol ({protocol} to {redirectedProtocol}) while fetching NodeInfo.", {
|
|
56
|
+
protocol: current.protocol,
|
|
57
|
+
redirectedProtocol: next.protocol
|
|
58
|
+
});
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
current = next;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
return response;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
11
67
|
async function getNodeInfo(url, options = {}) {
|
|
12
68
|
try {
|
|
13
69
|
let nodeInfoUrl = url;
|
|
14
70
|
if (!options.direct) {
|
|
15
71
|
const wellKnownUrl = new URL("/.well-known/nodeinfo", url);
|
|
16
|
-
const wellKnownResponse = await
|
|
72
|
+
const wellKnownResponse = await fetchPublicUrl(wellKnownUrl, {
|
|
17
73
|
Accept: "application/json",
|
|
18
74
|
"User-Agent": typeof options.userAgent === "string" ? options.userAgent : getUserAgent(options.userAgent)
|
|
19
|
-
}
|
|
75
|
+
});
|
|
76
|
+
if (wellKnownResponse == null) return void 0;
|
|
20
77
|
if (!wellKnownResponse.ok) {
|
|
21
78
|
logger.error("Failed to fetch {url}: {status} {statusText}", {
|
|
22
79
|
url: wellKnownUrl.href,
|
|
@@ -36,10 +93,11 @@ async function getNodeInfo(url, options = {}) {
|
|
|
36
93
|
}
|
|
37
94
|
nodeInfoUrl = link.href;
|
|
38
95
|
}
|
|
39
|
-
const response = await
|
|
96
|
+
const response = await fetchPublicUrl(nodeInfoUrl, {
|
|
40
97
|
Accept: "application/json",
|
|
41
98
|
"User-Agent": typeof options.userAgent === "string" ? options.userAgent : getUserAgent(options.userAgent)
|
|
42
|
-
}
|
|
99
|
+
});
|
|
100
|
+
if (response == null) return void 0;
|
|
43
101
|
if (!response.ok) {
|
|
44
102
|
logger.error("Failed to fetch NodeInfo document from {url}: {status} {statusText}", {
|
|
45
103
|
url: nodeInfoUrl.toString(),
|
|
@@ -9,15 +9,72 @@ const logger = (0, _logtape_logtape.getLogger)([
|
|
|
9
9
|
"nodeinfo",
|
|
10
10
|
"client"
|
|
11
11
|
]);
|
|
12
|
+
const DEFAULT_MAX_REDIRECTION = 5;
|
|
13
|
+
/**
|
|
14
|
+
* Fetches a URL while guarding against SSRF. Before every request—including
|
|
15
|
+
* each redirect hop—the destination is validated with
|
|
16
|
+
* {@link validatePublicUrl}, so that loopback, link-local, and private
|
|
17
|
+
* addresses, as well as non-HTTP(S) schemes such as `data:`, are rejected.
|
|
18
|
+
* Redirects are followed manually with a cap, so that a public URL cannot
|
|
19
|
+
* bounce the request to an internal address.
|
|
20
|
+
* @param url The URL to fetch.
|
|
21
|
+
* @param headers The request headers.
|
|
22
|
+
* @returns The final response, or `null` if the URL is disallowed or there
|
|
23
|
+
* are too many redirects.
|
|
24
|
+
*/
|
|
25
|
+
async function fetchPublicUrl(url, headers) {
|
|
26
|
+
let current = url instanceof URL ? url : new URL(url);
|
|
27
|
+
let redirected = 0;
|
|
28
|
+
while (true) {
|
|
29
|
+
try {
|
|
30
|
+
await (0, _fedify_vocab_runtime.validatePublicUrl)(current.href);
|
|
31
|
+
} catch (e) {
|
|
32
|
+
if (e instanceof _fedify_vocab_runtime.UrlError) {
|
|
33
|
+
logger.error("Refused to fetch a private or invalid URL {url}: {error}", {
|
|
34
|
+
url: current.href,
|
|
35
|
+
error: e
|
|
36
|
+
});
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
throw e;
|
|
40
|
+
}
|
|
41
|
+
const response = await fetch(current, {
|
|
42
|
+
headers,
|
|
43
|
+
redirect: "manual"
|
|
44
|
+
});
|
|
45
|
+
if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
|
|
46
|
+
redirected++;
|
|
47
|
+
if (redirected >= DEFAULT_MAX_REDIRECTION) {
|
|
48
|
+
logger.error("Too many redirections ({redirections}) while fetching {url}.", {
|
|
49
|
+
redirections: redirected,
|
|
50
|
+
url: current.href
|
|
51
|
+
});
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const next = new URL(response.headers.get("Location"), response.url == null || response.url === "" ? current : response.url);
|
|
55
|
+
if (next.protocol !== current.protocol) {
|
|
56
|
+
logger.error("Refused a redirect to a different protocol ({protocol} to {redirectedProtocol}) while fetching NodeInfo.", {
|
|
57
|
+
protocol: current.protocol,
|
|
58
|
+
redirectedProtocol: next.protocol
|
|
59
|
+
});
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
current = next;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
return response;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
12
68
|
async function getNodeInfo(url, options = {}) {
|
|
13
69
|
try {
|
|
14
70
|
let nodeInfoUrl = url;
|
|
15
71
|
if (!options.direct) {
|
|
16
72
|
const wellKnownUrl = new URL("/.well-known/nodeinfo", url);
|
|
17
|
-
const wellKnownResponse = await
|
|
73
|
+
const wellKnownResponse = await fetchPublicUrl(wellKnownUrl, {
|
|
18
74
|
Accept: "application/json",
|
|
19
75
|
"User-Agent": typeof options.userAgent === "string" ? options.userAgent : (0, _fedify_vocab_runtime.getUserAgent)(options.userAgent)
|
|
20
|
-
}
|
|
76
|
+
});
|
|
77
|
+
if (wellKnownResponse == null) return void 0;
|
|
21
78
|
if (!wellKnownResponse.ok) {
|
|
22
79
|
logger.error("Failed to fetch {url}: {status} {statusText}", {
|
|
23
80
|
url: wellKnownUrl.href,
|
|
@@ -37,10 +94,11 @@ async function getNodeInfo(url, options = {}) {
|
|
|
37
94
|
}
|
|
38
95
|
nodeInfoUrl = link.href;
|
|
39
96
|
}
|
|
40
|
-
const response = await
|
|
97
|
+
const response = await fetchPublicUrl(nodeInfoUrl, {
|
|
41
98
|
Accept: "application/json",
|
|
42
99
|
"User-Agent": typeof options.userAgent === "string" ? options.userAgent : (0, _fedify_vocab_runtime.getUserAgent)(options.userAgent)
|
|
43
|
-
}
|
|
100
|
+
});
|
|
101
|
+
if (response == null) return void 0;
|
|
44
102
|
if (!response.ok) {
|
|
45
103
|
logger.error("Failed to fetch NodeInfo document from {url}: {status} {statusText}", {
|
|
46
104
|
url: nodeInfoUrl.toString(),
|
|
@@ -5,9 +5,9 @@ import { t as esm_default } from "../esm-vrlUxr60.mjs";
|
|
|
5
5
|
import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
6
6
|
import "../std__assert-BBjXFNOb.mjs";
|
|
7
7
|
import { t as assertRejects } from "../assert_rejects-DN60FHPX.mjs";
|
|
8
|
-
import { l as verifyRequest } from "../http-
|
|
8
|
+
import { l as verifyRequest } from "../http-DlSQMJsb.mjs";
|
|
9
9
|
import { i as rsaPrivateKey2 } from "../keys-DGu1NFwu.mjs";
|
|
10
|
-
import { t as getAuthenticatedDocumentLoader } from "../docloader-
|
|
10
|
+
import { t as getAuthenticatedDocumentLoader } from "../docloader-BMjxpyJD.mjs";
|
|
11
11
|
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
12
12
|
import { UrlError } from "@fedify/vocab-runtime";
|
|
13
13
|
//#region src/utils/docloader.test.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as kvCache, t as MockKvStore } from "../kv-cache-
|
|
4
|
+
import { n as kvCache, t as MockKvStore } from "../kv-cache-BD6BgCTF.mjs";
|
|
5
5
|
import { deepStrictEqual, throws } from "node:assert";
|
|
6
6
|
import { createTestMeterProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
7
7
|
import { preloadedContexts } from "@fedify/vocab-runtime";
|
package/dist/utils/mod.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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_kv_cache = require("../kv-cache-
|
|
4
|
+
const require_kv_cache = require("../kv-cache-B8gm4cVB.cjs");
|
|
5
5
|
exports.getAuthenticatedDocumentLoader = require_kv_cache.getAuthenticatedDocumentLoader;
|
|
6
6
|
exports.kvCache = require_kv_cache.kvCache;
|
package/dist/utils/mod.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import { n as getAuthenticatedDocumentLoader, t as kvCache } from "../kv-cache-
|
|
3
|
+
import { n as getAuthenticatedDocumentLoader, t as kvCache } from "../kv-cache-B52kTPj4.js";
|
|
4
4
|
export { getAuthenticatedDocumentLoader, kvCache };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/fedify",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.2",
|
|
4
4
|
"description": "An ActivityPub server framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ActivityPub",
|
|
@@ -152,10 +152,10 @@
|
|
|
152
152
|
"jsonld": "^9.0.0",
|
|
153
153
|
"structured-field-values": "^2.0.4",
|
|
154
154
|
"urlpattern-polyfill": "^10.1.0",
|
|
155
|
-
"@fedify/
|
|
156
|
-
"@fedify/vocab": "2.3.
|
|
157
|
-
"@fedify/
|
|
158
|
-
"@fedify/
|
|
155
|
+
"@fedify/vocab": "2.3.2",
|
|
156
|
+
"@fedify/vocab-runtime": "2.3.2",
|
|
157
|
+
"@fedify/uri-template": "2.3.2",
|
|
158
|
+
"@fedify/webfinger": "2.3.2"
|
|
159
159
|
},
|
|
160
160
|
"devDependencies": {
|
|
161
161
|
"@std/assert": "npm:@jsr/std__assert@^0.226.0",
|
|
@@ -168,7 +168,7 @@
|
|
|
168
168
|
"typescript": "^6.0.0",
|
|
169
169
|
"wrangler": "^4.17.0",
|
|
170
170
|
"@fedify/fixture": "2.0.0",
|
|
171
|
-
"@fedify/vocab-tools": "^2.3.
|
|
171
|
+
"@fedify/vocab-tools": "^2.3.2"
|
|
172
172
|
},
|
|
173
173
|
"scripts": {
|
|
174
174
|
"build:self": "tsdown",
|