Node.js API¶
Generated from the package's public TypeScript declarations. See the Node.js integration guide for examples.
ENGINE_MAJOR¶
The engine major this package belongs to. A transport whose hello says another, or none, is sent no request.
MAX_REQUEST_BYTES¶
The most a request can be, in bytes, as the transport reads it: one line of JSON, its newline included, in UTF-8. A longer one would end the transport, and the session in it, so it is refused with a RangeError before it is queued.
ClientOptions¶
How a client is made. Each option is passed to tls-forge daemon.
Properties
profilestringoptionalproxystringoptionaltimeoutnumberoptionalbinarystringoptionalinsecurebooleanoptionalcookieFilestringoptional--cookies reads one.cookieSetstringoptionalcookieFile.onStderr(line: string) => voidoptionalNetworkContext¶
Actual network metadata; signal null means unavailable, zero is known. generation identifies a network-change epoch and must be a safe integer. Estimates are generated by the profile rather than supplied as headers.
Properties
type'unknown' | 'ethernet' | 'wifi' | '2g' | '3g' | '4g' | '5g' | 'none' | 'bluetooth'idstringgenerationnumbersignalnumber | nullBrowserContext¶
What in a browser a request stands for: it goes out as Chrome sends that kind, CORS and all. See GO.md, «Browser contexts».
Properties
kind'navigation' | 'form' | 'fetch' | 'xhr'initiatorstringoptionalreferrerPolicy'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url'optionalmode'cors' | 'no-cors' | 'same-origin'optionalcredentials'same-origin' | 'include' | 'omit'optionalRequestOptions¶
What get and post take besides the URL and the body.
Properties
headersRecord<string, string>optionalorderstring[]optionalcookiesstring[]optionalname=value pairs put in the jar before the request.browserContextBrowserContextoptionalnetworkContextNetworkContextoptionalRequest¶
A request, as request takes it.
Properties
urlstringmethodstringoptionalbodystring | Buffer | Uint8ArrayoptionalResponse¶
What came back: exactly these fields, in this order.
Properties
statusnumberurlstringbodystringcontentBufferheadersRecord<string, string[]>cookiesstring[]name=value pairs the jar holds for the final URL.Hello¶
What a transport is, as it answers hello.
Properties
engine_majornumberoptionalversionstringoptionalprotocolnumbercapabilitiesstring[]browser_context.Client¶
One browser identity: one transport process, one fingerprint, one cookie jar, one request at a time.
new Client()¶
A client, and no transport yet: the first request starts one.
Throws
RangeErrorTypeErrorClient.get()¶
GET a URL.
Client.post()¶
POST a body, in the browserContext of the form or script that posts it: a request without one is a navigation typed into the address bar, which posts nothing, and is refused. A Buffer or Uint8Array is sent as base64, so a body that is not text arrives intact.
Client.request()¶
Make a request. One with a browserContext or a networkContext is sent only to a transport that says, when asked with hello(), that it applies one, and to no other: it is refused with Unsupported rather than sent as though it had none. The first such request waits for that answer, and a request made after it may go first.
Client.hello()¶
What the transport is: the protocol it speaks and what it can do, asked without a connection and once. One older than the question speaks protocol 1, and can do nothing a client has to ask about.
Client.close()¶
Stop the transport, and reject what waits. Final.
resolveBinary()¶
The transport binary: the one given, TLSFORGE_BIN, the platform package, a local build, or the one on PATH, in that order.
Throws
TLSForgeError¶
The base of every error this package throws or rejects with.
new TLSForgeError()¶
BinaryNotFound¶
No transport binary was found, or the one named is not there: an install problem, which no retry mends.
TransportError¶
The transport failed: it would not start, would not take its arguments or its proxy, died, could not be written to, was closed, or answered with something that is not an answer. The request did not happen, or happened and its answer was lost. The client stays usable: the next request starts a fresh transport.
SessionReset¶
A request that was not sent because the transport the client's session was in has gone: its cookies, TLS sessions and connections went with it. Every request waiting when that happens is rejected with this, and the next one made is when none was waiting; requests after that start a new session in a new transport. The client never promises the identity it had before.
RequestFailed¶
The transport made the request, and the request failed: a refused connection, a DNS failure, a TLS error, a proxy that would not tunnel, or a request the transport would not make as it was asked. Nothing is wrong locally, and trying again can make sense.
| Example | |
|---|---|
Unsupported¶
A request this client's transport cannot make as asked: it does not do what the request needs, as it says when asked with hello(), or it is older than the question. The request was not sent.
Timeout¶
The deadline passed with no answer.
The package's default export is Client.