@fedify/fedify 2.2.13 → 2.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{builder-uTlVksLw.mjs → builder-ky-Enw7B.mjs} +2 -2
- package/dist/{client-CQ7zd8tW.mjs → client-CJ4Y0keQ.mjs} +7 -3
- package/dist/compat/transformers.test.mjs +1 -1
- package/dist/{deno-Cg_cZHcI.mjs → deno-BnfWZfzD.mjs} +1 -1
- package/dist/docloader-Ctm-HtB1.mjs +79 -0
- package/dist/federation/builder.test.mjs +2 -2
- package/dist/federation/collection.test.mjs +1 -1
- package/dist/federation/handler.test.mjs +6 -6
- package/dist/federation/idempotency.test.mjs +3 -3
- package/dist/federation/kv.test.mjs +1 -1
- package/dist/federation/middleware.test.mjs +134 -7
- package/dist/federation/mod.cjs +1 -1
- package/dist/federation/mod.js +1 -1
- package/dist/federation/mq.test.mjs +98 -43
- package/dist/federation/negotiation.test.mjs +1 -1
- package/dist/federation/router.test.mjs +1 -1
- package/dist/federation/send.test.mjs +68 -5
- package/dist/federation/temporal.test.mjs +2 -2
- package/dist/federation/webfinger.test.mjs +2 -2
- package/dist/{http-DaLdtguq.js → http-BBGyG2ez.js} +6 -2
- package/dist/{http-BdbKIiay.cjs → http-DXyLMSXp.cjs} +6 -2
- package/dist/{http-B3V9unT4.mjs → http-xscrPdwI.mjs} +7 -3
- package/dist/{key-CLRfRmA_.mjs → key-DwyWxSP6.mjs} +1 -1
- package/dist/{kv-cache-K6eHO_YH.cjs → kv-cache-BATy5Vhq.cjs} +34 -8
- package/dist/{kv-cache-TPuR5wYg.js → kv-cache-D_17I8jy.js} +35 -9
- package/dist/{ld-C0s4f-GU.mjs → ld-CQLGYzwy.mjs} +3 -3
- package/dist/{middleware-BDc7xyOx.cjs → middleware-BbomR2ro.cjs} +14 -5
- package/dist/{middleware-BDRZkGPG.js → middleware-CdgK6YM3.js} +13 -4
- package/dist/{middleware-D6bGiZn6.cjs → middleware-DRzTRfmd.cjs} +1 -1
- package/dist/{middleware-BsDiZP9H.mjs → middleware-Dv-j_sRD.mjs} +11 -11
- package/dist/{middleware-uaOjlLEG.mjs → middleware-kjzamfZM.mjs} +1 -1
- package/dist/{mod-DzPMtIV3.d.cts → mod-BYg1qMPB.d.cts} +2 -0
- package/dist/{mod-0MWo2Nu5.d.ts → mod-C9jqpInC.d.ts} +2 -0
- package/dist/mod.cjs +5 -5
- package/dist/mod.d.cts +1 -1
- package/dist/mod.d.ts +1 -1
- package/dist/mod.js +5 -5
- package/dist/nodeinfo/client.test.mjs +50 -2
- package/dist/nodeinfo/handler.test.mjs +2 -2
- package/dist/nodeinfo/mod.cjs +1 -1
- package/dist/nodeinfo/mod.js +1 -1
- package/dist/nodeinfo/types.test.mjs +1 -1
- package/dist/otel/exporter.test.mjs +1 -1
- package/dist/{owner-DLbN_4jZ.mjs → owner-pFTUYlVh.mjs} +2 -2
- package/dist/{proof-CqyprEYB.js → proof-BCHw9az4.js} +2 -2
- package/dist/{proof-CTIG9UEI.cjs → proof-BLZMJa2g.cjs} +2 -2
- package/dist/{proof-CW3Zrxmd.mjs → proof-CJxlMyX3.mjs} +2 -2
- package/dist/{send-B5QvdrZ1.mjs → send-C_Pfo7Lr.mjs} +12 -3
- package/dist/sig/http.test.mjs +43 -3
- package/dist/sig/key.test.mjs +2 -2
- package/dist/sig/ld.test.mjs +5 -2
- package/dist/sig/mod.cjs +2 -2
- package/dist/sig/mod.js +2 -2
- package/dist/sig/owner.test.mjs +2 -2
- package/dist/sig/proof.test.mjs +2 -2
- package/dist/{std__assert-CRDpx_HF.mjs → std__assert-BVFj8-_V.mjs} +1 -26
- package/dist/{temporal-CFLRXAcm.mjs → temporal-DA4sccOr.mjs} +1 -1
- package/dist/{types-DWs-qZaY.cjs → types-DRPjmHVV.cjs} +7 -3
- package/dist/{types-sXITXcWa.js → types-miAYfiGO.js} +7 -3
- package/dist/utils/docloader.test.mjs +299 -3
- package/dist/utils/mod.cjs +1 -1
- package/dist/utils/mod.d.cts +1 -1
- package/dist/utils/mod.d.ts +1 -1
- package/dist/utils/mod.js +1 -1
- package/dist/vocab/cjs.test.mjs +1 -1
- package/package.json +6 -6
- package/dist/docloader-BwXP5fDH.mjs +0 -53
|
@@ -3,9 +3,13 @@ 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-
|
|
7
|
-
import {
|
|
6
|
+
import "../std__assert-BVFj8-_V.mjs";
|
|
7
|
+
import { n as assertInstanceOf } from "../assert-BhQd8QHP.mjs";
|
|
8
|
+
import { a as parseProtocol, c as parseUsage, i as parseOutboundService, n as parseInboundService, o as parseServices, r as parseNodeInfo, s as parseSoftware, t as getNodeInfo } from "../client-CJ4Y0keQ.mjs";
|
|
8
9
|
import { test } from "@fedify/fixture";
|
|
10
|
+
import { UrlError } from "@fedify/vocab-runtime";
|
|
11
|
+
import { configure, reset } from "@logtape/logtape";
|
|
12
|
+
import dns from "node:dns/promises";
|
|
9
13
|
//#region src/nodeinfo/client.test.ts
|
|
10
14
|
test("getNodeInfo()", async (t) => {
|
|
11
15
|
esm_default.spyGlobal();
|
|
@@ -994,5 +998,49 @@ test("getNodeInfo() bounds both discovery and document responses", async () => {
|
|
|
994
998
|
esm_default.hardReset();
|
|
995
999
|
}
|
|
996
1000
|
});
|
|
1001
|
+
test("getNodeInfo() logs DNS failures as such", { ignore: "Deno" in globalThis && (await Deno.permissions.query({ name: "net" })).state !== "granted" }, async (t) => {
|
|
1002
|
+
for (const result of [
|
|
1003
|
+
"throws",
|
|
1004
|
+
"empty",
|
|
1005
|
+
"private"
|
|
1006
|
+
]) await t.step(result, async () => {
|
|
1007
|
+
const originalLookup = dns.lookup;
|
|
1008
|
+
dns.lookup = (() => result === "throws" ? Promise.reject(/* @__PURE__ */ new Error("Resolver unavailable")) : Promise.resolve(result === "empty" ? [] : [{
|
|
1009
|
+
address: "127.0.0.1",
|
|
1010
|
+
family: 4
|
|
1011
|
+
}]));
|
|
1012
|
+
const records = [];
|
|
1013
|
+
await configure({
|
|
1014
|
+
sinks: { buffer: (record) => records.push(record) },
|
|
1015
|
+
loggers: [{
|
|
1016
|
+
category: "fedify",
|
|
1017
|
+
sinks: ["buffer"],
|
|
1018
|
+
lowestLevel: "debug"
|
|
1019
|
+
}, {
|
|
1020
|
+
category: ["logtape", "meta"],
|
|
1021
|
+
sinks: []
|
|
1022
|
+
}],
|
|
1023
|
+
reset: true
|
|
1024
|
+
});
|
|
1025
|
+
try {
|
|
1026
|
+
assertEquals(await getNodeInfo("https://dns-failure.invalid/"), void 0);
|
|
1027
|
+
assertEquals(records.map((r) => [
|
|
1028
|
+
r.level,
|
|
1029
|
+
r.rawMessage,
|
|
1030
|
+
r.properties.url
|
|
1031
|
+
]), [[
|
|
1032
|
+
"error",
|
|
1033
|
+
result === "private" ? "Refused to fetch a private or invalid URL {url}: {error}" : "DNS lookup failed for {url}: {error}",
|
|
1034
|
+
"https://dns-failure.invalid/.well-known/nodeinfo"
|
|
1035
|
+
]]);
|
|
1036
|
+
const { error } = records[0].properties;
|
|
1037
|
+
assertInstanceOf(error, UrlError);
|
|
1038
|
+
assertEquals(error.reason, result === "private" ? "disallowed" : "dns");
|
|
1039
|
+
} finally {
|
|
1040
|
+
await reset();
|
|
1041
|
+
dns.lookup = originalLookup;
|
|
1042
|
+
}
|
|
1043
|
+
});
|
|
1044
|
+
});
|
|
997
1045
|
//#endregion
|
|
998
1046
|
export {};
|
|
@@ -3,9 +3,9 @@ import "urlpattern-polyfill";
|
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { r as createRequestContext } from "../context-Dk_tacqz.mjs";
|
|
5
5
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
6
|
-
import "../std__assert-
|
|
6
|
+
import "../std__assert-BVFj8-_V.mjs";
|
|
7
7
|
import { t as MemoryKvStore } from "../kv-CX8qfaad.mjs";
|
|
8
|
-
import { _ as handleNodeInfoJrd, g as handleNodeInfo, o as createFederation } from "../middleware-
|
|
8
|
+
import { _ as handleNodeInfoJrd, g as handleNodeInfo, o as createFederation } from "../middleware-Dv-j_sRD.mjs";
|
|
9
9
|
import { test } from "@fedify/fixture";
|
|
10
10
|
//#region src/nodeinfo/handler.test.ts
|
|
11
11
|
test("handleNodeInfo()", async () => {
|
package/dist/nodeinfo/mod.cjs
CHANGED
|
@@ -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_types = require("../types-
|
|
4
|
+
const require_types = require("../types-DRPjmHVV.cjs");
|
|
5
5
|
exports.getNodeInfo = require_types.getNodeInfo;
|
|
6
6
|
exports.nodeInfoToJson = require_types.nodeInfoToJson;
|
|
7
7
|
exports.parseNodeInfo = require_types.parseNodeInfo;
|
package/dist/nodeinfo/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 getNodeInfo, r as parseNodeInfo, t as nodeInfoToJson } from "../types-
|
|
3
|
+
import { n as getNodeInfo, r as parseNodeInfo, t as nodeInfoToJson } from "../types-miAYfiGO.js";
|
|
4
4
|
export { getNodeInfo, nodeInfoToJson, parseNodeInfo };
|
|
@@ -2,7 +2,7 @@ import "@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 "../std__assert-
|
|
5
|
+
import "../std__assert-BVFj8-_V.mjs";
|
|
6
6
|
import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
|
|
7
7
|
import { t as nodeInfoToJson } from "../types-s4mCTGkT.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 { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
5
|
-
import "../std__assert-
|
|
5
|
+
import "../std__assert-BVFj8-_V.mjs";
|
|
6
6
|
import { t as MemoryKvStore } from "../kv-CX8qfaad.mjs";
|
|
7
7
|
import { test } from "@fedify/fixture";
|
|
8
8
|
import { SpanKind, SpanStatusCode, TraceFlags } from "@opentelemetry/api";
|
|
@@ -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-
|
|
5
|
-
import { c as verifyKeyOwnership, n as fetchActorDocument, t as exportJwk } from "./key-
|
|
4
|
+
import { n as version, t as name } from "./deno-BnfWZfzD.mjs";
|
|
5
|
+
import { c as verifyKeyOwnership, n as fetchActorDocument, t as exportJwk } from "./key-DwyWxSP6.mjs";
|
|
6
6
|
import { CryptographicKey, Object as Object$1, isActor } from "@fedify/vocab";
|
|
7
7
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
8
8
|
import { getDocumentLoader } from "@fedify/vocab-runtime";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import { c as fetchKey, f as validateCryptoKey, o as exportJwk, p as verifyKeyOwnership, s as fetchActorDocument, v as name, y as version } from "./http-
|
|
3
|
+
import { c as fetchKey, f as validateCryptoKey, o as exportJwk, p as verifyKeyOwnership, s as fetchActorDocument, v as name, y as version } from "./http-BBGyG2ez.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";
|
|
@@ -202,7 +202,7 @@ function normalizeContextReference(reference, baseUrl) {
|
|
|
202
202
|
/** @internal */
|
|
203
203
|
function isInvalidUrlTypeError(error) {
|
|
204
204
|
const code = error.code;
|
|
205
|
-
return error instanceof TypeError && (code === "ERR_INVALID_URL" || /^Invalid URL(?::|$)/.test(error.message) || / cannot be parsed as a URL\.?$/.test(error.message));
|
|
205
|
+
return error instanceof TypeError && (code === "ERR_INVALID_URL" || error.message === "Invalid URL string." || /^Invalid URL(?::|$)/.test(error.message) || / cannot be parsed as a URL\.?$/.test(error.message));
|
|
206
206
|
}
|
|
207
207
|
async function applyGraphAliasContext(state, context, documentLoader, remoteContextCache, baseUrl = null, processingContexts = /* @__PURE__ */ new Set()) {
|
|
208
208
|
if (context === null) return createGraphAliasContextState();
|
|
@@ -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-DXyLMSXp.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");
|
|
@@ -205,7 +205,7 @@ function normalizeContextReference(reference, baseUrl) {
|
|
|
205
205
|
/** @internal */
|
|
206
206
|
function isInvalidUrlTypeError(error) {
|
|
207
207
|
const code = error.code;
|
|
208
|
-
return error instanceof TypeError && (code === "ERR_INVALID_URL" || /^Invalid URL(?::|$)/.test(error.message) || / cannot be parsed as a URL\.?$/.test(error.message));
|
|
208
|
+
return error instanceof TypeError && (code === "ERR_INVALID_URL" || error.message === "Invalid URL string." || /^Invalid URL(?::|$)/.test(error.message) || / cannot be parsed as a URL\.?$/.test(error.message));
|
|
209
209
|
}
|
|
210
210
|
async function applyGraphAliasContext(state, context, documentLoader, remoteContextCache, baseUrl = null, processingContexts = /* @__PURE__ */ new Set()) {
|
|
211
211
|
if (context === null) return createGraphAliasContextState();
|
|
@@ -1,8 +1,8 @@
|
|
|
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 { r as fetchKey, s as validateCryptoKey } from "./key-
|
|
4
|
+
import { n as version, t as name } from "./deno-BnfWZfzD.mjs";
|
|
5
|
+
import { r as fetchKey, s as validateCryptoKey } from "./key-DwyWxSP6.mjs";
|
|
6
6
|
import { n as preloadedOnlyDocumentLoader } from "./public-audience-CS1udGkN.mjs";
|
|
7
7
|
import { r as normalizeOutgoingActivityJsonLd } from "./outgoing-jsonld-Dc2OXyB-.mjs";
|
|
8
8
|
import { Activity, DataIntegrityProof, Multikey, getTypeId } from "@fedify/vocab";
|
|
@@ -1,10 +1,10 @@
|
|
|
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 doubleKnock } from "./http-
|
|
4
|
+
import { n as version, t as name } from "./deno-BnfWZfzD.mjs";
|
|
5
|
+
import { n as doubleKnock } from "./http-xscrPdwI.mjs";
|
|
6
6
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
7
|
-
import { UrlError, validatePublicUrl } from "@fedify/vocab-runtime";
|
|
7
|
+
import { FetchError, UrlError, validatePublicUrl } from "@fedify/vocab-runtime";
|
|
8
8
|
import { getLogger } from "@logtape/logtape";
|
|
9
9
|
//#region src/federation/send.ts
|
|
10
10
|
/**
|
|
@@ -102,6 +102,15 @@ async function sendActivityInternal({ activity, activityId, keys, inbox, allowPr
|
|
|
102
102
|
if (!allowPrivateAddress) try {
|
|
103
103
|
await validatePublicUrl(url);
|
|
104
104
|
} catch (error) {
|
|
105
|
+
if (error instanceof UrlError && error.reason === "dns") {
|
|
106
|
+
logger.error("DNS resolution failed for URL: {url}", {
|
|
107
|
+
url,
|
|
108
|
+
error
|
|
109
|
+
});
|
|
110
|
+
const failure = new FetchError(url, error.message);
|
|
111
|
+
failure.cause = error;
|
|
112
|
+
throw failure;
|
|
113
|
+
}
|
|
105
114
|
if (error instanceof UrlError) logger.error("Disallowed private URL: {url}", {
|
|
106
115
|
url,
|
|
107
116
|
error
|
package/dist/sig/http.test.mjs
CHANGED
|
@@ -3,12 +3,12 @@ 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 {
|
|
6
|
+
import { r as assertExists, t as assertStringIncludes } from "../std__assert-BVFj8-_V.mjs";
|
|
7
7
|
import { n as assertFalse, t as assertRejects } from "../assert_rejects-B-qJtC9Z.mjs";
|
|
8
8
|
import { t as assert } from "../assert-BhQd8QHP.mjs";
|
|
9
9
|
import { t as assertThrows } from "../assert_throws-4NwKEy2q.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-DwyWxSP6.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-xscrPdwI.mjs";
|
|
12
12
|
import { i as rsaPrivateKey2, l as rsaPublicKey5, o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-BAK-tUlf.mjs";
|
|
13
13
|
import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
14
14
|
import { FetchError, exportSpki } from "@fedify/vocab-runtime";
|
|
@@ -421,6 +421,46 @@ test("verifyRequest() [rfc9421] successful GET verification", async () => {
|
|
|
421
421
|
currentTime: Temporal.Instant.from(`${(/* @__PURE__ */ new Date(currentTimestamp * 1e3)).toISOString()}`)
|
|
422
422
|
}), rsaPublicKey2, "Valid signature should verify to the correct public key");
|
|
423
423
|
});
|
|
424
|
+
for (const failure of [
|
|
425
|
+
"missing key",
|
|
426
|
+
"invalid signature",
|
|
427
|
+
"digest mismatch",
|
|
428
|
+
"empty body",
|
|
429
|
+
"cached key"
|
|
430
|
+
]) test(`verifyRequest() [rfc9421] multiple POST signatures: ${failure}`, async () => {
|
|
431
|
+
const body = failure === "empty body" ? "" : "Hello, world!";
|
|
432
|
+
const currentTime = Temporal.Instant.from("2024-03-05T08:09:44Z");
|
|
433
|
+
const signed = await signRequest(new Request("https://example.com/inbox", {
|
|
434
|
+
method: "POST",
|
|
435
|
+
body
|
|
436
|
+
}), rsaPrivateKey2, new URL("https://example.com/key2"), {
|
|
437
|
+
spec: "rfc9421",
|
|
438
|
+
currentTime
|
|
439
|
+
});
|
|
440
|
+
const input = signed.headers.get("Signature-Input");
|
|
441
|
+
const signature = signed.headers.get("Signature");
|
|
442
|
+
const firstInput = failure === "missing key" ? input.replace("https://example.com/key2", "https://example.com/missing-key") : input;
|
|
443
|
+
signed.headers.set("Signature-Input", `${firstInput}, ${input.replace(/^sig1=/, "sig2=")}`);
|
|
444
|
+
signed.headers.set("Signature", `sig1=:AAAAAA==:, ${signature.replace(/^sig1=/, "sig2=")}`);
|
|
445
|
+
const request = failure === "digest mismatch" ? new Request(signed, { body: "Tampered body" }) : signed;
|
|
446
|
+
const loaded = [];
|
|
447
|
+
assertEquals(await verifyRequest(request, {
|
|
448
|
+
keyCache: failure === "cached key" ? {
|
|
449
|
+
get: () => Promise.resolve(rsaPublicKey1),
|
|
450
|
+
set: async () => {}
|
|
451
|
+
} : void 0,
|
|
452
|
+
spec: "rfc9421",
|
|
453
|
+
currentTime,
|
|
454
|
+
contextLoader: mockDocumentLoader,
|
|
455
|
+
documentLoader: (url, options) => {
|
|
456
|
+
loaded.push(url);
|
|
457
|
+
return mockDocumentLoader(url, options);
|
|
458
|
+
}
|
|
459
|
+
}), failure === "digest mismatch" ? null : rsaPublicKey2);
|
|
460
|
+
assertEquals(loaded, failure === "digest mismatch" ? [] : failure === "missing key" ? ["https://example.com/missing-key", "https://example.com/key2"] : ["https://example.com/key2", "https://example.com/key2"]);
|
|
461
|
+
assertFalse(request.bodyUsed);
|
|
462
|
+
assertEquals(await request.text(), failure === "digest mismatch" ? "Tampered body" : body);
|
|
463
|
+
});
|
|
424
464
|
test("verifyRequest() [rfc9421] manual POST verification", async () => {
|
|
425
465
|
const currentTimestamp = 1709626184;
|
|
426
466
|
const currentTime = Temporal.Instant.from("2024-03-05T08:09:44Z");
|
package/dist/sig/key.test.mjs
CHANGED
|
@@ -2,11 +2,11 @@ import "@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 "../std__assert-
|
|
5
|
+
import "../std__assert-BVFj8-_V.mjs";
|
|
6
6
|
import { t as assertRejects } from "../assert_rejects-B-qJtC9Z.mjs";
|
|
7
7
|
import { t as assert } from "../assert-BhQd8QHP.mjs";
|
|
8
8
|
import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
|
|
9
|
-
import { a as generateCryptoKeyPair, i as fetchKeyDetailed, o as importJwk, r as fetchKey, s as validateCryptoKey, t as exportJwk } from "../key-
|
|
9
|
+
import { a as generateCryptoKeyPair, i as fetchKeyDetailed, o as importJwk, r as fetchKey, s as validateCryptoKey, t as exportJwk } from "../key-DwyWxSP6.mjs";
|
|
10
10
|
import { c as rsaPublicKey3, i as rsaPrivateKey2, o as rsaPublicKey1, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-BAK-tUlf.mjs";
|
|
11
11
|
import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
12
12
|
import { CryptographicKey, Multikey } from "@fedify/vocab";
|
package/dist/sig/ld.test.mjs
CHANGED
|
@@ -5,14 +5,17 @@ import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
|
5
5
|
import { n as assertFalse, t as assertRejects } from "../assert_rejects-B-qJtC9Z.mjs";
|
|
6
6
|
import { n as assertInstanceOf, t as assert } from "../assert-BhQd8QHP.mjs";
|
|
7
7
|
import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
|
|
8
|
-
import { a as generateCryptoKeyPair } from "../key-
|
|
8
|
+
import { a as generateCryptoKeyPair } from "../key-DwyWxSP6.mjs";
|
|
9
9
|
import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-BAK-tUlf.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-CQLGYzwy.mjs";
|
|
11
11
|
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
12
12
|
import { CryptographicKey } from "@fedify/vocab";
|
|
13
13
|
import { encodeBase64 } from "byte-encodings/base64";
|
|
14
14
|
//#region src/sig/ld.test.ts
|
|
15
15
|
test("isInvalidUrlTypeError()", () => {
|
|
16
|
+
assert(isInvalidUrlTypeError(/* @__PURE__ */ new TypeError("Invalid URL string.")));
|
|
17
|
+
assertFalse(isInvalidUrlTypeError(/* @__PURE__ */ new Error("Invalid URL string.")));
|
|
18
|
+
assertFalse(isInvalidUrlTypeError(/* @__PURE__ */ new TypeError("Invalid URL string. Other error")));
|
|
16
19
|
assert(isInvalidUrlTypeError(/* @__PURE__ */ new TypeError("Invalid URL: http://[")));
|
|
17
20
|
assert(isInvalidUrlTypeError(/* @__PURE__ */ new TypeError("\"http://[\" cannot be parsed as a URL.")));
|
|
18
21
|
const error = /* @__PURE__ */ new TypeError("Failed to parse URL");
|
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-DXyLMSXp.cjs");
|
|
5
|
+
const require_proof = require("../proof-BLZMJa2g.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 { _ as validateAcceptSignature, a as verifyRequestDetailed, c as fetchKey, d as importJwk, g as parseAcceptSignature, h as fulfillAcceptSignature, i as verifyRequest, l as fetchKeyDetailed, m as formatAcceptSignature, o as exportJwk, r as signRequest, u as generateCryptoKeyPair } 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 { _ as validateAcceptSignature, a as verifyRequestDetailed, c as fetchKey, d as importJwk, g as parseAcceptSignature, h as fulfillAcceptSignature, i as verifyRequest, l as fetchKeyDetailed, m as formatAcceptSignature, o as exportJwk, r as signRequest, u as generateCryptoKeyPair } from "../http-BBGyG2ez.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-BCHw9az4.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
|
@@ -2,11 +2,11 @@ import "@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 "../std__assert-
|
|
5
|
+
import "../std__assert-BVFj8-_V.mjs";
|
|
6
6
|
import { n as assertFalse } from "../assert_rejects-B-qJtC9Z.mjs";
|
|
7
7
|
import { t as assert } from "../assert-BhQd8QHP.mjs";
|
|
8
8
|
import { o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-BAK-tUlf.mjs";
|
|
9
|
-
import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-
|
|
9
|
+
import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-pFTUYlVh.mjs";
|
|
10
10
|
import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
11
11
|
import { Create, CryptographicKey, lookupObject } from "@fedify/vocab";
|
|
12
12
|
//#region src/sig/owner.test.ts
|
package/dist/sig/proof.test.mjs
CHANGED
|
@@ -2,12 +2,12 @@ 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 "../std__assert-
|
|
5
|
+
import "../std__assert-BVFj8-_V.mjs";
|
|
6
6
|
import { n as assertFalse, t as assertRejects } from "../assert_rejects-B-qJtC9Z.mjs";
|
|
7
7
|
import { n as assertInstanceOf, t as assert } from "../assert-BhQd8QHP.mjs";
|
|
8
8
|
import { i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-BAK-tUlf.mjs";
|
|
9
9
|
import { r as normalizeOutgoingActivityJsonLd } from "../outgoing-jsonld-Dc2OXyB-.mjs";
|
|
10
|
-
import { a as verifyProof, i as verifyObject, n as hasProofLike, r as signObject, t as createProof } from "../proof-
|
|
10
|
+
import { a as verifyProof, i as verifyObject, n as hasProofLike, r as signObject, t as createProof } from "../proof-CJxlMyX3.mjs";
|
|
11
11
|
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
12
12
|
import { Create, DataIntegrityProof, Document, Multikey, Note, PUBLIC_COLLECTION, Place } from "@fedify/vocab";
|
|
13
13
|
import { decodeMultibase, importMultibaseKey } from "@fedify/vocab-runtime";
|
|
@@ -53,31 +53,6 @@ import "./assert_strict_equals-Dmjbg-bA.mjs";
|
|
|
53
53
|
throw new AssertionError(msg ?? `Expect ${actualString} >= ${expectedString}`);
|
|
54
54
|
}
|
|
55
55
|
//#endregion
|
|
56
|
-
//#region ../../node_modules/.pnpm/@jsr+std__assert@0.226.0/node_modules/@jsr/std__assert/assert_greater.js
|
|
57
|
-
/**
|
|
58
|
-
* Make an assertion that `actual` is greater than `expected`.
|
|
59
|
-
* If not then throw.
|
|
60
|
-
*
|
|
61
|
-
* @example Usage
|
|
62
|
-
* ```ts no-eval
|
|
63
|
-
* import { assertGreater } from "@std/assert/assert-greater";
|
|
64
|
-
*
|
|
65
|
-
* assertGreater(2, 1); // Doesn't throw
|
|
66
|
-
* assertGreater(1, 1); // Throws
|
|
67
|
-
* assertGreater(0, 1); // Throws
|
|
68
|
-
* ```
|
|
69
|
-
*
|
|
70
|
-
* @typeParam T The type of the values to compare.
|
|
71
|
-
* @param actual The actual value to compare.
|
|
72
|
-
* @param expected The expected value to compare.
|
|
73
|
-
* @param msg The optional message to display if the assertion fails.
|
|
74
|
-
*/ function assertGreater(actual, expected, msg) {
|
|
75
|
-
if (actual > expected) return;
|
|
76
|
-
const actualString = format(actual);
|
|
77
|
-
const expectedString = format(expected);
|
|
78
|
-
throw new AssertionError(msg ?? `Expect ${actualString} > ${expectedString}`);
|
|
79
|
-
}
|
|
80
|
-
//#endregion
|
|
81
56
|
//#region ../../node_modules/.pnpm/@jsr+std__assert@0.226.0/node_modules/@jsr/std__assert/assert_string_includes.js
|
|
82
57
|
/**
|
|
83
58
|
* Make an assertion that actual includes expected. If not
|
|
@@ -101,4 +76,4 @@ import "./assert_strict_equals-Dmjbg-bA.mjs";
|
|
|
101
76
|
}
|
|
102
77
|
}
|
|
103
78
|
//#endregion
|
|
104
|
-
export {
|
|
79
|
+
export { assertGreaterOrEqual as n, assertExists as r, assertStringIncludes as t };
|
|
@@ -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-CQLGYzwy.mjs";
|
|
5
5
|
import jsonld from "@fedify/vocab-runtime/jsonld";
|
|
6
6
|
//#region src/federation/temporal.ts
|
|
7
7
|
function isPlainObject(value) {
|
|
@@ -93,8 +93,8 @@ const DEFAULT_MAX_REDIRECTION = 5;
|
|
|
93
93
|
* bounce the request to an internal address.
|
|
94
94
|
* @param url The URL to fetch.
|
|
95
95
|
* @param headers The request headers.
|
|
96
|
-
* @returns The final response, or `null` if the URL is disallowed
|
|
97
|
-
* are too many redirects.
|
|
96
|
+
* @returns The final response, or `null` if the URL is disallowed, its
|
|
97
|
+
* hostname cannot be resolved, or there are too many redirects.
|
|
98
98
|
*/
|
|
99
99
|
async function fetchPublicUrl(url, headers) {
|
|
100
100
|
let current = url instanceof URL ? url : new URL(url);
|
|
@@ -104,7 +104,11 @@ async function fetchPublicUrl(url, headers) {
|
|
|
104
104
|
await (0, _fedify_vocab_runtime.validatePublicUrl)(current.href);
|
|
105
105
|
} catch (e) {
|
|
106
106
|
if (e instanceof _fedify_vocab_runtime.UrlError) {
|
|
107
|
-
logger.error("
|
|
107
|
+
if (e.reason === "dns") logger.error("DNS lookup failed for {url}: {error}", {
|
|
108
|
+
url: current.href,
|
|
109
|
+
error: e
|
|
110
|
+
});
|
|
111
|
+
else logger.error("Refused to fetch a private or invalid URL {url}: {error}", {
|
|
108
112
|
url: current.href,
|
|
109
113
|
error: e
|
|
110
114
|
});
|
|
@@ -92,8 +92,8 @@ const DEFAULT_MAX_REDIRECTION = 5;
|
|
|
92
92
|
* bounce the request to an internal address.
|
|
93
93
|
* @param url The URL to fetch.
|
|
94
94
|
* @param headers The request headers.
|
|
95
|
-
* @returns The final response, or `null` if the URL is disallowed
|
|
96
|
-
* are too many redirects.
|
|
95
|
+
* @returns The final response, or `null` if the URL is disallowed, its
|
|
96
|
+
* hostname cannot be resolved, or there are too many redirects.
|
|
97
97
|
*/
|
|
98
98
|
async function fetchPublicUrl(url, headers) {
|
|
99
99
|
let current = url instanceof URL ? url : new URL(url);
|
|
@@ -103,7 +103,11 @@ async function fetchPublicUrl(url, headers) {
|
|
|
103
103
|
await validatePublicUrl(current.href);
|
|
104
104
|
} catch (e) {
|
|
105
105
|
if (e instanceof UrlError) {
|
|
106
|
-
logger.error("
|
|
106
|
+
if (e.reason === "dns") logger.error("DNS lookup failed for {url}: {error}", {
|
|
107
|
+
url: current.href,
|
|
108
|
+
error: e
|
|
109
|
+
});
|
|
110
|
+
else logger.error("Refused to fetch a private or invalid URL {url}: {error}", {
|
|
107
111
|
url: current.href,
|
|
108
112
|
error: e
|
|
109
113
|
});
|