@fedify/fedify 2.0.0-pr.433.1601 → 2.0.0-pr.434.1659

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 (171) hide show
  1. package/dist/actor-BODH8--e.cjs +37786 -0
  2. package/dist/{actor-BYk33gpL.js → actor-DJS2ne1f.js} +200 -200
  3. package/dist/actor-DMgu-ZjT.d.cts +128 -0
  4. package/dist/{actor-DhgsJz-4.js → actor-WgMDAZc5.js} +1 -1
  5. package/dist/{assert_rejects-7UF4R_Qs.js → assert_rejects-DiIiJbZn.js} +1 -1
  6. package/dist/{assert_throws-53_pKeP3.js → assert_throws-BOO88avQ.js} +1 -1
  7. package/dist/authdocloader-C8Eqv2Kg.cjs +58 -0
  8. package/dist/{authdocloader-Bnyhgo9N.js → authdocloader-FA-VNPvw.js} +3 -3
  9. package/dist/{authdocloader-Dcu0wNV2.js → authdocloader-SW1oQJ7q.js} +6 -6
  10. package/dist/{builder-QxLyGSq9.js → builder-Cp2PpvmH.js} +4 -4
  11. package/dist/chunk-DqRYRqnO.cjs +34 -0
  12. package/dist/client-CegPX0Rn.d.cts +222 -0
  13. package/dist/{client-apb-XuqD.js → client-D_BQdihX.js} +2 -7
  14. package/dist/compat/mod.cjs +10 -0
  15. package/dist/compat/mod.d.cts +13 -0
  16. package/dist/compat/mod.d.ts +2 -2
  17. package/dist/compat/mod.js +5 -5
  18. package/dist/compat/transformers.test.js +18 -17
  19. package/dist/compat-DmDDELst.cjs +4 -0
  20. package/dist/compat-nxUqe4Z-.js +4 -0
  21. package/dist/{context-CDSZdQHD.d.ts → context-CQsAT7xk.d.ts} +0 -1
  22. package/dist/context-tVOQ76fi.d.cts +2254 -0
  23. package/dist/docloader-D-MrRyHl.d.cts +219 -0
  24. package/dist/{docloader-C5a95do5.js → docloader-DrPHprgh.js} +188 -8
  25. package/dist/docloader-dZO9fPIT.cjs +4861 -0
  26. package/dist/{esm-Bgz4xida.js → esm-CjcCcZ6s.js} +1 -1
  27. package/dist/federation/builder.test.js +10 -10
  28. package/dist/federation/collection.test.js +8 -8
  29. package/dist/federation/handler.test.js +26 -145
  30. package/dist/federation/inbox.test.js +6 -6
  31. package/dist/federation/keycache.test.js +4 -4
  32. package/dist/federation/kv.test.js +9 -8
  33. package/dist/federation/middleware.test.js +255 -38
  34. package/dist/federation/mod.cjs +29 -0
  35. package/dist/federation/mod.d.cts +13 -0
  36. package/dist/federation/mod.d.ts +1 -1
  37. package/dist/federation/mod.js +15 -15
  38. package/dist/federation/mq.test.js +10 -10
  39. package/dist/federation/negotiation.test.d.ts +3 -0
  40. package/dist/federation/negotiation.test.js +28 -0
  41. package/dist/federation/retry.test.js +5 -5
  42. package/dist/federation/router.test.js +8 -8
  43. package/dist/federation/send.test.js +15 -15
  44. package/dist/{federation-CMX7WzeL.js → federation-D1U8YY9t.js} +3 -3
  45. package/dist/federation-H2_En3j5.cjs +244 -0
  46. package/dist/{http-DNI66-5x.js → http-BPkuNd26.js} +2 -2
  47. package/dist/http-BS6766zs.d.cts +253 -0
  48. package/dist/{http-JY6wHpzI.js → http-BgQ07Ja_.js} +6 -6
  49. package/dist/http-CZJRJ0Pv.cjs +826 -0
  50. package/dist/{inbox-DQ8L0DJL.js → inbox-CCB1CbWJ.js} +1 -1
  51. package/dist/{key-5IrrMBg5.js → key-B_P3wH2F.js} +5 -5
  52. package/dist/{key-Be6l1ofa.js → key-BstbqwrH.js} +3 -3
  53. package/dist/{key-BPlyixfT.js → key-C0k2A_bI.js} +2 -2
  54. package/dist/key-C8TOf6mh.cjs +290 -0
  55. package/dist/key-CtA7xiw_.js +10 -0
  56. package/dist/key-hknDPZ-z.cjs +10 -0
  57. package/dist/{keycache-C4ahXsL4.js → keycache-DvDW8JPA.js} +1 -1
  58. package/dist/{keys-DJSYNKDA.js → keys-DzXrG_sX.js} +1 -1
  59. package/dist/kv-63Cil1MD.d.cts +81 -0
  60. package/dist/{ld-CWJxBIBV.js → ld-BcKcM_o9.js} +2 -2
  61. package/dist/{lookup-BnXYO054.js → lookup-C3BC8XO-.js} +4 -4
  62. package/dist/lookup-C3BGNQTz.cjs +137 -0
  63. package/dist/{lookup-C7LsgCJN.js → lookup-DbTBDJcT.js} +1 -1
  64. package/dist/{middleware-exe_8YIh.js → middleware-B3crRaK-.js} +50 -81
  65. package/dist/middleware-BWXHJSkY.cjs +17 -0
  66. package/dist/middleware-C4A4GTtX.cjs +4204 -0
  67. package/dist/middleware-CGlIdSyy.js +17 -0
  68. package/dist/middleware-CUWXMbGt.js +26 -0
  69. package/dist/{middleware-DfHez8_s.js → middleware-CXRqw8n4.js} +49 -144
  70. package/dist/{mod-RI3-KvUI.d.ts → mod-B26zRlH1.d.ts} +1 -1
  71. package/dist/mod-BClfg3ej.d.cts +266 -0
  72. package/dist/mod-C2tOeRkN.d.cts +1 -0
  73. package/dist/mod-DBQAI4v9.d.cts +80 -0
  74. package/dist/mod-Dc_-mf8s.d.cts +102 -0
  75. package/dist/mod-FZd39qVq.d.cts +1 -0
  76. package/dist/mod-evzlRVZq.d.cts +289 -0
  77. package/dist/mod-jQ4OODsl.d.cts +113 -0
  78. package/dist/mod.cjs +150 -0
  79. package/dist/mod.d.cts +17 -0
  80. package/dist/mod.d.ts +2 -2
  81. package/dist/mod.js +20 -20
  82. package/dist/mq-B7R1Q-M5.d.cts +140 -0
  83. package/dist/negotiation-5NPJL6zp.js +71 -0
  84. package/dist/nodeinfo/client.test.js +10 -10
  85. package/dist/nodeinfo/handler.test.js +23 -22
  86. package/dist/nodeinfo/mod.cjs +11 -0
  87. package/dist/nodeinfo/mod.d.cts +5 -0
  88. package/dist/nodeinfo/mod.js +6 -6
  89. package/dist/nodeinfo/types.test.js +8 -8
  90. package/dist/nodeinfo-Co9lJrWl.cjs +4 -0
  91. package/dist/nodeinfo-DfycQ8Wf.js +4 -0
  92. package/dist/owner-B-7Ptt_m.d.cts +67 -0
  93. package/dist/{owner-CM_3htrf.js → owner-BcEciLTD.js} +2 -2
  94. package/dist/{proof-WqatqDcH.js → proof-DAEfR6xA.js} +6 -6
  95. package/dist/proof-ZBmKo2zb.cjs +673 -0
  96. package/dist/{proof-B13S28BP.js → proof-vGquXXR6.js} +2 -2
  97. package/dist/runtime/authdocloader.test.js +14 -14
  98. package/dist/runtime/docloader.test.js +9 -9
  99. package/dist/runtime/key.test.js +10 -10
  100. package/dist/runtime/langstr.test.js +8 -8
  101. package/dist/runtime/link.test.d.ts +3 -0
  102. package/dist/runtime/link.test.js +61 -0
  103. package/dist/runtime/mod.cjs +25 -0
  104. package/dist/runtime/mod.d.cts +6 -0
  105. package/dist/runtime/mod.js +10 -10
  106. package/dist/runtime/multibase/multibase.test.js +8 -8
  107. package/dist/runtime/url.test.js +5 -5
  108. package/dist/runtime-C58AJWSv.cjs +4 -0
  109. package/dist/runtime-DPYEDf-o.js +4 -0
  110. package/dist/{send-BcaNFUhd.js → send-svmMjAUr.js} +2 -2
  111. package/dist/sig/http.test.js +13 -13
  112. package/dist/sig/key.test.js +11 -11
  113. package/dist/sig/ld.test.js +10 -10
  114. package/dist/sig/mod.cjs +30 -0
  115. package/dist/sig/mod.d.cts +8 -0
  116. package/dist/sig/mod.js +10 -10
  117. package/dist/sig/owner.test.js +12 -12
  118. package/dist/sig/proof.test.js +12 -12
  119. package/dist/sig-ByHXzqUi.cjs +4 -0
  120. package/dist/sig-Cj3tk-ig.js +4 -0
  121. package/dist/testing/docloader.test.js +8 -8
  122. package/dist/testing/mod.js +3 -3
  123. package/dist/{testing-CakwOL23.js → testing-y9ueu9Aj.js} +2 -2
  124. package/dist/{transformers-Dna8Fg7k.js → transformers-BFT6d7J5.js} +3 -3
  125. package/dist/transformers-CoBS-oFG.cjs +116 -0
  126. package/dist/{type-BKY_LVaq.js → type-9o78PXlX.js} +381 -201
  127. package/dist/{types-zVT9nODh.js → types-DTCqX5HE.js} +5 -10
  128. package/dist/types-K5btoOl6.cjs +315 -0
  129. package/dist/vocab/actor.test.js +10 -10
  130. package/dist/vocab/lookup.test.js +9 -9
  131. package/dist/vocab/mod.cjs +87 -0
  132. package/dist/vocab/mod.d.cts +6 -0
  133. package/dist/vocab/mod.js +7 -7
  134. package/dist/vocab/type.test.js +3 -3
  135. package/dist/vocab/vocab.test.js +45 -10
  136. package/dist/vocab-CJ0jQMQV.cjs +282 -0
  137. package/dist/{vocab-ClXayeh5.js → vocab-C_Pm3NG3.js} +6 -6
  138. package/dist/vocab-DJTYMqyU.d.cts +14632 -0
  139. package/dist/webfinger/handler.test.js +23 -22
  140. package/dist/webfinger/lookup.test.js +9 -9
  141. package/dist/webfinger/mod.cjs +9 -0
  142. package/dist/webfinger/mod.d.cts +4 -0
  143. package/dist/webfinger/mod.js +6 -6
  144. package/dist/webfinger-BjOEdFPs.cjs +4 -0
  145. package/dist/webfinger-De_bU0iE.js +4 -0
  146. package/dist/x/cfworkers.cjs +100 -0
  147. package/dist/x/cfworkers.d.cts +59 -0
  148. package/dist/x/cfworkers.js +3 -3
  149. package/dist/x/cfworkers.test.js +8 -8
  150. package/dist/x/hono.cjs +61 -0
  151. package/dist/x/hono.d.cts +54 -0
  152. package/dist/x/hono.d.ts +1 -1
  153. package/dist/x/hono.js +3 -3
  154. package/dist/x/sveltekit.cjs +69 -0
  155. package/dist/x/sveltekit.d.cts +46 -0
  156. package/dist/x/sveltekit.d.ts +1 -1
  157. package/dist/x/sveltekit.js +3 -3
  158. package/package.json +68 -13
  159. package/dist/compat-Bb5myD13.js +0 -4
  160. package/dist/key-BLStGL0R.js +0 -10
  161. package/dist/middleware-D2diREI8.js +0 -17
  162. package/dist/middleware-D5PCuUVh.js +0 -25
  163. package/dist/nodeinfo-CyEbLjHs.js +0 -4
  164. package/dist/runtime-BSkOVUWM.js +0 -4
  165. package/dist/sig-BXJO--F9.js +0 -4
  166. package/dist/webfinger-C3GIyXIg.js +0 -4
  167. /package/dist/{assert_is_error-B035L3om.js → assert_is_error-BPGph1Jx.js} +0 -0
  168. /package/dist/{assert_not_equals-C80BG-_5.js → assert_not_equals-f3m3epl3.js} +0 -0
  169. /package/dist/{denokv-jZ0Z2h0M.js → denokv-Bv33Xxea.js} +0 -0
  170. /package/dist/{retry-CfF8Gn4d.js → retry-D4GJ670a.js} +0 -0
  171. /package/dist/{std__assert-DWivtrGR.js → std__assert-X-_kMxKM.js} +0 -0
