nlcurl 0.7.0 → 0.8.0

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 (350) hide show
  1. package/README.md +143 -140
  2. package/dist/cache/groups.d.ts +75 -0
  3. package/dist/cache/groups.d.ts.map +1 -0
  4. package/dist/cache/groups.js +118 -0
  5. package/dist/cache/groups.js.map +1 -0
  6. package/dist/cache/no-vary-search.d.ts +33 -0
  7. package/dist/cache/no-vary-search.d.ts.map +1 -0
  8. package/dist/cache/no-vary-search.js +148 -0
  9. package/dist/cache/no-vary-search.js.map +1 -0
  10. package/dist/cache/range.d.ts +120 -0
  11. package/dist/cache/range.d.ts.map +1 -0
  12. package/dist/cache/range.js +193 -0
  13. package/dist/cache/range.js.map +1 -0
  14. package/dist/cache/store.d.ts +58 -36
  15. package/dist/cache/store.d.ts.map +1 -1
  16. package/dist/cache/store.js +58 -46
  17. package/dist/cache/store.js.map +1 -1
  18. package/dist/cache/types.d.ts +7 -39
  19. package/dist/cache/types.d.ts.map +1 -1
  20. package/dist/cli/args.d.ts +4 -37
  21. package/dist/cli/args.d.ts.map +1 -1
  22. package/dist/cli/args.js +3 -4
  23. package/dist/cli/args.js.map +1 -1
  24. package/dist/cli/index.d.ts +0 -5
  25. package/dist/cli/index.d.ts.map +1 -1
  26. package/dist/cli/index.js +1 -6
  27. package/dist/cli/index.js.map +1 -1
  28. package/dist/cli/output.d.ts +14 -20
  29. package/dist/cli/output.d.ts.map +1 -1
  30. package/dist/cli/output.js +14 -20
  31. package/dist/cli/output.js.map +1 -1
  32. package/dist/cookies/jar.d.ts +30 -39
  33. package/dist/cookies/jar.d.ts.map +1 -1
  34. package/dist/cookies/jar.js +27 -37
  35. package/dist/cookies/jar.js.map +1 -1
  36. package/dist/cookies/parser.d.ts +13 -17
  37. package/dist/cookies/parser.d.ts.map +1 -1
  38. package/dist/cookies/parser.js +17 -14
  39. package/dist/cookies/parser.js.map +1 -1
  40. package/dist/cookies/psl-data.d.ts +1 -1
  41. package/dist/cookies/psl-data.js +1 -1
  42. package/dist/cookies/public-suffix.d.ts +5 -27
  43. package/dist/cookies/public-suffix.d.ts.map +1 -1
  44. package/dist/cookies/public-suffix.js +5 -37
  45. package/dist/cookies/public-suffix.js.map +1 -1
  46. package/dist/core/auth.d.ts +30 -0
  47. package/dist/core/auth.d.ts.map +1 -0
  48. package/dist/core/auth.js +34 -0
  49. package/dist/core/auth.js.map +1 -0
  50. package/dist/core/client.d.ts +28 -40
  51. package/dist/core/client.d.ts.map +1 -1
  52. package/dist/core/client.js +31 -41
  53. package/dist/core/client.js.map +1 -1
  54. package/dist/core/errors.d.ts +64 -88
  55. package/dist/core/errors.d.ts.map +1 -1
  56. package/dist/core/errors.js +64 -88
  57. package/dist/core/errors.js.map +1 -1
  58. package/dist/core/request.d.ts +23 -111
  59. package/dist/core/request.d.ts.map +1 -1
  60. package/dist/core/response.d.ts +49 -66
  61. package/dist/core/response.d.ts.map +1 -1
  62. package/dist/core/response.js +45 -59
  63. package/dist/core/response.js.map +1 -1
  64. package/dist/core/session.d.ts +66 -78
  65. package/dist/core/session.d.ts.map +1 -1
  66. package/dist/core/session.js +105 -76
  67. package/dist/core/session.js.map +1 -1
  68. package/dist/core/validation.d.ts +44 -43
  69. package/dist/core/validation.d.ts.map +1 -1
  70. package/dist/core/validation.js +44 -56
  71. package/dist/core/validation.js.map +1 -1
  72. package/dist/dns/cache.d.ts +59 -0
  73. package/dist/dns/cache.d.ts.map +1 -0
  74. package/dist/dns/cache.js +99 -0
  75. package/dist/dns/cache.js.map +1 -0
  76. package/dist/dns/codec.d.ts +20 -18
  77. package/dist/dns/codec.d.ts.map +1 -1
  78. package/dist/dns/codec.js +20 -36
  79. package/dist/dns/codec.js.map +1 -1
  80. package/dist/dns/doh-resolver.d.ts +17 -31
  81. package/dist/dns/doh-resolver.d.ts.map +1 -1
  82. package/dist/dns/doh-resolver.js +46 -47
  83. package/dist/dns/doh-resolver.js.map +1 -1
  84. package/dist/dns/dot-resolver.d.ts +89 -0
  85. package/dist/dns/dot-resolver.d.ts.map +1 -0
  86. package/dist/dns/dot-resolver.js +158 -0
  87. package/dist/dns/dot-resolver.js.map +1 -0
  88. package/dist/dns/https-rr.d.ts +19 -30
  89. package/dist/dns/https-rr.d.ts.map +1 -1
  90. package/dist/dns/https-rr.js +22 -40
  91. package/dist/dns/https-rr.js.map +1 -1
  92. package/dist/dns/types.d.ts +31 -59
  93. package/dist/dns/types.d.ts.map +1 -1
  94. package/dist/dns/types.js +3 -14
  95. package/dist/dns/types.js.map +1 -1
  96. package/dist/fingerprints/akamai.d.ts +3 -11
  97. package/dist/fingerprints/akamai.d.ts.map +1 -1
  98. package/dist/fingerprints/akamai.js +3 -11
  99. package/dist/fingerprints/akamai.js.map +1 -1
  100. package/dist/fingerprints/database.d.ts +6 -14
  101. package/dist/fingerprints/database.d.ts.map +1 -1
  102. package/dist/fingerprints/database.js +6 -14
  103. package/dist/fingerprints/database.js.map +1 -1
  104. package/dist/fingerprints/extensions.d.ts +56 -71
  105. package/dist/fingerprints/extensions.d.ts.map +1 -1
  106. package/dist/fingerprints/extensions.js +58 -71
  107. package/dist/fingerprints/extensions.js.map +1 -1
  108. package/dist/fingerprints/ja3.d.ts +12 -30
  109. package/dist/fingerprints/ja3.d.ts.map +1 -1
  110. package/dist/fingerprints/ja3.js +12 -30
  111. package/dist/fingerprints/ja3.js.map +1 -1
  112. package/dist/fingerprints/ja4.d.ts +18 -0
  113. package/dist/fingerprints/ja4.d.ts.map +1 -0
  114. package/dist/fingerprints/ja4.js +83 -0
  115. package/dist/fingerprints/ja4.js.map +1 -0
  116. package/dist/fingerprints/profiles/chrome.d.ts +18 -21
  117. package/dist/fingerprints/profiles/chrome.d.ts.map +1 -1
  118. package/dist/fingerprints/profiles/chrome.js +35 -31
  119. package/dist/fingerprints/profiles/chrome.js.map +1 -1
  120. package/dist/fingerprints/profiles/edge.d.ts +7 -10
  121. package/dist/fingerprints/profiles/edge.d.ts.map +1 -1
  122. package/dist/fingerprints/profiles/edge.js +7 -10
  123. package/dist/fingerprints/profiles/edge.js.map +1 -1
  124. package/dist/fingerprints/profiles/firefox.d.ts +8 -11
  125. package/dist/fingerprints/profiles/firefox.d.ts.map +1 -1
  126. package/dist/fingerprints/profiles/firefox.js +8 -11
  127. package/dist/fingerprints/profiles/firefox.js.map +1 -1
  128. package/dist/fingerprints/profiles/safari.d.ts +11 -14
  129. package/dist/fingerprints/profiles/safari.d.ts.map +1 -1
  130. package/dist/fingerprints/profiles/safari.js +11 -14
  131. package/dist/fingerprints/profiles/safari.js.map +1 -1
  132. package/dist/fingerprints/profiles/tor.d.ts +5 -8
  133. package/dist/fingerprints/profiles/tor.d.ts.map +1 -1
  134. package/dist/fingerprints/profiles/tor.js +5 -8
  135. package/dist/fingerprints/profiles/tor.js.map +1 -1
  136. package/dist/fingerprints/types.d.ts +42 -73
  137. package/dist/fingerprints/types.d.ts.map +1 -1
  138. package/dist/hsts/store.d.ts +19 -21
  139. package/dist/hsts/store.d.ts.map +1 -1
  140. package/dist/hsts/store.js +20 -28
  141. package/dist/hsts/store.js.map +1 -1
  142. package/dist/hsts/types.d.ts +10 -14
  143. package/dist/hsts/types.d.ts.map +1 -1
  144. package/dist/http/alt-svc.d.ts +31 -49
  145. package/dist/http/alt-svc.d.ts.map +1 -1
  146. package/dist/http/alt-svc.js +21 -55
  147. package/dist/http/alt-svc.js.map +1 -1
  148. package/dist/http/early-hints.d.ts +23 -0
  149. package/dist/http/early-hints.d.ts.map +1 -0
  150. package/dist/http/early-hints.js +33 -0
  151. package/dist/http/early-hints.js.map +1 -0
  152. package/dist/http/form-data.d.ts +17 -35
  153. package/dist/http/form-data.d.ts.map +1 -1
  154. package/dist/http/form-data.js +12 -34
  155. package/dist/http/form-data.js.map +1 -1
  156. package/dist/http/h1/client.d.ts +14 -26
  157. package/dist/http/h1/client.d.ts.map +1 -1
  158. package/dist/http/h1/client.js +14 -23
  159. package/dist/http/h1/client.js.map +1 -1
  160. package/dist/http/h1/encoder.d.ts +10 -17
  161. package/dist/http/h1/encoder.d.ts.map +1 -1
  162. package/dist/http/h1/encoder.js +10 -17
  163. package/dist/http/h1/encoder.js.map +1 -1
  164. package/dist/http/h1/parser.d.ts +22 -59
  165. package/dist/http/h1/parser.d.ts.map +1 -1
  166. package/dist/http/h1/parser.js +15 -47
  167. package/dist/http/h1/parser.js.map +1 -1
  168. package/dist/http/h2/client.d.ts +18 -59
  169. package/dist/http/h2/client.d.ts.map +1 -1
  170. package/dist/http/h2/client.js +29 -64
  171. package/dist/http/h2/client.js.map +1 -1
  172. package/dist/http/h2/frames.d.ts +53 -84
  173. package/dist/http/h2/frames.d.ts.map +1 -1
  174. package/dist/http/h2/frames.js +48 -76
  175. package/dist/http/h2/frames.js.map +1 -1
  176. package/dist/http/h2/hpack.d.ts +16 -35
  177. package/dist/http/h2/hpack.d.ts.map +1 -1
  178. package/dist/http/h2/hpack.js +16 -35
  179. package/dist/http/h2/hpack.js.map +1 -1
  180. package/dist/http/h3/detection.d.ts +5 -7
  181. package/dist/http/h3/detection.d.ts.map +1 -1
  182. package/dist/http/h3/detection.js +5 -23
  183. package/dist/http/h3/detection.js.map +1 -1
  184. package/dist/http/negotiator.d.ts +25 -38
  185. package/dist/http/negotiator.d.ts.map +1 -1
  186. package/dist/http/negotiator.js +16 -28
  187. package/dist/http/negotiator.js.map +1 -1
  188. package/dist/http/pool.d.ts +32 -62
  189. package/dist/http/pool.d.ts.map +1 -1
  190. package/dist/http/pool.js +22 -41
  191. package/dist/http/pool.js.map +1 -1
  192. package/dist/http/resumable-upload.d.ts +76 -0
  193. package/dist/http/resumable-upload.d.ts.map +1 -0
  194. package/dist/http/resumable-upload.js +104 -0
  195. package/dist/http/resumable-upload.js.map +1 -0
  196. package/dist/http/trailers.d.ts +29 -0
  197. package/dist/http/trailers.d.ts.map +1 -0
  198. package/dist/http/trailers.js +57 -0
  199. package/dist/http/trailers.js.map +1 -0
  200. package/dist/index.d.ts +21 -8
  201. package/dist/index.d.ts.map +1 -1
  202. package/dist/index.js +21 -2
  203. package/dist/index.js.map +1 -1
  204. package/dist/middleware/interceptor.d.ts +13 -32
  205. package/dist/middleware/interceptor.d.ts.map +1 -1
  206. package/dist/middleware/interceptor.js +11 -16
  207. package/dist/middleware/interceptor.js.map +1 -1
  208. package/dist/middleware/rate-limiter.d.ts +8 -17
  209. package/dist/middleware/rate-limiter.d.ts.map +1 -1
  210. package/dist/middleware/rate-limiter.js +11 -12
  211. package/dist/middleware/rate-limiter.js.map +1 -1
  212. package/dist/middleware/retry-after.d.ts +15 -0
  213. package/dist/middleware/retry-after.d.ts.map +1 -0
  214. package/dist/middleware/retry-after.js +36 -0
  215. package/dist/middleware/retry-after.js.map +1 -0
  216. package/dist/middleware/retry.d.ts +9 -18
  217. package/dist/middleware/retry.d.ts.map +1 -1
  218. package/dist/middleware/retry.js +12 -9
  219. package/dist/middleware/retry.js.map +1 -1
  220. package/dist/proxy/auth.d.ts +73 -0
  221. package/dist/proxy/auth.d.ts.map +1 -0
  222. package/dist/proxy/auth.js +128 -0
  223. package/dist/proxy/auth.js.map +1 -0
  224. package/dist/proxy/env-proxy.d.ts +5 -15
  225. package/dist/proxy/env-proxy.d.ts.map +1 -1
  226. package/dist/proxy/env-proxy.js +5 -23
  227. package/dist/proxy/env-proxy.js.map +1 -1
  228. package/dist/proxy/http-proxy.d.ts +12 -19
  229. package/dist/proxy/http-proxy.d.ts.map +1 -1
  230. package/dist/proxy/http-proxy.js +5 -8
  231. package/dist/proxy/http-proxy.js.map +1 -1
  232. package/dist/proxy/socks.d.ts +13 -20
  233. package/dist/proxy/socks.d.ts.map +1 -1
  234. package/dist/proxy/socks.js +5 -8
  235. package/dist/proxy/socks.js.map +1 -1
  236. package/dist/sse/parser.d.ts +14 -37
  237. package/dist/sse/parser.d.ts.map +1 -1
  238. package/dist/sse/parser.js +14 -28
  239. package/dist/sse/parser.js.map +1 -1
  240. package/dist/tls/constants.d.ts +15 -74
  241. package/dist/tls/constants.d.ts.map +1 -1
  242. package/dist/tls/constants.js +15 -74
  243. package/dist/tls/constants.js.map +1 -1
  244. package/dist/tls/ct.d.ts +78 -0
  245. package/dist/tls/ct.d.ts.map +1 -0
  246. package/dist/tls/ct.js +175 -0
  247. package/dist/tls/ct.js.map +1 -0
  248. package/dist/tls/early-data.d.ts +45 -0
  249. package/dist/tls/early-data.d.ts.map +1 -0
  250. package/dist/tls/early-data.js +46 -0
  251. package/dist/tls/early-data.js.map +1 -0
  252. package/dist/tls/ech.d.ts +68 -85
  253. package/dist/tls/ech.d.ts.map +1 -1
  254. package/dist/tls/ech.js +54 -102
  255. package/dist/tls/ech.js.map +1 -1
  256. package/dist/tls/keylog.d.ts +34 -0
  257. package/dist/tls/keylog.d.ts.map +1 -0
  258. package/dist/tls/keylog.js +64 -0
  259. package/dist/tls/keylog.js.map +1 -0
  260. package/dist/tls/node-engine.d.ts +10 -17
  261. package/dist/tls/node-engine.d.ts.map +1 -1
  262. package/dist/tls/node-engine.js +20 -18
  263. package/dist/tls/node-engine.js.map +1 -1
  264. package/dist/tls/ocsp.d.ts +55 -0
  265. package/dist/tls/ocsp.d.ts.map +1 -0
  266. package/dist/tls/ocsp.js +131 -0
  267. package/dist/tls/ocsp.js.map +1 -0
  268. package/dist/tls/pin-verification.d.ts +5 -4
  269. package/dist/tls/pin-verification.d.ts.map +1 -1
  270. package/dist/tls/pin-verification.js +5 -11
  271. package/dist/tls/pin-verification.js.map +1 -1
  272. package/dist/tls/session-cache.d.ts +27 -39
  273. package/dist/tls/session-cache.d.ts.map +1 -1
  274. package/dist/tls/session-cache.js +20 -24
  275. package/dist/tls/session-cache.js.map +1 -1
  276. package/dist/tls/stealth/client-hello.d.ts +25 -44
  277. package/dist/tls/stealth/client-hello.d.ts.map +1 -1
  278. package/dist/tls/stealth/client-hello.js +17 -28
  279. package/dist/tls/stealth/client-hello.js.map +1 -1
  280. package/dist/tls/stealth/engine.d.ts +5 -15
  281. package/dist/tls/stealth/engine.d.ts.map +1 -1
  282. package/dist/tls/stealth/engine.js +11 -17
  283. package/dist/tls/stealth/engine.js.map +1 -1
  284. package/dist/tls/stealth/handshake.d.ts +21 -31
  285. package/dist/tls/stealth/handshake.d.ts.map +1 -1
  286. package/dist/tls/stealth/handshake.js +15 -43
  287. package/dist/tls/stealth/handshake.js.map +1 -1
  288. package/dist/tls/stealth/key-schedule.d.ts +59 -86
  289. package/dist/tls/stealth/key-schedule.d.ts.map +1 -1
  290. package/dist/tls/stealth/key-schedule.js +46 -58
  291. package/dist/tls/stealth/key-schedule.js.map +1 -1
  292. package/dist/tls/stealth/record-layer.d.ts +52 -75
  293. package/dist/tls/stealth/record-layer.d.ts.map +1 -1
  294. package/dist/tls/stealth/record-layer.js +47 -63
  295. package/dist/tls/stealth/record-layer.js.map +1 -1
  296. package/dist/tls/stealth/tls12-handshake.d.ts +16 -0
  297. package/dist/tls/stealth/tls12-handshake.d.ts.map +1 -1
  298. package/dist/tls/stealth/tls12-handshake.js +8 -0
  299. package/dist/tls/stealth/tls12-handshake.js.map +1 -1
  300. package/dist/tls/types.d.ts +42 -60
  301. package/dist/tls/types.d.ts.map +1 -1
  302. package/dist/utils/buffer-reader.d.ts +26 -81
  303. package/dist/utils/buffer-reader.d.ts.map +1 -1
  304. package/dist/utils/buffer-reader.js +26 -81
  305. package/dist/utils/buffer-reader.js.map +1 -1
  306. package/dist/utils/buffer-writer.d.ts +30 -66
  307. package/dist/utils/buffer-writer.d.ts.map +1 -1
  308. package/dist/utils/buffer-writer.js +30 -66
  309. package/dist/utils/buffer-writer.js.map +1 -1
  310. package/dist/utils/compression.d.ts +18 -0
  311. package/dist/utils/compression.d.ts.map +1 -0
  312. package/dist/utils/compression.js +34 -0
  313. package/dist/utils/compression.js.map +1 -0
  314. package/dist/utils/dictionary-transport.d.ts +97 -0
  315. package/dist/utils/dictionary-transport.d.ts.map +1 -0
  316. package/dist/utils/dictionary-transport.js +171 -0
  317. package/dist/utils/dictionary-transport.js.map +1 -0
  318. package/dist/utils/encoding.d.ts +12 -30
  319. package/dist/utils/encoding.d.ts.map +1 -1
  320. package/dist/utils/encoding.js +15 -46
  321. package/dist/utils/encoding.js.map +1 -1
  322. package/dist/utils/happy-eyeballs.d.ts +18 -8
  323. package/dist/utils/happy-eyeballs.d.ts.map +1 -1
  324. package/dist/utils/happy-eyeballs.js +19 -27
  325. package/dist/utils/happy-eyeballs.js.map +1 -1
  326. package/dist/utils/logger.d.ts +54 -81
  327. package/dist/utils/logger.d.ts.map +1 -1
  328. package/dist/utils/logger.js +92 -64
  329. package/dist/utils/logger.js.map +1 -1
  330. package/dist/utils/tcp-fast-open.d.ts +30 -0
  331. package/dist/utils/tcp-fast-open.d.ts.map +1 -0
  332. package/dist/utils/tcp-fast-open.js +36 -0
  333. package/dist/utils/tcp-fast-open.js.map +1 -0
  334. package/dist/utils/url.d.ts +18 -25
  335. package/dist/utils/url.d.ts.map +1 -1
  336. package/dist/utils/url.js +18 -25
  337. package/dist/utils/url.js.map +1 -1
  338. package/dist/ws/client.d.ts +33 -53
  339. package/dist/ws/client.d.ts.map +1 -1
  340. package/dist/ws/client.js +29 -30
  341. package/dist/ws/client.js.map +1 -1
  342. package/dist/ws/frame.d.ts +24 -41
  343. package/dist/ws/frame.d.ts.map +1 -1
  344. package/dist/ws/frame.js +18 -33
  345. package/dist/ws/frame.js.map +1 -1
  346. package/dist/ws/permessage-deflate.d.ts +23 -28
  347. package/dist/ws/permessage-deflate.d.ts.map +1 -1
  348. package/dist/ws/permessage-deflate.js +18 -26
  349. package/dist/ws/permessage-deflate.js.map +1 -1
  350. package/package.json +62 -62
