├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── dist ├── decorators │ ├── client.js │ └── index.js ├── index.js ├── interface │ ├── client.js │ ├── index.js │ └── session.js ├── lib │ ├── Client.js │ ├── Cookie.js │ ├── Response.js │ ├── Session.js │ ├── index.js │ └── requests.js └── utils │ ├── download.js │ ├── index.js │ ├── koffi.js │ ├── logger.js │ ├── request.js │ ├── tlsError.js │ └── worker.js ├── docs ├── .nojekyll ├── assets │ ├── highlight.css │ ├── icons.js │ ├── icons.svg │ ├── main.js │ ├── navigation.js │ ├── search.js │ └── style.css ├── classes │ ├── Client.html │ ├── Cookies.html │ ├── Response.html │ └── Session.html ├── enums │ └── ClientIdentifier.html ├── functions │ └── fetch.html ├── hierarchy.html ├── index.html ├── interfaces │ ├── BaseRequestOptions.html │ ├── DeleteRequestOptions.html │ ├── GetRequestOptions.html │ ├── H2Settings.html │ ├── HeadRequestOptions.html │ ├── IClient.html │ ├── OptionsRequestOptions.html │ ├── PatchRequestOptions.html │ ├── PostRequestOptions.html │ ├── PriorityFrames.html │ ├── PriorityParam.html │ ├── PutRequestOptions.html │ ├── RequestOptions.html │ ├── SessionOptions.html │ ├── TlsResponse.html │ └── fetchOptions.html ├── modules.html └── types │ ├── CertCompressionAlgo.html │ ├── KeyShareCurves.html │ ├── Methods.html │ ├── PseudoHeaderOrder.html │ ├── SupportedSignatureAlgorithms.html │ └── SupportedVersions.html ├── examples ├── advanced.js ├── extra.js ├── images.js ├── samples │ └── cookie-example.md ├── simple.js └── timeout.js ├── package.json ├── readme.md ├── src ├── decorators │ ├── client.ts │ └── index.ts ├── index.ts ├── interface │ ├── client.ts │ ├── index.ts │ └── session.ts ├── lib │ ├── Client.ts │ ├── Cookie.ts │ ├── Response.ts │ ├── Session.ts │ ├── index.ts │ └── requests.ts └── utils │ ├── download.ts │ ├── index.ts │ ├── koffi.ts │ ├── logger.ts │ ├── request.ts │ ├── tlsError.ts │ └── worker.ts ├── tsconfig.json └── typings ├── decorators ├── client.d.ts └── index.d.ts ├── index.d.ts ├── interface ├── client.d.ts ├── index.d.ts └── session.d.ts ├── lib ├── Client.d.ts ├── Cookie.d.ts ├── Response.d.ts ├── Session.d.ts ├── index.d.ts └── requests.d.ts └── utils ├── download.d.ts ├── index.d.ts ├── koffi.d.ts ├── logger.d.ts ├── request.d.ts ├── tlsError.d.ts └── worker.d.ts /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | package-lock.json 3 | yarn.lock -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 2.0.0 (December 15, 2024) 2 | > [!WARNING] 3 | > This version contains breaking changes. 4 | - Call `.init()` after setting up a session and before using any HTTP methods. (See the documentation for more details.) 5 | - Resolved memory leak issues by moving to workerpool. 6 | - Added new profiles: `chrome_131`, `chrome_131_psk`, `firefox_132`, `firefox_133`, and `ios_safari_18`. The default profile is now `chrome_131` (previously `chrome_124`). 7 | - Introduced the `isRotatingProxy` option for handling rotating proxies. PS: [SessionOptions](https://sahil1337.github.io/node-tls-client/interfaces/SessionOptions.html) 8 | 9 | # 1.1.4 (July 29, 2024) 10 | > [!IMPORTANT] 11 | > This version includes significant updates and improvements. 12 | 13 | ### Breaking changes 14 | - `response.cookies` is now a property instead of a method. [Note: `response.cookies()` has been removed and replaced with `response.cookies`.] 15 | 16 | ### Additional updates 17 | - Added `session.cookies` property to retrieve all session cookies. For detailed information, see [examples/session-cookies.md](https://github.com/Sahil1337/node-tls-client/tree/main/examples/samples/cookie-example.md). 18 | - Added `byteResponse` option in requestOptions. Setting this to true ensures that the response is treated as a byte response. For detailed information, see [examples/images.js](https://github.com/Sahil1337/node-tls-client/tree/main/examples/images.js) 19 | - Added functionality to send binary data. Note: Ensure that the appropriate headers are set before sending binary data in the body. 20 | - Added `disableIPV6` and `disableIPV4` options in `SessionOptions`. For detailed information, see [SessionOptions](https://sahil1337.github.io/node-tls-client/interfaces/SessionOptions.html#disableIPV4) 21 | - Added `hostOverride` property in requestOptions. Used to override the Host header, typically needed when making requests directly to an IP address. 22 | - `chrome_124` profile will be used when no `client_identifier` is specified in session options. 23 | - Refactored cookies.ts and session typings for improved readability (internal change, no impact on existing use cases) 24 | - Updated TlsResponse according to new changes. 25 | 26 | # 1.1.3 (June 13, 2024) 27 | > [!WARNING] 28 | > This version contains breaking changes. 29 | 30 | ### Breaking changes 31 | - `response.json()` and `response.text()` methods now return a `Promise`. 32 | - `response.cookies()` now returns an object of cookies instead of a`Promise`. 33 | - `session.methods` no longer include the `timeout` and `rejectUnauthorized` options. Since timeout cannot be changed during a session, ensure to specify `timeout` & `rejectUnauthorized` in SessionOptions when creating a session. 34 | 35 | ### Additions 36 | - `fetch(fetchOptions)` method have been added to use different timeouts & rejectUnauthorized values in each request. [examples/timeout.js] for more information. 37 | 38 | ### Fixes 39 | - Fixed a typo that prevented timeout from working correctly. 40 | 41 | # 1.1.2 (June 9, 2024) 42 | ### Additions 43 | - Introduced client profile types. 44 | ### Changes 45 | - Enhanced documentation for improved clarity and usability. 46 | - Updated the README with minor adjustments. 47 | - Refined interface definitions for better readability and understanding. 48 | 49 | # 1.1.1 (June 4 2024) 50 | ### Additions 51 | - Implemented dynamic methods for downloading shared files in "node-tls-client", eliminating the inclusion of prebuilt files. 52 | ### Changes 53 | - Path used for storing the shared library files is strictly set to tmpdir path. 54 | ### Benefits 55 | - Reduces package size. 56 | - Ensures better support for executables. 57 | 58 | # 1.1.0 (June 3, 2024) 59 | ### Changes 60 | - Improved handling of shared library files: 61 | - Only the shared library file matching the current operating system is preserved. All other shared library files are deleted. 62 | - Added support for executables. 63 | -------------------------------------------------------------------------------- /dist/decorators/client.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.verifyClientState = void 0; 4 | const tlsError_1 = require("../utils/tlsError"); 5 | function verifyClientState() { 6 | return function (target, propertyKey, descriptor) { 7 | const method = descriptor.value; 8 | descriptor.value = function (...args) { 9 | if ("isReady" in this && this.isReady && "pool" in this && this.pool) { 10 | return method.apply(this, args); 11 | } 12 | else { 13 | throw new tlsError_1.TlsClientError("Client is not yet ready."); 14 | } 15 | }; 16 | return descriptor; 17 | }; 18 | } 19 | exports.verifyClientState = verifyClientState; 20 | -------------------------------------------------------------------------------- /dist/decorators/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | __exportStar(require("./client"), exports); 18 | -------------------------------------------------------------------------------- /dist/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | __exportStar(require("./interface"), exports); 18 | __exportStar(require("./lib"), exports); 19 | -------------------------------------------------------------------------------- /dist/interface/client.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /dist/interface/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | __exportStar(require("./session"), exports); 18 | __exportStar(require("./client"), exports); 19 | -------------------------------------------------------------------------------- /dist/interface/session.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.ClientIdentifier = void 0; 4 | /** 5 | * Represents various client identifiers. 6 | * 7 | * The client identifiers are grouped by browser, mobile clients, and other clients. 8 | */ 9 | var ClientIdentifier; 10 | (function (ClientIdentifier) { 11 | // Chrome versions 12 | ClientIdentifier["chrome_103"] = "chrome_103"; 13 | ClientIdentifier["chrome_104"] = "chrome_104"; 14 | ClientIdentifier["chrome_105"] = "chrome_105"; 15 | ClientIdentifier["chrome_106"] = "chrome_106"; 16 | ClientIdentifier["chrome_107"] = "chrome_107"; 17 | ClientIdentifier["chrome_108"] = "chrome_108"; 18 | ClientIdentifier["chrome_109"] = "chrome_109"; 19 | ClientIdentifier["chrome_110"] = "chrome_110"; 20 | ClientIdentifier["chrome_111"] = "chrome_111"; 21 | ClientIdentifier["chrome_112"] = "chrome_112"; 22 | ClientIdentifier["chrome_116_PSK"] = "chrome_116_PSK"; 23 | ClientIdentifier["chrome_116_PSK_PQ"] = "chrome_116_PSK_PQ"; 24 | ClientIdentifier["chrome_117"] = "chrome_117"; 25 | ClientIdentifier["chrome_120"] = "chrome_120"; 26 | ClientIdentifier["chrome_124"] = "chrome_124"; 27 | ClientIdentifier["chrome_131"] = "chrome_131"; 28 | ClientIdentifier["chrome_131_psk"] = "chrome_131_PSK"; 29 | // Safari versions 30 | ClientIdentifier["safari_15_6_1"] = "safari_15_6_1"; 31 | ClientIdentifier["safari_16_0"] = "safari_16_0"; 32 | ClientIdentifier["safari_ipad_15_6"] = "safari_ipad_15_6"; 33 | ClientIdentifier["safari_ios_15_5"] = "safari_ios_15_5"; 34 | ClientIdentifier["safari_ios_15_6"] = "safari_ios_15_6"; 35 | ClientIdentifier["safari_ios_16_0"] = "safari_ios_16_0"; 36 | ClientIdentifier["safari_ios_17_0"] = "safari_ios_17_0"; 37 | ClientIdentifier["safari_ios_18_0"] = "safari_ios_18_0"; 38 | // Firefox versions 39 | ClientIdentifier["firefox_102"] = "firefox_102"; 40 | ClientIdentifier["firefox_104"] = "firefox_104"; 41 | ClientIdentifier["firefox_105"] = "firefox_105"; 42 | ClientIdentifier["firefox_106"] = "firefox_106"; 43 | ClientIdentifier["firefox_108"] = "firefox_108"; 44 | ClientIdentifier["firefox_110"] = "firefox_110"; 45 | ClientIdentifier["firefox_117"] = "firefox_117"; 46 | ClientIdentifier["firefox_120"] = "firefox_120"; 47 | ClientIdentifier["firefox_123"] = "firefox_123"; 48 | ClientIdentifier["firefox_132"] = "firefox_132"; 49 | ClientIdentifier["firefox_133"] = "firefox_133"; 50 | // Opera versions 51 | ClientIdentifier["opera_89"] = "opera_89"; 52 | ClientIdentifier["opera_90"] = "opera_90"; 53 | ClientIdentifier["opera_91"] = "opera_91"; 54 | // Zalando mobile clients 55 | ClientIdentifier["zalando_android_mobile"] = "zalando_android_mobile"; 56 | ClientIdentifier["zalando_ios_mobile"] = "zalando_ios_mobile"; 57 | // Nike mobile clients 58 | ClientIdentifier["nike_ios_mobile"] = "nike_ios_mobile"; 59 | ClientIdentifier["nike_android_mobile"] = "nike_android_mobile"; 60 | // Other clients 61 | ClientIdentifier["cloudscraper"] = "cloudscraper"; 62 | // MMS iOS versions 63 | ClientIdentifier["mms_ios"] = "mms_ios"; 64 | ClientIdentifier["mms_ios_1"] = "mms_ios_1"; 65 | ClientIdentifier["mms_ios_2"] = "mms_ios_2"; 66 | ClientIdentifier["mms_ios_3"] = "mms_ios_3"; 67 | // Mesh clients 68 | ClientIdentifier["mesh_ios"] = "mesh_ios"; 69 | ClientIdentifier["mesh_ios_1"] = "mesh_ios_1"; 70 | ClientIdentifier["mesh_ios_2"] = "mesh_ios_2"; 71 | ClientIdentifier["mesh_android"] = "mesh_android"; 72 | ClientIdentifier["mesh_android_1"] = "mesh_android_1"; 73 | ClientIdentifier["mesh_android_2"] = "mesh_android_2"; 74 | // Confirmed clients 75 | ClientIdentifier["confirmed_ios"] = "confirmed_ios"; 76 | ClientIdentifier["confirmed_android"] = "confirmed_android"; 77 | // OkHttp Android versions 78 | ClientIdentifier["okhttp4_android_7"] = "okhttp4_android_7"; 79 | ClientIdentifier["okhttp4_android_8"] = "okhttp4_android_8"; 80 | ClientIdentifier["okhttp4_android_9"] = "okhttp4_android_9"; 81 | ClientIdentifier["okhttp4_android_10"] = "okhttp4_android_10"; 82 | ClientIdentifier["okhttp4_android_11"] = "okhttp4_android_11"; 83 | ClientIdentifier["okhttp4_android_12"] = "okhttp4_android_12"; 84 | ClientIdentifier["okhttp4_android_13"] = "okhttp4_android_13"; 85 | })(ClientIdentifier || (exports.ClientIdentifier = ClientIdentifier = {})); 86 | -------------------------------------------------------------------------------- /dist/lib/Client.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.Client = void 0; 4 | const utils_1 = require("../utils"); 5 | const tlsError_1 = require("../utils/tlsError"); 6 | class Client { 7 | client; 8 | constructor() { 9 | this.client = {}; 10 | } 11 | /** 12 | * Intialize the client and load the native library. 13 | */ 14 | async init() { 15 | this.client = await (0, utils_1.load)(); 16 | } 17 | /** 18 | * Performs an HTTP request with native library. 19 | * @param {string} payload - The request payload to be sent. 20 | * @returns {Promise} - A promise resolving to the parsed TLS response object. 21 | * @throws {TlsClientError} - If no response is received from the client. 22 | */ 23 | async request(payload) { 24 | const response = this.client.request(payload); 25 | if (!response) 26 | throw new tlsError_1.TlsClientError("No response received."); 27 | return JSON.parse(response); 28 | } 29 | /** 30 | * Destroys all sessions and removes session cache from memory. 31 | * @param {string} payload 32 | * @returns {Promise} - A promise resolving to the session id. 33 | */ 34 | async destroySession(payload) { 35 | return this.client.destroySession(payload); 36 | } 37 | /** 38 | * Removes cache from memory. 39 | * @returns {Promise} 40 | */ 41 | async freeMemory(id) { 42 | if (!id) 43 | return; 44 | this.client.freeMemory(id); 45 | } 46 | } 47 | exports.Client = Client; 48 | -------------------------------------------------------------------------------- /dist/lib/Cookie.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.Cookies = void 0; 4 | const tough_cookie_1 = require("tough-cookie"); 5 | class Cookies extends tough_cookie_1.CookieJar { 6 | constructor() { 7 | super(); 8 | } 9 | /** 10 | * Fetches all cookies and organizes them by URL. 11 | * 12 | * This method serializes cookies and groups them by their domain and path, 13 | * constructing a URL as the key and an object of cookies as key-value pairs. 14 | * 15 | * @returns An object where keys are URLs and values are objects containing cookies as key-value pairs. 16 | * 17 | * @example 18 | * { 19 | * "https://example.com/": { 20 | * "cookie1": "value1", 21 | * "cookie2": "value2" 22 | * }, 23 | * "https://anotherdomain.com/": { 24 | * "cookieA": "valueA", 25 | * "cookieB": "valueB" 26 | * } 27 | * } 28 | */ 29 | fetchAllCookies() { 30 | const cookies = this.serializeSync().cookies; 31 | return cookies.reduce((acc, cookie) => { 32 | const url = `https://${cookie.domain}${cookie.path}`; 33 | if (!acc[url]) { 34 | acc[url] = {}; 35 | } 36 | acc[url][cookie.key] = cookie.value; 37 | return acc; 38 | }, {}); 39 | } 40 | /** 41 | * Fetches the cookies for a given URL as an object. 42 | * 43 | * @param url - The URL from which cookies are to be fetched. 44 | * @returns An object containing cookies as key-value pairs. 45 | * 46 | * @example 47 | * fetchCookiesObject('http://example.com') 48 | */ 49 | fetchCookiesObject(url) { 50 | return this.getCookiesSync(url).reduce((acc, cookie) => { 51 | acc[cookie.key] = cookie.value; 52 | return acc; 53 | }, {}); 54 | } 55 | /** 56 | * Fetches the cookies for a given URL as an array of objects. 57 | * Each object contains the name and value of a cookie. 58 | * 59 | * @param url - The URL from which cookies are to be fetched. 60 | * @returns An array of objects, each containing the name and value of a cookie. 61 | * 62 | * @example 63 | * fetchCookiesList('http://example.com') 64 | */ 65 | fetchCookiesList(url) { 66 | return this.getCookiesSync(url).map((cookie) => ({ 67 | name: cookie.key, 68 | value: cookie.value, 69 | })); 70 | } 71 | /** 72 | * Checks and sets cookies for a given URL. 73 | * 74 | * @param cookies - An object containing cookies as key-value pairs. 75 | * @param url - The URL for which cookies are to be set. 76 | * @returns An object containing cookies as key-value pairs. 77 | * 78 | * @example 79 | * syncCookies({ 'cookie1': 'value1', 'cookie2': 'value2' }, 'http://example.com') 80 | */ 81 | syncCookies(cookies, url) { 82 | if (!cookies) 83 | return this.fetchCookiesObject(url); 84 | for (const [key, value] of Object.entries(cookies)) { 85 | this.setCookieSync(`${key}=${value}`, url); 86 | } 87 | return this.fetchCookiesObject(url); 88 | } 89 | /** 90 | * Merges the provided cookies with the existing cookies for a given URL according to request payload. 91 | * 92 | * @param cookies - An object containing cookies as key-value pairs. 93 | * @param url - The URL for which cookies are to be set. 94 | * @returns An array of objects, each containing the name and value of a cookie. 95 | * 96 | * @example 97 | * mergeCookies({ 'cookie1': 'value1', 'cookie2': 'value2' }, 'http://example.com') 98 | */ 99 | mergeCookies(cookies, url) { 100 | for (const [key, value] of Object.entries(cookies)) { 101 | this.setCookieSync(`${key}=${value}`, url); 102 | } 103 | return this.fetchCookiesList(url); 104 | } 105 | } 106 | exports.Cookies = Cookies; 107 | -------------------------------------------------------------------------------- /dist/lib/Response.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.Response = void 0; 4 | class Response { 5 | response; 6 | // Indicates whether the response was successful (status in the range 200-299) or not. 7 | ok; 8 | // Represents the response headers. 9 | headers; 10 | // Represents the HTTP status code of the response. 11 | status; 12 | // Represents the URL of the response. 13 | url; 14 | constructor(response) { 15 | this.response = response; 16 | this.ok = response.status >= 200 && response.status < 300; 17 | this.headers = response.headers; 18 | this.status = response.status; 19 | this.url = response.target; 20 | } 21 | /** 22 | * Returns the body of the response as a string. 23 | * 24 | * @returns A promise that resolves with the body of the response as a string. 25 | */ 26 | async text() { 27 | return this.response.body.toString(); 28 | } 29 | /** 30 | * Returns the body of the response as a JSON object. 31 | * 32 | * @typeparam T - The type of the JSON object. 33 | * @returns A promise that resolves with the body of the response as a JSON object. 34 | */ 35 | async json() { 36 | return JSON.parse(this.response.body); 37 | } 38 | /** 39 | * Returns the cookies from the response as an object with key-value pairs. 40 | * 41 | * @returns An object containing cookies as key-value pairs. 42 | */ 43 | get cookies() { 44 | return this.response.cookies; 45 | } 46 | } 47 | exports.Response = Response; 48 | -------------------------------------------------------------------------------- /dist/lib/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | __exportStar(require("./Session"), exports); 18 | __exportStar(require("./Response"), exports); 19 | __exportStar(require("./Cookie"), exports); 20 | __exportStar(require("./requests"), exports); 21 | __exportStar(require("./Client"), exports); 22 | -------------------------------------------------------------------------------- /dist/lib/requests.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.fetch = void 0; 4 | const _1 = require("."); 5 | const utils_1 = require("../utils"); 6 | /** 7 | * Makes an HTTP request using the specified URL and options. 8 | * 9 | * @param {string} url - The URL to make the request to. 10 | * @param {fetchOptions} [options] - Optional parameters for the request. 11 | * @returns {Promise} The response from the HTTP request. 12 | * @throws Will throw an error if the HTTP request fails or the method is not allowed. 13 | */ 14 | async function fetch(url, options) { 15 | const session = new _1.Session(options?.options); 16 | const method = options?.method?.toUpperCase() || "GET"; 17 | try { 18 | await session.init(); 19 | let response; 20 | switch (method) { 21 | case "GET": 22 | response = await session.get(url, options); 23 | break; 24 | case "POST": 25 | response = await session.post(url, options); 26 | break; 27 | case "PUT": 28 | response = await session.put(url, options); 29 | break; 30 | case "DELETE": 31 | response = await session.delete(url, options); 32 | break; 33 | case "HEAD": 34 | response = await session.head(url, options); 35 | break; 36 | case "OPTIONS": 37 | response = await session.options(url, options); 38 | break; 39 | case "PATCH": 40 | response = await session.patch(url, options); 41 | break; 42 | default: 43 | throw new Error(`HTTP method ${method} is not allowed.`); 44 | } 45 | return response; 46 | } 47 | catch (error) { 48 | throw new utils_1.TlsClientError(error); 49 | } 50 | finally { 51 | await session.close(); 52 | } 53 | } 54 | exports.fetch = fetch; 55 | -------------------------------------------------------------------------------- /dist/utils/download.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { 14 | Object.defineProperty(o, "default", { enumerable: true, value: v }); 15 | }) : function(o, v) { 16 | o["default"] = v; 17 | }); 18 | var __importStar = (this && this.__importStar) || function (mod) { 19 | if (mod && mod.__esModule) return mod; 20 | var result = {}; 21 | if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); 22 | __setModuleDefault(result, mod); 23 | return result; 24 | }; 25 | var __importDefault = (this && this.__importDefault) || function (mod) { 26 | return (mod && mod.__esModule) ? mod : { "default": mod }; 27 | }; 28 | Object.defineProperty(exports, "__esModule", { value: true }); 29 | exports.Download = void 0; 30 | const logger_1 = require("./logger"); 31 | const https_1 = __importDefault(require("https")); 32 | const fs_1 = __importStar(require("fs")); 33 | class Download { 34 | file; 35 | path; 36 | issueURL = "https://github.com/Sahil1337/node-tls-client/issues"; 37 | constructor(file, libPath) { 38 | this.file = file; 39 | this.path = libPath; 40 | } 41 | async init() { 42 | try { 43 | const latest = await this.getLatest(); 44 | if (latest) { 45 | await this.extract(latest.browser_download_url); 46 | logger_1.logger.success("Extracted shared library."); 47 | } 48 | else { 49 | logger_1.logger.error(`Failed to find required asset: ${this.file.name}, report ${logger_1.logger.hyperlink("here", this.issueURL)}.`); 50 | } 51 | } 52 | catch (error) { 53 | logger_1.logger.error(`Initialization failed: ${error}`); 54 | } 55 | } 56 | formatBytes(bytes, decimals = 2) { 57 | if (bytes === 0) 58 | return "0 Bytes"; 59 | const k = 1024; 60 | const dm = decimals < 0 ? 0 : decimals; 61 | const sizes = ["Bytes", "KB", "MB", "GB", "TB"]; 62 | const i = Math.floor(Math.log(bytes) / Math.log(k)); 63 | return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i]; 64 | } 65 | progress(downloaded, total) { 66 | const percentage = (downloaded / total) * 100; 67 | const progress = Math.floor(percentage / 2); 68 | const bar = "█".repeat(progress) + " ".repeat(50 - progress); 69 | process.stdout.clearLine(0); 70 | process.stdout.cursorTo(0); 71 | process.stdout.write(`${logger_1.logger.stamp} DOWNLOADING:[${bar}] ${percentage.toFixed(2)}% (${this.formatBytes(downloaded)} / ${this.formatBytes(total)})`); 72 | } 73 | async download(url, file) { 74 | return new Promise((resolve, reject) => { 75 | https_1.default 76 | .get(url, (response) => { 77 | if (response.statusCode && 78 | response.statusCode >= 300 && 79 | response.statusCode < 400 && 80 | response.headers.location) { 81 | const newURL = new URL(response.headers.location, url).toString(); 82 | logger_1.logger.debug(`Fetched shared library ${logger_1.logger.hyperlink("url", newURL)}`); 83 | this.download(newURL, file).then(resolve).catch(reject); 84 | } 85 | else if (response.statusCode && 86 | response.statusCode >= 200 && 87 | response.statusCode < 300) { 88 | const totalBytes = parseInt(response.headers["content-length"] || "0", 10); 89 | let downloadedBytes = 0; 90 | response.pipe(file); 91 | response.on("data", (chunk) => { 92 | downloadedBytes += chunk.length; 93 | this.progress(downloadedBytes, totalBytes); 94 | }); 95 | response.on("end", () => { 96 | file.close((err) => { 97 | if (err) { 98 | reject(err); 99 | } 100 | else { 101 | process.stdout.write("\n"); 102 | resolve(); 103 | } 104 | }); 105 | }); 106 | file.on("error", (err) => { 107 | fs_1.default.unlink(this.path, () => reject(err)); 108 | }); 109 | } 110 | else { 111 | logger_1.logger.error(`Failed to download the file [statusCode:${response.statusCode}]`); 112 | reject(); 113 | } 114 | }) 115 | .on("error", (err) => { 116 | fs_1.default.unlink(this.path, () => reject(err)); 117 | }); 118 | }); 119 | } 120 | async extract(url) { 121 | return new Promise((resolve, reject) => { 122 | const file = (0, fs_1.createWriteStream)(this.path); 123 | this.download(url, file).then(resolve).catch(reject); 124 | }); 125 | } 126 | async getLatest() { 127 | return new Promise((resolve, reject) => { 128 | const options = { 129 | hostname: "api.github.com", 130 | path: "/repos/bogdanfinn/tls-client/releases/latest", 131 | method: "GET", 132 | headers: { 133 | "user-agent": "node-tls-client", 134 | }, 135 | }; 136 | https_1.default 137 | .get(options, (res) => { 138 | let data = ""; 139 | res.on("data", (chunk) => { 140 | data += chunk; 141 | }); 142 | res.on("end", () => { 143 | if (res.statusCode === 200) { 144 | try { 145 | const response = JSON.parse(data); 146 | const version = response.tag_name.replace("v", ""); 147 | logger_1.logger.debug(`Fetched latest version: v${version}`); 148 | const assetName = this.file.downloadName.replace("{version}", version); 149 | const asset = response.assets.find((asset) => asset.name === assetName); 150 | if (!asset) { 151 | logger_1.logger.error(`Failed to find required asset: ${this.file.name}, report ${logger_1.logger.hyperlink("here", this.issueURL)}.`); 152 | resolve(null); 153 | } 154 | else { 155 | resolve(asset); 156 | } 157 | } 158 | catch (err) { 159 | logger_1.logger.error(`Failed to parse response: ${err}`); 160 | resolve(null); 161 | } 162 | } 163 | else { 164 | logger_1.logger.error(`Failed to fetch the latest version. Status code: ${res.statusCode}`); 165 | resolve(null); 166 | } 167 | }); 168 | }) 169 | .on("error", (err) => { 170 | logger_1.logger.error(`Failed to fetch the latest version: ${err}`); 171 | resolve(null); 172 | }); 173 | }); 174 | } 175 | } 176 | exports.Download = Download; 177 | -------------------------------------------------------------------------------- /dist/utils/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | var desc = Object.getOwnPropertyDescriptor(m, k); 5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 6 | desc = { enumerable: true, get: function() { return m[k]; } }; 7 | } 8 | Object.defineProperty(o, k2, desc); 9 | }) : (function(o, m, k, k2) { 10 | if (k2 === undefined) k2 = k; 11 | o[k2] = m[k]; 12 | })); 13 | var __exportStar = (this && this.__exportStar) || function(m, exports) { 14 | for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); 15 | }; 16 | Object.defineProperty(exports, "__esModule", { value: true }); 17 | __exportStar(require("./download"), exports); 18 | __exportStar(require("./koffi"), exports); 19 | __exportStar(require("./logger"), exports); 20 | __exportStar(require("./request"), exports); 21 | __exportStar(require("./download"), exports); 22 | __exportStar(require("./tlsError"), exports); 23 | -------------------------------------------------------------------------------- /dist/utils/koffi.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __importDefault = (this && this.__importDefault) || function (mod) { 3 | return (mod && mod.__esModule) ? mod : { "default": mod }; 4 | }; 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | exports.load = void 0; 7 | const path_1 = __importDefault(require("path")); 8 | const fs_1 = __importDefault(require("fs")); 9 | const os_1 = __importDefault(require("os")); 10 | const koffi_1 = require("koffi"); 11 | const download_1 = require("./download"); 12 | /** 13 | * Downloads and loads the native library. 14 | * @returns {Promise} 15 | */ 16 | async function load() { 17 | const file = fileInfo(); 18 | const temp = os_1.default.tmpdir(); 19 | const libraryPath = path_1.default.join(temp, file.name); 20 | if (!fs_1.default.existsSync(libraryPath)) { 21 | const downloader = new download_1.Download(file, libraryPath); 22 | await downloader.init(); 23 | } 24 | const lib = (0, koffi_1.load)(libraryPath); 25 | return { 26 | request: lib.func("request", "string", ["string"]), 27 | freeMemory: lib.func("freeMemory", "void", ["string"]), 28 | destroyAll: lib.func("destroyAll", "string", []), 29 | destroySession: lib.func("destroySession", "string", ["string"]), 30 | }; 31 | } 32 | exports.load = load; 33 | function fileInfo() { 34 | const platform = process.platform; 35 | const arch = process.arch; 36 | const map = { 37 | darwin: { 38 | arm64: { 39 | name: "tls-client-arm64.dylib", 40 | downloadName: "tls-client-darwin-arm64-{version}.dylib", 41 | }, 42 | x64: { 43 | name: "tls-client-x86.dylib", 44 | downloadName: "tls-client-darwin-amd64-{version}.dylib", 45 | }, 46 | }, 47 | win32: { 48 | x64: { 49 | name: "tls-client-64.dll", 50 | downloadName: "tls-client-windows-64-{version}.dll", 51 | }, 52 | ia32: { 53 | name: "tls-client-32.dll", 54 | downloadName: "tls-client-windows-32-{version}.dll", 55 | }, 56 | }, 57 | linux: { 58 | arm64: { 59 | name: "tls-client-arm64.so", 60 | downloadName: "tls-client-linux-arm64-{version}.so", 61 | }, 62 | x64: { 63 | name: "tls-client-x64.so", 64 | downloadName: "tls-client-linux-ubuntu-amd64-{version}.so", 65 | }, 66 | default: { 67 | name: "tls-client-amd64.so", 68 | downloadName: "tls-client-linux-ubuntu-amd64-{version}.so", 69 | }, 70 | }, 71 | }; 72 | return map[platform]?.[arch] || map.linux.default; 73 | } 74 | -------------------------------------------------------------------------------- /dist/utils/logger.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.logger = void 0; 4 | const colors = { 5 | reset: "\x1b[0m", 6 | blue: "\x1b[34m", 7 | red: "\x1b[31m", 8 | green: "\x1b[32m", 9 | cyan: "\x1b[36m", 10 | }; 11 | /** 12 | * Logger utility. 13 | * 14 | * @property {Function} debug - Logs a debug message. 15 | * @property {Function} error - Logs an error message. 16 | * @property {Function} success - Logs a success message. 17 | * @property {Function} hyperlink - Generates a clickable hyperlink. 18 | */ 19 | exports.logger = { 20 | debug: function (...args) { 21 | return process.stdout.write(`${colors.cyan}@node-tls-client ~ ${colors.blue}DEBUG:${colors.reset} ${args.join(" ")}\n`); 22 | }, 23 | error: function (...args) { 24 | return process.stdout.write(`${colors.cyan}@node-tls-client ~ ${colors.red}ERROR:${colors.reset} ${args.join(" ")}\n`); 25 | }, 26 | success: function (...args) { 27 | return process.stdout.write(`${colors.cyan}@node-tls-client ~ ${colors.green}SUCCESS:${colors.reset} ${args.join(" ")}\n`); 28 | }, 29 | hyperlink: function (text, url) { 30 | return `\x1b]8;;${url}\x1b\\${text}\x1b]8;;\x1b\\`; 31 | }, 32 | stamp: `${colors.cyan}@node-tls-client ~${colors.reset}`, 33 | }; 34 | -------------------------------------------------------------------------------- /dist/utils/request.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.isByteRequest = void 0; 4 | const exactContentTypes = new Set([ 5 | "application/octet-stream", 6 | "application/pdf", 7 | "application/zip", 8 | "application/gzip", 9 | "application/x-rar-compressed", 10 | "application/x-msdownload", 11 | "application/x-sh", 12 | "application/x-binary", 13 | "base64", 14 | ]); 15 | const prefixContentTypes = new Set([ 16 | "image/", 17 | "audio/", 18 | "video/", 19 | "application/vnd.", 20 | ]); 21 | /** 22 | * Determines if a request should be treated as a byte request based on its headers. 23 | * 24 | * This function checks the "Content-Type" and "Content-Transfer-Encoding" headers 25 | * to determine if the request is for binary data (such as images, audio, video, 26 | * application binaries, etc.). If the headers indicate binary data, it returns true. 27 | * 28 | * @param {OutgoingHttpHeaders} headers - The headers of the request. 29 | * @returns {boolean} - Returns true if the request is for binary data, otherwise false. 30 | */ 31 | function isByteRequest(headers) { 32 | const contentType = headers["content-type"] || headers["Content-Type"]; 33 | const contentTransferEncoding = headers["content-transfer-encoding"] || 34 | headers["Content-Transfer-Encoding"]; 35 | if (contentTransferEncoding) { 36 | const encodingString = String(contentTransferEncoding); 37 | if (exactContentTypes.has(encodingString)) { 38 | return true; 39 | } 40 | } 41 | if (contentType) { 42 | const contentTypeString = String(contentType); 43 | if (exactContentTypes.has(contentTypeString)) { 44 | return true; 45 | } 46 | for (const prefix of prefixContentTypes) { 47 | if (contentTypeString.startsWith(prefix)) { 48 | return true; 49 | } 50 | } 51 | } 52 | return false; 53 | } 54 | exports.isByteRequest = isByteRequest; 55 | -------------------------------------------------------------------------------- /dist/utils/tlsError.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.TlsClientError = void 0; 4 | class TlsClientError extends Error { 5 | constructor(message) { 6 | super(message instanceof Error ? message.message : message); 7 | if (message instanceof Error && message.stack) { 8 | this.stack = message.stack; 9 | } 10 | this.name = "TlsClientError"; 11 | Object.setPrototypeOf(this, new.target.prototype); 12 | } 13 | } 14 | exports.TlsClientError = TlsClientError; 15 | -------------------------------------------------------------------------------- /dist/utils/worker.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __importDefault = (this && this.__importDefault) || function (mod) { 3 | return (mod && mod.__esModule) ? mod : { "default": mod }; 4 | }; 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | const workerpool_1 = __importDefault(require("workerpool")); 7 | const lib_1 = require("../lib"); 8 | const client = new lib_1.Client(); 9 | /** 10 | * Initialize the client 11 | */ 12 | client.init().then(() => { 13 | workerpool_1.default.worker({ 14 | request: client.request.bind(client), 15 | destroySession: client.destroySession.bind(client), 16 | freeMemory: client.freeMemory.bind(client), 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /docs/.nojekyll: -------------------------------------------------------------------------------- 1 | TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false. -------------------------------------------------------------------------------- /docs/assets/highlight.css: -------------------------------------------------------------------------------- 1 | :root { 2 | --light-hl-0: #795E26; 3 | --dark-hl-0: #DCDCAA; 4 | --light-hl-1: #000000; 5 | --dark-hl-1: #D4D4D4; 6 | --light-hl-2: #A31515; 7 | --dark-hl-2: #CE9178; 8 | --light-hl-3: #008000; 9 | --dark-hl-3: #6A9955; 10 | --light-hl-4: #0000FF; 11 | --dark-hl-4: #569CD6; 12 | --light-hl-5: #0070C1; 13 | --dark-hl-5: #4FC1FF; 14 | --light-hl-6: #267F99; 15 | --dark-hl-6: #4EC9B0; 16 | --light-hl-7: #001080; 17 | --dark-hl-7: #9CDCFE; 18 | --light-hl-8: #098658; 19 | --dark-hl-8: #B5CEA8; 20 | --light-hl-9: #AF00DB; 21 | --dark-hl-9: #C586C0; 22 | --light-code-background: #FFFFFF; 23 | --dark-code-background: #1E1E1E; 24 | } 25 | 26 | @media (prefers-color-scheme: light) { :root { 27 | --hl-0: var(--light-hl-0); 28 | --hl-1: var(--light-hl-1); 29 | --hl-2: var(--light-hl-2); 30 | --hl-3: var(--light-hl-3); 31 | --hl-4: var(--light-hl-4); 32 | --hl-5: var(--light-hl-5); 33 | --hl-6: var(--light-hl-6); 34 | --hl-7: var(--light-hl-7); 35 | --hl-8: var(--light-hl-8); 36 | --hl-9: var(--light-hl-9); 37 | --code-background: var(--light-code-background); 38 | } } 39 | 40 | @media (prefers-color-scheme: dark) { :root { 41 | --hl-0: var(--dark-hl-0); 42 | --hl-1: var(--dark-hl-1); 43 | --hl-2: var(--dark-hl-2); 44 | --hl-3: var(--dark-hl-3); 45 | --hl-4: var(--dark-hl-4); 46 | --hl-5: var(--dark-hl-5); 47 | --hl-6: var(--dark-hl-6); 48 | --hl-7: var(--dark-hl-7); 49 | --hl-8: var(--dark-hl-8); 50 | --hl-9: var(--dark-hl-9); 51 | --code-background: var(--dark-code-background); 52 | } } 53 | 54 | :root[data-theme='light'] { 55 | --hl-0: var(--light-hl-0); 56 | --hl-1: var(--light-hl-1); 57 | --hl-2: var(--light-hl-2); 58 | --hl-3: var(--light-hl-3); 59 | --hl-4: var(--light-hl-4); 60 | --hl-5: var(--light-hl-5); 61 | --hl-6: var(--light-hl-6); 62 | --hl-7: var(--light-hl-7); 63 | --hl-8: var(--light-hl-8); 64 | --hl-9: var(--light-hl-9); 65 | --code-background: var(--light-code-background); 66 | } 67 | 68 | :root[data-theme='dark'] { 69 | --hl-0: var(--dark-hl-0); 70 | --hl-1: var(--dark-hl-1); 71 | --hl-2: var(--dark-hl-2); 72 | --hl-3: var(--dark-hl-3); 73 | --hl-4: var(--dark-hl-4); 74 | --hl-5: var(--dark-hl-5); 75 | --hl-6: var(--dark-hl-6); 76 | --hl-7: var(--dark-hl-7); 77 | --hl-8: var(--dark-hl-8); 78 | --hl-9: var(--dark-hl-9); 79 | --code-background: var(--dark-code-background); 80 | } 81 | 82 | .hl-0 { color: var(--hl-0); } 83 | .hl-1 { color: var(--hl-1); } 84 | .hl-2 { color: var(--hl-2); } 85 | .hl-3 { color: var(--hl-3); } 86 | .hl-4 { color: var(--hl-4); } 87 | .hl-5 { color: var(--hl-5); } 88 | .hl-6 { color: var(--hl-6); } 89 | .hl-7 { color: var(--hl-7); } 90 | .hl-8 { color: var(--hl-8); } 91 | .hl-9 { color: var(--hl-9); } 92 | pre, code { background: var(--code-background); } 93 | -------------------------------------------------------------------------------- /docs/assets/navigation.js: -------------------------------------------------------------------------------- 1 | window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAAA43VXU/CMBQG4P+ya6JCBD/udEYlxkCY8cZ40WwH1rC1sz01EsN/dzDI2nUeesMF532fdexkfPxGCD8Y3UZxwUHgNKs/+JKDigZRxTCvJyBMqc+787Mcy6IOrbnIotvr7aAjtf20YFrDUXB7w5HTlHLNQfdUmwHVXYCupNDgl48Tqp2A1lwKv3wYUN17pmEBXwY0ziqsw9YNcIGgliytJT/moqPxxEIfoAAMYfuCFPwEGKB6KYp8HiWAyMWq32rHJAIsCziYH6PQaXcXLWnat49u/XCFgGP1Jil6zjDNA+CeHMlKHfJ4/RiJKi4Vx82jYiX8AzqREGzO6ihp7RMkZYLutZuiyAAvHDu8OyjMjVDYW6H9V5wlWXOKWUK9T9SJ7AAFxaAwlmWlmju4K1ay9XBT7d7afqQjXtxcDccjS32BTZIzBbFR3/aqNaA7PWW9AuYy85DD16facw0mk7vXDaiZyuw/xMbxAqfExFSVVAhZwleCoVGw+0XqTc9L75BUNvg676C0+5w7+DFwStzvRKssjUj3+9Esi9ueXG4//wBlZOLxVggAAA==" -------------------------------------------------------------------------------- /docs/assets/search.js: -------------------------------------------------------------------------------- 1 | window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAAA61dXZPbOK79L92vvVkT+p637Ez2T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N2v18kLIYtjrAvxAuzJhA38NpLzDH4uM+kUqpttFzY40MIYr/rfgbntK1L8zM41+t73AnO2xuRNAAuP1KMF6iYtFYm+mAeIgODWUgrs2mi0nM/MQ+5WZmfN+UW0pA+32CKF514MjVLJMilzuw65oGLJpB9YI5fxNb2u1lWiQVmvXpYHTdLlSxTu4rCFJyIiNFOl/b+MHJfzA29blu+JUubWUblgLjatfVtdhllg1iqBbA+8R9ndfHED9bPiD7qk+JJH6yfE33MHEjdx+gfVuurAOCtOXFLj9sOwycSQOx4vaa9DMuR0+bcDqgzdSnC0LXFjIIcRVGkYMy9+ngY4jlZnfkzaTbo1tLr8mA3ggegU5MwT5hukxYf598NrM0PGa7QDxmiUg5Vcn3CP/Mk4rAybX8+/yYhCimKaN/gOeuKYH/d37OLdjyTiCWT+dliHFqsKO4zdlf/48SGeXlx1Xv+eSg0y+DDbwvDsIrjqpmx2MRqHf9aSNC2P8OAvcabEWJpp39p+XD+pWVsFDMjShoEv5WbT48kWniKFtR+X231HO1YkiYodGJ1a5oRVqUobHy98cvdzWFzKLebfSP04Zc///x/TJd8zQ3mAAA="; -------------------------------------------------------------------------------- /docs/functions/fetch.html: -------------------------------------------------------------------------------- 1 | fetch | node-tls-client

Function fetch

  • Makes an HTTP request using the specified URL and options.

    2 |

    Parameters

    • url: string

      The URL to make the request to.

      3 |
    • Optional options: fetchOptions

      Optional parameters for the request.

      4 |

    Returns Promise<Response>

    The response from the HTTP request.

    5 |

    Throws

    Will throw an error if the HTTP request fails or the method is not allowed.

    6 |
-------------------------------------------------------------------------------- /docs/hierarchy.html: -------------------------------------------------------------------------------- 1 | node-tls-client
-------------------------------------------------------------------------------- /docs/interfaces/IClient.html: -------------------------------------------------------------------------------- 1 | IClient | node-tls-client

Interface IClient

interface IClient {
    destroyAll: KoffiFunction;
    destroySession: KoffiFunction;
    freeMemory: KoffiFunction;
    request: KoffiFunction;
}

Properties

Properties

destroyAll: KoffiFunction
destroySession: KoffiFunction
freeMemory: KoffiFunction
request: KoffiFunction
-------------------------------------------------------------------------------- /docs/interfaces/PriorityFrames.html: -------------------------------------------------------------------------------- 1 | PriorityFrames | node-tls-client

Interface PriorityFrames

Represents priority frames for HTTP/2 streams.

2 |
interface PriorityFrames {
    priorityParam: PriorityParam;
    streamID: number;
}

Properties

Properties

priorityParam: PriorityParam

The parameters for priority settings.

5 |
streamID: number

The stream ID for which priority is set.

6 |
-------------------------------------------------------------------------------- /docs/interfaces/PriorityParam.html: -------------------------------------------------------------------------------- 1 | PriorityParam | node-tls-client

Interface PriorityParam

Represents parameters for setting priority of HTTP/2 streams.

2 |
interface PriorityParam {
    exclusive: boolean;
    streamDep: number;
    weight: number;
}

Properties

Properties

exclusive: boolean

Indicates whether the priority is exclusive.

6 |
streamDep: number

The stream dependency for priority.

7 |
weight: number

The weight of the priority.

8 |
-------------------------------------------------------------------------------- /docs/modules.html: -------------------------------------------------------------------------------- 1 | node-tls-client
-------------------------------------------------------------------------------- /docs/types/CertCompressionAlgo.html: -------------------------------------------------------------------------------- 1 | CertCompressionAlgo | node-tls-client

Type alias CertCompressionAlgo

CertCompressionAlgo: "zlib" | "brotli" | "zstd"

Represents various certificate compression algorithms.

2 |
-------------------------------------------------------------------------------- /docs/types/KeyShareCurves.html: -------------------------------------------------------------------------------- 1 | KeyShareCurves | node-tls-client

Type alias KeyShareCurves

KeyShareCurves: "GREASE" | "P256" | "P384" | "P521" | "X25519" | "P256Kyber768" | "X25519Kyber512D" | "X25519Kyber768"

Represents various supported elliptic curves for key exchange.

2 |
-------------------------------------------------------------------------------- /docs/types/Methods.html: -------------------------------------------------------------------------------- 1 | Methods | node-tls-client

Type alias Methods

Methods: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "OPTIONS" | "HEAD"

Represents various HTTP methods.

2 |
-------------------------------------------------------------------------------- /docs/types/PseudoHeaderOrder.html: -------------------------------------------------------------------------------- 1 | PseudoHeaderOrder | node-tls-client

Type alias PseudoHeaderOrder

PseudoHeaderOrder: ":method" | ":authority" | ":scheme" | ":path"

Represents the order of pseudo headers in HTTP/2 requests.

2 |
-------------------------------------------------------------------------------- /docs/types/SupportedSignatureAlgorithms.html: -------------------------------------------------------------------------------- 1 | SupportedSignatureAlgorithms | node-tls-client

Type alias SupportedSignatureAlgorithms

SupportedSignatureAlgorithms: "PKCS1WithSHA256" | "PKCS1WithSHA384" | "PKCS1WithSHA512" | "PSSWithSHA256" | "PSSWithSHA384" | "PSSWithSHA512" | "ECDSAWithP256AndSHA256" | "ECDSAWithP384AndSHA384" | "ECDSAWithP521AndSHA512" | "PKCS1WithSHA1" | "ECDSAWithSHA1" | "Ed25519"

Represents various supported signature algorithms for TLS.

2 |
-------------------------------------------------------------------------------- /docs/types/SupportedVersions.html: -------------------------------------------------------------------------------- 1 | SupportedVersions | node-tls-client

Type alias SupportedVersions

SupportedVersions: "GREASE" | "1.3" | "1.2" | "1.1" | "1.0"

Represents various supported versions of TLS.

2 |
-------------------------------------------------------------------------------- /examples/advanced.js: -------------------------------------------------------------------------------- 1 | const { Session } = require("node-tls-client"); 2 | 3 | /** 4 | * @description Demonstrates an advanced usage scenario with the node-tls-client library, showcasing custom TLS client configuration. 5 | * 6 | * This example illustrates the creation of a TLS session with tailored settings and the execution of a GET request. 7 | * 8 | * Custom TLS settings encompass a wide array of configurations, including: 9 | * - JA3 string specification 10 | * - Fine-tuning HTTP/2 settings 11 | * - Defining supported signature algorithms 12 | * - Specifying ALPN (Application-Layer Protocol Negotiation) protocols 13 | * - Declaring supported TLS versions 14 | * - Setting key share curves for cryptographic key exchange 15 | * - Choosing a certificate compression algorithm 16 | * - Configuring connection and header flow parameters 17 | * - Defining the order of headers and priority frames 18 | * - Providing default headers for HTTP requests 19 | * 20 | * @see {@link https://sahil1337.github.io/node-tls-client/interfaces/SessionOptions.html SessionOptions} for more details on session options. 21 | */ 22 | 23 | (async () => { 24 | const session = new Session({ 25 | ja3string: 26 | "771,2570-4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,2570-0-23-65281-10-11-35-16-5-13-18-51-45-43-27-17513-2570-21,2570-29-23-24,0", 27 | h2Settings: { 28 | HEADER_TABLE_SIZE: 65536, 29 | MAX_CONCURRENT_STREAMS: 1000, 30 | INITIAL_WINDOW_SIZE: 6291456, 31 | MAX_HEADER_LIST_SIZE: 262144, 32 | }, 33 | h2SettingsOrder: [ 34 | "HEADER_TABLE_SIZE", 35 | "MAX_CONCURRENT_STREAMS", 36 | "INITIAL_WINDOW_SIZE", 37 | "MAX_HEADER_LIST_SIZE", 38 | ], 39 | supportedSignatureAlgorithms: [ 40 | "ECDSAWithP256AndSHA256", 41 | "PSSWithSHA256", 42 | "PKCS1WithSHA256", 43 | "ECDSAWithP384AndSHA384", 44 | "PSSWithSHA384", 45 | "PKCS1WithSHA384", 46 | "PSSWithSHA512", 47 | "PKCS1WithSHA512", 48 | ], 49 | alpnProtocols: ["h2", "http/1.1"], 50 | alpsProtocols: ["h2"], 51 | supportedVersions: ["GREASE", "1.3", "1.2"], 52 | keyShareCurves: ["GREASE", "X25519"], 53 | certCompressionAlgo: "brotli", 54 | pseudoHeaderOrder: [":method", ":authority", ":scheme", ":path"], 55 | connectionFlow: 15663105, 56 | headerOrder: ["accept", "user-agent", "accept-encoding", "accept-language"], 57 | priorityFrames: [ 58 | { 59 | streamID: 1, 60 | priorityParam: { 61 | streamDep: 1, 62 | exclusive: true, 63 | weight: 1, 64 | }, 65 | }, 66 | ], 67 | headerPriority: { 68 | streamDep: 1, 69 | exclusive: true, 70 | weight: 1, 71 | }, 72 | headers: { 73 | accept: 74 | "application/json,text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", 75 | "user-agent": 76 | "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36", 77 | "accept-encoding": "gzip, deflate, br", 78 | "accept-language": "de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7", 79 | }, 80 | }); 81 | 82 | //Initialize the session 83 | await session.init(); 84 | 85 | const response = await session.get("http://localhost:3000/"); 86 | console.log(response.status, await response.text()); 87 | await session.close(); 88 | })(); 89 | -------------------------------------------------------------------------------- /examples/extra.js: -------------------------------------------------------------------------------- 1 | const { Session, ClientIdentifier } = require("node-tls-client"); 2 | 3 | (async () => { 4 | const session = new Session({ 5 | clientIdentifier: ClientIdentifier.chrome_120, //client identifier 6 | timeout: 30 * 1000, //timeout in *milliseconds*, applies for each requests, checkout examples/timeout.js for using different timeouts. 7 | insecureSkipVerify: false, 8 | }); 9 | 10 | await session.init(); 11 | 12 | const response = await session.get("https://example.com", { 13 | proxy: `http://user:pass@ip:port`, //proxy format: http://user:pass@ip:port or http://ip:port 14 | cookies: { parameter: "value" }, //cookies 15 | redirect: true, //follow redirected urls 16 | headers: { authorization: "test" }, //request headers 17 | }); 18 | 19 | console.log(response.status); 20 | 21 | await session.close(); 22 | })(); 23 | -------------------------------------------------------------------------------- /examples/images.js: -------------------------------------------------------------------------------- 1 | const { Session, ClientIdentifier } = require("node-tls-client"); 2 | const fs = require("fs"); 3 | 4 | /** 5 | * @description Demonstrates a example for downloading images. 6 | * 7 | * @important 8 | * Ensure you specify `byteResponse: true` in the options to receive image data in base64 format. 9 | * This is necessary only for receiving image data, not for sending byte data in requests, which is handled internally. 10 | * 11 | * @see {@link https://sahil1337.github.io/node-tls-client/interfaces/SessionOptions.html SessionOptions} for more details. 12 | */ 13 | (async () => { 14 | const session = new Session({ 15 | clientIdentifier: ClientIdentifier.chrome_103, 16 | }); 17 | 18 | await session.init(); 19 | 20 | const avatarURI = "https://avatars.githubusercontent.com/u/69236315?v=4"; 21 | 22 | try { 23 | const avatarRes = await session.get(avatarURI, { byteResponse: true }); 24 | 25 | const avatarResText = await avatarRes.text(); 26 | const avatarBase64 = avatarResText.replace(/^data:image\/\w+;base64,/, ""); 27 | 28 | fs.writeFileSync("avatar.png", avatarBase64, "base64"); 29 | } catch (error) { 30 | console.error("An error occurred:", error); 31 | } finally { 32 | await session.close(); 33 | } 34 | })(); 35 | -------------------------------------------------------------------------------- /examples/samples/cookie-example.md: -------------------------------------------------------------------------------- 1 | # Example: session.cookies 2 | 3 | ## Retrieving all session cookies 4 | ```javascript 5 | const session = new Session(); 6 | await session.init(); 7 | const request1 = await session.get("https://website.com") 8 | const request2 = await session.get("https://website.com") 9 | const request3 = await session.get("https://example.com") 10 | const request4 = await session.get("https://example.com") 11 | console.log(session.cookies); 12 | ``` 13 | 14 | ## Cookies Response Example 15 | ```json 16 | { 17 | "https://website.com/": { 18 | cookie1: "value1", 19 | cookie2: "value2", 20 | cookie3: "value3", 21 | cookie4: "value4", 22 | }, 23 | "https://example.com/": { 24 | cookie1: "value1", 25 | cookie2: "value2", 26 | }, 27 | } 28 | ``` -------------------------------------------------------------------------------- /examples/simple.js: -------------------------------------------------------------------------------- 1 | const { Session, ClientIdentifier } = require("node-tls-client"); 2 | 3 | /** 4 | * @description Demonstrates using the node-tls-client library to make HTTP requests with a specified timeout. 5 | * Note: The timeout is set per session and cannot be changed during the session. 6 | * 7 | * @see {@link https://sahil1337.github.io/node-tls-client/interfaces/SessionOptions.html SessionOptions} for more details. 8 | */ 9 | (async () => { 10 | const session = new Session({ 11 | clientIdentifier: ClientIdentifier.chrome_103, 12 | timeout: 3000, 13 | }); 14 | 15 | try { 16 | await session.init(); 17 | 18 | const response = await session.get("https://website.com/"); 19 | 20 | console.log(response.status, await response.text()); 21 | } catch (error) { 22 | console.error("An error occurred:", error); 23 | } finally { 24 | await session.close(); 25 | } 26 | })(); 27 | -------------------------------------------------------------------------------- /examples/timeout.js: -------------------------------------------------------------------------------- 1 | const { fetch, ClientIdentifier } = require("node-tls-client"); 2 | 3 | /** 4 | * @description Demonstrates using the node-tls-client library to make HTTP requests with different timeouts. 5 | * 6 | * The `fetch` method in the node-tls-client library creates a new session with the provided options 7 | * and closes the session after the request ends. As a result, session cookies and cache won't be 8 | * automatically cached across multiple requests. 9 | * 10 | * This example shows how to make two HTTP requests with different timeout settings. 11 | * Checkout docs for fetchOptions information. 12 | */ 13 | (async () => { 14 | const response1 = await fetch("https://example.com", { 15 | options: { timeout: 3000, clientIdentifier: ClientIdentifier.chrome_110 }, 16 | }); 17 | console.log("Response 1:", await response1.text()); 18 | 19 | // Making the second request with a 6000ms timeout and a specific client identifier 20 | const response2 = await fetch("https://example.com", { 21 | options: { timeout: 6000, clientIdentifier: ClientIdentifier.chrome_110 }, //options: SessionOptions 22 | }); 23 | console.log("Response 2:", await response2.text()); 24 | })(); 25 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node-tls-client", 3 | "version": "2.0.0", 4 | "description": "Advanced library based on node-fetch and tls-client.", 5 | "main": "dist/index.js", 6 | "typings": "typings/index.d.ts", 7 | "repository": "https://github.com/Sahil1337/node-tls-client", 8 | "author": "Sahil1337", 9 | "license": "GPL-3.0", 10 | "private": false, 11 | "scripts": { 12 | "build": "tsc", 13 | "docs": "typedoc --out docs src/index.ts" 14 | }, 15 | "keywords": [ 16 | "tls-client", 17 | "node-tls-client", 18 | "javascript", 19 | "typescript", 20 | "tls client", 21 | "tls", 22 | "cloudflare" 23 | ], 24 | "devDependencies": { 25 | "@types/node": "^20.12.12", 26 | "@types/tough-cookie": "^4.0.5", 27 | "typedoc": "^0.25.13", 28 | "typescript": "^5.4.5" 29 | }, 30 | "dependencies": { 31 | "koffi": "^2.8.9", 32 | "tough-cookie": "^4.1.4", 33 | "tslib": "^2.6.2", 34 | "workerpool": "^9.2.0" 35 | }, 36 | "files": [ 37 | "dist", 38 | "typings" 39 | ] 40 | } 41 | -------------------------------------------------------------------------------- /src/decorators/client.ts: -------------------------------------------------------------------------------- 1 | import { TlsClientError } from "../utils/tlsError"; 2 | 3 | export function verifyClientState() { 4 | return function ( 5 | target: any, 6 | propertyKey: string, 7 | descriptor: PropertyDescriptor 8 | ) { 9 | const method = descriptor.value; 10 | 11 | descriptor.value = function (...args: any[]) { 12 | if ("isReady" in this && this.isReady && "pool" in this && this.pool) { 13 | return method.apply(this, args); 14 | } else { 15 | throw new TlsClientError("Client is not yet ready."); 16 | } 17 | }; 18 | 19 | return descriptor; 20 | }; 21 | } 22 | -------------------------------------------------------------------------------- /src/decorators/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./client"; 2 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./interface"; 2 | export * from "./lib"; 3 | -------------------------------------------------------------------------------- /src/interface/client.ts: -------------------------------------------------------------------------------- 1 | import { KoffiFunction } from "koffi"; 2 | 3 | export interface IClient { 4 | request: KoffiFunction; 5 | freeMemory: KoffiFunction; 6 | destroyAll: KoffiFunction; 7 | destroySession: KoffiFunction; 8 | } 9 | -------------------------------------------------------------------------------- /src/interface/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./session"; 2 | export * from "./client"; 3 | -------------------------------------------------------------------------------- /src/lib/Client.ts: -------------------------------------------------------------------------------- 1 | import { load } from "../utils"; 2 | import { IClient, TlsResponse } from "../interface"; 3 | import { TlsClientError } from "../utils/tlsError"; 4 | 5 | export class Client { 6 | private client: IClient; 7 | 8 | constructor() { 9 | this.client = {} as IClient; 10 | } 11 | 12 | /** 13 | * Intialize the client and load the native library. 14 | */ 15 | async init(): Promise { 16 | this.client = await load(); 17 | } 18 | 19 | /** 20 | * Performs an HTTP request with native library. 21 | * @param {string} payload - The request payload to be sent. 22 | * @returns {Promise} - A promise resolving to the parsed TLS response object. 23 | * @throws {TlsClientError} - If no response is received from the client. 24 | */ 25 | async request(payload: string): Promise { 26 | const response = this.client.request(payload); 27 | if (!response) throw new TlsClientError("No response received."); 28 | return JSON.parse(response); 29 | } 30 | 31 | /** 32 | * Destroys all sessions and removes session cache from memory. 33 | * @param {string} payload 34 | * @returns {Promise} - A promise resolving to the session id. 35 | */ 36 | async destroySession(payload: string): Promise { 37 | return this.client.destroySession(payload); 38 | } 39 | 40 | /** 41 | * Removes cache from memory. 42 | * @returns {Promise} 43 | */ 44 | async freeMemory(id: string): Promise { 45 | if (!id) return; 46 | this.client.freeMemory(id); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/lib/Cookie.ts: -------------------------------------------------------------------------------- 1 | import { CookieJar } from "tough-cookie"; 2 | 3 | export class Cookies extends CookieJar { 4 | constructor() { 5 | super(); 6 | } 7 | 8 | /** 9 | * Fetches all cookies and organizes them by URL. 10 | * 11 | * This method serializes cookies and groups them by their domain and path, 12 | * constructing a URL as the key and an object of cookies as key-value pairs. 13 | * 14 | * @returns An object where keys are URLs and values are objects containing cookies as key-value pairs. 15 | * 16 | * @example 17 | * { 18 | * "https://example.com/": { 19 | * "cookie1": "value1", 20 | * "cookie2": "value2" 21 | * }, 22 | * "https://anotherdomain.com/": { 23 | * "cookieA": "valueA", 24 | * "cookieB": "valueB" 25 | * } 26 | * } 27 | */ 28 | public fetchAllCookies() { 29 | const cookies = this.serializeSync().cookies; 30 | 31 | return cookies.reduce((acc, cookie) => { 32 | const url = `https://${cookie.domain}${cookie.path}`; 33 | if (!acc[url]) { 34 | acc[url] = {}; 35 | } 36 | acc[url][cookie.key] = cookie.value; 37 | return acc; 38 | }, {}); 39 | } 40 | 41 | /** 42 | * Fetches the cookies for a given URL as an object. 43 | * 44 | * @param url - The URL from which cookies are to be fetched. 45 | * @returns An object containing cookies as key-value pairs. 46 | * 47 | * @example 48 | * fetchCookiesObject('http://example.com') 49 | */ 50 | public fetchCookiesObject(url: string): Record { 51 | return this.getCookiesSync(url).reduce((acc, cookie) => { 52 | acc[cookie.key] = cookie.value; 53 | return acc; 54 | }, {} as Record); 55 | } 56 | 57 | /** 58 | * Fetches the cookies for a given URL as an array of objects. 59 | * Each object contains the name and value of a cookie. 60 | * 61 | * @param url - The URL from which cookies are to be fetched. 62 | * @returns An array of objects, each containing the name and value of a cookie. 63 | * 64 | * @example 65 | * fetchCookiesList('http://example.com') 66 | */ 67 | public fetchCookiesList(url: string) { 68 | return this.getCookiesSync(url).map((cookie) => ({ 69 | name: cookie.key, 70 | value: cookie.value, 71 | })); 72 | } 73 | 74 | /** 75 | * Checks and sets cookies for a given URL. 76 | * 77 | * @param cookies - An object containing cookies as key-value pairs. 78 | * @param url - The URL for which cookies are to be set. 79 | * @returns An object containing cookies as key-value pairs. 80 | * 81 | * @example 82 | * syncCookies({ 'cookie1': 'value1', 'cookie2': 'value2' }, 'http://example.com') 83 | */ 84 | public syncCookies(cookies: Record, url: string) { 85 | if (!cookies) return this.fetchCookiesObject(url); 86 | 87 | for (const [key, value] of Object.entries(cookies)) { 88 | this.setCookieSync(`${key}=${value}`, url); 89 | } 90 | 91 | return this.fetchCookiesObject(url); 92 | } 93 | 94 | /** 95 | * Merges the provided cookies with the existing cookies for a given URL according to request payload. 96 | * 97 | * @param cookies - An object containing cookies as key-value pairs. 98 | * @param url - The URL for which cookies are to be set. 99 | * @returns An array of objects, each containing the name and value of a cookie. 100 | * 101 | * @example 102 | * mergeCookies({ 'cookie1': 'value1', 'cookie2': 'value2' }, 'http://example.com') 103 | */ 104 | public mergeCookies(cookies: Record, url: string) { 105 | for (const [key, value] of Object.entries(cookies)) { 106 | this.setCookieSync(`${key}=${value}`, url); 107 | } 108 | return this.fetchCookiesList(url); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/lib/Response.ts: -------------------------------------------------------------------------------- 1 | import { TlsResponse } from "../interface"; 2 | import { IncomingHttpHeaders } from "http"; 3 | 4 | export class Response { 5 | // Indicates whether the response was successful (status in the range 200-299) or not. 6 | public readonly ok: boolean; 7 | 8 | // Represents the response headers. 9 | public readonly headers: IncomingHttpHeaders; 10 | 11 | // Represents the HTTP status code of the response. 12 | public readonly status: number; 13 | 14 | // Represents the URL of the response. 15 | public readonly url: string; 16 | 17 | constructor(private readonly response: TlsResponse) { 18 | this.ok = response.status >= 200 && response.status < 300; 19 | this.headers = response.headers; 20 | this.status = response.status; 21 | this.url = response.target; 22 | } 23 | 24 | /** 25 | * Returns the body of the response as a string. 26 | * 27 | * @returns A promise that resolves with the body of the response as a string. 28 | */ 29 | public async text(): Promise { 30 | return this.response.body.toString(); 31 | } 32 | 33 | /** 34 | * Returns the body of the response as a JSON object. 35 | * 36 | * @typeparam T - The type of the JSON object. 37 | * @returns A promise that resolves with the body of the response as a JSON object. 38 | */ 39 | public async json(): Promise { 40 | return JSON.parse(this.response.body) as T; 41 | } 42 | 43 | /** 44 | * Returns the cookies from the response as an object with key-value pairs. 45 | * 46 | * @returns An object containing cookies as key-value pairs. 47 | */ 48 | public get cookies() { 49 | return this.response.cookies; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/lib/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./Session"; 2 | export * from "./Response"; 3 | export * from "./Cookie"; 4 | export * from "./requests"; 5 | export * from "./Client"; 6 | -------------------------------------------------------------------------------- /src/lib/requests.ts: -------------------------------------------------------------------------------- 1 | import { 2 | DeleteRequestOptions, 3 | fetchOptions, 4 | GetRequestOptions, 5 | HeadRequestOptions, 6 | OptionsRequestOptions, 7 | PatchRequestOptions, 8 | PostRequestOptions, 9 | PutRequestOptions, 10 | SessionOptions, 11 | } from "../interface"; 12 | import { Response, Session } from "."; 13 | import { TlsClientError } from "../utils"; 14 | 15 | /** 16 | * Makes an HTTP request using the specified URL and options. 17 | * 18 | * @param {string} url - The URL to make the request to. 19 | * @param {fetchOptions} [options] - Optional parameters for the request. 20 | * @returns {Promise} The response from the HTTP request. 21 | * @throws Will throw an error if the HTTP request fails or the method is not allowed. 22 | */ 23 | export async function fetch( 24 | url: string, 25 | options?: fetchOptions 26 | ): Promise { 27 | const session = new Session(options?.options as SessionOptions); 28 | const method = options?.method?.toUpperCase() || "GET"; 29 | 30 | try { 31 | await session.init(); 32 | 33 | let response; 34 | 35 | switch (method) { 36 | case "GET": 37 | response = await session.get(url, options as GetRequestOptions); 38 | break; 39 | case "POST": 40 | response = await session.post(url, options as PostRequestOptions); 41 | break; 42 | case "PUT": 43 | response = await session.put(url, options as PutRequestOptions); 44 | break; 45 | case "DELETE": 46 | response = await session.delete(url, options as DeleteRequestOptions); 47 | break; 48 | case "HEAD": 49 | response = await session.head(url, options as HeadRequestOptions); 50 | break; 51 | case "OPTIONS": 52 | response = await session.options(url, options as OptionsRequestOptions); 53 | break; 54 | case "PATCH": 55 | response = await session.patch(url, options as PatchRequestOptions); 56 | break; 57 | default: 58 | throw new Error(`HTTP method ${method} is not allowed.`); 59 | } 60 | 61 | return response; 62 | } catch (error) { 63 | throw new TlsClientError(error as Error); 64 | } finally { 65 | await session.close(); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/utils/download.ts: -------------------------------------------------------------------------------- 1 | import { logger } from "./logger"; 2 | import https from "https"; 3 | import fs, { WriteStream, createWriteStream } from "fs"; 4 | import { IncomingMessage } from "http"; 5 | 6 | export class Download { 7 | private file: { name: string; downloadName: string }; 8 | private path: string; 9 | private issueURL: string = 10 | "https://github.com/Sahil1337/node-tls-client/issues"; 11 | 12 | constructor(file: { name: string; downloadName: string }, libPath: string) { 13 | this.file = file; 14 | this.path = libPath; 15 | } 16 | 17 | async init() { 18 | try { 19 | const latest = await this.getLatest(); 20 | if (latest) { 21 | await this.extract(latest.browser_download_url); 22 | logger.success("Extracted shared library."); 23 | } else { 24 | logger.error( 25 | `Failed to find required asset: ${ 26 | this.file.name 27 | }, report ${logger.hyperlink("here", this.issueURL)}.` 28 | ); 29 | } 30 | } catch (error) { 31 | logger.error(`Initialization failed: ${error}`); 32 | } 33 | } 34 | 35 | private formatBytes(bytes: number, decimals = 2): string { 36 | if (bytes === 0) return "0 Bytes"; 37 | const k = 1024; 38 | const dm = decimals < 0 ? 0 : decimals; 39 | const sizes = ["Bytes", "KB", "MB", "GB", "TB"]; 40 | const i = Math.floor(Math.log(bytes) / Math.log(k)); 41 | return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i]; 42 | } 43 | 44 | private progress(downloaded: number, total: number) { 45 | const percentage = (downloaded / total) * 100; 46 | const progress = Math.floor(percentage / 2); 47 | const bar = "█".repeat(progress) + " ".repeat(50 - progress); 48 | process.stdout.clearLine(0); 49 | process.stdout.cursorTo(0); 50 | process.stdout.write( 51 | `${logger.stamp} DOWNLOADING:[${bar}] ${percentage.toFixed( 52 | 2 53 | )}% (${this.formatBytes(downloaded)} / ${this.formatBytes(total)})` 54 | ); 55 | } 56 | 57 | private async download(url: string, file: WriteStream): Promise { 58 | return new Promise((resolve, reject) => { 59 | https 60 | .get(url, (response: IncomingMessage) => { 61 | if ( 62 | response.statusCode && 63 | response.statusCode >= 300 && 64 | response.statusCode < 400 && 65 | response.headers.location 66 | ) { 67 | const newURL = new URL(response.headers.location, url).toString(); 68 | logger.debug( 69 | `Fetched shared library ${logger.hyperlink("url", newURL)}` 70 | ); 71 | this.download(newURL, file).then(resolve).catch(reject); 72 | } else if ( 73 | response.statusCode && 74 | response.statusCode >= 200 && 75 | response.statusCode < 300 76 | ) { 77 | const totalBytes = parseInt( 78 | response.headers["content-length"] || "0", 79 | 10 80 | ); 81 | let downloadedBytes = 0; 82 | 83 | response.pipe(file); 84 | 85 | response.on("data", (chunk) => { 86 | downloadedBytes += chunk.length; 87 | this.progress(downloadedBytes, totalBytes); 88 | }); 89 | 90 | response.on("end", () => { 91 | file.close((err) => { 92 | if (err) { 93 | reject(err); 94 | } else { 95 | process.stdout.write("\n"); 96 | resolve(); 97 | } 98 | }); 99 | }); 100 | 101 | file.on("error", (err) => { 102 | fs.unlink(this.path, () => reject(err)); 103 | }); 104 | } else { 105 | logger.error( 106 | `Failed to download the file [statusCode:${response.statusCode}]` 107 | ); 108 | reject(); 109 | } 110 | }) 111 | .on("error", (err) => { 112 | fs.unlink(this.path, () => reject(err)); 113 | }); 114 | }); 115 | } 116 | 117 | private async extract(url: string): Promise { 118 | return new Promise((resolve, reject) => { 119 | const file = createWriteStream(this.path); 120 | this.download(url, file).then(resolve).catch(reject); 121 | }); 122 | } 123 | 124 | private async getLatest(): Promise { 125 | return new Promise((resolve, reject) => { 126 | const options = { 127 | hostname: "api.github.com", 128 | path: "/repos/bogdanfinn/tls-client/releases/latest", 129 | method: "GET", 130 | headers: { 131 | "user-agent": "node-tls-client", 132 | }, 133 | }; 134 | 135 | https 136 | .get(options, (res: IncomingMessage) => { 137 | let data = ""; 138 | 139 | res.on("data", (chunk) => { 140 | data += chunk; 141 | }); 142 | 143 | res.on("end", () => { 144 | if (res.statusCode === 200) { 145 | try { 146 | const response = JSON.parse(data); 147 | const version = response.tag_name.replace("v", ""); 148 | logger.debug(`Fetched latest version: v${version}`); 149 | 150 | const assetName = this.file.downloadName.replace( 151 | "{version}", 152 | version 153 | ); 154 | const asset = response.assets.find( 155 | (asset: { name: string }) => asset.name === assetName 156 | ); 157 | 158 | if (!asset) { 159 | logger.error( 160 | `Failed to find required asset: ${ 161 | this.file.name 162 | }, report ${logger.hyperlink("here", this.issueURL)}.` 163 | ); 164 | resolve(null); 165 | } else { 166 | resolve(asset); 167 | } 168 | } catch (err) { 169 | logger.error(`Failed to parse response: ${err}`); 170 | resolve(null); 171 | } 172 | } else { 173 | logger.error( 174 | `Failed to fetch the latest version. Status code: ${res.statusCode}` 175 | ); 176 | resolve(null); 177 | } 178 | }); 179 | }) 180 | .on("error", (err) => { 181 | logger.error(`Failed to fetch the latest version: ${err}`); 182 | resolve(null); 183 | }); 184 | }); 185 | } 186 | } 187 | -------------------------------------------------------------------------------- /src/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./download"; 2 | export * from "./koffi"; 3 | export * from "./logger"; 4 | export * from "./request"; 5 | export * from "./download"; 6 | export * from "./tlsError"; 7 | -------------------------------------------------------------------------------- /src/utils/koffi.ts: -------------------------------------------------------------------------------- 1 | import path from "path"; 2 | import fs from "fs"; 3 | import os from "os"; 4 | import { load as koffi } from "koffi"; 5 | import { Download } from "./download"; 6 | import { IClient } from "../interface/client"; 7 | 8 | /** 9 | * Downloads and loads the native library. 10 | * @returns {Promise} 11 | */ 12 | export async function load(): Promise { 13 | const file = fileInfo(); 14 | const temp = os.tmpdir(); 15 | const libraryPath = path.join(temp, file.name); 16 | 17 | if (!fs.existsSync(libraryPath)) { 18 | const downloader = new Download(file, libraryPath); 19 | await downloader.init(); 20 | } 21 | 22 | const lib = koffi(libraryPath); 23 | 24 | return { 25 | request: lib.func("request", "string", ["string"]), 26 | freeMemory: lib.func("freeMemory", "void", ["string"]), 27 | destroyAll: lib.func("destroyAll", "string", []), 28 | destroySession: lib.func("destroySession", "string", ["string"]), 29 | }; 30 | } 31 | 32 | function fileInfo() { 33 | const platform = process.platform; 34 | const arch = process.arch; 35 | 36 | const map: Record = { 37 | darwin: { 38 | arm64: { 39 | name: "tls-client-arm64.dylib", 40 | downloadName: "tls-client-darwin-arm64-{version}.dylib", 41 | }, 42 | x64: { 43 | name: "tls-client-x86.dylib", 44 | downloadName: "tls-client-darwin-amd64-{version}.dylib", 45 | }, 46 | }, 47 | win32: { 48 | x64: { 49 | name: "tls-client-64.dll", 50 | downloadName: "tls-client-windows-64-{version}.dll", 51 | }, 52 | ia32: { 53 | name: "tls-client-32.dll", 54 | downloadName: "tls-client-windows-32-{version}.dll", 55 | }, 56 | }, 57 | linux: { 58 | arm64: { 59 | name: "tls-client-arm64.so", 60 | downloadName: "tls-client-linux-arm64-{version}.so", 61 | }, 62 | x64: { 63 | name: "tls-client-x64.so", 64 | downloadName: "tls-client-linux-ubuntu-amd64-{version}.so", 65 | }, 66 | default: { 67 | name: "tls-client-amd64.so", 68 | downloadName: "tls-client-linux-ubuntu-amd64-{version}.so", 69 | }, 70 | }, 71 | }; 72 | 73 | return map[platform]?.[arch] || map.linux.default; 74 | } 75 | -------------------------------------------------------------------------------- /src/utils/logger.ts: -------------------------------------------------------------------------------- 1 | const colors = { 2 | reset: "\x1b[0m", 3 | blue: "\x1b[34m", 4 | red: "\x1b[31m", 5 | green: "\x1b[32m", 6 | cyan: "\x1b[36m", 7 | }; 8 | 9 | /** 10 | * Logger utility. 11 | * 12 | * @property {Function} debug - Logs a debug message. 13 | * @property {Function} error - Logs an error message. 14 | * @property {Function} success - Logs a success message. 15 | * @property {Function} hyperlink - Generates a clickable hyperlink. 16 | */ 17 | export const logger = { 18 | debug: function (...args: any[]) { 19 | return process.stdout.write( 20 | `${colors.cyan}@node-tls-client ~ ${colors.blue}DEBUG:${ 21 | colors.reset 22 | } ${args.join(" ")}\n` 23 | ); 24 | }, 25 | error: function (...args: any[]) { 26 | return process.stdout.write( 27 | `${colors.cyan}@node-tls-client ~ ${colors.red}ERROR:${ 28 | colors.reset 29 | } ${args.join(" ")}\n` 30 | ); 31 | }, 32 | success: function (...args: any[]) { 33 | return process.stdout.write( 34 | `${colors.cyan}@node-tls-client ~ ${colors.green}SUCCESS:${ 35 | colors.reset 36 | } ${args.join(" ")}\n` 37 | ); 38 | }, 39 | hyperlink: function (text: string, url: string) { 40 | return `\x1b]8;;${url}\x1b\\${text}\x1b]8;;\x1b\\`; 41 | }, 42 | stamp: `${colors.cyan}@node-tls-client ~${colors.reset}`, 43 | }; 44 | -------------------------------------------------------------------------------- /src/utils/request.ts: -------------------------------------------------------------------------------- 1 | import { OutgoingHttpHeaders } from "http"; 2 | 3 | const exactContentTypes = new Set([ 4 | "application/octet-stream", 5 | "application/pdf", 6 | "application/zip", 7 | "application/gzip", 8 | "application/x-rar-compressed", 9 | "application/x-msdownload", 10 | "application/x-sh", 11 | "application/x-binary", 12 | "base64", 13 | ]); 14 | 15 | const prefixContentTypes = new Set([ 16 | "image/", 17 | "audio/", 18 | "video/", 19 | "application/vnd.", 20 | ]); 21 | 22 | /** 23 | * Determines if a request should be treated as a byte request based on its headers. 24 | * 25 | * This function checks the "Content-Type" and "Content-Transfer-Encoding" headers 26 | * to determine if the request is for binary data (such as images, audio, video, 27 | * application binaries, etc.). If the headers indicate binary data, it returns true. 28 | * 29 | * @param {OutgoingHttpHeaders} headers - The headers of the request. 30 | * @returns {boolean} - Returns true if the request is for binary data, otherwise false. 31 | */ 32 | export function isByteRequest(headers: OutgoingHttpHeaders): boolean { 33 | const contentType = headers["content-type"] || headers["Content-Type"]; 34 | const contentTransferEncoding = 35 | headers["content-transfer-encoding"] || 36 | headers["Content-Transfer-Encoding"]; 37 | 38 | if (contentTransferEncoding) { 39 | const encodingString = String(contentTransferEncoding); 40 | if (exactContentTypes.has(encodingString)) { 41 | return true; 42 | } 43 | } 44 | 45 | if (contentType) { 46 | const contentTypeString = String(contentType); 47 | 48 | if (exactContentTypes.has(contentTypeString)) { 49 | return true; 50 | } 51 | 52 | for (const prefix of prefixContentTypes) { 53 | if (contentTypeString.startsWith(prefix)) { 54 | return true; 55 | } 56 | } 57 | } 58 | 59 | return false; 60 | } 61 | -------------------------------------------------------------------------------- /src/utils/tlsError.ts: -------------------------------------------------------------------------------- 1 | export class TlsClientError extends Error { 2 | constructor(message: string | Error) { 3 | super(message instanceof Error ? message.message : message); 4 | if (message instanceof Error && message.stack) { 5 | this.stack = message.stack; 6 | } 7 | this.name = "TlsClientError"; 8 | Object.setPrototypeOf(this, new.target.prototype); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/utils/worker.ts: -------------------------------------------------------------------------------- 1 | import workerpool from "workerpool"; 2 | import { Client } from "../lib"; 3 | 4 | const client = new Client(); 5 | 6 | /** 7 | * Initialize the client 8 | */ 9 | client.init().then(() => { 10 | workerpool.worker({ 11 | request: client.request.bind(client), 12 | destroySession: client.destroySession.bind(client), 13 | freeMemory: client.freeMemory.bind(client), 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig to read more about this file */ 4 | 5 | /* Projects */ 6 | // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ 7 | // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ 8 | // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ 9 | // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ 10 | // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ 11 | // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ 12 | 13 | /* Language and Environment */ 14 | "target": "es2022" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, 15 | // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ 16 | // "jsx": "preserve", /* Specify what JSX code is generated. */ 17 | "experimentalDecorators": true /* Enable experimental support for legacy experimental decorators. */, 18 | "emitDecoratorMetadata": true /* Emit design-type metadata for decorated declarations in source files. */, 19 | // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ 20 | // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ 21 | // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ 22 | // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ 23 | // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ 24 | // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ 25 | // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ 26 | 27 | /* Modules */ 28 | "module": "commonjs" /* Specify what module code is generated. */, 29 | // "rootDir": "./", /* Specify the root folder within your source files. */ 30 | // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ 31 | // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ 32 | // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ 33 | // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ 34 | // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ 35 | // "types": [], /* Specify type package names to be included without being referenced in a source file. */ 36 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 37 | // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ 38 | // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ 39 | // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ 40 | // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ 41 | // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ 42 | // "resolveJsonModule": true, /* Enable importing .json files. */ 43 | // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ 44 | // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ 45 | 46 | /* JavaScript Support */ 47 | // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ 48 | // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ 49 | // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ 50 | 51 | /* Emit */ 52 | "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */, 53 | // "declarationMap": true, /* Create sourcemaps for d.ts files. */ 54 | // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ 55 | // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ 56 | // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ 57 | // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ 58 | "outDir": "./dist" /* Specify an output folder for all emitted files. */, 59 | // "removeComments": true, /* Disable emitting comments. */ 60 | // "noEmit": true, /* Disable emitting files from a compilation. */ 61 | // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ 62 | // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ 63 | // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ 64 | // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ 65 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 66 | // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ 67 | // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ 68 | // "newLine": "crlf", /* Set the newline character for emitting files. */ 69 | // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ 70 | // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ 71 | // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ 72 | // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ 73 | "declarationDir": "./typings" /* Specify the output directory for generated declaration files. */, 74 | // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ 75 | 76 | /* Interop Constraints */ 77 | // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ 78 | // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ 79 | // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ 80 | "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */, 81 | // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ 82 | "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, 83 | 84 | /* Type Checking */ 85 | "strict": true /* Enable all strict type-checking options. */, 86 | // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ 87 | // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ 88 | // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ 89 | // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ 90 | // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ 91 | // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ 92 | // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ 93 | // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ 94 | // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ 95 | // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ 96 | // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ 97 | // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ 98 | // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ 99 | // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ 100 | // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ 101 | // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ 102 | // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ 103 | // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ 104 | 105 | /* Completeness */ 106 | // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ 107 | "skipLibCheck": true /* Skip type checking all .d.ts files. */ 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /typings/decorators/client.d.ts: -------------------------------------------------------------------------------- 1 | export declare function verifyClientState(): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor; 2 | -------------------------------------------------------------------------------- /typings/decorators/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from "./client"; 2 | -------------------------------------------------------------------------------- /typings/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from "./interface"; 2 | export * from "./lib"; 3 | -------------------------------------------------------------------------------- /typings/interface/client.d.ts: -------------------------------------------------------------------------------- 1 | import { KoffiFunction } from "koffi"; 2 | export interface IClient { 3 | request: KoffiFunction; 4 | freeMemory: KoffiFunction; 5 | destroyAll: KoffiFunction; 6 | destroySession: KoffiFunction; 7 | } 8 | -------------------------------------------------------------------------------- /typings/interface/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from "./session"; 2 | export * from "./client"; 3 | -------------------------------------------------------------------------------- /typings/interface/session.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | import { IncomingHttpHeaders, OutgoingHttpHeaders } from "http"; 3 | /** 4 | * Represents various settings for HTTP/2 (h2) protocol. 5 | */ 6 | export interface H2Settings { 7 | /** 8 | * The size of the header compression table used in HTTP/2. 9 | */ 10 | HEADER_TABLE_SIZE?: number; 11 | /** 12 | * Indicates whether server push is enabled in HTTP/2. 13 | */ 14 | ENABLE_PUSH?: boolean; 15 | /** 16 | * The maximum number of concurrent streams allowed in HTTP/2. 17 | */ 18 | MAX_CONCURRENT_STREAMS?: number; 19 | /** 20 | * The initial window size for HTTP/2 data frames. 21 | */ 22 | INITIAL_WINDOW_SIZE?: number; 23 | /** 24 | * The maximum size of HTTP/2 frames. 25 | */ 26 | MAX_FRAME_SIZE?: number; 27 | /** 28 | * The maximum size of header list in HTTP/2. 29 | */ 30 | MAX_HEADER_LIST_SIZE?: number; 31 | } 32 | /** 33 | * Represents various supported signature algorithms for TLS. 34 | */ 35 | export type SupportedSignatureAlgorithms = "PKCS1WithSHA256" | "PKCS1WithSHA384" | "PKCS1WithSHA512" | "PSSWithSHA256" | "PSSWithSHA384" | "PSSWithSHA512" | "ECDSAWithP256AndSHA256" | "ECDSAWithP384AndSHA384" | "ECDSAWithP521AndSHA512" | "PKCS1WithSHA1" | "ECDSAWithSHA1" | "Ed25519"; 36 | /** 37 | * Represents various supported versions of TLS. 38 | */ 39 | export type SupportedVersions = "GREASE" | "1.3" | "1.2" | "1.1" | "1.0"; 40 | /** 41 | * Represents various supported elliptic curves for key exchange. 42 | */ 43 | export type KeyShareCurves = "GREASE" | "P256" | "P384" | "P521" | "X25519" | "P256Kyber768" | "X25519Kyber512D" | "X25519Kyber768"; 44 | /** 45 | * Represents various certificate compression algorithms. 46 | */ 47 | export type CertCompressionAlgo = "zlib" | "brotli" | "zstd"; 48 | /** 49 | * Represents parameters for setting priority of HTTP/2 streams. 50 | */ 51 | export interface PriorityParam { 52 | /** 53 | * The stream dependency for priority. 54 | */ 55 | streamDep: number; 56 | /** 57 | * Indicates whether the priority is exclusive. 58 | */ 59 | exclusive: boolean; 60 | /** 61 | * The weight of the priority. 62 | */ 63 | weight: number; 64 | } 65 | /** 66 | * Represents priority frames for HTTP/2 streams. 67 | */ 68 | export interface PriorityFrames { 69 | /** 70 | * The stream ID for which priority is set. 71 | */ 72 | streamID: number; 73 | /** 74 | * The parameters for priority settings. 75 | */ 76 | priorityParam: PriorityParam; 77 | } 78 | /** 79 | * Represents the order of pseudo headers in HTTP/2 requests. 80 | */ 81 | export type PseudoHeaderOrder = ":method" | ":authority" | ":scheme" | ":path"; 82 | /** 83 | * Represents various HTTP methods. 84 | */ 85 | export type Methods = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "OPTIONS" | "HEAD"; 86 | /** 87 | * Represents various client identifiers. 88 | * 89 | * The client identifiers are grouped by browser, mobile clients, and other clients. 90 | */ 91 | export declare enum ClientIdentifier { 92 | chrome_103 = "chrome_103", 93 | chrome_104 = "chrome_104", 94 | chrome_105 = "chrome_105", 95 | chrome_106 = "chrome_106", 96 | chrome_107 = "chrome_107", 97 | chrome_108 = "chrome_108", 98 | chrome_109 = "chrome_109", 99 | chrome_110 = "chrome_110", 100 | chrome_111 = "chrome_111", 101 | chrome_112 = "chrome_112", 102 | chrome_116_PSK = "chrome_116_PSK", 103 | chrome_116_PSK_PQ = "chrome_116_PSK_PQ", 104 | chrome_117 = "chrome_117", 105 | chrome_120 = "chrome_120", 106 | chrome_124 = "chrome_124", 107 | chrome_131 = "chrome_131", 108 | chrome_131_psk = "chrome_131_PSK", 109 | safari_15_6_1 = "safari_15_6_1", 110 | safari_16_0 = "safari_16_0", 111 | safari_ipad_15_6 = "safari_ipad_15_6", 112 | safari_ios_15_5 = "safari_ios_15_5", 113 | safari_ios_15_6 = "safari_ios_15_6", 114 | safari_ios_16_0 = "safari_ios_16_0", 115 | safari_ios_17_0 = "safari_ios_17_0", 116 | safari_ios_18_0 = "safari_ios_18_0", 117 | firefox_102 = "firefox_102", 118 | firefox_104 = "firefox_104", 119 | firefox_105 = "firefox_105", 120 | firefox_106 = "firefox_106", 121 | firefox_108 = "firefox_108", 122 | firefox_110 = "firefox_110", 123 | firefox_117 = "firefox_117", 124 | firefox_120 = "firefox_120", 125 | firefox_123 = "firefox_123", 126 | firefox_132 = "firefox_132", 127 | firefox_133 = "firefox_133", 128 | opera_89 = "opera_89", 129 | opera_90 = "opera_90", 130 | opera_91 = "opera_91", 131 | zalando_android_mobile = "zalando_android_mobile", 132 | zalando_ios_mobile = "zalando_ios_mobile", 133 | nike_ios_mobile = "nike_ios_mobile", 134 | nike_android_mobile = "nike_android_mobile", 135 | cloudscraper = "cloudscraper", 136 | mms_ios = "mms_ios", 137 | mms_ios_1 = "mms_ios_1", 138 | mms_ios_2 = "mms_ios_2", 139 | mms_ios_3 = "mms_ios_3", 140 | mesh_ios = "mesh_ios", 141 | mesh_ios_1 = "mesh_ios_1", 142 | mesh_ios_2 = "mesh_ios_2", 143 | mesh_android = "mesh_android", 144 | mesh_android_1 = "mesh_android_1", 145 | mesh_android_2 = "mesh_android_2", 146 | confirmed_ios = "confirmed_ios", 147 | confirmed_android = "confirmed_android", 148 | okhttp4_android_7 = "okhttp4_android_7", 149 | okhttp4_android_8 = "okhttp4_android_8", 150 | okhttp4_android_9 = "okhttp4_android_9", 151 | okhttp4_android_10 = "okhttp4_android_10", 152 | okhttp4_android_11 = "okhttp4_android_11", 153 | okhttp4_android_12 = "okhttp4_android_12", 154 | okhttp4_android_13 = "okhttp4_android_13" 155 | } 156 | /** 157 | * Represents options for creating a session. 158 | */ 159 | export interface SessionOptions { 160 | /** 161 | * The unique identifier for the session. 162 | */ 163 | sessionId?: string; 164 | /** 165 | * The headers for the session. 166 | */ 167 | headers?: OutgoingHttpHeaders; 168 | /** 169 | * The proxy server to use for the session. 170 | */ 171 | proxy?: string; 172 | /** 173 | * Whether the proxy is rotating proxy. 174 | */ 175 | isRotatingProxy?: boolean; 176 | /** 177 | * The client identifier for the session. 178 | */ 179 | clientIdentifier?: ClientIdentifier; 180 | /** 181 | * The JA3 string for the session. 182 | */ 183 | ja3string?: string; 184 | /** 185 | * The settings for HTTP/2. 186 | */ 187 | h2Settings?: H2Settings; 188 | /** 189 | * The order of HTTP/2 settings. 190 | */ 191 | h2SettingsOrder?: (keyof H2Settings)[]; 192 | /** 193 | * The supported signature algorithms. 194 | */ 195 | supportedSignatureAlgorithms?: SupportedSignatureAlgorithms[]; 196 | /** 197 | * The supported versions of TLS. 198 | */ 199 | supportedVersions?: SupportedVersions[]; 200 | /** 201 | * The supported elliptic curves for key exchange. 202 | */ 203 | keyShareCurves?: KeyShareCurves[]; 204 | /** 205 | * The certificate compression algorithm. 206 | */ 207 | certCompressionAlgo?: CertCompressionAlgo; 208 | /** 209 | * The order of pseudo headers. 210 | */ 211 | pseudoHeaderOrder?: PseudoHeaderOrder[]; 212 | /** 213 | * The connection flow for the session. 214 | */ 215 | connectionFlow?: number; 216 | /** 217 | * The priority frames for HTTP/2 streams. 218 | */ 219 | priorityFrames?: PriorityFrames[]; 220 | /** 221 | * The order of headers. 222 | */ 223 | headerOrder?: string[]; 224 | /** 225 | * The ALPN protocols. 226 | */ 227 | alpnProtocols?: string[]; 228 | /** 229 | * The ALPS protocols. 230 | */ 231 | alpsProtocols?: string[]; 232 | /** 233 | * The priority of headers. 234 | */ 235 | headerPriority?: PriorityParam; 236 | /** 237 | * Whether to randomize TLS extension order. 238 | */ 239 | randomTlsExtensionOrder?: boolean; 240 | /** 241 | * Whether to force HTTP/1 protocol. 242 | */ 243 | forceHttp1?: boolean; 244 | /** 245 | * Whether to enable debugging. 246 | */ 247 | debug?: boolean; 248 | /** 249 | * Whether to skip SSL certificate verification. 250 | */ 251 | insecureSkipVerify?: boolean; 252 | /** 253 | * The timeout duration for each request, in milliseconds. 254 | */ 255 | timeout?: number; 256 | /** 257 | * If true, IPv4 is disabled for the session requests. 258 | */ 259 | disableIPV4?: boolean; 260 | /** 261 | * If true, IPv6 is disabled for the session requests. 262 | */ 263 | disableIPV6?: boolean; 264 | } 265 | /** 266 | * Represents base options for making HTTP requests, excluding the body. 267 | */ 268 | export interface BaseRequestOptions { 269 | /** 270 | * The headers for the request. 271 | */ 272 | headers?: OutgoingHttpHeaders; 273 | /** 274 | * Whether to follow redirects. 275 | */ 276 | redirect?: boolean; 277 | /** 278 | * Whether to perform additional decoding. 279 | */ 280 | additionalDecode?: boolean; 281 | /** 282 | * The proxy server to use for the request. 283 | */ 284 | proxy?: string; 285 | /** 286 | * Whether proxy is rotating proxy or not. 287 | */ 288 | isRotatingProxy?: boolean; 289 | /** 290 | * Cookies for the request. 291 | */ 292 | cookies?: Record; 293 | /** 294 | * If true, indicates the response is in binary format, like base64-encoded images. 295 | */ 296 | byteResponse?: boolean; 297 | /** 298 | * Used to override the Host header, typically needed when making requests directly to an IP address. 299 | */ 300 | hostOverride?: string | null; 301 | } 302 | /** 303 | * Represents options for making HTTP requests that may include a body. 304 | */ 305 | export interface RequestOptions extends BaseRequestOptions { 306 | /** 307 | * Request body. 308 | */ 309 | body?: any; 310 | } 311 | /** 312 | * Represents options for making a GET HTTP request. 313 | */ 314 | export interface GetRequestOptions extends BaseRequestOptions { 315 | } 316 | /** 317 | * Represents options for making a POST HTTP request. 318 | */ 319 | export interface PostRequestOptions extends RequestOptions { 320 | } 321 | /** 322 | * Represents options for making a PUT HTTP request. 323 | */ 324 | export interface PutRequestOptions extends RequestOptions { 325 | } 326 | /** 327 | * Represents options for making a DELETE HTTP request. 328 | */ 329 | export interface DeleteRequestOptions extends BaseRequestOptions { 330 | } 331 | /** 332 | * Represents options for making a PATCH HTTP request. 333 | */ 334 | export interface PatchRequestOptions extends RequestOptions { 335 | } 336 | /** 337 | * Represents options for making an OPTIONS HTTP request. 338 | */ 339 | export interface OptionsRequestOptions extends BaseRequestOptions { 340 | } 341 | /** 342 | * Represents options for making a HEAD HTTP request. 343 | */ 344 | export interface HeadRequestOptions extends BaseRequestOptions { 345 | } 346 | /** 347 | * Represents options for making HTTP requests. 348 | */ 349 | export interface fetchOptions { 350 | /** 351 | * Request method. 352 | */ 353 | method?: Methods; 354 | /** 355 | * The headers for the request. 356 | */ 357 | headers?: OutgoingHttpHeaders; 358 | /** 359 | * The body of the request. 360 | */ 361 | body?: any; 362 | /** 363 | * Whether to follow redirects. 364 | */ 365 | redirect?: boolean; 366 | /** 367 | * Whether to perform additional decoding. 368 | */ 369 | additionalDecode?: boolean; 370 | /** 371 | * The proxy server to use for the request. 372 | */ 373 | proxy?: string; 374 | /** 375 | * Whether proxy is rotating proxy or not. 376 | */ 377 | isRotatingProxy?: boolean; 378 | /** 379 | * Cookies for the request. 380 | */ 381 | cookies?: Record; 382 | /** 383 | * Additional session options. 384 | */ 385 | options?: SessionOptions; 386 | } 387 | /** 388 | * Represents a response from the shared library. 389 | */ 390 | export interface TlsResponse { 391 | /** 392 | * The unique identifier for the response. 393 | */ 394 | id: string; 395 | /** 396 | * The body of the response. 397 | */ 398 | body: string; 399 | /** 400 | * Cookies set in the response. 401 | */ 402 | cookies: Record; 403 | /** 404 | * Headers included in the response. 405 | */ 406 | headers: IncomingHttpHeaders; 407 | /** 408 | * The session ID associated with the response. 409 | */ 410 | sessionId: string; 411 | /** 412 | * The HTTP status code of the response. 413 | */ 414 | status: number; 415 | /** 416 | * The target URL of the response. 417 | */ 418 | target: string; 419 | /** 420 | * The protocol used for the response. 421 | */ 422 | usedProtocol: string; 423 | } 424 | -------------------------------------------------------------------------------- /typings/lib/Client.d.ts: -------------------------------------------------------------------------------- 1 | import { TlsResponse } from "../interface"; 2 | export declare class Client { 3 | private client; 4 | constructor(); 5 | /** 6 | * Intialize the client and load the native library. 7 | */ 8 | init(): Promise; 9 | /** 10 | * Performs an HTTP request with native library. 11 | * @param {string} payload - The request payload to be sent. 12 | * @returns {Promise} - A promise resolving to the parsed TLS response object. 13 | * @throws {TlsClientError} - If no response is received from the client. 14 | */ 15 | request(payload: string): Promise; 16 | /** 17 | * Destroys all sessions and removes session cache from memory. 18 | * @param {string} payload 19 | * @returns {Promise} - A promise resolving to the session id. 20 | */ 21 | destroySession(payload: string): Promise; 22 | /** 23 | * Removes cache from memory. 24 | * @returns {Promise} 25 | */ 26 | freeMemory(id: string): Promise; 27 | } 28 | -------------------------------------------------------------------------------- /typings/lib/Cookie.d.ts: -------------------------------------------------------------------------------- 1 | import { CookieJar } from "tough-cookie"; 2 | export declare class Cookies extends CookieJar { 3 | constructor(); 4 | /** 5 | * Fetches all cookies and organizes them by URL. 6 | * 7 | * This method serializes cookies and groups them by their domain and path, 8 | * constructing a URL as the key and an object of cookies as key-value pairs. 9 | * 10 | * @returns An object where keys are URLs and values are objects containing cookies as key-value pairs. 11 | * 12 | * @example 13 | * { 14 | * "https://example.com/": { 15 | * "cookie1": "value1", 16 | * "cookie2": "value2" 17 | * }, 18 | * "https://anotherdomain.com/": { 19 | * "cookieA": "valueA", 20 | * "cookieB": "valueB" 21 | * } 22 | * } 23 | */ 24 | fetchAllCookies(): import("tough-cookie").Cookie.Serialized; 25 | /** 26 | * Fetches the cookies for a given URL as an object. 27 | * 28 | * @param url - The URL from which cookies are to be fetched. 29 | * @returns An object containing cookies as key-value pairs. 30 | * 31 | * @example 32 | * fetchCookiesObject('http://example.com') 33 | */ 34 | fetchCookiesObject(url: string): Record; 35 | /** 36 | * Fetches the cookies for a given URL as an array of objects. 37 | * Each object contains the name and value of a cookie. 38 | * 39 | * @param url - The URL from which cookies are to be fetched. 40 | * @returns An array of objects, each containing the name and value of a cookie. 41 | * 42 | * @example 43 | * fetchCookiesList('http://example.com') 44 | */ 45 | fetchCookiesList(url: string): { 46 | name: string; 47 | value: string; 48 | }[]; 49 | /** 50 | * Checks and sets cookies for a given URL. 51 | * 52 | * @param cookies - An object containing cookies as key-value pairs. 53 | * @param url - The URL for which cookies are to be set. 54 | * @returns An object containing cookies as key-value pairs. 55 | * 56 | * @example 57 | * syncCookies({ 'cookie1': 'value1', 'cookie2': 'value2' }, 'http://example.com') 58 | */ 59 | syncCookies(cookies: Record, url: string): Record; 60 | /** 61 | * Merges the provided cookies with the existing cookies for a given URL according to request payload. 62 | * 63 | * @param cookies - An object containing cookies as key-value pairs. 64 | * @param url - The URL for which cookies are to be set. 65 | * @returns An array of objects, each containing the name and value of a cookie. 66 | * 67 | * @example 68 | * mergeCookies({ 'cookie1': 'value1', 'cookie2': 'value2' }, 'http://example.com') 69 | */ 70 | mergeCookies(cookies: Record, url: string): { 71 | name: string; 72 | value: string; 73 | }[]; 74 | } 75 | -------------------------------------------------------------------------------- /typings/lib/Response.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | import { TlsResponse } from "../interface"; 3 | import { IncomingHttpHeaders } from "http"; 4 | export declare class Response { 5 | private readonly response; 6 | readonly ok: boolean; 7 | readonly headers: IncomingHttpHeaders; 8 | readonly status: number; 9 | readonly url: string; 10 | constructor(response: TlsResponse); 11 | /** 12 | * Returns the body of the response as a string. 13 | * 14 | * @returns A promise that resolves with the body of the response as a string. 15 | */ 16 | text(): Promise; 17 | /** 18 | * Returns the body of the response as a JSON object. 19 | * 20 | * @typeparam T - The type of the JSON object. 21 | * @returns A promise that resolves with the body of the response as a JSON object. 22 | */ 23 | json(): Promise; 24 | /** 25 | * Returns the cookies from the response as an object with key-value pairs. 26 | * 27 | * @returns An object containing cookies as key-value pairs. 28 | */ 29 | get cookies(): Record; 30 | } 31 | -------------------------------------------------------------------------------- /typings/lib/Session.d.ts: -------------------------------------------------------------------------------- 1 | import { Methods, RequestOptions, GetRequestOptions, PostRequestOptions, PatchRequestOptions, PutRequestOptions, DeleteRequestOptions, OptionsRequestOptions, HeadRequestOptions, SessionOptions } from "../interface/session"; 2 | import { Response } from "."; 3 | export declare class Session { 4 | private sessionId?; 5 | private proxy?; 6 | private isRotatingProxy; 7 | private clientIdentifier?; 8 | private ja3string?; 9 | private h2Settings?; 10 | private h2SettingsOrder?; 11 | private supportedSignatureAlgorithms?; 12 | private supportedVersions?; 13 | private keyShareCurves?; 14 | private certCompressionAlgo?; 15 | private pseudoHeaderOrder?; 16 | private connectionFlow?; 17 | private priorityFrames?; 18 | private headerOrder?; 19 | private headerPriority?; 20 | private randomTlsExtensionOrder?; 21 | private forceHttp1?; 22 | private debug?; 23 | private insecureSkipVerify?; 24 | private headers; 25 | private alpnProtocols?; 26 | private alpsProtocols; 27 | private timeout; 28 | private disableIPV6; 29 | private disableIPV4; 30 | private jar; 31 | private pool?; 32 | isReady: boolean; 33 | constructor(options?: SessionOptions); 34 | init(): Promise; 35 | /** 36 | * Retrieves all cookies from the jar. 37 | * 38 | * @returns An object where keys are URLs and values are objects containing cookies as key-value pairs. 39 | * 40 | * @example 41 | { 42 | "https://example.com/": { 43 | "cookie1": "value1", 44 | "cookie2": "value2" 45 | }, 46 | "https://anotherdomain.com/": { 47 | "cookieA": "valueA", 48 | "cookieB": "valueB" 49 | } 50 | } 51 | */ 52 | get cookies(): import("tough-cookie").Cookie.Serialized; 53 | /** 54 | * The 'close' method closes the current session. 55 | * 56 | * @returns The response from the 'destroySession' function. 57 | */ 58 | close(): Promise; 59 | /** 60 | * The 'freeMemory' method frees the memory used by the session with the provided id. 61 | * 62 | * @param id - The id of the session to free the memory of. 63 | * 64 | * @returns The response from the 'destroySession' function. 65 | */ 66 | private free; 67 | /** 68 | * The 'get' method performs a GET request to the provided URL with the provided options. 69 | * 70 | * @param url - The URL to perform the GET request to. 71 | * @param options - The options for the GET request. 72 | * 73 | * @returns The response from the 'execute' method. 74 | */ 75 | get(url: string, options?: GetRequestOptions): Promise; 76 | /** 77 | * The 'delete' method performs a DELETE request to the provided URL with the provided options. 78 | * 79 | * @param url - The URL to perform the DELETE request to. 80 | * @param options - The options for the DELETE request. 81 | * 82 | * @returns The response from the 'execute' method. 83 | */ 84 | delete(url: string, options?: DeleteRequestOptions): Promise; 85 | /** 86 | * The 'options' method performs an OPTIONS request to the provided URL with the provided options. 87 | * 88 | * @param url - The URL to perform the OPTIONS request to. 89 | * @param options - The options for the OPTIONS request. 90 | * 91 | * @returns The response from the 'execute' method. 92 | */ 93 | options(url: string, options?: OptionsRequestOptions): Promise; 94 | /** 95 | * The 'head' method performs a HEAD request to the provided URL with the provided options. 96 | * 97 | * @param url - The URL to perform the HEAD request to. 98 | * @param options - The options for the HEAD request. 99 | * 100 | * @returns The response from the 'execute' method. 101 | */ 102 | head(url: string, options?: HeadRequestOptions): Promise; 103 | /** 104 | * The 'post' method performs a POST request to the provided URL with the provided options. 105 | * 106 | * @param url - The URL to perform the POST request to. 107 | * @param options - The options for the POST request. 108 | * 109 | * @returns The response from the 'execute' method. 110 | */ 111 | post(url: string, options?: PostRequestOptions): Promise; 112 | /** 113 | * The 'patch' method performs a PATCH request to the provided URL with the provided options. 114 | * 115 | * @param url - The URL to perform the PATCH request to. 116 | * @param options - The options for the PATCH request. 117 | * 118 | * @returns The response from the 'execute' method. 119 | */ 120 | patch(url: string, options?: PatchRequestOptions): Promise; 121 | /** 122 | * The 'put' method performs a PUT request to the provided URL with the provided options. 123 | * 124 | * @param url - The URL to perform the PUT request to. 125 | * @param options - The options for the PUT request. 126 | * 127 | * @returns The response from the 'execute' method. 128 | */ 129 | put(url: string, options?: PutRequestOptions): Promise; 130 | /** 131 | * The 'execute' method performs a HTTP request of the provided method to the provided URL with the provided options. 132 | * 133 | * @param method - The HTTP method of the request. 134 | * @param url - The URL to perform the request to. 135 | * @param options - The options for the request. 136 | * 137 | * @returns A new Response object. 138 | */ 139 | protected execute(method: Methods, url: string, options: RequestOptions): Promise; 140 | } 141 | -------------------------------------------------------------------------------- /typings/lib/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from "./Session"; 2 | export * from "./Response"; 3 | export * from "./Cookie"; 4 | export * from "./requests"; 5 | export * from "./Client"; 6 | -------------------------------------------------------------------------------- /typings/lib/requests.d.ts: -------------------------------------------------------------------------------- 1 | import { fetchOptions } from "../interface"; 2 | import { Response } from "."; 3 | /** 4 | * Makes an HTTP request using the specified URL and options. 5 | * 6 | * @param {string} url - The URL to make the request to. 7 | * @param {fetchOptions} [options] - Optional parameters for the request. 8 | * @returns {Promise} The response from the HTTP request. 9 | * @throws Will throw an error if the HTTP request fails or the method is not allowed. 10 | */ 11 | export declare function fetch(url: string, options?: fetchOptions): Promise; 12 | -------------------------------------------------------------------------------- /typings/utils/download.d.ts: -------------------------------------------------------------------------------- 1 | export declare class Download { 2 | private file; 3 | private path; 4 | private issueURL; 5 | constructor(file: { 6 | name: string; 7 | downloadName: string; 8 | }, libPath: string); 9 | init(): Promise; 10 | private formatBytes; 11 | private progress; 12 | private download; 13 | private extract; 14 | private getLatest; 15 | } 16 | -------------------------------------------------------------------------------- /typings/utils/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from "./download"; 2 | export * from "./koffi"; 3 | export * from "./logger"; 4 | export * from "./request"; 5 | export * from "./download"; 6 | export * from "./tlsError"; 7 | -------------------------------------------------------------------------------- /typings/utils/koffi.d.ts: -------------------------------------------------------------------------------- 1 | import { IClient } from "../interface/client"; 2 | /** 3 | * Downloads and loads the native library. 4 | * @returns {Promise} 5 | */ 6 | export declare function load(): Promise; 7 | -------------------------------------------------------------------------------- /typings/utils/logger.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Logger utility. 3 | * 4 | * @property {Function} debug - Logs a debug message. 5 | * @property {Function} error - Logs an error message. 6 | * @property {Function} success - Logs a success message. 7 | * @property {Function} hyperlink - Generates a clickable hyperlink. 8 | */ 9 | export declare const logger: { 10 | debug: (...args: any[]) => boolean; 11 | error: (...args: any[]) => boolean; 12 | success: (...args: any[]) => boolean; 13 | hyperlink: (text: string, url: string) => string; 14 | stamp: string; 15 | }; 16 | -------------------------------------------------------------------------------- /typings/utils/request.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | import { OutgoingHttpHeaders } from "http"; 3 | /** 4 | * Determines if a request should be treated as a byte request based on its headers. 5 | * 6 | * This function checks the "Content-Type" and "Content-Transfer-Encoding" headers 7 | * to determine if the request is for binary data (such as images, audio, video, 8 | * application binaries, etc.). If the headers indicate binary data, it returns true. 9 | * 10 | * @param {OutgoingHttpHeaders} headers - The headers of the request. 11 | * @returns {boolean} - Returns true if the request is for binary data, otherwise false. 12 | */ 13 | export declare function isByteRequest(headers: OutgoingHttpHeaders): boolean; 14 | -------------------------------------------------------------------------------- /typings/utils/tlsError.d.ts: -------------------------------------------------------------------------------- 1 | export declare class TlsClientError extends Error { 2 | constructor(message: string | Error); 3 | } 4 | -------------------------------------------------------------------------------- /typings/utils/worker.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | --------------------------------------------------------------------------------