@fedify/vocab-runtime 2.3.9-dev.2048 → 2.3.10
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 +52 -7
- package/dist/mod.d.cts +10 -0
- package/dist/mod.d.ts +10 -0
- package/dist/mod.js +52 -8
- package/dist/tests/{body-C0gO8fmt.cjs → body-BBcqb6fc.cjs} +1 -1
- package/dist/tests/{body-DYKjs6_2.mjs → body-Dl_2ZsMa.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-B3cffcK1.mjs → docloader-Ciq51f7p.mjs} +40 -6
- package/dist/tests/{docloader-BqznqaJT.cjs → docloader-D8C3FEvV.cjs} +40 -6
- package/dist/tests/docloader.test.cjs +241 -3
- package/dist/tests/docloader.test.mjs +240 -3
- package/dist/tests/{request-89V7ieWl.mjs → request-8CWJM_ZM.mjs} +1 -1
- package/dist/tests/{request-4o-Cs0CR.cjs → request-DWx4I133.cjs} +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-BbEC9H_R.cjs → url-4PAkYhZC.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, 1);
|
|
8
8
|
let node_dns_promises = require("node:dns/promises");
|
|
9
|
+
node_dns_promises = require_chunk.__toESM(node_dns_promises, 1);
|
|
9
10
|
let node_net = require("node:net");
|
|
10
11
|
let asn1js = require("asn1js");
|
|
11
12
|
let byte_encodings_base64 = require("byte-encodings/base64");
|
|
@@ -4407,6 +4408,28 @@ const preloadedContexts = {
|
|
|
4407
4408
|
},
|
|
4408
4409
|
"digestMultibase": "https://www.w3.org/ns/credentials/v2#digestMultibase"
|
|
4409
4410
|
} },
|
|
4411
|
+
"https://w3id.org/fep/7aa9": { "@context": {
|
|
4412
|
+
"FeaturedCollection": "https://w3id.org/fep/7aa9#FeaturedCollection",
|
|
4413
|
+
"FeaturedItem": "https://w3id.org/fep/7aa9#FeaturedItem",
|
|
4414
|
+
"FeatureRequest": "https://w3id.org/fep/7aa9#FeatureRequest",
|
|
4415
|
+
"FeatureAuthorization": "https://w3id.org/fep/7aa9#FeatureAuthorization",
|
|
4416
|
+
"topic": {
|
|
4417
|
+
"@id": "https://w3id.org/fep/7aa9#topic",
|
|
4418
|
+
"@type": "@id"
|
|
4419
|
+
},
|
|
4420
|
+
"featuredObject": {
|
|
4421
|
+
"@id": "https://w3id.org/fep/7aa9#featuredObject",
|
|
4422
|
+
"@type": "@id"
|
|
4423
|
+
},
|
|
4424
|
+
"canFeature": {
|
|
4425
|
+
"@id": "https://w3id.org/fep/7aa9#canFeature",
|
|
4426
|
+
"@type": "@id"
|
|
4427
|
+
},
|
|
4428
|
+
"featureAuthorization": {
|
|
4429
|
+
"@id": "https://w3id.org/fep/7aa9#featureAuthorization",
|
|
4430
|
+
"@type": "@id"
|
|
4431
|
+
}
|
|
4432
|
+
} },
|
|
4410
4433
|
"https://join-lemmy.org/context.json": { "@context": ["https://w3id.org/security/v1", {
|
|
4411
4434
|
"as": "https://www.w3.org/ns/activitystreams#",
|
|
4412
4435
|
"lemmy": "https://join-lemmy.org/ns#",
|
|
@@ -4476,7 +4499,7 @@ const preloadedContexts = {
|
|
|
4476
4499
|
//#endregion
|
|
4477
4500
|
//#region deno.json
|
|
4478
4501
|
var name = "@fedify/vocab-runtime";
|
|
4479
|
-
var version = "2.3.
|
|
4502
|
+
var version = "2.3.10";
|
|
4480
4503
|
//#endregion
|
|
4481
4504
|
//#region src/request.ts
|
|
4482
4505
|
/**
|
|
@@ -4805,9 +4828,16 @@ var HttpHeaderLink = class HttpHeaderLink {
|
|
|
4805
4828
|
//#endregion
|
|
4806
4829
|
//#region src/url.ts
|
|
4807
4830
|
var UrlError = class extends Error {
|
|
4831
|
+
/**
|
|
4832
|
+
* The failure category. Defaults to `"disallowed"`.
|
|
4833
|
+
* `"dns"` includes lookup errors and results with no usable IP addresses.
|
|
4834
|
+
* @since 2.0.29
|
|
4835
|
+
*/
|
|
4836
|
+
reason;
|
|
4808
4837
|
constructor(message, options) {
|
|
4809
4838
|
super(message, options);
|
|
4810
4839
|
this.name = "UrlError";
|
|
4840
|
+
this.reason = options?.reason ?? "disallowed";
|
|
4811
4841
|
}
|
|
4812
4842
|
};
|
|
4813
4843
|
/**
|
|
@@ -4833,9 +4863,12 @@ async function validatePublicUrl(url) {
|
|
|
4833
4863
|
}
|
|
4834
4864
|
let addresses;
|
|
4835
4865
|
try {
|
|
4836
|
-
addresses = await
|
|
4866
|
+
addresses = await node_dns_promises.default.lookup(hostname, { all: true });
|
|
4837
4867
|
} catch (error) {
|
|
4838
|
-
throw new UrlError("DNS lookup failed", {
|
|
4868
|
+
throw new UrlError("DNS lookup failed", {
|
|
4869
|
+
cause: error,
|
|
4870
|
+
reason: "dns"
|
|
4871
|
+
});
|
|
4839
4872
|
}
|
|
4840
4873
|
validateLookupAddresses(addresses);
|
|
4841
4874
|
}
|
|
@@ -4864,7 +4897,7 @@ function validateLookupAddresses(addresses) {
|
|
|
4864
4897
|
ipAddressCount++;
|
|
4865
4898
|
validatePublicIpAddress(address, family);
|
|
4866
4899
|
}
|
|
4867
|
-
if (ipAddressCount === 0) throw new UrlError("DNS lookup did not return any IP address");
|
|
4900
|
+
if (ipAddressCount === 0) throw new UrlError("DNS lookup did not return any IP address", { reason: "dns" });
|
|
4868
4901
|
}
|
|
4869
4902
|
function validatePublicIpAddress(address, family) {
|
|
4870
4903
|
if (family === 4 && isValidPublicIPv4Address(address) || family === 6 && isValidPublicIPv6Address(address)) return;
|
|
@@ -5100,6 +5133,8 @@ async function getRemoteDocument(url, response, fetch) {
|
|
|
5100
5133
|
}
|
|
5101
5134
|
/**
|
|
5102
5135
|
* Creates a JSON-LD document loader that utilizes the browser's `fetch` API.
|
|
5136
|
+
* At most 20 HTTP redirects and alternate document links are followed in total
|
|
5137
|
+
* per call. Revisiting a URL within that chain throws a {@link FetchError}.
|
|
5103
5138
|
*
|
|
5104
5139
|
* The created loader preloads the below frequently used contexts by default
|
|
5105
5140
|
* (unless `options.skipPreloadedContexts` is set to `true`):
|
|
@@ -5111,6 +5146,7 @@ async function getRemoteDocument(url, response, fetch) {
|
|
|
5111
5146
|
* - <https://www.w3.org/ns/cid/v1>
|
|
5112
5147
|
* - <https://w3id.org/security/multikey/v1>
|
|
5113
5148
|
* - <https://w3id.org/fep/ef61>
|
|
5149
|
+
* - <https://w3id.org/fep/7aa9>
|
|
5114
5150
|
* - <https://purl.archive.org/socialweb/webfinger>
|
|
5115
5151
|
* - <http://schema.org/>
|
|
5116
5152
|
* @param options Options for the document loader.
|
|
@@ -5134,7 +5170,11 @@ function getDocumentLoader({ allowPrivateAddress, maxRedirection, skipPreloadedC
|
|
|
5134
5170
|
if (!allowPrivateAddress) try {
|
|
5135
5171
|
await validatePublicUrl(currentUrl);
|
|
5136
5172
|
} catch (error) {
|
|
5137
|
-
if (error instanceof UrlError) logger.
|
|
5173
|
+
if (error instanceof UrlError) if (error.reason === "dns") logger.debug("DNS lookup failed for {url}", {
|
|
5174
|
+
url: currentUrl,
|
|
5175
|
+
error
|
|
5176
|
+
});
|
|
5177
|
+
else logger.error("Disallowed private URL: {url}", {
|
|
5138
5178
|
url: currentUrl,
|
|
5139
5179
|
error
|
|
5140
5180
|
});
|
|
@@ -5172,7 +5212,12 @@ function getDocumentLoader({ allowPrivateAddress, maxRedirection, skipPreloadedC
|
|
|
5172
5212
|
}
|
|
5173
5213
|
return await load(redirectUrl, options, redirected + 1, visited);
|
|
5174
5214
|
}
|
|
5175
|
-
const result = await getRemoteDocument(currentUrl, response,
|
|
5215
|
+
const result = await getRemoteDocument(currentUrl, response, async (alternateUrl) => {
|
|
5216
|
+
options?.signal?.throwIfAborted();
|
|
5217
|
+
if (redirected >= DEFAULT_MAX_REDIRECTION) throw new FetchError(currentUrl, `Too many redirections (${redirected + 1})`);
|
|
5218
|
+
if (visited.has(alternateUrl)) throw new FetchError(currentUrl, `Redirect loop detected: ${alternateUrl}`);
|
|
5219
|
+
return await load(alternateUrl, options, redirected + 1, visited);
|
|
5220
|
+
});
|
|
5176
5221
|
span.setAttribute("docloader.document_url", result.documentUrl);
|
|
5177
5222
|
if (result.contextUrl != null) span.setAttribute("docloader.context_url", result.contextUrl);
|
|
5178
5223
|
return result;
|
|
@@ -5188,7 +5233,7 @@ function getDocumentLoader({ allowPrivateAddress, maxRedirection, skipPreloadedC
|
|
|
5188
5233
|
}
|
|
5189
5234
|
});
|
|
5190
5235
|
}
|
|
5191
|
-
return load;
|
|
5236
|
+
return (url, options) => load(url, options);
|
|
5192
5237
|
}
|
|
5193
5238
|
//#endregion
|
|
5194
5239
|
//#region src/internal/multicodec.ts
|
package/dist/mod.d.cts
CHANGED
|
@@ -181,6 +181,8 @@ interface GetDocumentLoaderOptions extends DocumentLoaderFactoryOptions {
|
|
|
181
181
|
}
|
|
182
182
|
/**
|
|
183
183
|
* Creates a JSON-LD document loader that utilizes the browser's `fetch` API.
|
|
184
|
+
* At most 20 HTTP redirects and alternate document links are followed in total
|
|
185
|
+
* per call. Revisiting a URL within that chain throws a {@link FetchError}.
|
|
184
186
|
*
|
|
185
187
|
* The created loader preloads the below frequently used contexts by default
|
|
186
188
|
* (unless `options.skipPreloadedContexts` is set to `true`):
|
|
@@ -192,6 +194,7 @@ interface GetDocumentLoaderOptions extends DocumentLoaderFactoryOptions {
|
|
|
192
194
|
* - <https://www.w3.org/ns/cid/v1>
|
|
193
195
|
* - <https://w3id.org/security/multikey/v1>
|
|
194
196
|
* - <https://w3id.org/fep/ef61>
|
|
197
|
+
* - <https://w3id.org/fep/7aa9>
|
|
195
198
|
* - <https://purl.archive.org/socialweb/webfinger>
|
|
196
199
|
* - <http://schema.org/>
|
|
197
200
|
* @param options Options for the document loader.
|
|
@@ -460,8 +463,15 @@ type PropertyPreprocessor<T = unknown> = (value: Json, context: PropertyPreproce
|
|
|
460
463
|
//#endregion
|
|
461
464
|
//#region src/url.d.ts
|
|
462
465
|
declare class UrlError extends Error {
|
|
466
|
+
/**
|
|
467
|
+
* The failure category. Defaults to `"disallowed"`.
|
|
468
|
+
* `"dns"` includes lookup errors and results with no usable IP addresses.
|
|
469
|
+
* @since 2.0.29
|
|
470
|
+
*/
|
|
471
|
+
readonly reason: "dns" | "disallowed";
|
|
463
472
|
constructor(message: string, options?: {
|
|
464
473
|
cause?: unknown;
|
|
474
|
+
reason?: "dns" | "disallowed";
|
|
465
475
|
});
|
|
466
476
|
}
|
|
467
477
|
/**
|
package/dist/mod.d.ts
CHANGED
|
@@ -180,6 +180,8 @@ interface GetDocumentLoaderOptions extends DocumentLoaderFactoryOptions {
|
|
|
180
180
|
}
|
|
181
181
|
/**
|
|
182
182
|
* Creates a JSON-LD document loader that utilizes the browser's `fetch` API.
|
|
183
|
+
* At most 20 HTTP redirects and alternate document links are followed in total
|
|
184
|
+
* per call. Revisiting a URL within that chain throws a {@link FetchError}.
|
|
183
185
|
*
|
|
184
186
|
* The created loader preloads the below frequently used contexts by default
|
|
185
187
|
* (unless `options.skipPreloadedContexts` is set to `true`):
|
|
@@ -191,6 +193,7 @@ interface GetDocumentLoaderOptions extends DocumentLoaderFactoryOptions {
|
|
|
191
193
|
* - <https://www.w3.org/ns/cid/v1>
|
|
192
194
|
* - <https://w3id.org/security/multikey/v1>
|
|
193
195
|
* - <https://w3id.org/fep/ef61>
|
|
196
|
+
* - <https://w3id.org/fep/7aa9>
|
|
194
197
|
* - <https://purl.archive.org/socialweb/webfinger>
|
|
195
198
|
* - <http://schema.org/>
|
|
196
199
|
* @param options Options for the document loader.
|
|
@@ -459,8 +462,15 @@ type PropertyPreprocessor<T = unknown> = (value: Json, context: PropertyPreproce
|
|
|
459
462
|
//#endregion
|
|
460
463
|
//#region src/url.d.ts
|
|
461
464
|
declare class UrlError extends Error {
|
|
465
|
+
/**
|
|
466
|
+
* The failure category. Defaults to `"disallowed"`.
|
|
467
|
+
* `"dns"` includes lookup errors and results with no usable IP addresses.
|
|
468
|
+
* @since 2.0.29
|
|
469
|
+
*/
|
|
470
|
+
readonly reason: "dns" | "disallowed";
|
|
462
471
|
constructor(message: string, options?: {
|
|
463
472
|
cause?: unknown;
|
|
473
|
+
reason?: "dns" | "disallowed";
|
|
464
474
|
});
|
|
465
475
|
}
|
|
466
476
|
/**
|
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";
|
|
@@ -4403,6 +4403,28 @@ const preloadedContexts = {
|
|
|
4403
4403
|
},
|
|
4404
4404
|
"digestMultibase": "https://www.w3.org/ns/credentials/v2#digestMultibase"
|
|
4405
4405
|
} },
|
|
4406
|
+
"https://w3id.org/fep/7aa9": { "@context": {
|
|
4407
|
+
"FeaturedCollection": "https://w3id.org/fep/7aa9#FeaturedCollection",
|
|
4408
|
+
"FeaturedItem": "https://w3id.org/fep/7aa9#FeaturedItem",
|
|
4409
|
+
"FeatureRequest": "https://w3id.org/fep/7aa9#FeatureRequest",
|
|
4410
|
+
"FeatureAuthorization": "https://w3id.org/fep/7aa9#FeatureAuthorization",
|
|
4411
|
+
"topic": {
|
|
4412
|
+
"@id": "https://w3id.org/fep/7aa9#topic",
|
|
4413
|
+
"@type": "@id"
|
|
4414
|
+
},
|
|
4415
|
+
"featuredObject": {
|
|
4416
|
+
"@id": "https://w3id.org/fep/7aa9#featuredObject",
|
|
4417
|
+
"@type": "@id"
|
|
4418
|
+
},
|
|
4419
|
+
"canFeature": {
|
|
4420
|
+
"@id": "https://w3id.org/fep/7aa9#canFeature",
|
|
4421
|
+
"@type": "@id"
|
|
4422
|
+
},
|
|
4423
|
+
"featureAuthorization": {
|
|
4424
|
+
"@id": "https://w3id.org/fep/7aa9#featureAuthorization",
|
|
4425
|
+
"@type": "@id"
|
|
4426
|
+
}
|
|
4427
|
+
} },
|
|
4406
4428
|
"https://join-lemmy.org/context.json": { "@context": ["https://w3id.org/security/v1", {
|
|
4407
4429
|
"as": "https://www.w3.org/ns/activitystreams#",
|
|
4408
4430
|
"lemmy": "https://join-lemmy.org/ns#",
|
|
@@ -4472,7 +4494,7 @@ const preloadedContexts = {
|
|
|
4472
4494
|
//#endregion
|
|
4473
4495
|
//#region deno.json
|
|
4474
4496
|
var name = "@fedify/vocab-runtime";
|
|
4475
|
-
var version = "2.3.
|
|
4497
|
+
var version = "2.3.10";
|
|
4476
4498
|
//#endregion
|
|
4477
4499
|
//#region src/request.ts
|
|
4478
4500
|
/**
|
|
@@ -4801,9 +4823,16 @@ var HttpHeaderLink = class HttpHeaderLink {
|
|
|
4801
4823
|
//#endregion
|
|
4802
4824
|
//#region src/url.ts
|
|
4803
4825
|
var UrlError = class extends Error {
|
|
4826
|
+
/**
|
|
4827
|
+
* The failure category. Defaults to `"disallowed"`.
|
|
4828
|
+
* `"dns"` includes lookup errors and results with no usable IP addresses.
|
|
4829
|
+
* @since 2.0.29
|
|
4830
|
+
*/
|
|
4831
|
+
reason;
|
|
4804
4832
|
constructor(message, options) {
|
|
4805
4833
|
super(message, options);
|
|
4806
4834
|
this.name = "UrlError";
|
|
4835
|
+
this.reason = options?.reason ?? "disallowed";
|
|
4807
4836
|
}
|
|
4808
4837
|
};
|
|
4809
4838
|
/**
|
|
@@ -4829,9 +4858,12 @@ async function validatePublicUrl(url) {
|
|
|
4829
4858
|
}
|
|
4830
4859
|
let addresses;
|
|
4831
4860
|
try {
|
|
4832
|
-
addresses = await lookup(hostname, { all: true });
|
|
4861
|
+
addresses = await dns.lookup(hostname, { all: true });
|
|
4833
4862
|
} catch (error) {
|
|
4834
|
-
throw new UrlError("DNS lookup failed", {
|
|
4863
|
+
throw new UrlError("DNS lookup failed", {
|
|
4864
|
+
cause: error,
|
|
4865
|
+
reason: "dns"
|
|
4866
|
+
});
|
|
4835
4867
|
}
|
|
4836
4868
|
validateLookupAddresses(addresses);
|
|
4837
4869
|
}
|
|
@@ -4860,7 +4892,7 @@ function validateLookupAddresses(addresses) {
|
|
|
4860
4892
|
ipAddressCount++;
|
|
4861
4893
|
validatePublicIpAddress(address, family);
|
|
4862
4894
|
}
|
|
4863
|
-
if (ipAddressCount === 0) throw new UrlError("DNS lookup did not return any IP address");
|
|
4895
|
+
if (ipAddressCount === 0) throw new UrlError("DNS lookup did not return any IP address", { reason: "dns" });
|
|
4864
4896
|
}
|
|
4865
4897
|
function validatePublicIpAddress(address, family) {
|
|
4866
4898
|
if (family === 4 && isValidPublicIPv4Address(address) || family === 6 && isValidPublicIPv6Address(address)) return;
|
|
@@ -5096,6 +5128,8 @@ async function getRemoteDocument(url, response, fetch) {
|
|
|
5096
5128
|
}
|
|
5097
5129
|
/**
|
|
5098
5130
|
* Creates a JSON-LD document loader that utilizes the browser's `fetch` API.
|
|
5131
|
+
* At most 20 HTTP redirects and alternate document links are followed in total
|
|
5132
|
+
* per call. Revisiting a URL within that chain throws a {@link FetchError}.
|
|
5099
5133
|
*
|
|
5100
5134
|
* The created loader preloads the below frequently used contexts by default
|
|
5101
5135
|
* (unless `options.skipPreloadedContexts` is set to `true`):
|
|
@@ -5107,6 +5141,7 @@ async function getRemoteDocument(url, response, fetch) {
|
|
|
5107
5141
|
* - <https://www.w3.org/ns/cid/v1>
|
|
5108
5142
|
* - <https://w3id.org/security/multikey/v1>
|
|
5109
5143
|
* - <https://w3id.org/fep/ef61>
|
|
5144
|
+
* - <https://w3id.org/fep/7aa9>
|
|
5110
5145
|
* - <https://purl.archive.org/socialweb/webfinger>
|
|
5111
5146
|
* - <http://schema.org/>
|
|
5112
5147
|
* @param options Options for the document loader.
|
|
@@ -5130,7 +5165,11 @@ function getDocumentLoader({ allowPrivateAddress, maxRedirection, skipPreloadedC
|
|
|
5130
5165
|
if (!allowPrivateAddress) try {
|
|
5131
5166
|
await validatePublicUrl(currentUrl);
|
|
5132
5167
|
} catch (error) {
|
|
5133
|
-
if (error instanceof UrlError) logger.
|
|
5168
|
+
if (error instanceof UrlError) if (error.reason === "dns") logger.debug("DNS lookup failed for {url}", {
|
|
5169
|
+
url: currentUrl,
|
|
5170
|
+
error
|
|
5171
|
+
});
|
|
5172
|
+
else logger.error("Disallowed private URL: {url}", {
|
|
5134
5173
|
url: currentUrl,
|
|
5135
5174
|
error
|
|
5136
5175
|
});
|
|
@@ -5168,7 +5207,12 @@ function getDocumentLoader({ allowPrivateAddress, maxRedirection, skipPreloadedC
|
|
|
5168
5207
|
}
|
|
5169
5208
|
return await load(redirectUrl, options, redirected + 1, visited);
|
|
5170
5209
|
}
|
|
5171
|
-
const result = await getRemoteDocument(currentUrl, response,
|
|
5210
|
+
const result = await getRemoteDocument(currentUrl, response, async (alternateUrl) => {
|
|
5211
|
+
options?.signal?.throwIfAborted();
|
|
5212
|
+
if (redirected >= DEFAULT_MAX_REDIRECTION) throw new FetchError(currentUrl, `Too many redirections (${redirected + 1})`);
|
|
5213
|
+
if (visited.has(alternateUrl)) throw new FetchError(currentUrl, `Redirect loop detected: ${alternateUrl}`);
|
|
5214
|
+
return await load(alternateUrl, options, redirected + 1, visited);
|
|
5215
|
+
});
|
|
5172
5216
|
span.setAttribute("docloader.document_url", result.documentUrl);
|
|
5173
5217
|
if (result.contextUrl != null) span.setAttribute("docloader.context_url", result.contextUrl);
|
|
5174
5218
|
return result;
|
|
@@ -5184,7 +5228,7 @@ function getDocumentLoader({ allowPrivateAddress, maxRedirection, skipPreloadedC
|
|
|
5184
5228
|
}
|
|
5185
5229
|
});
|
|
5186
5230
|
}
|
|
5187
|
-
return load;
|
|
5231
|
+
return (url, options) => load(url, options);
|
|
5188
5232
|
}
|
|
5189
5233
|
//#endregion
|
|
5190
5234
|
//#region src/internal/multicodec.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require("./chunk-C2EiDwsr.cjs");
|
|
2
|
-
const require_request = require("./request-
|
|
2
|
+
const require_request = require("./request-DWx4I133.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-C2EiDwsr.cjs");
|
|
2
|
-
const require_body = require("./body-
|
|
2
|
+
const require_body = require("./body-BBcqb6fc.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-Dl_2ZsMa.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-C2EiDwsr.cjs");
|
|
2
|
-
require("./docloader-
|
|
3
|
-
require("./url-
|
|
2
|
+
require("./docloader-D8C3FEvV.cjs");
|
|
3
|
+
require("./url-4PAkYhZC.cjs");
|
|
4
4
|
require("./key-CWDxavIR.cjs");
|
|
5
5
|
require("./multibase-BL45eko3.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-8CWJM_ZM.mjs";
|
|
2
|
+
import { n as MAX_BODY_SIZE, r as readBoundedText } from "./body-Dl_2ZsMa.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
|
|
@@ -4402,6 +4402,28 @@ const preloadedContexts = {
|
|
|
4402
4402
|
},
|
|
4403
4403
|
"digestMultibase": "https://www.w3.org/ns/credentials/v2#digestMultibase"
|
|
4404
4404
|
} },
|
|
4405
|
+
"https://w3id.org/fep/7aa9": { "@context": {
|
|
4406
|
+
"FeaturedCollection": "https://w3id.org/fep/7aa9#FeaturedCollection",
|
|
4407
|
+
"FeaturedItem": "https://w3id.org/fep/7aa9#FeaturedItem",
|
|
4408
|
+
"FeatureRequest": "https://w3id.org/fep/7aa9#FeatureRequest",
|
|
4409
|
+
"FeatureAuthorization": "https://w3id.org/fep/7aa9#FeatureAuthorization",
|
|
4410
|
+
"topic": {
|
|
4411
|
+
"@id": "https://w3id.org/fep/7aa9#topic",
|
|
4412
|
+
"@type": "@id"
|
|
4413
|
+
},
|
|
4414
|
+
"featuredObject": {
|
|
4415
|
+
"@id": "https://w3id.org/fep/7aa9#featuredObject",
|
|
4416
|
+
"@type": "@id"
|
|
4417
|
+
},
|
|
4418
|
+
"canFeature": {
|
|
4419
|
+
"@id": "https://w3id.org/fep/7aa9#canFeature",
|
|
4420
|
+
"@type": "@id"
|
|
4421
|
+
},
|
|
4422
|
+
"featureAuthorization": {
|
|
4423
|
+
"@id": "https://w3id.org/fep/7aa9#featureAuthorization",
|
|
4424
|
+
"@type": "@id"
|
|
4425
|
+
}
|
|
4426
|
+
} },
|
|
4405
4427
|
"https://join-lemmy.org/context.json": { "@context": ["https://w3id.org/security/v1", {
|
|
4406
4428
|
"as": "https://www.w3.org/ns/activitystreams#",
|
|
4407
4429
|
"lemmy": "https://join-lemmy.org/ns#",
|
|
@@ -4566,6 +4588,8 @@ async function getRemoteDocument(url, response, fetch) {
|
|
|
4566
4588
|
}
|
|
4567
4589
|
/**
|
|
4568
4590
|
* Creates a JSON-LD document loader that utilizes the browser's `fetch` API.
|
|
4591
|
+
* At most 20 HTTP redirects and alternate document links are followed in total
|
|
4592
|
+
* per call. Revisiting a URL within that chain throws a {@link FetchError}.
|
|
4569
4593
|
*
|
|
4570
4594
|
* The created loader preloads the below frequently used contexts by default
|
|
4571
4595
|
* (unless `options.skipPreloadedContexts` is set to `true`):
|
|
@@ -4577,6 +4601,7 @@ async function getRemoteDocument(url, response, fetch) {
|
|
|
4577
4601
|
* - <https://www.w3.org/ns/cid/v1>
|
|
4578
4602
|
* - <https://w3id.org/security/multikey/v1>
|
|
4579
4603
|
* - <https://w3id.org/fep/ef61>
|
|
4604
|
+
* - <https://w3id.org/fep/7aa9>
|
|
4580
4605
|
* - <https://purl.archive.org/socialweb/webfinger>
|
|
4581
4606
|
* - <http://schema.org/>
|
|
4582
4607
|
* @param options Options for the document loader.
|
|
@@ -4600,7 +4625,11 @@ function getDocumentLoader({ allowPrivateAddress, maxRedirection, skipPreloadedC
|
|
|
4600
4625
|
if (!allowPrivateAddress) try {
|
|
4601
4626
|
await validatePublicUrl(currentUrl);
|
|
4602
4627
|
} catch (error) {
|
|
4603
|
-
if (error instanceof UrlError) logger.
|
|
4628
|
+
if (error instanceof UrlError) if (error.reason === "dns") logger.debug("DNS lookup failed for {url}", {
|
|
4629
|
+
url: currentUrl,
|
|
4630
|
+
error
|
|
4631
|
+
});
|
|
4632
|
+
else logger.error("Disallowed private URL: {url}", {
|
|
4604
4633
|
url: currentUrl,
|
|
4605
4634
|
error
|
|
4606
4635
|
});
|
|
@@ -4638,7 +4667,12 @@ function getDocumentLoader({ allowPrivateAddress, maxRedirection, skipPreloadedC
|
|
|
4638
4667
|
}
|
|
4639
4668
|
return await load(redirectUrl, options, redirected + 1, visited);
|
|
4640
4669
|
}
|
|
4641
|
-
const result = await getRemoteDocument(currentUrl, response,
|
|
4670
|
+
const result = await getRemoteDocument(currentUrl, response, async (alternateUrl) => {
|
|
4671
|
+
options?.signal?.throwIfAborted();
|
|
4672
|
+
if (redirected >= DEFAULT_MAX_REDIRECTION) throw new FetchError(currentUrl, `Too many redirections (${redirected + 1})`);
|
|
4673
|
+
if (visited.has(alternateUrl)) throw new FetchError(currentUrl, `Redirect loop detected: ${alternateUrl}`);
|
|
4674
|
+
return await load(alternateUrl, options, redirected + 1, visited);
|
|
4675
|
+
});
|
|
4642
4676
|
span.setAttribute("docloader.document_url", result.documentUrl);
|
|
4643
4677
|
if (result.contextUrl != null) span.setAttribute("docloader.context_url", result.contextUrl);
|
|
4644
4678
|
return result;
|
|
@@ -4654,7 +4688,7 @@ function getDocumentLoader({ allowPrivateAddress, maxRedirection, skipPreloadedC
|
|
|
4654
4688
|
}
|
|
4655
4689
|
});
|
|
4656
4690
|
}
|
|
4657
|
-
return load;
|
|
4691
|
+
return (url, options) => load(url, options);
|
|
4658
4692
|
}
|
|
4659
4693
|
//#endregion
|
|
4660
4694
|
export { cid_v1_default as i, getRemoteDocument as n, preloadedContexts as r, getDocumentLoader as t };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
require("./chunk-C2EiDwsr.cjs");
|
|
2
|
-
const require_request = require("./request-
|
|
3
|
-
const require_body = require("./body-
|
|
2
|
+
const require_request = require("./request-DWx4I133.cjs");
|
|
3
|
+
const require_body = require("./body-BBcqb6fc.cjs");
|
|
4
4
|
const require_link = require("./link-qDTmjPw_.cjs");
|
|
5
|
-
const require_url = require("./url-
|
|
5
|
+
const require_url = require("./url-4PAkYhZC.cjs");
|
|
6
6
|
let _logtape_logtape = require("@logtape/logtape");
|
|
7
7
|
let _opentelemetry_api = require("@opentelemetry/api");
|
|
8
8
|
//#region src/contexts/activitystreams.json
|
|
@@ -4403,6 +4403,28 @@ const preloadedContexts = {
|
|
|
4403
4403
|
},
|
|
4404
4404
|
"digestMultibase": "https://www.w3.org/ns/credentials/v2#digestMultibase"
|
|
4405
4405
|
} },
|
|
4406
|
+
"https://w3id.org/fep/7aa9": { "@context": {
|
|
4407
|
+
"FeaturedCollection": "https://w3id.org/fep/7aa9#FeaturedCollection",
|
|
4408
|
+
"FeaturedItem": "https://w3id.org/fep/7aa9#FeaturedItem",
|
|
4409
|
+
"FeatureRequest": "https://w3id.org/fep/7aa9#FeatureRequest",
|
|
4410
|
+
"FeatureAuthorization": "https://w3id.org/fep/7aa9#FeatureAuthorization",
|
|
4411
|
+
"topic": {
|
|
4412
|
+
"@id": "https://w3id.org/fep/7aa9#topic",
|
|
4413
|
+
"@type": "@id"
|
|
4414
|
+
},
|
|
4415
|
+
"featuredObject": {
|
|
4416
|
+
"@id": "https://w3id.org/fep/7aa9#featuredObject",
|
|
4417
|
+
"@type": "@id"
|
|
4418
|
+
},
|
|
4419
|
+
"canFeature": {
|
|
4420
|
+
"@id": "https://w3id.org/fep/7aa9#canFeature",
|
|
4421
|
+
"@type": "@id"
|
|
4422
|
+
},
|
|
4423
|
+
"featureAuthorization": {
|
|
4424
|
+
"@id": "https://w3id.org/fep/7aa9#featureAuthorization",
|
|
4425
|
+
"@type": "@id"
|
|
4426
|
+
}
|
|
4427
|
+
} },
|
|
4406
4428
|
"https://join-lemmy.org/context.json": { "@context": ["https://w3id.org/security/v1", {
|
|
4407
4429
|
"as": "https://www.w3.org/ns/activitystreams#",
|
|
4408
4430
|
"lemmy": "https://join-lemmy.org/ns#",
|
|
@@ -4567,6 +4589,8 @@ async function getRemoteDocument(url, response, fetch) {
|
|
|
4567
4589
|
}
|
|
4568
4590
|
/**
|
|
4569
4591
|
* Creates a JSON-LD document loader that utilizes the browser's `fetch` API.
|
|
4592
|
+
* At most 20 HTTP redirects and alternate document links are followed in total
|
|
4593
|
+
* per call. Revisiting a URL within that chain throws a {@link FetchError}.
|
|
4570
4594
|
*
|
|
4571
4595
|
* The created loader preloads the below frequently used contexts by default
|
|
4572
4596
|
* (unless `options.skipPreloadedContexts` is set to `true`):
|
|
@@ -4578,6 +4602,7 @@ async function getRemoteDocument(url, response, fetch) {
|
|
|
4578
4602
|
* - <https://www.w3.org/ns/cid/v1>
|
|
4579
4603
|
* - <https://w3id.org/security/multikey/v1>
|
|
4580
4604
|
* - <https://w3id.org/fep/ef61>
|
|
4605
|
+
* - <https://w3id.org/fep/7aa9>
|
|
4581
4606
|
* - <https://purl.archive.org/socialweb/webfinger>
|
|
4582
4607
|
* - <http://schema.org/>
|
|
4583
4608
|
* @param options Options for the document loader.
|
|
@@ -4601,7 +4626,11 @@ function getDocumentLoader({ allowPrivateAddress, maxRedirection, skipPreloadedC
|
|
|
4601
4626
|
if (!allowPrivateAddress) try {
|
|
4602
4627
|
await require_url.validatePublicUrl(currentUrl);
|
|
4603
4628
|
} catch (error) {
|
|
4604
|
-
if (error instanceof require_url.UrlError) logger.
|
|
4629
|
+
if (error instanceof require_url.UrlError) if (error.reason === "dns") logger.debug("DNS lookup failed for {url}", {
|
|
4630
|
+
url: currentUrl,
|
|
4631
|
+
error
|
|
4632
|
+
});
|
|
4633
|
+
else logger.error("Disallowed private URL: {url}", {
|
|
4605
4634
|
url: currentUrl,
|
|
4606
4635
|
error
|
|
4607
4636
|
});
|
|
@@ -4639,7 +4668,12 @@ function getDocumentLoader({ allowPrivateAddress, maxRedirection, skipPreloadedC
|
|
|
4639
4668
|
}
|
|
4640
4669
|
return await load(redirectUrl, options, redirected + 1, visited);
|
|
4641
4670
|
}
|
|
4642
|
-
const result = await getRemoteDocument(currentUrl, response,
|
|
4671
|
+
const result = await getRemoteDocument(currentUrl, response, async (alternateUrl) => {
|
|
4672
|
+
options?.signal?.throwIfAborted();
|
|
4673
|
+
if (redirected >= DEFAULT_MAX_REDIRECTION) throw new require_request.FetchError(currentUrl, `Too many redirections (${redirected + 1})`);
|
|
4674
|
+
if (visited.has(alternateUrl)) throw new require_request.FetchError(currentUrl, `Redirect loop detected: ${alternateUrl}`);
|
|
4675
|
+
return await load(alternateUrl, options, redirected + 1, visited);
|
|
4676
|
+
});
|
|
4643
4677
|
span.setAttribute("docloader.document_url", result.documentUrl);
|
|
4644
4678
|
if (result.contextUrl != null) span.setAttribute("docloader.context_url", result.contextUrl);
|
|
4645
4679
|
return result;
|
|
@@ -4655,7 +4689,7 @@ function getDocumentLoader({ allowPrivateAddress, maxRedirection, skipPreloadedC
|
|
|
4655
4689
|
}
|
|
4656
4690
|
});
|
|
4657
4691
|
}
|
|
4658
|
-
return load;
|
|
4692
|
+
return (url, options) => load(url, options);
|
|
4659
4693
|
}
|
|
4660
4694
|
//#endregion
|
|
4661
4695
|
Object.defineProperty(exports, "cid_v1_default", {
|