@fedify/fedify 2.5.0-dev.2448 → 2.5.0-dev.2492
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 +3 -0
- package/dist/{builder-DbC8bn6k.mjs → builder-DphK9v7f.mjs} +2 -2
- package/dist/{client-D-XP_Ccb.d.cts → client-3InDZbba.d.cts} +0 -1
- package/dist/{client-D-XP_Ccb.d.ts → client-3InDZbba.d.ts} +0 -1
- package/dist/{client-CEnNz8O7.mjs → client-5SIFzW3q.mjs} +113 -64
- 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/{compound-proof-heeXW2_A.mjs → compound-proof-cYtvlTgF.mjs} +2 -2
- package/dist/{context-GlHrzdSP.d.ts → context-DQJE9YfH.d.ts} +29 -3
- package/dist/{context-BazwQrHn.d.cts → context-DSuL3YWx.d.cts} +29 -3
- package/dist/{deno-Dpewt_jJ.mjs → deno-iOAA7iRN.mjs} +1 -1
- package/dist/docloader-DCZkiTeF.mjs +136 -0
- package/dist/{exporter-DThFfe7P.mjs → exporter-DVG68ozH.mjs} +36 -30
- package/dist/federation/builder.test.mjs +1 -1
- package/dist/federation/compound-fanout.test.mjs +6 -3
- package/dist/federation/handler-compound-proof.test.mjs +3 -3
- package/dist/federation/handler.test.mjs +5 -5
- package/dist/federation/hashlink-media.test.mjs +2 -2
- package/dist/federation/idempotency.test.mjs +2 -2
- package/dist/federation/inbox-actorless.test.mjs +5 -5
- package/dist/federation/inbox-report.test.mjs +5 -5
- package/dist/federation/inbox-view.test.mjs +1 -1
- package/dist/federation/inbox.test.mjs +1 -1
- package/dist/federation/metrics.test.mjs +1 -1
- package/dist/federation/middleware.test.mjs +468 -33
- package/dist/federation/mod.cjs +1 -1
- package/dist/federation/mod.d.cts +3 -3
- package/dist/federation/mod.d.ts +3 -3
- package/dist/federation/mod.js +1 -1
- package/dist/federation/mq.test.mjs +1 -1
- package/dist/federation/outgoing-proof.test.mjs +9 -6
- package/dist/federation/portable-actor.test.mjs +3 -3
- package/dist/federation/portable-chain.test.mjs +3 -3
- package/dist/federation/portable-collection.test.mjs +4 -4
- package/dist/federation/portable-delivery.test.mjs +2 -2
- package/dist/federation/portable-gateway-keys.test.mjs +11 -5
- package/dist/federation/portable-inbox.test.mjs +4 -4
- package/dist/federation/portable-parse-uri.test.mjs +1 -1
- package/dist/federation/portable-route-activity.test.mjs +2 -2
- package/dist/federation/portable.test.mjs +3 -3
- package/dist/federation/send.test.mjs +502 -93
- package/dist/federation/tasks/enqueue.test.mjs +1 -1
- package/dist/federation/tasks/tasks.test.mjs +2 -2
- package/dist/federation/temporal.test.mjs +1 -1
- package/dist/federation/webfinger.test.mjs +1 -1
- package/dist/{federation-D8YexkP1.cjs → federation-D0AZw_aw.cjs} +246 -108
- package/dist/{http-BZkyQIkb.mjs → http-BoJCMnjY.mjs} +204 -106
- package/dist/{http-BBr-VLil.js → http-ChXUU_3c.js} +178 -109
- package/dist/{http-CAl7Num5.cjs → http-kv1LZw-r.cjs} +179 -110
- package/dist/{inbox-wDuMKaFW.mjs → inbox-BjihTKLo.mjs} +2 -2
- package/dist/{inbox-view-NE9wXdLo.mjs → inbox-view-D-skypg-.mjs} +1 -1
- package/dist/{key-nYGY4QB9.d.cts → key-DbLNT-vA.d.ts} +1 -2
- package/dist/{key-DhsBxxZN.d.ts → key-DlHT4R6k.d.cts} +1 -2
- package/dist/{kv-cache-CTQSfkmp.mjs → kv-cache-Cmsyke4d.mjs} +1 -1
- package/dist/{kv-cache-U7uz5nx4.js → kv-cache-DQcte7ES.js} +73 -28
- package/dist/{kv-cache-CjgCOz3i.cjs → kv-cache-Ddh5sMxH.cjs} +72 -27
- package/dist/{ld-Cel1RRZ5.d.cts → ld-CWVpo_NM.d.cts} +1 -1
- package/dist/{ld-CQFuiah9.mjs → ld-CdvcOEXQ.mjs} +2 -2
- package/dist/{ld-CcuZ4NZa.d.ts → ld-Inagww4R.d.ts} +1 -1
- package/dist/{metrics-B-QxRSSR.mjs → metrics-CpxvUrBz.mjs} +1 -1
- package/dist/{middleware-P-AZEQMn.js → middleware-BHb5toqA.js} +247 -109
- package/dist/{middleware-BdlNa8BD.mjs → middleware-BKs2DLUF.mjs} +1 -1
- package/dist/{middleware-CuVa0UuS.mjs → middleware-CoBLrTKX.mjs} +89 -49
- package/dist/{mod-DvWOv2Ho.d.cts → mod-6TQ4UQZb.d.cts} +1 -1
- package/dist/{mod-BHQE-7WQ.d.ts → mod-B4kBw1-8.d.ts} +1 -1
- package/dist/{mod-DkhfZC1u.d.ts → mod-B7j30IQf.d.ts} +2 -9
- package/dist/{mod-B2783_3v.d.cts → mod-C1nT74IG.d.cts} +1 -1
- package/dist/{mod-DjZfJj9R.d.ts → mod-CIeBgsOC.d.ts} +1 -1
- package/dist/{mod-B5-wdzmJ.d.cts → mod-YvA4Rk8J.d.cts} +2 -9
- package/dist/mod.cjs +5 -5
- package/dist/mod.d.cts +7 -7
- package/dist/mod.d.ts +7 -7
- package/dist/mod.js +5 -5
- package/dist/nodeinfo/client.test.mjs +337 -19
- package/dist/nodeinfo/handler.test.mjs +1 -1
- package/dist/nodeinfo/mod.cjs +1 -1
- package/dist/nodeinfo/mod.d.cts +1 -1
- package/dist/nodeinfo/mod.d.ts +1 -1
- package/dist/nodeinfo/mod.js +1 -1
- package/dist/otel/exporter.test.mjs +257 -1
- package/dist/otel/mod.cjs +36 -30
- package/dist/otel/mod.d.cts +13 -0
- package/dist/otel/mod.d.ts +13 -0
- package/dist/otel/mod.js +36 -30
- package/dist/{owner-ccKkQOAf.mjs → owner-DTnVpUKA.mjs} +3 -3
- package/dist/{portable-collection-CndnpXfo.mjs → portable-collection-CJeYTL61.mjs} +2 -2
- package/dist/{portable-collection-TC-kvkVI.cjs → portable-collection-DciwBIia.cjs} +1 -1
- package/dist/{portable-collection-DUlQ3s2M.js → portable-collection-TmtpzD4E.js} +1 -1
- package/dist/{portable-key-D5tFOoV-.mjs → portable-key-DcYok4ki.mjs} +1 -1
- package/dist/{proof-DPoF06nz.mjs → proof-GH7Poos_.mjs} +3 -3
- package/dist/{send-CF44O1Df.mjs → send-BgGJh6pv.mjs} +174 -76
- package/dist/sig/compound-proof-discovery.test.mjs +1 -1
- package/dist/sig/compound-proof-producer.test.mjs +1 -1
- package/dist/sig/compound-proof-verification.test.mjs +2 -2
- package/dist/sig/compound-proof.test.mjs +2 -2
- package/dist/sig/http.test.mjs +553 -2
- package/dist/sig/key.test.mjs +1 -1
- package/dist/sig/ld.test.mjs +1 -1
- package/dist/sig/mitra-receive-interop.test.mjs +4 -4
- package/dist/sig/mitra-send-interop.test.mjs +3 -3
- package/dist/sig/mod.cjs +2 -2
- package/dist/sig/mod.d.cts +3 -3
- package/dist/sig/mod.d.ts +3 -3
- package/dist/sig/mod.js +2 -2
- package/dist/sig/owner.test.mjs +1 -1
- package/dist/sig/portable-collection.test.mjs +1 -1
- package/dist/sig/portable-interop.test.mjs +3 -3
- package/dist/sig/portable-key.test.mjs +5 -5
- package/dist/sig/proof.test.mjs +4 -4
- package/dist/sig/tootik-request-interop.test.mjs +4 -4
- package/dist/sig/tootik-send-interop.test.mjs +3 -3
- package/dist/sig/verification.test.mjs +3 -3
- package/dist/{temporal-XlZ4Wb94.mjs → temporal-gJINzcL4.mjs} +1 -1
- package/dist/testing/kv.test.mjs +1 -1
- package/dist/testing/mod.d.mts +26 -0
- package/dist/{types-_S2_MeLF.js → types-DUjZb4i6.js} +112 -63
- package/dist/{types-poIao40f.cjs → types-hKCCjii0.cjs} +111 -62
- package/dist/utils/docloader.test.mjs +344 -36
- package/dist/utils/kv-cache.test.mjs +1 -1
- 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/package.json +8 -8
- package/dist/docloader-CpsDyqVN.mjs +0 -91
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
2
|
-
const require_http = require("./http-
|
|
2
|
+
const require_http = require("./http-kv1LZw-r.cjs");
|
|
3
3
|
let _logtape_logtape = require("@logtape/logtape");
|
|
4
4
|
let _fedify_vocab_runtime = require("@fedify/vocab-runtime");
|
|
5
5
|
let es_toolkit = require("es-toolkit");
|
|
6
|
+
let _fedify_vocab_runtime_internal = require("@fedify/vocab-runtime/internal");
|
|
6
7
|
//#region src/utils/docloader.ts
|
|
7
8
|
const logger$1 = (0, _logtape_logtape.getLogger)([
|
|
8
9
|
"fedify",
|
|
@@ -26,13 +27,35 @@ const DEFAULT_MAX_REDIRECTION = 20;
|
|
|
26
27
|
* @throws {RangeError} If the `timeout` option is invalid.
|
|
27
28
|
* @since 0.4.0
|
|
28
29
|
*/
|
|
29
|
-
function getAuthenticatedDocumentLoader(identity,
|
|
30
|
+
function getAuthenticatedDocumentLoader(identity, options = {}) {
|
|
31
|
+
return createAuthenticatedDocumentLoader(identity, options);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The placeholder that the alternate document callback of
|
|
35
|
+
* `getRemoteDocument()` returns, so that the alternate document is loaded
|
|
36
|
+
* after the current hop is closed.
|
|
37
|
+
*/
|
|
38
|
+
const ALTERNATE_PLACEHOLDER = Object.freeze({
|
|
39
|
+
contextUrl: null,
|
|
40
|
+
document: null,
|
|
41
|
+
documentUrl: "about:blank"
|
|
42
|
+
});
|
|
43
|
+
/**
|
|
44
|
+
* The implementation of {@link getAuthenticatedDocumentLoader}. This is not
|
|
45
|
+
* exported from any entry point.
|
|
46
|
+
* @param identity The identity to get the document loader for.
|
|
47
|
+
* @param options The options for the document loader.
|
|
48
|
+
* @param deps The dependencies, for tests.
|
|
49
|
+
* @returns The authenticated document loader.
|
|
50
|
+
* @throws {TypeError} If the key is invalid or unsupported.
|
|
51
|
+
*/
|
|
52
|
+
function createAuthenticatedDocumentLoader(identity, { allowPrivateAddress, maxRedirection, userAgent, specDeterminer, timeout, tracerProvider } = {}, deps = {}) {
|
|
30
53
|
require_http.validateCryptoKey(identity.privateKey);
|
|
31
54
|
const resolvedTimeout = (0, _fedify_vocab_runtime.resolveDocumentLoaderTimeout)(timeout);
|
|
32
55
|
async function load(url, options, redirected = 0, visited = /* @__PURE__ */ new Set()) {
|
|
33
56
|
options?.signal?.throwIfAborted();
|
|
34
57
|
let currentUrl = new URL(url).href;
|
|
35
|
-
|
|
58
|
+
validateUrl(currentUrl);
|
|
36
59
|
visited.add(currentUrl);
|
|
37
60
|
const originalRequest = (0, _fedify_vocab_runtime.createActivityPubRequest)(currentUrl, { userAgent });
|
|
38
61
|
function follow(nextUrl) {
|
|
@@ -41,46 +64,68 @@ function getAuthenticatedDocumentLoader(identity, { allowPrivateAddress, maxRedi
|
|
|
41
64
|
if (visited.has(nextUrl)) throw new _fedify_vocab_runtime.FetchError(currentUrl, `Redirect loop detected: ${nextUrl}`);
|
|
42
65
|
redirected++;
|
|
43
66
|
}
|
|
44
|
-
const
|
|
67
|
+
const result = await require_http.doubleKnockScoped(originalRequest, identity, {
|
|
45
68
|
maxRedirection,
|
|
46
69
|
specDeterminer,
|
|
47
70
|
log: (0, es_toolkit.curry)(_fedify_vocab_runtime.logRequest)(logger$1),
|
|
48
71
|
tracerProvider,
|
|
49
72
|
signal: options?.signal,
|
|
50
|
-
validateRedirect:
|
|
73
|
+
validateRedirect: (nextUrl) => {
|
|
51
74
|
follow(nextUrl);
|
|
52
|
-
|
|
75
|
+
validateUrl(nextUrl);
|
|
53
76
|
visited.add(nextUrl);
|
|
54
77
|
currentUrl = nextUrl;
|
|
55
78
|
}
|
|
79
|
+
}, (hopUrl) => openHop(hopUrl, options), async (response) => {
|
|
80
|
+
options?.signal?.throwIfAborted();
|
|
81
|
+
let alternateUrl;
|
|
82
|
+
const document = await (0, _fedify_vocab_runtime.getRemoteDocument)(currentUrl, response, (url) => {
|
|
83
|
+
alternateUrl = url;
|
|
84
|
+
return Promise.resolve(ALTERNATE_PLACEHOLDER);
|
|
85
|
+
}, options);
|
|
86
|
+
if (alternateUrl == null) return { document };
|
|
87
|
+
if (!response.bodyUsed && response.body?.locked !== true) response.body?.cancel().catch((error) => {
|
|
88
|
+
logger$1.debug("Failed to cancel the response body from {url}: {error}", {
|
|
89
|
+
url: currentUrl,
|
|
90
|
+
error
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
return { alternateUrl };
|
|
56
94
|
});
|
|
57
95
|
options?.signal?.throwIfAborted();
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
96
|
+
if ("document" in result) return result.document;
|
|
97
|
+
follow(result.alternateUrl);
|
|
98
|
+
return load(result.alternateUrl, options, redirected, visited);
|
|
99
|
+
}
|
|
100
|
+
function openUnvalidatedHop(url, signal) {
|
|
101
|
+
if (deps.openHop != null) return deps.openHop(url);
|
|
102
|
+
return allowPrivateAddress ? (0, _fedify_vocab_runtime_internal.openDirectFetch)(url) : (0, _fedify_vocab_runtime_internal.openPublicFetch)(url, { signal });
|
|
62
103
|
}
|
|
63
|
-
async function
|
|
104
|
+
async function openHop(url, options) {
|
|
105
|
+
try {
|
|
106
|
+
const session = await openUnvalidatedHop(url, options?.signal);
|
|
107
|
+
if (options?.signal?.aborted) {
|
|
108
|
+
await session.close();
|
|
109
|
+
options.signal.throwIfAborted();
|
|
110
|
+
}
|
|
111
|
+
return session;
|
|
112
|
+
} catch (error) {
|
|
113
|
+
if (error instanceof _fedify_vocab_runtime.UrlError) if (error.reason === "dns") logger$1.debug("DNS lookup failed for {url}", {
|
|
114
|
+
url,
|
|
115
|
+
error
|
|
116
|
+
});
|
|
117
|
+
else logger$1[options?.suppressError ? "warn" : "error"]("Disallowed private URL: {url}", {
|
|
118
|
+
url,
|
|
119
|
+
error
|
|
120
|
+
});
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function validateUrl(url) {
|
|
64
125
|
const parsedUrl = new URL(url);
|
|
65
126
|
const protocol = parsedUrl.protocol;
|
|
66
127
|
if (protocol !== "http:" && protocol !== "https:") throw new _fedify_vocab_runtime.UrlError(`Unsupported protocol: ${protocol}`);
|
|
67
128
|
if (parsedUrl.username !== "" || parsedUrl.password !== "") throw new _fedify_vocab_runtime.UrlError("URLs with credentials are not allowed");
|
|
68
|
-
if (!allowPrivateAddress) {
|
|
69
|
-
try {
|
|
70
|
-
await (0, _fedify_vocab_runtime.validatePublicUrl)(url);
|
|
71
|
-
} catch (error) {
|
|
72
|
-
if (error instanceof _fedify_vocab_runtime.UrlError) if (error.reason === "dns") logger$1.debug("DNS lookup failed for {url}", {
|
|
73
|
-
url,
|
|
74
|
-
error
|
|
75
|
-
});
|
|
76
|
-
else logger$1[options?.suppressError ? "warn" : "error"]("Disallowed private URL: {url}", {
|
|
77
|
-
url,
|
|
78
|
-
error
|
|
79
|
-
});
|
|
80
|
-
throw error;
|
|
81
|
-
}
|
|
82
|
-
options?.signal?.throwIfAborted();
|
|
83
|
-
}
|
|
84
129
|
}
|
|
85
130
|
return (0, _fedify_vocab_runtime.withDocumentLoaderTimeout)((url, options) => load(url, options), resolvedTimeout);
|
|
86
131
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import { a as KeyCache, v as VerificationObservationOptions } from "./key-
|
|
2
|
+
import { a as KeyCache, v as VerificationObservationOptions } from "./key-DlHT4R6k.cjs";
|
|
3
3
|
import { Activity, Actor, CryptographicKey } from "@fedify/vocab";
|
|
4
4
|
import { DocumentLoader } from "@fedify/vocab-runtime";
|
|
5
5
|
import { MeterProvider, TracerProvider } from "@opentelemetry/api";
|
|
@@ -3,8 +3,8 @@ import "urlpattern-polyfill";
|
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { c as isPortableActorDocument, d as isPortableUri, l as isPortableId, m as parseKeyIdString, s as isCompatibleKeyId } from "./portable-key-id-Ca30-hOa.mjs";
|
|
5
5
|
import { a as verificationObservation, i as triedKey, n as observeCheck, t as observeAttempt } from "./verification-Dpfcw8ml.mjs";
|
|
6
|
-
import { n as version, t as name } from "./deno-
|
|
7
|
-
import { _ as recordKeyLookup, n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch, t as classifyFetchError } from "./metrics-
|
|
6
|
+
import { n as version, t as name } from "./deno-iOAA7iRN.mjs";
|
|
7
|
+
import { _ as recordKeyLookup, n as getDurationMs, r as getFederationMetrics, s as measureSignatureKeyFetch, t as classifyFetchError } from "./metrics-CpxvUrBz.mjs";
|
|
8
8
|
import { n as attachKeyOwnerEvidence, t as MAX_PORTABLE_KEY_TTL } from "./key-owner-evidence-APB6NpSk.mjs";
|
|
9
9
|
import { getLogger } from "@logtape/logtape";
|
|
10
10
|
import { Activity, CryptographicKey, Multikey, Object as Object$1, getTypeId, isActor } from "@fedify/vocab";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import { a as KeyCache, v as VerificationObservationOptions } from "./key-
|
|
2
|
+
import { a as KeyCache, v as VerificationObservationOptions } from "./key-DbLNT-vA.js";
|
|
3
3
|
import { Activity, Actor, CryptographicKey } from "@fedify/vocab";
|
|
4
4
|
import { MeterProvider, TracerProvider } from "@opentelemetry/api";
|
|
5
5
|
import { DocumentLoader } from "@fedify/vocab-runtime";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "temporal-polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
4
|
+
import { n as version, t as name } from "./deno-iOAA7iRN.mjs";
|
|
5
5
|
import { metrics } from "@opentelemetry/api";
|
|
6
6
|
import { FetchError } from "@fedify/vocab-runtime";
|
|
7
7
|
//#region src/federation/metrics.ts
|