Browse by type
A high-performance Node.js wrapper for bogdanfinn/tls-client using Koffi bindings and worker thread pools.
Now with TypeScript Support.
npm install tlsclientwrapper
# or
pnpm add tlsclientwrapper
TlsClientWrapper uses a two-tier architecture:
ModuleClient (Worker Pool)
├─ SessionClient 1
├─ SessionClient 2
└─ SessionClient N
Now TypeScript, ESM and CJS are supported.
import { ModuleClient, SessionClient } from 'tlsclientwrapper';
// 1. Create the worker pool manager
const moduleClient = new ModuleClient();
// 2. Create a session for making requests
const session = new SessionClient(moduleClient);
// 3. Make requests
const response = await session.get('https://example.com');
// 4. Clean up
await session.destroySession();
await moduleClient.terminate();
const moduleClient = new ModuleClient({
maxThreads: 8, // Optimize thread count (more Threads = more concurrent Requests, test whats the best for you)
});
// Create multiple sessions for different purposes
const loginSession = new SessionClient(moduleClient, {
defaultHeaders: { 'User-Agent': 'Chrome/146.0.0.0' },
});
const apiSession = new SessionClient(moduleClient, {
defaultHeaders: { Authorization: 'Bearer token' },
});
// Use sessions concurrently
await Promise.all([
loginSession.post('https://example.com/login', credentials),
apiSession.get('https://example.com/api/data'),
]);
// Clean up
await loginSession.destroySession();
await apiSession.destroySession();
await moduleClient.terminate();
const session = new SessionClient(moduleClient, {
// TLS Configuration
tlsClientIdentifier: 'chrome_146',
// Retry Configuration
retryIsEnabled: true,
retryMaxCount: 3,
retryStatusCodes: [429, 503, 504],
// Network Configuration
timeoutSeconds: 30,
proxyUrl: 'http://proxy:8080',
// Default Headers & Cookies
defaultHeaders: {
'User-Agent': 'Custom/1.0',
},
defaultCookies: [
{
domain: 'example.com',
name: 'session',
value: 'xyz',
},
],
});
const moduleClient = new ModuleClient();
const session = new SessionClient(moduleClient);
// Process multiple URLs efficiently
const urls = Array.from({ length: 100 }, (_, i) => `https://api.example.com/item/${i}`);
// Batch requests with concurrency control
const batchSize = 10;
for (let i = 0; i < urls.length; i += batchSize) {
const batch = urls.slice(i, i + batchSize);
const responses = await Promise.all(batch.map((url) => session.get(url)));
console.log(`Processed batch ${i / batchSize + 1}`);
}
await session.destroySession();
await moduleClient.terminate();
const moduleClient = new ModuleClient();
// Monitor worker pool performance
setInterval(() => {
const stats = moduleClient.getPoolStats();
console.log(stats);
}, 5000);
const session = new SessionClient(moduleClient, {
withDebug: true, // Enable debug logging
});
// ... your requests ...
For detailed API documentation and type information, explore the source code or use an editor with TypeScript Intellisense support. All public classes and methods are fully typed and documented for easy discovery.
This wrapper requires:
Special thanks to:
$ claude mcp add tlsClient \
-- python -m otcore.mcp_server <graph>