🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@aptos-labs/aptos-client

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aptos-labs/aptos-client - npm Package Compare versions

Comparing version
4.0.0
to
4.1.0
+1
-1
dist/cookieJar.d.ts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"cookieJar.d.ts","sourceRoot":"","sources":["../src/cookieJar.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,QAAQ,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;IACrC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,SAAS;IAKR,OAAO,CAAC,GAAG;IAJvB,MAAM,CAAC,QAAQ,CAAC,sBAAsB,MAAM;IAC5C,+DAA+D;IAC/D,MAAM,CAAC,QAAQ,CAAC,eAAe,QAAQ;gBAEnB,GAAG,wBAA8B;IAErD;;;;;OAKG;IACH,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM;IA8BrC;;;;;OAKG;IACH,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,EAAE;IA0B9B,4DAA4D;IAC5D,KAAK;IAIL;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;CAsElC"}
{"version":3,"file":"cookieJar.d.ts","sourceRoot":"","sources":["../src/cookieJar.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,QAAQ,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;IACrC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,SAAS;IAKR,OAAO,CAAC,GAAG;IAJvB,MAAM,CAAC,QAAQ,CAAC,sBAAsB,MAAM;IAC5C,+DAA+D;IAC/D,MAAM,CAAC,QAAQ,CAAC,eAAe,QAAQ;gBAEnB,GAAG,wBAA8B;IAErD;;;;;OAKG;IACH,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM;IA8BrC;;;;;OAKG;IACH,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,EAAE;IAyB9B,4DAA4D;IAC5D,KAAK;IAIL;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;CAsElC"}

@@ -70,5 +70,3 @@ /**

const live = cookies.filter((cookie) => {
if (cookie.expires && cookie.expires <= now)
return false;
return true;
return !(cookie.expires && cookie.expires <= now);
});

@@ -75,0 +73,0 @@ // Write back to evict expired cookies from storage

@@ -1,1 +0,1 @@

{"version":3,"file":"cookieJar.js","sourceRoot":"","sources":["../src/cookieJar.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,SAAS;IAKA;IAJpB,MAAM,CAAU,sBAAsB,GAAG,EAAE,CAAC;IAC5C,+DAA+D;IAC/D,MAAM,CAAU,eAAe,GAAG,IAAI,CAAC;IAEvC,YAAoB,MAAM,IAAI,GAAG,EAAoB;QAAjC,QAAG,GAAH,GAAG,CAA8B;IAAG,CAAC;IAEzD;;;;;OAKG;IACH,SAAS,CAAC,GAAQ,EAAE,SAAiB;QACnC,IAAI,SAAS,CAAC,MAAM,GAAG,SAAS,CAAC,eAAe,EAA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AAC,GAAG,CAAC,CAAC,CAE5G;AAED;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAAC,cAAc,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC,CAE9G"}
{"version":3,"file":"index.node.d.ts","sourceRoot":"","sources":["../src/index.node.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAiB,MAAM,YAAY,CAAC;AAEzF,YAAY,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,YAAY,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAKzF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAA8B,WAAW,CAAC,GAAG,EAAE,cAAc,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAEpH;AAED;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAAC,GAAG,EAAE,cAAc,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAE5G;AAED;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAAC,cAAc,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC,CAE9G"}
/**
* Node.js HTTP client backed by {@link https://undici.nodejs.org | undici}.
* Node.js HTTP client backed by {@link https://github.com/sindresorhus/got | got}.
*
* @remarks
* This entry point is selected when the package is imported from Node.js
* (via the `"node"` export condition). It uses undici's `Agent` with
* configurable HTTP/2 support (`allowH2`). Agents are cached per origin
* so connections are reused across requests to the same host.
* (via the `"node"` export condition). It uses {@link got} for transport,
* which provides:
*
* - HTTP/2 negotiation via `http2-wrapper` (`http2: true`).
* - Transparent decompression of `br`, `gzip`, and `deflate` response bodies
* on both HTTP/1.1 and HTTP/2 (`decompress: true`, the default).
* - Built-in connection pooling — we don't manage our own dispatcher cache.
*
* Historical note: v3 of this package replaced `got` with `undici`, but the
* `fetch + custom dispatcher` combination silently dropped response headers
* (including `set-cookie`) and failed to decompress responses on H2 (and
* via the fetch wrapper on H1 too). v4 returns to `got` because its body
* pipeline handles decompression independent of the transport, which is the
* only shape that works reliably with the Aptos fullnode (brotli) and
* indexer (gzip) endpoints.
*
* @module index.node
*/
import { Agent } from "undici";
import { STATUS_CODES } from "node:http";
import got, { HTTPError, RequestError } from "got";
import { CookieJar } from "./cookieJar.js";
import { applyCookiesToHeaders, applyJsonContentType, buildUrl, headersToRecord, parseJsonSafely, serializeBody, storeResponseCookies, } from "./shared.js";
import { buildUrl, serializeBody } from "./shared.js";
export { CookieJar } from "./cookieJar.js";
const textDecoder = new TextDecoder("utf-8");
const defaultCookieJar = new CookieJar();
/** One dispatcher per origin + HTTP/2 mode for connection reuse. */
const dispatcherCache = new Map();
const MAX_DISPATCHERS = 50;
/**

@@ -75,22 +86,76 @@ * Send a JSON request to an Aptos API endpoint.

const requestUrl = buildUrl(url, params);
const requestHeaders = buildHeaders(requestUrl, headers, jar);
const dispatcher = getDispatcher(requestUrl.origin, http2);
const init = {
method,
headers: requestHeaders,
dispatcher,
};
const requestHeaders = buildHeaders(requestUrl, headers, body, jar);
// `serializeBody` returns string | Uint8Array | undefined; got accepts both as `body`.
const serialized = serializeBody(body);
if (serialized !== undefined) {
init.body = serialized;
applyJsonContentType(body, requestHeaders);
let response;
try {
response = await got(requestUrl, {
method,
headers: requestHeaders,
body: serialized,
http2,
// Don't throw on 4xx/5xx — callers (e.g., the TS SDK) inspect the
// status code and handle errors themselves. Matches v2 behavior.
throwHttpErrors: false,
// Disable retries; SDK callers manage their own retry policy.
retry: { limit: 0 },
// Body comes back as a Uint8Array; we decode JSON / hand back ArrayBuffer
// ourselves so the empty-body and BCS cases stay consistent.
responseType: "buffer",
// `decompress: true` is the default — listed explicitly to make the
// intent (transparent br/gzip/deflate decoding) visible.
decompress: true,
// got's H2 path (via http2-wrapper) sets its own TLS context and does
// NOT inherit `NODE_TLS_REJECT_UNAUTHORIZED` from the env. Pass it
// through explicitly, so the documented Node env var works as expected.
https: {
rejectUnauthorized: process.env.NODE_TLS_REJECT_UNAUTHORIZED !== "0",
},
});
}
const res = await fetch(requestUrl, init);
storeResponseCookies(requestUrl, res.headers, jar);
const data = mode === "json" ? await parseJsonSafely(res) : await res.arrayBuffer();
catch (err) {
// got throws for transport-level failures (DNS, ECONNREFUSED, parse errors).
// HTTP 4xx/5xx do NOT throw thanks to throwHttpErrors: false. We preserve
// a v2-compatible shape: if there's an attached response, surface it as a
// normal AptosClientResponse so callers can read .status.
if ((err instanceof HTTPError || err instanceof RequestError) && err.response) {
response = err.response;
}
else {
throw err;
}
}
storeResponseCookies(requestUrl, response.headers, jar);
// got's `responseType: "buffer"` returns a Uint8Array (not a Node Buffer)
// in v15+.
const raw = response.body;
// TODO: at some point provide better type guarantees, since there is some legacy behavior in here
// biome-ignore lint/suspicious/noExplicitAny: legacy behavior, union of multiple body shapes
let data;
if (mode === "arrayBuffer") {
// Slice out a fresh ArrayBuffer that matches the body length exactly.
data = response.body.buffer.slice(raw.byteOffset, raw.byteOffset + raw.byteLength);
}
else if (response.statusCode === 204 || response.statusCode === 205 || response.body.byteLength === 0) {
data = null;
}
else {
const text = textDecoder.decode(response.body);
try {
data = JSON.parse(text);
}
catch {
// Backward compat: return raw text so callers can inspect non-JSON bodies.
data = text;
}
}
return {
status: res.status,
statusText: res.statusText,
status: response.statusCode,
statusText: response.statusMessage ?? STATUS_CODES[response.statusCode] ?? "",
data,
config: { ...init, headers: headersToRecord(requestHeaders) },
config: {
method,
headers: requestHeaders,
body: serialized,
},
request: {

@@ -100,53 +165,76 @@ url: requestUrl.toString(),

},
response: res,
headers: headersToRecord(res.headers),
response,
headers: normalizeHeaders(response.headers),
};
}
/**
* Return a cached undici `Agent` for the given origin, creating one if needed.
* Build the outgoing header record: caller-supplied headers, jar cookies,
* and a default JSON `content-type` for non-binary bodies.
*
* @param origin - URL origin (scheme + host + port).
* @param http2 - Whether to enable HTTP/2 via ALPN (`allowH2`).
* @remarks
* Unlike the v3 (undici) implementation, we do NOT need to manage
* `accept-encoding` here — `got` advertises the encodings it can decode
* and decompresses the response body transparently.
*
* @internal
*/
function getDispatcher(origin, http2) {
const key = `${origin}|h2=${http2}`;
const cached = dispatcherCache.get(key);
if (cached) {
// Move to end of Map (most-recently-used)
dispatcherCache.delete(key);
dispatcherCache.set(key, cached);
return cached;
function buildHeaders(url, headers, body, jar) {
const result = {};
for (const [key, value] of Object.entries(headers ?? {})) {
if (value !== undefined) {
result[key.toLowerCase()] = String(value);
}
}
// Evict oldest entry if cache is full
if (dispatcherCache.size >= MAX_DISPATCHERS) {
// biome-ignore lint/style/noNonNullAssertion: cache size check guarantees entry exists
const oldest = dispatcherCache.keys().next().value;
// biome-ignore lint/style/noNonNullAssertion: oldest key was just retrieved from cache
dispatcherCache
.get(oldest)
.destroy()
.catch(() => { });
dispatcherCache.delete(oldest);
if (body != null && !(body instanceof Uint8Array) && !("content-type" in result)) {
result["content-type"] = "application/json";
}
const agent = new Agent({
allowH2: http2,
});
dispatcherCache.set(key, agent);
return agent;
applyJarCookies(result, url, jar);
return result;
}
/**
* Merge caller-supplied headers with cookies from the jar.
* Merge jar cookies into the outgoing `cookie` header.
* @internal
*/
function buildHeaders(url, headers, jar) {
const result = new Headers();
for (const [key, value] of Object.entries(headers ?? {})) {
function applyJarCookies(headers, url, jar) {
const cookies = jar.getCookies(url);
if (cookies.length === 0)
return;
const jarCookies = cookies.map((c) => `${c.name}=${c.value}`).join("; ");
const existing = headers.cookie;
headers.cookie = existing ? `${existing}; ${jarCookies}` : jarCookies;
}
/**
* Extract `set-cookie` headers from the response and store them in the jar.
*
* `got` returns `set-cookie` as `string[]` (one entry per cookie) on
* `response.headers["set-cookie"]`. Other headers are plain strings.
*
* @internal
*/
function storeResponseCookies(url, headers, jar) {
const setCookie = headers["set-cookie"];
if (!setCookie)
return;
const cookies = Array.isArray(setCookie) ? setCookie : [setCookie];
for (const cookie of cookies) {
jar.setCookie(url, cookie);
}
}
/**
* Normalize got's header record to the v2-compatible response-headers shape.
*
* got already gives us lowercased plain-object headers; we strip undefined
* entries so downstream callers see only present headers.
*
* @internal
*/
function normalizeHeaders(headers) {
const result = {};
for (const [key, value] of Object.entries(headers)) {
if (value !== undefined) {
result.set(key, String(value));
result[key] = value;
}
}
applyCookiesToHeaders(result, url, jar);
return result;
}
//# sourceMappingURL=index.node.js.map

@@ -1,1 +0,1 @@

{"version":3,"file":"index.node.js","sourceRoot":"","sources":["../src/index.node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,QAAQ,EACR,eAAe,EACf,eAAe,EACf,aAAa,EACb,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAIrB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,MAAM,gBAAgB,GAAG,IAAI,SAAS,EAAE,CAAC;AAEzC,oEAAoE;AACpE,MAAM,eAAe,GAAG,IAAI,GAAG,EAAiB,CAAC;AACjD,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,WAAW,CAAM,cAAkC;IAC/E,OAAO,WAAW,CAAC,cAAc,CAAC,CAAC;AACrC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAM,cAAkC;IACvE,OAAO,MAAM,SAAS,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AACjD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,cAAkC;IACjE,O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,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}

@@ -30,3 +30,3 @@ /**

* Set the `content-type` header to `application/json` when the body is
* a non-binary, non-null value and no content-type has been set already.
* a non-binary, non-null value and no content-type has been set.
* @internal

@@ -40,3 +40,3 @@ */

* with v2, where `got` returned error responses as normal `AptosClientResponse`
* objects. This lets the caller (e.g. the TS SDK) inspect the status code and
* objects. This lets the caller (e.g., the TS SDK) inspect the status code and
* handle the error however it chooses.

@@ -65,3 +65,3 @@ *

* returned Node's `IncomingHttpHeaders` (a plain object) from the `got`
* library. Consumers (e.g. the TS SDK) access headers via bracket
* library. Consumers (e.g., the TS SDK) access headers via bracket
* notation (`response.headers["x-aptos-cursor"]`), which only works on

@@ -68,0 +68,0 @@ * plain objects — not on `Headers` instances.

@@ -38,3 +38,3 @@ /**

* Set the `content-type` header to `application/json` when the body is
* a non-binary, non-null value and no content-type has been set already.
* a non-binary, non-null value and no content-type has been set.
* @internal

@@ -52,3 +52,3 @@ */

* with v2, where `got` returned error responses as normal `AptosClientResponse`
* objects. This lets the caller (e.g. the TS SDK) inspect the status code and
* objects. This lets the caller (e.g., the TS SDK) inspect the status code and
* handle the error however it chooses.

@@ -105,3 +105,3 @@ *

* returned Node's `IncomingHttpHeaders` (a plain object) from the `got`
* library. Consumers (e.g. the TS SDK) access headers via bracket
* library. Consumers (e.g., the TS SDK) access headers via bracket
* notation (`response.headers["x-aptos-cursor"]`), which only works on

@@ -108,0 +108,0 @@ * plain objects — not on `Headers` instances.

@@ -15,3 +15,3 @@ /**

data: Res;
/** The `RequestInit` (or undici equivalent) that was sent. */
/** The request options that were sent (shape varies per entry point). */
config?: any;

@@ -78,6 +78,7 @@ /** Metadata about the outgoing request (Node entry point only). */

* @remarks
* Only effective in the **Node** entry point, where it maps to
* undici's `Agent({ allowH2 })`. In the **fetch**, **browser**, and
* **React Native** entry points the underlying runtime negotiates
* HTTP/2 automatically via ALPN — this option is ignored.
* Only effective in the **Node** entry point, where it maps to got's
* `http2` option (which uses `http2-wrapper` under the hood to negotiate
* H2 via ALPN). In the **fetch**, **browser**, and **React Native** entry
* points the underlying runtime negotiates HTTP/2 automatically — this
* option is ignored there.
*/

@@ -84,0 +85,0 @@ http2?: boolean;

@@ -1,1 +0,1 @@

{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,CAAC,GAAG,IAAI;IACrC,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,UAAU,EAAE,MAAM,CAAC;IACnB,4BAA4B;IAC5B,IAAI,EAAE,GAAG,CAAC;IACV,8DAA8D;IAE9D,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,mEAAmE;IAEnE,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,yDAAyD;IAEzD,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,oDAAoD;IACpD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;CAC7C,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC5B,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACxD,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9C;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,qDAAqD;IACrD,GAAG,EAAE,MAAM,CAAC;IACZ,yDAAyD;IACzD,MAAM,EAAE,KAAK,GAAG,MAAM,CAAC;IACvB;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,kGAAkG;IAClG,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG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EAAE,KAAK,GAAG,MAAM,CAAC;IACvB;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,kGAAkG;IAClG,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;IACxE,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAC7C;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE;QAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IAC3C;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,aAAa,CAAC;CAC3B,CAAC"}

@@ -56,2 +56,3 @@ {

"test": "tsx --test --test-force-exit test/node.test.ts test/fetch.test.ts test/browser.test.ts test/cookieJar.test.ts",
"coverage": "rm -rf coverage && mkdir -p coverage && tsx --test --experimental-test-coverage --test-coverage-include='src/**/*.ts' --test-coverage-exclude='test/**' --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=coverage/lcov.info --test-force-exit test/node.test.ts test/fetch.test.ts test/browser.test.ts test/cookieJar.test.ts",
"test:node": "tsx --test --test-force-exit test/node.test.ts",

@@ -71,3 +72,3 @@ "test:fetch": "tsx --test --test-force-exit test/fetch.test.ts",

"type": "git",
"url": "https://github.com/aptos-labs/aptos-client.git"
"url": "git+https://github.com/aptos-labs/aptos-client.git"
},

@@ -85,12 +86,12 @@ "homepage": "https://github.com/aptos-labs/aptos-client",

"dependencies": {
"undici": "^7.25.0"
"got": "^15.0.5"
},
"devDependencies": {
"@biomejs/biome": "^2.4.6",
"@types/node": "^22.19.17",
"esbuild": "^0.28.0",
"tsx": "^4.21.0",
"typescript": "^6.0.2"
"@biomejs/biome": "2.4.15",
"@types/node": "22.19.19",
"esbuild": "0.28.0",
"tsx": "4.22.2",
"typescript": "6.0.3"
},
"version": "4.0.0"
"version": "4.1.0"
}

@@ -6,2 +6,3 @@ ![License][github-license]

[![NPM Package Downloads][npm-image-downloads]][npm-url]
[![codecov](https://codecov.io/gh/aptos-labs/aptos-client/branch/main/graph/badge.svg)](https://codecov.io/gh/aptos-labs/aptos-client)

@@ -56,3 +57,3 @@ # @aptos-labs/aptos-client

|---|---|---|---|
| `node` | `index.node.ts` | Configurable via `http2` option (default `true`) | Uses [undici](https://undici.nodejs.org) `Agent({ allowH2 })` |
| `node` | `index.node.ts` | Configurable via `http2` option (default `true`) | Uses [got](https://github.com/sindresorhus/got) (decodes `br`/`gzip`/`deflate` transparently on H1 and H2) |
| `browser` | `index.browser.ts` | Automatic (browser engine) | Delegates cookies to the browser |

@@ -97,3 +98,3 @@ | `react-native` | `index.fetch.ts` | Automatic (OkHttp / NSURLSession) | Platform negotiates HTTP/2 via ALPN |

|---|---|
| **Node.js** | undici negotiates HTTP/2 via ALPN when `http2: true` (the default). Set `http2: false` to force HTTP/1.1. |
| **Node.js** | `got` negotiates HTTP/2 via ALPN (powered by `http2-wrapper`) when `http2: true` (the default). Set `http2: false` to force HTTP/1.1. |
| **Browser** | The browser engine negotiates HTTP/2 with the server automatically. The `http2` option is ignored. |

@@ -103,4 +104,53 @@ | **React Native** | OkHttp (Android) and NSURLSession (iOS) negotiate HTTP/2 via ALPN automatically. The `http2` option is ignored. |

#### Releasing a new version
## Migrating from v2
v4.1.0 returns to the same HTTP library v2 used (`got`) while keeping the v4 architecture (ESM, conditional exports, multi-runtime). For most callers the migration is one or two small edits.
> **If you are on v3.0.0 through v4.0.0, upgrade.** Those versions silently return raw compressed bytes instead of parsed JSON whenever the origin sends `content-encoding: br`/`gzip`/`deflate` — which is what the Aptos fullnode and indexer do. 4.1.0 restores v2-era decompression behavior.
### What works the same as v2
- `http2: true` default; falls back to H1.1 when the server doesn't support H2.
- Brotli / gzip / deflate decompression handled transparently.
- Cookie jar round-trips `set-cookie` and re-sends cookies on same-origin requests.
- `bigint` query params are stringified.
- 4xx / 5xx responses do **not** throw — inspect `res.status`.
- `AptosClientResponse` shape: `{ status, statusText, data, config, request, response, headers }` with `headers` as a plain `Record<string, string | string[]>`.
### Behavior changes (observable to callers)
| Change | v2 | v4.1.0 |
|---|---|---|
| **BCS response type** | `Buffer` | `ArrayBuffer` — cross-runtime, no `Buffer` polyfill needed. The bytes are identical; use `new Uint8Array(res.data)` or `Buffer.from(res.data)` if you need either shape. |
| **Retries** | got default (`limit: 2`, backoff) | **Off** (`limit: 0`). Wrap in your own retry loop, or let the Aptos TS SDK manage retries at a higher layer. |
| **Non-JSON bodies** | `JSON.parse` would throw | Falls back to returning the raw text in `data` — lets callers inspect the status code regardless of body content-type. |
| **Empty / 204 / 205 bodies** | Whatever got returned (often `""` or `undefined`) | Explicitly `null`. |
| **`statusText` over HTTP/2** | Empty string (H2 has no reason phrase) | Falls back to `http.STATUS_CODES[code]` — `"OK"`, `"Not Found"`, etc. |
| **`NODE_TLS_REJECT_UNAUTHORIZED=0` on H2** | Inherited transitively (worked by accident) | Explicitly propagated to got's `https.rejectUnauthorized` — works on both H1 and H2. |
### New capabilities since v2
- **Per-request cookie jar isolation** — pass `cookieJar: new CookieJar()` to keep multi-tenant requests from sharing cookie state.
- **Public `CookieJar`** is now exported (with RFC 6265 validation, expiry eviction, per-origin caps, and SameSite=None+Secure enforcement).
- **`CookieJarLike` interface** — bring your own jar (e.g. tough-cookie or a database-backed store).
- **Conditional exports** auto-select the right entry for Node / browser / Deno / Bun / Cloudflare Workers / Vercel Edge / React Native. v2 only shipped Node + browser.
- **`overrides.WITH_CREDENTIALS`** (browser entry) maps to `fetch`'s `credentials: "omit" | "include"`.
### Removed since v2
- **CJS `require()`** — the package is ESM-only since v4.0. Use `import` or `await import(...)`.
- **Re-export of got error types** — if you handled `RequestError` / `HTTPError` directly, import them from `got` (it's still a direct dependency).
- **Node < 22** — the minimum supported Node version is 22.
### Migration checklist
1. **Using `require()`?** → switch to `import` (or `await import()` from CJS).
2. **Calling `Buffer` methods on a BCS response?** → use `new Uint8Array(res.data)`, `new DataView(res.data)`, or wrap with `Buffer.from(res.data)`.
3. **Relying on automatic retries?** → add an explicit retry wrapper. (Most consumers — including the Aptos TS SDK — don't need to.)
4. **Node version < 22?** → upgrade.
That's the full migration. Everything else either works the same, is additive, or is a fixed bug.
## Releasing a new version
Releases are published to npm automatically via GitHub Actions whenever a GitHub release is created. The workflow lives in `.github/workflows/publish.yml`.

@@ -107,0 +157,0 @@

@@ -84,4 +84,3 @@ /** A parsed cookie with optional attributes. */

const live = cookies.filter((cookie) => {
if (cookie.expires && cookie.expires <= now) return false;
return true;
return !(cookie.expires && cookie.expires <= now);
});

@@ -88,0 +87,0 @@

/**
* Node.js HTTP client backed by {@link https://undici.nodejs.org | undici}.
* Node.js HTTP client backed by {@link https://github.com/sindresorhus/got | got}.
*
* @remarks
* This entry point is selected when the package is imported from Node.js
* (via the `"node"` export condition). It uses undici's `Agent` with
* configurable HTTP/2 support (`allowH2`). Agents are cached per origin
* so connections are reused across requests to the same host.
* (via the `"node"` export condition). It uses {@link got} for transport,
* which provides:
*
* - HTTP/2 negotiation via `http2-wrapper` (`http2: true`).
* - Transparent decompression of `br`, `gzip`, and `deflate` response bodies
* on both HTTP/1.1 and HTTP/2 (`decompress: true`, the default).
* - Built-in connection pooling — we don't manage our own dispatcher cache.
*
* Historical note: v3 of this package replaced `got` with `undici`, but the
* `fetch + custom dispatcher` combination silently dropped response headers
* (including `set-cookie`) and failed to decompress responses on H2 (and
* via the fetch wrapper on H1 too). v4 returns to `got` because its body
* pipeline handles decompression independent of the transport, which is the
* only shape that works reliably with the Aptos fullnode (brotli) and
* indexer (gzip) endpoints.
*
* @module index.node
*/
import { Agent } from "undici";
import { type IncomingMessage, STATUS_CODES } from "node:http";
import got, { HTTPError, RequestError } from "got";
import { CookieJar } from "./cookieJar.js";
import {
applyCookiesToHeaders,
applyJsonContentType,
buildUrl,
headersToRecord,
parseJsonSafely,
serializeBody,
storeResponseCookies,
} from "./shared.js";
import { buildUrl, serializeBody } from "./shared.js";
import type { AptosClientRequest, AptosClientResponse, CookieJarLike } from "./types.js";

@@ -29,8 +34,5 @@

const textDecoder = new TextDecoder("utf-8");
const defaultCookieJar = new CookieJar();
/** One dispatcher per origin + HTTP/2 mode for connection reuse. */
const dispatcherCache = new Map<string, Agent>();
const MAX_DISPATCHERS = 50;
/**

@@ -102,28 +104,79 @@ * Send a JSON request to an Aptos API endpoint.

const requestUrl = buildUrl(url, params);
const requestHeaders = buildHeaders(requestUrl, headers, jar);
const dispatcher = getDispatcher(requestUrl.origin, http2);
const requestHeaders = buildHeaders(requestUrl, headers, body, jar);
// `serializeBody` returns string | Uint8Array | undefined; got accepts both as `body`.
const serialized = serializeBody(body) as string | Uint8Array | undefined;
const init: RequestInit & { dispatcher?: Agent } = {
method,
headers: requestHeaders,
dispatcher,
};
const serialized = serializeBody(body);
if (serialized !== undefined) {
init.body = serialized;
applyJsonContentType(body, requestHeaders);
let response: {
body: Uint8Array<ArrayBuffer>;
statusCode: number;
} & IncomingMessage;
try {
response = await got(requestUrl, {
method,
headers: requestHeaders,
body: serialized,
http2,
// Don't throw on 4xx/5xx — callers (e.g., the TS SDK) inspect the
// status code and handle errors themselves. Matches v2 behavior.
throwHttpErrors: false,
// Disable retries; SDK callers manage their own retry policy.
retry: { limit: 0 },
// Body comes back as a Uint8Array; we decode JSON / hand back ArrayBuffer
// ourselves so the empty-body and BCS cases stay consistent.
responseType: "buffer",
// `decompress: true` is the default — listed explicitly to make the
// intent (transparent br/gzip/deflate decoding) visible.
decompress: true,
// got's H2 path (via http2-wrapper) sets its own TLS context and does
// NOT inherit `NODE_TLS_REJECT_UNAUTHORIZED` from the env. Pass it
// through explicitly, so the documented Node env var works as expected.
https: {
rejectUnauthorized: process.env.NODE_TLS_REJECT_UNAUTHORIZED !== "0",
},
});
} catch (err) {
// got throws for transport-level failures (DNS, ECONNREFUSED, parse errors).
// HTTP 4xx/5xx do NOT throw thanks to throwHttpErrors: false. We preserve
// a v2-compatible shape: if there's an attached response, surface it as a
// normal AptosClientResponse so callers can read .status.
if ((err instanceof HTTPError || err instanceof RequestError) && err.response) {
response = err.response;
} else {
throw err;
}
}
const res = await fetch(requestUrl, init);
storeResponseCookies(requestUrl, response.headers, jar);
storeResponseCookies(requestUrl, res.headers, jar);
// got's `responseType: "buffer"` returns a Uint8Array (not a Node Buffer)
// in v15+.
const raw = response.body;
const data = mode === "json" ? await parseJsonSafely(res) : await res.arrayBuffer();
// TODO: at some point provide better type guarantees, since there is some legacy behavior in here
// biome-ignore lint/suspicious/noExplicitAny: legacy behavior, union of multiple body shapes
let data: any;
if (mode === "arrayBuffer") {
// Slice out a fresh ArrayBuffer that matches the body length exactly.
data = response.body.buffer.slice(raw.byteOffset, raw.byteOffset + raw.byteLength);
} else if (response.statusCode === 204 || response.statusCode === 205 || response.body.byteLength === 0) {
data = null;
} else {
const text = textDecoder.decode(response.body);
try {
data = JSON.parse(text);
} catch {
// Backward compat: return raw text so callers can inspect non-JSON bodies.
data = text;
}
}
return {
status: res.status,
statusText: res.statusText,
status: response.statusCode,
statusText: response.statusMessage ?? STATUS_CODES[response.statusCode] ?? "",
data,
config: { ...init, headers: headersToRecord(requestHeaders) },
config: {
method,
headers: requestHeaders,
body: serialized,
},
request: {

@@ -133,4 +186,4 @@ url: requestUrl.toString(),

},
response: res,
headers: headersToRecord(res.headers),
response,
headers: normalizeHeaders(response.headers),
};

@@ -140,54 +193,84 @@ }

/**
* Return a cached undici `Agent` for the given origin, creating one if needed.
* Build the outgoing header record: caller-supplied headers, jar cookies,
* and a default JSON `content-type` for non-binary bodies.
*
* @param origin - URL origin (scheme + host + port).
* @param http2 - Whether to enable HTTP/2 via ALPN (`allowH2`).
* @remarks
* Unlike the v3 (undici) implementation, we do NOT need to manage
* `accept-encoding` here — `got` advertises the encodings it can decode
* and decompresses the response body transparently.
*
* @internal
*/
function getDispatcher(origin: string, http2: boolean): Agent {
const key = `${origin}|h2=${http2}`;
const cached = dispatcherCache.get(key);
if (cached) {
// Move to end of Map (most-recently-used)
dispatcherCache.delete(key);
dispatcherCache.set(key, cached);
return cached;
function buildHeaders(
url: URL,
headers: AptosClientRequest["headers"] | undefined,
body: unknown,
jar: CookieJarLike,
): Record<string, string> {
const result: Record<string, string> = {};
for (const [key, value] of Object.entries(headers ?? {})) {
if (value !== undefined) {
result[key.toLowerCase()] = String(value);
}
}
// Evict oldest entry if cache is full
if (dispatcherCache.size >= MAX_DISPATCHERS) {
// biome-ignore lint/style/noNonNullAssertion: cache size check guarantees entry exists
const oldest = dispatcherCache.keys().next().value!;
// biome-ignore lint/style/noNonNullAssertion: oldest key was just retrieved from cache
dispatcherCache
.get(oldest)!
.destroy()
.catch(() => {});
dispatcherCache.delete(oldest);
if (body != null && !(body instanceof Uint8Array) && !("content-type" in result)) {
result["content-type"] = "application/json";
}
const agent = new Agent({
allowH2: http2,
});
applyJarCookies(result, url, jar);
dispatcherCache.set(key, agent);
return agent;
return result;
}
/**
* Merge caller-supplied headers with cookies from the jar.
* Merge jar cookies into the outgoing `cookie` header.
* @internal
*/
function buildHeaders(url: URL, headers: AptosClientRequest["headers"] | undefined, jar: CookieJarLike): Headers {
const result = new Headers();
function applyJarCookies(headers: Record<string, string>, url: URL, jar: CookieJarLike): void {
const cookies = jar.getCookies(url);
if (cookies.length === 0) return;
const jarCookies = cookies.map((c) => `${c.name}=${c.value}`).join("; ");
const existing = headers.cookie;
headers.cookie = existing ? `${existing}; ${jarCookies}` : jarCookies;
}
for (const [key, value] of Object.entries(headers ?? {})) {
/**
* Extract `set-cookie` headers from the response and store them in the jar.
*
* `got` returns `set-cookie` as `string[]` (one entry per cookie) on
* `response.headers["set-cookie"]`. Other headers are plain strings.
*
* @internal
*/
function storeResponseCookies(
url: URL,
headers: Record<string, string | string[] | undefined>,
jar: CookieJarLike,
): void {
const setCookie = headers["set-cookie"];
if (!setCookie) return;
const cookies = Array.isArray(setCookie) ? setCookie : [setCookie];
for (const cookie of cookies) {
jar.setCookie(url, cookie);
}
}
/**
* Normalize got's header record to the v2-compatible response-headers shape.
*
* got already gives us lowercased plain-object headers; we strip undefined
* entries so downstream callers see only present headers.
*
* @internal
*/
function normalizeHeaders(headers: Record<string, string | string[] | undefined>): Record<string, string | string[]> {
const result: Record<string, string | string[]> = {};
for (const [key, value] of Object.entries(headers)) {
if (value !== undefined) {
result.set(key, String(value));
result[key] = value;
}
}
applyCookiesToHeaders(result, url, jar);
return result;
}

@@ -51,3 +51,3 @@ /**

* Set the `content-type` header to `application/json` when the body is
* a non-binary, non-null value and no content-type has been set already.
* a non-binary, non-null value and no content-type has been set.
* @internal

@@ -66,3 +66,3 @@ */

* with v2, where `got` returned error responses as normal `AptosClientResponse`
* objects. This lets the caller (e.g. the TS SDK) inspect the status code and
* objects. This lets the caller (e.g., the TS SDK) inspect the status code and
* handle the error however it chooses.

@@ -120,3 +120,3 @@ *

* returned Node's `IncomingHttpHeaders` (a plain object) from the `got`
* library. Consumers (e.g. the TS SDK) access headers via bracket
* library. Consumers (e.g., the TS SDK) access headers via bracket
* notation (`response.headers["x-aptos-cursor"]`), which only works on

@@ -123,0 +123,0 @@ * plain objects — not on `Headers` instances.

@@ -15,3 +15,3 @@ /**

data: Res;
/** The `RequestInit` (or undici equivalent) that was sent. */
/** The request options that were sent (shape varies per entry point). */
// biome-ignore lint/suspicious/noExplicitAny: cross-platform response type; varies per entry point

@@ -78,6 +78,7 @@ config?: any;

* @remarks
* Only effective in the **Node** entry point, where it maps to
* undici's `Agent({ allowH2 })`. In the **fetch**, **browser**, and
* **React Native** entry points the underlying runtime negotiates
* HTTP/2 automatically via ALPN — this option is ignored.
* Only effective in the **Node** entry point, where it maps to got's
* `http2` option (which uses `http2-wrapper` under the hood to negotiate
* H2 via ALPN). In the **fetch**, **browser**, and **React Native** entry
* points the underlying runtime negotiates HTTP/2 automatically — this
* option is ignored there.
*/

@@ -84,0 +85,0 @@ http2?: boolean;