node-tls-clientLatest version on npm

SessionOptions

Every option you can pass to new Session(), and to fetch() as its options field.

const session = new Session({
  clientIdentifier: ClientIdentifier.chrome_150,
  headers: { "user-agent": "Mozilla/5.0 …" },
  proxy: "http://user:pass@proxy.example.com:8080",
  timeout: 10_000,
});

Every option is optional and applies to every request the session sends. fetch() takes the same object as options. Per-request settings (body, redirects, per-request headers, …) are in Request options.

Options are grouped by what they control. A default of "—" means the option isn't sent, and the browser profile or the native library decides.

All options

Fingerprint

OptionTypeDefaultWhat it does
clientIdentifierClientIdentifierchrome_150Built-in browser or app profile to impersonate. See Browser profiles.
ja3stringstring—Build a custom fingerprint from a JA3 string instead. Only used when clientIdentifier is not set. See Custom fingerprints.
randomTlsExtensionOrderbooleanfalseRandomise the order of TLS extensions in the ClientHello, as current Chrome does.

Custom fingerprint (ja3string only)

These only apply when the session has a ja3string and no clientIdentifier. With a clientIdentifier, they're ignored. See Custom fingerprints for how to read them off a capture.

TLS ClientHello

OptionTypeDefaultWhat it does
supportedSignatureAlgorithmsSupportedSignatureAlgorithms[]—Signature algorithms offered, in order.
supportedDelegatedCredentialsAlgorithmsSupportedDelegatedCredentialsAlgorithms[]—Algorithms for the delegated credentials extension (Firefox sends it).
supportedVersionsSupportedVersions[]—TLS versions offered, e.g. ["GREASE", "1.3", "1.2"].
keyShareCurvesKeyShareCurves[]—Curves to send key shares for, e.g. ["GREASE", "X25519MLKEM768", "X25519"].
certCompressionAlgosCertCompressionAlgo[]["zlib"]Certificate compression algorithms offered.
certCompressionAlgoCertCompressionAlgo—Deprecated: a single value, wrapped into certCompressionAlgos. Use certCompressionAlgos.
alpnProtocolsstring[]—ALPN protocols offered, e.g. ["h2", "http/1.1"].
alpsProtocolsstring[]—ALPS (application settings) protocols, e.g. ["h2"] for Chrome.
recordSizeLimitnumber—Value of the TLS record_size_limit extension (Firefox sends it).
echCandidatePayloadsnumber[]—Candidate payload lengths for the Encrypted Client Hello extension.
echCandidateCipherSuitesCandidateCipherSuite[]—Candidate cipher suites for Encrypted Client Hello.
trustAnchorsPayloadstring—Trust-anchors extension payload. Required when the JA3 string lists extension 51764. Ignored by the 1.16.0 native release.

HTTP/2

OptionTypeDefaultWhat it does
h2SettingsH2Settings—Values of the HTTP/2 SETTINGS frame.
h2SettingsOrder(keyof H2Settings)[]—Order of the SETTINGS entries.
connectionFlownumber—Connection-level WINDOW_UPDATE increment, e.g. 15663105 for Chrome.
priorityFramesPriorityFrames[]—PRIORITY frames sent after the connection opens.
headerPriorityPriorityParam | nullzeroed priorityPriority attached to each request's HEADERS frame. null sends none. weight is 0–255.
pseudoHeaderOrderPseudoHeaderOrder[]—Order of :method, :authority, :scheme, :path.
streamIdnumber—HTTP/2 stream ID used by the custom client.
allowHttpbooleanfalseAllow plain HTTP with the custom client.

HTTP/3

OptionTypeDefaultWhat it does
h3SettingsH3Settings—Values of the HTTP/3 SETTINGS frame.
h3SettingsOrder(keyof H3Settings)[]—Order of the HTTP/3 SETTINGS entries.
h3PseudoHeaderOrderPseudoHeaderOrder[]—Pseudo-header order on HTTP/3 requests.
h3PriorityParamnumber—HTTP/3 priority parameter.
h3SendGreaseFramesbooleanfalseSend HTTP/3 GREASE frames, as Chrome does. See HTTP/3.

Headers

OptionTypeDefaultWhat it does
headersHeaderInputsmall built-in setHeaders sent with every request. Request headers are merged over them. Without any headers, User-Agent: tls-client/2.2.0 is sent. See Headers.
headerOrderstring[]—Header names, lower-case, in the order to send them. Unlisted headers come after. A request's headerOrder replaces it.
connectHeadersRecord<string, string[]>—Headers for the proxy CONNECT request. A request's connectHeaders replace them. See Proxies.

Proxy

OptionTypeDefaultWhat it does
proxystring—http://, http://user:pass@ or socks5:// proxy URL for every request. A request's proxy overrides it. See Proxies.
isRotatingProxybooleanfalseRe-apply the proxy before every request instead of reusing pooled connections, for providers that rotate the exit IP per connection.

Timeouts

OptionTypeDefaultWhat it does
timeoutnumber30 sPer-request timeout in milliseconds. A request that runs out resolves with status: 0. 0 means unset.
timeoutSecondsnumber—The same in seconds. Only used when timeout is unset; if both are set, timeout wins and a warning is logged.

Cookies