@@ -0,0 +1,219 @@
1
+ import { KvKey, KvStore } from "./kv-63Cil1MD.cjs";
2
+
3
+ //#region src/runtime/docloader.d.ts
4
+ /**
5
+ * A remote JSON-LD document and its context fetched by
6
+ * a {@link DocumentLoader}.
7
+ */
8
+ interface RemoteDocument {
9
+ /**
10
+ * The URL of the context document.
11
+ */
12
+ contextUrl: string | null;
13
+ /**
14
+ * The fetched JSON-LD document.
15
+ */
16
+ document: unknown;
17
+ /**
18
+ * The URL of the fetched document.
19
+ */
20
+ documentUrl: string;
21
+ }
22
+ /**
23
+ * Options for {@link DocumentLoader}.
24
+ * @since 1.8.0
25
+ */
26
+ interface DocumentLoaderOptions {
27
+ /**
28
+ * An `AbortSignal` for cancellation.
29
+ * @since 1.8.0
30
+ */
31
+ signal?: AbortSignal;
32
+ }
33
+ /**
34
+ * A JSON-LD document loader that fetches documents from the Web.
35
+ * @param url The URL of the document to load.
36
+ * @param options The options for the document loader.
37
+ * @returns The loaded remote document.
38
+ */
39
+ type DocumentLoader = (url: string, options?: DocumentLoaderOptions) => Promise<RemoteDocument>;
40
+ /**
41
+ * A factory function that creates a {@link DocumentLoader} with options.
42
+ * @param options The options for the document loader.
43
+ * @returns The document loader.
44
+ * @since 1.4.0
45
+ */
46
+ type DocumentLoaderFactory = (options?: DocumentLoaderFactoryOptions) => DocumentLoader;
47
+ /**
48
+ * Options for {@link DocumentLoaderFactory}.
49
+ * @see {@link DocumentLoaderFactory}
50
+ * @see {@link AuthenticatedDocumentLoaderFactory}
51
+ * @since 1.4.0
52
+ */
53
+ interface DocumentLoaderFactoryOptions {
54
+ /**
55
+ * Whether to allow fetching private network addresses.
56
+ * Turned off by default.
57
+ * @default `false``
58
+ */
59
+ allowPrivateAddress?: boolean;
60
+ /**
61
+ * Options for making `User-Agent` string.
62
+ * If a string is given, it is used as the `User-Agent` header value.
63
+ * If an object is given, it is passed to {@link getUserAgent} function.
64
+ */
65
+ userAgent?: GetUserAgentOptions | string;
66
+ }
67
+ /**
68
+ * A factory function that creates an authenticated {@link DocumentLoader} for
69
+ * a given identity. This is used for fetching documents that require
70
+ * authentication.
71
+ * @param identity The identity to create the document loader for.
72
+ * The actor's key pair.
73
+ * @param options The options for the document loader.
74
+ * @returns The authenticated document loader.
75
+ * @since 0.4.0
76
+ */
77
+ type AuthenticatedDocumentLoaderFactory = (identity: {
78
+ keyId: URL;
79
+ privateKey: CryptoKey;
80
+ }, options?: DocumentLoaderFactoryOptions) => DocumentLoader;
81
+ /**
82
+ * Error thrown when fetching a JSON-LD document failed.
83
+ */
84
+ declare class FetchError extends Error {
85
+ /**
86
+ * The URL that failed to fetch.
87
+ */
88
+ url: URL;
89
+ /**
90
+ * Constructs a new `FetchError`.
91
+ *
92
+ * @param url The URL that failed to fetch.
93
+ * @param message Error message.
94
+ */
95
+ constructor(url: URL | string, message?: string);
96
+ }
97
+ /**
98
+ * Options for creating a request.
99
+ * @internal
100
+ */
101
+
102
+ /**
103
+ * Options for {@link getDocumentLoader}.
104
+ * @since 1.3.0
105
+ */
106
+ interface GetDocumentLoaderOptions extends DocumentLoaderFactoryOptions {
107
+ /**
108
+ * Whether to preload the frequently used contexts.
109
+ */
110
+ skipPreloadedContexts?: boolean;
111
+ }
112
+ /**
113
+ * Creates a JSON-LD document loader that utilizes the browser's `fetch` API.
114
+ *
115
+ * The created loader preloads the below frequently used contexts by default
116
+ * (unless `options.ignorePreloadedContexts` is set to `true`):
117
+ *
118
+ * - <https://www.w3.org/ns/activitystreams>
119
+ * - <https://w3id.org/security/v1>
120
+ * - <https://w3id.org/security/data-integrity/v1>
121
+ * - <https://www.w3.org/ns/did/v1>
122
+ * - <https://w3id.org/security/multikey/v1>
123
+ * - <https://purl.archive.org/socialweb/webfinger>
124
+ * - <http://schema.org/>
125
+ * @param options Options for the document loader.
126
+ * @returns The document loader.
127
+ * @since 1.3.0
128
+ */
129
+ declare function getDocumentLoader({
130
+ allowPrivateAddress,
131
+ skipPreloadedContexts,
132
+ userAgent
133
+ }?: GetDocumentLoaderOptions): DocumentLoader;
134
+ /**
135
+ * A JSON-LD document loader that utilizes the browser's `fetch` API.
136
+ *
137
+ * This loader preloads the below frequently used contexts:
138
+ *
139
+ * - <https://www.w3.org/ns/activitystreams>
140
+ * - <https://w3id.org/security/v1>
141
+ * - <https://w3id.org/security/data-integrity/v1>
142
+ * - <https://www.w3.org/ns/did/v1>
143
+ * - <https://w3id.org/security/multikey/v1>
144
+ * - <https://purl.archive.org/socialweb/webfinger>
145
+ * - <http://schema.org/>
146
+ * @param url The URL of the document to load.
147
+ * @param allowPrivateAddress Whether to allow fetching private network
148
+ * addresses. Turned off by default.
149
+ * @returns The remote document.
150
+ * @deprecated Use {@link getDocumentLoader} instead.
151
+ */
152
+ declare function fetchDocumentLoader(url: string, allowPrivateAddress?: boolean): Promise<RemoteDocument>;
153
+ declare function fetchDocumentLoader(url: string, options?: DocumentLoaderOptions): Promise<RemoteDocument>;
154
+ /**
155
+ * The parameters for {@link kvCache} function.
156
+ */
157
+ interface KvCacheParameters {
158
+ /**
159
+ * The document loader to decorate with a cache.
160
+ */
161
+ loader: DocumentLoader;
162
+ /**
163
+ * The key–value store to use for backing the cache.
164
+ */
165
+ kv: KvStore;
166
+ /**
167
+ * The key prefix to use for namespacing the cache.
168
+ * `["_fedify", "remoteDocument"]` by default.
169
+ */
170
+ prefix?: KvKey;
171
+ /**
172
+ * The per-URL cache rules in the array of `[urlPattern, duration]` pairs
173
+ * where `urlPattern` is either a string, a {@link URL}, or
174
+ * a {@link URLPattern} and `duration` is a {@link Temporal.Duration}.
175
+ * The `duration` is allowed to be at most 30 days.
176
+ *
177
+ * By default, 5 minutes for all URLs.
178
+ */
179
+ rules?: [string | URL | URLPattern, Temporal.Duration][];
180
+ }
181
+ /**
182
+ * Decorates a {@link DocumentLoader} with a cache backed by a {@link Deno.Kv}.
183
+ * @param parameters The parameters for the cache.
184
+ * @returns The decorated document loader which is cache-enabled.
185
+ */
186
+ declare function kvCache({
187
+ loader,
188
+ kv,
189
+ prefix,
190
+ rules
191
+ }: KvCacheParameters): DocumentLoader;
192
+ /**
193
+ * Options for making `User-Agent` string.
194
+ * @see {@link getUserAgent}
195
+ * @since 1.3.0
196
+ */
197
+ interface GetUserAgentOptions {
198
+ /**
199
+ * An optional software name and version, e.g., `"Hollo/1.0.0"`.
200
+ */
201
+ software?: string | null;
202
+ /**
203
+ * An optional URL to append to the user agent string.
204
+ * Usually the URL of the ActivityPub instance.
205
+ */
206
+ url?: string | URL | null;
207
+ }
208
+ /**
209
+ * Gets the user agent string for the given application and URL.
210
+ * @param options The options for making the user agent string.
211
+ * @returns The user agent string.
212
+ * @since 1.3.0
213
+ */
214
+ declare function getUserAgent({
215
+ software,
216
+ url
217
+ }?: GetUserAgentOptions): string;
218
+ //#endregion
219
+ export { AuthenticatedDocumentLoaderFactory, DocumentLoader, DocumentLoaderFactory, DocumentLoaderFactoryOptions, FetchError, GetDocumentLoaderOptions, GetUserAgentOptions, KvCacheParameters, RemoteDocument, fetchDocumentLoader, getDocumentLoader, getUserAgent, kvCache };
@@ -1,16 +1,15 @@
1
1
 
