nlcurl 0.1.0 → 0.2.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 (197) hide show
  1. package/README.md +5 -13
  2. package/dist/cli/args.d.ts +37 -5
  3. package/dist/cli/args.d.ts.map +1 -1
  4. package/dist/cli/args.js +6 -17
  5. package/dist/cli/args.js.map +1 -1
  6. package/dist/cli/index.d.ts +3 -3
  7. package/dist/cli/index.js +25 -10
  8. package/dist/cli/index.js.map +1 -1
  9. package/dist/cli/output.d.ts +24 -7
  10. package/dist/cli/output.d.ts.map +1 -1
  11. package/dist/cli/output.js +24 -12
  12. package/dist/cli/output.js.map +1 -1
  13. package/dist/cookies/jar.d.ts +45 -13
  14. package/dist/cookies/jar.d.ts.map +1 -1
  15. package/dist/cookies/jar.js +88 -29
  16. package/dist/cookies/jar.js.map +1 -1
  17. package/dist/cookies/parser.d.ts +25 -3
  18. package/dist/cookies/parser.d.ts.map +1 -1
  19. package/dist/cookies/parser.js +12 -7
  20. package/dist/cookies/parser.js.map +1 -1
  21. package/dist/core/client.d.ts +49 -33
  22. package/dist/core/client.d.ts.map +1 -1
  23. package/dist/core/client.js +64 -38
  24. package/dist/core/client.js.map +1 -1
  25. package/dist/core/errors.d.ts +94 -6
  26. package/dist/core/errors.d.ts.map +1 -1
  27. package/dist/core/errors.js +95 -6
  28. package/dist/core/errors.js.map +1 -1
  29. package/dist/core/request.d.ts +96 -30
  30. package/dist/core/request.d.ts.map +1 -1
  31. package/dist/core/request.js +0 -3
  32. package/dist/core/request.js.map +1 -1
  33. package/dist/core/response.d.ts +92 -8
  34. package/dist/core/response.d.ts.map +1 -1
  35. package/dist/core/response.js +92 -7
  36. package/dist/core/response.js.map +1 -1
  37. package/dist/core/session.d.ts +109 -14
  38. package/dist/core/session.d.ts.map +1 -1
  39. package/dist/core/session.js +124 -46
  40. package/dist/core/session.js.map +1 -1
  41. package/dist/fingerprints/akamai.d.ts +11 -11
  42. package/dist/fingerprints/akamai.d.ts.map +1 -1
  43. package/dist/fingerprints/akamai.js +10 -14
  44. package/dist/fingerprints/akamai.js.map +1 -1
  45. package/dist/fingerprints/database.d.ts +14 -15
  46. package/dist/fingerprints/database.d.ts.map +1 -1
  47. package/dist/fingerprints/database.js +14 -19
  48. package/dist/fingerprints/database.js.map +1 -1
  49. package/dist/fingerprints/extensions.d.ts +121 -27
  50. package/dist/fingerprints/extensions.d.ts.map +1 -1
  51. package/dist/fingerprints/extensions.js +132 -49
  52. package/dist/fingerprints/extensions.js.map +1 -1
  53. package/dist/fingerprints/ja3.d.ts +34 -18
  54. package/dist/fingerprints/ja3.d.ts.map +1 -1
  55. package/dist/fingerprints/ja3.js +34 -18
  56. package/dist/fingerprints/ja3.js.map +1 -1
  57. package/dist/fingerprints/profiles/chrome.d.ts +21 -10
  58. package/dist/fingerprints/profiles/chrome.d.ts.map +1 -1
  59. package/dist/fingerprints/profiles/chrome.js +25 -22
  60. package/dist/fingerprints/profiles/chrome.js.map +1 -1
  61. package/dist/fingerprints/profiles/edge.d.ts +10 -7
  62. package/dist/fingerprints/profiles/edge.d.ts.map +1 -1
  63. package/dist/fingerprints/profiles/edge.js +10 -10
  64. package/dist/fingerprints/profiles/edge.js.map +1 -1
  65. package/dist/fingerprints/profiles/firefox.d.ts +11 -3
  66. package/dist/fingerprints/profiles/firefox.d.ts.map +1 -1
  67. package/dist/fingerprints/profiles/firefox.js +15 -14
  68. package/dist/fingerprints/profiles/firefox.js.map +1 -1
  69. package/dist/fingerprints/profiles/safari.d.ts +14 -3
  70. package/dist/fingerprints/profiles/safari.d.ts.map +1 -1
  71. package/dist/fingerprints/profiles/safari.js +16 -13
  72. package/dist/fingerprints/profiles/safari.js.map +1 -1
  73. package/dist/fingerprints/profiles/tor.d.ts +8 -7
  74. package/dist/fingerprints/profiles/tor.d.ts.map +1 -1
  75. package/dist/fingerprints/profiles/tor.js +8 -14
  76. package/dist/fingerprints/profiles/tor.js.map +1 -1
  77. package/dist/fingerprints/types.d.ts +70 -47
  78. package/dist/fingerprints/types.d.ts.map +1 -1
  79. package/dist/fingerprints/types.js +0 -7
  80. package/dist/fingerprints/types.js.map +1 -1
  81. package/dist/http/h1/client.d.ts +30 -9
  82. package/dist/http/h1/client.d.ts.map +1 -1
  83. package/dist/http/h1/client.js +152 -15
  84. package/dist/http/h1/client.js.map +1 -1
  85. package/dist/http/h1/encoder.d.ts +9 -6
  86. package/dist/http/h1/encoder.d.ts.map +1 -1
  87. package/dist/http/h1/encoder.js +8 -12
  88. package/dist/http/h1/encoder.js.map +1 -1
  89. package/dist/http/h1/parser.d.ts +68 -14
  90. package/dist/http/h1/parser.d.ts.map +1 -1
  91. package/dist/http/h1/parser.js +92 -37
  92. package/dist/http/h1/parser.js.map +1 -1
  93. package/dist/http/h2/client.d.ts +81 -14
  94. package/dist/http/h2/client.d.ts.map +1 -1
  95. package/dist/http/h2/client.js +465 -63
  96. package/dist/http/h2/client.js.map +1 -1
  97. package/dist/http/h2/frames.d.ts +103 -6
  98. package/dist/http/h2/frames.d.ts.map +1 -1
  99. package/dist/http/h2/frames.js +96 -17
  100. package/dist/http/h2/frames.js.map +1 -1
  101. package/dist/http/h2/hpack.d.ts +30 -5
  102. package/dist/http/h2/hpack.d.ts.map +1 -1
  103. package/dist/http/h2/hpack.js +39 -35
  104. package/dist/http/h2/hpack.js.map +1 -1
  105. package/dist/http/negotiator.d.ts +35 -12
  106. package/dist/http/negotiator.d.ts.map +1 -1
  107. package/dist/http/negotiator.js +89 -24
  108. package/dist/http/negotiator.js.map +1 -1
  109. package/dist/http/pool.d.ts +66 -17
  110. package/dist/http/pool.d.ts.map +1 -1
  111. package/dist/http/pool.js +47 -20
  112. package/dist/http/pool.js.map +1 -1
  113. package/dist/index.d.ts +2 -3
  114. package/dist/index.d.ts.map +1 -1
  115. package/dist/index.js +0 -13
  116. package/dist/index.js.map +1 -1
  117. package/dist/middleware/interceptor.d.ts +40 -8
  118. package/dist/middleware/interceptor.d.ts.map +1 -1
  119. package/dist/middleware/interceptor.js +28 -6
  120. package/dist/middleware/interceptor.js.map +1 -1
  121. package/dist/middleware/rate-limiter.d.ts +18 -5
  122. package/dist/middleware/rate-limiter.d.ts.map +1 -1
  123. package/dist/middleware/rate-limiter.js +12 -7
  124. package/dist/middleware/rate-limiter.js.map +1 -1
  125. package/dist/middleware/retry.d.ts +17 -5
  126. package/dist/middleware/retry.d.ts.map +1 -1
  127. package/dist/middleware/retry.js +13 -11
  128. package/dist/middleware/retry.js.map +1 -1
  129. package/dist/proxy/http-proxy.d.ts +17 -9
  130. package/dist/proxy/http-proxy.d.ts.map +1 -1
  131. package/dist/proxy/http-proxy.js +9 -13
  132. package/dist/proxy/http-proxy.js.map +1 -1
  133. package/dist/proxy/socks.d.ts +20 -9
  134. package/dist/proxy/socks.d.ts.map +1 -1
  135. package/dist/proxy/socks.js +20 -31
  136. package/dist/proxy/socks.js.map +1 -1
  137. package/dist/tls/constants.d.ts +74 -4
  138. package/dist/tls/constants.d.ts.map +1 -1
  139. package/dist/tls/constants.js +75 -21
  140. package/dist/tls/constants.js.map +1 -1
  141. package/dist/tls/node-engine.d.ts +17 -16
  142. package/dist/tls/node-engine.d.ts.map +1 -1
  143. package/dist/tls/node-engine.js +20 -27
  144. package/dist/tls/node-engine.js.map +1 -1
  145. package/dist/tls/stealth/client-hello.d.ts +32 -16
  146. package/dist/tls/stealth/client-hello.d.ts.map +1 -1
  147. package/dist/tls/stealth/client-hello.js +13 -37
  148. package/dist/tls/stealth/client-hello.js.map +1 -1
  149. package/dist/tls/stealth/engine.d.ts +18 -10
  150. package/dist/tls/stealth/engine.d.ts.map +1 -1
  151. package/dist/tls/stealth/engine.js +18 -24
  152. package/dist/tls/stealth/engine.js.map +1 -1
  153. package/dist/tls/stealth/handshake.d.ts +31 -17
  154. package/dist/tls/stealth/handshake.d.ts.map +1 -1
  155. package/dist/tls/stealth/handshake.js +173 -74
  156. package/dist/tls/stealth/handshake.js.map +1 -1
  157. package/dist/tls/stealth/key-schedule.d.ts +89 -32
  158. package/dist/tls/stealth/key-schedule.d.ts.map +1 -1
  159. package/dist/tls/stealth/key-schedule.js +62 -42
  160. package/dist/tls/stealth/key-schedule.js.map +1 -1
  161. package/dist/tls/stealth/record-layer.d.ts +76 -25
  162. package/dist/tls/stealth/record-layer.d.ts.map +1 -1
  163. package/dist/tls/stealth/record-layer.js +66 -36
  164. package/dist/tls/stealth/record-layer.js.map +1 -1
  165. package/dist/tls/types.d.ts +33 -25
  166. package/dist/tls/types.d.ts.map +1 -1
  167. package/dist/tls/types.js +0 -4
  168. package/dist/tls/types.js.map +1 -1
  169. package/dist/utils/buffer-reader.d.ts +99 -7
  170. package/dist/utils/buffer-reader.d.ts.map +1 -1
  171. package/dist/utils/buffer-reader.js +99 -7
  172. package/dist/utils/buffer-reader.js.map +1 -1
  173. package/dist/utils/buffer-writer.d.ts +99 -10
  174. package/dist/utils/buffer-writer.d.ts.map +1 -1
  175. package/dist/utils/buffer-writer.js +101 -12
  176. package/dist/utils/buffer-writer.js.map +1 -1
  177. package/dist/utils/encoding.d.ts +33 -8
  178. package/dist/utils/encoding.d.ts.map +1 -1
  179. package/dist/utils/encoding.js +58 -13
  180. package/dist/utils/encoding.js.map +1 -1
  181. package/dist/utils/logger.d.ts +61 -2
  182. package/dist/utils/logger.d.ts.map +1 -1
  183. package/dist/utils/logger.js +52 -4
  184. package/dist/utils/logger.js.map +1 -1
  185. package/dist/utils/url.d.ts +47 -7
  186. package/dist/utils/url.d.ts.map +1 -1
  187. package/dist/utils/url.js +47 -7
  188. package/dist/utils/url.js.map +1 -1
  189. package/dist/ws/client.d.ts +59 -15
  190. package/dist/ws/client.d.ts.map +1 -1
  191. package/dist/ws/client.js +34 -27
  192. package/dist/ws/client.js.map +1 -1
  193. package/dist/ws/frame.d.ts +43 -9
  194. package/dist/ws/frame.d.ts.map +1 -1
  195. package/dist/ws/frame.js +35 -19
  196. package/dist/ws/frame.js.map +1 -1
  197. package/package.json +2 -2
