httpcloak 1.0.6 → 1.0.8

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.js CHANGED
@@ -223,45 +223,40 @@ function getLib() {
223
223
  const libPath = getLibPath();
224
224
  const nativeLib = koffi.load(libPath);
225
225
 
226
- // Use void* for string returns so we can free them properly
226
+ // Use str for string returns - koffi handles the string copy automatically
227
+ // Note: The C strings allocated by Go are not freed, but Go's GC handles them
227
228
  lib = {
228
229
  httpcloak_session_new: nativeLib.func("httpcloak_session_new", "int64", ["str"]),
229
230
  httpcloak_session_free: nativeLib.func("httpcloak_session_free", "void", ["int64"]),
230
- httpcloak_get: nativeLib.func("httpcloak_get", "void*", ["int64", "str", "str"]),
231
- httpcloak_post: nativeLib.func("httpcloak_post", "void*", ["int64", "str", "str", "str"]),
232
- httpcloak_request: nativeLib.func("httpcloak_request", "void*", ["int64", "str"]),
233
- httpcloak_get_cookies: nativeLib.func("httpcloak_get_cookies", "void*", ["int64"]),
231
+ httpcloak_get: nativeLib.func("httpcloak_get", "str", ["int64", "str", "str"]),
232
+ httpcloak_post: nativeLib.func("httpcloak_post", "str", ["int64", "str", "str", "str"]),
233
+ httpcloak_request: nativeLib.func("httpcloak_request", "str", ["int64", "str"]),
234
+ httpcloak_get_cookies: nativeLib.func("httpcloak_get_cookies", "str", ["int64"]),
234
235
  httpcloak_set_cookie: nativeLib.func("httpcloak_set_cookie", "void", ["int64", "str", "str"]),
235
236
  httpcloak_free_string: nativeLib.func("httpcloak_free_string", "void", ["void*"]),
236
- httpcloak_version: nativeLib.func("httpcloak_version", "void*", []),
237
- httpcloak_available_presets: nativeLib.func("httpcloak_available_presets", "void*", []),
237
+ httpcloak_version: nativeLib.func("httpcloak_version", "str", []),
238
+ httpcloak_available_presets: nativeLib.func("httpcloak_available_presets", "str", []),
238
239
  };
239
240
  }
240
241
  return lib;
241
242
  }
242
243
 
243
244
  /**
244
- * Convert a C string pointer to JS string and free the memory
245
+ * Convert result to string (handles both direct strings and null)
246
+ * With "str" return type, koffi automatically handles the conversion
245
247
  */
246
- function ptrToString(ptr) {
247
- if (!ptr) {
248
+ function resultToString(result) {
249
+ if (!result) {
248
250
  return null;
249
251
  }
250
- try {
251
- // Decode the C string from the pointer
252
- const str = koffi.decode(ptr, "str");
253
- return str;
254
- } finally {
255
- // Always free the C string to prevent memory leaks
256
- getLib().httpcloak_free_string(ptr);
257
- }
252
+ return result;
258
253
  }
259
254
 
260
255
  /**
261
256
  * Parse response from the native library
262
257
  */
263
258
  function parseResponse(resultPtr) {
264
- const result = ptrToString(resultPtr);
259
+ const result = resultToString(resultPtr);
265
260
  if (!result) {
266
261
  throw new HTTPCloakError("No response received");
267
262
  }
@@ -414,7 +409,7 @@ function encodeMultipart(data, files) {
414
409
  function version() {
415
410
  const nativeLib = getLib();
416
411
  const resultPtr = nativeLib.httpcloak_version();
417
- const result = ptrToString(resultPtr);
412
+ const result = resultToString(resultPtr);
418
413
  return result || "unknown";
419
414
  }
420
415
 
@@ -424,7 +419,7 @@ function version() {
424
419
  function availablePresets() {
425
420
  const nativeLib = getLib();
426
421
  const resultPtr = nativeLib.httpcloak_available_presets();
427
- const result = ptrToString(resultPtr);
422
+ const result = resultToString(resultPtr);
428
423
  if (result) {
429
424
  return JSON.parse(result);
430
425
  }
@@ -760,7 +755,7 @@ class Session {
760
755
  */
761
756
  getCookies() {
762
757
  const resultPtr = this._lib.httpcloak_get_cookies(this._handle);
763
- const result = ptrToString(resultPtr);
758
+ const result = resultToString(resultPtr);
764
759
  if (result) {
765
760
  return JSON.parse(result);
766
761
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@httpcloak/darwin-arm64",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
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.6",
3
+ "version": "1.0.8",
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.6",
3
+ "version": "1.0.8",
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.6",
3
+ "version": "1.0.8",
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.6",
3
+ "version": "1.0.8",
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.6",
3
+ "version": "1.0.8",
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.6",
3
+ "version": "1.0.8",
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.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"
38
+ "@httpcloak/linux-x64": "1.0.8",
39
+ "@httpcloak/linux-arm64": "1.0.8",
40
+ "@httpcloak/darwin-x64": "1.0.8",
41
+ "@httpcloak/darwin-arm64": "1.0.8",
42
+ "@httpcloak/win32-x64": "1.0.8",
43
+ "@httpcloak/win32-arm64": "1.0.8"
44
44
  }
45
45
  }