New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ossiana/node-libcurl

Package Overview
Dependencies
Maintainers
1
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ossiana/node-libcurl - npm Package Compare versions

Comparing version 1.1.3-alpha-3 to 1.1.4-alpha-1

dist/ja3Map.d.ts

4

dist/export.d.ts
import { LibCurl } from "./libcurl";
import { fetch } from "./fetch";
import { requests } from './requests';
export { LibCurl, fetch, requests };
import { LibCurlJA3Map } from "./ja3Map";
import { LibCurlWebSocket } from "./libcurlWebSocket";
export { LibCurl, fetch, requests, LibCurlJA3Map, LibCurlWebSocket };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.requests = exports.fetch = exports.LibCurl = void 0;
exports.LibCurlWebSocket = exports.LibCurlJA3Map = exports.requests = exports.fetch = exports.LibCurl = void 0;
const libcurl_1 = require("./libcurl");

@@ -10,2 +10,6 @@ Object.defineProperty(exports, "LibCurl", { enumerable: true, get: function () { return libcurl_1.LibCurl; } });

Object.defineProperty(exports, "requests", { enumerable: true, get: function () { return requests_1.requests; } });
const ja3Map_1 = require("./ja3Map");
Object.defineProperty(exports, "LibCurlJA3Map", { enumerable: true, get: function () { return ja3Map_1.LibCurlJA3Map; } });
const libcurlWebSocket_1 = require("./libcurlWebSocket");
Object.defineProperty(exports, "LibCurlWebSocket", { enumerable: true, get: function () { return libcurlWebSocket_1.LibCurlWebSocket; } });
//# sourceMappingURL=export.js.map

