@fedify/vocab-runtime 2.0.31-dev.2306 → 2.0.31-dev.2310
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 +2 -2
- package/dist/mod.cjs +50 -3
- package/dist/mod.d.cts +28 -2
- package/dist/mod.d.ts +28 -2
- package/dist/mod.js +50 -4
- package/dist/tests/{body-CGeu_wlY.mjs → body-DhJNq-PQ.mjs} +1 -1
- package/dist/tests/{body-KqP1lgFZ.cjs → body-N4Kc5pwz.cjs} +1 -1
- package/dist/tests/body.test.cjs +1 -1
- package/dist/tests/body.test.mjs +1 -1
- package/dist/tests/docloader.test.cjs +41 -44
- package/dist/tests/docloader.test.mjs +32 -35
- package/dist/tests/langstr.test.cjs +12 -2
- package/dist/tests/langstr.test.mjs +13 -3
- package/dist/tests/langtag-Bm8oKhIO.cjs +50 -0
- package/dist/tests/langtag-QZZgy903.mjs +45 -0
- package/dist/tests/langtag.test.cjs +46 -0
- package/dist/tests/langtag.test.d.cts +1 -0
- package/dist/tests/langtag.test.d.mts +1 -0
- package/dist/tests/langtag.test.mjs +46 -0
- package/dist/tests/multibase/multibase.test.cjs +7 -7
- package/dist/tests/multibase/multibase.test.mjs +5 -5
- package/dist/tests/{request-75RoXeN4.cjs → request-CFKB-Yqd.cjs} +1 -1
- package/dist/tests/{request-JVGlYdPG.mjs → request-DDAEJJqw.mjs} +1 -1
- package/dist/tests/request.test.cjs +1 -1
- package/dist/tests/request.test.mjs +1 -1
- package/package.json +6 -3
- package/scripts/test-bun.mjs +18 -0
- package/src/docloader.test.ts +75 -68
- package/src/langstr.test.ts +18 -1
- package/src/langstr.ts +6 -2
- package/src/langtag.test.ts +53 -0
- package/src/langtag.ts +76 -0
- package/src/mod.ts +1 -0
- package/src/multibase/multibase.test.ts +5 -5
package/deno.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/vocab-runtime",
|
|
3
|
-
"version": "2.0.31-dev.
|
|
3
|
+
"version": "2.0.31-dev.2310+e604de57",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./src/mod.ts",
|
|
@@ -34,6 +34,6 @@
|
|
|
34
34
|
},
|
|
35
35
|
"tasks": {
|
|
36
36
|
"check": "deno fmt --check && deno lint && deno check src/*.ts",
|
|
37
|
-
"test": "deno test"
|
|
37
|
+
"test": "deno test --allow-net --allow-env=LOG"
|
|
38
38
|
}
|
|
39
39
|
}
|
package/dist/mod.cjs
CHANGED
|
@@ -4504,7 +4504,7 @@ const preloadedContexts = {
|
|
|
4504
4504
|
//#endregion
|
|
4505
4505
|
//#region deno.json
|
|
4506
4506
|
var name = "@fedify/vocab-runtime";
|
|
4507
|
-
var version = "2.0.31-dev.
|
|
4507
|
+
var version = "2.0.31-dev.2310+e604de57";
|
|
4508
4508
|
//#endregion
|
|
4509
4509
|
//#region src/request.ts
|
|
4510
4510
|
/**
|
|
@@ -5730,6 +5730,50 @@ async function exportMultibaseKey(key) {
|
|
|
5730
5730
|
return new TextDecoder().decode(encoded);
|
|
5731
5731
|
}
|
|
5732
5732
|
//#endregion
|
|
5733
|
+
//#region src/langtag.ts
|
|
5734
|
+
const EXTLANG_PAIRS = new Set(Object.entries({
|
|
5735
|
+
ar: "aao abh abv acm acq acw acx acy adf aeb aec afb ajp apc apd arb arq ars ary arz auz avl ayh ayl ayn ayp bbz pga shu ssh",
|
|
5736
|
+
kok: "gom knn",
|
|
5737
|
+
lv: "ltg lvs",
|
|
5738
|
+
ms: "bjn btj bve bvu coa dup hji jak jax kvb kvr kxd lce lcf liw max meo mfa mfb min mqg msi mui orn ors pel pse tmw urk vkk vkt xmm zlm zmi zsm",
|
|
5739
|
+
sgn: "ads aed aen afg ajs ase asf asp asq asw bfi bfk bog bqn bqy bvl bzs cds csc csd cse csf csg csl csn csq csr csx doq dse dsl dsz dyl ecs ehs esl esn eso eth fcs fse fsl fss gds gse gsg gsm gss gus hab haf hds hks hos hps hsh hsl icl iks ils inl ins ise isg isr jcs jhs jks jls jos jsl jus kgi kvk lbs lgs lls lsb lsc lsg lsl lsn lso lsp lst lsv lsw lsy lws mdl mfs mre msd msr mzc mzg mzy nbs ncs nsi nsl nsp nsr nzs okl pgz pks prl prz psc psd psg psl pso psp psr pys rib rms rnb rsi rsl rsm rsn sdl sfb sfs sgg sgx slf sls sqk sqs sqx ssp ssr svk swl syy szs tse tsm tsq tss tsy tza ugn ugy ukl uks vgt vsi vsl vsv wbs xki xml xms yds ygs yhs ysl ysm zhk zib zsl",
|
|
5740
|
+
sw: "swc swh",
|
|
5741
|
+
uz: "uzn uzs",
|
|
5742
|
+
zh: "cdo cjy cmn cnp cpx csp czh czo gan hak hnm hsn luh lzh mnp nan sjc wuu yue"
|
|
5743
|
+
}).flatMap(([prefix, extlangs]) => extlangs.split(" ").map((extlang) => `${prefix}-${extlang}`)));
|
|
5744
|
+
const PREFIX_PATTERN = /^[A-Za-z]{2,3}$/;
|
|
5745
|
+
const EXTLANG_PATTERN = /^[A-Za-z]{3}$/;
|
|
5746
|
+
/**
|
|
5747
|
+
* Normalizes a BCP 47 language tag that has an extended language subtag
|
|
5748
|
+
* (extlang), such as `zh-yue`, into its canonical form, such as `yue`, as
|
|
5749
|
+
* described in [RFC 5646, Section 4.5][1]. `Intl.Locale` rejects extlang
|
|
5750
|
+
* tags, so tags should be normalized before being passed to it.
|
|
5751
|
+
*
|
|
5752
|
+
* Only registered extlangs that follow their registered prefix are removed;
|
|
5753
|
+
* any other tag is returned unchanged, so the result still needs to be
|
|
5754
|
+
* validated, e.g., by `Intl.Locale`.
|
|
5755
|
+
*
|
|
5756
|
+
* NOTE: This function is marked as internal in the 2.0.x–2.4.x patch
|
|
5757
|
+
* releases. When merging it into the *main* branch, remove the `@internal`
|
|
5758
|
+
* tag, formalize it as a public API (`@since 2.5.0`), and add it to
|
|
5759
|
+
* the changelog fragment.
|
|
5760
|
+
*
|
|
5761
|
+
* [1]: https://www.rfc-editor.org/rfc/rfc5646.html#section-4.5
|
|
5762
|
+
*
|
|
5763
|
+
* @param tag The BCP 47 language tag to normalize.
|
|
5764
|
+
* @returns The normalized language tag.
|
|
5765
|
+
* @internal
|
|
5766
|
+
*/
|
|
5767
|
+
function normalizeLanguageTag(tag) {
|
|
5768
|
+
const subtags = tag.split("-");
|
|
5769
|
+
if (subtags.length < 2) return tag;
|
|
5770
|
+
const [prefix, extlang, ...rest] = subtags;
|
|
5771
|
+
if (!PREFIX_PATTERN.test(prefix) || !EXTLANG_PATTERN.test(extlang)) return tag;
|
|
5772
|
+
const language = extlang.toLowerCase();
|
|
5773
|
+
if (!EXTLANG_PAIRS.has(`${prefix.toLowerCase()}-${language}`)) return tag;
|
|
5774
|
+
return [language, ...rest].join("-");
|
|
5775
|
+
}
|
|
5776
|
+
//#endregion
|
|
5733
5777
|
//#region src/langstr.ts
|
|
5734
5778
|
/**
|
|
5735
5779
|
* A language-tagged string which corresponds to the `rdf:langString` type.
|
|
@@ -5744,11 +5788,13 @@ var LanguageString = class extends String {
|
|
|
5744
5788
|
* Constructs a new `LanguageString`.
|
|
5745
5789
|
* @param value A string value written in the given language.
|
|
5746
5790
|
* @param language The language of the string. If a string is given, it will
|
|
5747
|
-
* be parsed as a `Intl.Locale` object.
|
|
5791
|
+
* be parsed as a `Intl.Locale` object. Extended language
|
|
5792
|
+
* subtags are normalized first, e.g., `zh-yue` is parsed as
|
|
5793
|
+
* `yue`.
|
|
5748
5794
|
*/
|
|
5749
5795
|
constructor(value, language) {
|
|
5750
5796
|
super(value);
|
|
5751
|
-
this.locale = typeof language === "string" ? new Intl.Locale(language) : language;
|
|
5797
|
+
this.locale = typeof language === "string" ? new Intl.Locale(normalizeLanguageTag(language)) : language;
|
|
5752
5798
|
}
|
|
5753
5799
|
};
|
|
5754
5800
|
LanguageString.prototype[Symbol.for("Deno.customInspect")] = function(inspect, options) {
|
|
@@ -5778,5 +5824,6 @@ exports.importSpki = importSpki;
|
|
|
5778
5824
|
exports.isValidPublicIPv4Address = isValidPublicIPv4Address;
|
|
5779
5825
|
exports.isValidPublicIPv6Address = isValidPublicIPv6Address;
|
|
5780
5826
|
exports.logRequest = logRequest;
|
|
5827
|
+
exports.normalizeLanguageTag = normalizeLanguageTag;
|
|
5781
5828
|
exports.preloadedContexts = preloadedContexts;
|
|
5782
5829
|
exports.validatePublicUrl = validatePublicUrl;
|
package/dist/mod.d.cts
CHANGED
|
@@ -265,11 +265,37 @@ declare class LanguageString extends String {
|
|
|
265
265
|
* Constructs a new `LanguageString`.
|
|
266
266
|
* @param value A string value written in the given language.
|
|
267
267
|
* @param language The language of the string. If a string is given, it will
|
|
268
|
-
* be parsed as a `Intl.Locale` object.
|
|
268
|
+
* be parsed as a `Intl.Locale` object. Extended language
|
|
269
|
+
* subtags are normalized first, e.g., `zh-yue` is parsed as
|
|
270
|
+
* `yue`.
|
|
269
271
|
*/
|
|
270
272
|
constructor(value: string, language: Intl.Locale | string);
|
|
271
273
|
}
|
|
272
274
|
//#endregion
|
|
275
|
+
//#region src/langtag.d.ts
|
|
276
|
+
/**
|
|
277
|
+
* Normalizes a BCP 47 language tag that has an extended language subtag
|
|
278
|
+
* (extlang), such as `zh-yue`, into its canonical form, such as `yue`, as
|
|
279
|
+
* described in [RFC 5646, Section 4.5][1]. `Intl.Locale` rejects extlang
|
|
280
|
+
* tags, so tags should be normalized before being passed to it.
|
|
281
|
+
*
|
|
282
|
+
* Only registered extlangs that follow their registered prefix are removed;
|
|
283
|
+
* any other tag is returned unchanged, so the result still needs to be
|
|
284
|
+
* validated, e.g., by `Intl.Locale`.
|
|
285
|
+
*
|
|
286
|
+
* NOTE: This function is marked as internal in the 2.0.x–2.4.x patch
|
|
287
|
+
* releases. When merging it into the *main* branch, remove the `@internal`
|
|
288
|
+
* tag, formalize it as a public API (`@since 2.5.0`), and add it to
|
|
289
|
+
* the changelog fragment.
|
|
290
|
+
*
|
|
291
|
+
* [1]: https://www.rfc-editor.org/rfc/rfc5646.html#section-4.5
|
|
292
|
+
*
|
|
293
|
+
* @param tag The BCP 47 language tag to normalize.
|
|
294
|
+
* @returns The normalized language tag.
|
|
295
|
+
* @internal
|
|
296
|
+
*/
|
|
297
|
+
declare function normalizeLanguageTag(tag: string): string;
|
|
298
|
+
//#endregion
|
|
273
299
|
//#region src/multibase/types.d.ts
|
|
274
300
|
type BaseCode = "\x00" | "0" | "7" | "9" | "f" | "F" | "v" | "V" | "t" | "T" | "b" | "B" | "c" | "C" | "h" | "k" | "K" | "z" | "Z" | "m" | "M" | "u" | "U";
|
|
275
301
|
/**
|
|
@@ -344,4 +370,4 @@ declare function isValidPublicIPv4Address(address: string): boolean;
|
|
|
344
370
|
declare function isValidPublicIPv6Address(address: string): boolean;
|
|
345
371
|
declare function expandIPv6Address(address: string): string;
|
|
346
372
|
//#endregion
|
|
347
|
-
export { type AuthenticatedDocumentLoaderFactory, type CreateRequestOptions, type DocumentLoader, type DocumentLoaderFactory, type DocumentLoaderFactoryOptions, type DocumentLoaderOptions, FetchError, type GetDocumentLoaderOptions, type GetUserAgentOptions, LanguageString, type RemoteDocument, UrlError, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportMultibaseKey, exportSpki, getDocumentLoader, getRemoteDocument, getUserAgent, importMultibaseKey, importPem, importPkcs1, importSpki, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, preloadedContexts, validatePublicUrl };
|
|
373
|
+
export { type AuthenticatedDocumentLoaderFactory, type CreateRequestOptions, type DocumentLoader, type DocumentLoaderFactory, type DocumentLoaderFactoryOptions, type DocumentLoaderOptions, FetchError, type GetDocumentLoaderOptions, type GetUserAgentOptions, LanguageString, type RemoteDocument, UrlError, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportMultibaseKey, exportSpki, getDocumentLoader, getRemoteDocument, getUserAgent, importMultibaseKey, importPem, importPkcs1, importSpki, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, normalizeLanguageTag, preloadedContexts, validatePublicUrl };
|
package/dist/mod.d.ts
CHANGED
|
@@ -264,11 +264,37 @@ declare class LanguageString extends String {
|
|
|
264
264
|
* Constructs a new `LanguageString`.
|
|
265
265
|
* @param value A string value written in the given language.
|
|
266
266
|
* @param language The language of the string. If a string is given, it will
|
|
267
|
-
* be parsed as a `Intl.Locale` object.
|
|
267
|
+
* be parsed as a `Intl.Locale` object. Extended language
|
|
268
|
+
* subtags are normalized first, e.g., `zh-yue` is parsed as
|
|
269
|
+
* `yue`.
|
|
268
270
|
*/
|
|
269
271
|
constructor(value: string, language: Intl.Locale | string);
|
|
270
272
|
}
|
|
271
273
|
//#endregion
|
|
274
|
+
//#region src/langtag.d.ts
|
|
275
|
+
/**
|
|
276
|
+
* Normalizes a BCP 47 language tag that has an extended language subtag
|
|
277
|
+
* (extlang), such as `zh-yue`, into its canonical form, such as `yue`, as
|
|
278
|
+
* described in [RFC 5646, Section 4.5][1]. `Intl.Locale` rejects extlang
|
|
279
|
+
* tags, so tags should be normalized before being passed to it.
|
|
280
|
+
*
|
|
281
|
+
* Only registered extlangs that follow their registered prefix are removed;
|
|
282
|
+
* any other tag is returned unchanged, so the result still needs to be
|
|
283
|
+
* validated, e.g., by `Intl.Locale`.
|
|
284
|
+
*
|
|
285
|
+
* NOTE: This function is marked as internal in the 2.0.x–2.4.x patch
|
|
286
|
+
* releases. When merging it into the *main* branch, remove the `@internal`
|
|
287
|
+
* tag, formalize it as a public API (`@since 2.5.0`), and add it to
|
|
288
|
+
* the changelog fragment.
|
|
289
|
+
*
|
|
290
|
+
* [1]: https://www.rfc-editor.org/rfc/rfc5646.html#section-4.5
|
|
291
|
+
*
|
|
292
|
+
* @param tag The BCP 47 language tag to normalize.
|
|
293
|
+
* @returns The normalized language tag.
|
|
294
|
+
* @internal
|
|
295
|
+
*/
|
|
296
|
+
declare function normalizeLanguageTag(tag: string): string;
|
|
297
|
+
//#endregion
|
|
272
298
|
//#region src/multibase/types.d.ts
|
|
273
299
|
type BaseCode = "\x00" | "0" | "7" | "9" | "f" | "F" | "v" | "V" | "t" | "T" | "b" | "B" | "c" | "C" | "h" | "k" | "K" | "z" | "Z" | "m" | "M" | "u" | "U";
|
|
274
300
|
/**
|
|
@@ -343,4 +369,4 @@ declare function isValidPublicIPv4Address(address: string): boolean;
|
|
|
343
369
|
declare function isValidPublicIPv6Address(address: string): boolean;
|
|
344
370
|
declare function expandIPv6Address(address: string): string;
|
|
345
371
|
//#endregion
|
|
346
|
-
export { type AuthenticatedDocumentLoaderFactory, type CreateRequestOptions, type DocumentLoader, type DocumentLoaderFactory, type DocumentLoaderFactoryOptions, type DocumentLoaderOptions, FetchError, type GetDocumentLoaderOptions, type GetUserAgentOptions, LanguageString, type RemoteDocument, UrlError, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportMultibaseKey, exportSpki, getDocumentLoader, getRemoteDocument, getUserAgent, importMultibaseKey, importPem, importPkcs1, importSpki, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, preloadedContexts, validatePublicUrl };
|
|
372
|
+
export { type AuthenticatedDocumentLoaderFactory, type CreateRequestOptions, type DocumentLoader, type DocumentLoaderFactory, type DocumentLoaderFactoryOptions, type DocumentLoaderOptions, FetchError, type GetDocumentLoaderOptions, type GetUserAgentOptions, LanguageString, type RemoteDocument, UrlError, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportMultibaseKey, exportSpki, getDocumentLoader, getRemoteDocument, getUserAgent, importMultibaseKey, importPem, importPkcs1, importSpki, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, normalizeLanguageTag, preloadedContexts, validatePublicUrl };
|
package/dist/mod.js
CHANGED
|
@@ -4499,7 +4499,7 @@ const preloadedContexts = {
|
|
|
4499
4499
|
//#endregion
|
|
4500
4500
|
//#region deno.json
|
|
4501
4501
|
var name = "@fedify/vocab-runtime";
|
|
4502
|
-
var version = "2.0.31-dev.
|
|
4502
|
+
var version = "2.0.31-dev.2310+e604de57";
|
|
4503
4503
|
//#endregion
|
|
4504
4504
|
//#region src/request.ts
|
|
4505
4505
|
/**
|
|
@@ -5725,6 +5725,50 @@ async function exportMultibaseKey(key) {
|
|
|
5725
5725
|
return new TextDecoder().decode(encoded);
|
|
5726
5726
|
}
|
|
5727
5727
|
//#endregion
|
|
5728
|
+
//#region src/langtag.ts
|
|
5729
|
+
const EXTLANG_PAIRS = new Set(Object.entries({
|
|
5730
|
+
ar: "aao abh abv acm acq acw acx acy adf aeb aec afb ajp apc apd arb arq ars ary arz auz avl ayh ayl ayn ayp bbz pga shu ssh",
|
|
5731
|
+
kok: "gom knn",
|
|
5732
|
+
lv: "ltg lvs",
|
|
5733
|
+
ms: "bjn btj bve bvu coa dup hji jak jax kvb kvr kxd lce lcf liw max meo mfa mfb min mqg msi mui orn ors pel pse tmw urk vkk vkt xmm zlm zmi zsm",
|
|
5734
|
+
sgn: "ads aed aen afg ajs ase asf asp asq asw bfi bfk bog bqn bqy bvl bzs cds csc csd cse csf csg csl csn csq csr csx doq dse dsl dsz dyl ecs ehs esl esn eso eth fcs fse fsl fss gds gse gsg gsm gss gus hab haf hds hks hos hps hsh hsl icl iks ils inl ins ise isg isr jcs jhs jks jls jos jsl jus kgi kvk lbs lgs lls lsb lsc lsg lsl lsn lso lsp lst lsv lsw lsy lws mdl mfs mre msd msr mzc mzg mzy nbs ncs nsi nsl nsp nsr nzs okl pgz pks prl prz psc psd psg psl pso psp psr pys rib rms rnb rsi rsl rsm rsn sdl sfb sfs sgg sgx slf sls sqk sqs sqx ssp ssr svk swl syy szs tse tsm tsq tss tsy tza ugn ugy ukl uks vgt vsi vsl vsv wbs xki xml xms yds ygs yhs ysl ysm zhk zib zsl",
|
|
5735
|
+
sw: "swc swh",
|
|
5736
|
+
uz: "uzn uzs",
|
|
5737
|
+
zh: "cdo cjy cmn cnp cpx csp czh czo gan hak hnm hsn luh lzh mnp nan sjc wuu yue"
|
|
5738
|
+
}).flatMap(([prefix, extlangs]) => extlangs.split(" ").map((extlang) => `${prefix}-${extlang}`)));
|
|
5739
|
+
const PREFIX_PATTERN = /^[A-Za-z]{2,3}$/;
|
|
5740
|
+
const EXTLANG_PATTERN = /^[A-Za-z]{3}$/;
|
|
5741
|
+
/**
|
|
5742
|
+
* Normalizes a BCP 47 language tag that has an extended language subtag
|
|
5743
|
+
* (extlang), such as `zh-yue`, into its canonical form, such as `yue`, as
|
|
5744
|
+
* described in [RFC 5646, Section 4.5][1]. `Intl.Locale` rejects extlang
|
|
5745
|
+
* tags, so tags should be normalized before being passed to it.
|
|
5746
|
+
*
|
|
5747
|
+
* Only registered extlangs that follow their registered prefix are removed;
|
|
5748
|
+
* any other tag is returned unchanged, so the result still needs to be
|
|
5749
|
+
* validated, e.g., by `Intl.Locale`.
|
|
5750
|
+
*
|
|
5751
|
+
* NOTE: This function is marked as internal in the 2.0.x–2.4.x patch
|
|
5752
|
+
* releases. When merging it into the *main* branch, remove the `@internal`
|
|
5753
|
+
* tag, formalize it as a public API (`@since 2.5.0`), and add it to
|
|
5754
|
+
* the changelog fragment.
|
|
5755
|
+
*
|
|
5756
|
+
* [1]: https://www.rfc-editor.org/rfc/rfc5646.html#section-4.5
|
|
5757
|
+
*
|
|
5758
|
+
* @param tag The BCP 47 language tag to normalize.
|
|
5759
|
+
* @returns The normalized language tag.
|
|
5760
|
+
* @internal
|
|
5761
|
+
*/
|
|
5762
|
+
function normalizeLanguageTag(tag) {
|
|
5763
|
+
const subtags = tag.split("-");
|
|
5764
|
+
if (subtags.length < 2) return tag;
|
|
5765
|
+
const [prefix, extlang, ...rest] = subtags;
|
|
5766
|
+
if (!PREFIX_PATTERN.test(prefix) || !EXTLANG_PATTERN.test(extlang)) return tag;
|
|
5767
|
+
const language = extlang.toLowerCase();
|
|
5768
|
+
if (!EXTLANG_PAIRS.has(`${prefix.toLowerCase()}-${language}`)) return tag;
|
|
5769
|
+
return [language, ...rest].join("-");
|
|
5770
|
+
}
|
|
5771
|
+
//#endregion
|
|
5728
5772
|
//#region src/langstr.ts
|
|
5729
5773
|
/**
|
|
5730
5774
|
* A language-tagged string which corresponds to the `rdf:langString` type.
|
|
@@ -5739,11 +5783,13 @@ var LanguageString = class extends String {
|
|
|
5739
5783
|
* Constructs a new `LanguageString`.
|
|
5740
5784
|
* @param value A string value written in the given language.
|
|
5741
5785
|
* @param language The language of the string. If a string is given, it will
|
|
5742
|
-
* be parsed as a `Intl.Locale` object.
|
|
5786
|
+
* be parsed as a `Intl.Locale` object. Extended language
|
|
5787
|
+
* subtags are normalized first, e.g., `zh-yue` is parsed as
|
|
5788
|
+
* `yue`.
|
|
5743
5789
|
*/
|
|
5744
5790
|
constructor(value, language) {
|
|
5745
5791
|
super(value);
|
|
5746
|
-
this.locale = typeof language === "string" ? new Intl.Locale(language) : language;
|
|
5792
|
+
this.locale = typeof language === "string" ? new Intl.Locale(normalizeLanguageTag(language)) : language;
|
|
5747
5793
|
}
|
|
5748
5794
|
};
|
|
5749
5795
|
LanguageString.prototype[Symbol.for("Deno.customInspect")] = function(inspect, options) {
|
|
@@ -5753,4 +5799,4 @@ LanguageString.prototype[Symbol.for("nodejs.util.inspect.custom")] = function(_d
|
|
|
5753
5799
|
return `<${this.locale.baseName}> ${inspect(this.toString(), options)}`;
|
|
5754
5800
|
};
|
|
5755
5801
|
//#endregion
|
|
5756
|
-
export { FetchError, LanguageString, UrlError, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportMultibaseKey, exportSpki, getDocumentLoader, getRemoteDocument, getUserAgent, importMultibaseKey, importPem, importPkcs1, importSpki, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, preloadedContexts, validatePublicUrl };
|
|
5802
|
+
export { FetchError, LanguageString, UrlError, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportMultibaseKey, exportSpki, getDocumentLoader, getRemoteDocument, getUserAgent, importMultibaseKey, importPem, importPkcs1, importSpki, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, normalizeLanguageTag, preloadedContexts, validatePublicUrl };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require("./chunk-Do9eywBl.cjs");
|
|
2
|
-
const require_request = require("./request-
|
|
2
|
+
const require_request = require("./request-CFKB-Yqd.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-N4Kc5pwz.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-DhJNq-PQ.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,14 +1,14 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-Do9eywBl.cjs");
|
|
2
|
-
const require_request = require("./request-
|
|
3
|
-
const require_body = require("./body-
|
|
2
|
+
const require_request = require("./request-CFKB-Yqd.cjs");
|
|
3
|
+
const require_body = require("./body-N4Kc5pwz.cjs");
|
|
4
4
|
const require_link = require("./link-FguCydMA.cjs");
|
|
5
5
|
const require_url = require("./url-Qk1svKZU.cjs");
|
|
6
|
-
let node_test = require("node:test");
|
|
7
6
|
let node_zlib = require("node:zlib");
|
|
8
7
|
let _logtape_logtape = require("@logtape/logtape");
|
|
9
8
|
let node_assert = require("node:assert");
|
|
10
9
|
let node_dns_promises = require("node:dns/promises");
|
|
11
10
|
node_dns_promises = require_chunk.__toESM(node_dns_promises);
|
|
11
|
+
let _fedify_fixture = require("@fedify/fixture");
|
|
12
12
|
let node_http = require("node:http");
|
|
13
13
|
let _opentelemetry_api = require("@opentelemetry/api");
|
|
14
14
|
let jsonld_dist_jsonld_esm_js = require("jsonld/dist/jsonld.esm.js");
|
|
@@ -5906,7 +5906,7 @@ function getDocumentLoader({ allowPrivateAddress, skipPreloadedContexts, userAge
|
|
|
5906
5906
|
var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
5907
5907
|
//#endregion
|
|
5908
5908
|
//#region src/docloader.test.ts
|
|
5909
|
-
(0,
|
|
5909
|
+
(0, _fedify_fixture.test)("new FetchError()", () => {
|
|
5910
5910
|
const e = new require_request.FetchError("https://example.com/", "An error message.");
|
|
5911
5911
|
(0, node_assert.deepStrictEqual)(e.name, "FetchError");
|
|
5912
5912
|
(0, node_assert.deepStrictEqual)(e.url, new URL("https://example.com/"));
|
|
@@ -5915,7 +5915,7 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
5915
5915
|
(0, node_assert.deepStrictEqual)(e2.url, new URL("https://example.org/"));
|
|
5916
5916
|
(0, node_assert.deepStrictEqual)(e2.message, "https://example.org/");
|
|
5917
5917
|
});
|
|
5918
|
-
(0,
|
|
5918
|
+
(0, _fedify_fixture.test)("getDocumentLoader()", async (t) => {
|
|
5919
5919
|
const fetchDocumentLoader = getDocumentLoader();
|
|
5920
5920
|
esm_default.spyGlobal();
|
|
5921
5921
|
esm_default.get("https://example.com/object", { body: {
|
|
@@ -5924,7 +5924,7 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
5924
5924
|
name: "Fetched object",
|
|
5925
5925
|
type: "Object"
|
|
5926
5926
|
} });
|
|
5927
|
-
await t.
|
|
5927
|
+
await t.step("ok", async () => {
|
|
5928
5928
|
(0, node_assert.deepStrictEqual)(await fetchDocumentLoader("https://example.com/object"), {
|
|
5929
5929
|
contextUrl: null,
|
|
5930
5930
|
documentUrl: "https://example.com/object",
|
|
@@ -5967,7 +5967,7 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
5967
5967
|
Link: "<https://example.com/object>; rel=\"alternate\"; type=\"application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"\""
|
|
5968
5968
|
}
|
|
5969
5969
|
});
|
|
5970
|
-
await t.
|
|
5970
|
+
await t.step("Link header", async () => {
|
|
5971
5971
|
(0, node_assert.deepStrictEqual)(await fetchDocumentLoader("https://example.com/link-ctx"), {
|
|
5972
5972
|
contextUrl: "https://www.w3.org/ns/activitystreams",
|
|
5973
5973
|
documentUrl: "https://example.com/link-ctx",
|
|
@@ -5988,7 +5988,7 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
5988
5988
|
}
|
|
5989
5989
|
});
|
|
5990
5990
|
});
|
|
5991
|
-
await t.
|
|
5991
|
+
await t.step("Link header relative url", async () => {
|
|
5992
5992
|
(0, node_assert.deepStrictEqual)(await fetchDocumentLoader("https://example.com/link-ctx"), {
|
|
5993
5993
|
contextUrl: "https://www.w3.org/ns/activitystreams",
|
|
5994
5994
|
documentUrl: "https://example.com/link-ctx",
|
|
@@ -6009,7 +6009,7 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
6009
6009
|
}
|
|
6010
6010
|
});
|
|
6011
6011
|
});
|
|
6012
|
-
await t.
|
|
6012
|
+
await t.step("wrong Link header syntax", async () => {
|
|
6013
6013
|
(0, node_assert.deepStrictEqual)(await fetchDocumentLoader("https://example.com/obj-w-wrong-link"), {
|
|
6014
6014
|
contextUrl: null,
|
|
6015
6015
|
documentUrl: "https://example.com/obj-w-wrong-link",
|
|
@@ -6033,7 +6033,7 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
6033
6033
|
</html>`,
|
|
6034
6034
|
headers: { "Content-Type": "text/html; charset=utf-8" }
|
|
6035
6035
|
});
|
|
6036
|
-
await t.
|
|
6036
|
+
await t.step("HTML <link>", async () => {
|
|
6037
6037
|
(0, node_assert.deepStrictEqual)(await fetchDocumentLoader("https://example.com/html-link"), {
|
|
6038
6038
|
contextUrl: null,
|
|
6039
6039
|
documentUrl: "https://example.com/object",
|
|
@@ -6057,7 +6057,7 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
6057
6057
|
</html>`,
|
|
6058
6058
|
headers: { "Content-Type": "application/xhtml+xml; charset=utf-8" }
|
|
6059
6059
|
});
|
|
6060
|
-
await t.
|
|
6060
|
+
await t.step("XHTML <link>", async () => {
|
|
6061
6061
|
(0, node_assert.deepStrictEqual)(await fetchDocumentLoader("https://example.com/xhtml-link"), {
|
|
6062
6062
|
contextUrl: null,
|
|
6063
6063
|
documentUrl: "https://example.com/object",
|
|
@@ -6083,7 +6083,7 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
6083
6083
|
</html>`,
|
|
6084
6084
|
headers: { "Content-Type": "text/html; charset=utf-8" }
|
|
6085
6085
|
});
|
|
6086
|
-
await t.
|
|
6086
|
+
await t.step("HTML <a>", async () => {
|
|
6087
6087
|
(0, node_assert.deepStrictEqual)(await fetchDocumentLoader("https://example.com/html-a"), {
|
|
6088
6088
|
contextUrl: null,
|
|
6089
6089
|
documentUrl: "https://example.com/object",
|
|
@@ -6104,7 +6104,7 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
6104
6104
|
},
|
|
6105
6105
|
headers: { "Content-Type": "text/html; charset=utf-8" }
|
|
6106
6106
|
});
|
|
6107
|
-
await t.
|
|
6107
|
+
await t.step("Wrong Content-Type", async () => {
|
|
6108
6108
|
(0, node_assert.deepStrictEqual)(await fetchDocumentLoader("https://example.com/wrong-content-type"), {
|
|
6109
6109
|
contextUrl: null,
|
|
6110
6110
|
documentUrl: "https://example.com/wrong-content-type",
|
|
@@ -6117,10 +6117,10 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
6117
6117
|
});
|
|
6118
6118
|
});
|
|
6119
6119
|
esm_default.get("https://example.com/404", { status: 404 });
|
|
6120
|
-
await t.
|
|
6120
|
+
await t.step("not ok", async () => {
|
|
6121
6121
|
await (0, node_assert.rejects)(() => fetchDocumentLoader("https://example.com/404"), require_request.FetchError, "HTTP 404: https://example.com/404");
|
|
6122
6122
|
});
|
|
6123
|
-
await t.
|
|
6123
|
+
await t.step("preloaded contexts", async () => {
|
|
6124
6124
|
for (const [url, document] of Object.entries(preloadedContexts)) (0, node_assert.deepStrictEqual)(await fetchDocumentLoader(url), {
|
|
6125
6125
|
contextUrl: null,
|
|
6126
6126
|
documentUrl: url,
|
|
@@ -6128,7 +6128,7 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
6128
6128
|
});
|
|
6129
6129
|
});
|
|
6130
6130
|
esm_default.get("https://www.w3.org/ns/cid/v1", { status: 503 });
|
|
6131
|
-
await t.
|
|
6131
|
+
await t.step("preloaded CID v1 context", async () => {
|
|
6132
6132
|
const url = "https://www.w3.org/ns/cid/v1";
|
|
6133
6133
|
(0, node_assert.deepStrictEqual)(await fetchDocumentLoader(url), {
|
|
6134
6134
|
contextUrl: null,
|
|
@@ -6136,7 +6136,7 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
6136
6136
|
document: cid_v1_default
|
|
6137
6137
|
});
|
|
6138
6138
|
});
|
|
6139
|
-
await t.
|
|
6139
|
+
await t.step("preloaded FEP-ef61 context", async () => {
|
|
6140
6140
|
const url = "https://w3id.org/fep/ef61";
|
|
6141
6141
|
(0, node_assert.ok)(url in preloadedContexts);
|
|
6142
6142
|
(0, node_assert.deepStrictEqual)(await fetchDocumentLoader(url), {
|
|
@@ -6153,7 +6153,7 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
6153
6153
|
});
|
|
6154
6154
|
});
|
|
6155
6155
|
esm_default.get("https://w3id.org/fep/7aa9", { status: 502 });
|
|
6156
|
-
await t.
|
|
6156
|
+
await t.step("preloaded FEP-7aa9 context", async () => {
|
|
6157
6157
|
const url = "https://w3id.org/fep/7aa9";
|
|
6158
6158
|
(0, node_assert.deepStrictEqual)(await fetchDocumentLoader(url), {
|
|
6159
6159
|
contextUrl: null,
|
|
@@ -6184,7 +6184,7 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
6184
6184
|
(0, node_assert.deepStrictEqual)(esm_default.callHistory.calls(url).length, 0);
|
|
6185
6185
|
});
|
|
6186
6186
|
esm_default.get("https://w3id.org/fep/6757", { status: 502 });
|
|
6187
|
-
await t.
|
|
6187
|
+
await t.step("preloaded FEP-6757 context", async () => {
|
|
6188
6188
|
const url = "https://w3id.org/fep/6757";
|
|
6189
6189
|
(0, node_assert.deepStrictEqual)(await fetchDocumentLoader(url), {
|
|
6190
6190
|
contextUrl: null,
|
|
@@ -6213,7 +6213,7 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
6213
6213
|
(0, node_assert.deepStrictEqual)(esm_default.callHistory.calls(url).length, 0);
|
|
6214
6214
|
});
|
|
6215
6215
|
esm_default.get("https://w3id.org/fep/22cd", { status: 502 });
|
|
6216
|
-
await t.
|
|
6216
|
+
await t.step("preloaded FEP-22cd context", async () => {
|
|
6217
6217
|
const url = "https://w3id.org/fep/22cd";
|
|
6218
6218
|
const articleId = "https://example.com/articles/1";
|
|
6219
6219
|
const translatorId = "https://example.com/users/alice";
|
|
@@ -6291,7 +6291,7 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
6291
6291
|
(0, node_assert.deepStrictEqual)(esm_default.callHistory.calls(url).length, 0);
|
|
6292
6292
|
(0, node_assert.deepStrictEqual)(esm_default.callHistory.calls("https://www.w3.org/ns/activitystreams").length, 0);
|
|
6293
6293
|
});
|
|
6294
|
-
await t.
|
|
6294
|
+
await t.step("deny non-HTTP/HTTPS", async () => {
|
|
6295
6295
|
await (0, node_assert.rejects)(() => fetchDocumentLoader("ftp://localhost"), require_url.UrlError);
|
|
6296
6296
|
});
|
|
6297
6297
|
esm_default.get("https://example.com/localhost-redirect", {
|
|
@@ -6316,13 +6316,13 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
6316
6316
|
name: "Fetched object",
|
|
6317
6317
|
type: "Object"
|
|
6318
6318
|
} });
|
|
6319
|
-
await t.
|
|
6319
|
+
await t.step("allowPrivateAddress: false", async () => {
|
|
6320
6320
|
await (0, node_assert.rejects)(() => fetchDocumentLoader("https://localhost/object"), require_url.UrlError);
|
|
6321
6321
|
await (0, node_assert.rejects)(() => fetchDocumentLoader("https://example.com/localhost-redirect"), require_url.UrlError);
|
|
6322
6322
|
await (0, node_assert.rejects)(() => fetchDocumentLoader("https://example.com/localhost-link"), require_url.UrlError);
|
|
6323
6323
|
});
|
|
6324
6324
|
const fetchDocumentLoader2 = getDocumentLoader({ allowPrivateAddress: true });
|
|
6325
|
-
await t.
|
|
6325
|
+
await t.step("allowPrivateAddress: true", async () => {
|
|
6326
6326
|
const expected = {
|
|
6327
6327
|
contextUrl: null,
|
|
6328
6328
|
documentUrl: "https://localhost/object",
|
|
@@ -6345,7 +6345,7 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
6345
6345
|
headers: { Location: `https://example.com/too-many-redirects/${Number(cl.url.split("/").at(-1)) + 1}` }
|
|
6346
6346
|
};
|
|
6347
6347
|
});
|
|
6348
|
-
await t.
|
|
6348
|
+
await t.step("too many redirects", async () => {
|
|
6349
6349
|
redirectAttempts = 0;
|
|
6350
6350
|
await (0, node_assert.rejects)(() => fetchDocumentLoader("https://example.com/too-many-redirects/0"), require_request.FetchError, "Too many redirections");
|
|
6351
6351
|
(0, node_assert.deepStrictEqual)(redirectAttempts, 21);
|
|
@@ -6365,7 +6365,7 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
6365
6365
|
headers: { Location: "https://example.com/redirect-loop-a" }
|
|
6366
6366
|
};
|
|
6367
6367
|
});
|
|
6368
|
-
await t.
|
|
6368
|
+
await t.step("redirect loop", async () => {
|
|
6369
6369
|
loopAttempts = 0;
|
|
6370
6370
|
await (0, node_assert.rejects)(() => fetchDocumentLoader("https://example.com/redirect-loop-a"), require_request.FetchError, "Redirect loop detected");
|
|
6371
6371
|
(0, node_assert.deepStrictEqual)(loopAttempts, 2);
|
|
@@ -6378,7 +6378,7 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
6378
6378
|
headers: { Location: "/redirect-loop-relative" }
|
|
6379
6379
|
};
|
|
6380
6380
|
});
|
|
6381
|
-
await t.
|
|
6381
|
+
await t.step("redirect loop with relative location", async () => {
|
|
6382
6382
|
relativeLoopAttempts = 0;
|
|
6383
6383
|
await (0, node_assert.rejects)(() => fetchDocumentLoader("https://example.com/redirect-loop-relative"), require_request.FetchError, "Redirect loop detected");
|
|
6384
6384
|
(0, node_assert.deepStrictEqual)(relativeLoopAttempts, 1);
|
|
@@ -6388,7 +6388,7 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
6388
6388
|
body: maliciousPayload,
|
|
6389
6389
|
headers: { "Content-Type": "text/html; charset=utf-8" }
|
|
6390
6390
|
});
|
|
6391
|
-
await t.
|
|
6391
|
+
await t.step("ReDoS resistance (CVE-2025-68475)", async () => {
|
|
6392
6392
|
const start = performance.now();
|
|
6393
6393
|
await (0, node_assert.rejects)(() => fetchDocumentLoader("https://example.com/redos"), SyntaxError);
|
|
6394
6394
|
const elapsed = performance.now() - start;
|
|
@@ -6396,7 +6396,7 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
6396
6396
|
});
|
|
6397
6397
|
esm_default.hardReset();
|
|
6398
6398
|
});
|
|
6399
|
-
(0,
|
|
6399
|
+
(0, _fedify_fixture.test)("getDocumentLoader() bounds JSON, HTML, and alternate documents", async () => {
|
|
6400
6400
|
const url = "https://example.com/bounded";
|
|
6401
6401
|
esm_default.mockGlobal();
|
|
6402
6402
|
let oversized = true;
|
|
@@ -6426,7 +6426,7 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
6426
6426
|
esm_default.hardReset();
|
|
6427
6427
|
}
|
|
6428
6428
|
});
|
|
6429
|
-
(0,
|
|
6429
|
+
(0, _fedify_fixture.test)("getDocumentLoader() rejects oversized gzip responses from fetch", async () => {
|
|
6430
6430
|
const document = { name: "a".repeat(16 * 1024 * 1024) };
|
|
6431
6431
|
const compressed = (0, node_zlib.gzipSync)(JSON.stringify(document));
|
|
6432
6432
|
(0, node_assert.ok)(compressed.byteLength < 64 * 1024);
|
|
@@ -6456,7 +6456,7 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
6456
6456
|
});
|
|
6457
6457
|
}
|
|
6458
6458
|
});
|
|
6459
|
-
(0,
|
|
6459
|
+
(0, _fedify_fixture.test)("getRemoteDocument() bounds JSON by default", async () => {
|
|
6460
6460
|
let canceled = false;
|
|
6461
6461
|
let pulls = 0;
|
|
6462
6462
|
await (0, node_assert.rejects)(getRemoteDocument("https://example.com/document", new Response(new ReadableStream({
|
|
@@ -6473,17 +6473,14 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
6473
6473
|
(0, node_assert.deepStrictEqual)(canceled, true);
|
|
6474
6474
|
(0, node_assert.deepStrictEqual)(pulls, 257);
|
|
6475
6475
|
});
|
|
6476
|
-
(0,
|
|
6477
|
-
if ("Deno" in globalThis && (await Deno.permissions.query({ name: "net" })).state !== "granted")
|
|
6478
|
-
t.skip("requires the net permission");
|
|
6479
|
-
return;
|
|
6480
|
-
}
|
|
6476
|
+
(0, _fedify_fixture.test)("getDocumentLoader() logs DNS failures as such", async (t) => {
|
|
6477
|
+
if ("Deno" in globalThis && (await Deno.permissions.query({ name: "net" })).state !== "granted") throw new Error("This DNS test requires Deno network permission (--allow-net).");
|
|
6481
6478
|
const loader = getDocumentLoader();
|
|
6482
6479
|
for (const result of [
|
|
6483
6480
|
"throws",
|
|
6484
6481
|
"empty",
|
|
6485
6482
|
"private"
|
|
6486
|
-
]) await t.
|
|
6483
|
+
]) await t.step(result, async () => {
|
|
6487
6484
|
const originalLookup = node_dns_promises.default.lookup;
|
|
6488
6485
|
node_dns_promises.default.lookup = (() => result === "throws" ? Promise.reject(/* @__PURE__ */ new Error("Resolver unavailable")) : Promise.resolve(result === "empty" ? [] : [{
|
|
6489
6486
|
address: "127.0.0.1",
|
|
@@ -6531,14 +6528,14 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
6531
6528
|
}
|
|
6532
6529
|
});
|
|
6533
6530
|
});
|
|
6534
|
-
(0,
|
|
6531
|
+
(0, _fedify_fixture.test)("getDocumentLoader() bounds alternate document chains", async (t) => {
|
|
6535
6532
|
const base = "https://example.com/alternate-chain/";
|
|
6536
6533
|
const loader = getDocumentLoader({ allowPrivateAddress: true });
|
|
6537
6534
|
for (const mode of [
|
|
6538
6535
|
"header",
|
|
6539
6536
|
"html",
|
|
6540
6537
|
"mixed"
|
|
6541
|
-
]) for (const hops of [20, 21]) await t.
|
|
6538
|
+
]) for (const hops of [20, 21]) await t.step(`${mode}: ${hops} hops`, async () => {
|
|
6542
6539
|
esm_default.mockGlobal();
|
|
6543
6540
|
let requests = 0;
|
|
6544
6541
|
esm_default.get(`begin:${base}`, ({ url }) => {
|
|
@@ -6567,7 +6564,7 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
6567
6564
|
"alternate-redirect",
|
|
6568
6565
|
"redirect-alternate",
|
|
6569
6566
|
"redirect-intermediate"
|
|
6570
|
-
]) await t.
|
|
6567
|
+
]) await t.step(`${mode}: cycle`, async () => {
|
|
6571
6568
|
esm_default.mockGlobal();
|
|
6572
6569
|
let requests = 0;
|
|
6573
6570
|
esm_default.get(`begin:${base}`, ({ url }) => {
|
|
@@ -6589,7 +6586,7 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
6589
6586
|
esm_default.hardReset();
|
|
6590
6587
|
}
|
|
6591
6588
|
});
|
|
6592
|
-
await t.
|
|
6589
|
+
await t.step("alternate followed by 20 redirects shares the limit", async () => {
|
|
6593
6590
|
esm_default.mockGlobal();
|
|
6594
6591
|
let requests = 0;
|
|
6595
6592
|
esm_default.get(`begin:${base}`, ({ url }) => {
|
|
@@ -6609,7 +6606,7 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
6609
6606
|
esm_default.hardReset();
|
|
6610
6607
|
}
|
|
6611
6608
|
});
|
|
6612
|
-
await t.
|
|
6609
|
+
await t.step("relative alternate after redirect and isolated calls", async () => {
|
|
6613
6610
|
esm_default.mockGlobal();
|
|
6614
6611
|
esm_default.get(`${base}start`, Response.redirect(`${base}html`, 302));
|
|
6615
6612
|
esm_default.get(`${base}html`, alternate("./document", true));
|
|
@@ -6633,10 +6630,10 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
6633
6630
|
} });
|
|
6634
6631
|
}
|
|
6635
6632
|
});
|
|
6636
|
-
(0,
|
|
6633
|
+
(0, _fedify_fixture.test)("getDocumentLoader() preserves cancellation across alternates", async (t) => {
|
|
6637
6634
|
const base = "https://example.com/alternate-abort/";
|
|
6638
6635
|
const loader = getDocumentLoader({ allowPrivateAddress: true });
|
|
6639
|
-
for (const html of [false, true]) await t.
|
|
6636
|
+
for (const html of [false, true]) await t.step(html ? "HTML" : "Link header", async () => {
|
|
6640
6637
|
esm_default.mockGlobal();
|
|
6641
6638
|
const controller = new AbortController();
|
|
6642
6639
|
let requests = 0;
|
|
@@ -6659,7 +6656,7 @@ var jsonld_default = jsonld_dist_jsonld_esm_js.default;
|
|
|
6659
6656
|
}
|
|
6660
6657
|
});
|
|
6661
6658
|
});
|
|
6662
|
-
(0,
|
|
6659
|
+
(0, _fedify_fixture.test)("getDocumentLoader() rejects cancellation before fetching", async () => {
|
|
6663
6660
|
esm_default.mockGlobal();
|
|
6664
6661
|
let requests = 0;
|
|
6665
6662
|
const url = "https://example.com/pre-aborted-alternate";
|