@fedify/vocab-runtime 2.3.15-dev.2482 → 2.3.15
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 +5 -2
- package/dist/internal.cjs +6 -0
- package/dist/internal.d.cts +3 -0
- package/dist/internal.d.ts +3 -0
- package/dist/internal.js +3 -0
- package/dist/mod.cjs +105 -253
- package/dist/mod.d.cts +5 -28
- package/dist/mod.d.ts +6 -28
- package/dist/mod.js +98 -245
- package/dist/public-fetch-BC-nWJNM.d.ts +143 -0
- package/dist/public-fetch-Bk32IaYB.cjs +821 -0
- package/dist/public-fetch-DBpt3xxf.d.cts +143 -0
- package/dist/public-fetch-Dfmc_Kfy.js +772 -0
- package/dist/tests/{body-BmS3KJE1.cjs → body-BtW9TZGZ.cjs} +1 -1
- package/dist/tests/{body-xrlsEUPK.mjs → body-CmdrGt1w.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 +6 -6
- package/dist/tests/decimal.test.mjs +6 -6
- package/dist/tests/{docloader-CETMi5su.cjs → docloader-D34pSxKd.cjs} +106 -35
- package/dist/tests/{docloader-BJXlwNXs.mjs → docloader-zoX3z1bj.mjs} +102 -37
- package/dist/tests/docloader.test.cjs +523 -1273
- package/dist/tests/docloader.test.mjs +469 -1238
- package/dist/tests/esm-C_ftyt-G.cjs +1208 -0
- package/dist/tests/esm-LaZ1p80h.mjs +1222 -0
- package/dist/tests/internal/multicodec.test.cjs +1 -1
- package/dist/tests/internal/multicodec.test.mjs +1 -1
- package/dist/tests/{key-Qj7u1qmH.mjs → key-2lZR0Cht.mjs} +2 -2
- package/dist/tests/{key-CWDxavIR.cjs → key-CnsHrQSU.cjs} +2 -2
- package/dist/tests/key.test.cjs +2 -2
- package/dist/tests/key.test.mjs +2 -2
- package/dist/tests/{langstr-BsqFJupv.cjs → langstr-CZpWmpo5.cjs} +1 -1
- package/dist/tests/{langstr-ABdAOKlF.mjs → langstr-DTB4sl0a.mjs} +1 -1
- package/dist/tests/langstr.test.cjs +1 -1
- package/dist/tests/langstr.test.mjs +1 -1
- package/dist/tests/langtag.test.cjs +1 -1
- package/dist/tests/langtag.test.mjs +1 -1
- package/dist/tests/link.test.mjs +1 -1
- package/dist/tests/multibase/multibase.test.cjs +1 -1
- package/dist/tests/multibase/multibase.test.mjs +1 -1
- package/dist/tests/node-C0iftNaR.cjs +90 -0
- package/dist/tests/node-C3bjFjL1.mjs +84 -0
- package/dist/tests/pin-grant-CU-o367k.cjs +70 -0
- package/dist/tests/pin-grant-HW3B6SKv.mjs +53 -0
- package/dist/tests/pin-grant.test.cjs +88 -0
- package/dist/tests/pin-grant.test.d.cts +1 -0
- package/dist/tests/pin-grant.test.d.mts +1 -0
- package/dist/tests/pin-grant.test.mjs +88 -0
- package/dist/tests/pinners/bun.test.cjs +167 -0
- package/dist/tests/pinners/bun.test.d.cts +1 -0
- package/dist/tests/pinners/bun.test.d.mts +1 -0
- package/dist/tests/pinners/bun.test.mjs +167 -0
- package/dist/tests/pinners/node.test.cjs +269 -0
- package/dist/tests/pinners/node.test.d.cts +1 -0
- package/dist/tests/pinners/node.test.d.mts +1 -0
- package/dist/tests/pinners/node.test.mjs +268 -0
- package/dist/tests/pinners/pinners.test.cjs +197 -0
- package/dist/tests/pinners/pinners.test.d.cts +1 -0
- package/dist/tests/pinners/pinners.test.d.mts +1 -0
- package/dist/tests/pinners/pinners.test.mjs +197 -0
- package/dist/tests/pinners/testdata/node-child.cjs +135 -0
- package/dist/tests/pinners/testdata/node-child.d.cts +1 -0
- package/dist/tests/pinners/testdata/node-child.d.mts +1 -0
- package/dist/tests/pinners/testdata/node-child.mjs +134 -0
- package/dist/tests/pinners-D4UQ-HXm.cjs +221 -0
- package/dist/tests/pinners-ZgZDx9y6.mjs +203 -0
- package/dist/tests/public-fetch-BtiBjQPL.cjs +187 -0
- package/dist/tests/public-fetch-Yi7Vks9s.mjs +170 -0
- package/dist/tests/public-fetch.test.cjs +1074 -0
- package/dist/tests/public-fetch.test.d.cts +1 -0
- package/dist/tests/public-fetch.test.d.mts +1 -0
- package/dist/tests/public-fetch.test.mjs +1074 -0
- package/dist/tests/{request-rtQTKXfB.mjs → request-BKFirRrO.mjs} +1 -1
- package/dist/tests/{request-pbEw07NE.cjs → request-CqKju-Ll.cjs} +1 -1
- package/dist/tests/request.test.cjs +1 -1
- package/dist/tests/request.test.mjs +1 -1
- package/dist/tests/support-Cj0T6TP_.cjs +363 -0
- package/dist/tests/support-M5ClN-no.mjs +272 -0
- package/dist/tests/{url-4PAkYhZC.cjs → url-BR7UVTkW.cjs} +88 -12
- package/dist/tests/{url-3fyJuqC0.mjs → url-DQWrMGhu.mjs} +65 -13
- package/dist/tests/url.test.cjs +4 -1
- package/dist/tests/url.test.mjs +4 -1
- package/package.json +14 -3
- package/src/docloader.test.ts +700 -32
- package/src/docloader.ts +174 -67
- package/src/internal.ts +13 -0
- package/src/pin-grant.test.ts +118 -0
- package/src/pin-grant.ts +99 -0
- package/src/pinners/bun.test.ts +278 -0
- package/src/pinners/bun.ts +223 -0
- package/src/pinners/mod.ts +59 -0
- package/src/pinners/node.test.ts +415 -0
- package/src/pinners/node.ts +144 -0
- package/src/pinners/pinners.test.ts +316 -0
- package/src/pinners/testdata/node-child.ts +147 -0
- package/src/pinners/testdata/proxy-child.ts +82 -0
- package/src/pinners/testdata/support.ts +343 -0
- package/src/pinners/testdata/tls-cert.pem +12 -0
- package/src/pinners/testdata/tls-child.ts +88 -0
- package/src/pinners/testdata/tls-key.pem +5 -0
- package/src/pinners/types.ts +48 -0
- package/src/public-fetch.test.ts +1286 -0
- package/src/public-fetch.ts +338 -0
- package/src/testdata/public-fetch-deno-worker.ts +74 -0
- package/src/url.test.ts +11 -0
- package/src/url.ts +113 -22
- package/tsdown.config.ts +12 -3
- /package/dist/tests/{langtag-LDBqlxHv.mjs → langtag-D8FWxjv8.mjs} +0 -0
- /package/dist/tests/{langtag-DgySESmk.cjs → langtag-a2-s9uyi.cjs} +0 -0
- /package/dist/tests/{link-CYszIegt.mjs → link-CHMtH2-k.mjs} +0 -0
- /package/dist/tests/{multibase-BL45eko3.cjs → multibase-CPwWBzL3.cjs} +0 -0
- /package/dist/tests/{multibase-Da9VJCw8.mjs → multibase-D85wf3ZR.mjs} +0 -0
- /package/dist/tests/{multicodec-ByS9XLsw.cjs → multicodec-B-_CSt1M.cjs} +0 -0
- /package/dist/tests/{multicodec-BBPZjRfg.mjs → multicodec-caWdG98t.mjs} +0 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/// <reference lib="esnext.temporal" />
|
|
2
|
+
//#region src/url.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* An address returned by a DNS lookup. It has the same shape as
|
|
5
|
+
* `ResolvedAddress` of `node:dns`, without depending on its type declarations.
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
interface ResolvedAddress {
|
|
9
|
+
/** An IPv4 or IPv6 address. */
|
|
10
|
+
readonly address: string;
|
|
11
|
+
/** The IP family of the address: `4` or `6`. */
|
|
12
|
+
readonly family: number;
|
|
13
|
+
}
|
|
14
|
+
declare class UrlError extends Error {
|
|
15
|
+
/**
|
|
16
|
+
* The failure category. Defaults to `"disallowed"`.
|
|
17
|
+
* `"dns"` includes lookup errors and results with no usable IP addresses.
|
|
18
|
+
* @since 2.0.29
|
|
19
|
+
*/
|
|
20
|
+
readonly reason: "dns" | "disallowed";
|
|
21
|
+
constructor(message: string, options?: {
|
|
22
|
+
cause?: unknown;
|
|
23
|
+
reason?: "dns" | "disallowed";
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Validates a URL to prevent SSRF attacks.
|
|
28
|
+
*
|
|
29
|
+
* This function only checks the addresses that the hostname currently
|
|
30
|
+
* resolves to; it does not pin the connection to those addresses. A request
|
|
31
|
+
* made after this check resolves the hostname again, so this function alone
|
|
32
|
+
* does not prevent DNS rebinding.
|
|
33
|
+
*/
|
|
34
|
+
declare function validatePublicUrl(url: string): Promise<void>;
|
|
35
|
+
declare function isValidPublicIPv4Address(address: string): boolean;
|
|
36
|
+
declare function isValidPublicIPv6Address(address: string): boolean;
|
|
37
|
+
declare function expandIPv6Address(address: string): string;
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/public-fetch.d.ts
|
|
40
|
+
/**
|
|
41
|
+
* Options for {@link openPublicFetch} and {@link withPublicFetch}.
|
|
42
|
+
*/
|
|
43
|
+
interface PublicFetchOptions {
|
|
44
|
+
/**
|
|
45
|
+
* An `AbortSignal` for cancelling the DNS lookup.
|
|
46
|
+
*/
|
|
47
|
+
readonly signal?: AbortSignal;
|
|
48
|
+
/**
|
|
49
|
+
* A function that resolves all addresses of a hostname, used instead of
|
|
50
|
+
* `node:dns.lookup()`. The addresses it returns are validated in the same
|
|
51
|
+
* way as the default lookup's.
|
|
52
|
+
*/
|
|
53
|
+
readonly lookup?: (hostname: string) => Promise<readonly ResolvedAddress[]>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* A session for fetching resources from a single origin. Its `fetch()`
|
|
57
|
+
* connects only to the addresses validated when the session was opened, on
|
|
58
|
+
* runtimes that support it.
|
|
59
|
+
*/
|
|
60
|
+
interface PublicFetchSession {
|
|
61
|
+
/**
|
|
62
|
+
* A copy of the URL the session was opened for.
|
|
63
|
+
*/
|
|
64
|
+
readonly url: URL;
|
|
65
|
+
/**
|
|
66
|
+
* Fetches a resource from the session's origin. Redirects are never
|
|
67
|
+
* followed; the redirect mode is always `"manual"`.
|
|
68
|
+
* @throws {TypeError} If the input's origin differs from the session's, or
|
|
69
|
+
* if the session is closed.
|
|
70
|
+
*/
|
|
71
|
+
fetch(input: Request | URL | string, init?: RequestInit): Promise<Response>;
|
|
72
|
+
/**
|
|
73
|
+
* Closes the session. The cancellation of response bodies that have been
|
|
74
|
+
* neither consumed nor cancelled is started (without waiting for it), and
|
|
75
|
+
* the session can no longer fetch. Calling this more than once has no
|
|
76
|
+
* effect.
|
|
77
|
+
*/
|
|
78
|
+
close(): Promise<void>;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The functions created by {@link createPublicFetch}.
|
|
82
|
+
*/
|
|
83
|
+
interface PublicFetch {
|
|
84
|
+
/**
|
|
85
|
+
* Validates the URL, resolves its hostname, checks that every resolved
|
|
86
|
+
* address is public, and opens a session that connects only to those
|
|
87
|
+
* addresses.
|
|
88
|
+
* @param url The URL to open a session for.
|
|
89
|
+
* @param options The options.
|
|
90
|
+
* @returns The session. It must be closed.
|
|
91
|
+
* @throws {UrlError} If the URL is not allowed, or its hostname cannot be
|
|
92
|
+
* resolved (with `reason: "dns"`).
|
|
93
|
+
*/
|
|
94
|
+
openPublicFetch(url: URL | string, options?: PublicFetchOptions): Promise<PublicFetchSession>;
|
|
95
|
+
/**
|
|
96
|
+
* Opens a session with {@link PublicFetch.openPublicFetch}, runs the given
|
|
97
|
+
* function with its `fetch()`, and closes the session afterwards.
|
|
98
|
+
* @param url The URL to open a session for.
|
|
99
|
+
* @param fn The function to run. It must not return a `Response`, since
|
|
100
|
+
* the response bodies are cancelled when the session is closed.
|
|
101
|
+
* @param options The options.
|
|
102
|
+
* @returns The value returned by `fn`.
|
|
103
|
+
* @throws {UrlError} If the URL is not allowed.
|
|
104
|
+
* @throws {TypeError} If `fn` returns a `Response`.
|
|
105
|
+
*/
|
|
106
|
+
withPublicFetch<T>(url: URL | string, fn: (fetch: PublicFetchSession["fetch"]) => Promise<T>, options?: PublicFetchOptions): Promise<T>;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Validates the URL, resolves its hostname, checks that every resolved
|
|
110
|
+
* address is public, and opens a session that connects only to those
|
|
111
|
+
* addresses. Connections are pinned on Node.js and Bun. On other runtimes,
|
|
112
|
+
* the session uses the global `fetch()` after the check.
|
|
113
|
+
* @param url The URL to open a session for.
|
|
114
|
+
* @param options The options.
|
|
115
|
+
* @returns The session. It must be closed.
|
|
116
|
+
* @throws {UrlError} If the URL is not allowed, or its hostname cannot be
|
|
117
|
+
* resolved (with `reason: "dns"`).
|
|
118
|
+
*/
|
|
119
|
+
declare const openPublicFetch: PublicFetch["openPublicFetch"];
|
|
120
|
+
/**
|
|
121
|
+
* Opens a session with {@link openPublicFetch}, runs the given function with
|
|
122
|
+
* its `fetch()`, and closes the session afterwards.
|
|
123
|
+
* @param url The URL to open a session for.
|
|
124
|
+
* @param fn The function to run. It must not return a `Response`, since
|
|
125
|
+
* the response bodies are cancelled when the session is closed.
|
|
126
|
+
* @param options The options.
|
|
127
|
+
* @returns The value returned by `fn`.
|
|
128
|
+
* @throws {UrlError} If the URL is not allowed.
|
|
129
|
+
* @throws {TypeError} If `fn` returns a `Response`.
|
|
130
|
+
*/
|
|
131
|
+
declare const withPublicFetch: PublicFetch["withPublicFetch"];
|
|
132
|
+
/**
|
|
133
|
+
* Opens a session that neither validates nor pins addresses, for callers that
|
|
134
|
+
* allow private addresses. It has the same rules as {@link openPublicFetch}
|
|
135
|
+
* sessions otherwise: requests are limited to the URL's origin, redirects are
|
|
136
|
+
* never followed, and unconsumed response bodies are cancelled on close.
|
|
137
|
+
* It grants nothing beyond calling the global `fetch()` directly.
|
|
138
|
+
* @param url The URL to open a session for.
|
|
139
|
+
* @returns The session. It must be closed.
|
|
140
|
+
*/
|
|
141
|
+
declare function openDirectFetch(url: URL | string): Promise<PublicFetchSession>;
|
|
142
|
+
//#endregion
|
|
143
|
+
export { withPublicFetch as a, isValidPublicIPv4Address as c, openPublicFetch as i, isValidPublicIPv6Address as l, PublicFetchSession as n, UrlError as o, openDirectFetch as r, expandIPv6Address as s, PublicFetchOptions as t, validatePublicUrl as u };
|