@@ -1,48 +1,132 @@
1
+ import type { RequestTimings, HttpMethod } from './request.js';
2
+ import type { Readable } from 'node:stream';
1
3
  /**
2
- * NLcURL response model.
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.
3
11
  */
4
- import type { RequestTimings, HttpMethod } from './request.js';
5
12
  export interface ResponseMeta {
6
13
  url: string;
7
14
  method: HttpMethod;
8
15
  headers: Record<string, string>;
9
16
  command?: string;
10
17
  }
18
+ /**
19
+ * Represents the complete HTTP response from a successful request. Provides
20
+ * convenience accessors for common content-type parsing, streaming, and
21
+ * header inspection.
22
+ *
23
+ * @template T - Expected shape of the JSON-decoded body when calling {@link NLcURLResponse.json}.
24
+ */
11
25
  export declare class NLcURLResponse<T = unknown> {
26
+ /** HTTP status code (e.g. `200`, `404`). */
12
27
  readonly status: number;
28
+ /** HTTP status text (e.g. `"OK"`, `"Not Found"`). */
13
29
  readonly statusText: string;
30
+ /** Normalized, lowercase response headers. Duplicate values are joined by `, `. */
14
31
  readonly headers: Record<string, string>;
15
- /** Raw header pairs preserving duplicates (e.g. multiple Set-Cookie). */
32
+ /** All response header name-value pairs exactly as received, in transmission order. */
16
33
  readonly rawHeaders: Array<[string, string]>;
34
+ /** Fully buffered response body. Empty when the response was opened in streaming mode. */
17
35
  readonly rawBody: Buffer;
36
+ /** Readable stream of the response body, or `null` for buffered responses. */
37
+ readonly body: Readable | null;
38
+ /** HTTP protocol version string (e.g. `"HTTP/1.1"`, `"HTTP/2.0"`). */
18
39
  readonly httpVersion: string;
40
+ /** Final URL of the response after any redirects. */
19
41
  readonly url: string;
42
+ /** Number of redirects followed before this response was received. */
20
43
  readonly redirectCount: number;
44
+ /** Granular timing measurements for each phase of the request lifecycle. */
21
45
  readonly timings: RequestTimings;
46
+ /** Metadata about the originating request. */
22
47
  readonly request: ResponseMeta;
23
48
  private _json;
24
49
  private _text;
50
+ /**
51
+ * Creates a new NLcURLResponse instance.
52
+ *
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.
65
+ */
25
66
  constructor(init: {
26
67
  status: number;
27
68
  statusText: string;
28
69
  headers: Record<string, string>;
29
70
  rawHeaders?: Array<[string, string]>;
30
71
  rawBody: Buffer;
72
+ body?: Readable | null;
31
73
  httpVersion: string;
32
74
  url: string;
33
75
  redirectCount: number;
34
76
  timings: RequestTimings;
35
77
  request: ResponseMeta;
36
78
  });
37
- /** Whether the status code is 2xx. */
79
+ /**
80
+ * Returns `true` when the HTTP status code is in the 200–299 (successful)
81
+ * range, `false` otherwise.
82
+ *
83
+ * @returns {boolean} Whether the response indicates success.
84
+ */
38
85
  get ok(): boolean;
39
- /** Decode the body as UTF-8 text. Result is cached. */
86
+ /**
87
+ * Decodes the raw body as a UTF-8 string and returns it. The result is
88
+ * memoized after the first call.
89
+ *
90
+ * @returns {string} The response body decoded as UTF-8.
91
+ * @throws {Error} If the response was opened in streaming mode (`stream: true`).
92
+ */
40
93
  text(): string;
41
- /** Parse the body as JSON. Result is cached. Throws on invalid JSON. */
94
+ /**
95
+ * Parses the raw body as JSON and returns the decoded value. The result is
96
+ * memoized after the first call.
97
+ *
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`).
101
+ * @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
+ */
42
107
  json<R = T>(): R;
43
- /** Content-Length as reported by the server, or the actual body size. */
108
+ /**
109
+ * Returns the `Content-Length` as a number. Falls back to the buffer byte
110
+ * length when the header is absent or unparseable.
111
+ *
112
+ * @returns {number} The content length in bytes.
113
+ */
44
114
  get contentLength(): number;
45
- /** Shorthand for the content-type header value. */
115
+ /**
116
+ * Returns the value of the `Content-Type` response header, or an empty
117
+ * string when the header is absent.
118
+ *
119
+ * @returns {string} The `Content-Type` header value.
120
+ */
46
121
  get contentType(): string;
122
+ /**
123
+ * Returns all values for a response header, in transmission order,
124
+ * supporting multi-value headers such as `Set-Cookie` which are joined
125
+ * when accessed through `headers`.
126
+ *
127
+ * @param {string} name - The case-insensitive header name to look up.
128
+ * @returns {string[]} All header values for the given name, or an empty array.
129
+ */
130
+ getAll(name: string): string[];
47
131
  }
