azuretls
v0.0.6
Published
A TypeScript/Node.js wrapper for AzureTLS's C FFI with an API closely matching undici's fetch.
Downloads
635
Maintainers
Readme
azuretls
A TypeScript/Node.js wrapper for AzureTLS's C FFI with an API closely matching undici's fetch.
Installation
npm install azuretlsThe native library will be automatically downloaded during installation for your platform (Windows, macOS, Linux) and architecture (amd64, arm64). The native library is downloaded from azuretls-client.
Simple usage
import { AzureTLSSession } from 'azuretls';
const session = new AzureTLSSession();
const response = await session.get('https://example.com');
console.log(response.statusCode);
console.log(response.text()); // .json(), .arrayBuffer(), .blob() and .bytes() are also offered
session.close();API Reference
AzureTLSSession
Constructor
new AzureTLSSession(config?: SessionConfig)SessionConfig:
browser?: 'chrome' | 'firefox' | 'safari' | 'edge' | 'ios'user_agent?: stringproxy?: stringtimeout_ms?: numbermax_redirects?: numberinsecure_skip_verify?: booleanordered_headers?: [string, string][]headers?: Record<string, string>
Methods
HTTP Methods:
get(url: string, options?: RequestOptions): Promise<AzureTLSResponse>post(url: string, options?: RequestOptions): Promise<AzureTLSResponse>put(url: string, options?: RequestOptions): Promise<AzureTLSResponse>delete(url: string, options?: RequestOptions): Promise<AzureTLSResponse>head(url: string, options?: RequestOptions): Promise<AzureTLSResponse>options(url: string, options?: RequestOptions): Promise<AzureTLSResponse>patch(url: string, options?: RequestOptions): Promise<AzureTLSResponse>
Fingerprinting:
applyJa3(ja3: string, navigator?: string): voidapplyHttp2(fingerprint: string): voidapplyHttp3(fingerprint: string): void
Proxy:
setProxy(proxy: string): voidclearProxy(): void
Certificate Pinning:
addPins(url: string, pins: string[]): voidclearPins(url: string): void
Utilities:
getIp(): Promise<string>getVersion(): stringclose(): void
License
The majority of code was taken from the example Typescript usage for azuretls-client and made to work with koffi.
MIT