OptionTypeDefaultWhat it does
withoutCookieJarbooleanfalseTurn the cookie jar off: response cookies aren't sent on later requests, only the cookies you pass. See Cookies.
withCustomCookieJarbooleanfalseUse tls-client's own cookie jar instead of Go's standard one.

TLS and certificates

OptionTypeDefaultWhat it does
insecureSkipVerifybooleanfalseAccept any certificate (self-signed, expired, wrong host). For testing only. See TLS verification.
certificatePinningHostsRecord<string, string[]>—{ host: [pins] }: only accept certificates whose public-key hash matches a pin. Once set, unlisted hosts fail too.
serverNameOverwritestringURL hostTLS server name (SNI) to send instead of the URL's host.
disableSessionTicketsbooleanfalseTurn off TLS session tickets and resumption. Ignored by the 1.16.0 native release.

Protocols

OptionTypeDefaultWhat it does
forceHttp1booleanfalseUse HTTP/1.1 even when the server supports HTTP/2.
withProtocolRacingbooleanfalseRace HTTP/2 against HTTP/3 like a browser. Needs a SOCKS5 proxy or none. See HTTP/3 for known issues.
disableHttp3booleanfalseNever use HTTP/3 (QUIC).

Connections and network

OptionTypeDefaultWhat it does
transportOptionsTransportOptions—Keep-alive pool, connection limits, buffer sizes. See Connection tuning.
localAddressstringOS choosesSource address for outgoing connections, as host:port (port 0 lets the OS pick).
disableIPV4booleanfalseOnly connect over IPv6.
disableIPV6booleanfalseOnly connect over IPv4.

Session and debugging

OptionTypeDefaultWhat it does
sessionIdstringrandom UUIDName of the native session. Sessions with the same id share one cookie jar, connections and fingerprint. See Sessions.
debugbooleanfalsePrint each raw request and response (headers, cookies, status, bytes) to stdout. See Errors and debugging.
streamOutputPathstring—Write each response body to this file (appending) instead of returning it: res.body is empty.
streamOutputBlockSizenumber1024Block size in bytes for streamOutputPath.
streamOutputEOFSymbolstring—Text appended to the file when a body ends.

TransportOptions

Passed as transportOptions. Every field is optional; fields you leave out keep their defaults. See Connection tuning.

FieldTypeDescription
disableKeepAlives?booleanIf true, disables HTTP keep-alive connections.
disableCompression?booleanIf true, disables automatic response decompression (gzip, deflate, etc.).
maxIdleConns?numberThe maximum number of idle (keep-alive) connections across all hosts.
maxIdleConnsPerHost?numberThe maximum number of idle (keep-alive) HTTP/1.1 connections to keep per host. Default: 256, as in Node's http.Agent (0 means Go's default of 2).
maxConnsPerHost?numberThe maximum number of total connections per host (idle + active).
maxResponseHeaderBytes?numberThe maximum number of bytes allowed in response headers. If zero, a default is used.
writeBufferSize?numberThe size of the write buffer in bytes. If zero, a default (typically 4KB) is used.
readBufferSize?numberThe size of the read buffer in bytes. If zero, a default (typically 4KB) is used.
idleConnTimeout?numberThe maximum idle connection timeout, in nanoseconds.

H2Settings

Passed as h2Settings (ja3string only). Their order comes from h2SettingsOrder.

FieldTypeDescription
HEADER_TABLE_SIZE?numberThe size of the header compression table used in HTTP/2.
ENABLE_PUSH?number | booleanIndicates whether server push is enabled in HTTP/2: 1/0. A boolean (the 2.1.0 type) is accepted too and sent as 1/0, since the native settings map is numeric.
MAX_CONCURRENT_STREAMS?numberThe maximum number of concurrent streams allowed in HTTP/2.
INITIAL_WINDOW_SIZE?numberThe initial window size for HTTP/2 data frames.
MAX_FRAME_SIZE?numberThe maximum size of HTTP/2 frames.
MAX_HEADER_LIST_SIZE?numberThe maximum size of header list in HTTP/2.
UNKNOWN_SETTING_7?numberRaw HTTP/2 setting id 0x7 (no standard name; sent as-is).
UNKNOWN_SETTING_8?numberRaw HTTP/2 setting id 0x8 (no standard name; sent as-is).
UNKNOWN_SETTING_9?numberRaw HTTP/2 setting id 0x9 (no standard name; sent as-is).

H3Settings

Passed as h3Settings (ja3string only). Their order comes from h3SettingsOrder. See HTTP/3.

FieldTypeDescription
QPACK_MAX_TABLE_CAPACITY?number
MAX_FIELD_SECTION_SIZE?number
QPACK_BLOCKED_STREAMS?number
H3_DATAGRAM?number

PriorityFrames

One entry of priorityFrames (ja3string only).

FieldTypeDescription
streamIDnumberThe stream ID for which priority is set.
priorityParamPriorityParamThe parameters for priority settings.

PriorityParam

Used by PriorityFrames.priorityParam and headerPriority. weight is 0–255.

FieldTypeDescription
streamDepnumberThe stream dependency for priority.
exclusivebooleanIndicates whether the priority is exclusive.
weightnumberThe weight of the priority.

CandidateCipherSuite

One entry of echCandidateCipherSuites (ja3string only). kdfId and aeadId take the KdfId and AeadId values.

FieldTypeDescription
kdfIdKdfId
aeadIdAeadId

On this page