@fedify/vocab-runtime 2.1.24 → 2.1.25
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 +1 -1
- package/dist/mod.cjs +55 -7
- package/dist/mod.d.cts +10 -0
- package/dist/mod.d.ts +10 -0
- package/dist/mod.js +55 -8
- package/dist/tests/{body-BWNGF5gy.cjs → body-D-gC5vdl.cjs} +1 -1
- package/dist/tests/{body-D_GduSEt.mjs → body-DBqFojnW.mjs} +1 -1
- package/dist/tests/body.test.cjs +1 -1
- package/dist/tests/body.test.mjs +1 -1
- package/dist/tests/decimal.test.cjs +2 -2
- package/dist/tests/decimal.test.mjs +2 -2
- package/dist/tests/{docloader-BBEZYcQU.mjs → docloader-Beoc8qTH.mjs} +43 -6
- package/dist/tests/{docloader-CrsmzPTc.cjs → docloader-fn4ICzFS.cjs} +43 -6
- package/dist/tests/docloader.test.cjs +241 -3
- package/dist/tests/docloader.test.mjs +240 -3
- package/dist/tests/{request-xQEQeUO1.cjs → request-DrO5xzev.cjs} +1 -1
- package/dist/tests/{request-CbVzw-Ce.mjs → request-DxeGyJVh.mjs} +1 -1
- package/dist/tests/request.test.cjs +1 -1
- package/dist/tests/request.test.mjs +1 -1
- package/dist/tests/{url-BBfduh6o.mjs → url-3fyJuqC0.mjs} +14 -4
- package/dist/tests/{url-CnyF489g.cjs → url-vZTgkIZg.cjs} +15 -4
- package/dist/tests/url.test.cjs +36 -3
- package/dist/tests/url.test.mjs +37 -4
- package/package.json +1 -1
- package/src/contexts/fep-7aa9.json +24 -0
- package/src/contexts.ts +8 -0
- package/src/docloader.test.ts +307 -0
- package/src/docloader.ts +35 -6
- package/src/url.test.ts +29 -3
- package/src/url.ts +21 -5
package/deno.json
CHANGED
package/dist/mod.cjs
CHANGED
|
@@ -6,6 +6,7 @@ let _opentelemetry_api = require("@opentelemetry/api");
|
|
|
6
6
|
let node_process = require("node:process");
|
|
7
7
|
node_process = require_chunk.__toESM(node_process);
|
|
8
8
|
let node_dns_promises = require("node:dns/promises");
|
|
9
|
+
node_dns_promises = require_chunk.__toESM(node_dns_promises);
|
|
9
10
|
let node_net = require("node:net");
|
|
10
11
|
let asn1js = require("asn1js");
|
|
11
12
|
let byte_encodings_base64 = require("byte-encodings/base64");
|
|
@@ -599,6 +600,30 @@ var fep_5711_default = { "@context": {
|
|
|
599
600
|
}
|
|
600
601
|
} };
|
|
601
602
|
//#endregion
|
|
603
|
+
//#region src/contexts/fep-7aa9.json
|
|
604
|
+
var fep_7aa9_default = { "@context": {
|
|
605
|
+
"FeaturedCollection": "https://w3id.org/fep/7aa9#FeaturedCollection",
|
|
606
|
+
"FeaturedItem": "https://w3id.org/fep/7aa9#FeaturedItem",
|
|
607
|
+
"FeatureRequest": "https://w3id.org/fep/7aa9#FeatureRequest",
|
|
608
|
+
"FeatureAuthorization": "https://w3id.org/fep/7aa9#FeatureAuthorization",
|
|
609
|
+
"topic": {
|
|
610
|
+
"@id": "https://w3id.org/fep/7aa9#topic",
|
|
611
|
+
"@type": "@id"
|
|
612
|
+
},
|
|
613
|
+
"featuredObject": {
|
|
614
|
+
"@id": "https://w3id.org/fep/7aa9#featuredObject",
|
|
615
|
+
"@type": "@id"
|
|
616
|
+
},
|
|
617
|
+
"canFeature": {
|
|
618
|
+
"@id": "https://w3id.org/fep/7aa9#canFeature",
|
|
619
|
+
"@type": "@id"
|
|
620
|
+
},
|
|
621
|
+
"featureAuthorization": {
|
|
622
|
+
"@id": "https://w3id.org/fep/7aa9#featureAuthorization",
|
|
623
|
+
"@type": "@id"
|
|
624
|
+
}
|
|
625
|
+
} };
|
|
626
|
+
//#endregion
|
|
602
627
|
//#region src/contexts/fep-ef61.json
|
|
603
628
|
var fep_ef61_default = { "@context": {
|
|
604
629
|
"gateways": {
|
|
@@ -4516,6 +4541,7 @@ const preloadedContexts = {
|
|
|
4516
4541
|
"https://w3id.org/fep/5711": fep_5711_default,
|
|
4517
4542
|
"https://www.w3.org/ns/cid/v1": cid_v1_default,
|
|
4518
4543
|
"https://w3id.org/fep/ef61": fep_ef61_default,
|
|
4544
|
+
"https://w3id.org/fep/7aa9": fep_7aa9_default,
|
|
4519
4545
|
"https://join-lemmy.org/context.json": join_lemmy_default,
|
|
4520
4546
|
"http://joinmastodon.org/ns": joinmastodon_default,
|
|
4521
4547
|
"https://purl.archive.org/miscellany": miscellany_default
|
|
@@ -4523,7 +4549,7 @@ const preloadedContexts = {
|
|
|
4523
4549
|
//#endregion
|
|
4524
4550
|
//#region deno.json
|
|
4525
4551
|
var name = "@fedify/vocab-runtime";
|
|
4526
|
-
var version = "2.1.
|
|
4552
|
+
var version = "2.1.25";
|
|
4527
4553
|
//#endregion
|
|
4528
4554
|
//#region src/request.ts
|
|
4529
4555
|
/**
|
|
@@ -4852,9 +4878,16 @@ var HttpHeaderLink = class HttpHeaderLink {
|
|
|
4852
4878
|
//#endregion
|
|
4853
4879
|
//#region src/url.ts
|
|
4854
4880
|
var UrlError = class extends Error {
|
|
4881
|
+
/**
|
|
4882
|
+
* The failure category. Defaults to `"disallowed"`.
|
|
4883
|
+
* `"dns"` includes lookup errors and results with no usable IP addresses.
|
|
4884
|
+
* @since 2.0.29
|
|
4885
|
+
*/
|
|
4886
|
+
reason;
|
|
4855
4887
|
constructor(message, options) {
|
|
4856
4888
|
super(message, options);
|
|
4857
4889
|
this.name = "UrlError";
|
|
4890
|
+
this.reason = options?.reason ?? "disallowed";
|
|
4858
4891
|
}
|
|
4859
4892
|
};
|
|
4860
4893
|
/**
|
|
@@ -4880,9 +4913,12 @@ async function validatePublicUrl(url) {
|
|
|
4880
4913
|
}
|
|
4881
4914
|
let addresses;
|
|
4882
4915
|
try {
|
|
4883
|
-
addresses = await
|
|
4916
|
+
addresses = await node_dns_promises.default.lookup(hostname, { all: true });
|
|
4884
4917
|
} catch (error) {
|
|
4885
|
-
throw new UrlError("DNS lookup failed", {
|
|
4918
|
+
throw new UrlError("DNS lookup failed", {
|
|
4919
|
+
cause: error,
|
|
4920
|
+
reason: "dns"
|
|
4921
|
+
});
|
|
4886
4922
|
}
|
|
4887
4923
|
validateLookupAddresses(addresses);
|
|
4888
4924
|
}
|
|
@@ -4911,7 +4947,7 @@ function validateLookupAddresses(addresses) {
|
|
|
4911
4947
|
ipAddressCount++;
|
|
4912
4948
|
validatePublicIpAddress(address, family);
|
|
4913
4949
|
}
|
|
4914
|
-
if (ipAddressCount === 0) throw new UrlError("DNS lookup did not return any IP address");
|
|
4950
|
+
if (ipAddressCount === 0) throw new UrlError("DNS lookup did not return any IP address", { reason: "dns" });
|
|
4915
4951
|
}
|
|
4916
4952
|
function validatePublicIpAddress(address, family) {
|
|
4917
4953
|
if (family === 4 && isValidPublicIPv4Address(address) || family === 6 && isValidPublicIPv6Address(address)) return;
|
|
@@ -5147,6 +5183,8 @@ async function getRemoteDocument(url, response, fetch) {
|
|
|
5147
5183
|
}
|
|
5148
5184
|
/**
|
|
5149
5185
|
* Creates a JSON-LD document loader that utilizes the browser's `fetch` API.
|
|
5186
|
+
* At most 20 HTTP redirects and alternate document links are followed in total
|
|
5187
|
+
* per call. Revisiting a URL within that chain throws a {@link FetchError}.
|
|
5150
5188
|
*
|
|
5151
5189
|
* The created loader preloads the below frequently used contexts by default
|
|
5152
5190
|
* (unless `options.skipPreloadedContexts` is set to `true`):
|
|
@@ -5158,6 +5196,7 @@ async function getRemoteDocument(url, response, fetch) {
|
|
|
5158
5196
|
* - <https://www.w3.org/ns/cid/v1>
|
|
5159
5197
|
* - <https://w3id.org/security/multikey/v1>
|
|
5160
5198
|
* - <https://w3id.org/fep/ef61>
|
|
5199
|
+
* - <https://w3id.org/fep/7aa9>
|
|
5161
5200
|
* - <https://purl.archive.org/socialweb/webfinger>
|
|
5162
5201
|
* - <http://schema.org/>
|
|
5163
5202
|
* @param options Options for the document loader.
|
|
@@ -5180,7 +5219,11 @@ function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAge
|
|
|
5180
5219
|
if (!allowPrivateAddress) try {
|
|
5181
5220
|
await validatePublicUrl(currentUrl);
|
|
5182
5221
|
} catch (error) {
|
|
5183
|
-
if (error instanceof UrlError) logger.
|
|
5222
|
+
if (error instanceof UrlError) if (error.reason === "dns") logger.debug("DNS lookup failed for {url}", {
|
|
5223
|
+
url: currentUrl,
|
|
5224
|
+
error
|
|
5225
|
+
});
|
|
5226
|
+
else logger.error("Disallowed private URL: {url}", {
|
|
5184
5227
|
url: currentUrl,
|
|
5185
5228
|
error
|
|
5186
5229
|
});
|
|
@@ -5218,7 +5261,12 @@ function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAge
|
|
|
5218
5261
|
}
|
|
5219
5262
|
return await load(redirectUrl, options, redirected + 1, visited);
|
|
5220
5263
|
}
|
|
5221
|
-
const result = await getRemoteDocument(currentUrl, response,
|
|
5264
|
+
const result = await getRemoteDocument(currentUrl, response, async (alternateUrl) => {
|
|
5265
|
+
options?.signal?.throwIfAborted();
|
|
5266
|
+
if (redirected >= DEFAULT_MAX_REDIRECTION) throw new FetchError(currentUrl, `Too many redirections (${redirected + 1})`);
|
|
5267
|
+
if (visited.has(alternateUrl)) throw new FetchError(currentUrl, `Redirect loop detected: ${alternateUrl}`);
|
|
5268
|
+
return await load(alternateUrl, options, redirected + 1, visited);
|
|
5269
|
+
});
|
|
5222
5270
|
span.setAttribute("docloader.document_url", result.documentUrl);
|
|
5223
5271
|
if (result.contextUrl != null) span.setAttribute("docloader.context_url", result.contextUrl);
|
|
5224
5272
|
return result;
|
|
@@ -5234,7 +5282,7 @@ function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAge
|
|
|
5234
5282
|
}
|
|
5235
5283
|
});
|
|
5236
5284
|
}
|
|
5237
|
-
return load;
|
|
5285
|
+
return (url, options) => load(url, options);
|
|
5238
5286
|
}
|
|
5239
5287
|
//#endregion
|
|
5240
5288
|
//#region src/internal/multicodec.ts
|
package/dist/mod.d.cts
CHANGED
|
@@ -174,6 +174,8 @@ interface GetDocumentLoaderOptions extends DocumentLoaderFactoryOptions {
|
|
|
174
174
|
}
|
|
175
175
|
/**
|
|
176
176
|
* Creates a JSON-LD document loader that utilizes the browser's `fetch` API.
|
|
177
|
+
* At most 20 HTTP redirects and alternate document links are followed in total
|
|
178
|
+
* per call. Revisiting a URL within that chain throws a {@link FetchError}.
|
|
177
179
|
*
|
|
178
180
|
* The created loader preloads the below frequently used contexts by default
|
|
179
181
|
* (unless `options.skipPreloadedContexts` is set to `true`):
|
|
@@ -185,6 +187,7 @@ interface GetDocumentLoaderOptions extends DocumentLoaderFactoryOptions {
|
|
|
185
187
|
* - <https://www.w3.org/ns/cid/v1>
|
|
186
188
|
* - <https://w3id.org/security/multikey/v1>
|
|
187
189
|
* - <https://w3id.org/fep/ef61>
|
|
190
|
+
* - <https://w3id.org/fep/7aa9>
|
|
188
191
|
* - <https://purl.archive.org/socialweb/webfinger>
|
|
189
192
|
* - <http://schema.org/>
|
|
190
193
|
* @param options Options for the document loader.
|
|
@@ -419,8 +422,15 @@ declare function encodingFromBaseData(data: string | Uint8Array): Base;
|
|
|
419
422
|
//#endregion
|
|
420
423
|
//#region src/url.d.ts
|
|
421
424
|
declare class UrlError extends Error {
|
|
425
|
+
/**
|
|
426
|
+
* The failure category. Defaults to `"disallowed"`.
|
|
427
|
+
* `"dns"` includes lookup errors and results with no usable IP addresses.
|
|
428
|
+
* @since 2.0.29
|
|
429
|
+
*/
|
|
430
|
+
readonly reason: "dns" | "disallowed";
|
|
422
431
|
constructor(message: string, options?: {
|
|
423
432
|
cause?: unknown;
|
|
433
|
+
reason?: "dns" | "disallowed";
|
|
424
434
|
});
|
|
425
435
|
}
|
|
426
436
|
/**
|
package/dist/mod.d.ts
CHANGED
|
@@ -173,6 +173,8 @@ interface GetDocumentLoaderOptions extends DocumentLoaderFactoryOptions {
|
|
|
173
173
|
}
|
|
174
174
|
/**
|
|
175
175
|
* Creates a JSON-LD document loader that utilizes the browser's `fetch` API.
|
|
176
|
+
* At most 20 HTTP redirects and alternate document links are followed in total
|
|
177
|
+
* per call. Revisiting a URL within that chain throws a {@link FetchError}.
|
|
176
178
|
*
|
|
177
179
|
* The created loader preloads the below frequently used contexts by default
|
|
178
180
|
* (unless `options.skipPreloadedContexts` is set to `true`):
|
|
@@ -184,6 +186,7 @@ interface GetDocumentLoaderOptions extends DocumentLoaderFactoryOptions {
|
|
|
184
186
|
* - <https://www.w3.org/ns/cid/v1>
|
|
185
187
|
* - <https://w3id.org/security/multikey/v1>
|
|
186
188
|
* - <https://w3id.org/fep/ef61>
|
|
189
|
+
* - <https://w3id.org/fep/7aa9>
|
|
187
190
|
* - <https://purl.archive.org/socialweb/webfinger>
|
|
188
191
|
* - <http://schema.org/>
|
|
189
192
|
* @param options Options for the document loader.
|
|
@@ -418,8 +421,15 @@ declare function encodingFromBaseData(data: string | Uint8Array): Base;
|
|
|
418
421
|
//#endregion
|
|
419
422
|
//#region src/url.d.ts
|
|
420
423
|
declare class UrlError extends Error {
|
|
424
|
+
/**
|
|
425
|
+
* The failure category. Defaults to `"disallowed"`.
|
|
426
|
+
* `"dns"` includes lookup errors and results with no usable IP addresses.
|
|
427
|
+
* @since 2.0.29
|
|
428
|
+
*/
|
|
429
|
+
readonly reason: "dns" | "disallowed";
|
|
421
430
|
constructor(message: string, options?: {
|
|
422
431
|
cause?: unknown;
|
|
432
|
+
reason?: "dns" | "disallowed";
|
|
423
433
|
});
|
|
424
434
|
}
|
|
425
435
|
/**
|
package/dist/mod.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { getLogger } from "@logtape/logtape";
|
|
3
3
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
4
4
|
import process from "node:process";
|
|
5
|
-
import
|
|
5
|
+
import dns from "node:dns/promises";
|
|
6
6
|
import { isIP } from "node:net";
|
|
7
7
|
import { Integer, Sequence } from "asn1js";
|
|
8
8
|
import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
|
|
@@ -595,6 +595,30 @@ var fep_5711_default = { "@context": {
|
|
|
595
595
|
}
|
|
596
596
|
} };
|
|
597
597
|
//#endregion
|
|
598
|
+
//#region src/contexts/fep-7aa9.json
|
|
599
|
+
var fep_7aa9_default = { "@context": {
|
|
600
|
+
"FeaturedCollection": "https://w3id.org/fep/7aa9#FeaturedCollection",
|
|
601
|
+
"FeaturedItem": "https://w3id.org/fep/7aa9#FeaturedItem",
|
|
602
|
+
"FeatureRequest": "https://w3id.org/fep/7aa9#FeatureRequest",
|
|
603
|
+
"FeatureAuthorization": "https://w3id.org/fep/7aa9#FeatureAuthorization",
|
|
604
|
+
"topic": {
|
|
605
|
+
"@id": "https://w3id.org/fep/7aa9#topic",
|
|
606
|
+
"@type": "@id"
|
|
607
|
+
},
|
|
608
|
+
"featuredObject": {
|
|
609
|
+
"@id": "https://w3id.org/fep/7aa9#featuredObject",
|
|
610
|
+
"@type": "@id"
|
|
611
|
+
},
|
|
612
|
+
"canFeature": {
|
|
613
|
+
"@id": "https://w3id.org/fep/7aa9#canFeature",
|
|
614
|
+
"@type": "@id"
|
|
615
|
+
},
|
|
616
|
+
"featureAuthorization": {
|
|
617
|
+
"@id": "https://w3id.org/fep/7aa9#featureAuthorization",
|
|
618
|
+
"@type": "@id"
|
|
619
|
+
}
|
|
620
|
+
} };
|
|
621
|
+
//#endregion
|
|
598
622
|
//#region src/contexts/fep-ef61.json
|
|
599
623
|
var fep_ef61_default = { "@context": {
|
|
600
624
|
"gateways": {
|
|
@@ -4512,6 +4536,7 @@ const preloadedContexts = {
|
|
|
4512
4536
|
"https://w3id.org/fep/5711": fep_5711_default,
|
|
4513
4537
|
"https://www.w3.org/ns/cid/v1": cid_v1_default,
|
|
4514
4538
|
"https://w3id.org/fep/ef61": fep_ef61_default,
|
|
4539
|
+
"https://w3id.org/fep/7aa9": fep_7aa9_default,
|
|
4515
4540
|
"https://join-lemmy.org/context.json": join_lemmy_default,
|
|
4516
4541
|
"http://joinmastodon.org/ns": joinmastodon_default,
|
|
4517
4542
|
"https://purl.archive.org/miscellany": miscellany_default
|
|
@@ -4519,7 +4544,7 @@ const preloadedContexts = {
|
|
|
4519
4544
|
//#endregion
|
|
4520
4545
|
//#region deno.json
|
|
4521
4546
|
var name = "@fedify/vocab-runtime";
|
|
4522
|
-
var version = "2.1.
|
|
4547
|
+
var version = "2.1.25";
|
|
4523
4548
|
//#endregion
|
|
4524
4549
|
//#region src/request.ts
|
|
4525
4550
|
/**
|
|
@@ -4848,9 +4873,16 @@ var HttpHeaderLink = class HttpHeaderLink {
|
|
|
4848
4873
|
//#endregion
|
|
4849
4874
|
//#region src/url.ts
|
|
4850
4875
|
var UrlError = class extends Error {
|
|
4876
|
+
/**
|
|
4877
|
+
* The failure category. Defaults to `"disallowed"`.
|
|
4878
|
+
* `"dns"` includes lookup errors and results with no usable IP addresses.
|
|
4879
|
+
* @since 2.0.29
|
|
4880
|
+
*/
|
|
4881
|
+
reason;
|
|
4851
4882
|
constructor(message, options) {
|
|
4852
4883
|
super(message, options);
|
|
4853
4884
|
this.name = "UrlError";
|
|
4885
|
+
this.reason = options?.reason ?? "disallowed";
|
|
4854
4886
|
}
|
|
4855
4887
|
};
|
|
4856
4888
|
/**
|
|
@@ -4876,9 +4908,12 @@ async function validatePublicUrl(url) {
|
|
|
4876
4908
|
}
|
|
4877
4909
|
let addresses;
|
|
4878
4910
|
try {
|
|
4879
|
-
addresses = await lookup(hostname, { all: true });
|
|
4911
|
+
addresses = await dns.lookup(hostname, { all: true });
|
|
4880
4912
|
} catch (error) {
|
|
4881
|
-
throw new UrlError("DNS lookup failed", {
|
|
4913
|
+
throw new UrlError("DNS lookup failed", {
|
|
4914
|
+
cause: error,
|
|
4915
|
+
reason: "dns"
|
|
4916
|
+
});
|
|
4882
4917
|
}
|
|
4883
4918
|
validateLookupAddresses(addresses);
|
|
4884
4919
|
}
|
|
@@ -4907,7 +4942,7 @@ function validateLookupAddresses(addresses) {
|
|
|
4907
4942
|
ipAddressCount++;
|
|
4908
4943
|
validatePublicIpAddress(address, family);
|
|
4909
4944
|
}
|
|
4910
|
-
if (ipAddressCount === 0) throw new UrlError("DNS lookup did not return any IP address");
|
|
4945
|
+
if (ipAddressCount === 0) throw new UrlError("DNS lookup did not return any IP address", { reason: "dns" });
|
|
4911
4946
|
}
|
|
4912
4947
|
function validatePublicIpAddress(address, family) {
|
|
4913
4948
|
if (family === 4 && isValidPublicIPv4Address(address) || family === 6 && isValidPublicIPv6Address(address)) return;
|
|
@@ -5143,6 +5178,8 @@ async function getRemoteDocument(url, response, fetch) {
|
|
|
5143
5178
|
}
|
|
5144
5179
|
/**
|
|
5145
5180
|
* Creates a JSON-LD document loader that utilizes the browser's `fetch` API.
|
|
5181
|
+
* At most 20 HTTP redirects and alternate document links are followed in total
|
|
5182
|
+
* per call. Revisiting a URL within that chain throws a {@link FetchError}.
|
|
5146
5183
|
*
|
|
5147
5184
|
* The created loader preloads the below frequently used contexts by default
|
|
5148
5185
|
* (unless `options.skipPreloadedContexts` is set to `true`):
|
|
@@ -5154,6 +5191,7 @@ async function getRemoteDocument(url, response, fetch) {
|
|
|
5154
5191
|
* - <https://www.w3.org/ns/cid/v1>
|
|
5155
5192
|
* - <https://w3id.org/security/multikey/v1>
|
|
5156
5193
|
* - <https://w3id.org/fep/ef61>
|
|
5194
|
+
* - <https://w3id.org/fep/7aa9>
|
|
5157
5195
|
* - <https://purl.archive.org/socialweb/webfinger>
|
|
5158
5196
|
* - <http://schema.org/>
|
|
5159
5197
|
* @param options Options for the document loader.
|
|
@@ -5176,7 +5214,11 @@ function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAge
|
|
|
5176
5214
|
if (!allowPrivateAddress) try {
|
|
5177
5215
|
await validatePublicUrl(currentUrl);
|
|
5178
5216
|
} catch (error) {
|
|
5179
|
-
if (error instanceof UrlError) logger.
|
|
5217
|
+
if (error instanceof UrlError) if (error.reason === "dns") logger.debug("DNS lookup failed for {url}", {
|
|
5218
|
+
url: currentUrl,
|
|
5219
|
+
error
|
|
5220
|
+
});
|
|
5221
|
+
else logger.error("Disallowed private URL: {url}", {
|
|
5180
5222
|
url: currentUrl,
|
|
5181
5223
|
error
|
|
5182
5224
|
});
|
|
@@ -5214,7 +5256,12 @@ function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAge
|
|
|
5214
5256
|
}
|
|
5215
5257
|
return await load(redirectUrl, options, redirected + 1, visited);
|
|
5216
5258
|
}
|
|
5217
|
-
const result = await getRemoteDocument(currentUrl, response,
|
|
5259
|
+
const result = await getRemoteDocument(currentUrl, response, async (alternateUrl) => {
|
|
5260
|
+
options?.signal?.throwIfAborted();
|
|
5261
|
+
if (redirected >= DEFAULT_MAX_REDIRECTION) throw new FetchError(currentUrl, `Too many redirections (${redirected + 1})`);
|
|
5262
|
+
if (visited.has(alternateUrl)) throw new FetchError(currentUrl, `Redirect loop detected: ${alternateUrl}`);
|
|
5263
|
+
return await load(alternateUrl, options, redirected + 1, visited);
|
|
5264
|
+
});
|
|
5218
5265
|
span.setAttribute("docloader.document_url", result.documentUrl);
|
|
5219
5266
|
if (result.contextUrl != null) span.setAttribute("docloader.context_url", result.contextUrl);
|
|
5220
5267
|
return result;
|
|
@@ -5230,7 +5277,7 @@ function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAge
|
|
|
5230
5277
|
}
|
|
5231
5278
|
});
|
|
5232
5279
|
}
|
|
5233
|
-
return load;
|
|
5280
|
+
return (url, options) => load(url, options);
|
|
5234
5281
|
}
|
|
5235
5282
|
//#endregion
|
|
5236
5283
|
//#region src/internal/multicodec.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require("./chunk-Do9eywBl.cjs");
|
|
2
|
-
const require_request = require("./request-
|
|
2
|
+
const require_request = require("./request-DrO5xzev.cjs");
|
|
3
3
|
let _logtape_logtape = require("@logtape/logtape");
|
|
4
4
|
//#region src/body.ts
|
|
5
5
|
/** Decoded JSON body limit: 16 MiB. @internal */
|
package/dist/tests/body.test.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require("./chunk-Do9eywBl.cjs");
|
|
2
|
-
const require_body = require("./body-
|
|
2
|
+
const require_body = require("./body-D-gC5vdl.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");
|
package/dist/tests/body.test.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as readBoundedText, t as BodyTooLargeError } from "./body-
|
|
1
|
+
import { r as readBoundedText, t as BodyTooLargeError } from "./body-DBqFojnW.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,6 +1,6 @@
|
|
|
1
1
|
require("./chunk-Do9eywBl.cjs");
|
|
2
|
-
require("./docloader-
|
|
3
|
-
require("./url-
|
|
2
|
+
require("./docloader-fn4ICzFS.cjs");
|
|
3
|
+
require("./url-vZTgkIZg.cjs");
|
|
4
4
|
require("./key-BarKGLQz.cjs");
|
|
5
5
|
require("./multibase-8zhYPa7o.cjs");
|
|
6
6
|
require("./langstr-BOQHfJDr.cjs");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as name, i as logRequest, n as createActivityPubRequest, o as version, t as FetchError } from "./request-
|
|
2
|
-
import { n as MAX_BODY_SIZE, r as readBoundedText } from "./body-
|
|
1
|
+
import { a as name, i as logRequest, n as createActivityPubRequest, o as version, t as FetchError } from "./request-DxeGyJVh.mjs";
|
|
2
|
+
import { n as MAX_BODY_SIZE, r as readBoundedText } from "./body-DBqFojnW.mjs";
|
|
3
3
|
import { t as HttpHeaderLink } from "./link-CYszIegt.mjs";
|
|
4
|
-
import { o as validatePublicUrl, t as UrlError } from "./url-
|
|
4
|
+
import { o as validatePublicUrl, t as UrlError } from "./url-3fyJuqC0.mjs";
|
|
5
5
|
import { getLogger } from "@logtape/logtape";
|
|
6
6
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
7
7
|
//#region src/contexts/activitystreams.json
|
|
@@ -589,6 +589,30 @@ var fep_5711_default = { "@context": {
|
|
|
589
589
|
}
|
|
590
590
|
} };
|
|
591
591
|
//#endregion
|
|
592
|
+
//#region src/contexts/fep-7aa9.json
|
|
593
|
+
var fep_7aa9_default = { "@context": {
|
|
594
|
+
"FeaturedCollection": "https://w3id.org/fep/7aa9#FeaturedCollection",
|
|
595
|
+
"FeaturedItem": "https://w3id.org/fep/7aa9#FeaturedItem",
|
|
596
|
+
"FeatureRequest": "https://w3id.org/fep/7aa9#FeatureRequest",
|
|
597
|
+
"FeatureAuthorization": "https://w3id.org/fep/7aa9#FeatureAuthorization",
|
|
598
|
+
"topic": {
|
|
599
|
+
"@id": "https://w3id.org/fep/7aa9#topic",
|
|
600
|
+
"@type": "@id"
|
|
601
|
+
},
|
|
602
|
+
"featuredObject": {
|
|
603
|
+
"@id": "https://w3id.org/fep/7aa9#featuredObject",
|
|
604
|
+
"@type": "@id"
|
|
605
|
+
},
|
|
606
|
+
"canFeature": {
|
|
607
|
+
"@id": "https://w3id.org/fep/7aa9#canFeature",
|
|
608
|
+
"@type": "@id"
|
|
609
|
+
},
|
|
610
|
+
"featureAuthorization": {
|
|
611
|
+
"@id": "https://w3id.org/fep/7aa9#featureAuthorization",
|
|
612
|
+
"@type": "@id"
|
|
613
|
+
}
|
|
614
|
+
} };
|
|
615
|
+
//#endregion
|
|
592
616
|
//#region src/contexts/fep-ef61.json
|
|
593
617
|
var fep_ef61_default = { "@context": {
|
|
594
618
|
"gateways": {
|
|
@@ -4506,6 +4530,7 @@ const preloadedContexts = {
|
|
|
4506
4530
|
"https://w3id.org/fep/5711": fep_5711_default,
|
|
4507
4531
|
"https://www.w3.org/ns/cid/v1": cid_v1_default,
|
|
4508
4532
|
"https://w3id.org/fep/ef61": fep_ef61_default,
|
|
4533
|
+
"https://w3id.org/fep/7aa9": fep_7aa9_default,
|
|
4509
4534
|
"https://join-lemmy.org/context.json": join_lemmy_default,
|
|
4510
4535
|
"http://joinmastodon.org/ns": joinmastodon_default,
|
|
4511
4536
|
"https://purl.archive.org/miscellany": miscellany_default
|
|
@@ -4608,6 +4633,8 @@ async function getRemoteDocument(url, response, fetch) {
|
|
|
4608
4633
|
}
|
|
4609
4634
|
/**
|
|
4610
4635
|
* Creates a JSON-LD document loader that utilizes the browser's `fetch` API.
|
|
4636
|
+
* At most 20 HTTP redirects and alternate document links are followed in total
|
|
4637
|
+
* per call. Revisiting a URL within that chain throws a {@link FetchError}.
|
|
4611
4638
|
*
|
|
4612
4639
|
* The created loader preloads the below frequently used contexts by default
|
|
4613
4640
|
* (unless `options.skipPreloadedContexts` is set to `true`):
|
|
@@ -4619,6 +4646,7 @@ async function getRemoteDocument(url, response, fetch) {
|
|
|
4619
4646
|
* - <https://www.w3.org/ns/cid/v1>
|
|
4620
4647
|
* - <https://w3id.org/security/multikey/v1>
|
|
4621
4648
|
* - <https://w3id.org/fep/ef61>
|
|
4649
|
+
* - <https://w3id.org/fep/7aa9>
|
|
4622
4650
|
* - <https://purl.archive.org/socialweb/webfinger>
|
|
4623
4651
|
* - <http://schema.org/>
|
|
4624
4652
|
* @param options Options for the document loader.
|
|
@@ -4641,7 +4669,11 @@ function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAge
|
|
|
4641
4669
|
if (!allowPrivateAddress) try {
|
|
4642
4670
|
await validatePublicUrl(currentUrl);
|
|
4643
4671
|
} catch (error) {
|
|
4644
|
-
if (error instanceof UrlError) logger.
|
|
4672
|
+
if (error instanceof UrlError) if (error.reason === "dns") logger.debug("DNS lookup failed for {url}", {
|
|
4673
|
+
url: currentUrl,
|
|
4674
|
+
error
|
|
4675
|
+
});
|
|
4676
|
+
else logger.error("Disallowed private URL: {url}", {
|
|
4645
4677
|
url: currentUrl,
|
|
4646
4678
|
error
|
|
4647
4679
|
});
|
|
@@ -4679,7 +4711,12 @@ function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAge
|
|
|
4679
4711
|
}
|
|
4680
4712
|
return await load(redirectUrl, options, redirected + 1, visited);
|
|
4681
4713
|
}
|
|
4682
|
-
const result = await getRemoteDocument(currentUrl, response,
|
|
4714
|
+
const result = await getRemoteDocument(currentUrl, response, async (alternateUrl) => {
|
|
4715
|
+
options?.signal?.throwIfAborted();
|
|
4716
|
+
if (redirected >= DEFAULT_MAX_REDIRECTION) throw new FetchError(currentUrl, `Too many redirections (${redirected + 1})`);
|
|
4717
|
+
if (visited.has(alternateUrl)) throw new FetchError(currentUrl, `Redirect loop detected: ${alternateUrl}`);
|
|
4718
|
+
return await load(alternateUrl, options, redirected + 1, visited);
|
|
4719
|
+
});
|
|
4683
4720
|
span.setAttribute("docloader.document_url", result.documentUrl);
|
|
4684
4721
|
if (result.contextUrl != null) span.setAttribute("docloader.context_url", result.contextUrl);
|
|
4685
4722
|
return result;
|
|
@@ -4695,7 +4732,7 @@ function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAge
|
|
|
4695
4732
|
}
|
|
4696
4733
|
});
|
|
4697
4734
|
}
|
|
4698
|
-
return load;
|
|
4735
|
+
return (url, options) => load(url, options);
|
|
4699
4736
|
}
|
|
4700
4737
|
//#endregion
|
|
4701
4738
|
export { cid_v1_default as i, getRemoteDocument as n, preloadedContexts as r, getDocumentLoader as t };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
require("./chunk-Do9eywBl.cjs");
|
|
2
|
-
const require_request = require("./request-
|
|
3
|
-
const require_body = require("./body-
|
|
2
|
+
const require_request = require("./request-DrO5xzev.cjs");
|
|
3
|
+
const require_body = require("./body-D-gC5vdl.cjs");
|
|
4
4
|
const require_link = require("./link-qDTmjPw_.cjs");
|
|
5
|
-
const require_url = require("./url-
|
|
5
|
+
const require_url = require("./url-vZTgkIZg.cjs");
|
|
6
6
|
let _logtape_logtape = require("@logtape/logtape");
|
|
7
7
|
let _opentelemetry_api = require("@opentelemetry/api");
|
|
8
8
|
//#region src/contexts/activitystreams.json
|
|
@@ -590,6 +590,30 @@ var fep_5711_default = { "@context": {
|
|
|
590
590
|
}
|
|
591
591
|
} };
|
|
592
592
|
//#endregion
|
|
593
|
+
//#region src/contexts/fep-7aa9.json
|
|
594
|
+
var fep_7aa9_default = { "@context": {
|
|
595
|
+
"FeaturedCollection": "https://w3id.org/fep/7aa9#FeaturedCollection",
|
|
596
|
+
"FeaturedItem": "https://w3id.org/fep/7aa9#FeaturedItem",
|
|
597
|
+
"FeatureRequest": "https://w3id.org/fep/7aa9#FeatureRequest",
|
|
598
|
+
"FeatureAuthorization": "https://w3id.org/fep/7aa9#FeatureAuthorization",
|
|
599
|
+
"topic": {
|
|
600
|
+
"@id": "https://w3id.org/fep/7aa9#topic",
|
|
601
|
+
"@type": "@id"
|
|
602
|
+
},
|
|
603
|
+
"featuredObject": {
|
|
604
|
+
"@id": "https://w3id.org/fep/7aa9#featuredObject",
|
|
605
|
+
"@type": "@id"
|
|
606
|
+
},
|
|
607
|
+
"canFeature": {
|
|
608
|
+
"@id": "https://w3id.org/fep/7aa9#canFeature",
|
|
609
|
+
"@type": "@id"
|
|
610
|
+
},
|
|
611
|
+
"featureAuthorization": {
|
|
612
|
+
"@id": "https://w3id.org/fep/7aa9#featureAuthorization",
|
|
613
|
+
"@type": "@id"
|
|
614
|
+
}
|
|
615
|
+
} };
|
|
616
|
+
//#endregion
|
|
593
617
|
//#region src/contexts/fep-ef61.json
|
|
594
618
|
var fep_ef61_default = { "@context": {
|
|
595
619
|
"gateways": {
|
|
@@ -4507,6 +4531,7 @@ const preloadedContexts = {
|
|
|
4507
4531
|
"https://w3id.org/fep/5711": fep_5711_default,
|
|
4508
4532
|
"https://www.w3.org/ns/cid/v1": cid_v1_default,
|
|
4509
4533
|
"https://w3id.org/fep/ef61": fep_ef61_default,
|
|
4534
|
+
"https://w3id.org/fep/7aa9": fep_7aa9_default,
|
|
4510
4535
|
"https://join-lemmy.org/context.json": join_lemmy_default,
|
|
4511
4536
|
"http://joinmastodon.org/ns": joinmastodon_default,
|
|
4512
4537
|
"https://purl.archive.org/miscellany": miscellany_default
|
|
@@ -4609,6 +4634,8 @@ async function getRemoteDocument(url, response, fetch) {
|
|
|
4609
4634
|
}
|
|
4610
4635
|
/**
|
|
4611
4636
|
* Creates a JSON-LD document loader that utilizes the browser's `fetch` API.
|
|
4637
|
+
* At most 20 HTTP redirects and alternate document links are followed in total
|
|
4638
|
+
* per call. Revisiting a URL within that chain throws a {@link FetchError}.
|
|
4612
4639
|
*
|
|
4613
4640
|
* The created loader preloads the below frequently used contexts by default
|
|
4614
4641
|
* (unless `options.skipPreloadedContexts` is set to `true`):
|
|
@@ -4620,6 +4647,7 @@ async function getRemoteDocument(url, response, fetch) {
|
|
|
4620
4647
|
* - <https://www.w3.org/ns/cid/v1>
|
|
4621
4648
|
* - <https://w3id.org/security/multikey/v1>
|
|
4622
4649
|
* - <https://w3id.org/fep/ef61>
|
|
4650
|
+
* - <https://w3id.org/fep/7aa9>
|
|
4623
4651
|
* - <https://purl.archive.org/socialweb/webfinger>
|
|
4624
4652
|
* - <http://schema.org/>
|
|
4625
4653
|
* @param options Options for the document loader.
|
|
@@ -4642,7 +4670,11 @@ function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAge
|
|
|
4642
4670
|
if (!allowPrivateAddress) try {
|
|
4643
4671
|
await require_url.validatePublicUrl(currentUrl);
|
|
4644
4672
|
} catch (error) {
|
|
4645
|
-
if (error instanceof require_url.UrlError) logger.
|
|
4673
|
+
if (error instanceof require_url.UrlError) if (error.reason === "dns") logger.debug("DNS lookup failed for {url}", {
|
|
4674
|
+
url: currentUrl,
|
|
4675
|
+
error
|
|
4676
|
+
});
|
|
4677
|
+
else logger.error("Disallowed private URL: {url}", {
|
|
4646
4678
|
url: currentUrl,
|
|
4647
4679
|
error
|
|
4648
4680
|
});
|
|
@@ -4680,7 +4712,12 @@ function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAge
|
|
|
4680
4712
|
}
|
|
4681
4713
|
return await load(redirectUrl, options, redirected + 1, visited);
|
|
4682
4714
|
}
|
|
4683
|
-
const result = await getRemoteDocument(currentUrl, response,
|
|
4715
|
+
const result = await getRemoteDocument(currentUrl, response, async (alternateUrl) => {
|
|
4716
|
+
options?.signal?.throwIfAborted();
|
|
4717
|
+
if (redirected >= DEFAULT_MAX_REDIRECTION) throw new require_request.FetchError(currentUrl, `Too many redirections (${redirected + 1})`);
|
|
4718
|
+
if (visited.has(alternateUrl)) throw new require_request.FetchError(currentUrl, `Redirect loop detected: ${alternateUrl}`);
|
|
4719
|
+
return await load(alternateUrl, options, redirected + 1, visited);
|
|
4720
|
+
});
|
|
4684
4721
|
span.setAttribute("docloader.document_url", result.documentUrl);
|
|
4685
4722
|
if (result.contextUrl != null) span.setAttribute("docloader.context_url", result.contextUrl);
|
|
4686
4723
|
return result;
|
|
@@ -4696,7 +4733,7 @@ function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAge
|
|
|
4696
4733
|
}
|
|
4697
4734
|
});
|
|
4698
4735
|
}
|
|
4699
|
-
return load;
|
|
4736
|
+
return (url, options) => load(url, options);
|
|
4700
4737
|
}
|
|
4701
4738
|
//#endregion
|
|
4702
4739
|
Object.defineProperty(exports, "cid_v1_default", {
|