@@ -6,13 +6,11 @@ import type { CacheConfig, CacheMode } from "../cache/types.js";
6
6
  import type { HSTSConfig } from "../hsts/types.js";
7
7
  import type { DNSConfig } from "../dns/types.js";
8
8
  import type { ECHOptions } from "../tls/ech.js";
9
+ import type { AuthConfig } from "./auth.js";
10
+ import type { EarlyHintsCallback } from "../http/early-hints.js";
11
+ import type { RequestEncoding } from "../utils/compression.js";
9
12
  /**
10
- * Progress event data emitted during upload or download.
11
- *
12
- * @typedef {Object} ProgressEvent
13
- * @property {number} bytes - Bytes transferred so far.
14
- * @property {number} totalBytes - Total bytes expected (`0` if unknown).
15
- * @property {number} percent - Completion percentage (`0`–`100`), or `0` if total is unknown.
13
+ * Describes the progress of an upload or download operation.
16
14
  */
17
15
  export interface ProgressEvent {
18
16
  bytes: number;
@@ -20,28 +18,18 @@ export interface ProgressEvent {
20
18
  percent: number;
21
19
  }
22
20
  /**
23
- * Callback invoked during data transfer to report progress.
21
+ * Callback invoked during upload or download progress.
24
22
  *
25
23
  * @callback ProgressCallback
26
- * @param {ProgressEvent} event - Current transfer progress.
24
+ * @param {ProgressEvent} event - The current progress snapshot.
27
25
  */
28
26
  export type ProgressCallback = (event: ProgressEvent) => void;
29
27
  /**
30
- * Union of all HTTP method strings accepted by the library.
31
- *
32
- * @typedef {'GET'|'POST'|'PUT'|'PATCH'|'DELETE'|'HEAD'|'OPTIONS'} HttpMethod
28
+ * Supported HTTP request methods.
33
29
  */
34
- export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
30
+ export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS" | "QUERY";
35
31
  /**
36
- * Granular timing measurements recorded during a single request, in
37
- * milliseconds elapsed from request initiation.
38
- *
39
- * @typedef {Object} RequestTimings
40
- * @property {number} dns - Time spent resolving the hostname via DNS.
41
- * @property {number} connect - Time spent establishing the TCP connection.
42
- * @property {number} tls - Time spent completing the TLS handshake.
43
- * @property {number} firstByte - Time from connection open to the first response byte received.
44
- * @property {number} total - Total wall-clock time for the entire request.
32
+ * Timing measurements for each phase of a request lifecycle, in milliseconds.
45
33
  */
46
34
  export interface RequestTimings {
47
35
  dns: number;
@@ -51,14 +39,7 @@ export interface RequestTimings {
51
39
  total: number;
52
40
  }
53
41
  /**
54
- * Per-phase timeout limits for a single request, in milliseconds. Omitting
55
- * a field means no limit is applied for that phase.
56
- *
57
- * @typedef {Object} TimeoutConfig
58
- * @property {number} [connect] - Maximum milliseconds to establish the TCP connection.
59
- * @property {number} [tls] - Maximum milliseconds to complete the TLS handshake.
60
- * @property {number} [response] - Maximum milliseconds to receive the first response byte.
61
- * @property {number} [total] - Maximum total milliseconds for the whole request.
42
+ * Per-phase timeout thresholds for a request, in milliseconds.
62
43
  */
63
44
  export interface TimeoutConfig {
64
45
  connect?: number;
@@ -67,42 +48,12 @@ export interface TimeoutConfig {
67
48
  total?: number;
68
49
  }
69
50
  /**
70
- * Accepted body types for an outgoing request. Arrays, plain objects, and
71
- * plain strings are serialized automatically; raw `Buffer`s and
72
- * `URLSearchParams` are used verbatim.
73
- *
74
- * @typedef {string|Buffer|URLSearchParams|Record<string,unknown>|ReadableStream<Uint8Array>|null} RequestBody
51
+ * Acceptable request body types for outgoing HTTP requests.
75
52
  */
76
53
  export type RequestBody = string | Buffer | URLSearchParams | Record<string, unknown> | ReadableStream<Uint8Array> | FormData | null;
77
54
  /**
78
- * Describes a single HTTP request. All options at the request level override
79
- * any matching session-level defaults set on {@link NLcURLSessionConfig}.
80
- *
81
- * @typedef {Object} NLcURLRequest
82
- * @property {string} url - Absolute or relative URL to request.
83
- * @property {HttpMethod} [method='GET'] - HTTP method.
84
- * @property {Record<string,string>} [headers] - Request headers to merge with session defaults.
85
- * @property {RequestBody} [body] - Request body payload.
86
- * @property {number|TimeoutConfig} [timeout] - Timeout in ms (flat) or per-phase config object.
87
- * @property {AbortSignal} [signal] - Signal used to cancel the request early.
88
- * @property {string} [impersonate] - Browser profile name (e.g. `"chrome136"`).
89
- * @property {string} [ja3] - Custom JA3 fingerprint string override.
90
- * @property {string} [akamai] - Custom Akamai HTTP/2 fingerprint override.
91
- * @property {boolean} [stealth] - Use the custom stealth TLS engine.
92
- * @property {boolean} [followRedirects=true] - Follow HTTP redirects automatically.
93
- * @property {number} [maxRedirects=20] - Maximum number of redirects to follow.
94
- * @property {boolean} [insecure] - Skip TLS certificate verification.
95
- * @property {string} [proxy] - Proxy URL (`http://`, `socks4://`, `socks5://`).
96
- * @property {[string,string]} [proxyAuth] - Proxy credentials as `[username, password]`.
97
- * @property {'1.1'|'2'} [httpVersion] - Force a specific HTTP protocol version.
98
- * @property {string} [baseURL] - Base URL prepended to relative `url` values.
99
- * @property {Record<string,string|number|boolean>} [params] - Query parameters appended to the URL.
100
- * @property {boolean|string} [cookieJar] - Enable a per-request cookie jar.
101
- * @property {string} [acceptEncoding] - Override the `Accept-Encoding` header value.
102
- * @property {string[]} [headerOrder] - Explicit header ordering for fingerprinting.
103
- * @property {4|6} [dnsFamily] - Force IPv4 (`4`) or IPv6 (`6`) DNS resolution.
104
- * @property {boolean} [stream] - Return a streaming response body.
105
- * @property {Logger} [logger] - Logger instance for request-scoped diagnostics.
55
+ * Full request descriptor for a single HTTP request, including URL, method,
56
+ * headers, body, TLS fingerprinting, proxy, caching, and timeout options.
106
57
  */
107
58
  export interface NLcURLRequest {
108
59
  url: string;
@@ -130,29 +81,21 @@ export interface NLcURLRequest {
130
81
  stream?: boolean;
131
82
  logger?: Logger;
132
83
  tls?: TLSOptions;
133
- /** DNS-over-HTTPS configuration for this request. Overrides session-level DNS config. */
134
84
  dns?: DNSConfig;
135
- /** Encrypted Client Hello (ECH) options for this request. */
136
85
  ech?: ECHOptions;
137
86
  onUploadProgress?: ProgressCallback;
138
87
  onDownloadProgress?: ProgressCallback;
139
88
  throwOnError?: boolean;
140
- /** HTTP cache mode for this request. Overrides session-level cache config. */
141
89
  cache?: CacheMode;
142
- /**
143
- * Range header value for partial content requests (RFC 9110 §14).
144
- * Example: `"bytes=0-499"` or `"bytes=500-999"` or `"bytes=-500"`.
145
- */
146
90
  range?: string;
91
+ auth?: AuthConfig;
92
+ onEarlyHints?: EarlyHintsCallback;
93
+ expect100Continue?: boolean;
94
+ compressBody?: RequestEncoding;
95
+ methodOverride?: "QUERY";
147
96
  }
148
97
  /**
149
- * Server-Sent Event parsed from an SSE stream (W3C EventSource specification).
150
- *
151
- * @typedef {Object} ServerSentEvent
152
- * @property {string} event - Event type (defaults to `"message"`).
153
- * @property {string} data - Event data payload.
154
- * @property {string} id - Last event ID.
155
- * @property {number|undefined} retry - Reconnection time in ms suggested by the server.
98
+ * Represents a single server-sent event from an SSE stream.
156
99
  */
157
100
  export interface ServerSentEvent {
158
101
  event: string;
@@ -161,14 +104,7 @@ export interface ServerSentEvent {
161
104
  retry?: number;
162
105
  }
163
106
  /**
164
- * Configuration for automatic request retry with backoff.
165
- *
166
- * @typedef {Object} RetryConfig
167
- * @property {number} count - Maximum number of retry attempts after the initial request.
168
- * @property {number} delay - Base delay in milliseconds between attempts.
169
- * @property {'linear'|'exponential'} backoff - Strategy for increasing the delay on repeated failures.
170
- * @property {number} jitter - Maximum random jitter in milliseconds added to each delay.
171
- * @property {Function} [retryOn] - Optional predicate; return `true` to allow a retry.
107
+ * Configuration for automatic request retry behavior.
172
108
  */
173
109
  export interface RetryConfig {
174
110
  count: number;
@@ -178,28 +114,7 @@ export interface RetryConfig {
178
114
  retryOn?: (error: Error | null, statusCode?: number) => boolean;
179
115
  }
180
116
  /**
181
- * Session-level defaults applied to every request issued through an
182
- * {@link NLcURLSession}. Individual request options always take precedence.
183
- *
184
- * @typedef {Object} NLcURLSessionConfig
185
- * @property {string} [baseURL] - Base URL prepended to relative request URLs.
186
- * @property {Record<string,string>} [headers] - Headers merged into every request.
187
- * @property {number|TimeoutConfig} [timeout] - Default timeout applied to all requests.
188
- * @property {string} [impersonate] - Default browser profile for fingerprinting.
189
- * @property {string} [ja3] - Default JA3 fingerprint string.
190
- * @property {string} [akamai] - Default Akamai HTTP/2 fingerprint.
191
- * @property {boolean} [stealth] - Use the stealth TLS engine by default.
192
- * @property {string} [proxy] - Default proxy URL.
193
- * @property {[string,string]} [proxyAuth] - Default proxy credentials.
194
- * @property {boolean} [followRedirects=true] - Follow redirects by default.
195
- * @property {number} [maxRedirects=20] - Default maximum redirect count.
196
- * @property {boolean} [insecure] - Skip TLS verification by default.
197
- * @property {'1.1'|'2'} [httpVersion] - Force an HTTP protocol version for all requests.
198
- * @property {boolean|string} [cookieJar] - Persistent cookie jar for the session.
199
- * @property {Partial<RetryConfig>} [retry] - Automatic retry configuration.
200
- * @property {string} [acceptEncoding] - Default `Accept-Encoding` header value.
201
- * @property {4|6} [dnsFamily] - Force IPv4 or IPv6 for DNS resolution.
202
- * @property {Logger} [logger] - Logger instance for session-scoped diagnostics.
117
+ * Session-level configuration shared across all requests in a session.
203
118
  */
204
119
  export interface NLcURLSessionConfig {
205
120
  baseURL?: string;
@@ -224,15 +139,12 @@ export interface NLcURLSessionConfig {
224
139
  throwOnError?: boolean;
225
140
  onUploadProgress?: ProgressCallback;
226
141
  onDownloadProgress?: ProgressCallback;
227
- /** HTTP cache configuration for the session (RFC 9111). */
228
142
  cacheConfig?: CacheConfig;
229
- /** HSTS configuration for the session (RFC 6797). */
230
143
  hsts?: HSTSConfig;
231
- /** DNS-over-HTTPS configuration for the session (RFC 8484). */
232
144
  dns?: DNSConfig;
233
- /** Encrypted Client Hello (ECH) configuration for the session (draft-ietf-tls-esni). */
234
145
  ech?: ECHOptions;
235
- /** Enable Alt-Svc (RFC 7838) for automatic HTTP/3 discovery. @default true */
236
146
  altSvc?: boolean;
147
+ auth?: AuthConfig;
148
+ compressBody?: RequestEncoding;
237
149
  }
238
150
  //# sourceMappingURL=request.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/core/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EA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AAG,GAAG,CAAC;IAChC,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;IACzC,KAAK,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,UAAU,CAAC;IAEjB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,kBAAkB,CAAC,EAAE,gBAAgB,CAAC;IAEtC,WAAW,CAAC,EAAE,WAAW,CAAC;IAE1B,IAAI,CAAC,EAAE,UAAU,CAAC;IAElB,GAAG,CAAC,EAAE,SAAS,CAAC;IAEhB,GAAG,CAAC,EAAE,UAAU,CAAC;IAEjB,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,IAAI,CAAC,EAAE,UAAU,CAAC;IAElB,YAAY,CAAC,EAAE,eAAe,CAAC;CAChC"}
@@ -1,67 +1,53 @@
1
1
  import type { RequestTimings, HttpMethod } from "./request.js";
2
2
  import type { Readable } from "node:stream";
3
3
  /**
4
- * Metadata about the originating request that produced a response.
5
- *
6
- * @typedef {Object} ResponseMeta
7
- * @property {string} url - The final URL after all redirects.
8
- * @property {HttpMethod} method - The HTTP method used for the request.
9
- * @property {Record<string,string>} headers - The request headers that were sent.
10
- * @property {string} [command] - An optional cURL-equivalent command string for debugging.
4
+ * Metadata about the request that produced a given response.
11
5
  */
12
6
  export interface ResponseMeta {
13
7
  url: string;
14
8
  method: HttpMethod;
15
9
  headers: Record<string, string>;
16
10
  command?: string;
11
+ tlsVersion?: string;
12
+ tlsCipher?: string;
13
+ alpnProtocol?: string;
17
14
  }
18
15
  /**
19
- * Represents the complete HTTP response from a successful request. Provides
20
- * convenience accessors for common content-type parsing, streaming, and
21
- * header inspection.
16
+ * Encapsulates an HTTP response with status, headers, body, timing data,
17
+ * and convenience accessors for common header values and body parsing.
22
18
  *
23
- * @template T - Expected shape of the JSON-decoded body when calling {@link NLcURLResponse.json}.
19
+ * @class
20
+ * @template T - The expected JSON body type.
24
21
  */
25
22
  export declare class NLcURLResponse<T = unknown> {
26
- /** HTTP status code (e.g. `200`, `404`). */
23
+ /** The HTTP status code. */
27
24
  readonly status: number;
28
- /** HTTP status text (e.g. `"OK"`, `"Not Found"`). */
25
+ /** The HTTP reason phrase. */
29
26
  readonly statusText: string;
30
- /** Normalized, lowercase response headers. Duplicate values are joined by `, `. */
27
+ /** Response headers as a case-insensitive key-value map. */
31
28
  readonly headers: Record<string, string>;
32
- /** All response header name-value pairs exactly as received, in transmission order. */
29
+ /** Raw header pairs preserving original casing and duplicates. */
33
30
  readonly rawHeaders: Array<[string, string]>;
34
- /** Fully buffered response body. Empty when the response was opened in streaming mode. */
31
+ /** The full response body as a Buffer. */
35
32
  readonly rawBody: Buffer;
36
- /** Readable stream of the response body, or `null` for buffered responses. */
33
+ /** A readable stream for streaming responses, or `null` for buffered responses. */
37
34
  readonly body: Readable | null;
38
- /** HTTP protocol version string (e.g. `"HTTP/1.1"`, `"HTTP/2.0"`). */
35
+ /** The negotiated HTTP version (e.g. "1.1", "2"). */
39
36
  readonly httpVersion: string;
40
- /** Final URL of the response after any redirects. */
37
+ /** The final URL after any redirects. */
41
38
  readonly url: string;
42
- /** Number of redirects followed before this response was received. */
39
+ /** The number of redirects followed to reach this response. */
43
40
  readonly redirectCount: number;
44
- /** Granular timing measurements for each phase of the request lifecycle. */
41
+ /** Timing measurements for each request phase. */
45
42
  readonly timings: RequestTimings;
46
43
  /** Metadata about the originating request. */
47
44
  readonly request: ResponseMeta;
48
45
  private _json;
49
46
  private _text;
50
47
  /**
51
- * Creates a new NLcURLResponse instance.
48
+ * Creates a new NLcURLResponse from the provided initialization fields.
52
49
  *
53
- * @param {Object} init - Response initialization data.
54
- * @param {number} init.status - HTTP status code.
55
- * @param {string} init.statusText - HTTP status text.
56
- * @param {Record<string,string>} init.headers - Normalized response headers.
57
- * @param {Array<[string,string]>} [init.rawHeaders] - Raw header pairs; defaults to entries of `headers`.
58
- * @param {Buffer} init.rawBody - Fully buffered response body.
59
- * @param {Readable|null} [init.body] - Streaming body, or `null`.
60
- * @param {string} init.httpVersion - Protocol version string.
61
- * @param {string} init.url - Final URL after redirects.
62
- * @param {number} init.redirectCount - Number of redirects followed.
63
- * @param {RequestTimings} init.timings - Lifecycle timing measurements.
64
- * @param {ResponseMeta} init.request - Originating request metadata.
50
+ * @param {Object} init - Response initialization fields.
65
51
  */
66
52
  constructor(init: {
67
53
  status: number;
@@ -77,77 +63,74 @@ export declare class NLcURLResponse<T = unknown> {
77
63
  request: ResponseMeta;
78
64
  });
79
65
  /**
80
- * Returns `true` when the HTTP status code is in the 200–299 (successful)
81
- * range, `false` otherwise.
66
+ * Returns `true` if the response status is in the 2xx range.
82
67
  *
83
68
  * @returns {boolean} Whether the response indicates success.
84
69
  */
85
70
  get ok(): boolean;
86
71
  /**
87
- * Decodes the raw body as a UTF-8 string and returns it. The result is
88
- * memoized after the first call.
72
+ * Decodes the raw body as a UTF-8 string. Throws if the response is streaming.
89
73
  *
90
- * @returns {string} The response body decoded as UTF-8.
91
- * @throws {Error} If the response was opened in streaming mode (`stream: true`).
74
+ * @returns {string} The response body as text.
75
+ * @throws {Error} If the response is a streaming response.
92
76
  */
93
77
  text(): string;
94
78
  /**
95
- * Parses the raw body as JSON and returns the decoded value. The result is
96
- * memoized after the first call.
79
+ * Parses the response body as JSON. Throws if the response is streaming.
97
80
  *
98
- * @template R - Expected type of the decoded JSON value; defaults to `T`.
99
- * @returns {R} The JSON-decoded response body.
100
- * @throws {Error} If the response was opened in streaming mode (`stream: true`).
81
+ * @template R - The expected parsed type.
82
+ * @returns {R} The parsed JSON value.
83
+ * @throws {Error} If the response is a streaming response.
101
84
  * @throws {SyntaxError} If the body is not valid JSON.
102
- *
103
- * @example
104
- * const data = response.json<{ id: number; name: string }>();
105
- * console.log(data.id);
106
85
  */
107
86
  json<R = T>(): R;
108
87
  /**
109
- * Returns the `Content-Length` as a number. Falls back to the buffer byte
110
- * length when the header is absent or unparseable.
88
+ * Returns the Content-Length header value, or the raw body length as a fallback.
111
89
  *
112
90
  * @returns {number} The content length in bytes.
113
91
  */
114
92
  get contentLength(): number;
115
93
  /**
116
- * Returns the value of the `Content-Type` response header, or an empty
117
- * string when the header is absent.
94
+ * Returns the Content-Type header value.
118
95
  *
119
- * @returns {string} The `Content-Type` header value.
96
+ * @returns {string} The content type, or an empty string if absent.
120
97
  */
121
98
  get contentType(): string;
122
99
  /**
123
- * Returns the `ETag` response header value, or `undefined` when absent.
100
+ * Returns the ETag header value, if present.
101
+ *
102
+ * @returns {string|undefined} The entity tag.
124
103
  */
125
104
  get etag(): string | undefined;
126
105
  /**
127
- * Returns the `Last-Modified` response header value, or `undefined` when absent.
106
+ * Returns the Last-Modified header value, if present.
107
+ *
108
+ * @returns {string|undefined} The last modified date string.
128
109
  */
129
110
  get lastModified(): string | undefined;
130
111
  /**
131
- * Returns the `Cache-Control` response header value, or `undefined` when absent.
112
+ * Returns the Cache-Control header value, if present.
113
+ *
114
+ * @returns {string|undefined} The cache control directive string.
132
115
  */
133
116
  get cacheControl(): string | undefined;
134
117
  /**
135
- * Returns the `Content-Range` response header value, or `undefined` when absent.
136
- * Present on 206 Partial Content responses (RFC 9110 §14.4).
118
+ * Returns the Content-Range header value, if present.
119
+ *
120
+ * @returns {string|undefined} The content range descriptor.
137
121
  */
138
122
  get contentRange(): string | undefined;
139
123
  /**
140
- * Returns the `Accept-Ranges` response header value, or `undefined` when absent.
141
- * Indicates whether the server supports range requests (RFC 9110 §14.3).
124
+ * Returns the Accept-Ranges header value, if present.
125
+ *
126
+ * @returns {string|undefined} The accepted range unit.
142
127
  */
143
128
  get acceptRanges(): string | undefined;
144
129
  /**
145
- * Returns all values for a response header, in transmission order,
146
- * supporting multi-value headers such as `Set-Cookie` which are joined
147
- * when accessed through `headers`.
130
+ * Retrieves all values for a given header name from the raw headers array.
148
131
  *
149
- * @param {string} name - The case-insensitive header name to look up.
150
- * @returns {string[]} All header values for the given name, or an empty array.
132
+ * @param {string} name - The header name (case-insensitive).
133
+ * @returns {string[]} All values for the specified header.
151
134
  */
152
135
  getAll(name: string): string[];
153
136
  }
@@ -1 +1 @@
1
- {"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/core/response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,UAAU,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;GAMG;AACH,qBAAa,cAAc,CAAC,CAAC,GAAG,OAAO;IACrC,4CAA4C;IAC5C,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,qDAAqD;IACrD,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,mFAAmF;IACnF,SAAgB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChD,uFAAuF;IACvF,SAAgB,UAAU,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACpD,0FAA0F;IAC1F,SAAgB,OAAO,EAAE,MAAM,CAAC;IAChC,8EAA8E;IAC9E,SAAgB,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;IACtC,sEAAsE;IACtE,SAAgB,WAAW,EAAE,MAAM,CAAC;IACpC,qDAAqD;IACrD,SAAgB,GAAG,EAAE,MAAM,CAAC;IAC5B,sEAAsE;IACtE,SAAgB,aAAa,EAAE,MAAM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EAAE;CAI/B"}
@@ -1,50 +1,39 @@
1
1
  /**
2
- * Represents the complete HTTP response from a successful request. Provides
3
- * convenience accessors for common content-type parsing, streaming, and
4
- * header inspection.
2
+ * Encapsulates an HTTP response with status, headers, body, timing data,
3
+ * and convenience accessors for common header values and body parsing.
5
4
  *
6
- * @template T - Expected shape of the JSON-decoded body when calling {@link NLcURLResponse.json}.
5
+ * @class
6
+ * @template T - The expected JSON body type.
7
7
  */
8
8
  export class NLcURLResponse {
9
- /** HTTP status code (e.g. `200`, `404`). */
9
+ /** The HTTP status code. */
10
10
  status;
11
- /** HTTP status text (e.g. `"OK"`, `"Not Found"`). */
11
+ /** The HTTP reason phrase. */
12
12
  statusText;
13
- /** Normalized, lowercase response headers. Duplicate values are joined by `, `. */
13
+ /** Response headers as a case-insensitive key-value map. */
14
14
  headers;
15
- /** All response header name-value pairs exactly as received, in transmission order. */
15
+ /** Raw header pairs preserving original casing and duplicates. */
16
16
  rawHeaders;
17
- /** Fully buffered response body. Empty when the response was opened in streaming mode. */
17
+ /** The full response body as a Buffer. */
18
18
  rawBody;
19
- /** Readable stream of the response body, or `null` for buffered responses. */
19
+ /** A readable stream for streaming responses, or `null` for buffered responses. */
20
20
  body;
21
- /** HTTP protocol version string (e.g. `"HTTP/1.1"`, `"HTTP/2.0"`). */
21
+ /** The negotiated HTTP version (e.g. "1.1", "2"). */
22
22
  httpVersion;
23
- /** Final URL of the response after any redirects. */
23
+ /** The final URL after any redirects. */
24
24
  url;
25
- /** Number of redirects followed before this response was received. */
25
+ /** The number of redirects followed to reach this response. */
26
26
  redirectCount;
27
- /** Granular timing measurements for each phase of the request lifecycle. */
27
+ /** Timing measurements for each request phase. */
28
28
  timings;
29
29
  /** Metadata about the originating request. */
30
30
  request;
31
31
  _json;
32
32
  _text;
33
33
  /**
34
- * Creates a new NLcURLResponse instance.
34
+ * Creates a new NLcURLResponse from the provided initialization fields.
35
35
  *
36
- * @param {Object} init - Response initialization data.
37
- * @param {number} init.status - HTTP status code.
38
- * @param {string} init.statusText - HTTP status text.
39
- * @param {Record<string,string>} init.headers - Normalized response headers.
40
- * @param {Array<[string,string]>} [init.rawHeaders] - Raw header pairs; defaults to entries of `headers`.
41
- * @param {Buffer} init.rawBody - Fully buffered response body.
42
- * @param {Readable|null} [init.body] - Streaming body, or `null`.
43
- * @param {string} init.httpVersion - Protocol version string.
44
- * @param {string} init.url - Final URL after redirects.
45
- * @param {number} init.redirectCount - Number of redirects followed.
46
- * @param {RequestTimings} init.timings - Lifecycle timing measurements.
47
- * @param {ResponseMeta} init.request - Originating request metadata.
36
+ * @param {Object} init - Response initialization fields.
48
37
  */
49
38
  constructor(init) {
50
39
  this.status = init.status;
@@ -60,8 +49,7 @@ export class NLcURLResponse {
60
49
  this.request = init.request;
61
50
  }
62
51
  /**
63
- * Returns `true` when the HTTP status code is in the 200–299 (successful)
64
- * range, `false` otherwise.
52
+ * Returns `true` if the response status is in the 2xx range.
65
53
  *
66
54
  * @returns {boolean} Whether the response indicates success.
67
55
  */
@@ -69,11 +57,10 @@ export class NLcURLResponse {
69
57
  return this.status >= 200 && this.status < 300;
70
58
  }
71
59
  /**
72
- * Decodes the raw body as a UTF-8 string and returns it. The result is
73
- * memoized after the first call.
60
+ * Decodes the raw body as a UTF-8 string. Throws if the response is streaming.
74
61
  *
75
- * @returns {string} The response body decoded as UTF-8.
76
- * @throws {Error} If the response was opened in streaming mode (`stream: true`).
62
+ * @returns {string} The response body as text.
63
+ * @throws {Error} If the response is a streaming response.
77
64
  */
78
65
  text() {
79
66
  if (this.body) {
@@ -87,17 +74,12 @@ export class NLcURLResponse {
87
74
  return cached;
88
75
  }
89
76
  /**
90
- * Parses the raw body as JSON and returns the decoded value. The result is
91
- * memoized after the first call.
77
+ * Parses the response body as JSON. Throws if the response is streaming.
92
78
  *
93
- * @template R - Expected type of the decoded JSON value; defaults to `T`.
94
- * @returns {R} The JSON-decoded response body.
95
- * @throws {Error} If the response was opened in streaming mode (`stream: true`).
79
+ * @template R - The expected parsed type.
80
+ * @returns {R} The parsed JSON value.
81
+ * @throws {Error} If the response is a streaming response.
96
82
  * @throws {SyntaxError} If the body is not valid JSON.
97
- *
98
- * @example
99
- * const data = response.json<{ id: number; name: string }>();
100
- * console.log(data.id);
101
83
  */
102
84
  json() {
103
85
  if (this.body) {
@@ -109,8 +91,7 @@ export class NLcURLResponse {
109
91
  return this._json;
110
92
  }
111
93
  /**
112
- * Returns the `Content-Length` as a number. Falls back to the buffer byte
113
- * length when the header is absent or unparseable.
94
+ * Returns the Content-Length header value, or the raw body length as a fallback.
114
95
  *
115
96
  * @returns {number} The content length in bytes.
116
97
  */
@@ -124,53 +105,58 @@ export class NLcURLResponse {
124
105
  return this.rawBody.length;
125
106
  }
126
107
  /**
127
- * Returns the value of the `Content-Type` response header, or an empty
128
- * string when the header is absent.
108
+ * Returns the Content-Type header value.
129
109
  *
130
- * @returns {string} The `Content-Type` header value.
110
+ * @returns {string} The content type, or an empty string if absent.
131
111
  */
132
112
  get contentType() {
133
113
  return this.headers["content-type"] ?? "";
134
114
  }
135
115
  /**
136
- * Returns the `ETag` response header value, or `undefined` when absent.
116
+ * Returns the ETag header value, if present.
117
+ *
118
+ * @returns {string|undefined} The entity tag.
137
119
  */
138
120
  get etag() {
139
121
  return this.headers["etag"];
140
122
  }
141
123
  /**
142
- * Returns the `Last-Modified` response header value, or `undefined` when absent.
124
+ * Returns the Last-Modified header value, if present.
125
+ *
126
+ * @returns {string|undefined} The last modified date string.
143
127
  */
144
128
  get lastModified() {
145
129
  return this.headers["last-modified"];
146
130
  }
147
131
  /**
148
- * Returns the `Cache-Control` response header value, or `undefined` when absent.
132
+ * Returns the Cache-Control header value, if present.
133
+ *
134
+ * @returns {string|undefined} The cache control directive string.
149
135
  */
150
136
  get cacheControl() {
151
137
  return this.headers["cache-control"];
152
138
  }
153
139
  /**
154
- * Returns the `Content-Range` response header value, or `undefined` when absent.
155
- * Present on 206 Partial Content responses (RFC 9110 §14.4).
140
+ * Returns the Content-Range header value, if present.
141
+ *
142
+ * @returns {string|undefined} The content range descriptor.
156
143
  */
157
144
  get contentRange() {
158
145
  return this.headers["content-range"];
159
146
  }
160
147
  /**
161
- * Returns the `Accept-Ranges` response header value, or `undefined` when absent.
162
- * Indicates whether the server supports range requests (RFC 9110 §14.3).
148
+ * Returns the Accept-Ranges header value, if present.
149
+ *
150
+ * @returns {string|undefined} The accepted range unit.
163
151
  */
164
152
  get acceptRanges() {
165
153
  return this.headers["accept-ranges"];
166
154
  }
167
155
  /**
168
- * Returns all values for a response header, in transmission order,
169
- * supporting multi-value headers such as `Set-Cookie` which are joined
170
- * when accessed through `headers`.
156
+ * Retrieves all values for a given header name from the raw headers array.
171
157
  *
172
- * @param {string} name - The case-insensitive header name to look up.
173
- * @returns {string[]} All header values for the given name, or an empty array.
158
+ * @param {string} name - The header name (case-insensitive).
159
+ * @returns {string[]} All values for the specified header.
174
160
  */
175
161
  getAll(name) {
176
162
  const lower = name.toLowerCase();