48
132
  //# sourceMappingURL=response.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../src/core/response.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/D,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,qBAAa,cAAc,CAAC,CAAC,GAAG,OAAO;IACrC,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,OAAO,EAAE,MAAM,CA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AAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QACrC,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;QACvB,WAAW,EAAE,MAAM,CAAC;QACpB,GAAG,EAAE,MAAM,CAAC;QACZ,aAAa,EAAE,MAAM,CAAC;QACtB,OAAO,EAAE,cAAc,CAAC;QACxB,OAAO,EAAE,YAAY,CAAC;KACvB;IAcD;;;;;OAKG;IACH,IAAI,EAAE,IAAI,OAAO,CAEhB;IAED;;;;;;OAMG;IACH,IAAI,IAAI,MAAM;IAYd;;;;;;;;;;;;OAYG;IACH,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;IAUhB;;;;;OAKG;IACH,IAAI,aAAa,IAAI,MAAM,CAO1B;IAED;;;;;OAKG;IACH,IAAI,WAAW,IAAI,MAAM,CAExB;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE;CAM/B"}
@@ -1,38 +1,84 @@
1
1
  /**
2
- * NLcURL response model.
2
+ * Represents the complete HTTP response from a successful request. Provides
3
+ * convenience accessors for common content-type parsing, streaming, and
4
+ * header inspection.
5
+ *
6
+ * @template T - Expected shape of the JSON-decoded body when calling {@link NLcURLResponse.json}.
3
7
  */
