TlsClientWrapper
A wrapper for bogdanfinn/tls-client
based on koffi for unparalleled performance and usability. Inspired by @dryft/tlsclient
.
Installation
With npm:
npm install tlsclientwrapper
Information
This module, compared to bogdanfinn's example, offers:
- Advanced JSDocs for faster development.
- Use of the more updated koffi.
- Automatic conversations, session support, etc.
- Default settings compatible with bogdafinn's client.
- Built-in automatic retries on specific status codes.
- Automatic download of the required library file.
- Many more enhancements!
Usage
Simple Get Request
import tlsClient from 'tlsclientwrapper';
const client = new tlsClient();
console.log(await client.get("https://example.com/"));
await client.terminate();
import tlsClient from 'tlsclientwrapper';
const client = new tlsClient({
defaultHeaders: {
"Custom-Header": "Custom-Value",
"User-Agent": "TlsClient/1.0"
},
defaultCookies: [
{
domain: "example.com",
expires: 0,
name: "testCookie",
path: "/",
value: "testValue"
}
]
});
console.log(await client.get("https://myhttpheader.com/"));
await client.terminate();
TLS Request
Don't worry, all requests by default are sent imitating chrome_120 TLS
import tlsClient from 'tlsclientwrapper';
const client = new tlsClient({
tlsClientIdentifier: "chrome_120"
});
console.log(await client.get("https://tls.peet.ws/api/all"));
await client.terminate();
For more Identifiers, check here: https://bogdanfinn.gitbook.io/open-source-oasis/tls-client/supported-and-tested-client-profiles
Custom Library
import tlsClient from 'tlsclientwrapper';
import path from 'node:path';
const client = new tlsClient({
customLibraryPath: path.join(process.cwd(), 'lib', 'customLib.dll')
});
console.log(await client.get("https://example.com/"));
await client.terminate();
⚠️ Warning ⚠️
- All the JSDocs are currently based on the TLSClient Version 1.7.5, if you're using a custom LibraryPath it will not update the JSDocs.
- Koffi might not be supported by your platform. Please check: https://github.com/Koromix/koffi and verify that your platform is officially supported.
Constructor Options
Additional options for overriding defaults
TlsClientReponse
Additional Information
For more Documentation, please check https://bogdanfinn.gitbook.io/open-source-oasis
Special thanks to @bogdanfinn and @heydryft which both did great work and helped me build this wrapper.