@fedify/relay 2.0.7 → 2.0.8
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/litepub.test.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import { exportSpki, getDocumentLoader, isRelayFollowerData } from "./types-
|
|
6
|
+
import { exportSpki, getDocumentLoader, isRelayFollowerData } from "./types-B3gny4_t.js";
|
|
7
7
|
import { MemoryKvStore, signRequest } from "@fedify/fedify";
|
|
8
8
|
import { createRelay } from "@fedify/relay";
|
|
9
9
|
import { Accept, Announce, Create, Delete, Follow, Move, Note, Person, Undo, Update } from "@fedify/vocab";
|
package/dist/mastodon.test.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import { exportSpki, getDocumentLoader, isRelayFollowerData } from "./types-
|
|
6
|
+
import { exportSpki, getDocumentLoader, isRelayFollowerData } from "./types-B3gny4_t.js";
|
|
7
7
|
import { MemoryKvStore, signRequest } from "@fedify/fedify";
|
|
8
8
|
import { createRelay } from "@fedify/relay";
|
|
9
9
|
import { Create, Delete, Follow, Move, Note, Person, Undo, Update } from "@fedify/vocab";
|
|
@@ -25600,7 +25600,7 @@ const preloadedContexts = {
|
|
|
25600
25600
|
};
|
|
25601
25601
|
var contexts_default = preloadedContexts;
|
|
25602
25602
|
var name = "@fedify/vocab-runtime";
|
|
25603
|
-
var version = "2.0.
|
|
25603
|
+
var version = "2.0.8";
|
|
25604
25604
|
var license = "MIT";
|
|
25605
25605
|
var exports$1 = {
|
|
25606
25606
|
".": "./src/mod.ts",
|
|
@@ -25941,6 +25941,7 @@ const logger = getLogger([
|
|
|
25941
25941
|
"runtime",
|
|
25942
25942
|
"docloader"
|
|
25943
25943
|
]);
|
|
25944
|
+
const DEFAULT_MAX_REDIRECTION = 20;
|
|
25944
25945
|
/**
|
|
25945
25946
|
* Gets a {@link RemoteDocument} from the given response.
|
|
25946
25947
|
* @param url The URL of the document to load.
|
|
@@ -26059,31 +26060,33 @@ async function getRemoteDocument(url, response, fetch$1) {
|
|
|
26059
26060
|
function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAgent } = {}) {
|
|
26060
26061
|
const tracerProvider = trace.getTracerProvider();
|
|
26061
26062
|
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
26062
|
-
async function load(url, options) {
|
|
26063
|
+
async function load(url, options, redirected = 0, visited = /* @__PURE__ */ new Set()) {
|
|
26063
26064
|
options?.signal?.throwIfAborted();
|
|
26064
|
-
|
|
26065
|
-
|
|
26065
|
+
const currentUrl = new URL(url).href;
|
|
26066
|
+
if (!skipPreloadedContexts && currentUrl in contexts_default) {
|
|
26067
|
+
logger.debug("Using preloaded context: {url}.", { url: currentUrl });
|
|
26066
26068
|
return {
|
|
26067
26069
|
contextUrl: null,
|
|
26068
|
-
document: contexts_default[
|
|
26069
|
-
documentUrl:
|
|
26070
|
+
document: contexts_default[currentUrl],
|
|
26071
|
+
documentUrl: currentUrl
|
|
26070
26072
|
};
|
|
26071
26073
|
}
|
|
26072
26074
|
if (!allowPrivateAddress) try {
|
|
26073
|
-
await validatePublicUrl(
|
|
26075
|
+
await validatePublicUrl(currentUrl);
|
|
26074
26076
|
} catch (error) {
|
|
26075
26077
|
if (error instanceof UrlError) logger.error("Disallowed private URL: {url}", {
|
|
26076
|
-
url,
|
|
26078
|
+
url: currentUrl,
|
|
26077
26079
|
error
|
|
26078
26080
|
});
|
|
26079
26081
|
throw error;
|
|
26080
26082
|
}
|
|
26083
|
+
visited.add(currentUrl);
|
|
26081
26084
|
return await tracer.startActiveSpan("activitypub.fetch_document", {
|
|
26082
26085
|
kind: SpanKind.CLIENT,
|
|
26083
|
-
attributes: { "url.full":
|
|
26086
|
+
attributes: { "url.full": currentUrl }
|
|
26084
26087
|
}, async (span) => {
|
|
26085
26088
|
try {
|
|
26086
|
-
const request = createActivityPubRequest(
|
|
26089
|
+
const request = createActivityPubRequest(currentUrl, { userAgent });
|
|
26087
26090
|
logRequest(logger, request);
|
|
26088
26091
|
const response = await fetch(request, {
|
|
26089
26092
|
redirect: "manual",
|
|
@@ -26091,11 +26094,25 @@ function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAge
|
|
|
26091
26094
|
});
|
|
26092
26095
|
span.setAttribute("http.response.status_code", response.status);
|
|
26093
26096
|
if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
|
|
26094
|
-
|
|
26097
|
+
if (redirected >= DEFAULT_MAX_REDIRECTION) {
|
|
26098
|
+
logger.error("Too many redirections ({redirections}) while fetching document.", {
|
|
26099
|
+
redirections: redirected + 1,
|
|
26100
|
+
url: currentUrl
|
|
26101
|
+
});
|
|
26102
|
+
throw new FetchError(currentUrl, `Too many redirections (${redirected + 1})`);
|
|
26103
|
+
}
|
|
26104
|
+
const redirectUrl = new URL(response.headers.get("Location"), response.url === "" ? currentUrl : response.url).href;
|
|
26095
26105
|
span.setAttribute("http.redirect.url", redirectUrl);
|
|
26096
|
-
|
|
26106
|
+
if (visited.has(redirectUrl)) {
|
|
26107
|
+
logger.error("Detected a redirect loop while fetching document: {url} -> {redirectUrl}", {
|
|
26108
|
+
url: currentUrl,
|
|
26109
|
+
redirectUrl
|
|
26110
|
+
});
|
|
26111
|
+
throw new FetchError(currentUrl, `Redirect loop detected: ${redirectUrl}`);
|
|
26112
|
+
}
|
|
26113
|
+
return await load(redirectUrl, options, redirected + 1, visited);
|
|
26097
26114
|
}
|
|
26098
|
-
const result = await getRemoteDocument(
|
|
26115
|
+
const result = await getRemoteDocument(currentUrl, response, load);
|
|
26099
26116
|
span.setAttribute("docloader.document_url", result.documentUrl);
|
|
26100
26117
|
if (result.contextUrl != null) span.setAttribute("docloader.context_url", result.contextUrl);
|
|
26101
26118
|
return result;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/relay",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8",
|
|
4
4
|
"description": "ActivityPub relay support for Fedify",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Fedify",
|
|
@@ -50,14 +50,14 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@js-temporal/polyfill": "^0.5.1",
|
|
52
52
|
"@logtape/logtape": "^2.0.0",
|
|
53
|
-
"@fedify/fedify": "^2.0.
|
|
54
|
-
"@fedify/vocab": "2.0.
|
|
53
|
+
"@fedify/fedify": "^2.0.8",
|
|
54
|
+
"@fedify/vocab": "2.0.8"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"tsdown": "^0.12.9",
|
|
58
58
|
"typescript": "^5.9.3",
|
|
59
59
|
"urlpattern-polyfill": "^10.1.0",
|
|
60
|
-
"@fedify/vocab-runtime": "^2.0.
|
|
60
|
+
"@fedify/vocab-runtime": "^2.0.8"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build:self": "tsdown",
|