httpcloak 1.0.3 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts CHANGED
@@ -31,6 +31,18 @@ export interface SessionOptions {
31
31
  proxy?: string;
32
32
  /** Request timeout in seconds (default: 30) */
33
33
  timeout?: number;
34
+ /** HTTP version: "auto", "h1", "h2", "h3" (default: "auto") */
35
+ httpVersion?: string;
36
+ /** SSL certificate verification (default: true) */
37
+ verify?: boolean;
38
+ /** Follow redirects (default: true) */
39
+ allowRedirects?: boolean;
40
+ /** Maximum number of redirects to follow (default: 10) */
41
+ maxRedirects?: number;
42
+ /** Number of retries on failure (default: 3, set to 0 to disable) */
43
+ retry?: number;
44
+ /** Status codes to retry on (default: [429, 500, 502, 503, 504]) */
45
+ retryOnStatus?: number[];
34
46
  }
35
47
 
36
48
  export interface RequestOptions {
@@ -150,3 +162,56 @@ export function version(): string;
150
162
 
151
163
  /** Get list of available browser presets */
152
164
  export function availablePresets(): string[];
165
+
166
+ export interface ConfigureOptions extends SessionOptions {
167
+ /** Default headers for all requests */
168
+ headers?: Record<string, string>;
169
+ /** Default basic auth [username, password] */
170
+ auth?: [string, string];
171
+ }
172
+
173
+ /** Configure defaults for module-level functions */
174
+ export function configure(options?: ConfigureOptions): void;
175
+
176
+ /** Perform a GET request */
177
+ export function get(url: string, options?: RequestOptions): Promise<Response>;
178
+
179
+ /** Perform a POST request */
180
+ export function post(url: string, options?: RequestOptions): Promise<Response>;
181
+
182
+ /** Perform a PUT request */
183
+ export function put(url: string, options?: RequestOptions): Promise<Response>;
184
+
185
+ /** Perform a DELETE request */
186
+ declare function del(url: string, options?: RequestOptions): Promise<Response>;
187
+ export { del as delete };
188
+
189
+ /** Perform a PATCH request */
190
+ export function patch(url: string, options?: RequestOptions): Promise<Response>;
191
+
192
+ /** Perform a HEAD request */
193
+ export function head(url: string, options?: RequestOptions): Promise<Response>;
194
+
195
+ /** Perform an OPTIONS request */
196
+ export function options(url: string, options?: RequestOptions): Promise<Response>;
197
+
198
+ /** Perform a custom HTTP request */
199
+ export function request(method: string, url: string, options?: RequestOptions): Promise<Response>;
200
+
201
+ /** Available browser presets */
202
+ export const Preset: {
203
+ CHROME_143: string;
204
+ CHROME_143_WINDOWS: string;
205
+ CHROME_143_LINUX: string;
206
+ CHROME_143_MACOS: string;
207
+ CHROME_131: string;
208
+ CHROME_131_WINDOWS: string;
209
+ CHROME_131_LINUX: string;
210
+ CHROME_131_MACOS: string;
211
+ IOS_CHROME_143: string;
212
+ ANDROID_CHROME_143: string;
213
+ FIREFOX_133: string;
214
+ SAFARI_18: string;
215
+ IOS_SAFARI_17: string;
216
+ all(): string[];
217
+ };
package/lib/index.js CHANGED
@@ -43,11 +43,16 @@ const Preset = {
43
43
  CHROME_131_LINUX: "chrome-131-linux",
44
44
  CHROME_131_MACOS: "chrome-131-macos",
45
45
 
46
+ // Mobile Chrome
47
+ IOS_CHROME_143: "ios-chrome-143",
48
+ ANDROID_CHROME_143: "android-chrome-143",
49
+
46
50
  // Firefox
47
51
  FIREFOX_133: "firefox-133",
48
52
 
49
- // Safari
53
+ // Safari (desktop and mobile)
50
54
  SAFARI_18: "safari-18",
55
+ IOS_SAFARI_17: "ios-safari-17",
51
56
 
52
57
  /**
53
58
  * Get all available preset names
@@ -57,7 +62,9 @@ const Preset = {
57
62
  return [
58
63
  this.CHROME_143, this.CHROME_143_WINDOWS, this.CHROME_143_LINUX, this.CHROME_143_MACOS,
59
64
  this.CHROME_131, this.CHROME_131_WINDOWS, this.CHROME_131_LINUX, this.CHROME_131_MACOS,
60
- this.FIREFOX_133, this.SAFARI_18,
65
+ this.IOS_CHROME_143, this.ANDROID_CHROME_143,
66
+ this.FIREFOX_133,
67
+ this.SAFARI_18, this.IOS_SAFARI_17,
61
68
  ];
62
69
  },
63
70
  };
@@ -438,7 +445,7 @@ class Session {
438
445
  * @param {boolean} [options.verify=true] - SSL certificate verification
439
446
  * @param {boolean} [options.allowRedirects=true] - Follow redirects
440
447
  * @param {number} [options.maxRedirects=10] - Maximum number of redirects to follow
441
- * @param {number} [options.retry=0] - Number of retries on failure
448
+ * @param {number} [options.retry=3] - Number of retries on failure (set to 0 to disable)
442
449
  * @param {number[]} [options.retryOnStatus] - Status codes to retry on
443
450
  */
444
451
  constructor(options = {}) {
@@ -450,7 +457,7 @@ class Session {
450
457
  verify = true,
451
458
  allowRedirects = true,
452
459
  maxRedirects = 10,
453
- retry = 0,
460
+ retry = 3,
454
461
  retryOnStatus = null,
455
462
  } = options;
456
463
 
@@ -473,11 +480,10 @@ class Session {
473
480
  } else if (maxRedirects !== 10) {
474
481
  config.max_redirects = maxRedirects;
475
482
  }
476
- if (retry > 0) {
477
- config.retry = retry;
478
- if (retryOnStatus) {
479
- config.retry_on_status = retryOnStatus;
480
- }
483
+ // Always pass retry to clib (even if 0 to explicitly disable)
484
+ config.retry = retry;
485
+ if (retryOnStatus) {
486
+ config.retry_on_status = retryOnStatus;
481
487
  }
482
488
 
483
489
  this._handle = this._lib.httpcloak_session_new(JSON.stringify(config));
@@ -797,7 +803,7 @@ let _defaultConfig = {};
797
803
  * @param {boolean} [options.verify=true] - SSL certificate verification
798
804
  * @param {boolean} [options.allowRedirects=true] - Follow redirects
799
805
  * @param {number} [options.maxRedirects=10] - Maximum number of redirects to follow
800
- * @param {number} [options.retry=0] - Number of retries on failure
806
+ * @param {number} [options.retry=3] - Number of retries on failure (set to 0 to disable)
801
807
  * @param {number[]} [options.retryOnStatus] - Status codes to retry on
802
808
  */
803
809
  function configure(options = {}) {
@@ -811,7 +817,7 @@ function configure(options = {}) {
811
817
  verify = true,
812
818
  allowRedirects = true,
813
819
  maxRedirects = 10,
814
- retry = 0,
820
+ retry = 3,
815
821
  retryOnStatus = null,
816
822
  } = options;
817
823
 
@@ -867,7 +873,7 @@ function _getDefaultSession() {
867
873
  const verify = _defaultConfig.verify !== undefined ? _defaultConfig.verify : true;
868
874
  const allowRedirects = _defaultConfig.allowRedirects !== undefined ? _defaultConfig.allowRedirects : true;
869
875
  const maxRedirects = _defaultConfig.maxRedirects || 10;
870
- const retry = _defaultConfig.retry || 0;
876
+ const retry = _defaultConfig.retry !== undefined ? _defaultConfig.retry : 3;
871
877
  const retryOnStatus = _defaultConfig.retryOnStatus || null;
872
878
  const headers = _defaultConfig.headers || {};
873
879
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@httpcloak/darwin-arm64",
3
- "version": "1.0.3",
3
+ "version": "1.0.6",
4
4
  "description": "HTTPCloak native binary for darwin arm64",
5
5
  "os": [
6
6
  "darwin"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@httpcloak/darwin-x64",
3
- "version": "1.0.3",
3
+ "version": "1.0.6",
4
4
  "description": "HTTPCloak native binary for darwin x64",
5
5
  "os": [
6
6
  "darwin"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@httpcloak/linux-arm64",
3
- "version": "1.0.3",
3
+ "version": "1.0.6",
4
4
  "description": "HTTPCloak native binary for linux arm64",
5
5
  "os": [
6
6
  "linux"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@httpcloak/linux-x64",
3
- "version": "1.0.3",
3
+ "version": "1.0.6",
4
4
  "description": "HTTPCloak native binary for linux x64",
5
5
  "os": [
6
6
  "linux"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@httpcloak/win32-arm64",
3
- "version": "1.0.3",
3
+ "version": "1.0.6",
4
4
  "description": "HTTPCloak native binary for win32 arm64",
5
5
  "os": [
6
6
  "win32"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@httpcloak/win32-x64",
3
- "version": "1.0.3",
3
+ "version": "1.0.6",
4
4
  "description": "HTTPCloak native binary for win32 x64",
5
5
  "os": [
6
6
  "win32"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "httpcloak",
3
- "version": "1.0.3",
3
+ "version": "1.0.6",
4
4
  "description": "Browser fingerprint emulation HTTP client with HTTP/1.1, HTTP/2, and HTTP/3 support",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -35,11 +35,11 @@
35
35
  "koffi": "^2.9.0"
36
36
  },
37
37
  "optionalDependencies": {
38
- "@httpcloak/linux-x64": "1.0.3",
39
- "@httpcloak/linux-arm64": "1.0.3",
40
- "@httpcloak/darwin-x64": "1.0.3",
41
- "@httpcloak/darwin-arm64": "1.0.3",
42
- "@httpcloak/win32-x64": "1.0.3",
43
- "@httpcloak/win32-arm64": "1.0.3"
38
+ "@httpcloak/linux-x64": "1.0.6",
39
+ "@httpcloak/linux-arm64": "1.0.6",
40
+ "@httpcloak/darwin-x64": "1.0.6",
41
+ "@httpcloak/darwin-arm64": "1.0.6",
42
+ "@httpcloak/win32-x64": "1.0.6",
43
+ "@httpcloak/win32-arm64": "1.0.6"
44
44
  }
45
45
  }