@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.
Files changed (114) hide show
  1. package/deno.json +5 -2
  2. package/dist/internal.cjs +6 -0
  3. package/dist/internal.d.cts +3 -0
  4. package/dist/internal.d.ts +3 -0
  5. package/dist/internal.js +3 -0
  6. package/dist/mod.cjs +105 -253
  7. package/dist/mod.d.cts +5 -28
  8. package/dist/mod.d.ts +6 -28
  9. package/dist/mod.js +98 -245
  10. package/dist/public-fetch-BC-nWJNM.d.ts +143 -0
  11. package/dist/public-fetch-Bk32IaYB.cjs +821 -0
  12. package/dist/public-fetch-DBpt3xxf.d.cts +143 -0
  13. package/dist/public-fetch-Dfmc_Kfy.js +772 -0
  14. package/dist/tests/{body-BmS3KJE1.cjs → body-BtW9TZGZ.cjs} +1 -1
  15. package/dist/tests/{body-xrlsEUPK.mjs → body-CmdrGt1w.mjs} +1 -1
  16. package/dist/tests/body.test.cjs +1 -1
  17. package/dist/tests/body.test.mjs +1 -1
  18. package/dist/tests/decimal.test.cjs +6 -6
  19. package/dist/tests/decimal.test.mjs +6 -6
  20. package/dist/tests/{docloader-CETMi5su.cjs → docloader-D34pSxKd.cjs} +106 -35
  21. package/dist/tests/{docloader-BJXlwNXs.mjs → docloader-zoX3z1bj.mjs} +102 -37
  22. package/dist/tests/docloader.test.cjs +523 -1273
  23. package/dist/tests/docloader.test.mjs +469 -1238
  24. package/dist/tests/esm-C_ftyt-G.cjs +1208 -0
  25. package/dist/tests/esm-LaZ1p80h.mjs +1222 -0
  26. package/dist/tests/internal/multicodec.test.cjs +1 -1
  27. package/dist/tests/internal/multicodec.test.mjs +1 -1
  28. package/dist/tests/{key-Qj7u1qmH.mjs → key-2lZR0Cht.mjs} +2 -2
  29. package/dist/tests/{key-CWDxavIR.cjs → key-CnsHrQSU.cjs} +2 -2
  30. package/dist/tests/key.test.cjs +2 -2
  31. package/dist/tests/key.test.mjs +2 -2
  32. package/dist/tests/{langstr-BsqFJupv.cjs → langstr-CZpWmpo5.cjs} +1 -1
  33. package/dist/tests/{langstr-ABdAOKlF.mjs → langstr-DTB4sl0a.mjs} +1 -1
  34. package/dist/tests/langstr.test.cjs +1 -1
  35. package/dist/tests/langstr.test.mjs +1 -1
  36. package/dist/tests/langtag.test.cjs +1 -1
  37. package/dist/tests/langtag.test.mjs +1 -1
  38. package/dist/tests/link.test.mjs +1 -1
  39. package/dist/tests/multibase/multibase.test.cjs +1 -1
  40. package/dist/tests/multibase/multibase.test.mjs +1 -1
  41. package/dist/tests/node-C0iftNaR.cjs +90 -0
  42. package/dist/tests/node-C3bjFjL1.mjs +84 -0
  43. package/dist/tests/pin-grant-CU-o367k.cjs +70 -0
  44. package/dist/tests/pin-grant-HW3B6SKv.mjs +53 -0
  45. package/dist/tests/pin-grant.test.cjs +88 -0
  46. package/dist/tests/pin-grant.test.d.cts +1 -0
  47. package/dist/tests/pin-grant.test.d.mts +1 -0
  48. package/dist/tests/pin-grant.test.mjs +88 -0
  49. package/dist/tests/pinners/bun.test.cjs +167 -0
  50. package/dist/tests/pinners/bun.test.d.cts +1 -0
  51. package/dist/tests/pinners/bun.test.d.mts +1 -0
  52. package/dist/tests/pinners/bun.test.mjs +167 -0
  53. package/dist/tests/pinners/node.test.cjs +269 -0
  54. package/dist/tests/pinners/node.test.d.cts +1 -0
  55. package/dist/tests/pinners/node.test.d.mts +1 -0
  56. package/dist/tests/pinners/node.test.mjs +268 -0
  57. package/dist/tests/pinners/pinners.test.cjs +197 -0
  58. package/dist/tests/pinners/pinners.test.d.cts +1 -0
  59. package/dist/tests/pinners/pinners.test.d.mts +1 -0
  60. package/dist/tests/pinners/pinners.test.mjs +197 -0
  61. package/dist/tests/pinners/testdata/node-child.cjs +135 -0
  62. package/dist/tests/pinners/testdata/node-child.d.cts +1 -0
  63. package/dist/tests/pinners/testdata/node-child.d.mts +1 -0
  64. package/dist/tests/pinners/testdata/node-child.mjs +134 -0
  65. package/dist/tests/pinners-D4UQ-HXm.cjs +221 -0
  66. package/dist/tests/pinners-ZgZDx9y6.mjs +203 -0
  67. package/dist/tests/public-fetch-BtiBjQPL.cjs +187 -0
  68. package/dist/tests/public-fetch-Yi7Vks9s.mjs +170 -0
  69. package/dist/tests/public-fetch.test.cjs +1074 -0
  70. package/dist/tests/public-fetch.test.d.cts +1 -0
  71. package/dist/tests/public-fetch.test.d.mts +1 -0
  72. package/dist/tests/public-fetch.test.mjs +1074 -0
  73. package/dist/tests/{request-rtQTKXfB.mjs → request-BKFirRrO.mjs} +1 -1
  74. package/dist/tests/{request-pbEw07NE.cjs → request-CqKju-Ll.cjs} +1 -1
  75. package/dist/tests/request.test.cjs +1 -1
  76. package/dist/tests/request.test.mjs +1 -1
  77. package/dist/tests/support-Cj0T6TP_.cjs +363 -0
  78. package/dist/tests/support-M5ClN-no.mjs +272 -0
  79. package/dist/tests/{url-4PAkYhZC.cjs → url-BR7UVTkW.cjs} +88 -12
  80. package/dist/tests/{url-3fyJuqC0.mjs → url-DQWrMGhu.mjs} +65 -13
  81. package/dist/tests/url.test.cjs +4 -1
  82. package/dist/tests/url.test.mjs +4 -1
  83. package/package.json +14 -3
  84. package/src/docloader.test.ts +700 -32
  85. package/src/docloader.ts +174 -67
  86. package/src/internal.ts +13 -0
  87. package/src/pin-grant.test.ts +118 -0
  88. package/src/pin-grant.ts +99 -0
  89. package/src/pinners/bun.test.ts +278 -0
  90. package/src/pinners/bun.ts +223 -0
  91. package/src/pinners/mod.ts +59 -0
  92. package/src/pinners/node.test.ts +415 -0
  93. package/src/pinners/node.ts +144 -0
  94. package/src/pinners/pinners.test.ts +316 -0
  95. package/src/pinners/testdata/node-child.ts +147 -0
  96. package/src/pinners/testdata/proxy-child.ts +82 -0
  97. package/src/pinners/testdata/support.ts +343 -0
  98. package/src/pinners/testdata/tls-cert.pem +12 -0
  99. package/src/pinners/testdata/tls-child.ts +88 -0
  100. package/src/pinners/testdata/tls-key.pem +5 -0
  101. package/src/pinners/types.ts +48 -0
  102. package/src/public-fetch.test.ts +1286 -0
  103. package/src/public-fetch.ts +338 -0
  104. package/src/testdata/public-fetch-deno-worker.ts +74 -0
  105. package/src/url.test.ts +11 -0
  106. package/src/url.ts +113 -22
  107. package/tsdown.config.ts +12 -3
  108. /package/dist/tests/{langtag-LDBqlxHv.mjs → langtag-D8FWxjv8.mjs} +0 -0
  109. /package/dist/tests/{langtag-DgySESmk.cjs → langtag-a2-s9uyi.cjs} +0 -0
  110. /package/dist/tests/{link-CYszIegt.mjs → link-CHMtH2-k.mjs} +0 -0
  111. /package/dist/tests/{multibase-BL45eko3.cjs → multibase-CPwWBzL3.cjs} +0 -0
  112. /package/dist/tests/{multibase-Da9VJCw8.mjs → multibase-D85wf3ZR.mjs} +0 -0
  113. /package/dist/tests/{multicodec-ByS9XLsw.cjs → multicodec-B-_CSt1M.cjs} +0 -0
  114. /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 };