2
- import { Temporal } from "@js-temporal/polyfill";
3
- import { URLPattern } from "urlpattern-polyfill";
4
-
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+
5
5
  import { getLogger } from "@logtape/logtape";
6
- import { HTTPHeaderLink } from "@hugoalh/http-header-link";
7
6
  import process from "node:process";
8
7
  import { lookup } from "node:dns/promises";
9
8
  import { isIP } from "node:net";
10
9
 
11
10
  //#region deno.json
12
11
  var name = "@fedify/fedify";
13
- var version = "2.0.0-pr.433.1601+360b8a26";
12
+ var version = "2.0.0-pr.434.1659+7c115883";
14
13
  var license = "MIT";
15
14
  var exports = {
16
15
  ".": "./src/mod.ts",
@@ -30,7 +29,6 @@ var exports = {
30
29
  };
31
30
  var imports = {
32
31
  "@cfworker/json-schema": "npm:@cfworker/json-schema@^4.1.1",
33
- "@hugoalh/http-header-link": "jsr:@hugoalh/http-header-link@^1.0.2",
34
32
  "@multiformats/base-x": "npm:@multiformats/base-x@^4.0.1",
35
33
  "@opentelemetry/api": "npm:@opentelemetry/api@^1.9.0",
36
34
  "@opentelemetry/semantic-conventions": "npm:@opentelemetry/semantic-conventions@^1.27.0",
@@ -4277,6 +4275,188 @@ const preloadedContexts = {
4277
4275
  };
4278
4276
  var contexts_default = preloadedContexts;
4279
4277
 
4278
+ //#endregion
4279
+ //#region src/runtime/link.ts
4280
+ const parametersNeedLowerCase = ["rel", "type"];
4281
+ const regexpLinkWhitespace = /[\n\r\s\t]/;
4282
+ function validateURI(uri) {
4283
+ if (uri.includes("\n") || regexpLinkWhitespace.test(uri)) throw new SyntaxError(`\`${uri}\` is not a valid URI!`);
4284
+ }
4285
+ function* parseLinkFromString(input) {
4286
+ const inputFmt = input.replaceAll("\xA0", "").replaceAll("", "");
4287
+ for (let cursor = 0; cursor < inputFmt.length; cursor += 1) {
4288
+ while (regexpLinkWhitespace.test(inputFmt.charAt(cursor))) cursor += 1;
4289
+ if (inputFmt.charAt(cursor) !== "<") throw new SyntaxError(`Unexpected character \`${inputFmt.charAt(cursor)}\` at position ${cursor}; Expect character \`<\`!`);
4290
+ cursor += 1;
4291
+ const cursorEndUri = inputFmt.indexOf(">", cursor);
4292
+ if (cursorEndUri === -1) throw new SyntaxError(`Missing end of URI delimiter character \`>\` after position ${cursor}!`);
4293
+ if (cursorEndUri === cursor) throw new SyntaxError(`Missing URI at position ${cursor}!`);
4294
+ const uriSlice = inputFmt.slice(cursor, cursorEndUri);
4295
+ validateURI(uriSlice);
4296
+ const uri = decodeURI(uriSlice);
4297
+ const parameters = {};
4298
+ cursor = cursorEndUri + 1;
4299
+ while (regexpLinkWhitespace.test(inputFmt.charAt(cursor))) cursor += 1;
4300
+ if (cursor === inputFmt.length || inputFmt.charAt(cursor) === ",") {
4301
+ yield [uri, parameters];
4302
+ continue;
4303
+ }
4304
+ if (inputFmt.charAt(cursor) !== ";") throw new SyntaxError(`Unexpected character \`${inputFmt.charAt(cursor)}\` at position ${cursor}; Expect character \`;\`!`);
4305
+ cursor += 1;
4306
+ while (cursor < inputFmt.length) {
4307
+ while (regexpLinkWhitespace.test(inputFmt.charAt(cursor))) cursor += 1;
4308
+ const parameterKey = inputFmt.slice(cursor).match(/^[\w-]+\*?/)?.[0].toLowerCase();
4309
+ if (typeof parameterKey === "undefined") throw new SyntaxError(`Unexpected character \`${inputFmt.charAt(cursor)}\` at position ${cursor}; Expect a valid parameter key!`);
4310
+ cursor += parameterKey.length;
4311
+ while (regexpLinkWhitespace.test(inputFmt.charAt(cursor))) cursor += 1;
4312
+ if (cursor === inputFmt.length || inputFmt.charAt(cursor) === ",") {
4313
+ parameters[parameterKey] = "";
4314
+ break;
4315
+ }
4316
+ if (inputFmt.charAt(cursor) === ";") {
4317
+ parameters[parameterKey] = "";
4318
+ cursor += 1;
4319
+ continue;
4320
+ }
4321
+ if (inputFmt.charAt(cursor) !== "=") throw new SyntaxError(`Unexpected character \`${inputFmt.charAt(cursor)}\` at position ${cursor}; Expect character \`=\`!`);
4322
+ cursor += 1;
4323
+ while (regexpLinkWhitespace.test(inputFmt.charAt(cursor))) cursor += 1;
4324
+ let parameterValue = "";
4325
+ if (inputFmt.charAt(cursor) === "\"") {
4326
+ cursor += 1;
4327
+ while (cursor < inputFmt.length) {
4328
+ if (inputFmt.charAt(cursor) === "\"") {
4329
+ cursor += 1;
4330
+ break;
4331
+ }
4332
+ if (inputFmt.charAt(cursor) === "\\") cursor += 1;
4333
+ parameterValue += inputFmt.charAt(cursor);
4334
+ cursor += 1;
4335
+ }
4336
+ } else {
4337
+ const cursorDiffParameterValue = inputFmt.slice(cursor).search(/[\s;,]/);
4338
+ if (cursorDiffParameterValue === -1) {
4339
+ parameterValue += inputFmt.slice(cursor);
4340
+ cursor += parameterValue.length;
4341
+ } else {
4342
+ parameterValue += inputFmt.slice(cursor, cursorDiffParameterValue);
4343
+ cursor += cursorDiffParameterValue;
4344
+ }
4345
+ }
4346
+ parameters[parameterKey] = parametersNeedLowerCase.includes(parameterKey) ? parameterValue.toLowerCase() : parameterValue;
4347
+ while (regexpLinkWhitespace.test(inputFmt.charAt(cursor))) cursor += 1;
4348
+ if (cursor === inputFmt.length || inputFmt.charAt(cursor) === ",") break;
4349
+ if (inputFmt.charAt(cursor) === ";") {
4350
+ cursor += 1;
4351
+ continue;
4352
+ }
4353
+ throw new SyntaxError(`Unexpected character \`${inputFmt.charAt(cursor)}\` at position ${cursor}; Expect character \`,\`, character \`;\`, or end of the string!`);
4354
+ }
4355
+ yield [uri, parameters];
4356
+ }
4357
+ }
4358
+ /**
4359
+ * Handle the HTTP header `Link` according to the specification RFC 8288.
4360
+ */
4361
+ var HttpHeaderLink = class HttpHeaderLink {
4362
+ get [Symbol.toStringTag]() {
4363
+ return "HTTPHeaderLink";
4364
+ }
4365
+ #entries = [];
4366
+ /**
4367
+ * Handle the HTTP header `Link` according to the specification RFC 8288.
4368
+ * @param {...(string | Headers | HttpHeaderLink | HttpHeaderLinkEntry[] | Response)} inputs Input.
4369
+ */
4370
+ constructor(...inputs) {
4371
+ if (inputs.length > 0) this.add(...inputs);
4372
+ }
4373
+ /**
4374
+ * Add entries.
4375
+ * @param {...(string | Headers | HttpHeaderLink | HttpHeaderLinkEntry[] | Response)} inputs Input.
4376
+ * @returns {this}
4377
+ */
4378
+ add(...inputs) {
4379
+ for (const input of inputs) if (input instanceof HttpHeaderLink) this.#entries.push(...structuredClone(input.#entries));
4380
+ else if (Array.isArray(input)) this.#entries.push(...input.map(([uri, parameters]) => {
4381
+ validateURI(uri);
4382
+ Object.entries(parameters).forEach(([key, value]) => {
4383
+ if (key !== key.toLowerCase() || !/^[\w-]+\*?$/.test(key)) throw new SyntaxError(`\`${key}\` is not a valid parameter key!`);
4384
+ if (parametersNeedLowerCase.includes(key) && value !== value.toLowerCase()) throw new SyntaxError(`\`${value}\` is not a valid parameter value!`);
4385
+ });
4386
+ return [uri, structuredClone(parameters)];
4387
+ }));
4388
+ else for (const entry of parseLinkFromString((input instanceof Headers || input instanceof Response ? (input instanceof Headers ? input : input.headers).get("Link") : input) ?? "")) this.#entries.push(entry);
4389
+ return this;
4390
+ }
4391
+ /**
4392
+ * Return all of the entries.
4393
+ * @returns {HttpHeaderLinkEntry[]} Entries.
4394
+ */
4395
+ entries() {
4396
+ return structuredClone(this.#entries);
4397
+ }
4398
+ /**
4399
+ * Get entries by parameter.
4400
+ * @param {string} key Key of the parameter.
4401
+ * @param {string} value Value of the parameter.
4402
+ * @returns {HttpHeaderLinkEntry[]} Entries which match the parameter.
4403
+ */
4404
+ getByParameter(key, value) {
4405
+ if (key !== key.toLowerCase()) throw new SyntaxError(`\`${key}\` is not a valid parameter key!`);
4406
+ if (key === "rel") return this.getByRel(value);
4407
+ return structuredClone(this.#entries.filter((entry) => {
4408
+ return entry[1][key] === value;
4409
+ }));
4410
+ }
4411
+ /**
4412
+ * Get entries by parameter `rel`.
4413
+ * @param {string} value Value of the parameter `rel`.
4414
+ * @returns {HttpHeaderLinkEntry[]} Entries which match the parameter.
4415
+ */
4416
+ getByRel(value) {
4417
+ if (value !== value.toLowerCase()) throw new SyntaxError(`\`${value}\` is not a valid parameter \`rel\` value!`);
4418
+ return structuredClone(this.#entries.filter((entity) => {
4419
+ return entity[1].rel?.toLowerCase() === value;
4420
+ }));
4421
+ }
4422
+ /**
4423
+ * Whether have entries that match parameter.
4424
+ * @param {string} key Key of the parameter.
4425
+ * @param {string} value Value of the parameter.
4426
+ * @returns {boolean} Determine result.
4427
+ */
4428
+ hasParameter(key, value) {
4429
+ return this.getByParameter(key, value).length > 0;
4430
+ }
4431
+ /**
4432
+ * Stringify entries.
4433
+ * @returns {string} Stringified entries.
4434
+ */
4435
+ toString() {
4436
+ return this.#entries.map(([uri, parameters]) => {
4437
+ return [`<${encodeURI(uri)}>`, ...Object.entries(parameters).map(([key, value]) => {
4438
+ return value.length > 0 ? `${key}="${value.replaceAll("\"", "\\\"")}"` : key;
4439
+ })].join("; ");
4440
+ }).join(", ");
4441
+ }
4442
+ /**
4443
+ * Parse the HTTP header `Link` according to the specification RFC 8288.
4444
+ * @param {...(string | Headers | HttpHeaderLink | HttpHeaderLinkEntry[] | Response)} inputs Input.
4445
+ * @returns {HttpHeaderLink}
4446
+ */
4447
+ static parse(...inputs) {
4448
+ return new this(...inputs);
4449
+ }
4450
+ /**
4451
+ * Stringify as the HTTP header `Link` according to the specification RFC 8288.
4452
+ * @param {...(string | Headers | HttpHeaderLink | HttpHeaderLinkEntry[] | Response)} inputs Input.
4453
+ * @returns {string}
4454
+ */
4455
+ static stringify(...inputs) {
4456
+ return new this(...inputs).toString();
4457
+ }
4458
+ };
4459
+
4280
4460
  //#endregion
4281
4461
  //#region src/runtime/url.ts
4282
4462
  var UrlError = class extends Error {
@@ -4418,9 +4598,9 @@ async function getRemoteDocument(url, response, fetch$1) {
4418
4598
  if (linkHeader != null) {
4419
4599
  let link;
4420
4600
  try {
4421
- link = new HTTPHeaderLink(linkHeader);
4601
+ link = new HttpHeaderLink(linkHeader);
4422
4602
  } catch (e) {
4423
- if (e instanceof SyntaxError) link = new HTTPHeaderLink();
4603
+ if (e instanceof SyntaxError) link = new HttpHeaderLink();
4424
4604
  else throw e;
4425
4605
  }
4426
4606
  if (jsonLd) {