4
8
  export class NLcURLResponse {
9
+ /** HTTP status code (e.g. `200`, `404`). */
5
10
  status;
11
+ /** HTTP status text (e.g. `"OK"`, `"Not Found"`). */
6
12
  statusText;
13
+ /** Normalized, lowercase response headers. Duplicate values are joined by `, `. */
7
14
  headers;
8
- /** Raw header pairs preserving duplicates (e.g. multiple Set-Cookie). */
15
+ /** All response header name-value pairs exactly as received, in transmission order. */
9
16
  rawHeaders;
17
+ /** Fully buffered response body. Empty when the response was opened in streaming mode. */
10
18
  rawBody;
19
+ /** Readable stream of the response body, or `null` for buffered responses. */
20
+ body;
21
+ /** HTTP protocol version string (e.g. `"HTTP/1.1"`, `"HTTP/2.0"`). */
11
22
  httpVersion;
23
+ /** Final URL of the response after any redirects. */
12
24
  url;
25
+ /** Number of redirects followed before this response was received. */
13
26
  redirectCount;
27
+ /** Granular timing measurements for each phase of the request lifecycle. */
14
28
  timings;
29
+ /** Metadata about the originating request. */
15
30
  request;
16
31
  _json;
17
32
  _text;
33
+ /**
34
+ * Creates a new NLcURLResponse instance.
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.
48
+ */
18
49
  constructor(init) {
19
50
  this.status = init.status;
20
51
  this.statusText = init.statusText;
21
52
  this.headers = init.headers;
22
53
  this.rawHeaders = init.rawHeaders ?? Object.entries(init.headers);
23
54
  this.rawBody = init.rawBody;
55
+ this.body = init.body ?? null;
24
56
  this.httpVersion = init.httpVersion;
25
57
  this.url = init.url;
26
58
  this.redirectCount = init.redirectCount;
27
59
  this.timings = init.timings;
28
60
  this.request = init.request;
29
61
  }
30
- /** Whether the status code is 2xx. */
62
+ /**
63
+ * Returns `true` when the HTTP status code is in the 200–299 (successful)
64
+ * range, `false` otherwise.
65
+ *
66
+ * @returns {boolean} Whether the response indicates success.
67
+ */
31
68
  get ok() {
32
69
  return this.status >= 200 && this.status < 300;
33
70
  }
34
- /** Decode the body as UTF-8 text. Result is cached. */
71
+ /**
72
+ * Decodes the raw body as a UTF-8 string and returns it. The result is
73
+ * memoized after the first call.
74
+ *
75
+ * @returns {string} The response body decoded as UTF-8.
76
+ * @throws {Error} If the response was opened in streaming mode (`stream: true`).
77
+ */
35
78
  text() {
79
+ if (this.body) {
80
+ throw new Error('Cannot read text from a streaming response. Consume the .body stream instead.');
81
+ }
36
82
  let cached = this._text;
37
83
  if (cached === undefined) {
38
84
  cached = this.rawBody.toString('utf8');
@@ -40,14 +86,34 @@ export class NLcURLResponse {
40
86
  }
41
87
  return cached;
42
88
  }
43
- /** Parse the body as JSON. Result is cached. Throws on invalid JSON. */
89
+ /**
90
+ * Parses the raw body as JSON and returns the decoded value. The result is
91
+ * memoized after the first call.
92
+ *
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`).
96
+ * @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
+ */
44
102
  json() {
103
+ if (this.body) {
104
+ throw new Error('Cannot read JSON from a streaming response. Consume the .body stream instead.');
105
+ }
45
106
  if (this._json === undefined) {
46
107
  this._json = JSON.parse(this.text());
47
108
  }
48
109
  return this._json;
49
110
  }
50
- /** Content-Length as reported by the server, or the actual body size. */
111
+ /**
112
+ * Returns the `Content-Length` as a number. Falls back to the buffer byte
113
+ * length when the header is absent or unparseable.
114
+ *
115
+ * @returns {number} The content length in bytes.
116
+ */
51
117
  get contentLength() {
52
118
  const cl = this.headers['content-length'];
53
119
  if (cl !== undefined) {
@@ -57,9 +123,28 @@ export class NLcURLResponse {
57
123
  }
58
124
  return this.rawBody.length;
59
125
  }
60
- /** Shorthand for the content-type header value. */
126
+ /**
127
+ * Returns the value of the `Content-Type` response header, or an empty
128
+ * string when the header is absent.
129
+ *
130
+ * @returns {string} The `Content-Type` header value.
131
+ */
61
132
  get contentType() {
62
133
  return this.headers['content-type'] ?? '';
63
134
  }
135
+ /**
136
+ * Returns all values for a response header, in transmission order,
137
+ * supporting multi-value headers such as `Set-Cookie` which are joined
138
+ * when accessed through `headers`.
139
+ *
140
+ * @param {string} name - The case-insensitive header name to look up.
141
+ * @returns {string[]} All header values for the given name, or an empty array.
142
+ */
143
+ getAll(name) {
144
+ const lower = name.toLowerCase();
145
+ return this.rawHeaders
146
+ .filter(([k]) => k.toLowerCase() === lower)
147
+ .map(([, v]) => v);
148
+ }
64
149
  }
65
150
  //# sourceMappingURL=response.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"response.js","sourceRoot":"","sources":["../../src/core/response.ts"],"names":[],"mappings":"AAAA;;GAEG;AAWH,MAAM,OAAO,cAAc;IACT,MAAM,CAAS;IACf,UAAU,CAAS;IACnB,OAAO,CAAyB;IAChD,yEAAyE;IACzD,UAAU,CAA0B;IACpC,OAAO,CAAS;IAChB,WAAW,CAAS;IACpB,GAAG,CAAS;IACZ,aAAa,CAAS;IACtB,OAAO,CAAiB;IACxB,OAAO,CAAe;IAE9B,KAAK,CAAgB;IACrB,KAAK,CAAqB;IAElC,YAAY,IAWX;QACC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAClE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;QACpC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACpB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;QACxC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OA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CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,IAAY;QACjB,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC,UAAU;aACnB,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC;aAC1C,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;CACF"}
@@ -1,18 +1,25 @@
1
- /**
2
- * NLcURL Session.
3
- *
4
- * A persistent session that maintains cookies, connection pools,
5
- * default configuration, and middleware across multiple requests.
6
- */
7
1
  import type { NLcURLRequest, NLcURLSessionConfig, RequestBody } from './request.js';
8
2
  import { NLcURLResponse } from './response.js';
9
3
  import { CookieJar } from '../cookies/jar.js';
10
4
  import { type RequestInterceptor, type ResponseInterceptor } from '../middleware/interceptor.js';
11
5
  import { type RateLimitConfig } from '../middleware/rate-limiter.js';
12
6
  /**
13
- * Convenience options for HTTP method shortcuts.
7
+ * Request options that can be passed alongside a URL and HTTP method. All
8
+ * fields from {@link NLcURLRequest} except `url`, `method`, and `body`.
9
+ *
10
+ * @typedef {Omit<NLcURLRequest, 'url'|'method'|'body'>} RequestOptions
14
11
  */
15
12
  export type RequestOptions = Omit<NLcURLRequest, 'url' | 'method' | 'body'>;
13
+ /**
14
+ * Stateful HTTP client session that persists connections, cookies, interceptors,
15
+ * and configuration across multiple requests. Prefer using a session when making
16
+ * many requests to the same origin, or when you need shared cookie state.
17
+ *
18
+ * @example
19
+ * const session = new NLcURLSession({ impersonate: 'chrome136' });
20
+ * const response = await session.get('https://example.com');
21
+ * session.close();
22
+ */
16
23
  export declare class NLcURLSession {
17
24
  private readonly config;
18
25
  private readonly negotiator;
@@ -20,37 +27,125 @@ export declare class NLcURLSession {
20
27
  private readonly interceptors;
21
28
  private rateLimiter;
22
29
  private closed;
30
+ /**
31
+ * Creates a new NLcURLSession.
32
+ *
33
+ * @param {NLcURLSessionConfig} [config={}] - Session-level defaults applied to every request.
34
+ */
23
35
  constructor(config?: NLcURLSessionConfig);
24
36
  /**
25
- * Register a request interceptor.
37
+ * Registers a request interceptor that is invoked (in registration order)
38
+ * before each request is dispatched. The interceptor may return a modified
39
+ * request object or a `Promise` that resolves to one.
26
40
  *
27
- * Interceptors run before dispatch and may modify the outgoing request.
41
+ * @param {RequestInterceptor} fn - The interceptor function to add.
42
+ * @returns {this} The session instance, enabling a fluent call chain.
28
43
  */
29
44
  onRequest(fn: RequestInterceptor): this;
30
45
  /**
31
- * Register a response interceptor.
46
+ * Registers a response interceptor that is invoked (in registration order)
47
+ * after each response is received. The interceptor may return a modified
48
+ * response object or a `Promise` that resolves to one.
32
49
  *
33
- * Interceptors run after a response is received and may transform it.
50
+ * @param {ResponseInterceptor} fn - The interceptor function to add.
51
+ * @returns {this} The session instance, enabling a fluent call chain.
34
52
  */
35
53
  onResponse(fn: ResponseInterceptor): this;
36
54
  /**
37
- * Enable per-session rate limiting.
55
+ * Applies a token-bucket rate limit to all requests issued by this session.
56
+ * Requests that exceed the configured rate will wait until a token becomes
57
+ * available before proceeding.
58
+ *
59
+ * @param {RateLimitConfig} config - Rate limit parameters (`maxRequests` per `windowMs`).
60
+ * @returns {this} The session instance, enabling a fluent call chain.
38
61
  */
39
62
  setRateLimit(config: RateLimitConfig): this;
63
+ /**
64
+ * Issues a `GET` request and resolves with the complete response.
65
+ *
66
+ * @param {string} url - The URL to request.
67
+ * @param {RequestOptions} [options] - Optional per-request settings.
68
+ * @returns {Promise<NLcURLResponse>} Resolves with the server response.
69
+ */
40
70
  get(url: string, options?: RequestOptions): Promise<NLcURLResponse>;
71
+ /**
72
+ * Issues a `POST` request and resolves with the complete response.
73
+ *
74
+ * @param {string} url - The URL to request.
75
+ * @param {RequestBody} [body] - Request body payload.
76
+ * @param {RequestOptions} [options] - Optional per-request settings.
77
+ * @returns {Promise<NLcURLResponse>} Resolves with the server response.
78
+ */
41
79
  post(url: string, body?: RequestBody, options?: RequestOptions): Promise<NLcURLResponse>;
80
+ /**
81
+ * Issues a `PUT` request and resolves with the complete response.
82
+ *
83
+ * @param {string} url - The URL to request.
84
+ * @param {RequestBody} [body] - Request body payload.
85
+ * @param {RequestOptions} [options] - Optional per-request settings.
86
+ * @returns {Promise<NLcURLResponse>} Resolves with the server response.
87
+ */
42
88
  put(url: string, body?: RequestBody, options?: RequestOptions): Promise<NLcURLResponse>;
89
+ /**
90
+ * Issues a `PATCH` request and resolves with the complete response.
91
+ *
92
+ * @param {string} url - The URL to request.
93
+ * @param {RequestBody} [body] - Request body payload.
94
+ * @param {RequestOptions} [options] - Optional per-request settings.
95
+ * @returns {Promise<NLcURLResponse>} Resolves with the server response.
96
+ */
43
97
  patch(url: string, body?: RequestBody, options?: RequestOptions): Promise<NLcURLResponse>;
98
+ /**
99
+ * Issues a `DELETE` request and resolves with the complete response.
100
+ *
101
+ * @param {string} url - The URL to request.
102
+ * @param {RequestOptions} [options] - Optional per-request settings.
103
+ * @returns {Promise<NLcURLResponse>} Resolves with the server response.
104
+ */
44
105
  delete(url: string, options?: RequestOptions): Promise<NLcURLResponse>;
106
+ /**
107
+ * Issues a `HEAD` request and resolves with the complete response (no body).
108
+ *
109
+ * @param {string} url - The URL to request.
110
+ * @param {RequestOptions} [options] - Optional per-request settings.
111
+ * @returns {Promise<NLcURLResponse>} Resolves with the server response.
112
+ */
45
113
  head(url: string, options?: RequestOptions): Promise<NLcURLResponse>;
114
+ /**
115
+ * Issues an `OPTIONS` request and resolves with the complete response.
116
+ *
117
+ * @param {string} url - The URL to request.
118
+ * @param {RequestOptions} [options] - Optional per-request settings.
119
+ * @returns {Promise<NLcURLResponse>} Resolves with the server response.
120
+ */
46
121
  options(url: string, options?: RequestOptions): Promise<NLcURLResponse>;
122
+ /**
123
+ * Executes a fully described HTTP request, applying session defaults, request
124
+ * interceptors, redirect following, cookie management, and response
125
+ * interceptors in sequence.
126
+ *
127
+ * @param {NLcURLRequest} input - The request descriptor.
128
+ * @returns {Promise<NLcURLResponse>} Resolves with the final response after all redirects.
129
+ * @throws {NLcURLError} If the session has been closed.
130
+ * @throws {AbortError} If the provided `AbortSignal` fires before completion.
131
+ * @throws {TimeoutError} If any configured timeout is exceeded.
132
+ * @throws {ConnectionError} If a TCP connection cannot be established.
133
+ * @throws {TLSError} If the TLS handshake fails.
134
+ * @throws {ProxyError} If the proxy tunnel cannot be established.
135
+ * @throws {NLcURLError} If the maximum number of redirects is exceeded (`ERR_MAX_REDIRECTS`).
136
+ */
47
137
  request(input: NLcURLRequest): Promise<NLcURLResponse>;
48
138
  /**
49
- * Return the session cookie jar, or `null` when cookie management is disabled.
139
+ * Returns the active {@link CookieJar} for this session, or `null` if
140
+ * cookie management was disabled via `cookieJar: false`.
141
+ *
142
+ * @returns {CookieJar|null} The shared cookie jar, or `null`.
50
143
  */
51
144
  getCookies(): CookieJar | null;
52
145
  /**
53
- * Close the session and release pooled connections.
146
+ * Closes the session, releasing any pooled connections. After calling this
147
+ * method, issuing further requests will throw an `NLcURLError` with code
148
+ * `ERR_SESSION_CLOSED`. Subsequent calls are no-ops.
54
149
  */
55
150
  close(): void;
56
151
  private mergeDefaults;
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/core/session.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EAGnB,WAAW,EAEZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG/C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAoB,KAAK,kBAAkB,EAAE,KAAK,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnH,OAAO,EAAe,KAAK,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAMlF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG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