httpcloak 1.0.6 → 1.0.7
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 +17 -22
- package/npm/darwin-arm64/package.json +1 -1
- package/npm/darwin-x64/package.json +1 -1
- package/npm/linux-arm64/package.json +1 -1
- package/npm/linux-x64/package.json +1 -1
- package/npm/win32-arm64/package.json +1 -1
- package/npm/win32-x64/package.json +1 -1
- package/package.json +7 -7
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
|
|
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", "
|
|
231
|
-
httpcloak_post: nativeLib.func("httpcloak_post", "
|
|
232
|
-
httpcloak_request: nativeLib.func("httpcloak_request", "
|
|
233
|
-
httpcloak_get_cookies: nativeLib.func("httpcloak_get_cookies", "
|
|
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", "
|
|
237
|
-
httpcloak_available_presets: nativeLib.func("httpcloak_available_presets", "
|
|
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
|
|
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
|
|
247
|
-
if (!
|
|
248
|
+
function resultToString(result) {
|
|
249
|
+
if (!result) {
|
|
248
250
|
return null;
|
|
249
251
|
}
|
|
250
|
-
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
758
|
+
const result = resultToString(resultPtr);
|
|
764
759
|
if (result) {
|
|
765
760
|
return JSON.parse(result);
|
|
766
761
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "httpcloak",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
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.
|
|
39
|
-
"@httpcloak/linux-arm64": "1.0.
|
|
40
|
-
"@httpcloak/darwin-x64": "1.0.
|
|
41
|
-
"@httpcloak/darwin-arm64": "1.0.
|
|
42
|
-
"@httpcloak/win32-x64": "1.0.
|
|
43
|
-
"@httpcloak/win32-arm64": "1.0.
|
|
38
|
+
"@httpcloak/linux-x64": "1.0.7",
|
|
39
|
+
"@httpcloak/linux-arm64": "1.0.7",
|
|
40
|
+
"@httpcloak/darwin-x64": "1.0.7",
|
|
41
|
+
"@httpcloak/darwin-arm64": "1.0.7",
|
|
42
|
+
"@httpcloak/win32-x64": "1.0.7",
|
|
43
|
+
"@httpcloak/win32-arm64": "1.0.7"
|
|
44
44
|
}
|
|
45
45
|
}
|