curl-cffi-node 0.1.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/README.md +716 -0
- package/curl-cffi-node.darwin-arm64.node +0 -0
- package/curl-cffi-node.darwin-x64.node +0 -0
- package/curl-cffi-node.linux-arm64-gnu.node +0 -0
- package/curl-cffi-node.linux-x64-gnu.node +0 -0
- package/curl-cffi-node.win32-x64-msvc.node +0 -0
- package/dist/binding.d.ts +2 -0
- package/dist/binding.d.ts.map +1 -0
- package/dist/binding.js +90 -0
- package/dist/binding.js.map +1 -0
- package/dist/enums.d.ts +87 -0
- package/dist/enums.d.ts.map +1 -0
- package/dist/enums.js +101 -0
- package/dist/enums.js.map +1 -0
- package/dist/errors.d.ts +61 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +116 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +77 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +88 -0
- package/dist/index.js.map +1 -0
- package/dist/response.d.ts +86 -0
- package/dist/response.d.ts.map +1 -0
- package/dist/response.js +137 -0
- package/dist/response.js.map +1 -0
- package/dist/session.d.ts +93 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +228 -0
- package/dist/session.js.map +1 -0
- package/dist/websocket.d.ts +68 -0
- package/dist/websocket.d.ts.map +1 -0
- package/dist/websocket.js +176 -0
- package/dist/websocket.js.map +1 -0
- package/npm/darwin-arm64/curl-cffi-node.darwin-arm64.node +0 -0
- package/npm/darwin-arm64/package.json +19 -0
- package/npm/darwin-x64/curl-cffi-node.darwin-x64.node +0 -0
- package/npm/darwin-x64/package.json +19 -0
- package/npm/linux-arm64-gnu/curl-cffi-node.linux-arm64-gnu.node +0 -0
- package/npm/linux-arm64-gnu/package.json +22 -0
- package/npm/linux-x64-gnu/curl-cffi-node.linux-x64-gnu.node +0 -0
- package/npm/linux-x64-gnu/package.json +22 -0
- package/npm/linux-x64-musl/package.json +14 -0
- package/npm/win32-x64-msvc/curl-cffi-node.win32-x64-msvc.node +0 -0
- package/npm/win32-x64-msvc/package.json +19 -0
- package/package.json +83 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binding.d.ts","sourceRoot":"","sources":["../lib/binding.ts"],"names":[],"mappings":"AA+FA,eAAO,MAAM,aAAa,yBAAsB,CAAC"}
|
package/dist/binding.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.nativeBinding = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* Platform-specific native binding loader.
|
|
7
|
+
*
|
|
8
|
+
* This module detects the current platform (os + arch + libc) and loads
|
|
9
|
+
* the corresponding prebuilt `.node` binary. If no prebuilt binary is
|
|
10
|
+
* available, it falls back to loading a locally compiled binary.
|
|
11
|
+
*/
|
|
12
|
+
const platformPackages = {
|
|
13
|
+
'linux-x64-gnu': '@curl-cffi-node/linux-x64-gnu',
|
|
14
|
+
'linux-x64-musl': '@curl-cffi-node/linux-x64-musl',
|
|
15
|
+
'linux-arm64-gnu': '@curl-cffi-node/linux-arm64-gnu',
|
|
16
|
+
'darwin-x64': '@curl-cffi-node/darwin-x64',
|
|
17
|
+
'darwin-arm64': '@curl-cffi-node/darwin-arm64',
|
|
18
|
+
'win32-x64-msvc': '@curl-cffi-node/win32-x64-msvc',
|
|
19
|
+
};
|
|
20
|
+
function getPlatformKey() {
|
|
21
|
+
const platform = process.platform;
|
|
22
|
+
const arch = process.arch;
|
|
23
|
+
if (platform === 'win32') {
|
|
24
|
+
return `win32-${arch}-msvc`;
|
|
25
|
+
}
|
|
26
|
+
if (platform === 'linux') {
|
|
27
|
+
// Detect musl vs glibc
|
|
28
|
+
const isMusl = isMuslLibc();
|
|
29
|
+
const libc = isMusl ? 'musl' : 'gnu';
|
|
30
|
+
return `linux-${arch}-${libc}`;
|
|
31
|
+
}
|
|
32
|
+
return `${platform}-${arch}`;
|
|
33
|
+
}
|
|
34
|
+
function isMuslLibc() {
|
|
35
|
+
try {
|
|
36
|
+
const { execSync } = require('child_process');
|
|
37
|
+
const output = execSync('ldd --version 2>&1', { encoding: 'utf8' });
|
|
38
|
+
return output.toLowerCase().includes('musl');
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
// If ldd fails, check for /lib/ld-musl-*
|
|
42
|
+
try {
|
|
43
|
+
const { readdirSync } = require('fs');
|
|
44
|
+
const files = readdirSync('/lib');
|
|
45
|
+
return files.some((f) => f.startsWith('ld-musl'));
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function loadNativeBinding() {
|
|
53
|
+
const platformKey = getPlatformKey();
|
|
54
|
+
const packageName = platformPackages[platformKey];
|
|
55
|
+
// Try 1: Load from platform-specific npm package
|
|
56
|
+
if (packageName) {
|
|
57
|
+
try {
|
|
58
|
+
return require(packageName);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
// Platform package not installed, try local binary
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// Try 2: Load locally compiled binary (development mode)
|
|
65
|
+
try {
|
|
66
|
+
return require(`../curl-cffi-node.${platformKey}.node`);
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// Local binary not found
|
|
70
|
+
}
|
|
71
|
+
// Try 3: Load any .node file in root (single-platform dev build)
|
|
72
|
+
try {
|
|
73
|
+
const { readdirSync } = require('fs');
|
|
74
|
+
const { join } = require('path');
|
|
75
|
+
const rootDir = join(__dirname, '..');
|
|
76
|
+
const nodeFiles = readdirSync(rootDir).filter((f) => f.endsWith('.node'));
|
|
77
|
+
if (nodeFiles.length > 0) {
|
|
78
|
+
return require(join(rootDir, nodeFiles[0]));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
// No .node files found
|
|
83
|
+
}
|
|
84
|
+
throw new Error(`Failed to load native binding for platform: ${platformKey}\n` +
|
|
85
|
+
`Tried: ${packageName || 'no platform package'}, local binary\n` +
|
|
86
|
+
`Please ensure the package is installed correctly for your platform.\n` +
|
|
87
|
+
`Supported platforms: ${Object.keys(platformPackages).join(', ')}`);
|
|
88
|
+
}
|
|
89
|
+
exports.nativeBinding = loadNativeBinding();
|
|
90
|
+
//# sourceMappingURL=binding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binding.js","sourceRoot":"","sources":["../lib/binding.ts"],"names":[],"mappings":";AAAA,0DAA0D;;;AAE1D;;;;;;GAMG;AAEH,MAAM,gBAAgB,GAA2B;IAC/C,eAAe,EAAE,+BAA+B;IAChD,gBAAgB,EAAE,gCAAgC;IAClD,iBAAiB,EAAE,iCAAiC;IACpD,YAAY,EAAE,4BAA4B;IAC1C,cAAc,EAAE,8BAA8B;IAC9C,gBAAgB,EAAE,gCAAgC;CACnD,CAAC;AAEF,SAAS,cAAc;IACrB,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAClC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAE1B,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;QACzB,OAAO,SAAS,IAAI,OAAO,CAAC;IAC9B,CAAC;IAED,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;QACzB,uBAAuB;QACvB,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;QAC5B,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;QACrC,OAAO,SAAS,IAAI,IAAI,IAAI,EAAE,CAAC;IACjC,CAAC;IAED,OAAO,GAAG,QAAQ,IAAI,IAAI,EAAE,CAAC;AAC/B,CAAC;AAED,SAAS,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CAAC;QACjC,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QACtC,MAAM,SAAS,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;QAClF,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,uBAAuB;IACzB,CAAC;IAED,MAAM,IAAI,KAAK,CACb,+CAA+C,WAAW,IAAI;QAC9D,UAAU,WAAW,IAAI,qBAAqB,kBAAkB;QAChE,uEAAuE;QACvE,wBAAwB,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACnE,CAAC;AACJ,CAAC;AAEY,QAAA,aAAa,GAAG,iBAAiB,EAAE,CAAC"}
|
package/dist/enums.d.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript enum declarations for native napi-rs enums.
|
|
3
|
+
*
|
|
4
|
+
* These mirror the Rust enum variants in exact declaration order.
|
|
5
|
+
* napi-rs numeric enums map to sequential integers starting from 0.
|
|
6
|
+
* napi-rs string_enum maps to string values.
|
|
7
|
+
*/
|
|
8
|
+
/** Options for `Curl.setoptStr()`, `Curl.setoptLong()`, `Curl.setoptList()`. */
|
|
9
|
+
export declare enum CurlOpt {
|
|
10
|
+
Url = 0,
|
|
11
|
+
CustomRequest = 1,
|
|
12
|
+
PostFields = 2,
|
|
13
|
+
UserAgent = 3,
|
|
14
|
+
Referer = 4,
|
|
15
|
+
Cookie = 5,
|
|
16
|
+
CookieFile = 6,
|
|
17
|
+
CookieJar = 7,
|
|
18
|
+
Proxy = 8,
|
|
19
|
+
Username = 9,
|
|
20
|
+
Password = 10,
|
|
21
|
+
SslCipherList = 11,
|
|
22
|
+
Tls13Ciphers = 12,
|
|
23
|
+
SslEcCurves = 13,
|
|
24
|
+
SslSigHashAlgs = 14,
|
|
25
|
+
SslCertCompression = 15,
|
|
26
|
+
Http2PseudoHeadersOrder = 16,
|
|
27
|
+
Http2Settings = 17,
|
|
28
|
+
Http2Streams = 18,
|
|
29
|
+
FollowLocation = 19,
|
|
30
|
+
MaxRedirs = 20,
|
|
31
|
+
TimeoutMs = 21,
|
|
32
|
+
ConnectTimeoutMs = 22,
|
|
33
|
+
SslVerifyPeer = 23,
|
|
34
|
+
SslVerifyHost = 24,
|
|
35
|
+
Post = 25,
|
|
36
|
+
PostFieldSize = 26,
|
|
37
|
+
Port = 27,
|
|
38
|
+
HttpProxyTunnel = 28,
|
|
39
|
+
Upload = 29,
|
|
40
|
+
SslEnableAlps = 30,
|
|
41
|
+
SslEnableTicket = 31,
|
|
42
|
+
SslPermuteExtensions = 32,
|
|
43
|
+
HttpVersion = 33,
|
|
44
|
+
Http2WindowUpdate = 34,
|
|
45
|
+
StreamWeight = 35,
|
|
46
|
+
HttpHeader = 36,
|
|
47
|
+
ProxyHeader = 37,
|
|
48
|
+
Resolve = 38
|
|
49
|
+
}
|
|
50
|
+
/** Info keys for `Curl.getinfo()`. */
|
|
51
|
+
export declare enum CurlInfo {
|
|
52
|
+
/** The last HTTP response code. */
|
|
53
|
+
ResponseCode = 0,
|
|
54
|
+
/** Total time for the transfer in seconds. */
|
|
55
|
+
TotalTime = 1,
|
|
56
|
+
/** Time for name resolving in seconds. */
|
|
57
|
+
NameLookupTime = 2,
|
|
58
|
+
/** Time to connect in seconds. */
|
|
59
|
+
ConnectTime = 3,
|
|
60
|
+
/** Time to SSL/TLS handshake in seconds. */
|
|
61
|
+
AppConnectTime = 4,
|
|
62
|
+
/** Time until the first byte was received in seconds. */
|
|
63
|
+
StartTransferTime = 5,
|
|
64
|
+
/** The effective URL that was fetched (after redirects). */
|
|
65
|
+
EffectiveUrl = 6
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Browser impersonation targets for `Curl.impersonate()`.
|
|
69
|
+
*
|
|
70
|
+
* This is a string enum — values are the target strings accepted by
|
|
71
|
+
* curl_easy_impersonate().
|
|
72
|
+
*/
|
|
73
|
+
export declare enum BrowserType {
|
|
74
|
+
Chrome99 = "chrome99",
|
|
75
|
+
Chrome100 = "chrome100",
|
|
76
|
+
Chrome101 = "chrome101",
|
|
77
|
+
Chrome104 = "chrome104",
|
|
78
|
+
Chrome107 = "chrome107",
|
|
79
|
+
Chrome110 = "chrome110",
|
|
80
|
+
Chrome116 = "chrome116",
|
|
81
|
+
Chrome99Android = "chrome99_android",
|
|
82
|
+
Edge99 = "edge99",
|
|
83
|
+
Edge101 = "edge101",
|
|
84
|
+
Safari15_3 = "safari15_3",
|
|
85
|
+
Safari15_5 = "safari15_5"
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=enums.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../lib/enums.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,gFAAgF;AAChF,oBAAY,OAAO;IAEjB,GAAG,IAAI;IACP,aAAa,IAAI;IACjB,UAAU,IAAI;IACd,SAAS,IAAI;IACb,OAAO,IAAI;IACX,MAAM,IAAI;IACV,UAAU,IAAI;IACd,SAAS,IAAI;IACb,KAAK,IAAI;IACT,QAAQ,IAAI;IACZ,QAAQ,KAAK;IAGb,aAAa,KAAK;IAClB,YAAY,KAAK;IACjB,WAAW,KAAK;IAChB,cAAc,KAAK;IACnB,kBAAkB,KAAK;IAGvB,uBAAuB,KAAK;IAC5B,aAAa,KAAK;IAClB,YAAY,KAAK;IAGjB,cAAc,KAAK;IACnB,SAAS,KAAK;IACd,SAAS,KAAK;IACd,gBAAgB,KAAK;IACrB,aAAa,KAAK;IAClB,aAAa,KAAK;IAClB,IAAI,KAAK;IACT,aAAa,KAAK;IAClB,IAAI,KAAK;IACT,eAAe,KAAK;IACpB,MAAM,KAAK;IACX,aAAa,KAAK;IAClB,eAAe,KAAK;IACpB,oBAAoB,KAAK;IACzB,WAAW,KAAK;IAChB,iBAAiB,KAAK;IACtB,YAAY,KAAK;IAGjB,UAAU,KAAK;IACf,WAAW,KAAK;IAChB,OAAO,KAAK;CACb;AAID,sCAAsC;AACtC,oBAAY,QAAQ;IAClB,mCAAmC;IACnC,YAAY,IAAI;IAChB,8CAA8C;IAC9C,SAAS,IAAI;IACb,0CAA0C;IAC1C,cAAc,IAAI;IAClB,kCAAkC;IAClC,WAAW,IAAI;IACf,4CAA4C;IAC5C,cAAc,IAAI;IAClB,yDAAyD;IACzD,iBAAiB,IAAI;IACrB,4DAA4D;IAC5D,YAAY,IAAI;CACjB;AAID;;;;;GAKG;AACH,oBAAY,WAAW;IACrB,QAAQ,aAAa;IACrB,SAAS,cAAc;IACvB,SAAS,cAAc;IACvB,SAAS,cAAc;IACvB,SAAS,cAAc;IACvB,SAAS,cAAc;IACvB,SAAS,cAAc;IACvB,eAAe,qBAAqB;IACpC,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,UAAU,eAAe;CAC1B"}
|
package/dist/enums.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* TypeScript enum declarations for native napi-rs enums.
|
|
4
|
+
*
|
|
5
|
+
* These mirror the Rust enum variants in exact declaration order.
|
|
6
|
+
* napi-rs numeric enums map to sequential integers starting from 0.
|
|
7
|
+
* napi-rs string_enum maps to string values.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.BrowserType = exports.CurlInfo = exports.CurlOpt = void 0;
|
|
11
|
+
// ─── CurlOpt ────────────────────────────────────────────────────────────────
|
|
12
|
+
/** Options for `Curl.setoptStr()`, `Curl.setoptLong()`, `Curl.setoptList()`. */
|
|
13
|
+
var CurlOpt;
|
|
14
|
+
(function (CurlOpt) {
|
|
15
|
+
// String options
|
|
16
|
+
CurlOpt[CurlOpt["Url"] = 0] = "Url";
|
|
17
|
+
CurlOpt[CurlOpt["CustomRequest"] = 1] = "CustomRequest";
|
|
18
|
+
CurlOpt[CurlOpt["PostFields"] = 2] = "PostFields";
|
|
19
|
+
CurlOpt[CurlOpt["UserAgent"] = 3] = "UserAgent";
|
|
20
|
+
CurlOpt[CurlOpt["Referer"] = 4] = "Referer";
|
|
21
|
+
CurlOpt[CurlOpt["Cookie"] = 5] = "Cookie";
|
|
22
|
+
CurlOpt[CurlOpt["CookieFile"] = 6] = "CookieFile";
|
|
23
|
+
CurlOpt[CurlOpt["CookieJar"] = 7] = "CookieJar";
|
|
24
|
+
CurlOpt[CurlOpt["Proxy"] = 8] = "Proxy";
|
|
25
|
+
CurlOpt[CurlOpt["Username"] = 9] = "Username";
|
|
26
|
+
CurlOpt[CurlOpt["Password"] = 10] = "Password";
|
|
27
|
+
// TLS fingerprint string options
|
|
28
|
+
CurlOpt[CurlOpt["SslCipherList"] = 11] = "SslCipherList";
|
|
29
|
+
CurlOpt[CurlOpt["Tls13Ciphers"] = 12] = "Tls13Ciphers";
|
|
30
|
+
CurlOpt[CurlOpt["SslEcCurves"] = 13] = "SslEcCurves";
|
|
31
|
+
CurlOpt[CurlOpt["SslSigHashAlgs"] = 14] = "SslSigHashAlgs";
|
|
32
|
+
CurlOpt[CurlOpt["SslCertCompression"] = 15] = "SslCertCompression";
|
|
33
|
+
// HTTP/2 fingerprint string options
|
|
34
|
+
CurlOpt[CurlOpt["Http2PseudoHeadersOrder"] = 16] = "Http2PseudoHeadersOrder";
|
|
35
|
+
CurlOpt[CurlOpt["Http2Settings"] = 17] = "Http2Settings";
|
|
36
|
+
CurlOpt[CurlOpt["Http2Streams"] = 18] = "Http2Streams";
|
|
37
|
+
// Long/boolean options
|
|
38
|
+
CurlOpt[CurlOpt["FollowLocation"] = 19] = "FollowLocation";
|
|
39
|
+
CurlOpt[CurlOpt["MaxRedirs"] = 20] = "MaxRedirs";
|
|
40
|
+
CurlOpt[CurlOpt["TimeoutMs"] = 21] = "TimeoutMs";
|
|
41
|
+
CurlOpt[CurlOpt["ConnectTimeoutMs"] = 22] = "ConnectTimeoutMs";
|
|
42
|
+
CurlOpt[CurlOpt["SslVerifyPeer"] = 23] = "SslVerifyPeer";
|
|
43
|
+
CurlOpt[CurlOpt["SslVerifyHost"] = 24] = "SslVerifyHost";
|
|
44
|
+
CurlOpt[CurlOpt["Post"] = 25] = "Post";
|
|
45
|
+
CurlOpt[CurlOpt["PostFieldSize"] = 26] = "PostFieldSize";
|
|
46
|
+
CurlOpt[CurlOpt["Port"] = 27] = "Port";
|
|
47
|
+
CurlOpt[CurlOpt["HttpProxyTunnel"] = 28] = "HttpProxyTunnel";
|
|
48
|
+
CurlOpt[CurlOpt["Upload"] = 29] = "Upload";
|
|
49
|
+
CurlOpt[CurlOpt["SslEnableAlps"] = 30] = "SslEnableAlps";
|
|
50
|
+
CurlOpt[CurlOpt["SslEnableTicket"] = 31] = "SslEnableTicket";
|
|
51
|
+
CurlOpt[CurlOpt["SslPermuteExtensions"] = 32] = "SslPermuteExtensions";
|
|
52
|
+
CurlOpt[CurlOpt["HttpVersion"] = 33] = "HttpVersion";
|
|
53
|
+
CurlOpt[CurlOpt["Http2WindowUpdate"] = 34] = "Http2WindowUpdate";
|
|
54
|
+
CurlOpt[CurlOpt["StreamWeight"] = 35] = "StreamWeight";
|
|
55
|
+
// String list options
|
|
56
|
+
CurlOpt[CurlOpt["HttpHeader"] = 36] = "HttpHeader";
|
|
57
|
+
CurlOpt[CurlOpt["ProxyHeader"] = 37] = "ProxyHeader";
|
|
58
|
+
CurlOpt[CurlOpt["Resolve"] = 38] = "Resolve";
|
|
59
|
+
})(CurlOpt || (exports.CurlOpt = CurlOpt = {}));
|
|
60
|
+
// ─── CurlInfo ────────────────────────────────────────────────────────────────
|
|
61
|
+
/** Info keys for `Curl.getinfo()`. */
|
|
62
|
+
var CurlInfo;
|
|
63
|
+
(function (CurlInfo) {
|
|
64
|
+
/** The last HTTP response code. */
|
|
65
|
+
CurlInfo[CurlInfo["ResponseCode"] = 0] = "ResponseCode";
|
|
66
|
+
/** Total time for the transfer in seconds. */
|
|
67
|
+
CurlInfo[CurlInfo["TotalTime"] = 1] = "TotalTime";
|
|
68
|
+
/** Time for name resolving in seconds. */
|
|
69
|
+
CurlInfo[CurlInfo["NameLookupTime"] = 2] = "NameLookupTime";
|
|
70
|
+
/** Time to connect in seconds. */
|
|
71
|
+
CurlInfo[CurlInfo["ConnectTime"] = 3] = "ConnectTime";
|
|
72
|
+
/** Time to SSL/TLS handshake in seconds. */
|
|
73
|
+
CurlInfo[CurlInfo["AppConnectTime"] = 4] = "AppConnectTime";
|
|
74
|
+
/** Time until the first byte was received in seconds. */
|
|
75
|
+
CurlInfo[CurlInfo["StartTransferTime"] = 5] = "StartTransferTime";
|
|
76
|
+
/** The effective URL that was fetched (after redirects). */
|
|
77
|
+
CurlInfo[CurlInfo["EffectiveUrl"] = 6] = "EffectiveUrl";
|
|
78
|
+
})(CurlInfo || (exports.CurlInfo = CurlInfo = {}));
|
|
79
|
+
// ─── BrowserType ─────────────────────────────────────────────────────────────
|
|
80
|
+
/**
|
|
81
|
+
* Browser impersonation targets for `Curl.impersonate()`.
|
|
82
|
+
*
|
|
83
|
+
* This is a string enum — values are the target strings accepted by
|
|
84
|
+
* curl_easy_impersonate().
|
|
85
|
+
*/
|
|
86
|
+
var BrowserType;
|
|
87
|
+
(function (BrowserType) {
|
|
88
|
+
BrowserType["Chrome99"] = "chrome99";
|
|
89
|
+
BrowserType["Chrome100"] = "chrome100";
|
|
90
|
+
BrowserType["Chrome101"] = "chrome101";
|
|
91
|
+
BrowserType["Chrome104"] = "chrome104";
|
|
92
|
+
BrowserType["Chrome107"] = "chrome107";
|
|
93
|
+
BrowserType["Chrome110"] = "chrome110";
|
|
94
|
+
BrowserType["Chrome116"] = "chrome116";
|
|
95
|
+
BrowserType["Chrome99Android"] = "chrome99_android";
|
|
96
|
+
BrowserType["Edge99"] = "edge99";
|
|
97
|
+
BrowserType["Edge101"] = "edge101";
|
|
98
|
+
BrowserType["Safari15_3"] = "safari15_3";
|
|
99
|
+
BrowserType["Safari15_5"] = "safari15_5";
|
|
100
|
+
})(BrowserType || (exports.BrowserType = BrowserType = {}));
|
|
101
|
+
//# sourceMappingURL=enums.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enums.js","sourceRoot":"","sources":["../lib/enums.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,+EAA+E;AAE/E,gFAAgF;AAChF,IAAY,OAiDX;AAjDD,WAAY,OAAO;IACjB,iBAAiB;IACjB,mCAAO,CAAA;IACP,uDAAiB,CAAA;IACjB,iDAAc,CAAA;IACd,+CAAa,CAAA;IACb,2CAAW,CAAA;IACX,yCAAU,CAAA;IACV,iDAAc,CAAA;IACd,+CAAa,CAAA;IACb,uCAAS,CAAA;IACT,6CAAY,CAAA;IACZ,8CAAa,CAAA;IAEb,iCAAiC;IACjC,wDAAkB,CAAA;IAClB,sDAAiB,CAAA;IACjB,oDAAgB,CAAA;IAChB,0DAAmB,CAAA;IACnB,kEAAuB,CAAA;IAEvB,oCAAoC;IACpC,4EAA4B,CAAA;IAC5B,wDAAkB,CAAA;IAClB,sDAAiB,CAAA;IAEjB,uBAAuB;IACvB,0DAAmB,CAAA;IACnB,gDAAc,CAAA;IACd,gDAAc,CAAA;IACd,8DAAqB,CAAA;IACrB,wDAAkB,CAAA;IAClB,wDAAkB,CAAA;IAClB,sCAAS,CAAA;IACT,wDAAkB,CAAA;IAClB,sCAAS,CAAA;IACT,4DAAoB,CAAA;IACpB,0CAAW,CAAA;IACX,wDAAkB,CAAA;IAClB,4DAAoB,CAAA;IACpB,sEAAyB,CAAA;IACzB,oDAAgB,CAAA;IAChB,gEAAsB,CAAA;IACtB,sDAAiB,CAAA;IAEjB,sBAAsB;IACtB,kDAAe,CAAA;IACf,oDAAgB,CAAA;IAChB,4CAAY,CAAA;AACd,CAAC,EAjDW,OAAO,uBAAP,OAAO,QAiDlB;AAED,gFAAgF;AAEhF,sCAAsC;AACtC,IAAY,QAeX;AAfD,WAAY,QAAQ;IAClB,mCAAmC;IACnC,uDAAgB,CAAA;IAChB,8CAA8C;IAC9C,iDAAa,CAAA;IACb,0CAA0C;IAC1C,2DAAkB,CAAA;IAClB,kCAAkC;IAClC,qDAAe,CAAA;IACf,4CAA4C;IAC5C,2DAAkB,CAAA;IAClB,yDAAyD;IACzD,iEAAqB,CAAA;IACrB,4DAA4D;IAC5D,uDAAgB,CAAA;AAClB,CAAC,EAfW,QAAQ,wBAAR,QAAQ,QAenB;AAED,gFAAgF;AAEhF;;;;;GAKG;AACH,IAAY,WAaX;AAbD,WAAY,WAAW;IACrB,oCAAqB,CAAA;IACrB,sCAAuB,CAAA;IACvB,sCAAuB,CAAA;IACvB,sCAAuB,CAAA;IACvB,sCAAuB,CAAA;IACvB,sCAAuB,CAAA;IACvB,sCAAuB,CAAA;IACvB,mDAAoC,CAAA;IACpC,gCAAiB,CAAA;IACjB,kCAAmB,CAAA;IACnB,wCAAyB,CAAA;IACzB,wCAAyB,CAAA;AAC3B,CAAC,EAbW,WAAW,2BAAX,WAAW,QAatB"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* curl-cffi-node error hierarchy.
|
|
3
|
+
*
|
|
4
|
+
* Maps CURLcode values to typed error subclasses for structured error handling.
|
|
5
|
+
*/
|
|
6
|
+
/** CURLcode values for common error scenarios. */
|
|
7
|
+
export declare enum CurlCode {
|
|
8
|
+
OK = 0,
|
|
9
|
+
UNSUPPORTED_PROTOCOL = 1,
|
|
10
|
+
COULDNT_RESOLVE_PROXY = 5,
|
|
11
|
+
COULDNT_RESOLVE_HOST = 6,
|
|
12
|
+
COULDNT_CONNECT = 7,
|
|
13
|
+
OPERATION_TIMEDOUT = 28,
|
|
14
|
+
SSL_CONNECT_ERROR = 35,
|
|
15
|
+
SSL_PEER_CERTIFICATE = 51,
|
|
16
|
+
SSL_CERTPROBLEM = 58,
|
|
17
|
+
SSL_CIPHER = 59,
|
|
18
|
+
SSL_CACERT = 60,
|
|
19
|
+
SEND_ERROR = 55,
|
|
20
|
+
RECV_ERROR = 56,
|
|
21
|
+
PROXY = 97
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Base error class for all curl errors.
|
|
25
|
+
*
|
|
26
|
+
* Contains the CURLcode and the original curl error message.
|
|
27
|
+
*/
|
|
28
|
+
export declare class CurlError extends Error {
|
|
29
|
+
/** The CURLcode that caused this error. */
|
|
30
|
+
readonly code: number;
|
|
31
|
+
/** The original curl error description. */
|
|
32
|
+
readonly curlMessage: string;
|
|
33
|
+
constructor(code: number, curlMessage: string);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Thrown when a request times out (CURLcode 28).
|
|
37
|
+
*/
|
|
38
|
+
export declare class TimeoutError extends CurlError {
|
|
39
|
+
constructor(curlMessage: string);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Thrown when connection fails (CURLcode 6, 7).
|
|
43
|
+
*/
|
|
44
|
+
export declare class ConnectionError extends CurlError {
|
|
45
|
+
constructor(code: number, curlMessage: string);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Thrown when TLS/SSL fails (CURLcode 35, 51, 58, 59, 60).
|
|
49
|
+
*/
|
|
50
|
+
export declare class TLSError extends CurlError {
|
|
51
|
+
constructor(code: number, curlMessage: string);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Thrown when proxy fails (CURLcode 5, 97).
|
|
55
|
+
*/
|
|
56
|
+
export declare class ProxyError extends CurlError {
|
|
57
|
+
constructor(code: number, curlMessage: string);
|
|
58
|
+
}
|
|
59
|
+
/** Parse a native curl error string into a typed error. */
|
|
60
|
+
export declare function parseCurlError(message: string): CurlError;
|
|
61
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../lib/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,kDAAkD;AAClD,oBAAY,QAAQ;IAClB,EAAE,IAAI;IACN,oBAAoB,IAAI;IACxB,qBAAqB,IAAI;IACzB,oBAAoB,IAAI;IACxB,eAAe,IAAI;IACnB,kBAAkB,KAAK;IACvB,iBAAiB,KAAK;IACtB,oBAAoB,KAAK;IACzB,eAAe,KAAK;IACpB,UAAU,KAAK;IACf,UAAU,KAAK;IACf,UAAU,KAAK;IACf,UAAU,KAAK;IACf,KAAK,KAAK;CACX;AAED;;;;GAIG;AACH,qBAAa,SAAU,SAAQ,KAAK;IAClC,2CAA2C;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2CAA2C;IAC3C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;gBAEjB,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;CAQ9C;AAED;;GAEG;AACH,qBAAa,YAAa,SAAQ,SAAS;gBAC7B,WAAW,EAAE,MAAM;CAIhC;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,SAAS;gBAChC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;CAI9C;AAED;;GAEG;AACH,qBAAa,QAAS,SAAQ,SAAS;gBACzB,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;CAI9C;AAED;;GAEG;AACH,qBAAa,UAAW,SAAQ,SAAS;gBAC3B,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;CAI9C;AAED,2DAA2D;AAC3D,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAgCzD"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* curl-cffi-node error hierarchy.
|
|
4
|
+
*
|
|
5
|
+
* Maps CURLcode values to typed error subclasses for structured error handling.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.ProxyError = exports.TLSError = exports.ConnectionError = exports.TimeoutError = exports.CurlError = exports.CurlCode = void 0;
|
|
9
|
+
exports.parseCurlError = parseCurlError;
|
|
10
|
+
/** CURLcode values for common error scenarios. */
|
|
11
|
+
var CurlCode;
|
|
12
|
+
(function (CurlCode) {
|
|
13
|
+
CurlCode[CurlCode["OK"] = 0] = "OK";
|
|
14
|
+
CurlCode[CurlCode["UNSUPPORTED_PROTOCOL"] = 1] = "UNSUPPORTED_PROTOCOL";
|
|
15
|
+
CurlCode[CurlCode["COULDNT_RESOLVE_PROXY"] = 5] = "COULDNT_RESOLVE_PROXY";
|
|
16
|
+
CurlCode[CurlCode["COULDNT_RESOLVE_HOST"] = 6] = "COULDNT_RESOLVE_HOST";
|
|
17
|
+
CurlCode[CurlCode["COULDNT_CONNECT"] = 7] = "COULDNT_CONNECT";
|
|
18
|
+
CurlCode[CurlCode["OPERATION_TIMEDOUT"] = 28] = "OPERATION_TIMEDOUT";
|
|
19
|
+
CurlCode[CurlCode["SSL_CONNECT_ERROR"] = 35] = "SSL_CONNECT_ERROR";
|
|
20
|
+
CurlCode[CurlCode["SSL_PEER_CERTIFICATE"] = 51] = "SSL_PEER_CERTIFICATE";
|
|
21
|
+
CurlCode[CurlCode["SSL_CERTPROBLEM"] = 58] = "SSL_CERTPROBLEM";
|
|
22
|
+
CurlCode[CurlCode["SSL_CIPHER"] = 59] = "SSL_CIPHER";
|
|
23
|
+
CurlCode[CurlCode["SSL_CACERT"] = 60] = "SSL_CACERT";
|
|
24
|
+
CurlCode[CurlCode["SEND_ERROR"] = 55] = "SEND_ERROR";
|
|
25
|
+
CurlCode[CurlCode["RECV_ERROR"] = 56] = "RECV_ERROR";
|
|
26
|
+
CurlCode[CurlCode["PROXY"] = 97] = "PROXY";
|
|
27
|
+
})(CurlCode || (exports.CurlCode = CurlCode = {}));
|
|
28
|
+
/**
|
|
29
|
+
* Base error class for all curl errors.
|
|
30
|
+
*
|
|
31
|
+
* Contains the CURLcode and the original curl error message.
|
|
32
|
+
*/
|
|
33
|
+
class CurlError extends Error {
|
|
34
|
+
/** The CURLcode that caused this error. */
|
|
35
|
+
code;
|
|
36
|
+
/** The original curl error description. */
|
|
37
|
+
curlMessage;
|
|
38
|
+
constructor(code, curlMessage) {
|
|
39
|
+
super(`curl error (${code}): ${curlMessage}`);
|
|
40
|
+
this.name = 'CurlError';
|
|
41
|
+
this.code = code;
|
|
42
|
+
this.curlMessage = curlMessage;
|
|
43
|
+
// Fix prototype chain for instanceof
|
|
44
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.CurlError = CurlError;
|
|
48
|
+
/**
|
|
49
|
+
* Thrown when a request times out (CURLcode 28).
|
|
50
|
+
*/
|
|
51
|
+
class TimeoutError extends CurlError {
|
|
52
|
+
constructor(curlMessage) {
|
|
53
|
+
super(CurlCode.OPERATION_TIMEDOUT, curlMessage);
|
|
54
|
+
this.name = 'TimeoutError';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.TimeoutError = TimeoutError;
|
|
58
|
+
/**
|
|
59
|
+
* Thrown when connection fails (CURLcode 6, 7).
|
|
60
|
+
*/
|
|
61
|
+
class ConnectionError extends CurlError {
|
|
62
|
+
constructor(code, curlMessage) {
|
|
63
|
+
super(code, curlMessage);
|
|
64
|
+
this.name = 'ConnectionError';
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.ConnectionError = ConnectionError;
|
|
68
|
+
/**
|
|
69
|
+
* Thrown when TLS/SSL fails (CURLcode 35, 51, 58, 59, 60).
|
|
70
|
+
*/
|
|
71
|
+
class TLSError extends CurlError {
|
|
72
|
+
constructor(code, curlMessage) {
|
|
73
|
+
super(code, curlMessage);
|
|
74
|
+
this.name = 'TLSError';
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.TLSError = TLSError;
|
|
78
|
+
/**
|
|
79
|
+
* Thrown when proxy fails (CURLcode 5, 97).
|
|
80
|
+
*/
|
|
81
|
+
class ProxyError extends CurlError {
|
|
82
|
+
constructor(code, curlMessage) {
|
|
83
|
+
super(code, curlMessage);
|
|
84
|
+
this.name = 'ProxyError';
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.ProxyError = ProxyError;
|
|
88
|
+
/** Parse a native curl error string into a typed error. */
|
|
89
|
+
function parseCurlError(message) {
|
|
90
|
+
// Native errors have format: "curl error (CODE): MESSAGE"
|
|
91
|
+
const match = message.match(/^curl error \((\d+)\): (.+)$/);
|
|
92
|
+
if (!match) {
|
|
93
|
+
return new CurlError(-1, message);
|
|
94
|
+
}
|
|
95
|
+
const code = parseInt(match[1], 10);
|
|
96
|
+
const curlMessage = match[2];
|
|
97
|
+
switch (code) {
|
|
98
|
+
case CurlCode.OPERATION_TIMEDOUT:
|
|
99
|
+
return new TimeoutError(curlMessage);
|
|
100
|
+
case CurlCode.COULDNT_RESOLVE_HOST:
|
|
101
|
+
case CurlCode.COULDNT_CONNECT:
|
|
102
|
+
return new ConnectionError(code, curlMessage);
|
|
103
|
+
case CurlCode.SSL_CONNECT_ERROR:
|
|
104
|
+
case CurlCode.SSL_PEER_CERTIFICATE:
|
|
105
|
+
case CurlCode.SSL_CERTPROBLEM:
|
|
106
|
+
case CurlCode.SSL_CIPHER:
|
|
107
|
+
case CurlCode.SSL_CACERT:
|
|
108
|
+
return new TLSError(code, curlMessage);
|
|
109
|
+
case CurlCode.COULDNT_RESOLVE_PROXY:
|
|
110
|
+
case CurlCode.PROXY:
|
|
111
|
+
return new ProxyError(code, curlMessage);
|
|
112
|
+
default:
|
|
113
|
+
return new CurlError(code, curlMessage);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../lib/errors.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAkFH,wCAgCC;AAhHD,kDAAkD;AAClD,IAAY,QAeX;AAfD,WAAY,QAAQ;IAClB,mCAAM,CAAA;IACN,uEAAwB,CAAA;IACxB,yEAAyB,CAAA;IACzB,uEAAwB,CAAA;IACxB,6DAAmB,CAAA;IACnB,oEAAuB,CAAA;IACvB,kEAAsB,CAAA;IACtB,wEAAyB,CAAA;IACzB,8DAAoB,CAAA;IACpB,oDAAe,CAAA;IACf,oDAAe,CAAA;IACf,oDAAe,CAAA;IACf,oDAAe,CAAA;IACf,0CAAU,CAAA;AACZ,CAAC,EAfW,QAAQ,wBAAR,QAAQ,QAenB;AAED;;;;GAIG;AACH,MAAa,SAAU,SAAQ,KAAK;IAClC,2CAA2C;IAClC,IAAI,CAAS;IACtB,2CAA2C;IAClC,WAAW,CAAS;IAE7B,YAAY,IAAY,EAAE,WAAmB;QAC3C,KAAK,CAAC,eAAe,IAAI,MAAM,WAAW,EAAE,CAAC,CAAC;QAC9C,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,qCAAqC;QACrC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF;AAdD,8BAcC;AAED;;GAEG;AACH,MAAa,YAAa,SAAQ,SAAS;IACzC,YAAY,WAAmB;QAC7B,KAAK,CAAC,QAAQ,CAAC,kBAAkB,EAAE,WAAW,CAAC,CAAC;QAChD,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AALD,o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KAAK,QAAQ,CAAC,iBAAiB,CAAC;QAChC,KAAK,QAAQ,CAAC,oBAAoB,CAAC;QACnC,KAAK,QAAQ,CAAC,eAAe,CAAC;QAC9B,KAAK,QAAQ,CAAC,UAAU,CAAC;QACzB,KAAK,QAAQ,CAAC,UAAU;YACtB,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QAEzC,KAAK,QAAQ,CAAC,qBAAqB,CAAC;QACpC,KAAK,QAAQ,CAAC,KAAK;YACjB,OAAO,IAAI,UAAU,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QAE3C;YACE,OAAO,IAAI,SAAS,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAC5C,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* curl-cffi-node — Node.js binding for curl-impersonate
|
|
3
|
+
*
|
|
4
|
+
* Provides browser-impersonating HTTP client with TLS/JA3/HTTP2 fingerprinting.
|
|
5
|
+
*
|
|
6
|
+
* @module curl-cffi-node
|
|
7
|
+
*/
|
|
8
|
+
export { Response, Headers, type Timing } from './response.js';
|
|
9
|
+
export { CurlError, TimeoutError, ConnectionError, TLSError, ProxyError, CurlCode, parseCurlError, } from './errors.js';
|
|
10
|
+
export { Session, type SessionOptions, type RequestOptions, } from './session.js';
|
|
11
|
+
export { CurlWebSocket, type CurlWebSocketOptions, WS_TEXT, WS_BINARY, WS_CLOSE, } from './websocket.js';
|
|
12
|
+
/**
|
|
13
|
+
* Returns a greeting from the native module to verify binding works.
|
|
14
|
+
*/
|
|
15
|
+
export declare const hello: () => string;
|
|
16
|
+
/**
|
|
17
|
+
* Returns the version of the native Rust module.
|
|
18
|
+
*/
|
|
19
|
+
export declare const nativeVersion: () => string;
|
|
20
|
+
/**
|
|
21
|
+
* Returns the version string from the linked libcurl-impersonate library.
|
|
22
|
+
*/
|
|
23
|
+
export declare const curlVersion: () => string;
|
|
24
|
+
export { CurlOpt, CurlInfo, BrowserType } from './enums.js';
|
|
25
|
+
export declare const Curl: {
|
|
26
|
+
new (): CurlHandle;
|
|
27
|
+
};
|
|
28
|
+
export interface CurlHandle {
|
|
29
|
+
setoptStr(opt: number, value: string): void;
|
|
30
|
+
setoptLong(opt: number, value: number): void;
|
|
31
|
+
setoptList(opt: number, values: string[]): void;
|
|
32
|
+
impersonate(browser: string, defaultHeaders?: boolean): void;
|
|
33
|
+
impersonateStr(target: string, defaultHeaders?: boolean): void;
|
|
34
|
+
perform(): PerformResult;
|
|
35
|
+
performAsync(): Promise<PerformResult>;
|
|
36
|
+
getinfo(info: number): number | string;
|
|
37
|
+
reset(): void;
|
|
38
|
+
duplicate(): CurlHandle;
|
|
39
|
+
strerror(code: number): string;
|
|
40
|
+
}
|
|
41
|
+
export interface PerformResult {
|
|
42
|
+
body: Buffer;
|
|
43
|
+
headers: string;
|
|
44
|
+
statusCode: number;
|
|
45
|
+
effectiveUrl: string;
|
|
46
|
+
dnsTimeMs: number;
|
|
47
|
+
connectTimeMs: number;
|
|
48
|
+
tlsTimeMs: number;
|
|
49
|
+
totalTimeMs: number;
|
|
50
|
+
}
|
|
51
|
+
import { type RequestOptions } from './session.js';
|
|
52
|
+
import type { Response } from './response.js';
|
|
53
|
+
/** Shorthand for a GET request. Creates a temporary session. */
|
|
54
|
+
export declare function get(url: string, options?: RequestOptions & {
|
|
55
|
+
impersonate?: string;
|
|
56
|
+
}): Promise<Response>;
|
|
57
|
+
/** Shorthand for a POST request. */
|
|
58
|
+
export declare function post(url: string, options?: RequestOptions & {
|
|
59
|
+
impersonate?: string;
|
|
60
|
+
}): Promise<Response>;
|
|
61
|
+
/** Shorthand for a PUT request. */
|
|
62
|
+
export declare function put(url: string, options?: RequestOptions & {
|
|
63
|
+
impersonate?: string;
|
|
64
|
+
}): Promise<Response>;
|
|
65
|
+
/** Shorthand for a DELETE request. */
|
|
66
|
+
export declare function del(url: string, options?: RequestOptions & {
|
|
67
|
+
impersonate?: string;
|
|
68
|
+
}): Promise<Response>;
|
|
69
|
+
/** Shorthand for a HEAD request. */
|
|
70
|
+
export declare function head(url: string, options?: RequestOptions & {
|
|
71
|
+
impersonate?: string;
|
|
72
|
+
}): Promise<Response>;
|
|
73
|
+
/** Shorthand for a PATCH request. */
|
|
74
|
+
export declare function patch(url: string, options?: RequestOptions & {
|
|
75
|
+
impersonate?: string;
|
|
76
|
+
}): Promise<Response>;
|
|
77
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EACL,SAAS,EACT,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,OAAO,EACP,KAAK,cAAc,EACnB,KAAK,cAAc,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,aAAa,EACb,KAAK,oBAAoB,EACzB,OAAO,EACP,SAAS,EACT,QAAQ,GACT,MAAM,gBAAgB,CAAC;AAIxB;;GAEG;AACH,eAAO,MAAM,KAAK,EAAE,MAAM,MAA4C,CAAC;AAEvE;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,MAAoD,CAAC;AAEvF;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,MAAM,MAAkD,CAAC;AAInF,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE5D,eAAO,MAAM,IAAI,EAAyB;IACxC,QAAO,UAAU,CAAC;CACnB,CAAC;AAEF,MAAM,WAAW,UAAU;IACzB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAA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