@@ -53,2 +53,8 @@ export declare enum LibCurlHttpVersionInfo {

'AES256-SHA' = 53,
'DHE-RSA-AES128-SHA' = 51,
'DHE-RSA-AES256-SHA' = 57,
'AES128-SHA256' = 60,
'AES256-SHA256' = 61,
'DHE-RSA-AES128-SHA256' = 103,
'DHE-RSA-AES256-SHA256' = 107,
'PSK-AES128-CBC-SHA' = 140,

@@ -58,9 +64,17 @@ 'PSK-AES256-CBC-SHA' = 141,

'AES256-GCM-SHA384' = 157,
'DHE-RSA-AES128-GCM-SHA256' = 158,
'DHE-RSA-AES256-GCM-SHA384' = 159,
'TLS_AES_128_GCM_SHA256' = 4865,
'TLS_AES_256_GCM_SHA384' = 4866,
'TLS_CHACHA20_POLY1305_SHA256' = 4867,
'ECDHE-ECDSA-DES-CBC3-SHA' = 49160,
'ECDHE-ECDSA-AES128-SHA' = 49161,
'ECDHE-ECDSA-AES256-SHA' = 49162,
'ECDHE-RSA-DES-CBC3-SHA' = 49170,
'ECDHE-RSA-AES128-SHA' = 49171,
'ECDHE-RSA-AES256-SHA' = 49172,
'TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256' = 49187,
'TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384' = 49188,
'TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256' = 49191,
'TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384' = 49192,
'ECDHE-ECDSA-AES128-GCM-SHA256' = 49195,

@@ -147,3 +161,2 @@ 'ECDHE-ECDSA-AES256-GCM-SHA384' = 49196,

constructor();
private static multiExecute;
private checkSending;

@@ -150,0 +163,0 @@ open(method: LibCurlMethodInfo, url: LibCurlURLInfo): void;

@@ -10,6 +10,4 @@ "use strict";

const { BaoLibCurl } = (0, bindings_1.default)('bao_curl_node_addon');
const { WebSocket } = BaoLibCurl;
BaoLibCurl.globalInit();
process.on('exit', (e) => {
BaoLibCurl.globalCleanup();
});
var LibCurlHttpVersionInfo;

@@ -31,2 +29,8 @@ (function (LibCurlHttpVersionInfo) {

LibCurlJA3Cipher[LibCurlJA3Cipher["AES256-SHA"] = 53] = "AES256-SHA";
LibCurlJA3Cipher[LibCurlJA3Cipher["DHE-RSA-AES128-SHA"] = 51] = "DHE-RSA-AES128-SHA";
LibCurlJA3Cipher[LibCurlJA3Cipher["DHE-RSA-AES256-SHA"] = 57] = "DHE-RSA-AES256-SHA";
LibCurlJA3Cipher[LibCurlJA3Cipher["AES128-SHA256"] = 60] = "AES128-SHA256";
LibCurlJA3Cipher[LibCurlJA3Cipher["AES256-SHA256"] = 61] = "AES256-SHA256";
LibCurlJA3Cipher[LibCurlJA3Cipher["DHE-RSA-AES128-SHA256"] = 103] = "DHE-RSA-AES128-SHA256";
LibCurlJA3Cipher[LibCurlJA3Cipher["DHE-RSA-AES256-SHA256"] = 107] = "DHE-RSA-AES256-SHA256";
LibCurlJA3Cipher[LibCurlJA3Cipher["PSK-AES128-CBC-SHA"] = 140] = "PSK-AES128-CBC-SHA";

@@ -36,9 +40,17 @@ LibCurlJA3Cipher[LibCurlJA3Cipher["PSK-AES256-CBC-SHA"] = 141] = "PSK-AES256-CBC-SHA";

LibCurlJA3Cipher[LibCurlJA3Cipher["AES256-GCM-SHA384"] = 157] = "AES256-GCM-SHA384";
LibCurlJA3Cipher[LibCurlJA3Cipher["DHE-RSA-AES128-GCM-SHA256"] = 158] = "DHE-RSA-AES128-GCM-SHA256";
LibCurlJA3Cipher[LibCurlJA3Cipher["DHE-RSA-AES256-GCM-SHA384"] = 159] = "DHE-RSA-AES256-GCM-SHA384";
LibCurlJA3Cipher[LibCurlJA3Cipher["TLS_AES_128_GCM_SHA256"] = 4865] = "TLS_AES_128_GCM_SHA256";
LibCurlJA3Cipher[LibCurlJA3Cipher["TLS_AES_256_GCM_SHA384"] = 4866] = "TLS_AES_256_GCM_SHA384";
LibCurlJA3Cipher[LibCurlJA3Cipher["TLS_CHACHA20_POLY1305_SHA256"] = 4867] = "TLS_CHACHA20_POLY1305_SHA256";
LibCurlJA3Cipher[LibCurlJA3Cipher["ECDHE-ECDSA-DES-CBC3-SHA"] = 49160] = "ECDHE-ECDSA-DES-CBC3-SHA";
LibCurlJA3Cipher[LibCurlJA3Cipher["ECDHE-ECDSA-AES128-SHA"] = 49161] = "ECDHE-ECDSA-AES128-SHA";
LibCurlJA3Cipher[LibCurlJA3Cipher["ECDHE-ECDSA-AES256-SHA"] = 49162] = "ECDHE-ECDSA-AES256-SHA";
LibCurlJA3Cipher[LibCurlJA3Cipher["ECDHE-RSA-DES-CBC3-SHA"] = 49170] = "ECDHE-RSA-DES-CBC3-SHA";
LibCurlJA3Cipher[LibCurlJA3Cipher["ECDHE-RSA-AES128-SHA"] = 49171] = "ECDHE-RSA-AES128-SHA";
LibCurlJA3Cipher[LibCurlJA3Cipher["ECDHE-RSA-AES256-SHA"] = 49172] = "ECDHE-RSA-AES256-SHA";
LibCurlJA3Cipher[LibCurlJA3Cipher["TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256"] = 49187] = "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256";
LibCurlJA3Cipher[LibCurlJA3Cipher["TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384"] = 49188] = "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384";
LibCurlJA3Cipher[LibCurlJA3Cipher["TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"] = 49191] = "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256";
LibCurlJA3Cipher[LibCurlJA3Cipher["TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384"] = 49192] = "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384";
LibCurlJA3Cipher[LibCurlJA3Cipher["ECDHE-ECDSA-AES128-GCM-SHA256"] = 49195] = "ECDHE-ECDSA-AES128-GCM-SHA256";

@@ -143,4 +155,2 @@ LibCurlJA3Cipher[LibCurlJA3Cipher["ECDHE-ECDSA-AES256-GCM-SHA384"] = 49196] = "ECDHE-ECDSA-AES256-GCM-SHA384";

}
static multiExecute() {
}
checkSending() {

@@ -291,3 +301,3 @@ if (this.m_isSending_) {

if (cipher.startsWith('TLS_')) {
const pos = ['4865', '4866', '4867'].indexOf(key);
const pos = ['4865', '4866', '4867', '49187', '49188', '49191', '49192'].indexOf(key);
if (pos == -1) {

@@ -294,0 +304,0 @@ throw new LibCurlError(`ja3 fingerprint TLSv1.3 cipher ${key} no support`);

@@ -6,2 +6,6 @@ import { LibCurl, LibCurlBodyInfo, LibCurlCookiesAttr, LibCurlCookiesInfo, LibCurlHeadersAttr, LibCurlHeadersInfo, LibCurlProxyInfo, LibCurlHttpVersionInfo, LibCurlURLInfo, LibCurlJA3FingerPrintInfo } from "./libcurl";

type requestsCookiesInfo = LibCurlCookiesInfo;
type requestsCookiesInfoWithUri = {
value: requestsCookiesInfo;
uri: string;
};
type requestsProxyInfo = LibCurlProxyInfo;

@@ -31,3 +35,3 @@ type requestsURLInfo = LibCurlURLInfo;

redirect?: boolean;
cookies?: requestsCookiesInfo;
cookies?: requestsCookiesInfo | requestsCookiesInfoWithUri;
proxy?: requestsProxyInfo;

@@ -51,2 +55,6 @@ body?: requestsBodyInfo;

timeout?: number;
redirect?: boolean;
proxy?: requestsProxyInfo;
interface?: string;
httpVersion?: requestsHttpVersionInfo;
}

@@ -58,3 +66,4 @@ interface requestsStaticOption extends Omit<requestsInitOption, 'body' | 'instance'>, requestsOption {

private needSetCookies;
private ja3;
private lastJa3;
private randomJa3;
constructor(option?: requestsInitOption);

@@ -61,0 +70,0 @@ static session(option?: requestsInitOption): requests;

@@ -38,6 +38,8 @@ "use strict";

};
const ja3Md5Map = new Map();
class requests {
option;
needSetCookies;
ja3;
lastJa3;
randomJa3;
constructor(option = {}) {

@@ -47,4 +49,20 @@ this.option = { ...option };

const curl = this.option.instance ||= new libcurl_1.LibCurl();
if (cookies) {
this.needSetCookies = !!cookies;
switch (typeof cookies) {
case 'string':
this.needSetCookies = !!cookies;
break;
case 'object':
if (cookies !== null) {
if (cookies.value) {
if (cookies.uri) {
(0, utils_1.libcurlSetCookies)(curl, cookies.value, (0, utils_1.getUriTopLevelHost)(cookies.uri));
}
else {
this.needSetCookies = !!cookies;
}
}
}
break;
default:
break;
}

@@ -69,4 +87,9 @@ if (timeout) {

}
this.ja3 = ja3 || (0, utils_1.libcurlRandomJA3Fingerprint)();
curl.setJA3Fingerprint(this.ja3);
if (ja3) {
this.lastJa3 = ja3;
this.randomJa3 = false;
}
else {
this.randomJa3 = true;
}
}

@@ -153,10 +176,25 @@ static session(option = {}) {

getJA3Fingerprint() {
if (!this.lastJa3) {
return {
ja3: '',
ja3_hash: '',
};
}
if (!ja3Md5Map.has(this.lastJa3)) {
const ja3_hash = (0, utils_1.md5)(this.lastJa3);
ja3Md5Map.set(this.lastJa3, ja3_hash);
return {
ja3: this.lastJa3,
ja3_hash,
};
}
const ja3_hash = ja3Md5Map.get(this.lastJa3);
return {
ja3: this.ja3,
ja3_hash: (0, utils_1.md5)(this.ja3),
ja3: this.lastJa3,
ja3_hash,
};
}
async sendRequest(method, url, requestOpt) {
const { instance: curl, cookies, timeout: timeoutOpt } = this.option;
const { headers, data, json, params, timeout } = requestOpt || {};
const { instance: curl, cookies, timeout: timeoutOpt, ja3 } = this.option;
const { headers, data, json, params, timeout, interface: interface_, redirect, proxy, httpVersion } = requestOpt || {};
if (data && json) {

@@ -168,3 +206,3 @@ throw new libcurl_1.LibCurlError('both data and json exist');

this.needSetCookies = false;
(0, utils_1.libcurlSetCookies)(curl, cookies, url_.hostname.split('.').slice(-2).join('.'));
(0, utils_1.libcurlSetCookies)(curl, cookies, (0, utils_1.getUriTopLevelHost)(url_));
}

@@ -178,3 +216,3 @@ if (params) {

}
if (timeout) {
if (typeof timeout == 'number') {
curl.setTimeout(timeout, timeout);

@@ -185,2 +223,43 @@ }

}
if (typeof interface_ == 'string') {
curl.setInterface(interface_);
}
else {
if (this.option.interface) {
curl.setInterface(this.option.interface);
}
}
if (typeof redirect == 'boolean') {
curl.setRedirect(redirect);
}
else {
if (this.option.redirect) {
curl.setRedirect(this.option.redirect);
}
}
if (proxy) {
curl.setProxy(proxy);
}
else {
if (this.option.proxy) {
curl.setProxy(this.option.proxy);
}
}
if (typeof httpVersion == 'number') {
curl.setHttpVersion(httpVersion);
}
else {
if (this.option.httpVersion) {
curl.setHttpVersion(this.option.httpVersion);
}
}
if (ja3) {
curl.setJA3Fingerprint(ja3);
}
else {
if (this.randomJa3) {
this.lastJa3 = (0, utils_1.libcurlRandomJA3Fingerprint)();
curl.setJA3Fingerprint(this.lastJa3);
}
}
let hasContentType = false;

@@ -187,0 +266,0 @@ if (headers && (data || json)) {

@@ -7,1 +7,2 @@ import { LibCurl, LibCurlCookieAttrArray, LibCurlCookiesInfo, LibCurlGetCookiesOption } from "./libcurl";

export declare const md5: (e: string) => string;
export declare const getUriTopLevelHost: (uri: string | URL) => string;

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.md5 = exports.libcurlRandomJA3Fingerprint = exports.libcurlSetCookies = exports.cookieOptFilter = exports.httpCookiesToArray = void 0;
exports.getUriTopLevelHost = exports.md5 = exports.libcurlRandomJA3Fingerprint = exports.libcurlSetCookies = exports.cookieOptFilter = exports.httpCookiesToArray = void 0;
const node_crypto_1 = __importDefault(require("node:crypto"));

@@ -103,2 +103,11 @@ const httpCookiesToArray = (cookies) => {

exports.md5 = md5;
const getUriTopLevelHost = (uri) => {
const getHost = (e) => e.split('.').slice(-2).join('.');
let uri_ = uri + '';
if (uri_.startsWith('http')) {
return getHost(new URL(uri).hostname);
}
return getHost(uri_);
};
exports.getUriTopLevelHost = getUriTopLevelHost;
//# sourceMappingURL=utils.js.map
{
"name": "@ossiana/node-libcurl",
"version": "1.1.3-alpha-3",
"version": "1.1.4-alpha-1",
"dependencies": {

@@ -21,3 +21,3 @@ "@mapbox/node-pre-gyp": "^1.0.10",

"host": "https://ossianaa.github.io/static/github/release/node-libcurl/",
"remote_path": "v1.0.2"
"remote_path": "v1.0.3"
},

@@ -24,0 +24,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc