diff --git a/types/blake2/index.d.ts b/types/blake2/index.d.ts
index e97c51c6d3a687..412b47b42f5cae 100644
--- a/types/blake2/index.d.ts
+++ b/types/blake2/index.d.ts
@@ -1,5 +1,4 @@
///
-import { BinaryToTextEncoding } from "crypto";
import { Transform, TransformOptions } from "stream";
export interface Blake2Options extends TransformOptions {
@@ -13,7 +12,7 @@ export class Hash extends Transform {
update(buf: Buffer): this;
- digest(encoding: BinaryToTextEncoding): string;
+ digest(encoding: BufferEncoding): string;
digest(): Buffer;
copy(): this;
@@ -26,7 +25,7 @@ export class KeyedHash extends Transform {
update(buf: Buffer): this;
- digest(encoding: BinaryToTextEncoding): string;
+ digest(encoding: BufferEncoding): string;
digest(): Buffer;
copy(): this;
diff --git a/types/dkim-signer/index.d.ts b/types/dkim-signer/index.d.ts
index 42b3bd24d19751..4079e22bd372f9 100644
--- a/types/dkim-signer/index.d.ts
+++ b/types/dkim-signer/index.d.ts
@@ -26,7 +26,7 @@ export function generateDKIMHeader(
): string;
/** Generates a SHA-256 hash */
-export function sha256(str: string, encoding?: crypto.BinaryToTextEncoding): string;
+export function sha256(str: string, encoding?: BufferEncoding): string;
/** DKIM canonicalization functions */
export namespace DKIMCanonicalizer {
diff --git a/types/node/.npmignore b/types/node/.npmignore
index c18f3da74173f9..1651c9aa16d226 100644
--- a/types/node/.npmignore
+++ b/types/node/.npmignore
@@ -6,3 +6,4 @@
/v20/
/v22/
/v24/
+/v25/
diff --git a/types/node/assert.d.ts b/types/node/assert.d.ts
index c4cc77e432da08..72cc91de95e987 100644
--- a/types/node/assert.d.ts
+++ b/types/node/assert.d.ts
@@ -5,7 +5,15 @@ declare module "node:assert" {
* @since v0.5.9
* @param value The input that is checked for being truthy.
*/
- function assert(value: unknown, message?: string | Error): asserts value;
+ function assert(
+ value: unknown,
+ message?: Error | assert.AssertMessageFunction,
+ ): asserts value;
+ function assert(
+ value: unknown,
+ message: string,
+ ...args: unknown[]
+ ): asserts value;
const kOptions: unique symbol;
namespace assert {
type AssertMethodNames =
@@ -177,6 +185,7 @@ declare module "node:assert" {
*/
operator: string;
}
+ type AssertMessageFunction = (actual: unknown, expected: unknown) => string;
type AssertPredicate = RegExp | (new() => object) | ((thrown: unknown) => boolean) | object | Error;
/**
* Throws an `AssertionError` with the provided error message or a default
@@ -255,7 +264,15 @@ declare module "node:assert" {
* ```
* @since v0.1.21
*/
- function ok(value: unknown, message?: string | Error): asserts value;
+ function ok(
+ value: unknown,
+ message?: Error | AssertMessageFunction,
+ ): asserts value;
+ function ok(
+ value: unknown,
+ message: string,
+ ...args: unknown[]
+ ): asserts value;
/**
* **Strict assertion mode**
*
@@ -289,7 +306,17 @@ declare module "node:assert" {
* error message is assigned. If the `message` parameter is an instance of an `Error` then it will be thrown instead of the `AssertionError`.
* @since v0.1.21
*/
- function equal(actual: unknown, expected: unknown, message?: string | Error): void;
+ function equal(
+ actual: unknown,
+ expected: unknown,
+ message?: Error | AssertMessageFunction,
+ ): void;
+ function equal(
+ actual: unknown,
+ expected: unknown,
+ message: string,
+ ...args: unknown[]
+ ): void;
/**
* **Strict assertion mode**
*
@@ -319,7 +346,17 @@ declare module "node:assert" {
* message is assigned. If the `message` parameter is an instance of an `Error` then it will be thrown instead of the `AssertionError`.
* @since v0.1.21
*/
- function notEqual(actual: unknown, expected: unknown, message?: string | Error): void;
+ function notEqual(
+ actual: unknown,
+ expected: unknown,
+ message?: Error | AssertMessageFunction,
+ ): void;
+ function notEqual(
+ actual: unknown,
+ expected: unknown,
+ message: string,
+ ...args: unknown[]
+ ): void;
/**
* **Strict assertion mode**
*
@@ -337,7 +374,17 @@ declare module "node:assert" {
* are also recursively evaluated by the following rules.
* @since v0.1.21
*/
- function deepEqual(actual: unknown, expected: unknown, message?: string | Error): void;
+ function deepEqual(
+ actual: unknown,
+ expected: unknown,
+ message?: Error | AssertMessageFunction,
+ ): void;
+ function deepEqual(
+ actual: unknown,
+ expected: unknown,
+ message: string,
+ ...args: unknown[]
+ ): void;
/**
* **Strict assertion mode**
*
@@ -387,7 +434,17 @@ declare module "node:assert" {
* instead of the `AssertionError`.
* @since v0.1.21
*/
- function notDeepEqual(actual: unknown, expected: unknown, message?: string | Error): void;
+ function notDeepEqual(
+ actual: unknown,
+ expected: unknown,
+ message?: Error | AssertMessageFunction,
+ ): void;
+ function notDeepEqual(
+ actual: unknown,
+ expected: unknown,
+ message: string,
+ ...args: unknown[]
+ ): void;
/**
* Tests strict equality between the `actual` and `expected` parameters as
* determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
@@ -425,7 +482,17 @@ declare module "node:assert" {
* instead of the `AssertionError`.
* @since v0.1.21
*/
- function strictEqual(actual: unknown, expected: T, message?: string | Error): asserts actual is T;
+ function strictEqual(
+ actual: unknown,
+ expected: T,
+ message?: Error | AssertMessageFunction,
+ ): asserts actual is T;
+ function strictEqual(
+ actual: unknown,
+ expected: T,
+ message: string,
+ ...args: unknown[]
+ ): asserts actual is T;
/**
* Tests strict inequality between the `actual` and `expected` parameters as
* determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
@@ -450,14 +517,34 @@ declare module "node:assert" {
* instead of the `AssertionError`.
* @since v0.1.21
*/
- function notStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void;
+ function notStrictEqual(
+ actual: unknown,
+ expected: unknown,
+ message?: Error | AssertMessageFunction,
+ ): void;
+ function notStrictEqual(
+ actual: unknown,
+ expected: unknown,
+ message: string,
+ ...args: unknown[]
+ ): void;
/**
* Tests for deep equality between the `actual` and `expected` parameters.
* "Deep" equality means that the enumerable "own" properties of child objects
* are recursively evaluated also by the following rules.
* @since v1.2.0
*/
- function deepStrictEqual(actual: unknown, expected: T, message?: string | Error): asserts actual is T;
+ function deepStrictEqual(
+ actual: unknown,
+ expected: T,
+ message?: Error | AssertMessageFunction,
+ ): asserts actual is T;
+ function deepStrictEqual(
+ actual: unknown,
+ expected: T,
+ message: string,
+ ...args: unknown[]
+ ): asserts actual is T;
/**
* Tests for deep strict inequality. Opposite of {@link deepStrictEqual}.
*
@@ -475,7 +562,17 @@ declare module "node:assert" {
* instead of the `AssertionError`.
* @since v1.2.0
*/
- function notDeepStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void;
+ function notDeepStrictEqual(
+ actual: unknown,
+ expected: unknown,
+ message?: Error | AssertMessageFunction,
+ ): void;
+ function notDeepStrictEqual(
+ actual: unknown,
+ expected: unknown,
+ message: string,
+ ...args: unknown[]
+ ): void;
/**
* Expects the function `fn` to throw an error.
*
@@ -766,7 +863,7 @@ declare module "node:assert" {
* check that the promise is rejected.
*
* If `asyncFn` is a function and it throws an error synchronously, `assert.rejects()` will return a rejected `Promise` with that error. If the
- * function does not return a promise, `assert.rejects()` will return a rejected `Promise` with an [ERR_INVALID_RETURN_VALUE](https://nodejs.org/docs/latest-v25.x/api/errors.html#err_invalid_return_value)
+ * function does not return a promise, `assert.rejects()` will return a rejected `Promise` with an [ERR_INVALID_RETURN_VALUE](https://nodejs.org/docs/latest-v26.x/api/errors.html#err_invalid_return_value)
* error. In both cases the error handler is skipped.
*
* Besides the async nature to await the completion behaves identically to {@link throws}.
@@ -836,7 +933,7 @@ declare module "node:assert" {
*
* If `asyncFn` is a function and it throws an error synchronously, `assert.doesNotReject()` will return a rejected `Promise` with that error. If
* the function does not return a promise, `assert.doesNotReject()` will return a
- * rejected `Promise` with an [ERR_INVALID_RETURN_VALUE](https://nodejs.org/docs/latest-v25.x/api/errors.html#err_invalid_return_value) error. In both cases
+ * rejected `Promise` with an [ERR_INVALID_RETURN_VALUE](https://nodejs.org/docs/latest-v26.x/api/errors.html#err_invalid_return_value) error. In both cases
* the error handler is skipped.
*
* Using `assert.doesNotReject()` is actually not useful because there is little
@@ -899,10 +996,20 @@ declare module "node:assert" {
* If the values do not match, or if the `string` argument is of another type than `string`, an `{@link AssertionError}` is thrown with a `message` property set equal
* to the value of the `message` parameter. If the `message` parameter is
* undefined, a default error message is assigned. If the `message` parameter is an
- * instance of an [Error](https://nodejs.org/docs/latest-v25.x/api/errors.html#class-error) then it will be thrown instead of the `{@link AssertionError}`.
+ * instance of an [Error](https://nodejs.org/docs/latest-v26.x/api/errors.html#class-error) then it will be thrown instead of the `{@link AssertionError}`.
* @since v13.6.0, v12.16.0
*/
- function match(value: string, regExp: RegExp, message?: string | Error): void;
+ function match(
+ value: string,
+ regExp: RegExp,
+ message?: Error | AssertMessageFunction,
+ ): void;
+ function match(
+ value: string,
+ regExp: RegExp,
+ message: string,
+ ...args: unknown[]
+ ): void;
/**
* Expects the `string` input not to match the regular expression.
*
@@ -922,10 +1029,20 @@ declare module "node:assert" {
* If the values do match, or if the `string` argument is of another type than `string`, an `{@link AssertionError}` is thrown with a `message` property set equal
* to the value of the `message` parameter. If the `message` parameter is
* undefined, a default error message is assigned. If the `message` parameter is an
- * instance of an [Error](https://nodejs.org/docs/latest-v25.x/api/errors.html#class-error) then it will be thrown instead of the `{@link AssertionError}`.
+ * instance of an [Error](https://nodejs.org/docs/latest-v26.x/api/errors.html#class-error) then it will be thrown instead of the `{@link AssertionError}`.
* @since v13.6.0, v12.16.0
*/
- function doesNotMatch(value: string, regExp: RegExp, message?: string | Error): void;
+ function doesNotMatch(
+ value: string,
+ regExp: RegExp,
+ message?: Error | AssertMessageFunction,
+ ): void;
+ function doesNotMatch(
+ value: string,
+ regExp: RegExp,
+ message: string,
+ ...args: unknown[]
+ ): void;
/**
* Tests for partial deep equality between the `actual` and `expected` parameters.
* "Deep" equality means that the enumerable "own" properties of child objects
@@ -937,7 +1054,17 @@ declare module "node:assert" {
* behaving as a super set of it.
* @since v22.13.0
*/
- function partialDeepStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void;
+ function partialDeepStrictEqual(
+ actual: unknown,
+ expected: unknown,
+ message?: Error | AssertMessageFunction,
+ ): void;
+ function partialDeepStrictEqual(
+ actual: unknown,
+ expected: unknown,
+ message: string,
+ ...args: unknown[]
+ ): void;
}
namespace assert {
export { strict };
diff --git a/types/node/assert/strict.d.ts b/types/node/assert/strict.d.ts
index 7a9dcf5714b860..d4ea39083f7259 100644
--- a/types/node/assert/strict.d.ts
+++ b/types/node/assert/strict.d.ts
@@ -3,6 +3,7 @@ declare module "node:assert/strict" {
Assert,
AssertionError,
AssertionErrorOptions,
+ AssertMessageFunction,
AssertOptions,
AssertPredicate,
AssertStrict,
@@ -21,7 +22,15 @@ declare module "node:assert/strict" {
strictEqual,
throws,
} from "node:assert";
- function strict(value: unknown, message?: string | Error): asserts value;
+ function strict(
+ value: unknown,
+ message?: Error | AssertMessageFunction,
+ ): asserts value;
+ function strict(
+ value: unknown,
+ message: string,
+ ...args: unknown[]
+ ): asserts value;
namespace strict {
export {
Assert,
diff --git a/types/node/async_hooks.d.ts b/types/node/async_hooks.d.ts
index ac857ad185ef98..d38fcf096e45b9 100644
--- a/types/node/async_hooks.d.ts
+++ b/types/node/async_hooks.d.ts
@@ -28,7 +28,7 @@ declare module "node:async_hooks" {
* ```
*
* Promise contexts may not get precise `executionAsyncIds` by default.
- * See the section on [promise execution tracking](https://nodejs.org/docs/latest-v25.x/api/async_hooks.html#promise-execution-tracking).
+ * See the section on [promise execution tracking](https://nodejs.org/docs/latest-v26.x/api/async_hooks.html#promise-execution-tracking).
* @since v8.1.0
* @return The `asyncId` of the current execution context. Useful to track when something calls.
*/
@@ -101,29 +101,29 @@ declare module "node:async_hooks" {
* ```
*
* Promise contexts may not get valid `triggerAsyncId`s by default. See
- * the section on [promise execution tracking](https://nodejs.org/docs/latest-v25.x/api/async_hooks.html#promise-execution-tracking).
+ * the section on [promise execution tracking](https://nodejs.org/docs/latest-v26.x/api/async_hooks.html#promise-execution-tracking).
* @return The ID of the resource responsible for calling the callback that is currently being executed.
*/
function triggerAsyncId(): number;
interface HookCallbacks {
/**
- * The [`init` callback](https://nodejs.org/docs/latest-v25.x/api/async_hooks.html#initasyncid-type-triggerasyncid-resource).
+ * The [`init` callback](https://nodejs.org/docs/latest-v26.x/api/async_hooks.html#initasyncid-type-triggerasyncid-resource).
*/
init?(asyncId: number, type: string, triggerAsyncId: number, resource: object): void;
/**
- * The [`before` callback](https://nodejs.org/docs/latest-v25.x/api/async_hooks.html#beforeasyncid).
+ * The [`before` callback](https://nodejs.org/docs/latest-v26.x/api/async_hooks.html#beforeasyncid).
*/
before?(asyncId: number): void;
/**
- * The [`after` callback](https://nodejs.org/docs/latest-v25.x/api/async_hooks.html#afterasyncid).
+ * The [`after` callback](https://nodejs.org/docs/latest-v26.x/api/async_hooks.html#afterasyncid).
*/
after?(asyncId: number): void;
/**
- * The [`promiseResolve` callback](https://nodejs.org/docs/latest-v25.x/api/async_hooks.html#promiseresolveasyncid).
+ * The [`promiseResolve` callback](https://nodejs.org/docs/latest-v26.x/api/async_hooks.html#promiseresolveasyncid).
*/
promiseResolve?(asyncId: number): void;
/**
- * The [`destroy` callback](https://nodejs.org/docs/latest-v25.x/api/async_hooks.html#destroyasyncid).
+ * The [`destroy` callback](https://nodejs.org/docs/latest-v26.x/api/async_hooks.html#destroyasyncid).
*/
destroy?(asyncId: number): void;
/**
@@ -153,7 +153,7 @@ declare module "node:async_hooks" {
* All callbacks are optional. For example, if only resource cleanup needs to
* be tracked, then only the `destroy` callback needs to be passed. The
* specifics of all functions that can be passed to `callbacks` is in the
- * [Hook Callbacks](https://nodejs.org/docs/latest-v25.x/api/async_hooks.html#hook-callbacks) section.
+ * [Hook Callbacks](https://nodejs.org/docs/latest-v26.x/api/async_hooks.html#hook-callbacks) section.
*
* ```js
* import { createHook } from 'node:async_hooks';
@@ -184,7 +184,7 @@ declare module "node:async_hooks" {
* via the async hooks mechanism, the `init()`, `before()`, `after()`, and
* `destroy()` callbacks _must not_ be async functions that return promises.
* @since v8.1.0
- * @param options The [Hook Callbacks](https://nodejs.org/docs/latest-v25.x/api/async_hooks.html#hook-callbacks) to register
+ * @param options The [Hook Callbacks](https://nodejs.org/docs/latest-v26.x/api/async_hooks.html#hook-callbacks) to register
* @returns Instance used for disabling and enabling hooks
*/
function createHook(options: HookCallbacks): AsyncHook;
diff --git a/types/node/buffer.d.ts b/types/node/buffer.d.ts
index 7cff31fa790754..9fc15f5587b4ca 100644
--- a/types/node/buffer.d.ts
+++ b/types/node/buffer.d.ts
@@ -75,11 +75,6 @@ declare module "node:buffer" {
*/
export function resolveObjectURL(id: string): Blob | undefined;
export { type AllowSharedBuffer, Buffer, type NonSharedBuffer };
- /** @deprecated This alias will be removed in a future version. Use the canonical `BlobPropertyBag` instead. */
- // TODO: remove in future major
- export interface BlobOptions extends BlobPropertyBag {}
- /** @deprecated This alias will be removed in a future version. Use the canonical `FilePropertyBag` instead. */
- export interface FileOptions extends FilePropertyBag {}
export type WithImplicitCoercion =
| T
| { valueOf(): T }
diff --git a/types/node/child_process.d.ts b/types/node/child_process.d.ts
index e3964ab96fba03..eb65ecc07473ee 100644
--- a/types/node/child_process.d.ts
+++ b/types/node/child_process.d.ts
@@ -404,7 +404,7 @@ declare module "node:child_process" {
* as the connection may have been closed during the time it takes to send the
* connection to the child.
* @since v0.5.9
- * @param sendHandle `undefined`, or a [`net.Socket`](https://nodejs.org/docs/latest-v25.x/api/net.html#class-netsocket), [`net.Server`](https://nodejs.org/docs/latest-v25.x/api/net.html#class-netserver), or [`dgram.Socket`](https://nodejs.org/docs/latest-v25.x/api/dgram.html#class-dgramsocket) object.
+ * @param sendHandle `undefined`, or a [`net.Socket`](https://nodejs.org/docs/latest-v26.x/api/net.html#class-netsocket), [`net.Server`](https://nodejs.org/docs/latest-v26.x/api/net.html#class-netserver), or [`dgram.Socket`](https://nodejs.org/docs/latest-v26.x/api/dgram.html#class-dgramsocket) object.
* @param options The `options` argument, if present, is an object used to parameterize the sending of certain types of handles. `options` supports the following properties:
*/
send(message: Serializable, callback?: (error: Error | null) => void): boolean;
@@ -787,16 +787,15 @@ declare module "node:child_process" {
encoding?: BufferEncoding | undefined;
}
interface ExecOptionsWithBufferEncoding extends ExecOptions {
- encoding: "buffer" | null; // specify `null`.
+ encoding: "buffer" | null;
}
- // TODO: Just Plain Wrong™ (see also nodejs/node#57392)
- interface ExecException extends Error {
- cmd?: string;
+ interface ExecException extends Omit {
+ cmd: string;
+ code?: number | string;
killed?: boolean;
- code?: number;
signal?: NodeJS.Signals;
- stdout?: string;
- stderr?: string;
+ stdout?: string | NonSharedBuffer;
+ stderr?: string | NonSharedBuffer;
}
/**
* Spawns a shell then executes the `command` within that shell, buffering any
@@ -956,11 +955,6 @@ declare module "node:child_process" {
}
/** @deprecated Use `ExecFileOptions` instead. */
interface ExecFileOptionsWithOtherEncoding extends ExecFileOptions {}
- // TODO: execFile exceptions can take many forms... this accurately describes none of them
- type ExecFileException =
- & Omit
- & Omit
- & { code?: string | number | null };
/**
* The `child_process.execFile()` function is similar to {@link exec} except that it does not spawn a shell by default. Rather, the specified
* executable `file` is spawned directly as a new process making it slightly more
@@ -1028,36 +1022,36 @@ declare module "node:child_process" {
// no `options` definitely means stdout/stderr are `string`.
function execFile(
file: string,
- callback?: (error: ExecFileException | null, stdout: string, stderr: string) => void,
+ callback?: (error: ExecException | null, stdout: string, stderr: string) => void,
): ChildProcess;
function execFile(
file: string,
args: readonly string[] | undefined | null,
- callback?: (error: ExecFileException | null, stdout: string, stderr: string) => void,
+ callback?: (error: ExecException | null, stdout: string, stderr: string) => void,
): ChildProcess;
// `options` with `"buffer"` or `null` for `encoding` means stdout/stderr are definitely `Buffer`.
function execFile(
file: string,
options: ExecFileOptionsWithBufferEncoding,
- callback?: (error: ExecFileException | null, stdout: NonSharedBuffer, stderr: NonSharedBuffer) => void,
+ callback?: (error: ExecException | null, stdout: NonSharedBuffer, stderr: NonSharedBuffer) => void,
): ChildProcess;
function execFile(
file: string,
args: readonly string[] | undefined | null,
options: ExecFileOptionsWithBufferEncoding,
- callback?: (error: ExecFileException | null, stdout: NonSharedBuffer, stderr: NonSharedBuffer) => void,
+ callback?: (error: ExecException | null, stdout: NonSharedBuffer, stderr: NonSharedBuffer) => void,
): ChildProcess;
// `options` with well-known or absent `encoding` means stdout/stderr are definitely `string`.
function execFile(
file: string,
options: ExecFileOptionsWithStringEncoding,
- callback?: (error: ExecFileException | null, stdout: string, stderr: string) => void,
+ callback?: (error: ExecException | null, stdout: string, stderr: string) => void,
): ChildProcess;
function execFile(
file: string,
args: readonly string[] | undefined | null,
options: ExecFileOptionsWithStringEncoding,
- callback?: (error: ExecFileException | null, stdout: string, stderr: string) => void,
+ callback?: (error: ExecException | null, stdout: string, stderr: string) => void,
): ChildProcess;
// fallback if nothing else matches. Worst case is always `string | Buffer`.
function execFile(
@@ -1065,7 +1059,7 @@ declare module "node:child_process" {
options: ExecFileOptions | undefined | null,
callback:
| ((
- error: ExecFileException | null,
+ error: ExecException | null,
stdout: string | NonSharedBuffer,
stderr: string | NonSharedBuffer,
) => void)
@@ -1078,7 +1072,7 @@ declare module "node:child_process" {
options: ExecFileOptions | undefined | null,
callback:
| ((
- error: ExecFileException | null,
+ error: ExecException | null,
stdout: string | NonSharedBuffer,
stderr: string | NonSharedBuffer,
) => void)
@@ -1360,6 +1354,8 @@ declare module "node:child_process" {
args?: readonly string[],
options?: ExecFileSyncOptions,
): string | NonSharedBuffer;
+ /** @deprecated This deprecated alias will be removed in a future version. Use `ExecException` instead. */
+ interface ExecFileException extends ExecException {}
}
declare module "child_process" {
export * from "node:child_process";
diff --git a/types/node/cluster.d.ts b/types/node/cluster.d.ts
index 80f55aeb71c91c..b9dbc8c110099c 100644
--- a/types/node/cluster.d.ts
+++ b/types/node/cluster.d.ts
@@ -11,10 +11,10 @@ declare module "node:cluster" {
*/
id: number;
/**
- * All workers are created using [`child_process.fork()`](https://nodejs.org/docs/latest-v25.x/api/child_process.html#child_processforkmodulepath-args-options), the returned object
+ * All workers are created using [`child_process.fork()`](https://nodejs.org/docs/latest-v26.x/api/child_process.html#child_processforkmodulepath-args-options), the returned object
* from this function is stored as `.process`. In a worker, the global `process` is stored.
*
- * See: [Child Process module](https://nodejs.org/docs/latest-v25.x/api/child_process.html#child_processforkmodulepath-args-options).
+ * See: [Child Process module](https://nodejs.org/docs/latest-v26.x/api/child_process.html#child_processforkmodulepath-args-options).
*
* Workers will call `process.exit(0)` if the `'disconnect'` event occurs
* on `process` and `.exitedAfterDisconnect` is not `true`. This protects against
@@ -25,7 +25,7 @@ declare module "node:cluster" {
/**
* Send a message to a worker or primary, optionally with a handle.
*
- * In the primary, this sends a message to a specific worker. It is identical to [`ChildProcess.send()`](https://nodejs.org/docs/latest-v25.x/api/child_process.html#subprocesssendmessage-sendhandle-options-callback).
+ * In the primary, this sends a message to a specific worker. It is identical to [`ChildProcess.send()`](https://nodejs.org/docs/latest-v26.x/api/child_process.html#subprocesssendmessage-sendhandle-options-callback).
*
* In a worker, this sends a message to the primary. It is identical to `process.send()`.
*
@@ -67,7 +67,7 @@ declare module "node:cluster" {
* This method is aliased as `worker.destroy()` for backwards compatibility.
*
* In a worker, `process.kill()` exists, but it is not this function;
- * it is [`kill()`](https://nodejs.org/docs/latest-v25.x/api/process.html#processkillpid-signal).
+ * it is [`kill()`](https://nodejs.org/docs/latest-v26.x/api/process.html#processkillpid-signal).
* @since v0.9.12
* @param [signal='SIGTERM'] Name of the kill signal to send to the worker process.
*/
@@ -245,8 +245,8 @@ declare module "node:cluster" {
silent?: boolean | undefined;
/**
* Configures the stdio of forked processes. Because the cluster module relies on IPC to function, this configuration must
- * contain an `'ipc'` entry. When this option is provided, it overrides `silent`. See [`child_prcess.spawn()`](https://nodejs.org/docs/latest-v25.x/api/child_process.html#child_processspawncommand-args-options)'s
- * [`stdio`](https://nodejs.org/docs/latest-v25.x/api/child_process.html#optionsstdio).
+ * contain an `'ipc'` entry. When this option is provided, it overrides `silent`. See [`child_prcess.spawn()`](https://nodejs.org/docs/latest-v26.x/api/child_process.html#child_processspawncommand-args-options)'s
+ * [`stdio`](https://nodejs.org/docs/latest-v26.x/api/child_process.html#optionsstdio).
*/
stdio?: any[] | undefined;
/**
@@ -264,7 +264,7 @@ declare module "node:cluster" {
inspectPort?: number | (() => number) | undefined;
/**
* Specify the kind of serialization used for sending messages between processes. Possible values are `'json'` and `'advanced'`.
- * See [Advanced serialization for `child_process`](https://nodejs.org/docs/latest-v25.x/api/child_process.html#advanced-serialization) for more details.
+ * See [Advanced serialization for `child_process`](https://nodejs.org/docs/latest-v26.x/api/child_process.html#advanced-serialization) for more details.
* @default false
*/
serialization?: "json" | "advanced" | undefined;
@@ -333,7 +333,7 @@ declare module "node:cluster" {
readonly isWorker: boolean;
/**
* The scheduling policy, either `cluster.SCHED_RR` for round-robin or `cluster.SCHED_NONE` to leave it to the operating system. This is a
- * global setting and effectively frozen once either the first worker is spawned, or [`.setupPrimary()`](https://nodejs.org/docs/latest-v25.x/api/cluster.html#clustersetupprimarysettings)
+ * global setting and effectively frozen once either the first worker is spawned, or [`.setupPrimary()`](https://nodejs.org/docs/latest-v26.x/api/cluster.html#clustersetupprimarysettings)
* is called, whichever comes first.
*
* `SCHED_RR` is the default on all operating systems except Windows. Windows will change to `SCHED_RR` once libuv is able to effectively distribute
@@ -344,24 +344,24 @@ declare module "node:cluster" {
*/
schedulingPolicy: number;
/**
- * After calling [`.setupPrimary()`](https://nodejs.org/docs/latest-v25.x/api/cluster.html#clustersetupprimarysettings)
- * (or [`.fork()`](https://nodejs.org/docs/latest-v25.x/api/cluster.html#clusterforkenv)) this settings object will contain
+ * After calling [`.setupPrimary()`](https://nodejs.org/docs/latest-v26.x/api/cluster.html#clustersetupprimarysettings)
+ * (or [`.fork()`](https://nodejs.org/docs/latest-v26.x/api/cluster.html#clusterforkenv)) this settings object will contain
* the settings, including the default values.
*
* This object is not intended to be changed or set manually.
* @since v0.7.1
*/
readonly settings: ClusterSettings;
- /** @deprecated since v16.0.0 - use [`.setupPrimary()`](https://nodejs.org/docs/latest-v25.x/api/cluster.html#clustersetupprimarysettings) instead. */
+ /** @deprecated since v16.0.0 - use [`.setupPrimary()`](https://nodejs.org/docs/latest-v26.x/api/cluster.html#clustersetupprimarysettings) instead. */
setupMaster(settings?: ClusterSettings): void;
/**
* `setupPrimary` is used to change the default 'fork' behavior. Once called, the settings will be present in `cluster.settings`.
*
- * Any settings changes only affect future calls to [`.fork()`](https://nodejs.org/docs/latest-v25.x/api/cluster.html#clusterforkenv)
+ * Any settings changes only affect future calls to [`.fork()`](https://nodejs.org/docs/latest-v26.x/api/cluster.html#clusterforkenv)
* and have no effect on workers that are already running.
*
* The only attribute of a worker that cannot be set via `.setupPrimary()` is the `env` passed to
- * [`.fork()`](https://nodejs.org/docs/latest-v25.x/api/cluster.html#clusterforkenv).
+ * [`.fork()`](https://nodejs.org/docs/latest-v26.x/api/cluster.html#clusterforkenv).
*
* The defaults above apply to the first call only; the defaults for later calls are the current values at the time of
* `cluster.setupPrimary()` is called.
diff --git a/types/node/console.d.ts b/types/node/console.d.ts
index b7f883363a1b6e..5ba70b3f4b322d 100644
--- a/types/node/console.d.ts
+++ b/types/node/console.d.ts
@@ -19,7 +19,7 @@ declare module "node:console" {
colorMode?: boolean | "auto" | undefined;
/**
* Specifies options that are passed along to
- * [`util.inspect()`](https://nodejs.org/docs/latest-v25.x/api/util.html#utilinspectobject-options).
+ * [`util.inspect()`](https://nodejs.org/docs/latest-v26.x/api/util.html#utilinspectobject-options).
*/
inspectOptions?: InspectOptions | ReadonlyMap | undefined;
/**
diff --git a/types/node/crypto.d.ts b/types/node/crypto.d.ts
index 1933d6030140e4..a0e54f922f476f 100644
--- a/types/node/crypto.d.ts
+++ b/types/node/crypto.d.ts
@@ -1,6 +1,6 @@
declare module "node:crypto" {
import { NonSharedBuffer } from "node:buffer";
- import * as stream from "node:stream";
+ import { Transform, TransformOptions, Writable, WritableOptions } from "node:stream";
import { PeerCertificate } from "node:tls";
/**
* SPKAC is a Certificate Signing Request mechanism originally implemented by
@@ -27,7 +27,7 @@ declare module "node:crypto" {
* @param encoding The `encoding` of the `spkac` string.
* @return The challenge component of the `spkac` data structure, which includes a public key and a challenge.
*/
- static exportChallenge(spkac: BinaryLike): NonSharedBuffer;
+ static exportChallenge(spkac: BinaryLike, encoding?: BufferEncoding): NonSharedBuffer;
/**
* ```js
* const { Certificate } = await import('node:crypto');
@@ -40,7 +40,7 @@ declare module "node:crypto" {
* @param encoding The `encoding` of the `spkac` string.
* @return The public key component of the `spkac` data structure, which includes a public key and a challenge.
*/
- static exportPublicKey(spkac: BinaryLike, encoding?: string): NonSharedBuffer;
+ static exportPublicKey(spkac: BinaryLike, encoding?: BufferEncoding): NonSharedBuffer;
/**
* ```js
* import { Buffer } from 'node:buffer';
@@ -54,122 +54,34 @@ declare module "node:crypto" {
* @param encoding The `encoding` of the `spkac` string.
* @return `true` if the given `spkac` data structure is valid, `false` otherwise.
*/
- static verifySpkac(spkac: NodeJS.ArrayBufferView): boolean;
+ static verifySpkac(spkac: BinaryLike, encoding?: BufferEncoding): boolean;
/**
* @deprecated
- * @param spkac
+ * @param encoding The `encoding` of the `spkac` string.
* @returns The challenge component of the `spkac` data structure,
* which includes a public key and a challenge.
*/
- exportChallenge(spkac: BinaryLike): NonSharedBuffer;
+ exportChallenge(spkac: BinaryLike, encoding?: BufferEncoding): NonSharedBuffer;
/**
* @deprecated
- * @param spkac
* @param encoding The encoding of the spkac string.
* @returns The public key component of the `spkac` data structure,
* which includes a public key and a challenge.
*/
- exportPublicKey(spkac: BinaryLike, encoding?: string): NonSharedBuffer;
+ exportPublicKey(spkac: BinaryLike, encoding?: BufferEncoding): NonSharedBuffer;
/**
* @deprecated
- * @param spkac
+ * @param encoding The `encoding` of the `spkac` string.
* @returns `true` if the given `spkac` data structure is valid,
* `false` otherwise.
*/
- verifySpkac(spkac: NodeJS.ArrayBufferView): boolean;
+ verifySpkac(spkac: BinaryLike, encoding?: BufferEncoding): boolean;
}
- namespace constants {
- // https://nodejs.org/dist/latest-v25.x/docs/api/crypto.html#crypto-constants
- const OPENSSL_VERSION_NUMBER: number;
- /** Applies multiple bug workarounds within OpenSSL. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html for detail. */
- const SSL_OP_ALL: number;
- /** Instructs OpenSSL to allow a non-[EC]DHE-based key exchange mode for TLS v1.3 */
- const SSL_OP_ALLOW_NO_DHE_KEX: number;
- /** Allows legacy insecure renegotiation between OpenSSL and unpatched clients or servers. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html. */
- const SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number;
- /** Attempts to use the server's preferences instead of the client's when selecting a cipher. See https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_options.html. */
- const SSL_OP_CIPHER_SERVER_PREFERENCE: number;
- /** Instructs OpenSSL to use Cisco's version identifier of DTLS_BAD_VER. */
- const SSL_OP_CISCO_ANYCONNECT: number;
- /** Instructs OpenSSL to turn on cookie exchange. */
- const SSL_OP_COOKIE_EXCHANGE: number;
- /** Instructs OpenSSL to add server-hello extension from an early version of the cryptopro draft. */
- const SSL_OP_CRYPTOPRO_TLSEXT_BUG: number;
- /** Instructs OpenSSL to disable a SSL 3.0/TLS 1.0 vulnerability workaround added in OpenSSL 0.9.6d. */
- const SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number;
- /** Allows initial connection to servers that do not support RI. */
- const SSL_OP_LEGACY_SERVER_CONNECT: number;
- /** Instructs OpenSSL to disable support for SSL/TLS compression. */
- const SSL_OP_NO_COMPRESSION: number;
- /** Instructs OpenSSL to disable encrypt-then-MAC. */
- const SSL_OP_NO_ENCRYPT_THEN_MAC: number;
- const SSL_OP_NO_QUERY_MTU: number;
- /** Instructs OpenSSL to disable renegotiation. */
- const SSL_OP_NO_RENEGOTIATION: number;
- /** Instructs OpenSSL to always start a new session when performing renegotiation. */
- const SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number;
- /** Instructs OpenSSL to turn off SSL v2 */
- const SSL_OP_NO_SSLv2: number;
- /** Instructs OpenSSL to turn off SSL v3 */
- const SSL_OP_NO_SSLv3: number;
- /** Instructs OpenSSL to disable use of RFC4507bis tickets. */
- const SSL_OP_NO_TICKET: number;
- /** Instructs OpenSSL to turn off TLS v1 */
- const SSL_OP_NO_TLSv1: number;
- /** Instructs OpenSSL to turn off TLS v1.1 */
- const SSL_OP_NO_TLSv1_1: number;
- /** Instructs OpenSSL to turn off TLS v1.2 */
- const SSL_OP_NO_TLSv1_2: number;
- /** Instructs OpenSSL to turn off TLS v1.3 */
- const SSL_OP_NO_TLSv1_3: number;
- /** Instructs OpenSSL server to prioritize ChaCha20-Poly1305 when the client does. This option has no effect if `SSL_OP_CIPHER_SERVER_PREFERENCE` is not enabled. */
- const SSL_OP_PRIORITIZE_CHACHA: number;
- /** Instructs OpenSSL to disable version rollback attack detection. */
- const SSL_OP_TLS_ROLLBACK_BUG: number;
- const ENGINE_METHOD_RSA: number;
- const ENGINE_METHOD_DSA: number;
- const ENGINE_METHOD_DH: number;
- const ENGINE_METHOD_RAND: number;
- const ENGINE_METHOD_EC: number;
- const ENGINE_METHOD_CIPHERS: number;
- const ENGINE_METHOD_DIGESTS: number;
- const ENGINE_METHOD_PKEY_METHS: number;
- const ENGINE_METHOD_PKEY_ASN1_METHS: number;
- const ENGINE_METHOD_ALL: number;
- const ENGINE_METHOD_NONE: number;
- const DH_CHECK_P_NOT_SAFE_PRIME: number;
- const DH_CHECK_P_NOT_PRIME: number;
- const DH_UNABLE_TO_CHECK_GENERATOR: number;
- const DH_NOT_SUITABLE_GENERATOR: number;
- const RSA_PKCS1_PADDING: number;
- const RSA_SSLV23_PADDING: number;
- const RSA_NO_PADDING: number;
- const RSA_PKCS1_OAEP_PADDING: number;
- const RSA_X931_PADDING: number;
- const RSA_PKCS1_PSS_PADDING: number;
- /** Sets the salt length for RSA_PKCS1_PSS_PADDING to the digest size when signing or verifying. */
- const RSA_PSS_SALTLEN_DIGEST: number;
- /** Sets the salt length for RSA_PKCS1_PSS_PADDING to the maximum permissible value when signing data. */
- const RSA_PSS_SALTLEN_MAX_SIGN: number;
- /** Causes the salt length for RSA_PKCS1_PSS_PADDING to be determined automatically when verifying a signature. */
- const RSA_PSS_SALTLEN_AUTO: number;
- const POINT_CONVERSION_COMPRESSED: number;
- const POINT_CONVERSION_UNCOMPRESSED: number;
- const POINT_CONVERSION_HYBRID: number;
- /** Specifies the built-in default cipher list used by Node.js (colon-separated values). */
- const defaultCoreCipherList: string;
- /** Specifies the active default cipher list used by the current Node.js process (colon-separated values). */
- const defaultCipherList: string;
- }
- interface HashOptions extends stream.TransformOptions {
- /**
- * For XOF hash functions such as `shake256`, the
- * outputLength option can be used to specify the desired output length in bytes.
- */
+ /** @deprecated This property is deprecated. Please use `crypto.setFips()` and `crypto.getFips()` instead. */
+ var fips: boolean;
+ interface HashOptions extends TransformOptions {
outputLength?: number | undefined;
}
- /** @deprecated since v10.0.0 */
- const fips: boolean;
/**
* Creates and returns a `Hash` object that can be used to generate hash digests
* using the given `algorithm`. Optional `options` argument controls stream
@@ -212,6 +124,9 @@ declare module "node:crypto" {
* @param options `stream.transform` options
*/
function createHash(algorithm: string, options?: HashOptions): Hash;
+ interface HmacOptions extends TransformOptions {
+ encoding?: BufferEncoding | undefined;
+ }
/**
* Creates and returns an `Hmac` object that uses the given `algorithm` and `key`.
* Optional `options` argument controls stream behavior.
@@ -256,13 +171,7 @@ declare module "node:crypto" {
* @since v0.1.94
* @param options `stream.transform` options
*/
- function createHmac(algorithm: string, key: BinaryLike | KeyObject, options?: stream.TransformOptions): Hmac;
- // https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings
- type BinaryToTextEncoding = "base64" | "base64url" | "hex" | "binary";
- type CharacterEncoding = "utf8" | "utf-8" | "utf16le" | "utf-16le" | "latin1";
- type LegacyCharacterEncoding = "ascii" | "binary" | "ucs2" | "ucs-2";
- type Encoding = BinaryToTextEncoding | CharacterEncoding | LegacyCharacterEncoding;
- type ECDHKeyFormat = "compressed" | "uncompressed" | "hybrid";
+ function createHmac(algorithm: string, key: KeyLike, options?: HmacOptions): Hmac;
/**
* The `Hash` class is a utility for creating hash digests of data. It can be
* used in one of two ways:
@@ -327,7 +236,7 @@ declare module "node:crypto" {
* ```
* @since v0.1.92
*/
- class Hash extends stream.Transform {
+ class Hash extends Transform {
private constructor();
/**
* Creates a new `Hash` object that contains a deep copy of the internal state
@@ -373,8 +282,7 @@ declare module "node:crypto" {
* @since v0.1.92
* @param inputEncoding The `encoding` of the `data` string.
*/
- update(data: BinaryLike): Hash;
- update(data: string, inputEncoding: Encoding): Hash;
+ update(data: string | NodeJS.ArrayBufferView, inputEncoding?: BufferEncoding): Hash;
/**
* Calculates the digest of all of the data passed to be hashed (using the `hash.update()` method).
* If `encoding` is provided a string will be returned; otherwise
@@ -386,7 +294,7 @@ declare module "node:crypto" {
* @param encoding The `encoding` of the return value.
*/
digest(): NonSharedBuffer;
- digest(encoding: BinaryToTextEncoding): string;
+ digest(encoding: BufferEncoding): string;
}
/**
* The `Hmac` class is a utility for creating cryptographic HMAC digests. It can
@@ -454,7 +362,7 @@ declare module "node:crypto" {
* ```
* @since v0.1.94
*/
- class Hmac extends stream.Transform {
+ class Hmac extends Transform {
private constructor();
/**
* Updates the `Hmac` content with the given `data`, the encoding of which
@@ -466,8 +374,7 @@ declare module "node:crypto" {
* @since v0.1.94
* @param inputEncoding The `encoding` of the `data` string.
*/
- update(data: BinaryLike): Hmac;
- update(data: string, inputEncoding: Encoding): Hmac;
+ update(data: string | NodeJS.ArrayBufferView, inputEncoding?: BufferEncoding): Hmac;
/**
* Calculates the HMAC digest of all of the data passed using `hmac.update()`.
* If `encoding` is
@@ -479,9 +386,9 @@ declare module "node:crypto" {
* @param encoding The `encoding` of the return value.
*/
digest(): NonSharedBuffer;
- digest(encoding: BinaryToTextEncoding): string;
+ digest(encoding: BufferEncoding): string;
}
- type KeyFormat = "pem" | "der" | "jwk";
+ type KeyFormat = "pem" | "der" | "jwk" | "raw-public" | "raw-private" | "raw-seed";
type KeyObjectType = "secret" | "public" | "private";
type PublicKeyExportType = "pkcs1" | "spki";
type PrivateKeyExportType = "pkcs1" | "pkcs8" | "sec1";
@@ -489,38 +396,60 @@ declare module "node:crypto" {
| SymmetricKeyExportOptions
| PublicKeyExportOptions
| PrivateKeyExportOptions
- | JwkKeyExportOptions;
+ | JwkKeyExportOptions
+ | RawPublicKeyExportOptions
+ | RawPrivateKeyExportOptions;
interface SymmetricKeyExportOptions {
format?: "buffer" | undefined;
}
interface PublicKeyExportOptions {
type: T;
- format: Exclude;
+ format: "pem" | "der";
}
interface PrivateKeyExportOptions {
type: T;
- format: Exclude;
+ format: "pem" | "der";
cipher?: string | undefined;
- passphrase?: string | Buffer | undefined;
+ passphrase?: BinaryLike | undefined;
}
interface JwkKeyExportOptions {
format: "jwk";
}
+ interface RawPublicKeyExportOptions {
+ format: "raw-public";
+ }
+ interface RawPrivateKeyExportOptions {
+ format: "raw-private" | "raw-seed";
+ }
interface KeyPairExportOptions<
TPublic extends PublicKeyExportType = PublicKeyExportType,
TPrivate extends PrivateKeyExportType = PrivateKeyExportType,
> {
- publicKeyEncoding?: PublicKeyExportOptions | JwkKeyExportOptions | undefined;
- privateKeyEncoding?: PrivateKeyExportOptions | JwkKeyExportOptions | undefined;
+ publicKeyEncoding?:
+ | PublicKeyExportOptions
+ | RawPublicKeyExportOptions
+ | JwkKeyExportOptions
+ | undefined;
+ privateKeyEncoding?:
+ | PrivateKeyExportOptions
+ | RawPrivateKeyExportOptions
+ | JwkKeyExportOptions
+ | undefined;
}
- type KeyExportResult = T extends { format: infer F extends KeyFormat }
- ? { der: NonSharedBuffer; jwk: webcrypto.JsonWebKey; pem: string }[F]
+ type KeyExportResult = T extends { format: infer F extends KeyFormat } ? {
+ "der": NonSharedBuffer;
+ "jwk": webcrypto.JsonWebKey;
+ "pem": string;
+ "raw-public": NonSharedBuffer;
+ "raw-private": NonSharedBuffer;
+ "raw-seed": NonSharedBuffer;
+ }[F]
: Default;
interface KeyPairExportResult {
publicKey: KeyExportResult;
privateKey: KeyExportResult;
}
- type KeyPairExportCallback = (
+ type KeyPairExportCallback = (
err: Error | null,
publicKey: KeyExportResult,
privateKey: KeyExportResult,
@@ -542,33 +471,12 @@ declare module "node:crypto" {
| "x25519"
| "x448";
interface AsymmetricKeyDetails {
- /**
- * Key size in bits (RSA, DSA).
- */
modulusLength?: number;
- /**
- * Public exponent (RSA).
- */
publicExponent?: bigint;
- /**
- * Name of the message digest (RSA-PSS).
- */
hashAlgorithm?: string;
- /**
- * Name of the message digest used by MGF1 (RSA-PSS).
- */
mgf1HashAlgorithm?: string;
- /**
- * Minimal salt length in bytes (RSA-PSS).
- */
saltLength?: number;
- /**
- * Size of q in bits (DSA).
- */
divisorLength?: number;
- /**
- * Name of the curve (EC).
- */
namedCurve?: string;
}
/**
@@ -587,7 +495,11 @@ declare module "node:crypto" {
class KeyObject {
private constructor();
/**
- * Example: Converting a `CryptoKey` instance to a `KeyObject`:
+ * Returns the underlying `KeyObject` of a `CryptoKey`. The returned `KeyObject`
+ * does not retain any of the restrictions imposed by the Web Crypto API on the
+ * original `CryptoKey`, such as the allowed key usages, the algorithm or hash
+ * algorithm bindings, and the extractability flag. In particular, the underlying
+ * key material of the returned `KeyObject` can always be exported.
*
* ```js
* const { KeyObject } = await import('node:crypto');
@@ -608,7 +520,7 @@ declare module "node:crypto" {
static from(key: webcrypto.CryptoKey): KeyObject;
/**
* For asymmetric keys, this property represents the type of the key. See the
- * supported [asymmetric key types](https://nodejs.org/docs/latest-v25.x/api/crypto.html#asymmetric-key-types).
+ * supported [asymmetric key types](https://nodejs.org/docs/latest-v26.x/api/crypto.html#asymmetric-key-types).
*
* This property is `undefined` for unrecognized `KeyObject` types and symmetric
* keys.
@@ -630,26 +542,18 @@ declare module "node:crypto" {
*/
asymmetricKeyDetails?: AsymmetricKeyDetails;
/**
- * For symmetric keys, the following encoding options can be used:
- *
- * For public keys, the following encoding options can be used:
- *
- * For private keys, the following encoding options can be used:
- *
* The result type depends on the selected encoding format, when PEM the
* result is a string, when DER it will be a buffer containing the data
- * encoded as DER, when [JWK](https://tools.ietf.org/html/rfc7517) it will be an object.
- *
- * When [JWK](https://tools.ietf.org/html/rfc7517) encoding format was selected, all other encoding options are
- * ignored.
- *
- * PKCS#1, SEC1, and PKCS#8 type keys can be encrypted by using a combination of
- * the `cipher` and `format` options. The PKCS#8 `type` can be used with any`format` to encrypt any key algorithm (RSA, EC, or DH) by specifying a`cipher`. PKCS#1 and SEC1 can only be
- * encrypted by specifying a `cipher`when the PEM `format` is used. For maximum compatibility, use PKCS#8 for
- * encrypted private keys. Since PKCS#8 defines its own
- * encryption mechanism, PEM-level encryption is not supported when encrypting
- * a PKCS#8 key. See [RFC 5208](https://www.rfc-editor.org/rfc/rfc5208.txt) for PKCS#8 encryption and [RFC 1421](https://www.rfc-editor.org/rfc/rfc1421.txt) for
- * PKCS#1 and SEC1 encryption.
+ * encoded as DER, when [JWK](https://tools.ietf.org/html/rfc7517) it will be an object. Raw formats return a
+ * `Buffer` containing the raw key material.
+ *
+ * Private keys can be encrypted by specifying a `cipher` and `passphrase`.
+ * The PKCS#8 `type` supports encryption with both PEM and DER `format` for any
+ * key algorithm. PKCS#1 and SEC1 can only be encrypted when the PEM `format` is
+ * used. For maximum compatibility, use PKCS#8 for encrypted private keys. Since
+ * PKCS#8 defines its own encryption mechanism, PEM-level encryption is not
+ * supported when encrypting a PKCS#8 key. See [RFC 5208](https://www.rfc-editor.org/rfc/rfc5208.txt) for PKCS#8 encryption
+ * and [RFC 1421](https://www.rfc-editor.org/rfc/rfc1421.txt) for PKCS#1 and SEC1 encryption.
* @since v11.6.0
*/
export(options?: T): KeyExportResult;
@@ -690,19 +594,18 @@ declare module "node:crypto" {
type CipherGCMTypes = "aes-128-gcm" | "aes-192-gcm" | "aes-256-gcm";
type CipherOCBTypes = "aes-128-ocb" | "aes-192-ocb" | "aes-256-ocb";
type CipherChaCha20Poly1305Types = "chacha20-poly1305";
- type BinaryLike = string | NodeJS.ArrayBufferView;
- type CipherKey = BinaryLike | KeyObject;
- interface CipherCCMOptions extends stream.TransformOptions {
+ type BinaryLike = string | ArrayBufferLike | NodeJS.ArrayBufferView;
+ type KeyLike = BinaryLike | KeyObject;
+ interface CipherCCMOptions extends TransformOptions {
authTagLength: number;
}
- interface CipherGCMOptions extends stream.TransformOptions {
+ interface CipherGCMOptions extends TransformOptions {
authTagLength?: number | undefined;
}
- interface CipherOCBOptions extends stream.TransformOptions {
+ interface CipherOCBOptions extends TransformOptions {
authTagLength: number;
}
- interface CipherChaCha20Poly1305Options extends stream.TransformOptions {
- /** @default 16 */
+ interface CipherChaCha20Poly1305Options extends TransformOptions {
authTagLength?: number | undefined;
}
/**
@@ -737,33 +640,33 @@ declare module "node:crypto" {
*/
function createCipheriv(
algorithm: CipherCCMTypes,
- key: CipherKey,
+ key: KeyLike,
iv: BinaryLike,
options: CipherCCMOptions,
): CipherCCM;
function createCipheriv(
algorithm: CipherOCBTypes,
- key: CipherKey,
+ key: KeyLike,
iv: BinaryLike,
options: CipherOCBOptions,
): CipherOCB;
function createCipheriv(
algorithm: CipherGCMTypes,
- key: CipherKey,
+ key: KeyLike,
iv: BinaryLike,
options?: CipherGCMOptions,
): CipherGCM;
function createCipheriv(
algorithm: CipherChaCha20Poly1305Types,
- key: CipherKey,
+ key: KeyLike,
iv: BinaryLike,
options?: CipherChaCha20Poly1305Options,
): CipherChaCha20Poly1305;
function createCipheriv(
algorithm: string,
- key: CipherKey,
+ key: KeyLike,
iv: BinaryLike | null,
- options?: stream.TransformOptions,
+ options?: TransformOptions,
): Cipheriv;
/**
* Instances of the `Cipheriv` class are used to encrypt data. The class can be
@@ -884,7 +787,7 @@ declare module "node:crypto" {
* ```
* @since v0.1.94
*/
- class Cipheriv extends stream.Transform {
+ class Cipheriv extends Transform {
private constructor();
/**
* Updates the cipher with `data`. If the `inputEncoding` argument is given,
@@ -900,10 +803,12 @@ declare module "node:crypto" {
* @param inputEncoding The `encoding` of the data.
* @param outputEncoding The `encoding` of the return value.
*/
- update(data: BinaryLike): NonSharedBuffer;
- update(data: string, inputEncoding: Encoding): NonSharedBuffer;
- update(data: NodeJS.ArrayBufferView, inputEncoding: undefined, outputEncoding: Encoding): string;
- update(data: string, inputEncoding: Encoding | undefined, outputEncoding: Encoding): string;
+ update(data: string | NodeJS.ArrayBufferView, inputEncoding?: BufferEncoding): NonSharedBuffer;
+ update(
+ data: string | NodeJS.ArrayBufferView,
+ inputEncoding: BufferEncoding | null | undefined,
+ outputEncoding: BufferEncoding,
+ ): string;
/**
* Once the `cipher.final()` method has been called, the `Cipheriv` object can no
* longer be used to encrypt data. Attempts to call `cipher.final()` more than
@@ -931,50 +836,31 @@ declare module "node:crypto" {
*/
setAutoPadding(autoPadding?: boolean): this;
}
- interface CipherCCM extends Cipheriv {
- setAAD(
- buffer: NodeJS.ArrayBufferView,
- options: {
- plaintextLength: number;
- },
- ): this;
- getAuthTag(): NonSharedBuffer;
- }
- interface CipherGCM extends Cipheriv {
- setAAD(
- buffer: NodeJS.ArrayBufferView,
- options?: {
- plaintextLength: number;
- },
- ): this;
+ interface CipherAEADMethods {
getAuthTag(): NonSharedBuffer;
+ setAAD(buffer: BinaryLike, options?: {
+ plaintextLength?: number | undefined;
+ encoding?: BufferEncoding | undefined;
+ }): this;
}
- interface CipherOCB extends Cipheriv {
- setAAD(
- buffer: NodeJS.ArrayBufferView,
- options?: {
- plaintextLength: number;
- },
- ): this;
- getAuthTag(): NonSharedBuffer;
- }
- interface CipherChaCha20Poly1305 extends Cipheriv {
- setAAD(
- buffer: NodeJS.ArrayBufferView,
- options: {
- plaintextLength: number;
- },
- ): this;
- getAuthTag(): NonSharedBuffer;
+ interface CipherCCM extends Cipheriv, CipherAEADMethods {
+ setAAD(buffer: BinaryLike, options: {
+ plaintextLength: number;
+ encoding?: BufferEncoding | undefined;
+ }): this;
}
+ interface CipherGCM extends Cipheriv, CipherAEADMethods {}
+ interface CipherOCB extends Cipheriv, CipherAEADMethods {}
+ interface CipherChaCha20Poly1305 extends Cipheriv, CipherAEADMethods {}
/**
* Creates and returns a `Decipheriv` object that uses the given `algorithm`, `key` and initialization vector (`iv`).
*
* The `options` argument controls stream behavior and is optional except when a
- * cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the `authTagLength` option is required and specifies the length of the
- * authentication tag in bytes, see `CCM mode`. In GCM mode, the `authTagLength` option is not required but can be used to restrict accepted authentication tags
- * to those with the specified length.
- * For `chacha20-poly1305`, the `authTagLength` option defaults to 16 bytes.
+ * cipher in CCM or OCB mode (e.g. `'aes-128-ccm'`) is used. In that case, the
+ * `authTagLength` option is required and specifies the length of the
+ * authentication tag in bytes, see [CCM mode](https://nodejs.org/docs/latest-v26.x/api/crypto.html#ccm-mode).
+ * For AES-GCM and `chacha20-poly1305`, the `authTagLength` option defaults to 16
+ * bytes and must be set to a different value if a different length is used.
*
* The `algorithm` is dependent on OpenSSL, examples are `'aes192'`, etc. On
* recent OpenSSL releases, `openssl list -cipher-algorithms` will
@@ -998,33 +884,33 @@ declare module "node:crypto" {
*/
function createDecipheriv(
algorithm: CipherCCMTypes,
- key: CipherKey,
+ key: KeyLike,
iv: BinaryLike,
options: CipherCCMOptions,
): DecipherCCM;
function createDecipheriv(
algorithm: CipherOCBTypes,
- key: CipherKey,
+ key: KeyLike,
iv: BinaryLike,
options: CipherOCBOptions,
): DecipherOCB;
function createDecipheriv(
algorithm: CipherGCMTypes,
- key: CipherKey,
+ key: KeyLike,
iv: BinaryLike,
options?: CipherGCMOptions,
): DecipherGCM;
function createDecipheriv(
algorithm: CipherChaCha20Poly1305Types,
- key: CipherKey,
+ key: KeyLike,
iv: BinaryLike,
options?: CipherChaCha20Poly1305Options,
): DecipherChaCha20Poly1305;
function createDecipheriv(
algorithm: string,
- key: CipherKey,
+ key: KeyLike,
iv: BinaryLike | null,
- options?: stream.TransformOptions,
+ options?: TransformOptions,
): Decipheriv;
/**
* Instances of the `Decipheriv` class are used to decrypt data. The class can be
@@ -1134,7 +1020,7 @@ declare module "node:crypto" {
* ```
* @since v0.1.94
*/
- class Decipheriv extends stream.Transform {
+ class Decipheriv extends Transform {
private constructor();
/**
* Updates the decipher with `data`. If the `inputEncoding` argument is given,
@@ -1150,10 +1036,12 @@ declare module "node:crypto" {
* @param inputEncoding The `encoding` of the `data` string.
* @param outputEncoding The `encoding` of the return value.
*/
- update(data: NodeJS.ArrayBufferView): NonSharedBuffer;
- update(data: string, inputEncoding: Encoding): NonSharedBuffer;
- update(data: NodeJS.ArrayBufferView, inputEncoding: undefined, outputEncoding: Encoding): string;
- update(data: string, inputEncoding: Encoding | undefined, outputEncoding: Encoding): string;
+ update(data: string | NodeJS.ArrayBufferView, inputEncoding?: BufferEncoding): NonSharedBuffer;
+ update(
+ data: string | NodeJS.ArrayBufferView,
+ inputEncoding: BufferEncoding | null | undefined,
+ outputEncoding: BufferEncoding,
+ ): string;
/**
* Once the `decipher.final()` method has been called, the `Decipheriv` object can
* no longer be used to decrypt data. Attempts to call `decipher.final()` more
@@ -1178,54 +1066,59 @@ declare module "node:crypto" {
*/
setAutoPadding(auto_padding?: boolean): this;
}
- interface DecipherCCM extends Decipheriv {
- setAuthTag(buffer: NodeJS.ArrayBufferView): this;
- setAAD(
- buffer: NodeJS.ArrayBufferView,
- options: {
- plaintextLength: number;
- },
- ): this;
- }
- interface DecipherGCM extends Decipheriv {
- setAuthTag(buffer: NodeJS.ArrayBufferView): this;
- setAAD(
- buffer: NodeJS.ArrayBufferView,
- options?: {
- plaintextLength: number;
- },
- ): this;
- }
- interface DecipherOCB extends Decipheriv {
- setAuthTag(buffer: NodeJS.ArrayBufferView): this;
+ interface DecipherAEADMethods {
setAAD(
- buffer: NodeJS.ArrayBufferView,
+ buffer: BinaryLike,
options?: {
- plaintextLength: number;
+ plaintextLength?: number | undefined;
+ encoding?: BufferEncoding | undefined;
},
): this;
+ setAuthTag(buffer: BinaryLike, encoding?: BufferEncoding): this;
}
- interface DecipherChaCha20Poly1305 extends Decipheriv {
- setAuthTag(buffer: NodeJS.ArrayBufferView): this;
+ interface DecipherCCM extends Decipheriv, DecipherAEADMethods {
setAAD(
- buffer: NodeJS.ArrayBufferView,
+ buffer: BinaryLike,
options: {
plaintextLength: number;
+ encoding?: BufferEncoding | undefined;
},
): this;
}
+ interface DecipherGCM extends Decipheriv, DecipherAEADMethods {}
+ interface DecipherOCB extends Decipheriv, DecipherAEADMethods {}
+ interface DecipherChaCha20Poly1305 extends Decipheriv, DecipherAEADMethods {}
interface PrivateKeyInput {
- key: string | Buffer;
- format?: KeyFormat | undefined;
+ key: BinaryLike;
+ format?: "pem" | "der" | undefined;
type?: PrivateKeyExportType | undefined;
- passphrase?: string | Buffer | undefined;
- encoding?: string | undefined;
+ passphrase?: BinaryLike | undefined;
+ encoding?: BufferEncoding | undefined;
}
interface PublicKeyInput {
- key: string | Buffer;
- format?: KeyFormat | undefined;
+ key: BinaryLike;
+ format?: "pem" | "der" | undefined;
type?: PublicKeyExportType | undefined;
- encoding?: string | undefined;
+ encoding?: BufferEncoding | undefined;
+ }
+ interface RawPrivateKeyInput {
+ key: ArrayBufferLike | NodeJS.ArrayBufferView;
+ format: "raw-private" | "raw-seed";
+ asymmetricKeyType: AsymmetricKeyType;
+ namedCurve?: string | undefined;
+ }
+ interface RawPublicKeyInput {
+ key: ArrayBufferLike | NodeJS.ArrayBufferView;
+ format: "raw-public";
+ asymmetricKeyType: AsymmetricKeyType;
+ namedCurve?: string | undefined;
+ }
+ interface JsonWebKeyInput {
+ key: webcrypto.JsonWebKey;
+ format: "jwk";
+ }
+ interface SecretKeyOptions {
+ length: number;
}
/**
* Asynchronously generates a new random secret key of the given `length`. The `type` will determine which validations will be performed on the `length`.
@@ -1248,9 +1141,7 @@ declare module "node:crypto" {
*/
function generateKey(
type: "hmac" | "aes",
- options: {
- length: number;
- },
+ options: SecretKeyOptions,
callback: (err: Error | null, key: KeyObject) => void,
): void;
/**
@@ -1270,16 +1161,7 @@ declare module "node:crypto" {
* @since v15.0.0
* @param type The intended use of the generated secret key. Currently accepted values are `'hmac'` and `'aes'`.
*/
- function generateKeySync(
- type: "hmac" | "aes",
- options: {
- length: number;
- },
- ): KeyObject;
- interface JsonWebKeyInput {
- key: webcrypto.JsonWebKey;
- format: "jwk";
- }
+ function generateKeySync(type: "hmac" | "aes", options: SecretKeyOptions): KeyObject;
/**
* Creates and returns a new key object containing a private key. If `key` is a
* string or `Buffer`, `format` is assumed to be `'pem'`; otherwise, `key` must be an object with the properties described above.
@@ -1288,7 +1170,7 @@ declare module "node:crypto" {
* of the passphrase is limited to 1024 bytes.
* @since v11.6.0
*/
- function createPrivateKey(key: PrivateKeyInput | string | Buffer | JsonWebKeyInput): KeyObject;
+ function createPrivateKey(key: PrivateKeyInput | RawPrivateKeyInput | JsonWebKeyInput | BinaryLike): KeyObject;
/**
* Creates and returns a new key object containing a public key. If `key` is a
* string or `Buffer`, `format` is assumed to be `'pem'`; if `key` is a `KeyObject` with type `'private'`, the public key is derived from the given private key;
@@ -1303,15 +1185,14 @@ declare module "node:crypto" {
* and it will be impossible to extract the private key from the returned object.
* @since v11.6.0
*/
- function createPublicKey(key: PublicKeyInput | string | Buffer | KeyObject | JsonWebKeyInput): KeyObject;
+ function createPublicKey(key: PublicKeyInput | RawPublicKeyInput | JsonWebKeyInput | BinaryLike): KeyObject;
/**
* Creates and returns a new key object containing a secret key for symmetric
* encryption or `Hmac`.
* @since v11.6.0
* @param encoding The string encoding when `key` is a string.
*/
- function createSecretKey(key: NodeJS.ArrayBufferView): KeyObject;
- function createSecretKey(key: string, encoding: BufferEncoding): KeyObject;
+ function createSecretKey(key: BinaryLike, encoding?: BufferEncoding): KeyObject;
/**
* Creates and returns a `Sign` object that uses the given `algorithm`. Use {@link getHashes} to obtain the names of the available digest algorithms.
* Optional `options` argument controls the `stream.Writable` behavior.
@@ -1324,29 +1205,26 @@ declare module "node:crypto" {
* @since v0.1.92
* @param options `stream.Writable` options
*/
- // TODO: signing algorithm type
- function createSign(algorithm: string, options?: stream.WritableOptions): Sign;
+ function createSign(algorithm: string, options?: WritableOptions): Sign;
type DSAEncoding = "der" | "ieee-p1363";
interface SigningOptions {
- /**
- * @see crypto.constants.RSA_PKCS1_PADDING
- */
padding?: number | undefined;
saltLength?: number | undefined;
dsaEncoding?: DSAEncoding | undefined;
- context?: ArrayBuffer | NodeJS.ArrayBufferView | undefined;
+ context?: NodeJS.ArrayBufferView | undefined;
}
interface SignPrivateKeyInput extends PrivateKeyInput, SigningOptions {}
+ interface SignRawPrivateKeyInput extends RawPrivateKeyInput, SigningOptions {}
+ interface SignJsonWebKeyInput extends JsonWebKeyInput, SigningOptions {}
interface SignKeyObjectInput extends SigningOptions {
key: KeyObject;
}
- interface SignJsonWebKeyInput extends JsonWebKeyInput, SigningOptions {}
interface VerifyPublicKeyInput extends PublicKeyInput, SigningOptions {}
+ interface VerifyRawPublicKeyInput extends RawPublicKeyInput, SigningOptions {}
+ interface VerifyJsonWebKeyInput extends JsonWebKeyInput, SigningOptions {}
interface VerifyKeyObjectInput extends SigningOptions {
key: KeyObject;
}
- interface VerifyJsonWebKeyInput extends JsonWebKeyInput, SigningOptions {}
- type KeyLike = string | Buffer | KeyObject;
/**
* The `Sign` class is a utility for generating signatures. It can be used in one
* of two ways:
@@ -1410,7 +1288,7 @@ declare module "node:crypto" {
* ```
* @since v0.1.92
*/
- class Sign extends stream.Writable {
+ class Sign extends Writable {
private constructor();
/**
* Updates the `Sign` content with the given `data`, the encoding of which
@@ -1422,8 +1300,7 @@ declare module "node:crypto" {
* @since v0.1.92
* @param inputEncoding The `encoding` of the `data` string.
*/
- update(data: BinaryLike): this;
- update(data: string, inputEncoding: Encoding): this;
+ update(data: string | NodeJS.ArrayBufferView, inputEncoding?: BufferEncoding): this;
/**
* Calculates the signature on all the data passed through using either `sign.update()` or `sign.write()`.
*
@@ -1436,10 +1313,22 @@ declare module "node:crypto" {
* called. Multiple calls to `sign.sign()` will result in an error being thrown.
* @since v0.1.92
*/
- sign(privateKey: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput): NonSharedBuffer;
sign(
- privateKey: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput,
- outputFormat: BinaryToTextEncoding,
+ privateKey:
+ | KeyLike
+ | SignKeyObjectInput
+ | SignPrivateKeyInput
+ | SignRawPrivateKeyInput
+ | SignJsonWebKeyInput,
+ ): NonSharedBuffer;
+ sign(
+ privateKey:
+ | KeyLike
+ | SignKeyObjectInput
+ | SignPrivateKeyInput
+ | SignRawPrivateKeyInput
+ | SignJsonWebKeyInput,
+ outputFormat: BufferEncoding,
): string;
}
/**
@@ -1455,7 +1344,7 @@ declare module "node:crypto" {
* @since v0.1.92
* @param options `stream.Writable` options
*/
- function createVerify(algorithm: string, options?: stream.WritableOptions): Verify;
+ function createVerify(algorithm: string, options?: WritableOptions): Verify;
/**
* The `Verify` class is a utility for verifying signatures. It can be used in one
* of two ways:
@@ -1470,7 +1359,7 @@ declare module "node:crypto" {
* See `Sign` for examples.
* @since v0.1.92
*/
- class Verify extends stream.Writable {
+ class Verify extends Writable {
private constructor();
/**
* Updates the `Verify` content with the given `data`, the encoding of which
@@ -1482,8 +1371,7 @@ declare module "node:crypto" {
* @since v0.1.92
* @param inputEncoding The `encoding` of the `data` string.
*/
- update(data: BinaryLike): Verify;
- update(data: string, inputEncoding: Encoding): Verify;
+ update(data: string | NodeJS.ArrayBufferView, inputEncoding?: BufferEncoding): Verify;
/**
* Verifies the provided data using the given `object` and `signature`.
*
@@ -1504,13 +1392,14 @@ declare module "node:crypto" {
* @since v0.1.92
*/
verify(
- object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput,
- signature: NodeJS.ArrayBufferView,
- ): boolean;
- verify(
- object: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput,
- signature: string,
- signature_format?: BinaryToTextEncoding,
+ object:
+ | KeyLike
+ | VerifyKeyObjectInput
+ | VerifyPublicKeyInput
+ | VerifyRawPublicKeyInput
+ | VerifyJsonWebKeyInput,
+ signature: BinaryLike,
+ signatureEncoding?: BufferEncoding,
): boolean;
}
/**
@@ -1531,24 +1420,15 @@ declare module "node:crypto" {
*/
function createDiffieHellman(primeLength: number, generator?: number): DiffieHellman;
function createDiffieHellman(
- prime: ArrayBuffer | NodeJS.ArrayBufferView,
- generator?: number | ArrayBuffer | NodeJS.ArrayBufferView,
- ): DiffieHellman;
- function createDiffieHellman(
- prime: ArrayBuffer | NodeJS.ArrayBufferView,
- generator: string,
- generatorEncoding: BinaryToTextEncoding,
+ prime: BinaryLike,
+ primeEncoding?: BufferEncoding,
+ generator?: number | BinaryLike,
+ generatorEncoding?: BufferEncoding,
): DiffieHellman;
function createDiffieHellman(
- prime: string,
- primeEncoding: BinaryToTextEncoding,
- generator?: number | ArrayBuffer | NodeJS.ArrayBufferView,
- ): DiffieHellman;
- function createDiffieHellman(
- prime: string,
- primeEncoding: BinaryToTextEncoding,
- generator: string,
- generatorEncoding: BinaryToTextEncoding,
+ prime: BinaryLike,
+ generator: number | BinaryLike,
+ generatorEncoding?: BufferEncoding,
): DiffieHellman;
/**
* The `DiffieHellman` class is a utility for creating Diffie-Hellman key
@@ -1596,7 +1476,7 @@ declare module "node:crypto" {
* @param encoding The `encoding` of the return value.
*/
generateKeys(): NonSharedBuffer;
- generateKeys(encoding: BinaryToTextEncoding): string;
+ generateKeys(encoding: BufferEncoding): string;
/**
* Computes the shared secret using `otherPublicKey` as the other
* party's public key and returns the computed shared secret. The supplied
@@ -1611,24 +1491,13 @@ declare module "node:crypto" {
* @param outputEncoding The `encoding` of the return value.
*/
computeSecret(
- otherPublicKey: NodeJS.ArrayBufferView,
- inputEncoding?: null,
- outputEncoding?: null,
+ otherPublicKey: BinaryLike,
+ inputEncoding?: BufferEncoding,
): NonSharedBuffer;
computeSecret(
- otherPublicKey: string,
- inputEncoding: BinaryToTextEncoding,
- outputEncoding?: null,
- ): NonSharedBuffer;
- computeSecret(
- otherPublicKey: NodeJS.ArrayBufferView,
- inputEncoding: null,
- outputEncoding: BinaryToTextEncoding,
- ): string;
- computeSecret(
- otherPublicKey: string,
- inputEncoding: BinaryToTextEncoding,
- outputEncoding: BinaryToTextEncoding,
+ otherPublicKey: BinaryLike,
+ inputEncoding: BufferEncoding | null | undefined,
+ outputEncoding: BufferEncoding,
): string;
/**
* Returns the Diffie-Hellman prime in the specified `encoding`.
@@ -1638,7 +1507,7 @@ declare module "node:crypto" {
* @param encoding The `encoding` of the return value.
*/
getPrime(): NonSharedBuffer;
- getPrime(encoding: BinaryToTextEncoding): string;
+ getPrime(encoding: BufferEncoding): string;
/**
* Returns the Diffie-Hellman generator in the specified `encoding`.
* If `encoding` is provided a string is
@@ -1647,7 +1516,7 @@ declare module "node:crypto" {
* @param encoding The `encoding` of the return value.
*/
getGenerator(): NonSharedBuffer;
- getGenerator(encoding: BinaryToTextEncoding): string;
+ getGenerator(encoding: BufferEncoding): string;
/**
* Returns the Diffie-Hellman public key in the specified `encoding`.
* If `encoding` is provided a
@@ -1656,7 +1525,7 @@ declare module "node:crypto" {
* @param encoding The `encoding` of the return value.
*/
getPublicKey(): NonSharedBuffer;
- getPublicKey(encoding: BinaryToTextEncoding): string;
+ getPublicKey(encoding: BufferEncoding): string;
/**
* Returns the Diffie-Hellman private key in the specified `encoding`.
* If `encoding` is provided a
@@ -1665,7 +1534,7 @@ declare module "node:crypto" {
* @param encoding The `encoding` of the return value.
*/
getPrivateKey(): NonSharedBuffer;
- getPrivateKey(encoding: BinaryToTextEncoding): string;
+ getPrivateKey(encoding: BufferEncoding): string;
/**
* Sets the Diffie-Hellman public key. If the `encoding` argument is provided, `publicKey` is expected
* to be a string. If no `encoding` is provided, `publicKey` is expected
@@ -1673,8 +1542,7 @@ declare module "node:crypto" {
* @since v0.5.0
* @param encoding The `encoding` of the `publicKey` string.
*/
- setPublicKey(publicKey: NodeJS.ArrayBufferView): void;
- setPublicKey(publicKey: string, encoding: BufferEncoding): void;
+ setPublicKey(publicKey: BinaryLike, encoding?: BufferEncoding): void;
/**
* Sets the Diffie-Hellman private key. If the `encoding` argument is provided,`privateKey` is expected
* to be a string. If no `encoding` is provided, `privateKey` is expected
@@ -1685,8 +1553,7 @@ declare module "node:crypto" {
* @since v0.5.0
* @param encoding The `encoding` of the `privateKey` string.
*/
- setPrivateKey(privateKey: NodeJS.ArrayBufferView): void;
- setPrivateKey(privateKey: string, encoding: BufferEncoding): void;
+ setPrivateKey(privateKey: BinaryLike, encoding?: BufferEncoding): void;
/**
* A bit field containing any warnings and/or errors resulting from a check
* performed during initialization of the `DiffieHellman` object.
@@ -1724,13 +1591,10 @@ declare module "node:crypto" {
* ```
* @since v0.7.5
*/
- const DiffieHellmanGroup: DiffieHellmanGroupConstructor;
- interface DiffieHellmanGroupConstructor {
- new(name: string): DiffieHellmanGroup;
- (name: string): DiffieHellmanGroup;
- readonly prototype: DiffieHellmanGroup;
+ class DiffieHellmanGroup {
+ private constructor();
}
- type DiffieHellmanGroup = Omit;
+ interface DiffieHellmanGroup extends Omit {}
/**
* Creates a predefined `DiffieHellmanGroup` key exchange object. The
* supported groups are listed in the documentation for `DiffieHellmanGroup`.
@@ -1944,9 +1808,8 @@ declare module "node:crypto" {
* console.log(`The dice rolled: ${n}`);
* ```
* @since v14.10.0, v12.19.0
- * @param [min=0] Start of random range (inclusive).
+ * @param min Start of random range (inclusive).
* @param max End of random range (exclusive).
- * @param callback `function(err, n) {}`.
*/
function randomInt(max: number): number;
function randomInt(min: number, max: number): number;
@@ -1993,7 +1856,11 @@ declare module "node:crypto" {
* @param [size=buffer.length - offset]
* @return The object passed as `buffer` argument.
*/
- function randomFillSync(buffer: T, offset?: number, size?: number): T;
+ function randomFillSync(
+ buffer: T,
+ offset?: number,
+ size?: number,
+ ): T;
/**
* This function is similar to {@link randomBytes} but requires the first
* argument to be a `Buffer` that will be filled. It also
@@ -2069,16 +1936,16 @@ declare module "node:crypto" {
* @param [size=buffer.length - offset]
* @param callback `function(err, buf) {}`.
*/
- function randomFill(
+ function randomFill(
buffer: T,
callback: (err: Error | null, buf: T) => void,
): void;
- function randomFill(
+ function randomFill(
buffer: T,
offset: number,
callback: (err: Error | null, buf: T) => void,
): void;
- function randomFill(
+ function randomFill(
buffer: T,
offset: number,
size: number,
@@ -2176,19 +2043,25 @@ declare module "node:crypto" {
keylen: number,
options?: ScryptOptions,
): NonSharedBuffer;
- interface RsaPublicKey {
- key: KeyLike;
+ interface PublicDecryptOptions {
padding?: number | undefined;
+ encoding?: BufferEncoding | undefined;
}
- interface RsaPrivateKey {
- key: KeyLike;
- passphrase?: string | undefined;
- /**
- * @default 'sha1'
- */
+ interface PublicDecryptPrivateKeyInput extends PrivateKeyInput, PublicDecryptOptions {}
+ interface PublicDecryptPublicKeyInput extends PublicKeyInput, PublicDecryptOptions {}
+ interface PublicDecryptJsonWebKeyInput extends JsonWebKeyInput, PublicDecryptOptions {}
+ interface PublicDecryptKeyObjectInput extends PublicDecryptOptions {
+ key: KeyObject;
+ }
+ interface PublicEncryptOptions extends PublicDecryptOptions {
oaepHash?: string | undefined;
- oaepLabel?: NodeJS.TypedArray | undefined;
- padding?: number | undefined;
+ oaepLabel?: BinaryLike | undefined;
+ }
+ interface PublicEncryptPrivateKeyInput extends PrivateKeyInput, PublicEncryptOptions {}
+ interface PublicEncryptPublicKeyInput extends PublicKeyInput, PublicEncryptOptions {}
+ interface PublicEncryptJsonWebKeyInput extends JsonWebKeyInput, PublicEncryptOptions {}
+ interface PublicEncryptKeyObjectInput extends PublicEncryptOptions {
+ key: KeyObject;
}
/**
* Encrypts the content of `buffer` with `key` and returns a new `Buffer` with encrypted content. The returned data can be decrypted using
@@ -2202,8 +2075,13 @@ declare module "node:crypto" {
* @since v0.11.14
*/
function publicEncrypt(
- key: RsaPublicKey | RsaPrivateKey | KeyLike,
- buffer: NodeJS.ArrayBufferView | string,
+ key:
+ | KeyLike
+ | PublicEncryptKeyObjectInput
+ | PublicEncryptPrivateKeyInput
+ | PublicEncryptPublicKeyInput
+ | PublicEncryptJsonWebKeyInput,
+ buffer: BinaryLike,
): NonSharedBuffer;
/**
* Decrypts `buffer` with `key`.`buffer` was previously encrypted using
@@ -2217,8 +2095,13 @@ declare module "node:crypto" {
* @since v1.1.0
*/
function publicDecrypt(
- key: RsaPublicKey | RsaPrivateKey | KeyLike,
- buffer: NodeJS.ArrayBufferView | string,
+ key:
+ | KeyLike
+ | PublicDecryptKeyObjectInput
+ | PublicDecryptPrivateKeyInput
+ | PublicDecryptPublicKeyInput
+ | PublicDecryptJsonWebKeyInput,
+ buffer: BinaryLike,
): NonSharedBuffer;
/**
* Decrypts `buffer` with `privateKey`. `buffer` was previously encrypted using
@@ -2229,8 +2112,12 @@ declare module "node:crypto" {
* @since v0.11.14
*/
function privateDecrypt(
- privateKey: RsaPrivateKey | KeyLike,
- buffer: NodeJS.ArrayBufferView | string,
+ privateKey:
+ | KeyLike
+ | PublicEncryptKeyObjectInput
+ | PublicEncryptPrivateKeyInput
+ | PublicEncryptJsonWebKeyInput,
+ buffer: BinaryLike,
): NonSharedBuffer;
/**
* Encrypts `buffer` with `privateKey`. The returned data can be decrypted using
@@ -2241,8 +2128,12 @@ declare module "node:crypto" {
* @since v1.1.0
*/
function privateEncrypt(
- privateKey: RsaPrivateKey | KeyLike,
- buffer: NodeJS.ArrayBufferView | string,
+ privateKey:
+ | KeyLike
+ | PublicDecryptKeyObjectInput
+ | PublicDecryptPrivateKeyInput
+ | PublicDecryptJsonWebKeyInput,
+ buffer: BinaryLike,
): NonSharedBuffer;
/**
* ```js
@@ -2292,6 +2183,7 @@ declare module "node:crypto" {
* @return An array of the names of the supported hash algorithms, such as `'RSA-SHA256'`. Hash algorithms are also called "digest" algorithms.
*/
function getHashes(): string[];
+ type ECDHKeyFormat = "compressed" | "uncompressed" | "hybrid";
/**
* The `ECDH` class is a utility for creating Elliptic Curve Diffie-Hellman (ECDH)
* key exchanges.
@@ -2364,15 +2256,21 @@ declare module "node:crypto" {
* @since v10.0.0
* @param inputEncoding The `encoding` of the `key` string.
* @param outputEncoding The `encoding` of the return value.
- * @param [format='uncompressed']
*/
static convertKey(
key: BinaryLike,
curve: string,
- inputEncoding?: BinaryToTextEncoding,
- outputEncoding?: "latin1" | "hex" | "base64" | "base64url",
+ inputEncoding?: BufferEncoding,
+ outputEncoding?: null,
format?: "uncompressed" | "compressed" | "hybrid",
- ): NonSharedBuffer | string;
+ ): NonSharedBuffer;
+ static convertKey(
+ key: BinaryLike,
+ curve: string,
+ inputEncoding: BufferEncoding | null | undefined,
+ outputEncoding: BufferEncoding,
+ format?: "uncompressed" | "compressed" | "hybrid",
+ ): string;
/**
* Generates private and public EC Diffie-Hellman key values, and returns
* the public key in the specified `format` and `encoding`. This key should be
@@ -2385,8 +2283,8 @@ declare module "node:crypto" {
* @param encoding The `encoding` of the return value.
* @param [format='uncompressed']
*/
- generateKeys(): NonSharedBuffer;
- generateKeys(encoding: BinaryToTextEncoding, format?: ECDHKeyFormat): string;
+ generateKeys(encoding?: null, format?: ECDHKeyFormat): NonSharedBuffer;
+ generateKeys(encoding: BufferEncoding, format?: ECDHKeyFormat): string;
/**
* Computes the shared secret using `otherPublicKey` as the other
* party's public key and returns the computed shared secret. The supplied
@@ -2404,13 +2302,11 @@ declare module "node:crypto" {
* @param inputEncoding The `encoding` of the `otherPublicKey` string.
* @param outputEncoding The `encoding` of the return value.
*/
- computeSecret(otherPublicKey: NodeJS.ArrayBufferView): NonSharedBuffer;
- computeSecret(otherPublicKey: string, inputEncoding: BinaryToTextEncoding): NonSharedBuffer;
- computeSecret(otherPublicKey: NodeJS.ArrayBufferView, outputEncoding: BinaryToTextEncoding): string;
+ computeSecret(otherPublicKey: BinaryLike, inputEncoding?: BufferEncoding): NonSharedBuffer;
computeSecret(
- otherPublicKey: string,
- inputEncoding: BinaryToTextEncoding,
- outputEncoding: BinaryToTextEncoding,
+ otherPublicKey: BinaryLike,
+ inputEncoding: BufferEncoding | null | undefined,
+ outputEncoding: BufferEncoding,
): string;
/**
* If `encoding` is specified, a string is returned; otherwise a `Buffer` is
@@ -2420,7 +2316,7 @@ declare module "node:crypto" {
* @return The EC Diffie-Hellman in the specified `encoding`.
*/
getPrivateKey(): NonSharedBuffer;
- getPrivateKey(encoding: BinaryToTextEncoding): string;
+ getPrivateKey(encoding: BufferEncoding): string;
/**
* The `format` argument specifies point encoding and can be `'compressed'` or `'uncompressed'`. If `format` is not specified the point will be returned in`'uncompressed'` format.
*
@@ -2432,7 +2328,7 @@ declare module "node:crypto" {
* @return The EC Diffie-Hellman public key in the specified `encoding` and `format`.
*/
getPublicKey(encoding?: null, format?: ECDHKeyFormat): NonSharedBuffer;
- getPublicKey(encoding: BinaryToTextEncoding, format?: ECDHKeyFormat): string;
+ getPublicKey(encoding: BufferEncoding, format?: ECDHKeyFormat): string;
/**
* Sets the EC Diffie-Hellman private key.
* If `encoding` is provided, `privateKey` is expected
@@ -2444,8 +2340,7 @@ declare module "node:crypto" {
* @since v0.11.14
* @param encoding The `encoding` of the `privateKey` string.
*/
- setPrivateKey(privateKey: NodeJS.ArrayBufferView): void;
- setPrivateKey(privateKey: string, encoding: BinaryToTextEncoding): void;
+ setPrivateKey(privateKey: BinaryLike, encoding?: BufferEncoding): void;
}
/**
* Creates an Elliptic Curve Diffie-Hellman (`ECDH`) key exchange object using a
@@ -2480,46 +2375,22 @@ declare module "node:crypto" {
* not introduce timing vulnerabilities.
* @since v6.6.0
*/
- function timingSafeEqual(a: NodeJS.ArrayBufferView, b: NodeJS.ArrayBufferView): boolean;
+ function timingSafeEqual(
+ a: ArrayBufferLike | NodeJS.ArrayBufferView,
+ b: ArrayBufferLike | NodeJS.ArrayBufferView,
+ ): boolean;
interface DHKeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {
- /**
- * The prime parameter
- */
- prime?: Buffer | undefined;
- /**
- * Prime length in bits
- */
+ prime?: NodeJS.ArrayBufferView | undefined;
primeLength?: number | undefined;
- /**
- * Custom generator
- * @default 2
- */
generator?: number | undefined;
- /**
- * Diffie-Hellman group name
- * @see {@link getDiffieHellman}
- */
groupName?: string | undefined;
}
interface DSAKeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {
- /**
- * Key size in bits
- */
modulusLength: number;
- /**
- * Size of q in bits
- */
- divisorLength: number;
+ divisorLength?: number | undefined;
}
interface ECKeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8" | "sec1"> {
- /**
- * Name of the curve to use
- */
namedCurve: string;
- /**
- * Must be `'named'` or `'explicit'`
- * @default 'named'
- */
paramEncoding?: "explicit" | "named" | undefined;
}
interface ED25519KeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {}
@@ -2527,37 +2398,14 @@ declare module "node:crypto" {
interface MLDSAKeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {}
interface MLKEMKeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {}
interface RSAPSSKeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {
- /**
- * Key size in bits
- */
modulusLength: number;
- /**
- * Public exponent
- * @default 0x10001
- */
publicExponent?: number | undefined;
- /**
- * Name of the message digest
- */
hashAlgorithm?: string | undefined;
- /**
- * Name of the message digest used by MGF1
- */
mgf1HashAlgorithm?: string | undefined;
- /**
- * Minimal salt length in bytes
- */
saltLength?: string | undefined;
}
interface RSAKeyPairOptions extends KeyPairExportOptions<"pkcs1" | "spki", "pkcs1" | "pkcs8"> {
- /**
- * Key size in bits
- */
modulusLength: number;
- /**
- * Public exponent
- * @default 0x10001
- */
publicExponent?: number | undefined;
}
interface SLHDSAKeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {}
@@ -2565,7 +2413,7 @@ declare module "node:crypto" {
interface X448KeyPairOptions extends KeyPairExportOptions<"spki", "pkcs8"> {}
/**
* Generates a new asymmetric key pair of the given `type`. See the
- * supported [asymmetric key types](https://nodejs.org/docs/latest-v25.x/api/crypto.html#asymmetric-key-types).
+ * supported [asymmetric key types](https://nodejs.org/docs/latest-v26.x/api/crypto.html#asymmetric-key-types).
*
* If a `publicKeyEncoding` or `privateKeyEncoding` was specified, this function
* behaves as if `keyObject.export()` had been called on its result. Otherwise,
@@ -2603,7 +2451,7 @@ declare module "node:crypto" {
* it will be a buffer containing the data encoded as DER.
* @since v10.12.0
* @param type The asymmetric key type to generate. See the
- * supported [asymmetric key types](https://nodejs.org/docs/latest-v25.x/api/crypto.html#asymmetric-key-types).
+ * supported [asymmetric key types](https://nodejs.org/docs/latest-v26.x/api/crypto.html#asymmetric-key-types).
*/
function generateKeyPairSync(
type: "dh",
@@ -2655,7 +2503,7 @@ declare module "node:crypto" {
): KeyPairExportResult;
/**
* Generates a new asymmetric key pair of the given `type`. See the
- * supported [asymmetric key types](https://nodejs.org/docs/latest-v25.x/api/crypto.html#asymmetric-key-types).
+ * supported [asymmetric key types](https://nodejs.org/docs/latest-v26.x/api/crypto.html#asymmetric-key-types).
*
* If a `publicKeyEncoding` or `privateKeyEncoding` was specified, this function
* behaves as if `keyObject.export()` had been called on its result. Otherwise,
@@ -2691,7 +2539,7 @@ declare module "node:crypto" {
* a `Promise` for an `Object` with `publicKey` and `privateKey` properties.
* @since v10.12.0
* @param type The asymmetric key type to generate. See the
- * supported [asymmetric key types](https://nodejs.org/docs/latest-v25.x/api/crypto.html#asymmetric-key-types).
+ * supported [asymmetric key types](https://nodejs.org/docs/latest-v26.x/api/crypto.html#asymmetric-key-types).
*/
function generateKeyPair(
type: "dh",
@@ -2708,21 +2556,37 @@ declare module "node:crypto" {
options: T,
callback: KeyPairExportCallback,
): void;
+ function generateKeyPair(
+ type: "ed25519",
+ callback: KeyPairExportCallback,
+ ): void;
function generateKeyPair(
type: "ed25519",
options: T | undefined,
callback: KeyPairExportCallback,
): void;
+ function generateKeyPair(
+ type: "ed448",
+ callback: KeyPairExportCallback,
+ ): void;
function generateKeyPair(
type: "ed448",
options: T | undefined,
callback: KeyPairExportCallback,
): void;
+ function generateKeyPair(
+ type: MLDSAKeyType,
+ callback: KeyPairExportCallback,
+ ): void;
function generateKeyPair(
type: MLDSAKeyType,
options: T | undefined,
callback: KeyPairExportCallback,
): void;
+ function generateKeyPair(
+ type: MLKEMKeyType,
+ callback: KeyPairExportCallback,
+ ): void;
function generateKeyPair(
type: MLKEMKeyType,
options: T | undefined,
@@ -2738,16 +2602,28 @@ declare module "node:crypto" {
options: T,
callback: KeyPairExportCallback,
): void;
+ function generateKeyPair(
+ type: SLHDSAKeyType,
+ callback: KeyPairExportCallback,
+ ): void;
function generateKeyPair(
type: SLHDSAKeyType,
options: T | undefined,
callback: KeyPairExportCallback,
): void;
+ function generateKeyPair(
+ type: "x25519",
+ callback: KeyPairExportCallback,
+ ): void;
function generateKeyPair(
type: "x25519",
options: T | undefined,
callback: KeyPairExportCallback,
): void;
+ function generateKeyPair(
+ type: "x448",
+ callback: KeyPairExportCallback,
+ ): void;
function generateKeyPair(
type: "x448",
options: T | undefined,
@@ -2820,12 +2696,12 @@ declare module "node:crypto" {
*/
function sign(
algorithm: string | null | undefined,
- data: NodeJS.ArrayBufferView,
+ data: ArrayBufferLike | NodeJS.ArrayBufferView,
key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput,
): NonSharedBuffer;
function sign(
algorithm: string | null | undefined,
- data: NodeJS.ArrayBufferView,
+ data: ArrayBufferLike | NodeJS.ArrayBufferView,
key: KeyLike | SignKeyObjectInput | SignPrivateKeyInput | SignJsonWebKeyInput,
callback: (error: Error | null, data: NonSharedBuffer) => void,
): void;
@@ -2851,15 +2727,15 @@ declare module "node:crypto" {
*/
function verify(
algorithm: string | null | undefined,
- data: NodeJS.ArrayBufferView,
+ data: ArrayBufferLike | NodeJS.ArrayBufferView,
key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput,
- signature: NodeJS.ArrayBufferView,
+ signature: ArrayBufferLike | NodeJS.ArrayBufferView,
): boolean;
function verify(
algorithm: string | null | undefined,
- data: NodeJS.ArrayBufferView,
+ data: ArrayBufferLike | NodeJS.ArrayBufferView,
key: KeyLike | VerifyKeyObjectInput | VerifyPublicKeyInput | VerifyJsonWebKeyInput,
- signature: NodeJS.ArrayBufferView,
+ signature: ArrayBufferLike | NodeJS.ArrayBufferView,
callback: (error: Error | null, result: boolean) => void,
): void;
/**
@@ -2882,14 +2758,18 @@ declare module "node:crypto" {
* @since v24.7.0
*/
function decapsulate(
- key: KeyLike | PrivateKeyInput | JsonWebKeyInput,
- ciphertext: ArrayBuffer | NodeJS.ArrayBufferView,
+ key: KeyLike | PrivateKeyInput | RawPrivateKeyInput | JsonWebKeyInput,
+ ciphertext: ArrayBufferLike | NodeJS.ArrayBufferView,
): NonSharedBuffer;
function decapsulate(
- key: KeyLike | PrivateKeyInput | JsonWebKeyInput,
- ciphertext: ArrayBuffer | NodeJS.ArrayBufferView,
+ key: KeyLike | PrivateKeyInput | RawPrivateKeyInput | JsonWebKeyInput,
+ ciphertext: ArrayBufferLike | NodeJS.ArrayBufferView,
callback: (err: Error, sharedKey: NonSharedBuffer) => void,
): void;
+ interface DiffieHellmanOptions {
+ privateKey: KeyLike | PrivateKeyInput;
+ publicKey: KeyLike | PublicKeyInput;
+ }
/**
* Computes the Diffie-Hellman shared secret based on a `privateKey` and a `publicKey`.
* Both keys must have the same `asymmetricKeyType` and must support either the DH or
@@ -2898,9 +2778,9 @@ declare module "node:crypto" {
* If the `callback` function is provided this function uses libuv's threadpool.
* @since v13.9.0, v12.17.0
*/
- function diffieHellman(options: { privateKey: KeyObject; publicKey: KeyObject }): NonSharedBuffer;
+ function diffieHellman(options: DiffieHellmanOptions): NonSharedBuffer;
function diffieHellman(
- options: { privateKey: KeyObject; publicKey: KeyObject },
+ options: DiffieHellmanOptions,
callback: (err: Error | null, secret: NonSharedBuffer) => void,
): void;
/**
@@ -2923,10 +2803,10 @@ declare module "node:crypto" {
* @since v24.7.0
*/
function encapsulate(
- key: KeyLike | PublicKeyInput | JsonWebKeyInput,
+ key: KeyLike | PublicKeyInput | RawPublicKeyInput | JsonWebKeyInput,
): { sharedKey: NonSharedBuffer; ciphertext: NonSharedBuffer };
function encapsulate(
- key: KeyLike | PublicKeyInput | JsonWebKeyInput,
+ key: KeyLike | PublicKeyInput | RawPublicKeyInput | JsonWebKeyInput,
callback: (err: Error, result: { sharedKey: NonSharedBuffer; ciphertext: NonSharedBuffer }) => void,
): void;
interface OneShotDigestOptions {
@@ -2934,7 +2814,7 @@ declare module "node:crypto" {
* Encoding used to encode the returned digest.
* @default 'hex'
*/
- outputEncoding?: BinaryToTextEncoding | "buffer" | undefined;
+ outputEncoding?: BufferEncoding | "buffer" | undefined;
/**
* For XOF hash functions such as 'shake256', the outputLength option
* can be used to specify the desired output length in bytes.
@@ -2942,7 +2822,7 @@ declare module "node:crypto" {
outputLength?: number | undefined;
}
interface OneShotDigestOptionsWithStringEncoding extends OneShotDigestOptions {
- outputEncoding?: BinaryToTextEncoding | undefined;
+ outputEncoding?: BufferEncoding | undefined;
}
interface OneShotDigestOptionsWithBufferEncoding extends OneShotDigestOptions {
outputEncoding: "buffer";
@@ -2986,7 +2866,7 @@ declare module "node:crypto" {
function hash(
algorithm: string,
data: BinaryLike,
- options?: OneShotDigestOptionsWithStringEncoding | BinaryToTextEncoding,
+ options?: OneShotDigestOptionsWithStringEncoding | BufferEncoding,
): string;
function hash(
algorithm: string,
@@ -2996,7 +2876,7 @@ declare module "node:crypto" {
function hash(
algorithm: string,
data: BinaryLike,
- options: OneShotDigestOptions | BinaryToTextEncoding | "buffer",
+ options: OneShotDigestOptions | BufferEncoding | "buffer",
): string | NonSharedBuffer;
type CipherMode = "cbc" | "ccm" | "cfb" | "ctr" | "ecb" | "gcm" | "ocb" | "ofb" | "stream" | "wrap" | "xts";
interface CipherInfoOptions {
@@ -3010,31 +2890,11 @@ declare module "node:crypto" {
ivLength?: number | undefined;
}
interface CipherInfo {
- /**
- * The name of the cipher.
- */
name: string;
- /**
- * The nid of the cipher.
- */
nid: number;
- /**
- * The block size of the cipher in bytes.
- * This property is omitted when mode is 'stream'.
- */
- blockSize?: number | undefined;
- /**
- * The expected or default initialization vector length in bytes.
- * This property is omitted if the cipher does not use an initialization vector.
- */
- ivLength?: number | undefined;
- /**
- * The expected or default key length in bytes.
- */
+ blockSize?: number;
+ ivLength?: number;
keyLength: number;
- /**
- * The cipher mode.
- */
mode: CipherMode;
}
/**
@@ -3078,7 +2938,7 @@ declare module "node:crypto" {
*/
function hkdf(
digest: string,
- irm: BinaryLike | KeyObject,
+ ikm: KeyLike,
salt: BinaryLike,
info: BinaryLike,
keylen: number,
@@ -3112,27 +2972,15 @@ declare module "node:crypto" {
*/
function hkdfSync(
digest: string,
- ikm: BinaryLike | KeyObject,
+ ikm: KeyLike,
salt: BinaryLike,
info: BinaryLike,
keylen: number,
): ArrayBuffer;
interface SecureHeapUsage {
- /**
- * The total allocated secure heap size as specified using the `--secure-heap=n` command-line flag.
- */
total: number;
- /**
- * The minimum allocation from the secure heap as specified using the `--secure-heap-min` command-line flag.
- */
min: number;
- /**
- * The total number of bytes currently allocated from the secure heap.
- */
used: number;
- /**
- * The calculated ratio of `used` to `total` allocated bytes.
- */
utilization: number;
}
/**
@@ -3145,7 +2993,6 @@ declare module "node:crypto" {
* Node.js will pre-emptively generate and persistently cache enough
* random data to generate up to 128 random UUIDs. To generate a UUID
* without using the cache, set `disableEntropyCache` to `true`.
- *
* @default `false`
*/
disableEntropyCache?: boolean | undefined;
@@ -3158,25 +3005,10 @@ declare module "node:crypto" {
*/
function randomUUID(options?: RandomUUIDOptions): UUID;
interface X509CheckOptions {
- /**
- * @default 'always'
- */
subject?: "always" | "default" | "never" | undefined;
- /**
- * @default true
- */
wildcards?: boolean | undefined;
- /**
- * @default true
- */
partialWildcards?: boolean | undefined;
- /**
- * @default false
- */
multiLabelWildcards?: boolean | undefined;
- /**
- * @default false
- */
singleLabelSubdomains?: boolean | undefined;
}
/**
@@ -3329,7 +3161,7 @@ declare module "node:crypto" {
* @since v22.10.0
*/
readonly validToDate: Date;
- constructor(buffer: BinaryLike);
+ constructor(buffer: string | NodeJS.ArrayBufferView);
/**
* Checks whether the certificate matches the given email address.
*
@@ -3432,13 +3264,10 @@ declare module "node:crypto" {
*/
verify(publicKey: KeyObject): boolean;
}
- type LargeNumberLike = NodeJS.ArrayBufferView | SharedArrayBuffer | ArrayBuffer | bigint;
+ type LargeNumberLike = ArrayBufferLike | NodeJS.ArrayBufferView | bigint;
interface GeneratePrimeOptions {
add?: LargeNumberLike | undefined;
rem?: LargeNumberLike | undefined;
- /**
- * @default false
- */
safe?: boolean | undefined;
bigint?: boolean | undefined;
}
@@ -3478,13 +3307,13 @@ declare module "node:crypto" {
function generatePrime(size: number, callback: (err: Error | null, prime: ArrayBuffer) => void): void;
function generatePrime(
size: number,
- options: GeneratePrimeOptionsBigInt,
- callback: (err: Error | null, prime: bigint) => void,
+ options: GeneratePrimeOptionsArrayBuffer,
+ callback: (err: Error | null, prime: ArrayBuffer) => void,
): void;
function generatePrime(
size: number,
- options: GeneratePrimeOptionsArrayBuffer,
- callback: (err: Error | null, prime: ArrayBuffer) => void,
+ options: GeneratePrimeOptionsBigInt,
+ callback: (err: Error | null, prime: bigint) => void,
): void;
function generatePrime(
size: number,
@@ -3519,8 +3348,8 @@ declare module "node:crypto" {
* @param size The size (in bits) of the prime to generate.
*/
function generatePrimeSync(size: number): ArrayBuffer;
- function generatePrimeSync(size: number, options: GeneratePrimeOptionsBigInt): bigint;
function generatePrimeSync(size: number, options: GeneratePrimeOptionsArrayBuffer): ArrayBuffer;
+ function generatePrimeSync(size: number, options: GeneratePrimeOptionsBigInt): bigint;
function generatePrimeSync(size: number, options: GeneratePrimeOptions): ArrayBuffer | bigint;
interface CheckPrimeOptions {
/**
@@ -3528,7 +3357,6 @@ declare module "node:crypto" {
* When the value is 0 (zero), a number of checks is used that yields a false positive rate of at most `2**-64` for random input.
* Care must be used when selecting a number of checks.
* Refer to the OpenSSL documentation for the BN_is_prime_ex function nchecks options for more details.
- *
* @default 0
*/
checks?: number | undefined;
@@ -3588,47 +3416,14 @@ declare module "node:crypto" {
>(typedArray: T): T;
type Argon2Algorithm = "argon2d" | "argon2i" | "argon2id";
interface Argon2Parameters {
- /**
- * REQUIRED, this is the password for password hashing applications of Argon2.
- */
- message: string | ArrayBuffer | NodeJS.ArrayBufferView;
- /**
- * REQUIRED, must be at least 8 bytes long. This is the salt for password hashing applications of Argon2.
- */
- nonce: string | ArrayBuffer | NodeJS.ArrayBufferView;
- /**
- * REQUIRED, degree of parallelism determines how many computational chains (lanes)
- * can be run. Must be greater than 1 and less than `2**24-1`.
- */
+ message: BinaryLike;
+ nonce: BinaryLike;
parallelism: number;
- /**
- * REQUIRED, the length of the key to generate. Must be greater than 4 and
- * less than `2**32-1`.
- */
tagLength: number;
- /**
- * REQUIRED, memory cost in 1KiB blocks. Must be greater than
- * `8 * parallelism` and less than `2**32-1`. The actual number of blocks is rounded
- * down to the nearest multiple of `4 * parallelism`.
- */
memory: number;
- /**
- * REQUIRED, number of passes (iterations). Must be greater than 1 and less
- * than `2**32-1`.
- */
passes: number;
- /**
- * OPTIONAL, Random additional input,
- * similar to the salt, that should **NOT** be stored with the derived key. This is known as pepper in
- * password hashing applications. If used, must have a length not greater than `2**32-1` bytes.
- */
- secret?: string | ArrayBuffer | NodeJS.ArrayBufferView | undefined;
- /**
- * OPTIONAL, Additional data to
- * be added to the hash, functionally equivalent to salt or secret, but meant for
- * non-random data. If used, must have a length not greater than `2**32-1` bytes.
- */
- associatedData?: string | ArrayBuffer | NodeJS.ArrayBufferView | undefined;
+ secret?: BinaryLike | undefined;
+ associatedData?: BinaryLike | undefined;
}
/**
* Provides an asynchronous [Argon2](https://www.rfc-editor.org/rfc/rfc9106.html) implementation. Argon2 is a password-based
@@ -3639,7 +3434,7 @@ declare module "node:crypto" {
* random and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details.
*
* When passing strings for `message`, `nonce`, `secret` or `associatedData`, please
- * consider [caveats when using strings as inputs to cryptographic APIs](https://nodejs.org/docs/latest-v25.x/api/crypto.html#using-strings-as-inputs-to-cryptographic-apis).
+ * consider [caveats when using strings as inputs to cryptographic APIs](https://nodejs.org/docs/latest-v26.x/api/crypto.html#using-strings-as-inputs-to-cryptographic-apis).
*
* The `callback` function is called with two arguments: `err` and `derivedKey`.
* `err` is an exception object when key derivation fails, otherwise `err` is
@@ -3683,7 +3478,7 @@ declare module "node:crypto" {
* random and at least 16 bytes long. See [NIST SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf) for details.
*
* When passing strings for `message`, `nonce`, `secret` or `associatedData`, please
- * consider [caveats when using strings as inputs to cryptographic APIs](https://nodejs.org/docs/latest-v25.x/api/crypto.html#using-strings-as-inputs-to-cryptographic-apis).
+ * consider [caveats when using strings as inputs to cryptographic APIs](https://nodejs.org/docs/latest-v26.x/api/crypto.html#using-strings-as-inputs-to-cryptographic-apis).
*
* An exception is thrown when key derivation fails, otherwise the derived key is
* returned as a `Buffer`.
@@ -4052,6 +3847,94 @@ declare module "node:crypto" {
): Promise;
}
}
+ /**
+ * An object containing commonly used constants for crypto and security related
+ * operations. The specific constants currently defined are described in
+ * [Crypto constants](https://nodejs.org/docs/latest-v26.x/api/crypto.html#crypto-constants).
+ * @since v6.3.0
+ */
+ namespace constants {
+ const OPENSSL_VERSION_NUMBER: number;
+ const SSL_OP_ALL: number;
+ const SSL_OP_ALLOW_NO_DHE_KEX: number;
+ const SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number;
+ const SSL_OP_CIPHER_SERVER_PREFERENCE: number;
+ const SSL_OP_CISCO_ANYCONNECT: number;
+ const SSL_OP_COOKIE_EXCHANGE: number;
+ const SSL_OP_CRYPTOPRO_TLSEXT_BUG: number;
+ const SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number;
+ const SSL_OP_LEGACY_SERVER_CONNECT: number;
+ const SSL_OP_NO_COMPRESSION: number;
+ const SSL_OP_NO_ENCRYPT_THEN_MAC: number;
+ const SSL_OP_NO_QUERY_MTU: number;
+ const SSL_OP_NO_RENEGOTIATION: number;
+ const SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number;
+ const SSL_OP_NO_SSLv2: number;
+ const SSL_OP_NO_SSLv3: number;
+ const SSL_OP_NO_TICKET: number;
+ const SSL_OP_NO_TLSv1: number;
+ const SSL_OP_NO_TLSv1_1: number;
+ const SSL_OP_NO_TLSv1_2: number;
+ const SSL_OP_NO_TLSv1_3: number;
+ const SSL_OP_PRIORITIZE_CHACHA: number;
+ const SSL_OP_TLS_ROLLBACK_BUG: number;
+ const ENGINE_METHOD_RSA: number;
+ const ENGINE_METHOD_DSA: number;
+ const ENGINE_METHOD_DH: number;
+ const ENGINE_METHOD_RAND: number;
+ const ENGINE_METHOD_EC: number;
+ const ENGINE_METHOD_CIPHERS: number;
+ const ENGINE_METHOD_DIGESTS: number;
+ const ENGINE_METHOD_PKEY_METHS: number;
+ const ENGINE_METHOD_PKEY_ASN1_METHS: number;
+ const ENGINE_METHOD_ALL: number;
+ const ENGINE_METHOD_NONE: number;
+ const DH_CHECK_P_NOT_SAFE_PRIME: number;
+ const DH_CHECK_P_NOT_PRIME: number;
+ const DH_UNABLE_TO_CHECK_GENERATOR: number;
+ const DH_NOT_SUITABLE_GENERATOR: number;
+ const RSA_PKCS1_PADDING: number;
+ const RSA_NO_PADDING: number;
+ const RSA_PKCS1_OAEP_PADDING: number;
+ const RSA_X931_PADDING: number;
+ const RSA_PKCS1_PSS_PADDING: number;
+ const RSA_PSS_SALTLEN_DIGEST: number;
+ const RSA_PSS_SALTLEN_MAX_SIGN: number;
+ const RSA_PSS_SALTLEN_AUTO: number;
+ const TLS1_VERSION: number;
+ const TLS1_1_VERSION: number;
+ const TLS1_2_VERSION: number;
+ const TLS1_3_VERSION: number;
+ const POINT_CONVERSION_COMPRESSED: number;
+ const POINT_CONVERSION_UNCOMPRESSED: number;
+ const POINT_CONVERSION_HYBRID: number;
+ const defaultCipherList: string;
+ const defaultCoreCipherList: string;
+ }
+ // TODO: remove in future major version
+ /** @deprecated This type will be removed in a future version. Use `BufferEncoding` instead. */
+ type BinaryToTextEncoding = "base64" | "base64url" | "hex" | "binary";
+ /** @deprecated This type will be removed in a future version. Use `BufferEncoding` instead. */
+ type CharacterEncoding = "utf8" | "utf-8" | "utf16le" | "utf-16le" | "latin1";
+ /** @deprecated This type will be removed in a future version. Use `BufferEncoding` instead. */
+ type LegacyCharacterEncoding = "ascii" | "binary" | "ucs2" | "ucs-2";
+ /** @deprecated This type will be removed in a future version. Use `BufferEncoding` instead. */
+ type Encoding = BufferEncoding;
+ /** @deprecated This type will be removed in a future version. Use `KeyLike` instead. */
+ type CipherKey = KeyLike;
+ /** @deprecated This type will be removed in a future version. */
+ interface RsaPrivateKey {
+ key: KeyLike;
+ passphrase?: string | undefined;
+ oaepHash?: string | undefined;
+ oaepLabel?: NodeJS.TypedArray | undefined;
+ padding?: number | undefined;
+ }
+ /** @deprecated This type will be removed in a future version. */
+ interface RsaPublicKey {
+ key: KeyLike;
+ padding?: number | undefined;
+ }
}
declare module "crypto" {
export * from "node:crypto";
diff --git a/types/node/diagnostics_channel.d.ts b/types/node/diagnostics_channel.d.ts
index fa8361272e6c75..a88c7454d716d5 100644
--- a/types/node/diagnostics_channel.d.ts
+++ b/types/node/diagnostics_channel.d.ts
@@ -427,12 +427,20 @@ declare module "node:diagnostics_channel" {
...args: Args
): Result;
/**
- * Trace a promise-returning function call. This will always produce a `start event` and `end event` around the synchronous portion of the
- * function execution, and will produce an `asyncStart event` and `asyncEnd event` when a promise continuation is reached. It may also
- * produce an `error event` if the given function throws an error or the
- * returned promise rejects. This will run the given function using `channel.runStores(context, ...)` on the `start` channel which ensures all
+ * Trace an asynchronous function call which returns a `Promise` or
+ * [thenable object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise#thenables). This will always produce a [`start` event](https://nodejs.org/docs/latest-v26.x/api/diagnostics_channel.html#startevent) and
+ * [`end` event](https://nodejs.org/docs/latest-v26.x/api/diagnostics_channel.html#endevent) around the synchronous portion of the function execution, and
+ * will produce an [`asyncStart` event](https://nodejs.org/docs/latest-v26.x/api/diagnostics_channel.html#asyncstartevent) and [`asyncEnd` event](https://nodejs.org/docs/latest-v26.x/api/diagnostics_channel.html#asyncendevent) when the
+ * returned promise is resolved or rejected. It may also produce an
+ * [`error` event](https://nodejs.org/docs/latest-v26.x/api/diagnostics_channel.html#errorevent) if the given function throws an error or the returned promise
+ * is rejected. This will run the given function using
+ * [`channel.runStores(context, ...)`](https://nodejs.org/docs/latest-v26.x/api/diagnostics_channel.html##channelrunstorescontext-fn-thisarg-args) on the `start` channel which ensures all
* events should have any bound stores set to match this trace context.
*
+ * If the value returned by `fn` is not a Promise or thenable, then it will be
+ * returned with a warning, and no `asyncStart` or `asyncEnd` events will be
+ * produced.
+ *
* To ensure only correct trace graphs are formed, events will only be published if subscribers are present prior to starting the trace. Subscriptions
* which are added after the trace begins will not receive future events from that trace, only future traces will be seen.
*
@@ -449,18 +457,21 @@ declare module "node:diagnostics_channel" {
* ```
* @since v19.9.0
* @experimental
- * @param fn Promise-returning function to wrap a trace around
+ * @param fn Function to wrap a trace around
* @param context Shared object to correlate trace events through
* @param thisArg The receiver to be used for the function call
* @param args Optional arguments to pass to the function
- * @return Chained from promise returned by the given function
+ * @returns The return value of the given function, or the result of
+ * calling `.then(...)` on the return value if the tracing channel has active
+ * subscribers. If the return value is not a Promise or thenable, then
+ * it is returned as-is and a warning is emitted.
*/
- tracePromise(
- fn: (this: ThisArg, ...args: Args) => Promise,
+ tracePromise = any>(
+ fn: (this: ThisArg, ...args: Args) => Result,
context?: ContextType,
thisArg?: ThisArg,
...args: Args
- ): Promise;
+ ): Result;
/**
* Trace a callback-receiving function call. This will always produce a `start event` and `end event` around the synchronous portion of the
* function execution, and will produce a `asyncStart event` and `asyncEnd event` around the callback execution. It may also produce an `error event` if the given function throws an error or
diff --git a/types/node/dns.d.ts b/types/node/dns.d.ts
index 2e0941e58e1c3c..7a1d41109965ae 100644
--- a/types/node/dns.d.ts
+++ b/types/node/dns.d.ts
@@ -24,7 +24,7 @@ declare module "node:dns" {
*/
family?: number | "IPv4" | "IPv6" | undefined;
/**
- * One or more [supported `getaddrinfo`](https://nodejs.org/docs/latest-v25.x/api/dns.html#supported-getaddrinfo-flags) flags. Multiple flags may be
+ * One or more [supported `getaddrinfo`](https://nodejs.org/docs/latest-v26.x/api/dns.html#supported-getaddrinfo-flags) flags. Multiple flags may be
* passed by bitwise `OR`ing their values.
*/
hints?: number | undefined;
@@ -37,7 +37,7 @@ declare module "node:dns" {
* When `verbatim`, the resolved addresses are return unsorted. When `ipv4first`, the resolved addresses are sorted
* by placing IPv4 addresses before IPv6 addresses. When `ipv6first`, the resolved addresses are sorted by placing IPv6
* addresses before IPv4 addresses. Default value is configurable using
- * {@link setDefaultResultOrder} or [`--dns-result-order`](https://nodejs.org/docs/latest-v25.x/api/cli.html#--dns-result-orderorder).
+ * {@link setDefaultResultOrder} or [`--dns-result-order`](https://nodejs.org/docs/latest-v26.x/api/cli.html#--dns-result-orderorder).
* @default `verbatim` (addresses are not reordered)
* @since v22.1.0
*/
@@ -86,7 +86,7 @@ declare module "node:dns" {
* The implementation uses an operating system facility that can associate names
* with addresses and vice versa. This implementation can have subtle but
* important consequences on the behavior of any Node.js program. Please take some
- * time to consult the [Implementation considerations section](https://nodejs.org/docs/latest-v25.x/api/dns.html#implementation-considerations)
+ * time to consult the [Implementation considerations section](https://nodejs.org/docs/latest-v26.x/api/dns.html#implementation-considerations)
* before using `dns.lookup()`.
*
* Example usage:
@@ -108,7 +108,7 @@ declare module "node:dns" {
* // addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}]
* ```
*
- * If this method is invoked as its [util.promisify()](https://nodejs.org/docs/latest-v25.x/api/util.html#utilpromisifyoriginal) ed
+ * If this method is invoked as its [util.promisify()](https://nodejs.org/docs/latest-v26.x/api/util.html#utilpromisifyoriginal) ed
* version, and `all` is not set to `true`, it returns a `Promise` for an `Object` with `address` and `family` properties.
* @since v0.1.90
*/
@@ -148,7 +148,7 @@ declare module "node:dns" {
* If `address` is not a valid IP address, a `TypeError` will be thrown.
* The `port` will be coerced to a number. If it is not a legal port, a `TypeError` will be thrown.
*
- * On an error, `err` is an [`Error`](https://nodejs.org/docs/latest-v25.x/api/errors.html#class-error) object,
+ * On an error, `err` is an [`Error`](https://nodejs.org/docs/latest-v26.x/api/errors.html#class-error) object,
* where `err.code` is the error code.
*
* ```js
@@ -159,7 +159,7 @@ declare module "node:dns" {
* });
* ```
*
- * If this method is invoked as its [util.promisify()](https://nodejs.org/docs/latest-v25.x/api/util.html#utilpromisifyoriginal) ed
+ * If this method is invoked as its [util.promisify()](https://nodejs.org/docs/latest-v26.x/api/util.html#utilpromisifyoriginal) ed
* version, it returns a `Promise` for an `Object` with `hostname` and `service` properties.
* @since v0.11.14
*/
@@ -288,7 +288,7 @@ declare module "node:dns" {
*
*
*
- * On error, `err` is an [`Error`](https://nodejs.org/docs/latest-v25.x/api/errors.html#class-error) object,
+ * On error, `err` is an [`Error`](https://nodejs.org/docs/latest-v26.x/api/errors.html#class-error) object,
* where `err.code` is one of the `DNS error codes`.
* @since v0.1.27
* @param hostname Host name to resolve.
@@ -667,8 +667,8 @@ declare module "node:dns" {
* Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an
* array of host names.
*
- * On error, `err` is an [`Error`](https://nodejs.org/docs/latest-v25.x/api/errors.html#class-error) object, where `err.code` is
- * one of the [DNS error codes](https://nodejs.org/docs/latest-v25.x/api/dns.html#error-codes).
+ * On error, `err` is an [`Error`](https://nodejs.org/docs/latest-v26.x/api/errors.html#class-error) object, where `err.code` is
+ * one of the [DNS error codes](https://nodejs.org/docs/latest-v26.x/api/dns.html#error-codes).
* @since v0.1.16
*/
function reverse(
@@ -676,7 +676,7 @@ declare module "node:dns" {
callback: (err: NodeJS.ErrnoException | null, hostnames: string[]) => void,
): void;
/**
- * Get the default value for `order` in {@link lookup} and [`dnsPromises.lookup()`](https://nodejs.org/docs/latest-v25.x/api/dns.html#dnspromiseslookuphostname-options).
+ * Get the default value for `order` in {@link lookup} and [`dnsPromises.lookup()`](https://nodejs.org/docs/latest-v26.x/api/dns.html#dnspromiseslookuphostname-options).
* The value could be:
*
* * `ipv4first`: for `order` defaulting to `ipv4first`.
@@ -731,7 +731,7 @@ declare module "node:dns" {
*/
function getServers(): string[];
/**
- * Set the default value of `order` in {@link lookup} and [`dnsPromises.lookup()`](https://nodejs.org/docs/latest-v25.x/api/dns.html#dnspromiseslookuphostname-options).
+ * Set the default value of `order` in {@link lookup} and [`dnsPromises.lookup()`](https://nodejs.org/docs/latest-v26.x/api/dns.html#dnspromiseslookuphostname-options).
* The value could be:
*
* * `ipv4first`: sets default `order` to `ipv4first`.
@@ -739,8 +739,8 @@ declare module "node:dns" {
* * `verbatim`: sets default `order` to `verbatim`.
*
* The default is `verbatim` and {@link setDefaultResultOrder} have higher
- * priority than [`--dns-result-order`](https://nodejs.org/docs/latest-v25.x/api/cli.html#--dns-result-orderorder). When using
- * [worker threads](https://nodejs.org/docs/latest-v25.x/api/worker_threads.html), {@link setDefaultResultOrder} from the main
+ * priority than [`--dns-result-order`](https://nodejs.org/docs/latest-v26.x/api/cli.html#--dns-result-orderorder). When using
+ * [worker threads](https://nodejs.org/docs/latest-v26.x/api/worker_threads.html), {@link setDefaultResultOrder} from the main
* thread won't affect the default dns orders in workers.
* @since v16.4.0, v14.18.0
* @param order must be `'ipv4first'`, `'ipv6first'` or `'verbatim'`.
@@ -791,7 +791,7 @@ declare module "node:dns" {
* An independent resolver for DNS requests.
*
* Creating a new resolver uses the default server settings. Setting
- * the servers used for a resolver using [`resolver.setServers()`](https://nodejs.org/docs/latest-v25.x/api/dns.html#dnssetserversservers) does not affect
+ * the servers used for a resolver using [`resolver.setServers()`](https://nodejs.org/docs/latest-v26.x/api/dns.html#dnssetserversservers) does not affect
* other resolvers:
*
* ```js
diff --git a/types/node/events.d.ts b/types/node/events.d.ts
index f481a32da68e8f..3191046e5298b3 100644
--- a/types/node/events.d.ts
+++ b/types/node/events.d.ts
@@ -32,7 +32,7 @@ declare module "node:events" {
interface EventEmitterOptions {
/**
* It enables
- * [automatic capturing of promise rejection](https://nodejs.org/docs/latest-v25.x/api/events.html#capture-rejections-of-promises).
+ * [automatic capturing of promise rejection](https://nodejs.org/docs/latest-v26.x/api/events.html#capture-rejections-of-promises).
* @default false
*/
captureRejections?: boolean | undefined;
@@ -445,7 +445,7 @@ declare module "node:events" {
signal?: AbortSignal | undefined;
}
/**
- * See how to write a custom [rejection handler](https://nodejs.org/docs/latest-v25.x/api/events.html#emittersymbolfornodejsrejectionerr-eventname-args).
+ * See how to write a custom [rejection handler](https://nodejs.org/docs/latest-v26.x/api/events.html#emittersymbolfornodejsrejectionerr-eventname-args).
* @since v13.4.0, v12.16.0
*/
const captureRejectionSymbol: unique symbol;
@@ -857,7 +857,7 @@ declare module "node:events" {
/**
* Integrates `EventEmitter` with `AsyncResource` for `EventEmitter`s that
* require manual async tracking. Specifically, all events emitted by instances
- * of `events.EventEmitterAsyncResource` will run within its [async context](https://nodejs.org/docs/latest-v25.x/api/async_context.html).
+ * of `events.EventEmitterAsyncResource` will run within its [async context](https://nodejs.org/docs/latest-v26.x/api/async_context.html).
*
* ```js
* import { EventEmitterAsyncResource, EventEmitter } from 'node:events';
diff --git a/types/node/fs.d.ts b/types/node/fs.d.ts
index 1fce8b85862fd7..ed3219149762f1 100644
--- a/types/node/fs.d.ts
+++ b/types/node/fs.d.ts
@@ -2916,12 +2916,6 @@ declare module "node:fs" {
interface ReadOptionsWithBuffer extends ReadOptions {
buffer?: T | undefined;
}
- /** @deprecated Use `ReadOptions` instead. */
- // TODO: remove in future major
- interface ReadSyncOptions extends ReadOptions {}
- /** @deprecated Use `ReadOptionsWithBuffer` instead. */
- // TODO: remove in future major
- interface ReadAsyncOptions extends ReadOptionsWithBuffer {}
/**
* Read data from the file specified by `fd`.
*
@@ -4675,9 +4669,7 @@ declare module "node:fs" {
* @param dest destination path to copy to.
*/
function cpSync(source: string | URL, destination: string | URL, opts?: CopySyncOptions): void;
-
- // TODO: collapse
- interface _GlobOptions {
+ interface GlobOptions {
/**
* Current working directory.
* @default process.cwd()
@@ -4700,11 +4692,10 @@ declare module "node:fs" {
*/
exclude?: ((fileName: T) => boolean) | readonly string[] | undefined;
}
- interface GlobOptions extends _GlobOptions {}
- interface GlobOptionsWithFileTypes extends _GlobOptions {
+ interface GlobOptionsWithFileTypes extends GlobOptions {
withFileTypes: true;
}
- interface GlobOptionsWithoutFileTypes extends _GlobOptions {
+ interface GlobOptionsWithoutFileTypes extends GlobOptions {
withFileTypes?: false | undefined;
}
diff --git a/types/node/fs/promises.d.ts b/types/node/fs/promises.d.ts
index c9c24215addd70..e17dfdb3ae9288 100644
--- a/types/node/fs/promises.d.ts
+++ b/types/node/fs/promises.d.ts
@@ -256,9 +256,9 @@ declare module "node:fs/promises" {
datasync(): Promise;
/**
* Return the file contents as an async iterable using the
- * [`node:stream/iter`](https://nodejs.org/docs/latest-v25.x/api/stream_iter.html) pull model. Reads are performed in `chunkSize`-byte
+ * [`node:stream/iter`](https://nodejs.org/docs/latest-v26.x/api/stream_iter.html) pull model. Reads are performed in `chunkSize`-byte
* chunks (default 128 KB). If transforms are provided, they are applied
- * via [`stream/iter pull()`](https://nodejs.org/docs/latest-v25.x/api/stream_iter.html#pullsource-transforms-options).
+ * via [`stream/iter pull()`](https://nodejs.org/docs/latest-v26.x/api/stream_iter.html#pullsource-transforms-options).
*
* The file handle is locked while the iterable is being consumed and unlocked
* when iteration completes, an error occurs, or the consumer breaks.
@@ -538,7 +538,7 @@ declare module "node:fs/promises" {
position?: number,
): Promise>;
/**
- * Return a [`node:stream/iter`](https://nodejs.org/docs/latest-v25.x/api/stream_iter.html) writer backed by this file handle.
+ * Return a [`node:stream/iter`](https://nodejs.org/docs/latest-v26.x/api/stream_iter.html) writer backed by this file handle.
*
* The writer supports both `Symbol.asyncDispose` and `Symbol.dispose`:
*
@@ -548,7 +548,7 @@ declare module "node:fs/promises" {
* * `using w = fh.writer()` — calls `fail()` unconditionally.
*
* The `writeSync()` and `writevSync()` methods enable the try-sync fast path
- * used by [`stream/iter pipeTo()`](https://nodejs.org/docs/latest-v25.x/api/stream_iter.html#pipetosource-transforms-writer). When the reader's chunk size matches the
+ * used by [`stream/iter pipeTo()`](https://nodejs.org/docs/latest-v26.x/api/stream_iter.html#pipetosource-transforms-writer). When the reader's chunk size matches the
* writer's `chunkSize`, all writes in a `pipeTo()` pipeline complete
* synchronously with zero promise overhead.
*
diff --git a/types/node/globals.d.ts b/types/node/globals.d.ts
index 36e7f90cf1aebe..0c2f0b09ebbea9 100644
--- a/types/node/globals.d.ts
+++ b/types/node/globals.d.ts
@@ -98,10 +98,10 @@ declare namespace NodeJS {
}
interface ErrnoException extends Error {
- errno?: number | undefined;
- code?: string | undefined;
- path?: string | undefined;
- syscall?: string | undefined;
+ errno?: number;
+ code?: string;
+ path?: string;
+ syscall?: string;
}
interface RefCounted {
diff --git a/types/node/http.d.ts b/types/node/http.d.ts
index c2e00e7c2fce77..71523152e2b13b 100644
--- a/types/node/http.d.ts
+++ b/types/node/http.d.ts
@@ -341,7 +341,7 @@ declare module "node:http" {
"connection": [socket: net.Socket];
"dropRequest": [request: InstanceType, socket: stream.Duplex];
"request": Parameters>;
- "upgrade": [req: InstanceType, socket: stream.Duplex, head: NonSharedBuffer];
+ "upgrade": [req: InstanceType, stream: stream.Duplex, head: NonSharedBuffer];
}
/**
* @since v0.1.17
@@ -947,7 +947,7 @@ declare module "node:http" {
"response": [response: IncomingMessage];
"socket": [socket: net.Socket];
"timeout": [];
- "upgrade": [response: IncomingMessage, socket: net.Socket, head: NonSharedBuffer];
+ "upgrade": [response: IncomingMessage, stream: net.Socket, head: NonSharedBuffer];
}
/**
* This object is created internally and returned from {@link request}. It
@@ -1502,7 +1502,7 @@ declare module "node:http" {
scheduling?: "fifo" | "lifo" | undefined;
/**
* Environment variables for proxy configuration. See
- * [Built-in Proxy Support](https://nodejs.org/docs/latest-v25.x/api/http.html#built-in-proxy-support) for details.
+ * [Built-in Proxy Support](https://nodejs.org/docs/latest-v26.x/api/http.html#built-in-proxy-support) for details.
* @since v24.5.0
*/
proxyEnv?: ProxyEnv | undefined;
@@ -1571,7 +1571,7 @@ declare module "node:http" {
* });
* ```
*
- * `options` in [`socket.connect()`](https://nodejs.org/docs/latest-v25.x/api/net.html#socketconnectoptions-connectlistener) are also supported.
+ * `options` in [`socket.connect()`](https://nodejs.org/docs/latest-v26.x/api/net.html#socketconnectoptions-connectlistener) are also supported.
*
* To configure any of them, a custom {@link Agent} instance must be created.
*
@@ -2106,7 +2106,7 @@ declare module "node:http" {
* overridden after this function is invoked. It's recommended to invoke it before any
* requests are made and avoid invoking it in the middle of any requests.
*
- * See [Built-in Proxy Support](https://nodejs.org/docs/latest-v25.x/api/http.html#built-in-proxy-support) for details on proxy URL formats and `NO_PROXY`
+ * See [Built-in Proxy Support](https://nodejs.org/docs/latest-v26.x/api/http.html#built-in-proxy-support) for details on proxy URL formats and `NO_PROXY`
* syntax.
* @since v25.4.0
* @param proxyEnv An object containing proxy configuration. This accepts the
diff --git a/types/node/http2.d.ts b/types/node/http2.d.ts
index a026ef506e2fce..3ac20907f336f1 100644
--- a/types/node/http2.d.ts
+++ b/types/node/http2.d.ts
@@ -1760,7 +1760,7 @@ declare module "node:http2" {
* If there were no previous values for the header, this is equivalent to calling {@link setHeader}.
*
* Attempting to set a header field name or value that contains invalid characters will result in a
- * [TypeError](https://nodejs.org/docs/latest-v25.x/api/errors.html#class-typeerror) being thrown.
+ * [TypeError](https://nodejs.org/docs/latest-v26.x/api/errors.html#class-typeerror) being thrown.
*
* ```js
* // Returns headers including "set-cookie: a" and "set-cookie: b"
diff --git a/types/node/index.d.ts b/types/node/index.d.ts
index 14dd60bcb7e98a..3986214a90a2c6 100644
--- a/types/node/index.d.ts
+++ b/types/node/index.d.ts
@@ -29,9 +29,6 @@
///
///
-// Iterator definitions required for compatibility with TypeScript <5.6:
-///
-
// Definitions for Node.js modules specific to TypeScript 5.7+:
///
///
diff --git a/types/node/inspector.d.ts b/types/node/inspector.d.ts
index cf385b76dc1587..ae86f81cd51ba4 100644
--- a/types/node/inspector.d.ts
+++ b/types/node/inspector.d.ts
@@ -34,7 +34,7 @@ declare module "node:inspector" {
* If wait is `true`, will block until a client has connected to the inspect port
* and flow control has been passed to the debugger client.
*
- * See the [security warning](https://nodejs.org/docs/latest-v25.x/api/cli.html#warning-binding-inspector-to-a-public-ipport-combination-is-insecure)
+ * See the [security warning](https://nodejs.org/docs/latest-v26.x/api/cli.html#warning-binding-inspector-to-a-public-ipport-combination-is-insecure)
* regarding the `host` parameter usage.
* @param port Port to listen on for inspector connections. Defaults to what was specified on the CLI.
* @param host Host to listen on for inspector connections. Defaults to what was specified on the CLI.
diff --git a/types/node/module.d.ts b/types/node/module.d.ts
index ae6c32988d9da3..792a0bd5def128 100644
--- a/types/node/module.d.ts
+++ b/types/node/module.d.ts
@@ -27,7 +27,7 @@ declare module "node:module" {
/**
* The following constants are returned as the `status` field in the object returned by
* {@link enableCompileCache} to indicate the result of the attempt to enable the
- * [module compile cache](https://nodejs.org/docs/latest-v25.x/api/module.html#module-compile-cache).
+ * [module compile cache](https://nodejs.org/docs/latest-v26.x/api/module.html#module-compile-cache).
* @since v22.8.0
*/
namespace compileCacheStatus {
@@ -96,7 +96,7 @@ declare module "node:module" {
directory?: string;
}
/**
- * Enable [module compile cache](https://nodejs.org/docs/latest-v25.x/api/module.html#module-compile-cache)
+ * Enable [module compile cache](https://nodejs.org/docs/latest-v26.x/api/module.html#module-compile-cache)
* in the current Node.js instance.
*
* For general use cases, it's recommended to call `module.enableCompileCache()` without
@@ -110,7 +110,7 @@ declare module "node:module" {
* returned object contains the path to the directory where the compile cache is stored. The
* `status` field in the returned object would be one of the `module.constants.compileCacheStatus`
* values to indicate the result of the attempt to enable the
- * [module compile cache](https://nodejs.org/docs/latest-v25.x/api/module.html#module-compile-cache).
+ * [module compile cache](https://nodejs.org/docs/latest-v26.x/api/module.html#module-compile-cache).
*
* This method only affects the current Node.js instance. To enable it in child worker threads,
* either call this method in child worker threads too, or set the
@@ -122,7 +122,7 @@ declare module "node:module" {
*/
function enableCompileCache(options?: string | EnableCompileCacheOptions): EnableCompileCacheResult;
/**
- * Flush the [module compile cache](https://nodejs.org/docs/latest-v25.x/api/module.html#module-compile-cache)
+ * Flush the [module compile cache](https://nodejs.org/docs/latest-v26.x/api/module.html#module-compile-cache)
* accumulated from modules already loaded
* in the current Node.js instance to disk. This returns after all the flushing
* file system operations come to an end, no matter they succeed or not. If there
@@ -133,7 +133,7 @@ declare module "node:module" {
function flushCompileCache(): void;
/**
* @since v22.8.0
- * @return Path to the [module compile cache](https://nodejs.org/docs/latest-v25.x/api/module.html#module-compile-cache)
+ * @return Path to the [module compile cache](https://nodejs.org/docs/latest-v26.x/api/module.html#module-compile-cache)
* directory if it is enabled, or `undefined` otherwise.
*/
function getCompileCacheDir(): string | undefined;
@@ -204,7 +204,7 @@ declare module "node:module" {
*/
data?: Data | undefined;
/**
- * [Transferable objects](https://nodejs.org/docs/latest-v25.x/api/worker_threads.html#portpostmessagevalue-transferlist)
+ * [Transferable objects](https://nodejs.org/docs/latest-v26.x/api/worker_threads.html#portpostmessagevalue-transferlist)
* to be passed into the `initialize` hook.
*/
transferList?: any[] | undefined;
@@ -213,10 +213,10 @@ declare module "node:module" {
/**
* Register a module that exports hooks that customize Node.js module
* resolution and loading behavior. See
- * [Customization hooks](https://nodejs.org/docs/latest-v25.x/api/module.html#customization-hooks).
+ * [Customization hooks](https://nodejs.org/docs/latest-v26.x/api/module.html#customization-hooks).
*
* This feature requires `--allow-worker` if used with the
- * [Permission Model](https://nodejs.org/docs/latest-v25.x/api/permissions.html#permission-model).
+ * [Permission Model](https://nodejs.org/docs/latest-v26.x/api/permissions.html#permission-model).
* @since v20.6.0, v18.19.0
* @deprecated Use `module.registerHooks()` instead.
* @param specifier Customization hooks to be registered; this should be
@@ -233,12 +233,12 @@ declare module "node:module" {
function register(specifier: string | URL, options?: RegisterOptions): void;
interface RegisterHooksOptions {
/**
- * See [load hook](https://nodejs.org/docs/latest-v25.x/api/module.html#loadurl-context-nextload).
+ * See [load hook](https://nodejs.org/docs/latest-v26.x/api/module.html#loadurl-context-nextload).
* @default undefined
*/
load?: LoadHookSync | undefined;
/**
- * See [resolve hook](https://nodejs.org/docs/latest-v25.x/api/module.html#resolvespecifier-context-nextresolve).
+ * See [resolve hook](https://nodejs.org/docs/latest-v26.x/api/module.html#resolvespecifier-context-nextresolve).
* @default undefined
*/
resolve?: ResolveHookSync | undefined;
@@ -250,7 +250,7 @@ declare module "node:module" {
deregister(): void;
}
/**
- * Register [hooks](https://nodejs.org/docs/latest-v25.x/api/module.html#customization-hooks)
+ * Register [hooks](https://nodejs.org/docs/latest-v26.x/api/module.html#customization-hooks)
* that customize Node.js module resolution and loading behavior.
* @since v22.15.0
* @experimental
@@ -260,16 +260,9 @@ declare module "node:module" {
/**
* Possible values are:
* * `'strip'` Only strip type annotations without performing the transformation of TypeScript features.
- * * `'transform'` Strip type annotations and transform TypeScript features to JavaScript.
* @default 'strip'
*/
- mode?: "strip" | "transform" | undefined;
- /**
- * Only when `mode` is `'transform'`, if `true`, a source map
- * will be generated for the transformed code.
- * @default false
- */
- sourceMap?: boolean | undefined;
+ mode?: "strip" | undefined;
/**
* Specifies the source url used in the source map.
*/
@@ -279,13 +272,9 @@ declare module "node:module" {
* `module.stripTypeScriptTypes()` removes type annotations from TypeScript code. It
* can be used to strip type annotations from TypeScript code before running it
* with `vm.runInContext()` or `vm.compileFunction()`.
+ *
* By default, it will throw an error if the code contains TypeScript features
- * that require transformation such as `Enums`,
- * see [type-stripping](https://nodejs.org/docs/latest-v25.x/api/typescript.md#type-stripping) for more information.
- * When mode is `'transform'`, it also transforms TypeScript features to JavaScript,
- * see [transform TypeScript features](https://nodejs.org/docs/latest-v25.x/api/typescript.md#typescript-features) for more information.
- * When mode is `'strip'`, source maps are not generated, because locations are preserved.
- * If `sourceMap` is provided, when mode is `'strip'`, an error will be thrown.
+ * that require transformation, such as `enum`s. See [type-stripping](https://nodejs.org/docs/latest-v26.x/api/typescript.md#type-stripping) for more information.
*
* _WARNING_: The output of this function should not be considered stable across Node.js versions,
* due to changes in the TypeScript parser.
@@ -307,24 +296,6 @@ declare module "node:module" {
* console.log(strippedCode);
* // Prints: const a = 1\n\n//# sourceURL=source.ts;
* ```
- *
- * When `mode` is `'transform'`, the code is transformed to JavaScript:
- *
- * ```js
- * import { stripTypeScriptTypes } from 'node:module';
- * const code = `
- * namespace MathUtil {
- * export const add = (a: number, b: number) => a + b;
- * }`;
- * const strippedCode = stripTypeScriptTypes(code, { mode: 'transform', sourceMap: true });
- * console.log(strippedCode);
- * // Prints:
- * // var MathUtil;
- * // (function(MathUtil) {
- * // MathUtil.add = (a, b)=>a + b;
- * // })(MathUtil || (MathUtil = {}));
- * // # sourceMappingURL=data:application/json;base64, ...
- * ```
* @since v22.13.0
* @param code The code to strip type annotations from.
* @returns The code with type annotations stripped.
@@ -645,7 +616,7 @@ declare module "node:module" {
* Modules are cached in this object when they are required. By deleting a key
* value from this object, the next `require` will reload the module.
* This does not apply to
- * [native addons](https://nodejs.org/docs/latest-v25.x/api/addons.html),
+ * [native addons](https://nodejs.org/docs/latest-v26.x/api/addons.html),
* for which reloading will result in an error.
* @since v0.3.0
*/
@@ -679,7 +650,7 @@ declare module "node:module" {
* Paths to resolve module location from. If present, these
* paths are used instead of the default resolution paths, with the exception
* of
- * [GLOBAL\_FOLDERS](https://nodejs.org/docs/latest-v25.x/api/modules.html#loading-from-the-global-folders)
+ * [GLOBAL\_FOLDERS](https://nodejs.org/docs/latest-v26.x/api/modules.html#loading-from-the-global-folders)
* like `$HOME/.node_modules`, which are
* always included. Each of these paths is used as a starting point for
* the module resolution algorithm, meaning that the `node_modules` hierarchy
diff --git a/types/node/net.d.ts b/types/node/net.d.ts
index bb6d3a3930a956..8650981d49da91 100644
--- a/types/node/net.d.ts
+++ b/types/node/net.d.ts
@@ -488,7 +488,7 @@ declare module "node:net" {
keepAliveInitialDelay?: number | undefined;
/**
* Optionally overrides all `net.Socket`s' `readableHighWaterMark` and `writableHighWaterMark`.
- * @default See [stream.getDefaultHighWaterMark()](https://nodejs.org/docs/latest-v25.x/api/stream.html#streamgetdefaulthighwatermarkobjectmode).
+ * @default See [stream.getDefaultHighWaterMark()](https://nodejs.org/docs/latest-v26.x/api/stream.html#streamgetdefaulthighwatermarkobjectmode).
* @since v18.17.0, v20.1.0
*/
highWaterMark?: number | undefined;
diff --git a/types/node/node-tests/assert.ts b/types/node/node-tests/assert.ts
index ed69e458ecd6fd..2c9cb453b12f24 100644
--- a/types/node/node-tests/assert.ts
+++ b/types/node/node-tests/assert.ts
@@ -108,6 +108,49 @@ assert.throws(
assert.partialDeepStrictEqual({ a: 1, b: 2, c: 3 }, { a: 1, b: 2 });
+// Printf-style messages (v26.0.0+)
+{
+ const apples = 1;
+ const oranges = 2;
+
+ // Printf-style format string with substitution arguments
+ assert.strictEqual(apples, oranges, "apples %d !== oranges %d", apples, oranges);
+ assert.ok(true, "value is %s", "truthy");
+ assert.equal(1, 1, "values %d and %d are equal", 1, 1);
+ assert.notEqual(1, 2, "values %d and %d differ", 1, 2);
+ assert.deepEqual({ a: 1 }, { a: 1 }, "objects are %s equal", "deeply");
+ assert.notDeepEqual({ a: 1 }, { a: 2 }, "objects %s", "differ");
+ assert.deepStrictEqual({ a: 1 }, { a: 1 }, "strict deep %s", "equal");
+ assert.notDeepStrictEqual({ a: 1 }, { a: 2 }, "not %s equal", "strictly");
+ assert.notStrictEqual(1, 2, "values %d and %d are not strictly equal", 1, 2);
+ assert.match("test", /test/, "string %s matches", "test");
+ assert.doesNotMatch("test", /xyz/, "string %s does not match %s", "test", "xyz");
+ assert.partialDeepStrictEqual({ a: 1, b: 2 }, { a: 1 }, "partial match %s", "ok");
+
+ // Function-based messages (called only on failure)
+ assert.strictEqual(apples, oranges, (actual, expected) => `expected ${expected} but got ${actual}`);
+ assert.ok(true, (actual, expected) => `failed: ${actual}`);
+ assert.equal(1, 1, (actual, expected) => `${actual} != ${expected}`);
+ assert.deepStrictEqual({ a: 1 }, { a: 1 }, (actual, expected) => `mismatch`);
+
+ // Top-level assert with printf-style
+ assert(true, "value is %s", "truthy");
+ assert(true, (actual, expected) => `failed`);
+}
+
+// Printf-style extras only permitted with string message (v26.0.0+)
+{
+ // OK: printf-style with string message
+ assert.strictEqual(1, 2, "got %s expected %s", "ONE", "TWO");
+ // OK: plain string message, no extras
+ assert.strictEqual(1, 2, "plain");
+
+ // @ts-expect-error extras not allowed with Error message
+ assert.strictEqual(1, 2, new Error("boom"), "extra");
+ // @ts-expect-error extras not allowed with function message
+ assert.strictEqual(1, 2, (a, b) => `${String(a)}/${String(b)}`, "extra");
+}
+
// Test assert predicates
{
let a!: Error | null;
diff --git a/types/node/node-tests/child_process.ts b/types/node/node-tests/child_process.ts
index 3808b217342e11..9e9fede65b9610 100644
--- a/types/node/node-tests/child_process.ts
+++ b/types/node/node-tests/child_process.ts
@@ -212,7 +212,7 @@ import { promisify } from "node:util";
childProcess.execFile(
cmd,
(error, stdout, stderr) => {
- // $ExpectType ExecFileException | null
+ // $ExpectType ExecException | null
error;
// $ExpectType string
stdout;
@@ -230,7 +230,7 @@ import { promisify } from "node:util";
cmd,
args,
(error, stdout, stderr) => {
- // $ExpectType ExecFileException | null
+ // $ExpectType ExecException | null
error;
// $ExpectType string
stdout;
@@ -247,7 +247,7 @@ import { promisify } from "node:util";
cmd,
{},
(error, stdout, stderr) => {
- // $ExpectType ExecFileException | null
+ // $ExpectType ExecException | null
error;
// $ExpectType string
stdout;
@@ -263,7 +263,7 @@ import { promisify } from "node:util";
args,
{},
(error, stdout, stderr) => {
- // $ExpectType ExecFileException | null
+ // $ExpectType ExecException | null
error;
// $ExpectType string
stdout;
@@ -286,7 +286,7 @@ import { promisify } from "node:util";
signal: new AbortSignal(),
},
(error, stdout, stderr) => {
- // $ExpectType ExecFileException | null
+ // $ExpectType ExecException | null
error;
// $ExpectType string
stdout;
@@ -317,7 +317,7 @@ import { promisify } from "node:util";
signal: new AbortSignal(),
},
(error, stdout, stderr) => {
- // $ExpectType ExecFileException | null
+ // $ExpectType ExecException | null
error;
// $ExpectType string
stdout;
@@ -344,7 +344,7 @@ import { promisify } from "node:util";
cmd,
{ encoding: boolFlag ? "buffer" : null },
(error, stdout, stderr) => {
- // $ExpectType ExecFileException | null
+ // $ExpectType ExecException | null
error;
// $ExpectType NonSharedBuffer
stdout;
@@ -360,7 +360,7 @@ import { promisify } from "node:util";
args,
{ encoding: boolFlag ? "buffer" : null },
(error, stdout, stderr) => {
- // $ExpectType ExecFileException | null
+ // $ExpectType ExecException | null
error;
// $ExpectType NonSharedBuffer
stdout;
@@ -378,7 +378,7 @@ import { promisify } from "node:util";
args,
{ encoding: "utf16le" },
(error, stdout, stderr) => {
- // $ExpectType ExecFileException | null
+ // $ExpectType ExecException | null
error;
// $ExpectType string
stdout;
@@ -394,7 +394,7 @@ import { promisify } from "node:util";
args,
{ encoding: "utf16le" },
(error, stdout, stderr) => {
- // $ExpectType ExecFileException | null
+ // $ExpectType ExecException | null
error;
// $ExpectType string
stdout;
@@ -411,7 +411,7 @@ import { promisify } from "node:util";
cmd,
{ encoding: "unknown" },
(error, stdout, stderr) => {
- // $ExpectType ExecFileException | null
+ // $ExpectType ExecException | null
error;
// $ExpectType string | NonSharedBuffer
stdout;
@@ -427,7 +427,7 @@ import { promisify } from "node:util";
args,
{ encoding: "unknown" },
(error, stdout, stderr) => {
- // $ExpectType ExecFileException | null
+ // $ExpectType ExecException | null
error;
// $ExpectType string | NonSharedBuffer
stdout;
@@ -444,7 +444,7 @@ import { promisify } from "node:util";
cmd,
boolFlag ? { encoding: "unknown" } : null,
(error, stdout, stderr) => {
- // $ExpectType ExecFileException | null
+ // $ExpectType ExecException | null
error;
// $ExpectType string | NonSharedBuffer
stdout;
@@ -460,7 +460,7 @@ import { promisify } from "node:util";
args,
boolFlag ? { encoding: "unknown" } : null,
(error, stdout, stderr) => {
- // $ExpectType ExecFileException | null
+ // $ExpectType ExecException | null
error;
// $ExpectType string | NonSharedBuffer
stdout;
diff --git a/types/node/node-tests/crypto.ts b/types/node/node-tests/crypto.ts
index a56c619cadbf1e..1d41674c320804 100644
--- a/types/node/node-tests/crypto.ts
+++ b/types/node/node-tests/crypto.ts
@@ -217,7 +217,7 @@ import { promisify } from "node:util";
}
{
- let key: crypto.CipherKey = "" as crypto.CipherKey;
+ let key: crypto.KeyLike = "" as crypto.KeyLike;
let iv: crypto.BinaryLike = "" as crypto.BinaryLike;
{
let cipher = crypto.createCipheriv("aes-128-ccm", key, iv, { authTagLength: 16 });
@@ -301,7 +301,7 @@ import { promisify } from "node:util";
}
{
- let key: crypto.CipherKey = "" as crypto.CipherKey;
+ let key: crypto.KeyLike = "" as crypto.KeyLike;
let iv: crypto.BinaryLike = "" as crypto.BinaryLike;
{
let cipher = crypto.createDecipheriv("aes-128-ccm", key, iv, { authTagLength: 16 });
@@ -1171,7 +1171,7 @@ import { promisify } from "node:util";
format: "der",
});
crypto.createPrivateKey({
- key: "asd",
+ key: {},
format: "jwk",
});
}
@@ -1298,62 +1298,6 @@ import { promisify } from "node:util";
crypto.hash("shake256", "Node.js", { outputEncoding: "buffer", outputLength: 256 });
}
-{
- // crypto_constants_test
- let num: number;
- let str: string;
-
- num = crypto.constants.OPENSSL_VERSION_NUMBER;
- num = crypto.constants.SSL_OP_ALL;
- num = crypto.constants.SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION;
- num = crypto.constants.SSL_OP_CIPHER_SERVER_PREFERENCE;
- num = crypto.constants.SSL_OP_CISCO_ANYCONNECT;
- num = crypto.constants.SSL_OP_COOKIE_EXCHANGE;
- num = crypto.constants.SSL_OP_CRYPTOPRO_TLSEXT_BUG;
- num = crypto.constants.SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS;
- num = crypto.constants.SSL_OP_LEGACY_SERVER_CONNECT;
- num = crypto.constants.SSL_OP_NO_COMPRESSION;
- num = crypto.constants.SSL_OP_NO_QUERY_MTU;
- num = crypto.constants.SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION;
- num = crypto.constants.SSL_OP_NO_SSLv2;
- num = crypto.constants.SSL_OP_NO_SSLv3;
- num = crypto.constants.SSL_OP_NO_TICKET;
- num = crypto.constants.SSL_OP_NO_TLSv1;
- num = crypto.constants.SSL_OP_NO_TLSv1_1;
- num = crypto.constants.SSL_OP_NO_TLSv1_2;
- num = crypto.constants.SSL_OP_TLS_ROLLBACK_BUG;
- num = crypto.constants.ENGINE_METHOD_RSA;
- num = crypto.constants.ENGINE_METHOD_DSA;
- num = crypto.constants.ENGINE_METHOD_DH;
- num = crypto.constants.ENGINE_METHOD_RAND;
- num = crypto.constants.ENGINE_METHOD_EC;
- num = crypto.constants.ENGINE_METHOD_CIPHERS;
- num = crypto.constants.ENGINE_METHOD_DIGESTS;
- num = crypto.constants.ENGINE_METHOD_PKEY_METHS;
- num = crypto.constants.ENGINE_METHOD_PKEY_ASN1_METHS;
- num = crypto.constants.ENGINE_METHOD_ALL;
- num = crypto.constants.ENGINE_METHOD_NONE;
- num = crypto.constants.DH_CHECK_P_NOT_SAFE_PRIME;
- num = crypto.constants.DH_CHECK_P_NOT_PRIME;
- num = crypto.constants.DH_UNABLE_TO_CHECK_GENERATOR;
- num = crypto.constants.DH_NOT_SUITABLE_GENERATOR;
- num = crypto.constants.RSA_PKCS1_PADDING;
- num = crypto.constants.RSA_SSLV23_PADDING;
- num = crypto.constants.RSA_NO_PADDING;
- num = crypto.constants.RSA_PKCS1_OAEP_PADDING;
- num = crypto.constants.RSA_X931_PADDING;
- num = crypto.constants.RSA_PKCS1_PSS_PADDING;
- num = crypto.constants.RSA_PSS_SALTLEN_DIGEST;
- num = crypto.constants.RSA_PSS_SALTLEN_MAX_SIGN;
- num = crypto.constants.RSA_PSS_SALTLEN_AUTO;
- num = crypto.constants.POINT_CONVERSION_COMPRESSED;
- num = crypto.constants.POINT_CONVERSION_UNCOMPRESSED;
- num = crypto.constants.POINT_CONVERSION_HYBRID;
-
- str = crypto.constants.defaultCoreCipherList;
- str = crypto.constants.defaultCipherList;
-}
-
{
const sig: Buffer = crypto.sign("md5", Buffer.from(""), "mykey");
@@ -1445,7 +1389,7 @@ import { promisify } from "node:util";
dsaEncoding: "der",
});
- crypto.sign("slh-dsa-sha2-128s", Buffer.from("asd"), { key, context: Uint8Array.of(1, 2, 3, 4).buffer });
+ crypto.sign("slh-dsa-sha2-128s", Buffer.from("asd"), { key, context: Uint8Array.of(1, 2, 3, 4) });
}
{
@@ -1756,9 +1700,6 @@ import { promisify } from "node:util";
}
{
- crypto.DiffieHellmanGroup("modp14");
- new crypto.DiffieHellmanGroup("modp14");
-
const alice: crypto.DiffieHellmanGroup = crypto.getDiffieHellman("modp14");
const bob: crypto.DiffieHellmanGroup = crypto.createDiffieHellmanGroup("modp14");
@@ -1810,7 +1751,7 @@ import { promisify } from "node:util";
let aliceSecret = alice.computeSecret(bobPublicKey, "hex"); // $ExpectType NonSharedBuffer
aliceSecret = alice.computeSecret(Buffer.from(bobPublicKey, "hex"));
- let bobSecret = bob.computeSecret(alicePublicKey, "hex"); // $ExpectType string
+ let bobSecret = bob.computeSecret(alicePublicKey, null, "hex"); // $ExpectType string
bobSecret = bob.computeSecret(alicePublicKey.toString("hex"), "hex", "hex");
aliceSecret.toString("hex") === bobSecret;
@@ -1942,3 +1883,48 @@ import { promisify } from "node:util";
const publicKey = crypto.decapsulate(privateKey, Buffer.from("the quick brown fox jumped over the lazy dog"));
const { sharedKey, ciphertext } = crypto.encapsulate(publicKey);
}
+
+// Raw key format export/import (v26.0.0+)
+{
+ const { publicKey, privateKey } = crypto.generateKeyPairSync("ed25519");
+
+ // Export with raw formats
+ const rawPublic = publicKey.export({ format: "raw-public" });
+ rawPublic; // $ExpectType NonSharedBuffer
+ const rawPrivate = privateKey.export({ format: "raw-private" });
+ rawPrivate; // $ExpectType NonSharedBuffer
+ const rawSeed = privateKey.export({ format: "raw-seed" });
+ rawSeed; // $ExpectType NonSharedBuffer
+
+ // Import with raw formats
+ const importedPublic = crypto.createPublicKey({
+ key: rawPublic,
+ format: "raw-public",
+ asymmetricKeyType: "ed25519",
+ });
+ const importedPrivate = crypto.createPrivateKey({
+ key: rawPrivate,
+ format: "raw-private",
+ asymmetricKeyType: "ed25519",
+ });
+
+ // @ts-expect-error
+ crypto.createPublicKey({ key: rawPrivate, format: "raw-private" });
+ // @ts-expect-error
+ crypto.createPrivateKey({ key: rawPublic, format: "raw-public" });
+}
+
+// Raw key formats in generateKeyPair (v26.0.0+)
+{
+ const ed = crypto.generateKeyPairSync("ed25519", {
+ publicKeyEncoding: { format: "raw-public" },
+ privateKeyEncoding: { format: "raw-private" },
+ });
+ ed.publicKey; // $ExpectType NonSharedBuffer
+ ed.privateKey; // $ExpectType NonSharedBuffer
+
+ const pq = crypto.generateKeyPairSync("ml-dsa-44", {
+ privateKeyEncoding: { format: "raw-seed" },
+ });
+ pq.privateKey; // $ExpectType NonSharedBuffer
+}
diff --git a/types/node/node-tests/globals.ts b/types/node/node-tests/globals.ts
index 561e4b56ea2841..793956563b4ced 100644
--- a/types/node/node-tests/globals.ts
+++ b/types/node/node-tests/globals.ts
@@ -82,6 +82,14 @@ declare var RANDOM_GLOBAL_VARIABLE: true;
e.name; // $ExpectType string
}
+{
+ const e = new QuotaExceededError();
+ e.message; // $ExpectType string
+ e.name; // $ExpectType string
+ e.quota; // $ExpectType number | null
+ e.requested; // $ExpectType number | null
+}
+
{
navigator.hardwareConcurrency; // $ExpectType number
navigator.language; // $ExpectType string
diff --git a/types/node/node-tests/process.ts b/types/node/node-tests/process.ts
index 1fbbc00268f651..723d749fa4b528 100644
--- a/types/node/node-tests/process.ts
+++ b/types/node/node-tests/process.ts
@@ -50,12 +50,15 @@ import { fileURLToPath } from "node:url";
const stdErrorFd = process.stderr.fd;
}
{
- function myCb(err: Error): void {
- }
- process.setUncaughtExceptionCaptureCallback(myCb);
+ process.setUncaughtExceptionCaptureCallback((err) => {
+ err; // $ExpectType unknown
+ });
process.setUncaughtExceptionCaptureCallback(null);
- process.addUncaughtExceptionCaptureCallback((err) => true);
- const b: boolean = process.hasUncaughtExceptionCaptureCallback();
+ process.addUncaughtExceptionCaptureCallback((err) => {
+ err; // $ExpectType unknown
+ return true;
+ });
+ process.hasUncaughtExceptionCaptureCallback(); // $ExpectType boolean
}
{
diff --git a/types/node/node-tests/readline.ts b/types/node/node-tests/readline.ts
index 9744536d0020f2..4e7affd5270b63 100644
--- a/types/node/node-tests/readline.ts
+++ b/types/node/node-tests/readline.ts
@@ -2,7 +2,7 @@ import * as readline from "node:readline";
import * as readlinePromises from "node:readline/promises";
import * as stream from "node:stream";
-const rl: readline.ReadLine = readline.createInterface(new stream.Readable());
+const rl: readline.Interface = readline.createInterface(new stream.Readable());
{
const input: NodeJS.ReadableStream = new stream.Readable();
@@ -20,7 +20,7 @@ const rl: readline.ReadLine = readline.createInterface(new stream.Readable());
};
const terminal = false;
- let result: readline.ReadLine;
+ let result: readline.Interface;
result = readline.createInterface(input);
result = readline.createInterface(input, output);
@@ -46,35 +46,22 @@ const rl: readline.ReadLine = readline.createInterface(new stream.Readable());
{
rl.setPrompt("prompt");
-}
-{
rl.prompt();
rl.prompt(true);
-}
-{
rl.getPrompt(); // $ExpectType string
-}
-{
rl.question("query", (answer: string) => {});
rl.question("query", { signal: new AbortSignal() }, (answer: string) => {});
}
{
- let result: readline.ReadLine;
+ let result: readline.Interface;
result = rl.pause();
-}
-
-{
- let result: readline.ReadLine;
-
result = rl.resume();
-}
-{
rl.close();
}
@@ -122,7 +109,7 @@ const rl: readline.ReadLine = readline.createInterface(new stream.Readable());
{
const strm: NodeJS.ReadableStream = new stream.Readable();
- const readLineInterface: readline.ReadLine = readline.createInterface(new stream.Readable());
+ const readLineInterface: readline.Interface = readline.createInterface(new stream.Readable());
readline.emitKeypressEvents(strm);
readline.emitKeypressEvents(strm, readLineInterface);
@@ -281,17 +268,11 @@ const readlineInstance = new readlinePromises.Readline(new stream.Writable());
readlineInstance.clearLine(1); // $ExpectType Readline
readlineInstance.clearLine(0); // $ExpectType Readline
readlineInstance.clearLine(-1); // $ExpectType Readline
-}
-{
readlineInstance.clearScreenDown(); // $ExpectType Readline
-}
-{
readlineInstance.commit(); // $ExpectType Promise
-}
-{
// @ts-expect-error
readlineInstance.cursorTo();
// @ts-expect-error
@@ -299,9 +280,7 @@ const readlineInstance = new readlinePromises.Readline(new stream.Writable());
readlineInstance.cursorTo(1); // $ExpectType Readline
readlineInstance.cursorTo(1, 2); // $ExpectType Readline
-}
-{
// @ts-expect-error
readlineInstance.moveCursor();
// @ts-expect-error
@@ -310,9 +289,7 @@ const readlineInstance = new readlinePromises.Readline(new stream.Writable());
readlineInstance.moveCursor("bad");
readlineInstance.moveCursor(0, 1); // $ExpectType Readline
-}
-{
readlineInstance.rollback(); // $ExpectType Readline
}
diff --git a/types/node/os.d.ts b/types/node/os.d.ts
index 562c463ba1201a..ad2413a82e8a87 100644
--- a/types/node/os.d.ts
+++ b/types/node/os.d.ts
@@ -242,7 +242,7 @@ declare module "node:os" {
* environment variables for the home directory before falling back to the
* operating system response.
*
- * Throws a [`SystemError`](https://nodejs.org/docs/latest-v25.x/api/errors.html#class-systemerror) if a user has no `username` or `homedir`.
+ * Throws a [`SystemError`](https://nodejs.org/docs/latest-v26.x/api/errors.html#class-systemerror) if a user has no `username` or `homedir`.
* @since v6.0.0
*/
function userInfo(options?: UserInfoOptionsWithStringEncoding): UserInfo;
@@ -422,7 +422,7 @@ declare module "node:os" {
* compiled. Possible values are `'arm'`, `'arm64'`, `'ia32'`, `'loong64'`,
* `'mips'`, `'mipsel'`, `'ppc64'`, `'riscv64'`, `'s390x'`, and `'x64'`.
*
- * The return value is equivalent to [process.arch](https://nodejs.org/docs/latest-v25.x/api/process.html#processarch).
+ * The return value is equivalent to [process.arch](https://nodejs.org/docs/latest-v26.x/api/process.html#processarch).
* @since v0.5.0
*/
function arch(): NodeJS.Architecture;
diff --git a/types/node/package.json b/types/node/package.json
index 0558ddd3943238..90b78c0b3c4a90 100644
--- a/types/node/package.json
+++ b/types/node/package.json
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@types/node",
- "version": "25.9.9999",
+ "version": "26.0.9999",
"nonNpm": "conflict",
"nonNpmDescription": "Node.js",
"projects": [
@@ -18,7 +18,7 @@
}
},
"dependencies": {
- "undici-types": ">=7.24.0 <7.24.7"
+ "undici-types": "~8.3.0"
},
"devDependencies": {
"@types/node": "workspace:."
diff --git a/types/node/perf_hooks.d.ts b/types/node/perf_hooks.d.ts
index 46e725c314c53a..bc84794441d2c3 100644
--- a/types/node/perf_hooks.d.ts
+++ b/types/node/perf_hooks.d.ts
@@ -52,9 +52,6 @@ declare module "node:perf_hooks" {
entryTypes?: EntryType[];
type?: EntryType;
}
- // TODO: remove in next major
- /** @deprecated Use `TimerifyOptions` instead. */
- interface PerformanceTimerifyOptions extends TimerifyOptions {}
interface PerformanceEventMap {
"resourcetimingbufferfull": Event;
}
@@ -459,7 +456,7 @@ declare module "node:perf_hooks" {
* Event Loop Utilization (ELU).
*
* If bootstrapping has not yet finished on the main thread the properties have
- * the value of `0`. The ELU is immediately available on [Worker threads](https://nodejs.org/docs/latest-v25.x/api/worker_threads.html#worker-threads) since
+ * the value of `0`. The ELU is immediately available on [Worker threads](https://nodejs.org/docs/latest-v26.x/api/worker_threads.html#worker-threads) since
* bootstrap happens within the event loop.
*
* Both `utilization1` and `utilization2` are optional parameters.
@@ -601,11 +598,6 @@ declare module "node:perf_hooks" {
* @since v15.9.0, v14.18.0
*/
function createHistogram(options?: CreateHistogramOptions): RecordableHistogram;
- // TODO: remove these in a future major
- /** @deprecated Use the canonical `PerformanceMarkOptions` instead. */
- interface MarkOptions extends PerformanceMarkOptions {}
- /** @deprecated Use the canonical `PerformanceMeasureOptions` instead. */
- interface MeasureOptions extends PerformanceMeasureOptions {}
}
declare module "perf_hooks" {
export * from "node:perf_hooks";
diff --git a/types/node/process.d.ts b/types/node/process.d.ts
index 00ab94e16b367f..dd41214be293bb 100644
--- a/types/node/process.d.ts
+++ b/types/node/process.d.ts
@@ -81,6 +81,8 @@ declare module "node:process" {
"node:stream": typeof import("node:stream");
"stream/consumers": typeof import("stream/consumers");
"node:stream/consumers": typeof import("node:stream/consumers");
+ "stream/iter": typeof import("stream/iter");
+ "node:stream/iter": typeof import("node:stream/iter");
"stream/promises": typeof import("stream/promises");
"node:stream/promises": typeof import("node:stream/promises");
"stream/web": typeof import("stream/web");
@@ -214,7 +216,7 @@ declare module "node:process" {
readonly ipv6: boolean;
/**
* A boolean value that is `true` if the current Node.js build supports
- * [loading ECMAScript modules using `require()`](https://nodejs.org/docs/latest-v25.x/api/modules.md#loading-ecmascript-modules-using-require).
+ * [loading ECMAScript modules using `require()`](https://nodejs.org/docs/latest-v26.x/api/modules.md#loading-ecmascript-modules-using-require).
* @since v22.10.0
*/
readonly require_module: boolean;
@@ -251,12 +253,11 @@ declare module "node:process" {
*/
readonly tls_sni: boolean;
/**
- * A value that is `"strip"` by default,
- * `"transform"` if Node.js is run with `--experimental-transform-types`, and `false` if
+ * A value that is `"strip"` by default, and `false` if
* Node.js is run with `--no-strip-types`.
* @since v22.10.0
*/
- readonly typescript: "strip" | "transform" | false;
+ readonly typescript: "strip" | false;
/**
* A boolean value that is `true` if the current Node.js build includes support for libuv.
*
@@ -729,7 +730,7 @@ declare module "node:process" {
* arguments passed when the Node.js process was launched. The first element will
* be {@link execPath}. See `process.argv0` if access to the original value
* of `argv[0]` is needed. The second element will be the path to the JavaScript
- * file being executed. If a [program entry point](https://nodejs.org/docs/latest-v25.x/api/cli.html#program-entry-point) was provided, the second element
+ * file being executed. If a [program entry point](https://nodejs.org/docs/latest-v26.x/api/cli.html#program-entry-point) was provided, the second element
* will be the absolute path to it. The remaining elements are additional command-line
* arguments.
*
@@ -829,7 +830,7 @@ declare module "node:process" {
*
* Unlike `process.setUncaughtExceptionCaptureCallback()`, this function allows
* multiple callbacks to be registered and does not conflict with the
- * [`domain`](https://nodejs.org/docs/latest-v25.x/api/domain.html) module. Callbacks are called in reverse order of registration
+ * [`domain`](https://nodejs.org/docs/latest-v26.x/api/domain.html) module. Callbacks are called in reverse order of registration
* (most recent first). If a callback returns `true`, subsequent callbacks
* and the default uncaught exception handling are skipped.
*
@@ -893,7 +894,7 @@ declare module "node:process" {
* should not be used directly, except in special cases. In other words, `require()` should be preferred over `process.dlopen()`
* unless there are specific reasons such as custom dlopen flags or loading from ES modules.
*
- * The `flags` argument is an integer that allows to specify dlopen behavior. See the `[os.constants.dlopen](https://nodejs.org/docs/latest-v25.x/api/os.html#dlopen-constants)`
+ * The `flags` argument is an integer that allows to specify dlopen behavior. See the `[os.constants.dlopen](https://nodejs.org/docs/latest-v26.x/api/os.html#dlopen-constants)`
* documentation for details.
*
* An important requirement when calling `process.dlopen()` is that the `module` instance must be passed. Functions exported by the C++ Addon
@@ -1444,8 +1445,7 @@ declare module "node:process" {
* `process.addUncaughtExceptionCaptureCallback()` instead.
* @since v9.3.0
*/
- // TODO: callback parameter should be `unknown`
- setUncaughtExceptionCaptureCallback(cb: ((err: Error) => void) | null): void;
+ setUncaughtExceptionCaptureCallback(cb: ((err: unknown) => void) | null): void;
/**
* Indicates whether a callback has been set using {@link setUncaughtExceptionCaptureCallback}.
* @since v9.3.0
@@ -1735,7 +1735,7 @@ declare module "node:process" {
constrainedMemory(): number;
/**
* Gets the amount of free memory that is still available to the process (in bytes).
- * See [`uv_get_available_memory`](https://nodejs.org/docs/latest-v25.x/api/process.html#processavailablememory) for more information.
+ * See [`uv_get_available_memory`](https://nodejs.org/docs/latest-v26.x/api/process.html#processavailablememory) for more information.
* @since v20.13.0
*/
availableMemory(): number;
@@ -2027,7 +2027,7 @@ declare module "node:process" {
allowedNodeEnvironmentFlags: ReadonlySet;
/**
* `process.report` is an object whose methods are used to generate diagnostic reports for the current process.
- * Additional documentation is available in the [report documentation](https://nodejs.org/docs/latest-v25.x/api/report.html).
+ * Additional documentation is available in the [report documentation](https://nodejs.org/docs/latest-v26.x/api/report.html).
* @since v11.8.0
*/
report: ProcessReport;
diff --git a/types/node/readline.d.ts b/types/node/readline.d.ts
index 5042975a79b55e..a9ad29df4cf698 100644
--- a/types/node/readline.d.ts
+++ b/types/node/readline.d.ts
@@ -20,7 +20,7 @@ declare module "node:readline" {
}
/**
* Instances of the `readline.Interface` class are constructed using the `readline.createInterface()` method. Every instance is associated with a
- * single `input` [Readable](https://nodejs.org/docs/latest-v25.x/api/stream.html#readable-streams) stream and a single `output` [Writable](https://nodejs.org/docs/latest-v25.x/api/stream.html#writable-streams) stream.
+ * single `input` [Readable](https://nodejs.org/docs/latest-v26.x/api/stream.html#readable-streams) stream and a single `output` [Writable](https://nodejs.org/docs/latest-v26.x/api/stream.html#writable-streams) stream.
* The `output` stream is used to print prompts for user input that arrives on,
* and is read from, the `input` stream.
* @since v0.1.104
@@ -32,7 +32,7 @@ declare module "node:readline" {
* > Instances of the `readline.Interface` class are constructed using the
* > `readline.createInterface()` method.
*
- * @see https://nodejs.org/dist/latest-v25.x/docs/api/readline.html#class-interfaceconstructor
+ * @see https://nodejs.org/dist/latest-v26.x/docs/api/readline.html#class-interfaceconstructor
*/
protected constructor(
input: NodeJS.ReadableStream,
@@ -46,7 +46,7 @@ declare module "node:readline" {
* > Instances of the `readline.Interface` class are constructed using the
* > `readline.createInterface()` method.
*
- * @see https://nodejs.org/dist/latest-v25.x/docs/api/readline.html#class-interfaceconstructor
+ * @see https://nodejs.org/dist/latest-v26.x/docs/api/readline.html#class-interfaceconstructor
*/
protected constructor(options: ReadLineOptions);
readonly terminal: boolean;
@@ -221,7 +221,6 @@ declare module "node:readline" {
[Symbol.asyncIterator](): NodeJS.AsyncIterator;
}
interface Interface extends InternalEventEmitter {}
- type ReadLine = Interface; // type forwarded for backwards compatibility
type Completer = (line: string) => CompleterResult;
type AsyncCompleter = (
line: string,
@@ -230,11 +229,11 @@ declare module "node:readline" {
type CompleterResult = [string[], string];
interface ReadLineOptions {
/**
- * The [`Readable`](https://nodejs.org/docs/latest-v25.x/api/stream.html#readable-streams) stream to listen to
+ * The [`Readable`](https://nodejs.org/docs/latest-v26.x/api/stream.html#readable-streams) stream to listen to
*/
input: NodeJS.ReadableStream;
/**
- * The [`Writable`](https://nodejs.org/docs/latest-v25.x/api/stream.html#writable-streams) stream to write readline data to.
+ * The [`Writable`](https://nodejs.org/docs/latest-v26.x/api/stream.html#writable-streams) stream to write readline data to.
*/
output?: NodeJS.WritableStream | undefined;
/**
@@ -279,7 +278,7 @@ declare module "node:readline" {
* `crlfDelay` will be coerced to a number no less than `100`.
* It can be set to `Infinity`, in which case
* `\r` followed by `\n` will always be considered a single newline
- * (which may be reasonable for [reading files](https://nodejs.org/docs/latest-v25.x/api/readline.html#example-read-file-stream-line-by-line) with `\r\n` line delimiter).
+ * (which may be reasonable for [reading files](https://nodejs.org/docs/latest-v26.x/api/readline.html#example-read-file-stream-line-by-line) with `\r\n` line delimiter).
* @default 100
*/
crlfDelay?: number | undefined;
@@ -467,7 +466,7 @@ declare module "node:readline" {
cols: number;
}
/**
- * The `readline.clearLine()` method clears current line of given [TTY](https://nodejs.org/docs/latest-v25.x/api/tty.html) stream
+ * The `readline.clearLine()` method clears current line of given [TTY](https://nodejs.org/docs/latest-v26.x/api/tty.html) stream
* in a specified direction identified by `dir`.
* @since v0.7.7
* @param callback Invoked once the operation completes.
@@ -475,7 +474,7 @@ declare module "node:readline" {
*/
function clearLine(stream: NodeJS.WritableStream, dir: Direction, callback?: () => void): boolean;
/**
- * The `readline.clearScreenDown()` method clears the given [TTY](https://nodejs.org/docs/latest-v25.x/api/tty.html) stream from
+ * The `readline.clearScreenDown()` method clears the given [TTY](https://nodejs.org/docs/latest-v26.x/api/tty.html) stream from
* the current position of the cursor down.
* @since v0.7.7
* @param callback Invoked once the operation completes.
@@ -484,7 +483,7 @@ declare module "node:readline" {
function clearScreenDown(stream: NodeJS.WritableStream, callback?: () => void): boolean;
/**
* The `readline.cursorTo()` method moves cursor to the specified position in a
- * given [TTY](https://nodejs.org/docs/latest-v25.x/api/tty.html) `stream`.
+ * given [TTY](https://nodejs.org/docs/latest-v26.x/api/tty.html) `stream`.
* @since v0.7.7
* @param callback Invoked once the operation completes.
* @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
@@ -492,12 +491,14 @@ declare module "node:readline" {
function cursorTo(stream: NodeJS.WritableStream, x: number, y?: number, callback?: () => void): boolean;
/**
* The `readline.moveCursor()` method moves the cursor _relative_ to its current
- * position in a given [TTY](https://nodejs.org/docs/latest-v25.x/api/tty.html) `stream`.
+ * position in a given [TTY](https://nodejs.org/docs/latest-v26.x/api/tty.html) `stream`.
* @since v0.7.7
* @param callback Invoked once the operation completes.
* @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
*/
function moveCursor(stream: NodeJS.WritableStream, dx: number, dy: number, callback?: () => void): boolean;
+ /** @deprecated This alias will be removed in a future version. Use `import { Interface } from 'node:readline'` instead. */
+ type ReadLine = Interface;
}
declare module "node:readline" {
export * as promises from "node:readline/promises";
diff --git a/types/node/repl.d.ts b/types/node/repl.d.ts
index 4bb74ec4a257d1..33e2fe97a2d695 100644
--- a/types/node/repl.d.ts
+++ b/types/node/repl.d.ts
@@ -29,7 +29,7 @@ declare module "node:repl" {
* The function to be used when evaluating each given line of input.
* **Default:** an async wrapper for the JavaScript `eval()` function. An `eval` function can
* error with `repl.Recoverable` to indicate the input was incomplete and prompt for
- * additional lines. See the [custom evaluation functions](https://nodejs.org/dist/latest-v25.x/docs/api/repl.html#custom-evaluation-functions)
+ * additional lines. See the [custom evaluation functions](https://nodejs.org/dist/latest-v26.x/docs/api/repl.html#custom-evaluation-functions)
* section for more details.
*/
eval?: REPLEval | undefined;
@@ -62,13 +62,13 @@ declare module "node:repl" {
* The function to invoke to format the output of each command before writing to `output`.
* @default a wrapper for `util.inspect`
*
- * @see https://nodejs.org/dist/latest-v25.x/docs/api/repl.html#repl_customizing_repl_output
+ * @see https://nodejs.org/dist/latest-v26.x/docs/api/repl.html#repl_customizing_repl_output
*/
writer?: REPLWriter | undefined;
/**
* An optional function used for custom Tab auto completion.
*
- * @see https://nodejs.org/dist/latest-v25.x/docs/api/readline.html#readline_use_of_the_completer_function
+ * @see https://nodejs.org/dist/latest-v26.x/docs/api/readline.html#readline_use_of_the_completer_function
*/
completer?: Completer | AsyncCompleter | undefined;
/**
@@ -161,7 +161,7 @@ declare module "node:repl" {
*
* `REPLServer` cannot be subclassed due to implementation specifics in NodeJS.
*
- * @see https://nodejs.org/dist/latest-v25.x/docs/api/repl.html#repl_class_replserver
+ * @see https://nodejs.org/dist/latest-v26.x/docs/api/repl.html#repl_class_replserver
*/
private constructor();
/**
@@ -192,33 +192,33 @@ declare module "node:repl" {
/**
* A value indicating whether the REPL is currently in "editor mode".
*
- * @see https://nodejs.org/dist/latest-v25.x/docs/api/repl.html#repl_commands_and_special_keys
+ * @see https://nodejs.org/dist/latest-v26.x/docs/api/repl.html#repl_commands_and_special_keys
*/
readonly editorMode: boolean;
/**
* A value indicating whether the `_` variable has been assigned.
*
- * @see https://nodejs.org/dist/latest-v25.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable
+ * @see https://nodejs.org/dist/latest-v26.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable
*/
readonly underscoreAssigned: boolean;
/**
* The last evaluation result from the REPL (assigned to the `_` variable inside of the REPL).
*
- * @see https://nodejs.org/dist/latest-v25.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable
+ * @see https://nodejs.org/dist/latest-v26.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable
*/
readonly last: any;
/**
* A value indicating whether the `_error` variable has been assigned.
*
* @since v9.8.0
- * @see https://nodejs.org/dist/latest-v25.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable
+ * @see https://nodejs.org/dist/latest-v26.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable
*/
readonly underscoreErrAssigned: boolean;
/**
* The last error raised inside the REPL (assigned to the `_error` variable inside of the REPL).
*
* @since v9.8.0
- * @see https://nodejs.org/dist/latest-v25.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable
+ * @see https://nodejs.org/dist/latest-v26.x/docs/api/repl.html#repl_assignment_of_the_underscore_variable
*/
readonly lastError: any;
/**
@@ -408,7 +408,7 @@ declare module "node:repl" {
/**
* Indicates a recoverable error that a `REPLServer` can use to support multi-line input.
*
- * @see https://nodejs.org/dist/latest-v25.x/docs/api/repl.html#repl_recoverable_errors
+ * @see https://nodejs.org/dist/latest-v26.x/docs/api/repl.html#repl_recoverable_errors
*/
class Recoverable extends SyntaxError {
err: Error;
diff --git a/types/node/sqlite.d.ts b/types/node/sqlite.d.ts
index a1fa35823261b2..8e1e8bac750b87 100644
--- a/types/node/sqlite.d.ts
+++ b/types/node/sqlite.d.ts
@@ -336,7 +336,7 @@ declare module "node:sqlite" {
* @param options Optional configuration settings for the function.
* @param fn The JavaScript function to call when the SQLite function is
* invoked. The return value of this function should be a valid SQLite data type:
- * see [Type conversion between JavaScript and SQLite](https://nodejs.org/docs/latest-v25.x/api/sqlite.html#type-conversion-between-javascript-and-sqlite). The result defaults to
+ * see [Type conversion between JavaScript and SQLite](https://nodejs.org/docs/latest-v26.x/api/sqlite.html#type-conversion-between-javascript-and-sqlite). The result defaults to
* `NULL` if the return value is `undefined`.
*/
function(
diff --git a/types/node/stream.d.ts b/types/node/stream.d.ts
index 887b6d4d9bb21a..3d39bccf2b1fa6 100644
--- a/types/node/stream.d.ts
+++ b/types/node/stream.d.ts
@@ -128,13 +128,13 @@ declare module "node:stream" {
*/
readonly readableEncoding: BufferEncoding | null;
/**
- * Becomes `true` when [`'end'`](https://nodejs.org/docs/latest-v25.x/api/stream.html#event-end) event is emitted.
+ * Becomes `true` when [`'end'`](https://nodejs.org/docs/latest-v26.x/api/stream.html#event-end) event is emitted.
* @since v12.9.0
*/
readonly readableEnded: boolean;
/**
* This property reflects the current state of a `Readable` stream as described
- * in the [Three states](https://nodejs.org/docs/latest-v25.x/api/stream.html#three-states) section.
+ * in the [Three states](https://nodejs.org/docs/latest-v26.x/api/stream.html#three-states) section.
* @since v9.4.0
*/
readableFlowing: boolean | null;
@@ -478,7 +478,7 @@ declare module "node:stream" {
* This method also allows for an `AbortSignal` to be provided, which will destroy
* the composed stream when aborted.
*
- * See [`stream.compose(...streams)`](https://nodejs.org/docs/latest-v25.x/api/stream.html#streamcomposestreams) for more information.
+ * See [`stream.compose(...streams)`](https://nodejs.org/docs/latest-v26.x/api/stream.html#streamcomposestreams) for more information.
* @since v19.1.0, v18.13.0
* @returns a stream composed with the stream `stream`.
*/
@@ -1360,7 +1360,7 @@ declare module "node:stream" {
* Especially useful in error handling scenarios where a stream is destroyed
* prematurely (like an aborted HTTP request), and will not emit `'end'` or `'finish'`.
*
- * The `finished` API provides [`promise version`](https://nodejs.org/docs/latest-v25.x/api/stream.html#streamfinishedstream-options).
+ * The `finished` API provides [`promise version`](https://nodejs.org/docs/latest-v26.x/api/stream.html#streamfinishedstream-options).
*
* `stream.finished()` leaves dangling event listeners (in particular `'error'`, `'end'`, `'finish'` and `'close'`) after `callback` has been
* invoked. The reason for this is so that unexpected `'error'` events (due to
@@ -1459,7 +1459,7 @@ declare module "node:stream" {
* );
* ```
*
- * The `pipeline` API provides a [`promise version`](https://nodejs.org/docs/latest-v25.x/api/stream.html#streampipelinesource-transforms-destination-options).
+ * The `pipeline` API provides a [`promise version`](https://nodejs.org/docs/latest-v26.x/api/stream.html#streampipelinesource-transforms-destination-options).
*
* `stream.pipeline()` will call `stream.destroy(err)` on all streams except:
*
diff --git a/types/node/stream/promises.d.ts b/types/node/stream/promises.d.ts
index c4bd3ea2923fcd..c57fe1e3416afd 100644
--- a/types/node/stream/promises.d.ts
+++ b/types/node/stream/promises.d.ts
@@ -30,7 +30,7 @@ declare module "node:stream/promises" {
* rs.resume(); // Drain the stream.
* ```
*
- * The `finished` API also provides a [callback version](https://nodejs.org/docs/latest-v25.x/api/stream.html#streamfinishedstream-options-callback).
+ * The `finished` API also provides a [callback version](https://nodejs.org/docs/latest-v26.x/api/stream.html#streamfinishedstream-options-callback).
*
* `stream.finished()` leaves dangling event listeners (in particular
* `'error'`, `'end'`, `'finish'` and `'close'`) after the returned promise is
@@ -129,7 +129,7 @@ declare module "node:stream/promises" {
* console.log('Pipeline succeeded.');
* ```
*
- * The `pipeline` API provides [callback version](https://nodejs.org/docs/latest-v25.x/api/stream.html#streampipelinesource-transforms-destination-callback):
+ * The `pipeline` API provides [callback version](https://nodejs.org/docs/latest-v26.x/api/stream.html#streampipelinesource-transforms-destination-callback):
* @since v15.0.0
* @returns Fulfills when the pipeline is complete.
*/
diff --git a/types/node/stream/web.d.ts b/types/node/stream/web.d.ts
index 84d3811c27481f..c657494b35e278 100644
--- a/types/node/stream/web.d.ts
+++ b/types/node/stream/web.d.ts
@@ -184,7 +184,7 @@ declare module "node:stream/web" {
new(underlyingSource?: UnderlyingSource, strategy?: QueuingStrategy): ReadableStream;
from(iterable: Iterable | AsyncIterable): ReadableStream;
};
- interface ReadableStreamAsyncIterator extends NodeJS.AsyncIterator {
+ interface ReadableStreamAsyncIterator extends NodeJS.AsyncIterator {
[Symbol.asyncIterator](): ReadableStreamAsyncIterator;
}
interface ReadableStreamBYOBReader extends ReadableStreamGenericReader {
diff --git a/types/node/test.d.ts b/types/node/test.d.ts
index 0ad8b60c29e2ac..e3ce6167a0b6af 100644
--- a/types/node/test.d.ts
+++ b/types/node/test.d.ts
@@ -180,14 +180,14 @@ declare module "node:test" {
/**
* Specifies the current working directory to be used by the test runner.
* Serves as the base path for resolving files according to the
- * [test runner execution model](https://nodejs.org/docs/latest-v25.x/api/test.html#test-runner-execution-model).
+ * [test runner execution model](https://nodejs.org/docs/latest-v26.x/api/test.html#test-runner-execution-model).
* @since v23.0.0
* @default process.cwd()
*/
cwd?: string | undefined;
/**
* An array containing the list of files to run. If omitted, files are run according to the
- * [test runner execution model](https://nodejs.org/docs/latest-v25.x/api/test.html#test-runner-execution-model).
+ * [test runner execution model](https://nodejs.org/docs/latest-v26.x/api/test.html#test-runner-execution-model).
*/
files?: readonly string[] | undefined;
/**
@@ -200,7 +200,7 @@ declare module "node:test" {
/**
* An array containing the list of glob patterns to match test files.
* This option cannot be used together with `files`. If omitted, files are run according to the
- * [test runner execution model](https://nodejs.org/docs/latest-v25.x/api/test.html#test-runner-execution-model).
+ * [test runner execution model](https://nodejs.org/docs/latest-v26.x/api/test.html#test-runner-execution-model).
* @since v22.6.0
*/
globPatterns?: readonly string[] | undefined;
@@ -288,7 +288,7 @@ declare module "node:test" {
*/
rerunFailuresFilePath?: string | undefined;
/**
- * enable [code coverage](https://nodejs.org/docs/latest-v25.x/api/test.html#collecting-code-coverage) collection.
+ * enable [code coverage](https://nodejs.org/docs/latest-v26.x/api/test.html#collecting-code-coverage) collection.
* @since v22.10.0
* @default false
*/
@@ -1193,7 +1193,7 @@ declare module "node:test" {
* highlighting.
* @since v22.14.0
* @param value A value to serialize to a string. If Node.js was started with
- * the [`--test-update-snapshots`](https://nodejs.org/docs/latest-v25.x/api/cli.html#--test-update-snapshots)
+ * the [`--test-update-snapshots`](https://nodejs.org/docs/latest-v26.x/api/cli.html#--test-update-snapshots)
* flag, the serialized value is written to
* `path`. Otherwise, the serialized value is compared to the contents of the
* existing snapshot file.
@@ -1216,7 +1216,7 @@ declare module "node:test" {
* ```
* @since v22.3.0
* @param value A value to serialize to a string. If Node.js was started with
- * the [`--test-update-snapshots`](https://nodejs.org/docs/latest-v25.x/api/cli.html#--test-update-snapshots)
+ * the [`--test-update-snapshots`](https://nodejs.org/docs/latest-v26.x/api/cli.html#--test-update-snapshots)
* flag, the serialized value is written to
* the snapshot file. Otherwise, the serialized value is compared to the
* corresponding value in the existing snapshot file.
@@ -1684,10 +1684,10 @@ declare module "node:test" {
* This function is used to mock the exports of ECMAScript modules, CommonJS modules, JSON modules, and
* Node.js builtin modules. Any references to the original module prior to mocking are not impacted. In
* order to enable module mocking, Node.js must be started with the
- * [`--experimental-test-module-mocks`](https://nodejs.org/docs/latest-v25.x/api/cli.html#--experimental-test-module-mocks)
+ * [`--experimental-test-module-mocks`](https://nodejs.org/docs/latest-v26.x/api/cli.html#--experimental-test-module-mocks)
* command-line flag.
*
- * **Note**: [module customization hooks](https://nodejs.org/docs/latest-v25.x/api/module.html#customization-hooks) registered via the **synchronous** API effect resolution of
+ * **Note**: [module customization hooks](https://nodejs.org/docs/latest-v26.x/api/module.html#customization-hooks) registered via the **synchronous** API effect resolution of
* the `specifier` provided to `mock.module`. Customization hooks registered via the **asynchronous**
* API are currently ignored (because the test runner's loader is synchronous, and node does not
* support multi-chain / cross-chain loading).
diff --git a/types/node/test/reporters.d.ts b/types/node/test/reporters.d.ts
index 55595f37fc869f..c93f4c0076ef61 100644
--- a/types/node/test/reporters.d.ts
+++ b/types/node/test/reporters.d.ts
@@ -51,7 +51,7 @@ declare module "node:test/reporters" {
}
/**
* The `lcov` reporter outputs test coverage when used with the
- * [`--experimental-test-coverage`](https://nodejs.org/docs/latest-v25.x/api/cli.html#--experimental-test-coverage) flag.
+ * [`--experimental-test-coverage`](https://nodejs.org/docs/latest-v26.x/api/cli.html#--experimental-test-coverage) flag.
* @since v22.0.0
*/
const lcov: ReporterConstructorWrapper;
diff --git a/types/node/tls.d.ts b/types/node/tls.d.ts
index 3efd2ae2027e8f..8cbf8661b18f20 100644
--- a/types/node/tls.d.ts
+++ b/types/node/tls.d.ts
@@ -1099,7 +1099,7 @@ declare module "node:tls" {
* the `ciphers` option of `{@link createSecureContext}`.
*
* Not all supported ciphers are enabled by default. See
- * [Modifying the default TLS cipher suite](https://nodejs.org/docs/latest-v25.x/api/tls.html#modifying-the-default-tls-cipher-suite).
+ * [Modifying the default TLS cipher suite](https://nodejs.org/docs/latest-v26.x/api/tls.html#modifying-the-default-tls-cipher-suite).
*
* Cipher names that start with `'tls_'` are for TLSv1.3, all the others are for
* TLSv1.2 and below.
diff --git a/types/node/ts5.6/index.d.ts b/types/node/ts5.6/index.d.ts
index c088541c099655..83f660488b56e7 100644
--- a/types/node/ts5.6/index.d.ts
+++ b/types/node/ts5.6/index.d.ts
@@ -22,7 +22,7 @@
* IN THE SOFTWARE.
*/
-// NOTE: These definitions support Node.js and TypeScript 5.2 through 5.6.
+// NOTE: These definitions support Node.js and TypeScript 5.6.
// Reference required TypeScript libraries:
///
@@ -31,9 +31,6 @@
// TypeScript library polyfills required for TypeScript <=5.6:
///
-// Iterator definitions required for compatibility with TypeScript <5.6:
-///
-
// Definitions for Node.js modules specific to TypeScript <=5.6:
///
///
diff --git a/types/node/ts5.7/index.d.ts b/types/node/ts5.7/index.d.ts
index 2510b2ed66c46d..d296cc6151a449 100644
--- a/types/node/ts5.7/index.d.ts
+++ b/types/node/ts5.7/index.d.ts
@@ -31,9 +31,6 @@
// TypeScript library polyfills required for TypeScript 5.7:
///
-// Iterator definitions required for compatibility with TypeScript <5.6:
-///
-
// Definitions for Node.js modules specific to TypeScript 5.7+:
///
///
diff --git a/types/node/url.d.ts b/types/node/url.d.ts
index a464d82a1b97a5..d6ea8c59e7faf4 100644
--- a/types/node/url.d.ts
+++ b/types/node/url.d.ts
@@ -65,7 +65,7 @@ declare module "node:url" {
* strings. It is prone to security issues such as [host name spoofing](https://hackerone.com/reports/678487)
* and incorrect handling of usernames and passwords. Do not use with untrusted
* input. CVEs are not issued for `url.parse()` vulnerabilities. Use the
- * [WHATWG URL](https://nodejs.org/docs/latest-v25.x/api/url.html#the-whatwg-url-api) API instead, for example:
+ * [WHATWG URL](https://nodejs.org/docs/latest-v26.x/api/url.html#the-whatwg-url-api) API instead, for example:
*
* ```js
* function getURL(req) {
@@ -88,7 +88,7 @@ declare module "node:url" {
* @deprecated Use the WHATWG URL API instead.
* @param urlString The URL string to parse.
* @param parseQueryString If `true`, the `query` property will always
- * be set to an object returned by the [`querystring`](https://nodejs.org/docs/latest-v25.x/api/querystring.html) module's `parse()`
+ * be set to an object returned by the [`querystring`](https://nodejs.org/docs/latest-v26.x/api/querystring.html) module's `parse()`
* method. If `false`, the `query` property on the returned URL object will be an
* unparsed, undecoded string. **Default:** `false`.
* @param slashesDenoteHost If `true`, the first token after the literal
@@ -546,7 +546,7 @@ declare module "node:url" {
prototype: URLSearchParams;
new(init?: string[][] | Record | string | URLSearchParams): URLSearchParams;
};
- interface URLSearchParamsIterator extends NodeJS.Iterator {
+ interface URLSearchParamsIterator extends NodeJS.Iterator {
[Symbol.iterator](): URLSearchParamsIterator;
}
// #endregion
diff --git a/types/node/util.d.ts b/types/node/util.d.ts
index 90f12aa21416cb..f6da4ee7d103cb 100644
--- a/types/node/util.d.ts
+++ b/types/node/util.d.ts
@@ -139,19 +139,6 @@ declare module "node:util" {
export interface Inspectable {
[inspect.custom](depth: number, options: InspectContext, inspect: typeof _inspect): any;
}
- // TODO: Remove these in a future major
- /** @deprecated Use `InspectStyle` instead. */
- export type Style = Exclude;
- /** @deprecated Use the `Inspectable` interface instead. */
- export type CustomInspectFunction = (depth: number, options: InspectContext) => any;
- /** @deprecated Use `InspectContext` instead. */
- export interface InspectOptionsStylized extends InspectContext {}
- /** @deprecated Use `InspectColorModifier` instead. */
- export type Modifiers = InspectColorModifier;
- /** @deprecated Use `InspectColorForeground` instead. */
- export type ForegroundColors = InspectColorForeground;
- /** @deprecated Use `InspectColorBackground` instead. */
- export type BackgroundColors = InspectColorBackground;
export interface CallSiteObject {
/**
* Returns the name of the function associated with this call site.
@@ -340,8 +327,7 @@ declare module "node:util" {
*
* It is possible to reconstruct the original locations by setting the option `sourceMap` to `true`.
* If the source map is not available, the original location will be the same as the current location.
- * When the `--enable-source-maps` flag is enabled, for example when using `--experimental-transform-types`,
- * `sourceMap` will be true by default.
+ * When the `--enable-source-maps` flag is enabled, `sourceMap` will be true by default.
*
* ```ts
* import { getCallSites } from 'node:util';
@@ -1115,7 +1101,7 @@ declare module "node:util" {
* ```
*
* If there is an `original[util.promisify.custom]` property present, `promisify`
- * will return its value, see [Custom promisified functions](https://nodejs.org/docs/latest-v25.x/api/util.html#custom-promisified-functions).
+ * will return its value, see [Custom promisified functions](https://nodejs.org/docs/latest-v26.x/api/util.html#custom-promisified-functions).
*
* `promisify()` assumes that `original` is a function taking a callback as its
* final argument in all cases. If `original` is not a function, `promisify()`
@@ -1260,7 +1246,7 @@ declare module "node:util" {
*
* The special format value `none` applies no additional styling to the text.
*
- * The full list of formats can be found in [modifiers](https://nodejs.org/docs/latest-v25.x/api/util.html#modifiers).
+ * The full list of formats can be found in [modifiers](https://nodejs.org/docs/latest-v26.x/api/util.html#modifiers).
* @param format A text format or an Array of text formats defined in `util.inspect.colors`.
* @param text The text to to be formatted.
* @since v20.12.0
@@ -1270,9 +1256,6 @@ declare module "node:util" {
text: string,
options?: StyleTextOptions,
): string;
- /** @deprecated This alias will be removed in a future version. Use the canonical `TextEncoderEncodeIntoResult` instead. */
- // TODO: remove in future major
- export interface EncodeIntoResult extends TextEncoderEncodeIntoResult {}
//// parseArgs
/**
* Provides a higher level API for command-line argument parsing than interacting
diff --git a/types/node/util/types.d.ts b/types/node/util/types.d.ts
index 818825bd57ee1c..174c0fa0e81808 100644
--- a/types/node/util/types.d.ts
+++ b/types/node/util/types.d.ts
@@ -187,7 +187,7 @@ declare module "node:util/types" {
* ```
*
* For further information on `napi_create_external`, refer to
- * [`napi_create_external()`](https://nodejs.org/docs/latest-v25.x/api/n-api.html#napi_create_external).
+ * [`napi_create_external()`](https://nodejs.org/docs/latest-v26.x/api/n-api.html#napi_create_external).
* @since v10.0.0
*/
function isExternal(object: unknown): boolean;
diff --git a/types/node/v25/.eslintrc.json b/types/node/v25/.eslintrc.json
new file mode 100644
index 00000000000000..13a6d5b41a2e04
--- /dev/null
+++ b/types/node/v25/.eslintrc.json
@@ -0,0 +1,10 @@
+{
+ "rules": {
+ "@definitelytyped/no-single-element-tuple-type": "off",
+ "@definitelytyped/no-single-declare-module": "off",
+ "@typescript-eslint/no-unsafe-function-type": "off",
+ "@typescript-eslint/no-wrapper-object-types": "off",
+ "@typescript-eslint/no-empty-interface": "off",
+ "no-duplicate-imports": "off"
+ }
+}
diff --git a/types/node/v25/.npmignore b/types/node/v25/.npmignore
new file mode 100644
index 00000000000000..93e307400a5456
--- /dev/null
+++ b/types/node/v25/.npmignore
@@ -0,0 +1,5 @@
+*
+!**/*.d.ts
+!**/*.d.cts
+!**/*.d.mts
+!**/*.d.*.ts
diff --git a/types/node/v25/assert.d.ts b/types/node/v25/assert.d.ts
new file mode 100644
index 00000000000000..c4cc77e432da08
--- /dev/null
+++ b/types/node/v25/assert.d.ts
@@ -0,0 +1,950 @@
+declare module "node:assert" {
+ import strict = require("node:assert/strict");
+ /**
+ * An alias of {@link assert.ok}.
+ * @since v0.5.9
+ * @param value The input that is checked for being truthy.
+ */
+ function assert(value: unknown, message?: string | Error): asserts value;
+ const kOptions: unique symbol;
+ namespace assert {
+ type AssertMethodNames =
+ | "deepEqual"
+ | "deepStrictEqual"
+ | "doesNotMatch"
+ | "doesNotReject"
+ | "doesNotThrow"
+ | "equal"
+ | "fail"
+ | "ifError"
+ | "match"
+ | "notDeepEqual"
+ | "notDeepStrictEqual"
+ | "notEqual"
+ | "notStrictEqual"
+ | "ok"
+ | "partialDeepStrictEqual"
+ | "rejects"
+ | "strictEqual"
+ | "throws";
+ interface AssertOptions {
+ /**
+ * If set to `'full'`, shows the full diff in assertion errors.
+ * @default 'simple'
+ */
+ diff?: "simple" | "full" | undefined;
+ /**
+ * If set to `true`, non-strict methods behave like their
+ * corresponding strict methods.
+ * @default true
+ */
+ strict?: boolean | undefined;
+ /**
+ * If set to `true`, skips prototype and constructor
+ * comparison in deep equality checks.
+ * @since v24.9.0
+ * @default false
+ */
+ skipPrototype?: boolean | undefined;
+ }
+ interface Assert extends Pick {
+ readonly [kOptions]: AssertOptions & { strict: false };
+ }
+ interface AssertStrict extends Pick {
+ readonly [kOptions]: AssertOptions & { strict: true };
+ }
+ /**
+ * The `Assert` class allows creating independent assertion instances with custom options.
+ * @since v24.6.0
+ */
+ var Assert: {
+ /**
+ * Creates a new assertion instance. The `diff` option controls the verbosity of diffs in assertion error messages.
+ *
+ * ```js
+ * const { Assert } = require('node:assert');
+ * const assertInstance = new Assert({ diff: 'full' });
+ * assertInstance.deepStrictEqual({ a: 1 }, { a: 2 });
+ * // Shows a full diff in the error message.
+ * ```
+ *
+ * **Important**: When destructuring assertion methods from an `Assert` instance,
+ * the methods lose their connection to the instance's configuration options (such
+ * as `diff`, `strict`, and `skipPrototype` settings).
+ * The destructured methods will fall back to default behavior instead.
+ *
+ * ```js
+ * const myAssert = new Assert({ diff: 'full' });
+ *
+ * // This works as expected - uses 'full' diff
+ * myAssert.strictEqual({ a: 1 }, { b: { c: 1 } });
+ *
+ * // This loses the 'full' diff setting - falls back to default 'simple' diff
+ * const { strictEqual } = myAssert;
+ * strictEqual({ a: 1 }, { b: { c: 1 } });
+ * ```
+ *
+ * The `skipPrototype` option affects all deep equality methods:
+ *
+ * ```js
+ * class Foo {
+ * constructor(a) {
+ * this.a = a;
+ * }
+ * }
+ *
+ * class Bar {
+ * constructor(a) {
+ * this.a = a;
+ * }
+ * }
+ *
+ * const foo = new Foo(1);
+ * const bar = new Bar(1);
+ *
+ * // Default behavior - fails due to different constructors
+ * const assert1 = new Assert();
+ * assert1.deepStrictEqual(foo, bar); // AssertionError
+ *
+ * // Skip prototype comparison - passes if properties are equal
+ * const assert2 = new Assert({ skipPrototype: true });
+ * assert2.deepStrictEqual(foo, bar); // OK
+ * ```
+ *
+ * When destructured, methods lose access to the instance's `this` context and revert to default assertion behavior
+ * (diff: 'simple', non-strict mode).
+ * To maintain custom options when using destructured methods, avoid
+ * destructuring and call methods directly on the instance.
+ * @since v24.6.0
+ */
+ new(
+ options?: AssertOptions & { strict?: true | undefined },
+ ): AssertStrict;
+ new(
+ options: AssertOptions,
+ ): Assert;
+ };
+ interface AssertionErrorOptions {
+ /**
+ * If provided, the error message is set to this value.
+ */
+ message?: string | undefined;
+ /**
+ * The `actual` property on the error instance.
+ */
+ actual?: unknown;
+ /**
+ * The `expected` property on the error instance.
+ */
+ expected?: unknown;
+ /**
+ * The `operator` property on the error instance.
+ */
+ operator?: string | undefined;
+ /**
+ * If provided, the generated stack trace omits frames before this function.
+ */
+ stackStartFn?: Function | undefined;
+ /**
+ * If set to `'full'`, shows the full diff in assertion errors.
+ * @default 'simple'
+ */
+ diff?: "simple" | "full" | undefined;
+ }
+ /**
+ * Indicates the failure of an assertion. All errors thrown by the `node:assert` module will be instances of the `AssertionError` class.
+ */
+ class AssertionError extends Error {
+ constructor(options: AssertionErrorOptions);
+ /**
+ * Set to the `actual` argument for methods such as {@link assert.strictEqual()}.
+ */
+ actual: unknown;
+ /**
+ * Set to the `expected` argument for methods such as {@link assert.strictEqual()}.
+ */
+ expected: unknown;
+ /**
+ * Indicates if the message was auto-generated (`true`) or not.
+ */
+ generatedMessage: boolean;
+ /**
+ * Value is always `ERR_ASSERTION` to show that the error is an assertion error.
+ */
+ code: "ERR_ASSERTION";
+ /**
+ * Set to the passed in operator value.
+ */
+ operator: string;
+ }
+ type AssertPredicate = RegExp | (new() => object) | ((thrown: unknown) => boolean) | object | Error;
+ /**
+ * Throws an `AssertionError` with the provided error message or a default
+ * error message. If the `message` parameter is an instance of an `Error` then
+ * it will be thrown instead of the `AssertionError`.
+ *
+ * ```js
+ * import assert from 'node:assert/strict';
+ *
+ * assert.fail();
+ * // AssertionError [ERR_ASSERTION]: Failed
+ *
+ * assert.fail('boom');
+ * // AssertionError [ERR_ASSERTION]: boom
+ *
+ * assert.fail(new TypeError('need array'));
+ * // TypeError: need array
+ * ```
+ * @since v0.1.21
+ * @param [message='Failed']
+ */
+ function fail(message?: string | Error): never;
+ /**
+ * Tests if `value` is truthy. It is equivalent to `assert.equal(!!value, true, message)`.
+ *
+ * If `value` is not truthy, an `AssertionError` is thrown with a `message` property set equal to the value of the `message` parameter. If the `message` parameter is `undefined`, a default
+ * error message is assigned. If the `message` parameter is an instance of an `Error` then it will be thrown instead of the `AssertionError`.
+ * If no arguments are passed in at all `message` will be set to the string:`` 'No value argument passed to `assert.ok()`' ``.
+ *
+ * Be aware that in the `repl` the error message will be different to the one
+ * thrown in a file! See below for further details.
+ *
+ * ```js
+ * import assert from 'node:assert/strict';
+ *
+ * assert.ok(true);
+ * // OK
+ * assert.ok(1);
+ * // OK
+ *
+ * assert.ok();
+ * // AssertionError: No value argument passed to `assert.ok()`
+ *
+ * assert.ok(false, 'it\'s false');
+ * // AssertionError: it's false
+ *
+ * // In the repl:
+ * assert.ok(typeof 123 === 'string');
+ * // AssertionError: false == true
+ *
+ * // In a file (e.g. test.js):
+ * assert.ok(typeof 123 === 'string');
+ * // AssertionError: The expression evaluated to a falsy value:
+ * //
+ * // assert.ok(typeof 123 === 'string')
+ *
+ * assert.ok(false);
+ * // AssertionError: The expression evaluated to a falsy value:
+ * //
+ * // assert.ok(false)
+ *
+ * assert.ok(0);
+ * // AssertionError: The expression evaluated to a falsy value:
+ * //
+ * // assert.ok(0)
+ * ```
+ *
+ * ```js
+ * import assert from 'node:assert/strict';
+ *
+ * // Using `assert()` works the same:
+ * assert(2 + 2 > 5);;
+ * // AssertionError: The expression evaluated to a falsy value:
+ * //
+ * // assert(2 + 2 > 5)
+ * ```
+ * @since v0.1.21
+ */
+ function ok(value: unknown, message?: string | Error): asserts value;
+ /**
+ * **Strict assertion mode**
+ *
+ * An alias of {@link strictEqual}.
+ *
+ * **Legacy assertion mode**
+ *
+ * > Stability: 3 - Legacy: Use {@link strictEqual} instead.
+ *
+ * Tests shallow, coercive equality between the `actual` and `expected` parameters
+ * using the [`==` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Equality). `NaN` is specially handled
+ * and treated as being identical if both sides are `NaN`.
+ *
+ * ```js
+ * import assert from 'node:assert';
+ *
+ * assert.equal(1, 1);
+ * // OK, 1 == 1
+ * assert.equal(1, '1');
+ * // OK, 1 == '1'
+ * assert.equal(NaN, NaN);
+ * // OK
+ *
+ * assert.equal(1, 2);
+ * // AssertionError: 1 == 2
+ * assert.equal({ a: { b: 1 } }, { a: { b: 1 } });
+ * // AssertionError: { a: { b: 1 } } == { a: { b: 1 } }
+ * ```
+ *
+ * If the values are not equal, an `AssertionError` is thrown with a `message` property set equal to the value of the `message` parameter. If the `message` parameter is undefined, a default
+ * error message is assigned. If the `message` parameter is an instance of an `Error` then it will be thrown instead of the `AssertionError`.
+ * @since v0.1.21
+ */
+ function equal(actual: unknown, expected: unknown, message?: string | Error): void;
+ /**
+ * **Strict assertion mode**
+ *
+ * An alias of {@link notStrictEqual}.
+ *
+ * **Legacy assertion mode**
+ *
+ * > Stability: 3 - Legacy: Use {@link notStrictEqual} instead.
+ *
+ * Tests shallow, coercive inequality with the [`!=` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Inequality). `NaN` is
+ * specially handled and treated as being identical if both sides are `NaN`.
+ *
+ * ```js
+ * import assert from 'node:assert';
+ *
+ * assert.notEqual(1, 2);
+ * // OK
+ *
+ * assert.notEqual(1, 1);
+ * // AssertionError: 1 != 1
+ *
+ * assert.notEqual(1, '1');
+ * // AssertionError: 1 != '1'
+ * ```
+ *
+ * If the values are equal, an `AssertionError` is thrown with a `message` property set equal to the value of the `message` parameter. If the `message` parameter is undefined, a default error
+ * message is assigned. If the `message` parameter is an instance of an `Error` then it will be thrown instead of the `AssertionError`.
+ * @since v0.1.21
+ */
+ function notEqual(actual: unknown, expected: unknown, message?: string | Error): void;
+ /**
+ * **Strict assertion mode**
+ *
+ * An alias of {@link deepStrictEqual}.
+ *
+ * **Legacy assertion mode**
+ *
+ * > Stability: 3 - Legacy: Use {@link deepStrictEqual} instead.
+ *
+ * Tests for deep equality between the `actual` and `expected` parameters. Consider
+ * using {@link deepStrictEqual} instead. {@link deepEqual} can have
+ * surprising results.
+ *
+ * _Deep equality_ means that the enumerable "own" properties of child objects
+ * are also recursively evaluated by the following rules.
+ * @since v0.1.21
+ */
+ function deepEqual(actual: unknown, expected: unknown, message?: string | Error): void;
+ /**
+ * **Strict assertion mode**
+ *
+ * An alias of {@link notDeepStrictEqual}.
+ *
+ * **Legacy assertion mode**
+ *
+ * > Stability: 3 - Legacy: Use {@link notDeepStrictEqual} instead.
+ *
+ * Tests for any deep inequality. Opposite of {@link deepEqual}.
+ *
+ * ```js
+ * import assert from 'node:assert';
+ *
+ * const obj1 = {
+ * a: {
+ * b: 1,
+ * },
+ * };
+ * const obj2 = {
+ * a: {
+ * b: 2,
+ * },
+ * };
+ * const obj3 = {
+ * a: {
+ * b: 1,
+ * },
+ * };
+ * const obj4 = { __proto__: obj1 };
+ *
+ * assert.notDeepEqual(obj1, obj1);
+ * // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
+ *
+ * assert.notDeepEqual(obj1, obj2);
+ * // OK
+ *
+ * assert.notDeepEqual(obj1, obj3);
+ * // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
+ *
+ * assert.notDeepEqual(obj1, obj4);
+ * // OK
+ * ```
+ *
+ * If the values are deeply equal, an `AssertionError` is thrown with a `message` property set equal to the value of the `message` parameter. If the `message` parameter is undefined, a default
+ * error message is assigned. If the `message` parameter is an instance of an `Error` then it will be thrown
+ * instead of the `AssertionError`.
+ * @since v0.1.21
+ */
+ function notDeepEqual(actual: unknown, expected: unknown, message?: string | Error): void;
+ /**
+ * Tests strict equality between the `actual` and `expected` parameters as
+ * determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
+ *
+ * ```js
+ * import assert from 'node:assert/strict';
+ *
+ * assert.strictEqual(1, 2);
+ * // AssertionError [ERR_ASSERTION]: Expected inputs to be strictly equal:
+ * //
+ * // 1 !== 2
+ *
+ * assert.strictEqual(1, 1);
+ * // OK
+ *
+ * assert.strictEqual('Hello foobar', 'Hello World!');
+ * // AssertionError [ERR_ASSERTION]: Expected inputs to be strictly equal:
+ * // + actual - expected
+ * //
+ * // + 'Hello foobar'
+ * // - 'Hello World!'
+ * // ^
+ *
+ * const apples = 1;
+ * const oranges = 2;
+ * assert.strictEqual(apples, oranges, `apples ${apples} !== oranges ${oranges}`);
+ * // AssertionError [ERR_ASSERTION]: apples 1 !== oranges 2
+ *
+ * assert.strictEqual(1, '1', new TypeError('Inputs are not identical'));
+ * // TypeError: Inputs are not identical
+ * ```
+ *
+ * If the values are not strictly equal, an `AssertionError` is thrown with a `message` property set equal to the value of the `message` parameter. If the `message` parameter is undefined, a
+ * default error message is assigned. If the `message` parameter is an instance of an `Error` then it will be thrown
+ * instead of the `AssertionError`.
+ * @since v0.1.21
+ */
+ function strictEqual(actual: unknown, expected: T, message?: string | Error): asserts actual is T;
+ /**
+ * Tests strict inequality between the `actual` and `expected` parameters as
+ * determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
+ *
+ * ```js
+ * import assert from 'node:assert/strict';
+ *
+ * assert.notStrictEqual(1, 2);
+ * // OK
+ *
+ * assert.notStrictEqual(1, 1);
+ * // AssertionError [ERR_ASSERTION]: Expected "actual" to be strictly unequal to:
+ * //
+ * // 1
+ *
+ * assert.notStrictEqual(1, '1');
+ * // OK
+ * ```
+ *
+ * If the values are strictly equal, an `AssertionError` is thrown with a `message` property set equal to the value of the `message` parameter. If the `message` parameter is undefined, a
+ * default error message is assigned. If the `message` parameter is an instance of an `Error` then it will be thrown
+ * instead of the `AssertionError`.
+ * @since v0.1.21
+ */
+ function notStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void;
+ /**
+ * Tests for deep equality between the `actual` and `expected` parameters.
+ * "Deep" equality means that the enumerable "own" properties of child objects
+ * are recursively evaluated also by the following rules.
+ * @since v1.2.0
+ */
+ function deepStrictEqual(actual: unknown, expected: T, message?: string | Error): asserts actual is T;
+ /**
+ * Tests for deep strict inequality. Opposite of {@link deepStrictEqual}.
+ *
+ * ```js
+ * import assert from 'node:assert/strict';
+ *
+ * assert.notDeepStrictEqual({ a: 1 }, { a: '1' });
+ * // OK
+ * ```
+ *
+ * If the values are deeply and strictly equal, an `AssertionError` is thrown
+ * with a `message` property set equal to the value of the `message` parameter. If
+ * the `message` parameter is undefined, a default error message is assigned. If
+ * the `message` parameter is an instance of an `Error` then it will be thrown
+ * instead of the `AssertionError`.
+ * @since v1.2.0
+ */
+ function notDeepStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void;
+ /**
+ * Expects the function `fn` to throw an error.
+ *
+ * If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
+ * [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), a validation function,
+ * a validation object where each property will be tested for strict deep equality,
+ * or an instance of error where each property will be tested for strict deep
+ * equality including the non-enumerable `message` and `name` properties. When
+ * using an object, it is also possible to use a regular expression, when
+ * validating against a string property. See below for examples.
+ *
+ * If specified, `message` will be appended to the message provided by the `AssertionError` if the `fn` call fails to throw or in case the error validation
+ * fails.
+ *
+ * Custom validation object/error instance:
+ *
+ * ```js
+ * import assert from 'node:assert/strict';
+ *
+ * const err = new TypeError('Wrong value');
+ * err.code = 404;
+ * err.foo = 'bar';
+ * err.info = {
+ * nested: true,
+ * baz: 'text',
+ * };
+ * err.reg = /abc/i;
+ *
+ * assert.throws(
+ * () => {
+ * throw err;
+ * },
+ * {
+ * name: 'TypeError',
+ * message: 'Wrong value',
+ * info: {
+ * nested: true,
+ * baz: 'text',
+ * },
+ * // Only properties on the validation object will be tested for.
+ * // Using nested objects requires all properties to be present. Otherwise
+ * // the validation is going to fail.
+ * },
+ * );
+ *
+ * // Using regular expressions to validate error properties:
+ * assert.throws(
+ * () => {
+ * throw err;
+ * },
+ * {
+ * // The `name` and `message` properties are strings and using regular
+ * // expressions on those will match against the string. If they fail, an
+ * // error is thrown.
+ * name: /^TypeError$/,
+ * message: /Wrong/,
+ * foo: 'bar',
+ * info: {
+ * nested: true,
+ * // It is not possible to use regular expressions for nested properties!
+ * baz: 'text',
+ * },
+ * // The `reg` property contains a regular expression and only if the
+ * // validation object contains an identical regular expression, it is going
+ * // to pass.
+ * reg: /abc/i,
+ * },
+ * );
+ *
+ * // Fails due to the different `message` and `name` properties:
+ * assert.throws(
+ * () => {
+ * const otherErr = new Error('Not found');
+ * // Copy all enumerable properties from `err` to `otherErr`.
+ * for (const [key, value] of Object.entries(err)) {
+ * otherErr[key] = value;
+ * }
+ * throw otherErr;
+ * },
+ * // The error's `message` and `name` properties will also be checked when using
+ * // an error as validation object.
+ * err,
+ * );
+ * ```
+ *
+ * Validate instanceof using constructor:
+ *
+ * ```js
+ * import assert from 'node:assert/strict';
+ *
+ * assert.throws(
+ * () => {
+ * throw new Error('Wrong value');
+ * },
+ * Error,
+ * );
+ * ```
+ *
+ * Validate error message using [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions):
+ *
+ * Using a regular expression runs `.toString` on the error object, and will
+ * therefore also include the error name.
+ *
+ * ```js
+ * import assert from 'node:assert/strict';
+ *
+ * assert.throws(
+ * () => {
+ * throw new Error('Wrong value');
+ * },
+ * /^Error: Wrong value$/,
+ * );
+ * ```
+ *
+ * Custom error validation:
+ *
+ * The function must return `true` to indicate all internal validations passed.
+ * It will otherwise fail with an `AssertionError`.
+ *
+ * ```js
+ * import assert from 'node:assert/strict';
+ *
+ * assert.throws(
+ * () => {
+ * throw new Error('Wrong value');
+ * },
+ * (err) => {
+ * assert(err instanceof Error);
+ * assert(/value/.test(err));
+ * // Avoid returning anything from validation functions besides `true`.
+ * // Otherwise, it's not clear what part of the validation failed. Instead,
+ * // throw an error about the specific validation that failed (as done in this
+ * // example) and add as much helpful debugging information to that error as
+ * // possible.
+ * return true;
+ * },
+ * 'unexpected error',
+ * );
+ * ```
+ *
+ * `error` cannot be a string. If a string is provided as the second
+ * argument, then `error` is assumed to be omitted and the string will be used for `message` instead. This can lead to easy-to-miss mistakes. Using the same
+ * message as the thrown error message is going to result in an `ERR_AMBIGUOUS_ARGUMENT` error. Please read the example below carefully if using
+ * a string as the second argument gets considered:
+ *
+ * ```js
+ * import assert from 'node:assert/strict';
+ *
+ * function throwingFirst() {
+ * throw new Error('First');
+ * }
+ *
+ * function throwingSecond() {
+ * throw new Error('Second');
+ * }
+ *
+ * function notThrowing() {}
+ *
+ * // The second argument is a string and the input function threw an Error.
+ * // The first case will not throw as it does not match for the error message
+ * // thrown by the input function!
+ * assert.throws(throwingFirst, 'Second');
+ * // In the next example the message has no benefit over the message from the
+ * // error and since it is not clear if the user intended to actually match
+ * // against the error message, Node.js throws an `ERR_AMBIGUOUS_ARGUMENT` error.
+ * assert.throws(throwingSecond, 'Second');
+ * // TypeError [ERR_AMBIGUOUS_ARGUMENT]
+ *
+ * // The string is only used (as message) in case the function does not throw:
+ * assert.throws(notThrowing, 'Second');
+ * // AssertionError [ERR_ASSERTION]: Missing expected exception: Second
+ *
+ * // If it was intended to match for the error message do this instead:
+ * // It does not throw because the error messages match.
+ * assert.throws(throwingSecond, /Second$/);
+ *
+ * // If the error message does not match, an AssertionError is thrown.
+ * assert.throws(throwingFirst, /Second$/);
+ * // AssertionError [ERR_ASSERTION]
+ * ```
+ *
+ * Due to the confusing error-prone notation, avoid a string as the second
+ * argument.
+ * @since v0.1.21
+ */
+ function throws(block: () => unknown, message?: string | Error): void;
+ function throws(block: () => unknown, error: AssertPredicate, message?: string | Error): void;
+ /**
+ * Asserts that the function `fn` does not throw an error.
+ *
+ * Using `assert.doesNotThrow()` is actually not useful because there
+ * is no benefit in catching an error and then rethrowing it. Instead, consider
+ * adding a comment next to the specific code path that should not throw and keep
+ * error messages as expressive as possible.
+ *
+ * When `assert.doesNotThrow()` is called, it will immediately call the `fn` function.
+ *
+ * If an error is thrown and it is the same type as that specified by the `error` parameter, then an `AssertionError` is thrown. If the error is of a
+ * different type, or if the `error` parameter is undefined, the error is
+ * propagated back to the caller.
+ *
+ * If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
+ * [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), or a validation
+ * function. See {@link throws} for more details.
+ *
+ * The following, for instance, will throw the `TypeError` because there is no
+ * matching error type in the assertion:
+ *
+ * ```js
+ * import assert from 'node:assert/strict';
+ *
+ * assert.doesNotThrow(
+ * () => {
+ * throw new TypeError('Wrong value');
+ * },
+ * SyntaxError,
+ * );
+ * ```
+ *
+ * However, the following will result in an `AssertionError` with the message
+ * 'Got unwanted exception...':
+ *
+ * ```js
+ * import assert from 'node:assert/strict';
+ *
+ * assert.doesNotThrow(
+ * () => {
+ * throw new TypeError('Wrong value');
+ * },
+ * TypeError,
+ * );
+ * ```
+ *
+ * If an `AssertionError` is thrown and a value is provided for the `message` parameter, the value of `message` will be appended to the `AssertionError` message:
+ *
+ * ```js
+ * import assert from 'node:assert/strict';
+ *
+ * assert.doesNotThrow(
+ * () => {
+ * throw new TypeError('Wrong value');
+ * },
+ * /Wrong value/,
+ * 'Whoops',
+ * );
+ * // Throws: AssertionError: Got unwanted exception: Whoops
+ * ```
+ * @since v0.1.21
+ */
+ function doesNotThrow(block: () => unknown, message?: string | Error): void;
+ function doesNotThrow(block: () => unknown, error: AssertPredicate, message?: string | Error): void;
+ /**
+ * Throws `value` if `value` is not `undefined` or `null`. This is useful when
+ * testing the `error` argument in callbacks. The stack trace contains all frames
+ * from the error passed to `ifError()` including the potential new frames for `ifError()` itself.
+ *
+ * ```js
+ * import assert from 'node:assert/strict';
+ *
+ * assert.ifError(null);
+ * // OK
+ * assert.ifError(0);
+ * // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: 0
+ * assert.ifError('error');
+ * // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: 'error'
+ * assert.ifError(new Error());
+ * // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: Error
+ *
+ * // Create some random error frames.
+ * let err;
+ * (function errorFrame() {
+ * err = new Error('test error');
+ * })();
+ *
+ * (function ifErrorFrame() {
+ * assert.ifError(err);
+ * })();
+ * // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: test error
+ * // at ifErrorFrame
+ * // at errorFrame
+ * ```
+ * @since v0.1.97
+ */
+ function ifError(value: unknown): asserts value is null | undefined;
+ /**
+ * Awaits the `asyncFn` promise or, if `asyncFn` is a function, immediately
+ * calls the function and awaits the returned promise to complete. It will then
+ * check that the promise is rejected.
+ *
+ * If `asyncFn` is a function and it throws an error synchronously, `assert.rejects()` will return a rejected `Promise` with that error. If the
+ * function does not return a promise, `assert.rejects()` will return a rejected `Promise` with an [ERR_INVALID_RETURN_VALUE](https://nodejs.org/docs/latest-v25.x/api/errors.html#err_invalid_return_value)
+ * error. In both cases the error handler is skipped.
+ *
+ * Besides the async nature to await the completion behaves identically to {@link throws}.
+ *
+ * If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
+ * [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), a validation function,
+ * an object where each property will be tested for, or an instance of error where
+ * each property will be tested for including the non-enumerable `message` and `name` properties.
+ *
+ * If specified, `message` will be the message provided by the `{@link AssertionError}` if the `asyncFn` fails to reject.
+ *
+ * ```js
+ * import assert from 'node:assert/strict';
+ *
+ * await assert.rejects(
+ * async () => {
+ * throw new TypeError('Wrong value');
+ * },
+ * {
+ * name: 'TypeError',
+ * message: 'Wrong value',
+ * },
+ * );
+ * ```
+ *
+ * ```js
+ * import assert from 'node:assert/strict';
+ *
+ * await assert.rejects(
+ * async () => {
+ * throw new TypeError('Wrong value');
+ * },
+ * (err) => {
+ * assert.strictEqual(err.name, 'TypeError');
+ * assert.strictEqual(err.message, 'Wrong value');
+ * return true;
+ * },
+ * );
+ * ```
+ *
+ * ```js
+ * import assert from 'node:assert/strict';
+ *
+ * assert.rejects(
+ * Promise.reject(new Error('Wrong value')),
+ * Error,
+ * ).then(() => {
+ * // ...
+ * });
+ * ```
+ *
+ * `error` cannot be a string. If a string is provided as the second argument, then `error` is assumed to
+ * be omitted and the string will be used for `message` instead. This can lead to easy-to-miss mistakes. Please read the
+ * example in {@link throws} carefully if using a string as the second argument gets considered.
+ * @since v10.0.0
+ */
+ function rejects(block: (() => Promise) | Promise, message?: string | Error): Promise;
+ function rejects(
+ block: (() => Promise) | Promise,
+ error: AssertPredicate,
+ message?: string | Error,
+ ): Promise;
+ /**
+ * Awaits the `asyncFn` promise or, if `asyncFn` is a function, immediately
+ * calls the function and awaits the returned promise to complete. It will then
+ * check that the promise is not rejected.
+ *
+ * If `asyncFn` is a function and it throws an error synchronously, `assert.doesNotReject()` will return a rejected `Promise` with that error. If
+ * the function does not return a promise, `assert.doesNotReject()` will return a
+ * rejected `Promise` with an [ERR_INVALID_RETURN_VALUE](https://nodejs.org/docs/latest-v25.x/api/errors.html#err_invalid_return_value) error. In both cases
+ * the error handler is skipped.
+ *
+ * Using `assert.doesNotReject()` is actually not useful because there is little
+ * benefit in catching a rejection and then rejecting it again. Instead, consider
+ * adding a comment next to the specific code path that should not reject and keep
+ * error messages as expressive as possible.
+ *
+ * If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
+ * [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), or a validation
+ * function. See {@link throws} for more details.
+ *
+ * Besides the async nature to await the completion behaves identically to {@link doesNotThrow}.
+ *
+ * ```js
+ * import assert from 'node:assert/strict';
+ *
+ * await assert.doesNotReject(
+ * async () => {
+ * throw new TypeError('Wrong value');
+ * },
+ * SyntaxError,
+ * );
+ * ```
+ *
+ * ```js
+ * import assert from 'node:assert/strict';
+ *
+ * assert.doesNotReject(Promise.reject(new TypeError('Wrong value')))
+ * .then(() => {
+ * // ...
+ * });
+ * ```
+ * @since v10.0.0
+ */
+ function doesNotReject(
+ block: (() => Promise) | Promise,
+ message?: string | Error,
+ ): Promise;
+ function doesNotReject(
+ block: (() => Promise) | Promise,
+ error: AssertPredicate,
+ message?: string | Error,
+ ): Promise;
+ /**
+ * Expects the `string` input to match the regular expression.
+ *
+ * ```js
+ * import assert from 'node:assert/strict';
+ *
+ * assert.match('I will fail', /pass/);
+ * // AssertionError [ERR_ASSERTION]: The input did not match the regular ...
+ *
+ * assert.match(123, /pass/);
+ * // AssertionError [ERR_ASSERTION]: The "string" argument must be of type string.
+ *
+ * assert.match('I will pass', /pass/);
+ * // OK
+ * ```
+ *
+ * If the values do not match, or if the `string` argument is of another type than `string`, an `{@link AssertionError}` is thrown with a `message` property set equal
+ * to the value of the `message` parameter. If the `message` parameter is
+ * undefined, a default error message is assigned. If the `message` parameter is an
+ * instance of an [Error](https://nodejs.org/docs/latest-v25.x/api/errors.html#class-error) then it will be thrown instead of the `{@link AssertionError}`.
+ * @since v13.6.0, v12.16.0
+ */
+ function match(value: string, regExp: RegExp, message?: string | Error): void;
+ /**
+ * Expects the `string` input not to match the regular expression.
+ *
+ * ```js
+ * import assert from 'node:assert/strict';
+ *
+ * assert.doesNotMatch('I will fail', /fail/);
+ * // AssertionError [ERR_ASSERTION]: The input was expected to not match the ...
+ *
+ * assert.doesNotMatch(123, /pass/);
+ * // AssertionError [ERR_ASSERTION]: The "string" argument must be of type string.
+ *
+ * assert.doesNotMatch('I will pass', /different/);
+ * // OK
+ * ```
+ *
+ * If the values do match, or if the `string` argument is of another type than `string`, an `{@link AssertionError}` is thrown with a `message` property set equal
+ * to the value of the `message` parameter. If the `message` parameter is
+ * undefined, a default error message is assigned. If the `message` parameter is an
+ * instance of an [Error](https://nodejs.org/docs/latest-v25.x/api/errors.html#class-error) then it will be thrown instead of the `{@link AssertionError}`.
+ * @since v13.6.0, v12.16.0
+ */
+ function doesNotMatch(value: string, regExp: RegExp, message?: string | Error): void;
+ /**
+ * Tests for partial deep equality between the `actual` and `expected` parameters.
+ * "Deep" equality means that the enumerable "own" properties of child objects
+ * are recursively evaluated also by the following rules. "Partial" equality means
+ * that only properties that exist on the `expected` parameter are going to be
+ * compared.
+ *
+ * This method always passes the same test cases as `assert.deepStrictEqual()`,
+ * behaving as a super set of it.
+ * @since v22.13.0
+ */
+ function partialDeepStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void;
+ }
+ namespace assert {
+ export { strict };
+ }
+ export = assert;
+}
+declare module "assert" {
+ import assert = require("node:assert");
+ export = assert;
+}
diff --git a/types/node/v25/assert/strict.d.ts b/types/node/v25/assert/strict.d.ts
new file mode 100644
index 00000000000000..7a9dcf5714b860
--- /dev/null
+++ b/types/node/v25/assert/strict.d.ts
@@ -0,0 +1,59 @@
+declare module "node:assert/strict" {
+ import {
+ Assert,
+ AssertionError,
+ AssertionErrorOptions,
+ AssertOptions,
+ AssertPredicate,
+ AssertStrict,
+ deepStrictEqual,
+ doesNotMatch,
+ doesNotReject,
+ doesNotThrow,
+ fail,
+ ifError,
+ match,
+ notDeepStrictEqual,
+ notStrictEqual,
+ ok,
+ partialDeepStrictEqual,
+ rejects,
+ strictEqual,
+ throws,
+ } from "node:assert";
+ function strict(value: unknown, message?: string | Error): asserts value;
+ namespace strict {
+ export {
+ Assert,
+ AssertionError,
+ AssertionErrorOptions,
+ AssertOptions,
+ AssertPredicate,
+ AssertStrict,
+ deepStrictEqual,
+ deepStrictEqual as deepEqual,
+ doesNotMatch,
+ doesNotReject,
+ doesNotThrow,
+ fail,
+ ifError,
+ match,
+ notDeepStrictEqual,
+ notDeepStrictEqual as notDeepEqual,
+ notStrictEqual,
+ notStrictEqual as notEqual,
+ ok,
+ partialDeepStrictEqual,
+ rejects,
+ strict,
+ strictEqual,
+ strictEqual as equal,
+ throws,
+ };
+ }
+ export = strict;
+}
+declare module "assert/strict" {
+ import strict = require("node:assert/strict");
+ export = strict;
+}
diff --git a/types/node/v25/async_hooks.d.ts b/types/node/v25/async_hooks.d.ts
new file mode 100644
index 00000000000000..ac857ad185ef98
--- /dev/null
+++ b/types/node/v25/async_hooks.d.ts
@@ -0,0 +1,711 @@
+declare module "node:async_hooks" {
+ /**
+ * ```js
+ * import { executionAsyncId } from 'node:async_hooks';
+ * import fs from 'node:fs';
+ *
+ * console.log(executionAsyncId()); // 1 - bootstrap
+ * const path = '.';
+ * fs.open(path, 'r', (err, fd) => {
+ * console.log(executionAsyncId()); // 6 - open()
+ * });
+ * ```
+ *
+ * The ID returned from `executionAsyncId()` is related to execution timing, not
+ * causality (which is covered by `triggerAsyncId()`):
+ *
+ * ```js
+ * const server = net.createServer((conn) => {
+ * // Returns the ID of the server, not of the new connection, because the
+ * // callback runs in the execution scope of the server's MakeCallback().
+ * async_hooks.executionAsyncId();
+ *
+ * }).listen(port, () => {
+ * // Returns the ID of a TickObject (process.nextTick()) because all
+ * // callbacks passed to .listen() are wrapped in a nextTick().
+ * async_hooks.executionAsyncId();
+ * });
+ * ```
+ *
+ * Promise contexts may not get precise `executionAsyncIds` by default.
+ * See the section on [promise execution tracking](https://nodejs.org/docs/latest-v25.x/api/async_hooks.html#promise-execution-tracking).
+ * @since v8.1.0
+ * @return The `asyncId` of the current execution context. Useful to track when something calls.
+ */
+ function executionAsyncId(): number;
+ /**
+ * Resource objects returned by `executionAsyncResource()` are most often internal
+ * Node.js handle objects with undocumented APIs. Using any functions or properties
+ * on the object is likely to crash your application and should be avoided.
+ *
+ * Using `executionAsyncResource()` in the top-level execution context will
+ * return an empty object as there is no handle or request object to use,
+ * but having an object representing the top-level can be helpful.
+ *
+ * ```js
+ * import { open } from 'node:fs';
+ * import { executionAsyncId, executionAsyncResource } from 'node:async_hooks';
+ *
+ * console.log(executionAsyncId(), executionAsyncResource()); // 1 {}
+ * open(new URL(import.meta.url), 'r', (err, fd) => {
+ * console.log(executionAsyncId(), executionAsyncResource()); // 7 FSReqWrap
+ * });
+ * ```
+ *
+ * This can be used to implement continuation local storage without the
+ * use of a tracking `Map` to store the metadata:
+ *
+ * ```js
+ * import { createServer } from 'node:http';
+ * import {
+ * executionAsyncId,
+ * executionAsyncResource,
+ * createHook,
+ * } from 'node:async_hooks';
+ * const sym = Symbol('state'); // Private symbol to avoid pollution
+ *
+ * createHook({
+ * init(asyncId, type, triggerAsyncId, resource) {
+ * const cr = executionAsyncResource();
+ * if (cr) {
+ * resource[sym] = cr[sym];
+ * }
+ * },
+ * }).enable();
+ *
+ * const server = createServer((req, res) => {
+ * executionAsyncResource()[sym] = { state: req.url };
+ * setTimeout(function() {
+ * res.end(JSON.stringify(executionAsyncResource()[sym]));
+ * }, 100);
+ * }).listen(3000);
+ * ```
+ * @since v13.9.0, v12.17.0
+ * @return The resource representing the current execution. Useful to store data within the resource.
+ */
+ function executionAsyncResource(): object;
+ /**
+ * ```js
+ * const server = net.createServer((conn) => {
+ * // The resource that caused (or triggered) this callback to be called
+ * // was that of the new connection. Thus the return value of triggerAsyncId()
+ * // is the asyncId of "conn".
+ * async_hooks.triggerAsyncId();
+ *
+ * }).listen(port, () => {
+ * // Even though all callbacks passed to .listen() are wrapped in a nextTick()
+ * // the callback itself exists because the call to the server's .listen()
+ * // was made. So the return value would be the ID of the server.
+ * async_hooks.triggerAsyncId();
+ * });
+ * ```
+ *
+ * Promise contexts may not get valid `triggerAsyncId`s by default. See
+ * the section on [promise execution tracking](https://nodejs.org/docs/latest-v25.x/api/async_hooks.html#promise-execution-tracking).
+ * @return The ID of the resource responsible for calling the callback that is currently being executed.
+ */
+ function triggerAsyncId(): number;
+ interface HookCallbacks {
+ /**
+ * The [`init` callback](https://nodejs.org/docs/latest-v25.x/api/async_hooks.html#initasyncid-type-triggerasyncid-resource).
+ */
+ init?(asyncId: number, type: string, triggerAsyncId: number, resource: object): void;
+ /**
+ * The [`before` callback](https://nodejs.org/docs/latest-v25.x/api/async_hooks.html#beforeasyncid).
+ */
+ before?(asyncId: number): void;
+ /**
+ * The [`after` callback](https://nodejs.org/docs/latest-v25.x/api/async_hooks.html#afterasyncid).
+ */
+ after?(asyncId: number): void;
+ /**
+ * The [`promiseResolve` callback](https://nodejs.org/docs/latest-v25.x/api/async_hooks.html#promiseresolveasyncid).
+ */
+ promiseResolve?(asyncId: number): void;
+ /**
+ * The [`destroy` callback](https://nodejs.org/docs/latest-v25.x/api/async_hooks.html#destroyasyncid).
+ */
+ destroy?(asyncId: number): void;
+ /**
+ * Whether the hook should track `Promise`s. Cannot be `false` if
+ * `promiseResolve` is set.
+ * @default true
+ */
+ trackPromises?: boolean | undefined;
+ }
+ interface AsyncHook {
+ /**
+ * Enable the callbacks for a given AsyncHook instance. If no callbacks are provided enabling is a noop.
+ */
+ enable(): this;
+ /**
+ * Disable the callbacks for a given AsyncHook instance from the global pool of AsyncHook callbacks to be executed. Once a hook has been disabled it will not be called again until enabled.
+ */
+ disable(): this;
+ }
+ /**
+ * Registers functions to be called for different lifetime events of each async
+ * operation.
+ *
+ * The callbacks `init()`/`before()`/`after()`/`destroy()` are called for the
+ * respective asynchronous event during a resource's lifetime.
+ *
+ * All callbacks are optional. For example, if only resource cleanup needs to
+ * be tracked, then only the `destroy` callback needs to be passed. The
+ * specifics of all functions that can be passed to `callbacks` is in the
+ * [Hook Callbacks](https://nodejs.org/docs/latest-v25.x/api/async_hooks.html#hook-callbacks) section.
+ *
+ * ```js
+ * import { createHook } from 'node:async_hooks';
+ *
+ * const asyncHook = createHook({
+ * init(asyncId, type, triggerAsyncId, resource) { },
+ * destroy(asyncId) { },
+ * });
+ * ```
+ *
+ * The callbacks will be inherited via the prototype chain:
+ *
+ * ```js
+ * class MyAsyncCallbacks {
+ * init(asyncId, type, triggerAsyncId, resource) { }
+ * destroy(asyncId) {}
+ * }
+ *
+ * class MyAddedCallbacks extends MyAsyncCallbacks {
+ * before(asyncId) { }
+ * after(asyncId) { }
+ * }
+ *
+ * const asyncHook = async_hooks.createHook(new MyAddedCallbacks());
+ * ```
+ *
+ * Because promises are asynchronous resources whose lifecycle is tracked
+ * via the async hooks mechanism, the `init()`, `before()`, `after()`, and
+ * `destroy()` callbacks _must not_ be async functions that return promises.
+ * @since v8.1.0
+ * @param options The [Hook Callbacks](https://nodejs.org/docs/latest-v25.x/api/async_hooks.html#hook-callbacks) to register
+ * @returns Instance used for disabling and enabling hooks
+ */
+ function createHook(options: HookCallbacks): AsyncHook;
+ interface AsyncResourceOptions {
+ /**
+ * The ID of the execution context that created this async event.
+ * @default executionAsyncId()
+ */
+ triggerAsyncId?: number | undefined;
+ /**
+ * Disables automatic `emitDestroy` when the object is garbage collected.
+ * This usually does not need to be set (even if `emitDestroy` is called
+ * manually), unless the resource's `asyncId` is retrieved and the
+ * sensitive API's `emitDestroy` is called with it.
+ * @default false
+ */
+ requireManualDestroy?: boolean | undefined;
+ }
+ /**
+ * The class `AsyncResource` is designed to be extended by the embedder's async
+ * resources. Using this, users can easily trigger the lifetime events of their
+ * own resources.
+ *
+ * The `init` hook will trigger when an `AsyncResource` is instantiated.
+ *
+ * The following is an overview of the `AsyncResource` API.
+ *
+ * ```js
+ * import { AsyncResource, executionAsyncId } from 'node:async_hooks';
+ *
+ * // AsyncResource() is meant to be extended. Instantiating a
+ * // new AsyncResource() also triggers init. If triggerAsyncId is omitted then
+ * // async_hook.executionAsyncId() is used.
+ * const asyncResource = new AsyncResource(
+ * type, { triggerAsyncId: executionAsyncId(), requireManualDestroy: false },
+ * );
+ *
+ * // Run a function in the execution context of the resource. This will
+ * // * establish the context of the resource
+ * // * trigger the AsyncHooks before callbacks
+ * // * call the provided function `fn` with the supplied arguments
+ * // * trigger the AsyncHooks after callbacks
+ * // * restore the original execution context
+ * asyncResource.runInAsyncScope(fn, thisArg, ...args);
+ *
+ * // Call AsyncHooks destroy callbacks.
+ * asyncResource.emitDestroy();
+ *
+ * // Return the unique ID assigned to the AsyncResource instance.
+ * asyncResource.asyncId();
+ *
+ * // Return the trigger ID for the AsyncResource instance.
+ * asyncResource.triggerAsyncId();
+ * ```
+ */
+ class AsyncResource {
+ /**
+ * AsyncResource() is meant to be extended. Instantiating a
+ * new AsyncResource() also triggers init. If triggerAsyncId is omitted then
+ * async_hook.executionAsyncId() is used.
+ * @param type The type of async event.
+ * @param triggerAsyncId The ID of the execution context that created
+ * this async event (default: `executionAsyncId()`), or an
+ * AsyncResourceOptions object (since v9.3.0)
+ */
+ constructor(type: string, triggerAsyncId?: number | AsyncResourceOptions);
+ /**
+ * Binds the given function to the current execution context.
+ * @since v14.8.0, v12.19.0
+ * @param fn The function to bind to the current execution context.
+ * @param type An optional name to associate with the underlying `AsyncResource`.
+ */
+ static bind any, ThisArg>(
+ fn: Func,
+ type?: string,
+ thisArg?: ThisArg,
+ ): Func;
+ /**
+ * Binds the given function to execute to this `AsyncResource`'s scope.
+ * @since v14.8.0, v12.19.0
+ * @param fn The function to bind to the current `AsyncResource`.
+ */
+ bind any>(fn: Func): Func;
+ /**
+ * Call the provided function with the provided arguments in the execution context
+ * of the async resource. This will establish the context, trigger the AsyncHooks
+ * before callbacks, call the function, trigger the AsyncHooks after callbacks, and
+ * then restore the original execution context.
+ * @since v9.6.0
+ * @param fn The function to call in the execution context of this async resource.
+ * @param thisArg The receiver to be used for the function call.
+ * @param args Optional arguments to pass to the function.
+ */
+ runInAsyncScope(
+ fn: (this: This, ...args: any[]) => Result,
+ thisArg?: This,
+ ...args: any[]
+ ): Result;
+ /**
+ * Call all `destroy` hooks. This should only ever be called once. An error will
+ * be thrown if it is called more than once. This **must** be manually called. If
+ * the resource is left to be collected by the GC then the `destroy` hooks will
+ * never be called.
+ * @return A reference to `asyncResource`.
+ */
+ emitDestroy(): this;
+ /**
+ * @return The unique `asyncId` assigned to the resource.
+ */
+ asyncId(): number;
+ /**
+ * @return The same `triggerAsyncId` that is passed to the `AsyncResource` constructor.
+ */
+ triggerAsyncId(): number;
+ }
+ interface AsyncLocalStorageOptions {
+ /**
+ * The default value to be used when no store is provided.
+ */
+ defaultValue?: any;
+ /**
+ * A name for the `AsyncLocalStorage` value.
+ */
+ name?: string | undefined;
+ }
+ /**
+ * This class creates stores that stay coherent through asynchronous operations.
+ *
+ * While you can create your own implementation on top of the `node:async_hooks` module, `AsyncLocalStorage` should be preferred as it is a performant and memory
+ * safe implementation that involves significant optimizations that are non-obvious
+ * to implement.
+ *
+ * The following example uses `AsyncLocalStorage` to build a simple logger
+ * that assigns IDs to incoming HTTP requests and includes them in messages
+ * logged within each request.
+ *
+ * ```js
+ * import http from 'node:http';
+ * import { AsyncLocalStorage } from 'node:async_hooks';
+ *
+ * const asyncLocalStorage = new AsyncLocalStorage();
+ *
+ * function logWithId(msg) {
+ * const id = asyncLocalStorage.getStore();
+ * console.log(`${id !== undefined ? id : '-'}:`, msg);
+ * }
+ *
+ * let idSeq = 0;
+ * http.createServer((req, res) => {
+ * asyncLocalStorage.run(idSeq++, () => {
+ * logWithId('start');
+ * // Imagine any chain of async operations here
+ * setImmediate(() => {
+ * logWithId('finish');
+ * res.end();
+ * });
+ * });
+ * }).listen(8080);
+ *
+ * http.get('http://localhost:8080');
+ * http.get('http://localhost:8080');
+ * // Prints:
+ * // 0: start
+ * // 0: finish
+ * // 1: start
+ * // 1: finish
+ * ```
+ *
+ * Each instance of `AsyncLocalStorage` maintains an independent storage context.
+ * Multiple instances can safely exist simultaneously without risk of interfering
+ * with each other's data.
+ * @since v13.10.0, v12.17.0
+ */
+ class AsyncLocalStorage {
+ /**
+ * Creates a new instance of `AsyncLocalStorage`. Store is only provided within a
+ * `run()` call or after an `enterWith()` call.
+ */
+ constructor(options?: AsyncLocalStorageOptions);
+ /**
+ * Binds the given function to the current execution context.
+ * @since v19.8.0
+ * @param fn The function to bind to the current execution context.
+ * @return A new function that calls `fn` within the captured execution context.
+ */
+ static bind any>(fn: Func): Func;
+ /**
+ * Captures the current execution context and returns a function that accepts a
+ * function as an argument. Whenever the returned function is called, it
+ * calls the function passed to it within the captured context.
+ *
+ * ```js
+ * const asyncLocalStorage = new AsyncLocalStorage();
+ * const runInAsyncScope = asyncLocalStorage.run(123, () => AsyncLocalStorage.snapshot());
+ * const result = asyncLocalStorage.run(321, () => runInAsyncScope(() => asyncLocalStorage.getStore()));
+ * console.log(result); // returns 123
+ * ```
+ *
+ * AsyncLocalStorage.snapshot() can replace the use of AsyncResource for simple
+ * async context tracking purposes, for example:
+ *
+ * ```js
+ * class Foo {
+ * #runInAsyncScope = AsyncLocalStorage.snapshot();
+ *
+ * get() { return this.#runInAsyncScope(() => asyncLocalStorage.getStore()); }
+ * }
+ *
+ * const foo = asyncLocalStorage.run(123, () => new Foo());
+ * console.log(asyncLocalStorage.run(321, () => foo.get())); // returns 123
+ * ```
+ * @since v19.8.0
+ * @return A new function with the signature `(fn: (...args) : R, ...args) : R`.
+ */
+ static snapshot(): (fn: (...args: TArgs) => R, ...args: TArgs) => R;
+ /**
+ * Disables the instance of `AsyncLocalStorage`. All subsequent calls
+ * to `asyncLocalStorage.getStore()` will return `undefined` until `asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()` is called again.
+ *
+ * When calling `asyncLocalStorage.disable()`, all current contexts linked to the
+ * instance will be exited.
+ *
+ * Calling `asyncLocalStorage.disable()` is required before the `asyncLocalStorage` can be garbage collected. This does not apply to stores
+ * provided by the `asyncLocalStorage`, as those objects are garbage collected
+ * along with the corresponding async resources.
+ *
+ * Use this method when the `asyncLocalStorage` is not in use anymore
+ * in the current process.
+ * @since v13.10.0, v12.17.0
+ * @experimental
+ */
+ disable(): void;
+ /**
+ * Returns the current store.
+ * If called outside of an asynchronous context initialized by
+ * calling `asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()`, it
+ * returns `undefined`.
+ * @since v13.10.0, v12.17.0
+ */
+ getStore(): T | undefined;
+ /**
+ * The name of the `AsyncLocalStorage` instance if provided.
+ * @since v24.0.0
+ */
+ readonly name: string;
+ /**
+ * Runs a function synchronously within a context and returns its
+ * return value. The store is not accessible outside of the callback function.
+ * The store is accessible to any asynchronous operations created within the
+ * callback.
+ *
+ * The optional `args` are passed to the callback function.
+ *
+ * If the callback function throws an error, the error is thrown by `run()` too.
+ * The stacktrace is not impacted by this call and the context is exited.
+ *
+ * Example:
+ *
+ * ```js
+ * const store = { id: 2 };
+ * try {
+ * asyncLocalStorage.run(store, () => {
+ * asyncLocalStorage.getStore(); // Returns the store object
+ * setTimeout(() => {
+ * asyncLocalStorage.getStore(); // Returns the store object
+ * }, 200);
+ * throw new Error();
+ * });
+ * } catch (e) {
+ * asyncLocalStorage.getStore(); // Returns undefined
+ * // The error will be caught here
+ * }
+ * ```
+ * @since v13.10.0, v12.17.0
+ */
+ run(store: T, callback: () => R): R;
+ run(store: T, callback: (...args: TArgs) => R, ...args: TArgs): R;
+ /**
+ * Runs a function synchronously outside of a context and returns its
+ * return value. The store is not accessible within the callback function or
+ * the asynchronous operations created within the callback. Any `getStore()` call done within the callback function will always return `undefined`.
+ *
+ * The optional `args` are passed to the callback function.
+ *
+ * If the callback function throws an error, the error is thrown by `exit()` too.
+ * The stacktrace is not impacted by this call and the context is re-entered.
+ *
+ * Example:
+ *
+ * ```js
+ * // Within a call to run
+ * try {
+ * asyncLocalStorage.getStore(); // Returns the store object or value
+ * asyncLocalStorage.exit(() => {
+ * asyncLocalStorage.getStore(); // Returns undefined
+ * throw new Error();
+ * });
+ * } catch (e) {
+ * asyncLocalStorage.getStore(); // Returns the same object or value
+ * // The error will be caught here
+ * }
+ * ```
+ * @since v13.10.0, v12.17.0
+ * @experimental
+ */
+ exit(callback: (...args: TArgs) => R, ...args: TArgs): R;
+ /**
+ * Creates a disposable scope that enters the given store and automatically
+ * restores the previous store value when the scope is disposed. This method is
+ * designed to work with JavaScript's explicit resource management (`using` syntax).
+ *
+ * Example:
+ *
+ * ```js
+ * import { AsyncLocalStorage } from 'node:async_hooks';
+ *
+ * const asyncLocalStorage = new AsyncLocalStorage();
+ *
+ * {
+ * using _ = asyncLocalStorage.withScope('my-store');
+ * console.log(asyncLocalStorage.getStore()); // Prints: my-store
+ * }
+ *
+ * console.log(asyncLocalStorage.getStore()); // Prints: undefined
+ * ```
+ *
+ * The `withScope()` method is particularly useful for managing context in
+ * synchronous code where you want to ensure the previous store value is restored
+ * when exiting a block, even if an error is thrown.
+ *
+ * ```js
+ * import { AsyncLocalStorage } from 'node:async_hooks';
+ *
+ * const asyncLocalStorage = new AsyncLocalStorage();
+ *
+ * try {
+ * using _ = asyncLocalStorage.withScope('my-store');
+ * console.log(asyncLocalStorage.getStore()); // Prints: my-store
+ * throw new Error('test');
+ * } catch (e) {
+ * // Store is automatically restored even after error
+ * console.log(asyncLocalStorage.getStore()); // Prints: undefined
+ * }
+ * ```
+ *
+ * **Important:** When using `withScope()` in async functions before the first
+ * `await`, be aware that the scope change will affect the caller's context. The
+ * synchronous portion of an async function (before the first `await`) runs
+ * immediately when called, and when it reaches the first `await`, it returns the
+ * promise to the caller. At that point, the scope change becomes visible in the
+ * caller's context and will persist in subsequent synchronous code until something
+ * else changes the scope value. For async operations, prefer using `run()` which
+ * properly isolates context across async boundaries.
+ *
+ * ```js
+ * import { AsyncLocalStorage } from 'node:async_hooks';
+ *
+ * const asyncLocalStorage = new AsyncLocalStorage();
+ *
+ * async function example() {
+ * using _ = asyncLocalStorage.withScope('my-store');
+ * console.log(asyncLocalStorage.getStore()); // Prints: my-store
+ * await someAsyncOperation(); // Function pauses here and returns promise
+ * console.log(asyncLocalStorage.getStore()); // Prints: my-store
+ * }
+ *
+ * // Calling without await
+ * example(); // Synchronous portion runs, then pauses at first await
+ * // After the promise is returned, the scope 'my-store' is now active in caller!
+ * console.log(asyncLocalStorage.getStore()); // Prints: my-store (unexpected!)
+ * ```
+ * @since v25.9.0
+ * @experimental
+ */
+ withScope(store: T): RunScope;
+ /**
+ * Transitions into the context for the remainder of the current
+ * synchronous execution and then persists the store through any following
+ * asynchronous calls.
+ *
+ * Example:
+ *
+ * ```js
+ * const store = { id: 1 };
+ * // Replaces previous store with the given store object
+ * asyncLocalStorage.enterWith(store);
+ * asyncLocalStorage.getStore(); // Returns the store object
+ * someAsyncOperation(() => {
+ * asyncLocalStorage.getStore(); // Returns the same object
+ * });
+ * ```
+ *
+ * This transition will continue for the _entire_ synchronous execution.
+ * This means that if, for example, the context is entered within an event
+ * handler subsequent event handlers will also run within that context unless
+ * specifically bound to another context with an `AsyncResource`. That is why `run()` should be preferred over `enterWith()` unless there are strong reasons
+ * to use the latter method.
+ *
+ * ```js
+ * const store = { id: 1 };
+ *
+ * emitter.on('my-event', () => {
+ * asyncLocalStorage.enterWith(store);
+ * });
+ * emitter.on('my-event', () => {
+ * asyncLocalStorage.getStore(); // Returns the same object
+ * });
+ *
+ * asyncLocalStorage.getStore(); // Returns undefined
+ * emitter.emit('my-event');
+ * asyncLocalStorage.getStore(); // Returns the same object
+ * ```
+ * @since v13.11.0, v12.17.0
+ * @experimental
+ */
+ enterWith(store: T): void;
+ }
+ /**
+ * A disposable scope returned by `asyncLocalStorage.withScope()` that
+ * automatically restores the previous store value when disposed. This class
+ * implements the [Explicit Resource Management](https://github.com/tc39/proposal-explicit-resource-management) protocol and is designed to work
+ * with JavaScript's `using` syntax.
+ *
+ * The scope automatically restores the previous store value when the `using` block
+ * exits, whether through normal completion or by throwing an error.
+ * @since v25.9.0
+ * @experimental
+ */
+ interface RunScope extends Disposable {
+ /**
+ * Explicitly ends the scope and restores the previous store value. This method
+ * is idempotent: calling it multiple times has the same effect as calling it once.
+ *
+ * The `[Symbol.dispose]()` method defers to `dispose()`.
+ *
+ * If `withScope()` is called without the `using` keyword, `dispose()` must be
+ * called manually to restore the previous store value. Forgetting to call
+ * `dispose()` will cause the store value to persist for the remainder of the
+ * current execution context:
+ *
+ * ```js
+ * import { AsyncLocalStorage } from 'node:async_hooks';
+ *
+ * const storage = new AsyncLocalStorage();
+ *
+ * // Without using, the scope must be disposed manually
+ * const scope = storage.withScope('my-store');
+ * // storage.getStore() === 'my-store' here
+ *
+ * scope.dispose(); // Restore previous value
+ * // storage.getStore() === undefined here
+ * ```
+ * @since v25.9.0
+ */
+ dispose(): void;
+ }
+ /**
+ * @since v17.2.0, v16.14.0
+ * @return A map of provider types to the corresponding numeric id.
+ * This map contains all the event types that might be emitted by the `async_hooks.init()` event.
+ */
+ namespace asyncWrapProviders {
+ const NONE: number;
+ const DIRHANDLE: number;
+ const DNSCHANNEL: number;
+ const ELDHISTOGRAM: number;
+ const FILEHANDLE: number;
+ const FILEHANDLECLOSEREQ: number;
+ const FIXEDSIZEBLOBCOPY: number;
+ const FSEVENTWRAP: number;
+ const FSREQCALLBACK: number;
+ const FSREQPROMISE: number;
+ const GETADDRINFOREQWRAP: number;
+ const GETNAMEINFOREQWRAP: number;
+ const HEAPSNAPSHOT: number;
+ const HTTP2SESSION: number;
+ const HTTP2STREAM: number;
+ const HTTP2PING: number;
+ const HTTP2SETTINGS: number;
+ const HTTPINCOMINGMESSAGE: number;
+ const HTTPCLIENTREQUEST: number;
+ const JSSTREAM: number;
+ const JSUDPWRAP: number;
+ const MESSAGEPORT: number;
+ const PIPECONNECTWRAP: number;
+ const PIPESERVERWRAP: number;
+ const PIPEWRAP: number;
+ const PROCESSWRAP: number;
+ const PROMISE: number;
+ const QUERYWRAP: number;
+ const SHUTDOWNWRAP: number;
+ const SIGNALWRAP: number;
+ const STATWATCHER: number;
+ const STREAMPIPE: number;
+ const TCPCONNECTWRAP: number;
+ const TCPSERVERWRAP: number;
+ const TCPWRAP: number;
+ const TTYWRAP: number;
+ const UDPSENDWRAP: number;
+ const UDPWRAP: number;
+ const SIGINTWATCHDOG: number;
+ const WORKER: number;
+ const WORKERHEAPSNAPSHOT: number;
+ const WRITEWRAP: number;
+ const ZLIB: number;
+ const CHECKPRIMEREQUEST: number;
+ const PBKDF2REQUEST: number;
+ const KEYPAIRGENREQUEST: number;
+ const KEYGENREQUEST: number;
+ const KEYEXPORTREQUEST: number;
+ const CIPHERREQUEST: number;
+ const DERIVEBITSREQUEST: number;
+ const HASHREQUEST: number;
+ const RANDOMBYTESREQUEST: number;
+ const RANDOMPRIMEREQUEST: number;
+ const SCRYPTREQUEST: number;
+ const SIGNREQUEST: number;
+ const TLSWRAP: number;
+ const VERIFYREQUEST: number;
+ }
+}
+declare module "async_hooks" {
+ export * from "node:async_hooks";
+}
diff --git a/types/node/v25/buffer.buffer.d.ts b/types/node/v25/buffer.buffer.d.ts
new file mode 100644
index 00000000000000..a6c4b256c987aa
--- /dev/null
+++ b/types/node/v25/buffer.buffer.d.ts
@@ -0,0 +1,466 @@
+declare module "node:buffer" {
+ type ImplicitArrayBuffer> = T extends
+ { valueOf(): infer V extends ArrayBufferLike } ? V : T;
+ global {
+ interface BufferConstructor {
+ // see buffer.d.ts for implementation shared with all TypeScript versions
+
+ /**
+ * Allocates a new buffer containing the given {str}.
+ *
+ * @param str String to store in buffer.
+ * @param encoding encoding to use, optional. Default is 'utf8'
+ * @deprecated since v10.0.0 - Use `Buffer.from(string[, encoding])` instead.
+ */
+ new(str: string, encoding?: BufferEncoding): Buffer;
+ /**
+ * Allocates a new buffer of {size} octets.
+ *
+ * @param size count of octets to allocate.
+ * @deprecated since v10.0.0 - Use `Buffer.alloc()` instead (also see `Buffer.allocUnsafe()`).
+ */
+ new(size: number): Buffer;
+ /**
+ * Allocates a new buffer containing the given {array} of octets.
+ *
+ * @param array The octets to store.
+ * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
+ */
+ new(array: ArrayLike): Buffer;
+ /**
+ * Produces a Buffer backed by the same allocated memory as
+ * the given {ArrayBuffer}/{SharedArrayBuffer}.
+ *
+ * @param arrayBuffer The ArrayBuffer with which to share memory.
+ * @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead.
+ */
+ new(arrayBuffer: TArrayBuffer): Buffer;
+ /**
+ * Allocates a new `Buffer` using an `array` of bytes in the range `0` – `255`.
+ * Array entries outside that range will be truncated to fit into it.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * // Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'.
+ * const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
+ * ```
+ *
+ * If `array` is an `Array`-like object (that is, one with a `length` property of
+ * type `number`), it is treated as if it is an array, unless it is a `Buffer` or
+ * a `Uint8Array`. This means all other `TypedArray` variants get treated as an
+ * `Array`. To create a `Buffer` from the bytes backing a `TypedArray`, use
+ * `Buffer.copyBytesFrom()`.
+ *
+ * A `TypeError` will be thrown if `array` is not an `Array` or another type
+ * appropriate for `Buffer.from()` variants.
+ *
+ * `Buffer.from(array)` and `Buffer.from(string)` may also use the internal
+ * `Buffer` pool like `Buffer.allocUnsafe()` does.
+ * @since v5.10.0
+ */
+ from(array: WithImplicitCoercion>): Buffer;
+ /**
+ * This creates a view of the `ArrayBuffer` without copying the underlying
+ * memory. For example, when passed a reference to the `.buffer` property of a
+ * `TypedArray` instance, the newly created `Buffer` will share the same
+ * allocated memory as the `TypedArray`'s underlying `ArrayBuffer`.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const arr = new Uint16Array(2);
+ *
+ * arr[0] = 5000;
+ * arr[1] = 4000;
+ *
+ * // Shares memory with `arr`.
+ * const buf = Buffer.from(arr.buffer);
+ *
+ * console.log(buf);
+ * // Prints:
+ *
+ * // Changing the original Uint16Array changes the Buffer also.
+ * arr[1] = 6000;
+ *
+ * console.log(buf);
+ * // Prints:
+ * ```
+ *
+ * The optional `byteOffset` and `length` arguments specify a memory range within
+ * the `arrayBuffer` that will be shared by the `Buffer`.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const ab = new ArrayBuffer(10);
+ * const buf = Buffer.from(ab, 0, 2);
+ *
+ * console.log(buf.length);
+ * // Prints: 2
+ * ```
+ *
+ * A `TypeError` will be thrown if `arrayBuffer` is not an `ArrayBuffer` or a
+ * `SharedArrayBuffer` or another type appropriate for `Buffer.from()`
+ * variants.
+ *
+ * It is important to remember that a backing `ArrayBuffer` can cover a range
+ * of memory that extends beyond the bounds of a `TypedArray` view. A new
+ * `Buffer` created using the `buffer` property of a `TypedArray` may extend
+ * beyond the range of the `TypedArray`:
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const arrA = Uint8Array.from([0x63, 0x64, 0x65, 0x66]); // 4 elements
+ * const arrB = new Uint8Array(arrA.buffer, 1, 2); // 2 elements
+ * console.log(arrA.buffer === arrB.buffer); // true
+ *
+ * const buf = Buffer.from(arrB.buffer);
+ * console.log(buf);
+ * // Prints:
+ * ```
+ * @since v5.10.0
+ * @param arrayBuffer An `ArrayBuffer`, `SharedArrayBuffer`, for example the
+ * `.buffer` property of a `TypedArray`.
+ * @param byteOffset Index of first byte to expose. **Default:** `0`.
+ * @param length Number of bytes to expose. **Default:**
+ * `arrayBuffer.byteLength - byteOffset`.
+ */
+ from>(
+ arrayBuffer: TArrayBuffer,
+ byteOffset?: number,
+ length?: number,
+ ): Buffer>;
+ /**
+ * Creates a new `Buffer` containing `string`. The `encoding` parameter identifies
+ * the character encoding to be used when converting `string` into bytes.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf1 = Buffer.from('this is a tést');
+ * const buf2 = Buffer.from('7468697320697320612074c3a97374', 'hex');
+ *
+ * console.log(buf1.toString());
+ * // Prints: this is a tést
+ * console.log(buf2.toString());
+ * // Prints: this is a tést
+ * console.log(buf1.toString('latin1'));
+ * // Prints: this is a tést
+ * ```
+ *
+ * A `TypeError` will be thrown if `string` is not a string or another type
+ * appropriate for `Buffer.from()` variants.
+ *
+ * `Buffer.from(string)` may also use the internal `Buffer` pool like
+ * `Buffer.allocUnsafe()` does.
+ * @since v5.10.0
+ * @param string A string to encode.
+ * @param encoding The encoding of `string`. **Default:** `'utf8'`.
+ */
+ from(string: WithImplicitCoercion, encoding?: BufferEncoding): Buffer;
+ from(arrayOrString: WithImplicitCoercion | string>): Buffer;
+ /**
+ * Creates a new Buffer using the passed {data}
+ * @param values to create a new Buffer
+ */
+ of(...items: number[]): Buffer;
+ /**
+ * Returns a new `Buffer` which is the result of concatenating all the `Buffer` instances in the `list` together.
+ *
+ * If the list has no items, or if the `totalLength` is 0, then a new zero-length `Buffer` is returned.
+ *
+ * If `totalLength` is not provided, it is calculated from the `Buffer` instances
+ * in `list` by adding their lengths.
+ *
+ * If `totalLength` is provided, it must be an unsigned integer. If the
+ * combined length of the `Buffer`s in `list` exceeds `totalLength`, the result is
+ * truncated to `totalLength`. If the combined length of the `Buffer`s in `list` is
+ * less than `totalLength`, the remaining space is filled with zeros.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * // Create a single `Buffer` from a list of three `Buffer` instances.
+ *
+ * const buf1 = Buffer.alloc(10);
+ * const buf2 = Buffer.alloc(14);
+ * const buf3 = Buffer.alloc(18);
+ * const totalLength = buf1.length + buf2.length + buf3.length;
+ *
+ * console.log(totalLength);
+ * // Prints: 42
+ *
+ * const bufA = Buffer.concat([buf1, buf2, buf3], totalLength);
+ *
+ * console.log(bufA);
+ * // Prints:
+ * console.log(bufA.length);
+ * // Prints: 42
+ * ```
+ *
+ * `Buffer.concat()` may also use the internal `Buffer` pool like `Buffer.allocUnsafe()` does.
+ * @since v0.7.11
+ * @param list List of `Buffer` or {@link Uint8Array} instances to concatenate.
+ * @param totalLength Total length of the `Buffer` instances in `list` when concatenated.
+ */
+ concat(list: readonly Uint8Array[], totalLength?: number): Buffer;
+ /**
+ * Copies the underlying memory of `view` into a new `Buffer`.
+ *
+ * ```js
+ * const u16 = new Uint16Array([0, 0xffff]);
+ * const buf = Buffer.copyBytesFrom(u16, 1, 1);
+ * u16[1] = 0;
+ * console.log(buf.length); // 2
+ * console.log(buf[0]); // 255
+ * console.log(buf[1]); // 255
+ * ```
+ * @since v19.8.0
+ * @param view The {TypedArray} to copy.
+ * @param [offset=0] The starting offset within `view`.
+ * @param [length=view.length - offset] The number of elements from `view` to copy.
+ */
+ copyBytesFrom(view: NodeJS.TypedArray, offset?: number, length?: number): Buffer;
+ /**
+ * Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the`Buffer` will be zero-filled.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.alloc(5);
+ *
+ * console.log(buf);
+ * // Prints:
+ * ```
+ *
+ * If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown.
+ *
+ * If `fill` is specified, the allocated `Buffer` will be initialized by calling `buf.fill(fill)`.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.alloc(5, 'a');
+ *
+ * console.log(buf);
+ * // Prints:
+ * ```
+ *
+ * If both `fill` and `encoding` are specified, the allocated `Buffer` will be
+ * initialized by calling `buf.fill(fill, encoding)`.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');
+ *
+ * console.log(buf);
+ * // Prints:
+ * ```
+ *
+ * Calling `Buffer.alloc()` can be measurably slower than the alternative `Buffer.allocUnsafe()` but ensures that the newly created `Buffer` instance
+ * contents will never contain sensitive data from previous allocations, including
+ * data that might not have been allocated for `Buffer`s.
+ *
+ * A `TypeError` will be thrown if `size` is not a number.
+ * @since v5.10.0
+ * @param size The desired length of the new `Buffer`.
+ * @param [fill=0] A value to pre-fill the new `Buffer` with.
+ * @param [encoding='utf8'] If `fill` is a string, this is its encoding.
+ */
+ alloc(size: number, fill?: string | Uint8Array | number, encoding?: BufferEncoding): Buffer;
+ /**
+ * Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown.
+ *
+ * The underlying memory for `Buffer` instances created in this way is _not_
+ * _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `Buffer.alloc()` instead to initialize`Buffer` instances with zeroes.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.allocUnsafe(10);
+ *
+ * console.log(buf);
+ * // Prints (contents may vary):
+ *
+ * buf.fill(0);
+ *
+ * console.log(buf);
+ * // Prints:
+ * ```
+ *
+ * A `TypeError` will be thrown if `size` is not a number.
+ *
+ * The `Buffer` module pre-allocates an internal `Buffer` instance of
+ * size `Buffer.poolSize` that is used as a pool for the fast allocation of new `Buffer` instances created using `Buffer.allocUnsafe()`, `Buffer.from(array)`,
+ * and `Buffer.concat()` only when `size` is less than `Buffer.poolSize >>> 1` (floor of `Buffer.poolSize` divided by two).
+ *
+ * Use of this pre-allocated internal memory pool is a key difference between
+ * calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`.
+ * Specifically, `Buffer.alloc(size, fill)` will _never_ use the internal `Buffer`pool, while `Buffer.allocUnsafe(size).fill(fill)`_will_ use the internal`Buffer` pool if `size` is less
+ * than or equal to half `Buffer.poolSize`. The
+ * difference is subtle but can be important when an application requires the
+ * additional performance that `Buffer.allocUnsafe()` provides.
+ * @since v5.10.0
+ * @param size The desired length of the new `Buffer`.
+ */
+ allocUnsafe(size: number): Buffer;
+ /**
+ * Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown. A zero-length `Buffer` is created if
+ * `size` is 0.
+ *
+ * The underlying memory for `Buffer` instances created in this way is _not_
+ * _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `buf.fill(0)` to initialize
+ * such `Buffer` instances with zeroes.
+ *
+ * When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances,
+ * allocations under 4 KiB are sliced from a single pre-allocated `Buffer`. This
+ * allows applications to avoid the garbage collection overhead of creating many
+ * individually allocated `Buffer` instances. This approach improves both
+ * performance and memory usage by eliminating the need to track and clean up as
+ * many individual `ArrayBuffer` objects.
+ *
+ * However, in the case where a developer may need to retain a small chunk of
+ * memory from a pool for an indeterminate amount of time, it may be appropriate
+ * to create an un-pooled `Buffer` instance using `Buffer.allocUnsafeSlow()` and
+ * then copying out the relevant bits.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * // Need to keep around a few small chunks of memory.
+ * const store = [];
+ *
+ * socket.on('readable', () => {
+ * let data;
+ * while (null !== (data = readable.read())) {
+ * // Allocate for retained data.
+ * const sb = Buffer.allocUnsafeSlow(10);
+ *
+ * // Copy the data into the new allocation.
+ * data.copy(sb, 0, 0, 10);
+ *
+ * store.push(sb);
+ * }
+ * });
+ * ```
+ *
+ * A `TypeError` will be thrown if `size` is not a number.
+ * @since v5.12.0
+ * @param size The desired length of the new `Buffer`.
+ */
+ allocUnsafeSlow(size: number): Buffer;
+ }
+ interface Buffer extends Uint8Array {
+ // see buffer.d.ts for implementation shared with all TypeScript versions
+
+ /**
+ * Returns a new `Buffer` that references the same memory as the original, but
+ * offset and cropped by the `start` and `end` indices.
+ *
+ * This method is not compatible with the `Uint8Array.prototype.slice()`,
+ * which is a superclass of `Buffer`. To copy the slice, use`Uint8Array.prototype.slice()`.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.from('buffer');
+ *
+ * const copiedBuf = Uint8Array.prototype.slice.call(buf);
+ * copiedBuf[0]++;
+ * console.log(copiedBuf.toString());
+ * // Prints: cuffer
+ *
+ * console.log(buf.toString());
+ * // Prints: buffer
+ *
+ * // With buf.slice(), the original buffer is modified.
+ * const notReallyCopiedBuf = buf.slice();
+ * notReallyCopiedBuf[0]++;
+ * console.log(notReallyCopiedBuf.toString());
+ * // Prints: cuffer
+ * console.log(buf.toString());
+ * // Also prints: cuffer (!)
+ * ```
+ * @since v0.3.0
+ * @deprecated Use `subarray` instead.
+ * @param [start=0] Where the new `Buffer` will start.
+ * @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
+ */
+ slice(start?: number, end?: number): Buffer;
+ /**
+ * Returns a new `Buffer` that references the same memory as the original, but
+ * offset and cropped by the `start` and `end` indices.
+ *
+ * Specifying `end` greater than `buf.length` will return the same result as
+ * that of `end` equal to `buf.length`.
+ *
+ * This method is inherited from [`TypedArray.prototype.subarray()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray).
+ *
+ * Modifying the new `Buffer` slice will modify the memory in the original `Buffer`because the allocated memory of the two objects overlap.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * // Create a `Buffer` with the ASCII alphabet, take a slice, and modify one byte
+ * // from the original `Buffer`.
+ *
+ * const buf1 = Buffer.allocUnsafe(26);
+ *
+ * for (let i = 0; i < 26; i++) {
+ * // 97 is the decimal ASCII value for 'a'.
+ * buf1[i] = i + 97;
+ * }
+ *
+ * const buf2 = buf1.subarray(0, 3);
+ *
+ * console.log(buf2.toString('ascii', 0, buf2.length));
+ * // Prints: abc
+ *
+ * buf1[0] = 33;
+ *
+ * console.log(buf2.toString('ascii', 0, buf2.length));
+ * // Prints: !bc
+ * ```
+ *
+ * Specifying negative indexes causes the slice to be generated relative to the
+ * end of `buf` rather than the beginning.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.from('buffer');
+ *
+ * console.log(buf.subarray(-6, -1).toString());
+ * // Prints: buffe
+ * // (Equivalent to buf.subarray(0, 5).)
+ *
+ * console.log(buf.subarray(-6, -2).toString());
+ * // Prints: buff
+ * // (Equivalent to buf.subarray(0, 4).)
+ *
+ * console.log(buf.subarray(-5, -2).toString());
+ * // Prints: uff
+ * // (Equivalent to buf.subarray(1, 4).)
+ * ```
+ * @since v3.0.0
+ * @param [start=0] Where the new `Buffer` will start.
+ * @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
+ */
+ subarray(start?: number, end?: number): Buffer;
+ }
+ // TODO: remove globals in future version
+ /**
+ * @deprecated This is intended for internal use, and will be removed once `@types/node` no longer supports
+ * TypeScript versions earlier than 5.7.
+ */
+ type NonSharedBuffer = Buffer;
+ /**
+ * @deprecated This is intended for internal use, and will be removed once `@types/node` no longer supports
+ * TypeScript versions earlier than 5.7.
+ */
+ type AllowSharedBuffer = Buffer;
+ }
+}
diff --git a/types/node/v25/buffer.d.ts b/types/node/v25/buffer.d.ts
new file mode 100644
index 00000000000000..7cff31fa790754
--- /dev/null
+++ b/types/node/v25/buffer.d.ts
@@ -0,0 +1,1765 @@
+declare module "node:buffer" {
+ import { ReadableStream } from "node:stream/web";
+ /**
+ * This function returns `true` if `input` contains only valid UTF-8-encoded data,
+ * including the case in which `input` is empty.
+ *
+ * Throws if the `input` is a detached array buffer.
+ * @since v19.4.0, v18.14.0
+ * @param input The input to validate.
+ */
+ export function isUtf8(input: ArrayBuffer | NodeJS.TypedArray): boolean;
+ /**
+ * This function returns `true` if `input` contains only valid ASCII-encoded data,
+ * including the case in which `input` is empty.
+ *
+ * Throws if the `input` is a detached array buffer.
+ * @since v19.6.0, v18.15.0
+ * @param input The input to validate.
+ */
+ export function isAscii(input: ArrayBuffer | NodeJS.TypedArray): boolean;
+ export let INSPECT_MAX_BYTES: number;
+ export const kMaxLength: number;
+ export const kStringMaxLength: number;
+ export const constants: {
+ MAX_LENGTH: number;
+ MAX_STRING_LENGTH: number;
+ };
+ export type TranscodeEncoding =
+ | "ascii"
+ | "utf8"
+ | "utf-8"
+ | "utf16le"
+ | "utf-16le"
+ | "ucs2"
+ | "ucs-2"
+ | "latin1"
+ | "binary";
+ /**
+ * Re-encodes the given `Buffer` or `Uint8Array` instance from one character
+ * encoding to another. Returns a new `Buffer` instance.
+ *
+ * Throws if the `fromEnc` or `toEnc` specify invalid character encodings or if
+ * conversion from `fromEnc` to `toEnc` is not permitted.
+ *
+ * Encodings supported by `buffer.transcode()` are: `'ascii'`, `'utf8'`, `'utf16le'`, `'ucs2'`, `'latin1'`, and `'binary'`.
+ *
+ * The transcoding process will use substitution characters if a given byte
+ * sequence cannot be adequately represented in the target encoding. For instance:
+ *
+ * ```js
+ * import { Buffer, transcode } from 'node:buffer';
+ *
+ * const newBuf = transcode(Buffer.from('€'), 'utf8', 'ascii');
+ * console.log(newBuf.toString('ascii'));
+ * // Prints: '?'
+ * ```
+ *
+ * Because the Euro (`€`) sign is not representable in US-ASCII, it is replaced
+ * with `?` in the transcoded `Buffer`.
+ * @since v7.1.0
+ * @param source A `Buffer` or `Uint8Array` instance.
+ * @param fromEnc The current encoding.
+ * @param toEnc To target encoding.
+ */
+ export function transcode(
+ source: Uint8Array,
+ fromEnc: TranscodeEncoding,
+ toEnc: TranscodeEncoding,
+ ): NonSharedBuffer;
+ /**
+ * Resolves a `'blob:nodedata:...'` an associated `Blob` object registered using
+ * a prior call to `URL.createObjectURL()`.
+ * @since v16.7.0
+ * @param id A `'blob:nodedata:...` URL string returned by a prior call to `URL.createObjectURL()`.
+ */
+ export function resolveObjectURL(id: string): Blob | undefined;
+ export { type AllowSharedBuffer, Buffer, type NonSharedBuffer };
+ /** @deprecated This alias will be removed in a future version. Use the canonical `BlobPropertyBag` instead. */
+ // TODO: remove in future major
+ export interface BlobOptions extends BlobPropertyBag {}
+ /** @deprecated This alias will be removed in a future version. Use the canonical `FilePropertyBag` instead. */
+ export interface FileOptions extends FilePropertyBag {}
+ export type WithImplicitCoercion =
+ | T
+ | { valueOf(): T }
+ | (T extends string ? { [Symbol.toPrimitive](hint: "string"): T } : never);
+ global {
+ namespace NodeJS {
+ export { BufferEncoding };
+ }
+ // Buffer class
+ type BufferEncoding =
+ | "ascii"
+ | "utf8"
+ | "utf-8"
+ | "utf16le"
+ | "utf-16le"
+ | "ucs2"
+ | "ucs-2"
+ | "base64"
+ | "base64url"
+ | "latin1"
+ | "binary"
+ | "hex";
+ /**
+ * Raw data is stored in instances of the Buffer class.
+ * A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized.
+ * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'base64url'|'binary'(deprecated)|'hex'
+ */
+ interface BufferConstructor {
+ // see buffer.buffer.d.ts for implementation specific to TypeScript 5.7 and later
+ // see ts5.6/buffer.buffer.d.ts for implementation specific to TypeScript 5.6 and earlier
+
+ /**
+ * Returns `true` if `obj` is a `Buffer`, `false` otherwise.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * Buffer.isBuffer(Buffer.alloc(10)); // true
+ * Buffer.isBuffer(Buffer.from('foo')); // true
+ * Buffer.isBuffer('a string'); // false
+ * Buffer.isBuffer([]); // false
+ * Buffer.isBuffer(new Uint8Array(1024)); // false
+ * ```
+ * @since v0.1.101
+ */
+ isBuffer(obj: any): obj is Buffer;
+ /**
+ * Returns `true` if `encoding` is the name of a supported character encoding,
+ * or `false` otherwise.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * console.log(Buffer.isEncoding('utf8'));
+ * // Prints: true
+ *
+ * console.log(Buffer.isEncoding('hex'));
+ * // Prints: true
+ *
+ * console.log(Buffer.isEncoding('utf/8'));
+ * // Prints: false
+ *
+ * console.log(Buffer.isEncoding(''));
+ * // Prints: false
+ * ```
+ * @since v0.9.1
+ * @param encoding A character encoding name to check.
+ */
+ isEncoding(encoding: string): encoding is BufferEncoding;
+ /**
+ * Returns the byte length of a string when encoded using `encoding`.
+ * This is not the same as [`String.prototype.length`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length), which does not account
+ * for the encoding that is used to convert the string into bytes.
+ *
+ * For `'base64'`, `'base64url'`, and `'hex'`, this function assumes valid input.
+ * For strings that contain non-base64/hex-encoded data (e.g. whitespace), the
+ * return value might be greater than the length of a `Buffer` created from the
+ * string.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const str = '\u00bd + \u00bc = \u00be';
+ *
+ * console.log(`${str}: ${str.length} characters, ` +
+ * `${Buffer.byteLength(str, 'utf8')} bytes`);
+ * // Prints: ½ + ¼ = ¾: 9 characters, 12 bytes
+ * ```
+ *
+ * When `string` is a
+ * `Buffer`/[`DataView`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView)/[`TypedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/-
+ * Reference/Global_Objects/TypedArray)/[`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)/[`SharedArrayBuffer`](https://develop-
+ * er.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer), the byte length as reported by `.byteLength`is returned.
+ * @since v0.1.90
+ * @param string A value to calculate the length of.
+ * @param [encoding='utf8'] If `string` is a string, this is its encoding.
+ * @return The number of bytes contained within `string`.
+ */
+ byteLength(
+ string: string | NodeJS.ArrayBufferView | ArrayBufferLike,
+ encoding?: BufferEncoding,
+ ): number;
+ /**
+ * Compares `buf1` to `buf2`, typically for the purpose of sorting arrays of `Buffer` instances. This is equivalent to calling `buf1.compare(buf2)`.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf1 = Buffer.from('1234');
+ * const buf2 = Buffer.from('0123');
+ * const arr = [buf1, buf2];
+ *
+ * console.log(arr.sort(Buffer.compare));
+ * // Prints: [ , ]
+ * // (This result is equal to: [buf2, buf1].)
+ * ```
+ * @since v0.11.13
+ * @return Either `-1`, `0`, or `1`, depending on the result of the comparison. See `compare` for details.
+ */
+ compare(buf1: Uint8Array, buf2: Uint8Array): -1 | 0 | 1;
+ /**
+ * This is the size (in bytes) of pre-allocated internal `Buffer` instances used
+ * for pooling. This value may be modified.
+ * @since v0.11.3
+ */
+ poolSize: number;
+ }
+ interface Buffer {
+ // see buffer.buffer.d.ts for implementation specific to TypeScript 5.7 and later
+ // see ts5.6/buffer.buffer.d.ts for implementation specific to TypeScript 5.6 and earlier
+
+ /**
+ * Writes `string` to `buf` at `offset` according to the character encoding in`encoding`. The `length` parameter is the number of bytes to write. If `buf` did
+ * not contain enough space to fit the entire string, only part of `string` will be
+ * written. However, partially encoded characters will not be written.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.alloc(256);
+ *
+ * const len = buf.write('\u00bd + \u00bc = \u00be', 0);
+ *
+ * console.log(`${len} bytes: ${buf.toString('utf8', 0, len)}`);
+ * // Prints: 12 bytes: ½ + ¼ = ¾
+ *
+ * const buffer = Buffer.alloc(10);
+ *
+ * const length = buffer.write('abcd', 8);
+ *
+ * console.log(`${length} bytes: ${buffer.toString('utf8', 8, 10)}`);
+ * // Prints: 2 bytes : ab
+ * ```
+ * @since v0.1.90
+ * @param string String to write to `buf`.
+ * @param [offset=0] Number of bytes to skip before starting to write `string`.
+ * @param [length=buf.length - offset] Maximum number of bytes to write (written bytes will not exceed `buf.length - offset`).
+ * @param [encoding='utf8'] The character encoding of `string`.
+ * @return Number of bytes written.
+ */
+ write(string: string, encoding?: BufferEncoding): number;
+ write(string: string, offset: number, encoding?: BufferEncoding): number;
+ write(string: string, offset: number, length: number, encoding?: BufferEncoding): number;
+ /**
+ * Decodes `buf` to a string according to the specified character encoding in`encoding`. `start` and `end` may be passed to decode only a subset of `buf`.
+ *
+ * If `encoding` is `'utf8'` and a byte sequence in the input is not valid UTF-8,
+ * then each invalid byte is replaced with the replacement character `U+FFFD`.
+ *
+ * The maximum length of a string instance (in UTF-16 code units) is available
+ * as {@link constants.MAX_STRING_LENGTH}.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf1 = Buffer.allocUnsafe(26);
+ *
+ * for (let i = 0; i < 26; i++) {
+ * // 97 is the decimal ASCII value for 'a'.
+ * buf1[i] = i + 97;
+ * }
+ *
+ * console.log(buf1.toString('utf8'));
+ * // Prints: abcdefghijklmnopqrstuvwxyz
+ * console.log(buf1.toString('utf8', 0, 5));
+ * // Prints: abcde
+ *
+ * const buf2 = Buffer.from('tést');
+ *
+ * console.log(buf2.toString('hex'));
+ * // Prints: 74c3a97374
+ * console.log(buf2.toString('utf8', 0, 3));
+ * // Prints: té
+ * console.log(buf2.toString(undefined, 0, 3));
+ * // Prints: té
+ * ```
+ * @since v0.1.90
+ * @param [encoding='utf8'] The character encoding to use.
+ * @param [start=0] The byte offset to start decoding at.
+ * @param [end=buf.length] The byte offset to stop decoding at (not inclusive).
+ */
+ toString(encoding?: BufferEncoding, start?: number, end?: number): string;
+ /**
+ * Returns a JSON representation of `buf`. [`JSON.stringify()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) implicitly calls
+ * this function when stringifying a `Buffer` instance.
+ *
+ * `Buffer.from()` accepts objects in the format returned from this method.
+ * In particular, `Buffer.from(buf.toJSON())` works like `Buffer.from(buf)`.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5]);
+ * const json = JSON.stringify(buf);
+ *
+ * console.log(json);
+ * // Prints: {"type":"Buffer","data":[1,2,3,4,5]}
+ *
+ * const copy = JSON.parse(json, (key, value) => {
+ * return value && value.type === 'Buffer' ?
+ * Buffer.from(value) :
+ * value;
+ * });
+ *
+ * console.log(copy);
+ * // Prints:
+ * ```
+ * @since v0.9.2
+ */
+ toJSON(): {
+ type: "Buffer";
+ data: number[];
+ };
+ /**
+ * Returns `true` if both `buf` and `otherBuffer` have exactly the same bytes,`false` otherwise. Equivalent to `buf.compare(otherBuffer) === 0`.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf1 = Buffer.from('ABC');
+ * const buf2 = Buffer.from('414243', 'hex');
+ * const buf3 = Buffer.from('ABCD');
+ *
+ * console.log(buf1.equals(buf2));
+ * // Prints: true
+ * console.log(buf1.equals(buf3));
+ * // Prints: false
+ * ```
+ * @since v0.11.13
+ * @param otherBuffer A `Buffer` or {@link Uint8Array} with which to compare `buf`.
+ */
+ equals(otherBuffer: Uint8Array): boolean;
+ /**
+ * Compares `buf` with `target` and returns a number indicating whether `buf`comes before, after, or is the same as `target` in sort order.
+ * Comparison is based on the actual sequence of bytes in each `Buffer`.
+ *
+ * * `0` is returned if `target` is the same as `buf`
+ * * `1` is returned if `target` should come _before_`buf` when sorted.
+ * * `-1` is returned if `target` should come _after_`buf` when sorted.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf1 = Buffer.from('ABC');
+ * const buf2 = Buffer.from('BCD');
+ * const buf3 = Buffer.from('ABCD');
+ *
+ * console.log(buf1.compare(buf1));
+ * // Prints: 0
+ * console.log(buf1.compare(buf2));
+ * // Prints: -1
+ * console.log(buf1.compare(buf3));
+ * // Prints: -1
+ * console.log(buf2.compare(buf1));
+ * // Prints: 1
+ * console.log(buf2.compare(buf3));
+ * // Prints: 1
+ * console.log([buf1, buf2, buf3].sort(Buffer.compare));
+ * // Prints: [ , , ]
+ * // (This result is equal to: [buf1, buf3, buf2].)
+ * ```
+ *
+ * The optional `targetStart`, `targetEnd`, `sourceStart`, and `sourceEnd` arguments can be used to limit the comparison to specific ranges within `target` and `buf` respectively.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf1 = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8, 9]);
+ * const buf2 = Buffer.from([5, 6, 7, 8, 9, 1, 2, 3, 4]);
+ *
+ * console.log(buf1.compare(buf2, 5, 9, 0, 4));
+ * // Prints: 0
+ * console.log(buf1.compare(buf2, 0, 6, 4));
+ * // Prints: -1
+ * console.log(buf1.compare(buf2, 5, 6, 5));
+ * // Prints: 1
+ * ```
+ *
+ * `ERR_OUT_OF_RANGE` is thrown if `targetStart < 0`, `sourceStart < 0`, `targetEnd > target.byteLength`, or `sourceEnd > source.byteLength`.
+ * @since v0.11.13
+ * @param target A `Buffer` or {@link Uint8Array} with which to compare `buf`.
+ * @param [targetStart=0] The offset within `target` at which to begin comparison.
+ * @param [targetEnd=target.length] The offset within `target` at which to end comparison (not inclusive).
+ * @param [sourceStart=0] The offset within `buf` at which to begin comparison.
+ * @param [sourceEnd=buf.length] The offset within `buf` at which to end comparison (not inclusive).
+ */
+ compare(
+ target: Uint8Array,
+ targetStart?: number,
+ targetEnd?: number,
+ sourceStart?: number,
+ sourceEnd?: number,
+ ): -1 | 0 | 1;
+ /**
+ * Copies data from a region of `buf` to a region in `target`, even if the `target`memory region overlaps with `buf`.
+ *
+ * [`TypedArray.prototype.set()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set) performs the same operation, and is available
+ * for all TypedArrays, including Node.js `Buffer`s, although it takes
+ * different function arguments.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * // Create two `Buffer` instances.
+ * const buf1 = Buffer.allocUnsafe(26);
+ * const buf2 = Buffer.allocUnsafe(26).fill('!');
+ *
+ * for (let i = 0; i < 26; i++) {
+ * // 97 is the decimal ASCII value for 'a'.
+ * buf1[i] = i + 97;
+ * }
+ *
+ * // Copy `buf1` bytes 16 through 19 into `buf2` starting at byte 8 of `buf2`.
+ * buf1.copy(buf2, 8, 16, 20);
+ * // This is equivalent to:
+ * // buf2.set(buf1.subarray(16, 20), 8);
+ *
+ * console.log(buf2.toString('ascii', 0, 25));
+ * // Prints: !!!!!!!!qrst!!!!!!!!!!!!!
+ * ```
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * // Create a `Buffer` and copy data from one region to an overlapping region
+ * // within the same `Buffer`.
+ *
+ * const buf = Buffer.allocUnsafe(26);
+ *
+ * for (let i = 0; i < 26; i++) {
+ * // 97 is the decimal ASCII value for 'a'.
+ * buf[i] = i + 97;
+ * }
+ *
+ * buf.copy(buf, 0, 4, 10);
+ *
+ * console.log(buf.toString());
+ * // Prints: efghijghijklmnopqrstuvwxyz
+ * ```
+ * @since v0.1.90
+ * @param target A `Buffer` or {@link Uint8Array} to copy into.
+ * @param [targetStart=0] The offset within `target` at which to begin writing.
+ * @param [sourceStart=0] The offset within `buf` from which to begin copying.
+ * @param [sourceEnd=buf.length] The offset within `buf` at which to stop copying (not inclusive).
+ * @return The number of bytes copied.
+ */
+ copy(target: Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
+ /**
+ * Writes `value` to `buf` at the specified `offset` as big-endian.
+ *
+ * `value` is interpreted and written as a two's complement signed integer.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.allocUnsafe(8);
+ *
+ * buf.writeBigInt64BE(0x0102030405060708n, 0);
+ *
+ * console.log(buf);
+ * // Prints:
+ * ```
+ * @since v12.0.0, v10.20.0
+ * @param value Number to be written to `buf`.
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`.
+ * @return `offset` plus the number of bytes written.
+ */
+ writeBigInt64BE(value: bigint, offset?: number): number;
+ /**
+ * Writes `value` to `buf` at the specified `offset` as little-endian.
+ *
+ * `value` is interpreted and written as a two's complement signed integer.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.allocUnsafe(8);
+ *
+ * buf.writeBigInt64LE(0x0102030405060708n, 0);
+ *
+ * console.log(buf);
+ * // Prints:
+ * ```
+ * @since v12.0.0, v10.20.0
+ * @param value Number to be written to `buf`.
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`.
+ * @return `offset` plus the number of bytes written.
+ */
+ writeBigInt64LE(value: bigint, offset?: number): number;
+ /**
+ * Writes `value` to `buf` at the specified `offset` as big-endian.
+ *
+ * This function is also available under the `writeBigUint64BE` alias.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.allocUnsafe(8);
+ *
+ * buf.writeBigUInt64BE(0xdecafafecacefaden, 0);
+ *
+ * console.log(buf);
+ * // Prints:
+ * ```
+ * @since v12.0.0, v10.20.0
+ * @param value Number to be written to `buf`.
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`.
+ * @return `offset` plus the number of bytes written.
+ */
+ writeBigUInt64BE(value: bigint, offset?: number): number;
+ /**
+ * @alias Buffer.writeBigUInt64BE
+ * @since v14.10.0, v12.19.0
+ */
+ writeBigUint64BE(value: bigint, offset?: number): number;
+ /**
+ * Writes `value` to `buf` at the specified `offset` as little-endian
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.allocUnsafe(8);
+ *
+ * buf.writeBigUInt64LE(0xdecafafecacefaden, 0);
+ *
+ * console.log(buf);
+ * // Prints:
+ * ```
+ *
+ * This function is also available under the `writeBigUint64LE` alias.
+ * @since v12.0.0, v10.20.0
+ * @param value Number to be written to `buf`.
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`.
+ * @return `offset` plus the number of bytes written.
+ */
+ writeBigUInt64LE(value: bigint, offset?: number): number;
+ /**
+ * @alias Buffer.writeBigUInt64LE
+ * @since v14.10.0, v12.19.0
+ */
+ writeBigUint64LE(value: bigint, offset?: number): number;
+ /**
+ * Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as little-endian. Supports up to 48 bits of accuracy. Behavior is undefined
+ * when `value` is anything other than an unsigned integer.
+ *
+ * This function is also available under the `writeUintLE` alias.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.allocUnsafe(6);
+ *
+ * buf.writeUIntLE(0x1234567890ab, 0, 6);
+ *
+ * console.log(buf);
+ * // Prints:
+ * ```
+ * @since v0.5.5
+ * @param value Number to be written to `buf`.
+ * @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`.
+ * @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`.
+ * @return `offset` plus the number of bytes written.
+ */
+ writeUIntLE(value: number, offset: number, byteLength: number): number;
+ /**
+ * @alias Buffer.writeUIntLE
+ * @since v14.9.0, v12.19.0
+ */
+ writeUintLE(value: number, offset: number, byteLength: number): number;
+ /**
+ * Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as big-endian. Supports up to 48 bits of accuracy. Behavior is undefined
+ * when `value` is anything other than an unsigned integer.
+ *
+ * This function is also available under the `writeUintBE` alias.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.allocUnsafe(6);
+ *
+ * buf.writeUIntBE(0x1234567890ab, 0, 6);
+ *
+ * console.log(buf);
+ * // Prints:
+ * ```
+ * @since v0.5.5
+ * @param value Number to be written to `buf`.
+ * @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`.
+ * @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`.
+ * @return `offset` plus the number of bytes written.
+ */
+ writeUIntBE(value: number, offset: number, byteLength: number): number;
+ /**
+ * @alias Buffer.writeUIntBE
+ * @since v14.9.0, v12.19.0
+ */
+ writeUintBE(value: number, offset: number, byteLength: number): number;
+ /**
+ * Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as little-endian. Supports up to 48 bits of accuracy. Behavior is undefined
+ * when `value` is anything other than a signed integer.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.allocUnsafe(6);
+ *
+ * buf.writeIntLE(0x1234567890ab, 0, 6);
+ *
+ * console.log(buf);
+ * // Prints:
+ * ```
+ * @since v0.11.15
+ * @param value Number to be written to `buf`.
+ * @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`.
+ * @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`.
+ * @return `offset` plus the number of bytes written.
+ */
+ writeIntLE(value: number, offset: number, byteLength: number): number;
+ /**
+ * Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as big-endian. Supports up to 48 bits of accuracy. Behavior is undefined when`value` is anything other than a
+ * signed integer.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.allocUnsafe(6);
+ *
+ * buf.writeIntBE(0x1234567890ab, 0, 6);
+ *
+ * console.log(buf);
+ * // Prints:
+ * ```
+ * @since v0.11.15
+ * @param value Number to be written to `buf`.
+ * @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`.
+ * @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`.
+ * @return `offset` plus the number of bytes written.
+ */
+ writeIntBE(value: number, offset: number, byteLength: number): number;
+ /**
+ * Reads an unsigned, big-endian 64-bit integer from `buf` at the specified`offset`.
+ *
+ * This function is also available under the `readBigUint64BE` alias.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);
+ *
+ * console.log(buf.readBigUInt64BE(0));
+ * // Prints: 4294967295n
+ * ```
+ * @since v12.0.0, v10.20.0
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`.
+ */
+ readBigUInt64BE(offset?: number): bigint;
+ /**
+ * @alias Buffer.readBigUInt64BE
+ * @since v14.10.0, v12.19.0
+ */
+ readBigUint64BE(offset?: number): bigint;
+ /**
+ * Reads an unsigned, little-endian 64-bit integer from `buf` at the specified`offset`.
+ *
+ * This function is also available under the `readBigUint64LE` alias.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);
+ *
+ * console.log(buf.readBigUInt64LE(0));
+ * // Prints: 18446744069414584320n
+ * ```
+ * @since v12.0.0, v10.20.0
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`.
+ */
+ readBigUInt64LE(offset?: number): bigint;
+ /**
+ * @alias Buffer.readBigUInt64LE
+ * @since v14.10.0, v12.19.0
+ */
+ readBigUint64LE(offset?: number): bigint;
+ /**
+ * Reads a signed, big-endian 64-bit integer from `buf` at the specified `offset`.
+ *
+ * Integers read from a `Buffer` are interpreted as two's complement signed
+ * values.
+ * @since v12.0.0, v10.20.0
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`.
+ */
+ readBigInt64BE(offset?: number): bigint;
+ /**
+ * Reads a signed, little-endian 64-bit integer from `buf` at the specified`offset`.
+ *
+ * Integers read from a `Buffer` are interpreted as two's complement signed
+ * values.
+ * @since v12.0.0, v10.20.0
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`.
+ */
+ readBigInt64LE(offset?: number): bigint;
+ /**
+ * Reads `byteLength` number of bytes from `buf` at the specified `offset` and interprets the result as an unsigned, little-endian integer supporting
+ * up to 48 bits of accuracy.
+ *
+ * This function is also available under the `readUintLE` alias.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
+ *
+ * console.log(buf.readUIntLE(0, 6).toString(16));
+ * // Prints: ab9078563412
+ * ```
+ * @since v0.11.15
+ * @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`.
+ * @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`.
+ */
+ readUIntLE(offset: number, byteLength: number): number;
+ /**
+ * @alias Buffer.readUIntLE
+ * @since v14.9.0, v12.19.0
+ */
+ readUintLE(offset: number, byteLength: number): number;
+ /**
+ * Reads `byteLength` number of bytes from `buf` at the specified `offset` and interprets the result as an unsigned big-endian integer supporting
+ * up to 48 bits of accuracy.
+ *
+ * This function is also available under the `readUintBE` alias.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
+ *
+ * console.log(buf.readUIntBE(0, 6).toString(16));
+ * // Prints: 1234567890ab
+ * console.log(buf.readUIntBE(1, 6).toString(16));
+ * // Throws ERR_OUT_OF_RANGE.
+ * ```
+ * @since v0.11.15
+ * @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`.
+ * @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`.
+ */
+ readUIntBE(offset: number, byteLength: number): number;
+ /**
+ * @alias Buffer.readUIntBE
+ * @since v14.9.0, v12.19.0
+ */
+ readUintBE(offset: number, byteLength: number): number;
+ /**
+ * Reads `byteLength` number of bytes from `buf` at the specified `offset` and interprets the result as a little-endian, two's complement signed value
+ * supporting up to 48 bits of accuracy.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
+ *
+ * console.log(buf.readIntLE(0, 6).toString(16));
+ * // Prints: -546f87a9cbee
+ * ```
+ * @since v0.11.15
+ * @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`.
+ * @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`.
+ */
+ readIntLE(offset: number, byteLength: number): number;
+ /**
+ * Reads `byteLength` number of bytes from `buf` at the specified `offset` and interprets the result as a big-endian, two's complement signed value
+ * supporting up to 48 bits of accuracy.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
+ *
+ * console.log(buf.readIntBE(0, 6).toString(16));
+ * // Prints: 1234567890ab
+ * console.log(buf.readIntBE(1, 6).toString(16));
+ * // Throws ERR_OUT_OF_RANGE.
+ * console.log(buf.readIntBE(1, 0).toString(16));
+ * // Throws ERR_OUT_OF_RANGE.
+ * ```
+ * @since v0.11.15
+ * @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`.
+ * @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`.
+ */
+ readIntBE(offset: number, byteLength: number): number;
+ /**
+ * Reads an unsigned 8-bit integer from `buf` at the specified `offset`.
+ *
+ * This function is also available under the `readUint8` alias.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.from([1, -2]);
+ *
+ * console.log(buf.readUInt8(0));
+ * // Prints: 1
+ * console.log(buf.readUInt8(1));
+ * // Prints: 254
+ * console.log(buf.readUInt8(2));
+ * // Throws ERR_OUT_OF_RANGE.
+ * ```
+ * @since v0.5.0
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 1`.
+ */
+ readUInt8(offset?: number): number;
+ /**
+ * @alias Buffer.readUInt8
+ * @since v14.9.0, v12.19.0
+ */
+ readUint8(offset?: number): number;
+ /**
+ * Reads an unsigned, little-endian 16-bit integer from `buf` at the specified `offset`.
+ *
+ * This function is also available under the `readUint16LE` alias.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.from([0x12, 0x34, 0x56]);
+ *
+ * console.log(buf.readUInt16LE(0).toString(16));
+ * // Prints: 3412
+ * console.log(buf.readUInt16LE(1).toString(16));
+ * // Prints: 5634
+ * console.log(buf.readUInt16LE(2).toString(16));
+ * // Throws ERR_OUT_OF_RANGE.
+ * ```
+ * @since v0.5.5
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`.
+ */
+ readUInt16LE(offset?: number): number;
+ /**
+ * @alias Buffer.readUInt16LE
+ * @since v14.9.0, v12.19.0
+ */
+ readUint16LE(offset?: number): number;
+ /**
+ * Reads an unsigned, big-endian 16-bit integer from `buf` at the specified`offset`.
+ *
+ * This function is also available under the `readUint16BE` alias.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.from([0x12, 0x34, 0x56]);
+ *
+ * console.log(buf.readUInt16BE(0).toString(16));
+ * // Prints: 1234
+ * console.log(buf.readUInt16BE(1).toString(16));
+ * // Prints: 3456
+ * ```
+ * @since v0.5.5
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`.
+ */
+ readUInt16BE(offset?: number): number;
+ /**
+ * @alias Buffer.readUInt16BE
+ * @since v14.9.0, v12.19.0
+ */
+ readUint16BE(offset?: number): number;
+ /**
+ * Reads an unsigned, little-endian 32-bit integer from `buf` at the specified`offset`.
+ *
+ * This function is also available under the `readUint32LE` alias.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]);
+ *
+ * console.log(buf.readUInt32LE(0).toString(16));
+ * // Prints: 78563412
+ * console.log(buf.readUInt32LE(1).toString(16));
+ * // Throws ERR_OUT_OF_RANGE.
+ * ```
+ * @since v0.5.5
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
+ */
+ readUInt32LE(offset?: number): number;
+ /**
+ * @alias Buffer.readUInt32LE
+ * @since v14.9.0, v12.19.0
+ */
+ readUint32LE(offset?: number): number;
+ /**
+ * Reads an unsigned, big-endian 32-bit integer from `buf` at the specified`offset`.
+ *
+ * This function is also available under the `readUint32BE` alias.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]);
+ *
+ * console.log(buf.readUInt32BE(0).toString(16));
+ * // Prints: 12345678
+ * ```
+ * @since v0.5.5
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
+ */
+ readUInt32BE(offset?: number): number;
+ /**
+ * @alias Buffer.readUInt32BE
+ * @since v14.9.0, v12.19.0
+ */
+ readUint32BE(offset?: number): number;
+ /**
+ * Reads a signed 8-bit integer from `buf` at the specified `offset`.
+ *
+ * Integers read from a `Buffer` are interpreted as two's complement signed values.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.from([-1, 5]);
+ *
+ * console.log(buf.readInt8(0));
+ * // Prints: -1
+ * console.log(buf.readInt8(1));
+ * // Prints: 5
+ * console.log(buf.readInt8(2));
+ * // Throws ERR_OUT_OF_RANGE.
+ * ```
+ * @since v0.5.0
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 1`.
+ */
+ readInt8(offset?: number): number;
+ /**
+ * Reads a signed, little-endian 16-bit integer from `buf` at the specified`offset`.
+ *
+ * Integers read from a `Buffer` are interpreted as two's complement signed values.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.from([0, 5]);
+ *
+ * console.log(buf.readInt16LE(0));
+ * // Prints: 1280
+ * console.log(buf.readInt16LE(1));
+ * // Throws ERR_OUT_OF_RANGE.
+ * ```
+ * @since v0.5.5
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`.
+ */
+ readInt16LE(offset?: number): number;
+ /**
+ * Reads a signed, big-endian 16-bit integer from `buf` at the specified `offset`.
+ *
+ * Integers read from a `Buffer` are interpreted as two's complement signed values.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.from([0, 5]);
+ *
+ * console.log(buf.readInt16BE(0));
+ * // Prints: 5
+ * ```
+ * @since v0.5.5
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`.
+ */
+ readInt16BE(offset?: number): number;
+ /**
+ * Reads a signed, little-endian 32-bit integer from `buf` at the specified`offset`.
+ *
+ * Integers read from a `Buffer` are interpreted as two's complement signed values.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.from([0, 0, 0, 5]);
+ *
+ * console.log(buf.readInt32LE(0));
+ * // Prints: 83886080
+ * console.log(buf.readInt32LE(1));
+ * // Throws ERR_OUT_OF_RANGE.
+ * ```
+ * @since v0.5.5
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
+ */
+ readInt32LE(offset?: number): number;
+ /**
+ * Reads a signed, big-endian 32-bit integer from `buf` at the specified `offset`.
+ *
+ * Integers read from a `Buffer` are interpreted as two's complement signed values.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.from([0, 0, 0, 5]);
+ *
+ * console.log(buf.readInt32BE(0));
+ * // Prints: 5
+ * ```
+ * @since v0.5.5
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
+ */
+ readInt32BE(offset?: number): number;
+ /**
+ * Reads a 32-bit, little-endian float from `buf` at the specified `offset`.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.from([1, 2, 3, 4]);
+ *
+ * console.log(buf.readFloatLE(0));
+ * // Prints: 1.539989614439558e-36
+ * console.log(buf.readFloatLE(1));
+ * // Throws ERR_OUT_OF_RANGE.
+ * ```
+ * @since v0.11.15
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
+ */
+ readFloatLE(offset?: number): number;
+ /**
+ * Reads a 32-bit, big-endian float from `buf` at the specified `offset`.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.from([1, 2, 3, 4]);
+ *
+ * console.log(buf.readFloatBE(0));
+ * // Prints: 2.387939260590663e-38
+ * ```
+ * @since v0.11.15
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
+ */
+ readFloatBE(offset?: number): number;
+ /**
+ * Reads a 64-bit, little-endian double from `buf` at the specified `offset`.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
+ *
+ * console.log(buf.readDoubleLE(0));
+ * // Prints: 5.447603722011605e-270
+ * console.log(buf.readDoubleLE(1));
+ * // Throws ERR_OUT_OF_RANGE.
+ * ```
+ * @since v0.11.15
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 8`.
+ */
+ readDoubleLE(offset?: number): number;
+ /**
+ * Reads a 64-bit, big-endian double from `buf` at the specified `offset`.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
+ *
+ * console.log(buf.readDoubleBE(0));
+ * // Prints: 8.20788039913184e-304
+ * ```
+ * @since v0.11.15
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 8`.
+ */
+ readDoubleBE(offset?: number): number;
+ reverse(): this;
+ /**
+ * Interprets `buf` as an array of unsigned 16-bit integers and swaps the
+ * byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 2.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
+ *
+ * console.log(buf1);
+ * // Prints:
+ *
+ * buf1.swap16();
+ *
+ * console.log(buf1);
+ * // Prints:
+ *
+ * const buf2 = Buffer.from([0x1, 0x2, 0x3]);
+ *
+ * buf2.swap16();
+ * // Throws ERR_INVALID_BUFFER_SIZE.
+ * ```
+ *
+ * One convenient use of `buf.swap16()` is to perform a fast in-place conversion
+ * between UTF-16 little-endian and UTF-16 big-endian:
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.from('This is little-endian UTF-16', 'utf16le');
+ * buf.swap16(); // Convert to big-endian UTF-16 text.
+ * ```
+ * @since v5.10.0
+ * @return A reference to `buf`.
+ */
+ swap16(): this;
+ /**
+ * Interprets `buf` as an array of unsigned 32-bit integers and swaps the
+ * byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 4.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
+ *
+ * console.log(buf1);
+ * // Prints:
+ *
+ * buf1.swap32();
+ *
+ * console.log(buf1);
+ * // Prints:
+ *
+ * const buf2 = Buffer.from([0x1, 0x2, 0x3]);
+ *
+ * buf2.swap32();
+ * // Throws ERR_INVALID_BUFFER_SIZE.
+ * ```
+ * @since v5.10.0
+ * @return A reference to `buf`.
+ */
+ swap32(): this;
+ /**
+ * Interprets `buf` as an array of 64-bit numbers and swaps byte order _in-place_.
+ * Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 8.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
+ *
+ * console.log(buf1);
+ * // Prints:
+ *
+ * buf1.swap64();
+ *
+ * console.log(buf1);
+ * // Prints:
+ *
+ * const buf2 = Buffer.from([0x1, 0x2, 0x3]);
+ *
+ * buf2.swap64();
+ * // Throws ERR_INVALID_BUFFER_SIZE.
+ * ```
+ * @since v6.3.0
+ * @return A reference to `buf`.
+ */
+ swap64(): this;
+ /**
+ * Writes `value` to `buf` at the specified `offset`. `value` must be a
+ * valid unsigned 8-bit integer. Behavior is undefined when `value` is anything
+ * other than an unsigned 8-bit integer.
+ *
+ * This function is also available under the `writeUint8` alias.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.allocUnsafe(4);
+ *
+ * buf.writeUInt8(0x3, 0);
+ * buf.writeUInt8(0x4, 1);
+ * buf.writeUInt8(0x23, 2);
+ * buf.writeUInt8(0x42, 3);
+ *
+ * console.log(buf);
+ * // Prints:
+ * ```
+ * @since v0.5.0
+ * @param value Number to be written to `buf`.
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 1`.
+ * @return `offset` plus the number of bytes written.
+ */
+ writeUInt8(value: number, offset?: number): number;
+ /**
+ * @alias Buffer.writeUInt8
+ * @since v14.9.0, v12.19.0
+ */
+ writeUint8(value: number, offset?: number): number;
+ /**
+ * Writes `value` to `buf` at the specified `offset` as little-endian. The `value` must be a valid unsigned 16-bit integer. Behavior is undefined when `value` is
+ * anything other than an unsigned 16-bit integer.
+ *
+ * This function is also available under the `writeUint16LE` alias.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.allocUnsafe(4);
+ *
+ * buf.writeUInt16LE(0xdead, 0);
+ * buf.writeUInt16LE(0xbeef, 2);
+ *
+ * console.log(buf);
+ * // Prints:
+ * ```
+ * @since v0.5.5
+ * @param value Number to be written to `buf`.
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`.
+ * @return `offset` plus the number of bytes written.
+ */
+ writeUInt16LE(value: number, offset?: number): number;
+ /**
+ * @alias Buffer.writeUInt16LE
+ * @since v14.9.0, v12.19.0
+ */
+ writeUint16LE(value: number, offset?: number): number;
+ /**
+ * Writes `value` to `buf` at the specified `offset` as big-endian. The `value` must be a valid unsigned 16-bit integer. Behavior is undefined when `value`is anything other than an
+ * unsigned 16-bit integer.
+ *
+ * This function is also available under the `writeUint16BE` alias.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.allocUnsafe(4);
+ *
+ * buf.writeUInt16BE(0xdead, 0);
+ * buf.writeUInt16BE(0xbeef, 2);
+ *
+ * console.log(buf);
+ * // Prints:
+ * ```
+ * @since v0.5.5
+ * @param value Number to be written to `buf`.
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`.
+ * @return `offset` plus the number of bytes written.
+ */
+ writeUInt16BE(value: number, offset?: number): number;
+ /**
+ * @alias Buffer.writeUInt16BE
+ * @since v14.9.0, v12.19.0
+ */
+ writeUint16BE(value: number, offset?: number): number;
+ /**
+ * Writes `value` to `buf` at the specified `offset` as little-endian. The `value` must be a valid unsigned 32-bit integer. Behavior is undefined when `value` is
+ * anything other than an unsigned 32-bit integer.
+ *
+ * This function is also available under the `writeUint32LE` alias.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.allocUnsafe(4);
+ *
+ * buf.writeUInt32LE(0xfeedface, 0);
+ *
+ * console.log(buf);
+ * // Prints:
+ * ```
+ * @since v0.5.5
+ * @param value Number to be written to `buf`.
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
+ * @return `offset` plus the number of bytes written.
+ */
+ writeUInt32LE(value: number, offset?: number): number;
+ /**
+ * @alias Buffer.writeUInt32LE
+ * @since v14.9.0, v12.19.0
+ */
+ writeUint32LE(value: number, offset?: number): number;
+ /**
+ * Writes `value` to `buf` at the specified `offset` as big-endian. The `value` must be a valid unsigned 32-bit integer. Behavior is undefined when `value`is anything other than an
+ * unsigned 32-bit integer.
+ *
+ * This function is also available under the `writeUint32BE` alias.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.allocUnsafe(4);
+ *
+ * buf.writeUInt32BE(0xfeedface, 0);
+ *
+ * console.log(buf);
+ * // Prints:
+ * ```
+ * @since v0.5.5
+ * @param value Number to be written to `buf`.
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
+ * @return `offset` plus the number of bytes written.
+ */
+ writeUInt32BE(value: number, offset?: number): number;
+ /**
+ * @alias Buffer.writeUInt32BE
+ * @since v14.9.0, v12.19.0
+ */
+ writeUint32BE(value: number, offset?: number): number;
+ /**
+ * Writes `value` to `buf` at the specified `offset`. `value` must be a valid
+ * signed 8-bit integer. Behavior is undefined when `value` is anything other than
+ * a signed 8-bit integer.
+ *
+ * `value` is interpreted and written as a two's complement signed integer.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.allocUnsafe(2);
+ *
+ * buf.writeInt8(2, 0);
+ * buf.writeInt8(-2, 1);
+ *
+ * console.log(buf);
+ * // Prints:
+ * ```
+ * @since v0.5.0
+ * @param value Number to be written to `buf`.
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 1`.
+ * @return `offset` plus the number of bytes written.
+ */
+ writeInt8(value: number, offset?: number): number;
+ /**
+ * Writes `value` to `buf` at the specified `offset` as little-endian. The `value` must be a valid signed 16-bit integer. Behavior is undefined when `value` is
+ * anything other than a signed 16-bit integer.
+ *
+ * The `value` is interpreted and written as a two's complement signed integer.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.allocUnsafe(2);
+ *
+ * buf.writeInt16LE(0x0304, 0);
+ *
+ * console.log(buf);
+ * // Prints:
+ * ```
+ * @since v0.5.5
+ * @param value Number to be written to `buf`.
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`.
+ * @return `offset` plus the number of bytes written.
+ */
+ writeInt16LE(value: number, offset?: number): number;
+ /**
+ * Writes `value` to `buf` at the specified `offset` as big-endian. The `value` must be a valid signed 16-bit integer. Behavior is undefined when `value` is
+ * anything other than a signed 16-bit integer.
+ *
+ * The `value` is interpreted and written as a two's complement signed integer.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.allocUnsafe(2);
+ *
+ * buf.writeInt16BE(0x0102, 0);
+ *
+ * console.log(buf);
+ * // Prints:
+ * ```
+ * @since v0.5.5
+ * @param value Number to be written to `buf`.
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`.
+ * @return `offset` plus the number of bytes written.
+ */
+ writeInt16BE(value: number, offset?: number): number;
+ /**
+ * Writes `value` to `buf` at the specified `offset` as little-endian. The `value` must be a valid signed 32-bit integer. Behavior is undefined when `value` is
+ * anything other than a signed 32-bit integer.
+ *
+ * The `value` is interpreted and written as a two's complement signed integer.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.allocUnsafe(4);
+ *
+ * buf.writeInt32LE(0x05060708, 0);
+ *
+ * console.log(buf);
+ * // Prints:
+ * ```
+ * @since v0.5.5
+ * @param value Number to be written to `buf`.
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
+ * @return `offset` plus the number of bytes written.
+ */
+ writeInt32LE(value: number, offset?: number): number;
+ /**
+ * Writes `value` to `buf` at the specified `offset` as big-endian. The `value` must be a valid signed 32-bit integer. Behavior is undefined when `value` is
+ * anything other than a signed 32-bit integer.
+ *
+ * The `value` is interpreted and written as a two's complement signed integer.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.allocUnsafe(4);
+ *
+ * buf.writeInt32BE(0x01020304, 0);
+ *
+ * console.log(buf);
+ * // Prints:
+ * ```
+ * @since v0.5.5
+ * @param value Number to be written to `buf`.
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
+ * @return `offset` plus the number of bytes written.
+ */
+ writeInt32BE(value: number, offset?: number): number;
+ /**
+ * Writes `value` to `buf` at the specified `offset` as little-endian. Behavior is
+ * undefined when `value` is anything other than a JavaScript number.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.allocUnsafe(4);
+ *
+ * buf.writeFloatLE(0xcafebabe, 0);
+ *
+ * console.log(buf);
+ * // Prints:
+ * ```
+ * @since v0.11.15
+ * @param value Number to be written to `buf`.
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
+ * @return `offset` plus the number of bytes written.
+ */
+ writeFloatLE(value: number, offset?: number): number;
+ /**
+ * Writes `value` to `buf` at the specified `offset` as big-endian. Behavior is
+ * undefined when `value` is anything other than a JavaScript number.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.allocUnsafe(4);
+ *
+ * buf.writeFloatBE(0xcafebabe, 0);
+ *
+ * console.log(buf);
+ * // Prints:
+ * ```
+ * @since v0.11.15
+ * @param value Number to be written to `buf`.
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
+ * @return `offset` plus the number of bytes written.
+ */
+ writeFloatBE(value: number, offset?: number): number;
+ /**
+ * Writes `value` to `buf` at the specified `offset` as little-endian. The `value` must be a JavaScript number. Behavior is undefined when `value` is anything
+ * other than a JavaScript number.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.allocUnsafe(8);
+ *
+ * buf.writeDoubleLE(123.456, 0);
+ *
+ * console.log(buf);
+ * // Prints:
+ * ```
+ * @since v0.11.15
+ * @param value Number to be written to `buf`.
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 8`.
+ * @return `offset` plus the number of bytes written.
+ */
+ writeDoubleLE(value: number, offset?: number): number;
+ /**
+ * Writes `value` to `buf` at the specified `offset` as big-endian. The `value` must be a JavaScript number. Behavior is undefined when `value` is anything
+ * other than a JavaScript number.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.allocUnsafe(8);
+ *
+ * buf.writeDoubleBE(123.456, 0);
+ *
+ * console.log(buf);
+ * // Prints:
+ * ```
+ * @since v0.11.15
+ * @param value Number to be written to `buf`.
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 8`.
+ * @return `offset` plus the number of bytes written.
+ */
+ writeDoubleBE(value: number, offset?: number): number;
+ /**
+ * Fills `buf` with the specified `value`. If the `offset` and `end` are not given,
+ * the entire `buf` will be filled:
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * // Fill a `Buffer` with the ASCII character 'h'.
+ *
+ * const b = Buffer.allocUnsafe(50).fill('h');
+ *
+ * console.log(b.toString());
+ * // Prints: hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
+ *
+ * // Fill a buffer with empty string
+ * const c = Buffer.allocUnsafe(5).fill('');
+ *
+ * console.log(c.fill(''));
+ * // Prints:
+ * ```
+ *
+ * `value` is coerced to a `uint32` value if it is not a string, `Buffer`, or
+ * integer. If the resulting integer is greater than `255` (decimal), `buf` will be
+ * filled with `value & 255`.
+ *
+ * If the final write of a `fill()` operation falls on a multi-byte character,
+ * then only the bytes of that character that fit into `buf` are written:
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * // Fill a `Buffer` with character that takes up two bytes in UTF-8.
+ *
+ * console.log(Buffer.allocUnsafe(5).fill('\u0222'));
+ * // Prints:
+ * ```
+ *
+ * If `value` contains invalid characters, it is truncated; if no valid
+ * fill data remains, an exception is thrown:
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.allocUnsafe(5);
+ *
+ * console.log(buf.fill('a'));
+ * // Prints:
+ * console.log(buf.fill('aazz', 'hex'));
+ * // Prints:
+ * console.log(buf.fill('zz', 'hex'));
+ * // Throws an exception.
+ * ```
+ * @since v0.5.0
+ * @param value The value with which to fill `buf`. Empty value (string, Uint8Array, Buffer) is coerced to `0`.
+ * @param [offset=0] Number of bytes to skip before starting to fill `buf`.
+ * @param [end=buf.length] Where to stop filling `buf` (not inclusive).
+ * @param [encoding='utf8'] The encoding for `value` if `value` is a string.
+ * @return A reference to `buf`.
+ */
+ fill(value: string | Uint8Array | number, offset?: number, end?: number, encoding?: BufferEncoding): this;
+ fill(value: string | Uint8Array | number, offset: number, encoding: BufferEncoding): this;
+ fill(value: string | Uint8Array | number, encoding: BufferEncoding): this;
+ /**
+ * If `value` is:
+ *
+ * * a string, `value` is interpreted according to the character encoding in `encoding`.
+ * * a `Buffer` or [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array), `value` will be used in its entirety.
+ * To compare a partial `Buffer`, use `buf.subarray`.
+ * * a number, `value` will be interpreted as an unsigned 8-bit integer
+ * value between `0` and `255`.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.from('this is a buffer');
+ *
+ * console.log(buf.indexOf('this'));
+ * // Prints: 0
+ * console.log(buf.indexOf('is'));
+ * // Prints: 2
+ * console.log(buf.indexOf(Buffer.from('a buffer')));
+ * // Prints: 8
+ * console.log(buf.indexOf(97));
+ * // Prints: 8 (97 is the decimal ASCII value for 'a')
+ * console.log(buf.indexOf(Buffer.from('a buffer example')));
+ * // Prints: -1
+ * console.log(buf.indexOf(Buffer.from('a buffer example').slice(0, 8)));
+ * // Prints: 8
+ *
+ * const utf16Buffer = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'utf16le');
+ *
+ * console.log(utf16Buffer.indexOf('\u03a3', 0, 'utf16le'));
+ * // Prints: 4
+ * console.log(utf16Buffer.indexOf('\u03a3', -4, 'utf16le'));
+ * // Prints: 6
+ * ```
+ *
+ * If `value` is not a string, number, or `Buffer`, this method will throw a `TypeError`. If `value` is a number, it will be coerced to a valid byte value,
+ * an integer between 0 and 255.
+ *
+ * If `byteOffset` is not a number, it will be coerced to a number. If the result
+ * of coercion is `NaN` or `0`, then the entire buffer will be searched. This
+ * behavior matches [`String.prototype.indexOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf).
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const b = Buffer.from('abcdef');
+ *
+ * // Passing a value that's a number, but not a valid byte.
+ * // Prints: 2, equivalent to searching for 99 or 'c'.
+ * console.log(b.indexOf(99.9));
+ * console.log(b.indexOf(256 + 99));
+ *
+ * // Passing a byteOffset that coerces to NaN or 0.
+ * // Prints: 1, searching the whole buffer.
+ * console.log(b.indexOf('b', undefined));
+ * console.log(b.indexOf('b', {}));
+ * console.log(b.indexOf('b', null));
+ * console.log(b.indexOf('b', []));
+ * ```
+ *
+ * If `value` is an empty string or empty `Buffer` and `byteOffset` is less
+ * than `buf.length`, `byteOffset` will be returned. If `value` is empty and`byteOffset` is at least `buf.length`, `buf.length` will be returned.
+ * @since v1.5.0
+ * @param value What to search for.
+ * @param [byteOffset=0] Where to begin searching in `buf`. If negative, then offset is calculated from the end of `buf`.
+ * @param [encoding='utf8'] If `value` is a string, this is the encoding used to determine the binary representation of the string that will be searched for in `buf`.
+ * @return The index of the first occurrence of `value` in `buf`, or `-1` if `buf` does not contain `value`.
+ */
+ indexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number;
+ indexOf(value: string | number | Uint8Array, encoding: BufferEncoding): number;
+ /**
+ * Identical to `buf.indexOf()`, except the last occurrence of `value` is found
+ * rather than the first occurrence.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.from('this buffer is a buffer');
+ *
+ * console.log(buf.lastIndexOf('this'));
+ * // Prints: 0
+ * console.log(buf.lastIndexOf('buffer'));
+ * // Prints: 17
+ * console.log(buf.lastIndexOf(Buffer.from('buffer')));
+ * // Prints: 17
+ * console.log(buf.lastIndexOf(97));
+ * // Prints: 15 (97 is the decimal ASCII value for 'a')
+ * console.log(buf.lastIndexOf(Buffer.from('yolo')));
+ * // Prints: -1
+ * console.log(buf.lastIndexOf('buffer', 5));
+ * // Prints: 5
+ * console.log(buf.lastIndexOf('buffer', 4));
+ * // Prints: -1
+ *
+ * const utf16Buffer = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'utf16le');
+ *
+ * console.log(utf16Buffer.lastIndexOf('\u03a3', undefined, 'utf16le'));
+ * // Prints: 6
+ * console.log(utf16Buffer.lastIndexOf('\u03a3', -5, 'utf16le'));
+ * // Prints: 4
+ * ```
+ *
+ * If `value` is not a string, number, or `Buffer`, this method will throw a `TypeError`. If `value` is a number, it will be coerced to a valid byte value,
+ * an integer between 0 and 255.
+ *
+ * If `byteOffset` is not a number, it will be coerced to a number. Any arguments
+ * that coerce to `NaN`, like `{}` or `undefined`, will search the whole buffer.
+ * This behavior matches [`String.prototype.lastIndexOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf).
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const b = Buffer.from('abcdef');
+ *
+ * // Passing a value that's a number, but not a valid byte.
+ * // Prints: 2, equivalent to searching for 99 or 'c'.
+ * console.log(b.lastIndexOf(99.9));
+ * console.log(b.lastIndexOf(256 + 99));
+ *
+ * // Passing a byteOffset that coerces to NaN.
+ * // Prints: 1, searching the whole buffer.
+ * console.log(b.lastIndexOf('b', undefined));
+ * console.log(b.lastIndexOf('b', {}));
+ *
+ * // Passing a byteOffset that coerces to 0.
+ * // Prints: -1, equivalent to passing 0.
+ * console.log(b.lastIndexOf('b', null));
+ * console.log(b.lastIndexOf('b', []));
+ * ```
+ *
+ * If `value` is an empty string or empty `Buffer`, `byteOffset` will be returned.
+ * @since v6.0.0
+ * @param value What to search for.
+ * @param [byteOffset=buf.length - 1] Where to begin searching in `buf`. If negative, then offset is calculated from the end of `buf`.
+ * @param [encoding='utf8'] If `value` is a string, this is the encoding used to determine the binary representation of the string that will be searched for in `buf`.
+ * @return The index of the last occurrence of `value` in `buf`, or `-1` if `buf` does not contain `value`.
+ */
+ lastIndexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number;
+ lastIndexOf(value: string | number | Uint8Array, encoding: BufferEncoding): number;
+ /**
+ * Equivalent to `buf.indexOf() !== -1`.
+ *
+ * ```js
+ * import { Buffer } from 'node:buffer';
+ *
+ * const buf = Buffer.from('this is a buffer');
+ *
+ * console.log(buf.includes('this'));
+ * // Prints: true
+ * console.log(buf.includes('is'));
+ * // Prints: true
+ * console.log(buf.includes(Buffer.from('a buffer')));
+ * // Prints: true
+ * console.log(buf.includes(97));
+ * // Prints: true (97 is the decimal ASCII value for 'a')
+ * console.log(buf.includes(Buffer.from('a buffer example')));
+ * // Prints: false
+ * console.log(buf.includes(Buffer.from('a buffer example').slice(0, 8)));
+ * // Prints: true
+ * console.log(buf.includes('this', 4));
+ * // Prints: false
+ * ```
+ * @since v5.3.0
+ * @param value What to search for.
+ * @param [byteOffset=0] Where to begin searching in `buf`. If negative, then offset is calculated from the end of `buf`.
+ * @param [encoding='utf8'] If `value` is a string, this is its encoding.
+ * @return `true` if `value` was found in `buf`, `false` otherwise.
+ */
+ includes(value: string | number | Buffer, byteOffset?: number, encoding?: BufferEncoding): boolean;
+ includes(value: string | number | Buffer, encoding: BufferEncoding): boolean;
+ }
+ var Buffer: BufferConstructor;
+ }
+ // #region web types
+ export type BlobPart = NodeJS.BufferSource | Blob | string;
+ export interface BlobPropertyBag {
+ endings?: "native" | "transparent";
+ type?: string;
+ }
+ export interface FilePropertyBag extends BlobPropertyBag {
+ lastModified?: number;
+ }
+ export interface Blob {
+ readonly size: number;
+ readonly type: string;
+ arrayBuffer(): Promise;
+ bytes(): Promise;
+ slice(start?: number, end?: number, contentType?: string): Blob;
+ stream(): ReadableStream;
+ text(): Promise;
+ }
+ export var Blob: {
+ prototype: Blob;
+ new(blobParts?: BlobPart[], options?: BlobPropertyBag): Blob;
+ };
+ export interface File extends Blob {
+ readonly lastModified: number;
+ readonly name: string;
+ readonly webkitRelativePath: string;
+ }
+ export var File: {
+ prototype: File;
+ new(fileBits: BlobPart[], fileName: string, options?: FilePropertyBag): File;
+ };
+ export import atob = globalThis.atob;
+ export import btoa = globalThis.btoa;
+ // #endregion
+}
+declare module "buffer" {
+ export * from "node:buffer";
+}
diff --git a/types/node/v25/child_process.d.ts b/types/node/v25/child_process.d.ts
new file mode 100644
index 00000000000000..e3964ab96fba03
--- /dev/null
+++ b/types/node/v25/child_process.d.ts
@@ -0,0 +1,1366 @@
+declare module "node:child_process" {
+ import { NonSharedBuffer } from "node:buffer";
+ import * as dgram from "node:dgram";
+ import { Abortable, EventEmitter, InternalEventEmitter } from "node:events";
+ import * as net from "node:net";
+ import { Readable, Stream, Writable } from "node:stream";
+ import { URL } from "node:url";
+ type Serializable = string | object | number | boolean | bigint;
+ type SendHandle = net.Socket | net.Server | dgram.Socket | undefined;
+ interface ChildProcessEventMap {
+ "close": [code: number | null, signal: NodeJS.Signals | null];
+ "disconnect": [];
+ "error": [err: Error];
+ "exit": [code: number | null, signal: NodeJS.Signals | null];
+ "message": [message: Serializable, sendHandle: SendHandle];
+ "spawn": [];
+ }
+ /**
+ * Instances of the `ChildProcess` represent spawned child processes.
+ *
+ * Instances of `ChildProcess` are not intended to be created directly. Rather,
+ * use the {@link spawn}, {@link exec},{@link execFile}, or {@link fork} methods to create
+ * instances of `ChildProcess`.
+ * @since v2.2.0
+ */
+ class ChildProcess implements EventEmitter {
+ /**
+ * A `Writable Stream` that represents the child process's `stdin`.
+ *
+ * If a child process waits to read all of its input, the child will not continue
+ * until this stream has been closed via `end()`.
+ *
+ * If the child was spawned with `stdio[0]` set to anything other than `'pipe'`,
+ * then this will be `null`.
+ *
+ * `subprocess.stdin` is an alias for `subprocess.stdio[0]`. Both properties will
+ * refer to the same value.
+ *
+ * The `subprocess.stdin` property can be `null` or `undefined` if the child process could not be successfully spawned.
+ * @since v0.1.90
+ */
+ stdin: Writable | null;
+ /**
+ * A `Readable Stream` that represents the child process's `stdout`.
+ *
+ * If the child was spawned with `stdio[1]` set to anything other than `'pipe'`,
+ * then this will be `null`.
+ *
+ * `subprocess.stdout` is an alias for `subprocess.stdio[1]`. Both properties will
+ * refer to the same value.
+ *
+ * ```js
+ * import { spawn } from 'node:child_process';
+ *
+ * const subprocess = spawn('ls');
+ *
+ * subprocess.stdout.on('data', (data) => {
+ * console.log(`Received chunk ${data}`);
+ * });
+ * ```
+ *
+ * The `subprocess.stdout` property can be `null` or `undefined` if the child process could not be successfully spawned.
+ * @since v0.1.90
+ */
+ stdout: Readable | null;
+ /**
+ * A `Readable Stream` that represents the child process's `stderr`.
+ *
+ * If the child was spawned with `stdio[2]` set to anything other than `'pipe'`,
+ * then this will be `null`.
+ *
+ * `subprocess.stderr` is an alias for `subprocess.stdio[2]`. Both properties will
+ * refer to the same value.
+ *
+ * The `subprocess.stderr` property can be `null` or `undefined` if the child process could not be successfully spawned.
+ * @since v0.1.90
+ */
+ stderr: Readable | null;
+ /**
+ * The `subprocess.channel` property is a reference to the child's IPC channel. If
+ * no IPC channel exists, this property is `undefined`.
+ * @since v7.1.0
+ */
+ readonly channel?: Control | null;
+ /**
+ * A sparse array of pipes to the child process, corresponding with positions in
+ * the `stdio` option passed to {@link spawn} that have been set
+ * to the value `'pipe'`. `subprocess.stdio[0]`, `subprocess.stdio[1]`, and `subprocess.stdio[2]` are also available as `subprocess.stdin`, `subprocess.stdout`, and `subprocess.stderr`,
+ * respectively.
+ *
+ * In the following example, only the child's fd `1` (stdout) is configured as a
+ * pipe, so only the parent's `subprocess.stdio[1]` is a stream, all other values
+ * in the array are `null`.
+ *
+ * ```js
+ * import assert from 'node:assert';
+ * import fs from 'node:fs';
+ * import child_process from 'node:child_process';
+ *
+ * const subprocess = child_process.spawn('ls', {
+ * stdio: [
+ * 0, // Use parent's stdin for child.
+ * 'pipe', // Pipe child's stdout to parent.
+ * fs.openSync('err.out', 'w'), // Direct child's stderr to a file.
+ * ],
+ * });
+ *
+ * assert.strictEqual(subprocess.stdio[0], null);
+ * assert.strictEqual(subprocess.stdio[0], subprocess.stdin);
+ *
+ * assert(subprocess.stdout);
+ * assert.strictEqual(subprocess.stdio[1], subprocess.stdout);
+ *
+ * assert.strictEqual(subprocess.stdio[2], null);
+ * assert.strictEqual(subprocess.stdio[2], subprocess.stderr);
+ * ```
+ *
+ * The `subprocess.stdio` property can be `undefined` if the child process could
+ * not be successfully spawned.
+ * @since v0.7.10
+ */
+ readonly stdio: [
+ Writable | null,
+ // stdin
+ Readable | null,
+ // stdout
+ Readable | null,
+ // stderr
+ Readable | Writable | null | undefined,
+ // extra
+ Readable | Writable | null | undefined, // extra
+ ];
+ /**
+ * The `subprocess.killed` property indicates whether the child process
+ * successfully received a signal from `subprocess.kill()`. The `killed` property
+ * does not indicate that the child process has been terminated.
+ * @since v0.5.10
+ */
+ readonly killed: boolean;
+ /**
+ * Returns the process identifier (PID) of the child process. If the child process
+ * fails to spawn due to errors, then the value is `undefined` and `error` is
+ * emitted.
+ *
+ * ```js
+ * import { spawn } from 'node:child_process';
+ * const grep = spawn('grep', ['ssh']);
+ *
+ * console.log(`Spawned child pid: ${grep.pid}`);
+ * grep.stdin.end();
+ * ```
+ * @since v0.1.90
+ */
+ readonly pid?: number | undefined;
+ /**
+ * The `subprocess.connected` property indicates whether it is still possible to
+ * send and receive messages from a child process. When `subprocess.connected` is `false`, it is no longer possible to send or receive messages.
+ * @since v0.7.2
+ */
+ readonly connected: boolean;
+ /**
+ * The `subprocess.exitCode` property indicates the exit code of the child process.
+ * If the child process is still running, the field will be `null`.
+ *
+ * When the child process is terminated by a signal, `subprocess.exitCode` will be
+ * `null` and `subprocess.signalCode` will be set. To get the corresponding
+ * POSIX exit code, use
+ * `util.convertProcessSignalToExitCode(subprocess.signalCode)`.
+ */
+ readonly exitCode: number | null;
+ /**
+ * The `subprocess.signalCode` property indicates the signal received by
+ * the child process if any, else `null`.
+ */
+ readonly signalCode: NodeJS.Signals | null;
+ /**
+ * The `subprocess.spawnargs` property represents the full list of command-line
+ * arguments the child process was launched with.
+ */
+ readonly spawnargs: string[];
+ /**
+ * The `subprocess.spawnfile` property indicates the executable file name of
+ * the child process that is launched.
+ *
+ * For {@link fork}, its value will be equal to `process.execPath`.
+ * For {@link spawn}, its value will be the name of
+ * the executable file.
+ * For {@link exec}, its value will be the name of the shell
+ * in which the child process is launched.
+ */
+ readonly spawnfile: string;
+ /**
+ * The `subprocess.kill()` method sends a signal to the child process. If no
+ * argument is given, the process will be sent the `'SIGTERM'` signal. See [`signal(7)`](http://man7.org/linux/man-pages/man7/signal.7.html) for a list of available signals. This function
+ * returns `true` if [`kill(2)`](http://man7.org/linux/man-pages/man2/kill.2.html) succeeds, and `false` otherwise.
+ *
+ * ```js
+ * import { spawn } from 'node:child_process';
+ * const grep = spawn('grep', ['ssh']);
+ *
+ * grep.on('close', (code, signal) => {
+ * console.log(
+ * `child process terminated due to receipt of signal ${signal}`);
+ * });
+ *
+ * // Send SIGHUP to process.
+ * grep.kill('SIGHUP');
+ * ```
+ *
+ * The `ChildProcess` object may emit an `'error'` event if the signal
+ * cannot be delivered. Sending a signal to a child process that has already exited
+ * is not an error but may have unforeseen consequences. Specifically, if the
+ * process identifier (PID) has been reassigned to another process, the signal will
+ * be delivered to that process instead which can have unexpected results.
+ *
+ * While the function is called `kill`, the signal delivered to the child process
+ * may not actually terminate the process.
+ *
+ * See [`kill(2)`](http://man7.org/linux/man-pages/man2/kill.2.html) for reference.
+ *
+ * On Windows, where POSIX signals do not exist, the `signal` argument will be
+ * ignored, and the process will be killed forcefully and abruptly (similar to `'SIGKILL'`).
+ * See `Signal Events` for more details.
+ *
+ * On Linux, child processes of child processes will not be terminated
+ * when attempting to kill their parent. This is likely to happen when running a
+ * new process in a shell or with the use of the `shell` option of `ChildProcess`:
+ *
+ * ```js
+ * 'use strict';
+ * import { spawn } from 'node:child_process';
+ *
+ * const subprocess = spawn(
+ * 'sh',
+ * [
+ * '-c',
+ * `node -e "setInterval(() => {
+ * console.log(process.pid, 'is alive')
+ * }, 500);"`,
+ * ], {
+ * stdio: ['inherit', 'inherit', 'inherit'],
+ * },
+ * );
+ *
+ * setTimeout(() => {
+ * subprocess.kill(); // Does not terminate the Node.js process in the shell.
+ * }, 2000);
+ * ```
+ * @since v0.1.90
+ */
+ kill(signal?: NodeJS.Signals | number): boolean;
+ /**
+ * Calls {@link ChildProcess.kill} with `'SIGTERM'`.
+ * @since v20.5.0
+ */
+ [Symbol.dispose](): void;
+ /**
+ * When an IPC channel has been established between the parent and child (
+ * i.e. when using {@link fork}), the `subprocess.send()` method can
+ * be used to send messages to the child process. When the child process is a
+ * Node.js instance, these messages can be received via the `'message'` event.
+ *
+ * The message goes through serialization and parsing. The resulting
+ * message might not be the same as what is originally sent.
+ *
+ * For example, in the parent script:
+ *
+ * ```js
+ * import cp from 'node:child_process';
+ * const n = cp.fork(`${__dirname}/sub.js`);
+ *
+ * n.on('message', (m) => {
+ * console.log('PARENT got message:', m);
+ * });
+ *
+ * // Causes the child to print: CHILD got message: { hello: 'world' }
+ * n.send({ hello: 'world' });
+ * ```
+ *
+ * And then the child script, `'sub.js'` might look like this:
+ *
+ * ```js
+ * process.on('message', (m) => {
+ * console.log('CHILD got message:', m);
+ * });
+ *
+ * // Causes the parent to print: PARENT got message: { foo: 'bar', baz: null }
+ * process.send({ foo: 'bar', baz: NaN });
+ * ```
+ *
+ * Child Node.js processes will have a `process.send()` method of their own
+ * that allows the child to send messages back to the parent.
+ *
+ * There is a special case when sending a `{cmd: 'NODE_foo'}` message. Messages
+ * containing a `NODE_` prefix in the `cmd` property are reserved for use within
+ * Node.js core and will not be emitted in the child's `'message'` event. Rather, such messages are emitted using the `'internalMessage'` event and are consumed internally by Node.js.
+ * Applications should avoid using such messages or listening for `'internalMessage'` events as it is subject to change without notice.
+ *
+ * The optional `sendHandle` argument that may be passed to `subprocess.send()` is
+ * for passing a TCP server or socket object to the child process. The child will
+ * receive the object as the second argument passed to the callback function
+ * registered on the `'message'` event. Any data that is received and buffered in
+ * the socket will not be sent to the child. Sending IPC sockets is not supported on Windows.
+ *
+ * The optional `callback` is a function that is invoked after the message is
+ * sent but before the child may have received it. The function is called with a
+ * single argument: `null` on success, or an `Error` object on failure.
+ *
+ * If no `callback` function is provided and the message cannot be sent, an `'error'` event will be emitted by the `ChildProcess` object. This can
+ * happen, for instance, when the child process has already exited.
+ *
+ * `subprocess.send()` will return `false` if the channel has closed or when the
+ * backlog of unsent messages exceeds a threshold that makes it unwise to send
+ * more. Otherwise, the method returns `true`. The `callback` function can be
+ * used to implement flow control.
+ *
+ * #### Example: sending a server object
+ *
+ * The `sendHandle` argument can be used, for instance, to pass the handle of
+ * a TCP server object to the child process as illustrated in the example below:
+ *
+ * ```js
+ * import { createServer } from 'node:net';
+ * import { fork } from 'node:child_process';
+ * const subprocess = fork('subprocess.js');
+ *
+ * // Open up the server object and send the handle.
+ * const server = createServer();
+ * server.on('connection', (socket) => {
+ * socket.end('handled by parent');
+ * });
+ * server.listen(1337, () => {
+ * subprocess.send('server', server);
+ * });
+ * ```
+ *
+ * The child would then receive the server object as:
+ *
+ * ```js
+ * process.on('message', (m, server) => {
+ * if (m === 'server') {
+ * server.on('connection', (socket) => {
+ * socket.end('handled by child');
+ * });
+ * }
+ * });
+ * ```
+ *
+ * Once the server is now shared between the parent and child, some connections
+ * can be handled by the parent and some by the child.
+ *
+ * While the example above uses a server created using the `node:net` module, `node:dgram` module servers use exactly the same workflow with the exceptions of
+ * listening on a `'message'` event instead of `'connection'` and using `server.bind()` instead of `server.listen()`. This is, however, only
+ * supported on Unix platforms.
+ *
+ * #### Example: sending a socket object
+ *
+ * Similarly, the `sendHandler` argument can be used to pass the handle of a
+ * socket to the child process. The example below spawns two children that each
+ * handle connections with "normal" or "special" priority:
+ *
+ * ```js
+ * import { createServer } from 'node:net';
+ * import { fork } from 'node:child_process';
+ * const normal = fork('subprocess.js', ['normal']);
+ * const special = fork('subprocess.js', ['special']);
+ *
+ * // Open up the server and send sockets to child. Use pauseOnConnect to prevent
+ * // the sockets from being read before they are sent to the child process.
+ * const server = createServer({ pauseOnConnect: true });
+ * server.on('connection', (socket) => {
+ *
+ * // If this is special priority...
+ * if (socket.remoteAddress === '74.125.127.100') {
+ * special.send('socket', socket);
+ * return;
+ * }
+ * // This is normal priority.
+ * normal.send('socket', socket);
+ * });
+ * server.listen(1337);
+ * ```
+ *
+ * The `subprocess.js` would receive the socket handle as the second argument
+ * passed to the event callback function:
+ *
+ * ```js
+ * process.on('message', (m, socket) => {
+ * if (m === 'socket') {
+ * if (socket) {
+ * // Check that the client socket exists.
+ * // It is possible for the socket to be closed between the time it is
+ * // sent and the time it is received in the child process.
+ * socket.end(`Request handled with ${process.argv[2]} priority`);
+ * }
+ * }
+ * });
+ * ```
+ *
+ * Do not use `.maxConnections` on a socket that has been passed to a subprocess.
+ * The parent cannot track when the socket is destroyed.
+ *
+ * Any `'message'` handlers in the subprocess should verify that `socket` exists,
+ * as the connection may have been closed during the time it takes to send the
+ * connection to the child.
+ * @since v0.5.9
+ * @param sendHandle `undefined`, or a [`net.Socket`](https://nodejs.org/docs/latest-v25.x/api/net.html#class-netsocket), [`net.Server`](https://nodejs.org/docs/latest-v25.x/api/net.html#class-netserver), or [`dgram.Socket`](https://nodejs.org/docs/latest-v25.x/api/dgram.html#class-dgramsocket) object.
+ * @param options The `options` argument, if present, is an object used to parameterize the sending of certain types of handles. `options` supports the following properties:
+ */
+ send(message: Serializable, callback?: (error: Error | null) => void): boolean;
+ send(message: Serializable, sendHandle?: SendHandle, callback?: (error: Error | null) => void): boolean;
+ send(
+ message: Serializable,
+ sendHandle?: SendHandle,
+ options?: MessageOptions,
+ callback?: (error: Error | null) => void,
+ ): boolean;
+ /**
+ * Closes the IPC channel between parent and child, allowing the child to exit
+ * gracefully once there are no other connections keeping it alive. After calling
+ * this method the `subprocess.connected` and `process.connected` properties in
+ * both the parent and child (respectively) will be set to `false`, and it will be
+ * no longer possible to pass messages between the processes.
+ *
+ * The `'disconnect'` event will be emitted when there are no messages in the
+ * process of being received. This will most often be triggered immediately after
+ * calling `subprocess.disconnect()`.
+ *
+ * When the child process is a Node.js instance (e.g. spawned using {@link fork}), the `process.disconnect()` method can be invoked
+ * within the child process to close the IPC channel as well.
+ * @since v0.7.2
+ */
+ disconnect(): void;
+ /**
+ * By default, the parent will wait for the detached child to exit. To prevent the
+ * parent from waiting for a given `subprocess` to exit, use the `subprocess.unref()` method. Doing so will cause the parent's event loop to not
+ * include the child in its reference count, allowing the parent to exit
+ * independently of the child, unless there is an established IPC channel between
+ * the child and the parent.
+ *
+ * ```js
+ * import { spawn } from 'node:child_process';
+ *
+ * const subprocess = spawn(process.argv[0], ['child_program.js'], {
+ * detached: true,
+ * stdio: 'ignore',
+ * });
+ *
+ * subprocess.unref();
+ * ```
+ * @since v0.7.10
+ */
+ unref(): void;
+ /**
+ * Calling `subprocess.ref()` after making a call to `subprocess.unref()` will
+ * restore the removed reference count for the child process, forcing the parent
+ * to wait for the child to exit before exiting itself.
+ *
+ * ```js
+ * import { spawn } from 'node:child_process';
+ *
+ * const subprocess = spawn(process.argv[0], ['child_program.js'], {
+ * detached: true,
+ * stdio: 'ignore',
+ * });
+ *
+ * subprocess.unref();
+ * subprocess.ref();
+ * ```
+ * @since v0.7.10
+ */
+ ref(): void;
+ }
+ interface ChildProcess extends InternalEventEmitter {}
+ // return this object when stdio option is undefined or not specified
+ interface ChildProcessWithoutNullStreams extends ChildProcess {
+ stdin: Writable;
+ stdout: Readable;
+ stderr: Readable;
+ readonly stdio: [
+ Writable,
+ Readable,
+ Readable,
+ // stderr
+ Readable | Writable | null | undefined,
+ // extra, no modification
+ Readable | Writable | null | undefined, // extra, no modification
+ ];
+ }
+ // return this object when stdio option is a tuple of 3
+ interface ChildProcessByStdio
+ extends ChildProcess
+ {
+ stdin: I;
+ stdout: O;
+ stderr: E;
+ readonly stdio: [
+ I,
+ O,
+ E,
+ Readable | Writable | null | undefined,
+ // extra, no modification
+ Readable | Writable | null | undefined, // extra, no modification
+ ];
+ }
+ interface Control extends EventEmitter {
+ ref(): void;
+ unref(): void;
+ }
+ interface MessageOptions {
+ keepOpen?: boolean | undefined;
+ }
+ type IOType = "overlapped" | "pipe" | "ignore" | "inherit";
+ type StdioOptions = IOType | Array;
+ type SerializationType = "json" | "advanced";
+ interface MessagingOptions extends Abortable {
+ /**
+ * Specify the kind of serialization used for sending messages between processes.
+ * @default 'json'
+ */
+ serialization?: SerializationType | undefined;
+ /**
+ * The signal value to be used when the spawned process will be killed by the abort signal.
+ * @default 'SIGTERM'
+ */
+ killSignal?: NodeJS.Signals | number | undefined;
+ /**
+ * In milliseconds the maximum amount of time the process is allowed to run.
+ */
+ timeout?: number | undefined;
+ }
+ interface ProcessEnvOptions {
+ uid?: number | undefined;
+ gid?: number | undefined;
+ cwd?: string | URL | undefined;
+ env?: NodeJS.ProcessEnv | undefined;
+ }
+ interface CommonOptions extends ProcessEnvOptions {
+ /**
+ * @default false
+ */
+ windowsHide?: boolean | undefined;
+ /**
+ * @default 0
+ */
+ timeout?: number | undefined;
+ }
+ interface CommonSpawnOptions extends CommonOptions, MessagingOptions, Abortable {
+ argv0?: string | undefined;
+ /**
+ * Can be set to 'pipe', 'inherit', 'overlapped', or 'ignore', or an array of these strings.
+ * If passed as an array, the first element is used for `stdin`, the second for
+ * `stdout`, and the third for `stderr`. A fourth element can be used to
+ * specify the `stdio` behavior beyond the standard streams. See
+ * {@link ChildProcess.stdio} for more information.
+ *
+ * @default 'pipe'
+ */
+ stdio?: StdioOptions | undefined;
+ shell?: boolean | string | undefined;
+ windowsVerbatimArguments?: boolean | undefined;
+ }
+ interface SpawnOptions extends CommonSpawnOptions {
+ detached?: boolean | undefined;
+ }
+ interface SpawnOptionsWithoutStdio extends SpawnOptions {
+ stdio?: StdioPipeNamed | StdioPipe[] | undefined;
+ }
+ type StdioNull = "inherit" | "ignore" | Stream;
+ type StdioPipeNamed = "pipe" | "overlapped";
+ type StdioPipe = undefined | null | StdioPipeNamed;
+ interface SpawnOptionsWithStdioTuple<
+ Stdin extends StdioNull | StdioPipe,
+ Stdout extends StdioNull | StdioPipe,
+ Stderr extends StdioNull | StdioPipe,
+ > extends SpawnOptions {
+ stdio: [Stdin, Stdout, Stderr];
+ }
+ /**
+ * The `child_process.spawn()` method spawns a new process using the given `command`, with command-line arguments in `args`. If omitted, `args` defaults
+ * to an empty array.
+ *
+ * **If the `shell` option is enabled, do not pass unsanitized user input to this**
+ * **function. Any input containing shell metacharacters may be used to trigger**
+ * **arbitrary command execution.**
+ *
+ * A third argument may be used to specify additional options, with these defaults:
+ *
+ * ```js
+ * const defaults = {
+ * cwd: undefined,
+ * env: process.env,
+ * };
+ * ```
+ *
+ * Use `cwd` to specify the working directory from which the process is spawned.
+ * If not given, the default is to inherit the current working directory. If given,
+ * but the path does not exist, the child process emits an `ENOENT` error
+ * and exits immediately. `ENOENT` is also emitted when the command
+ * does not exist.
+ *
+ * Use `env` to specify environment variables that will be visible to the new
+ * process, the default is `process.env`.
+ *
+ * `undefined` values in `env` will be ignored.
+ *
+ * Example of running `ls -lh /usr`, capturing `stdout`, `stderr`, and the
+ * exit code:
+ *
+ * ```js
+ * import { spawn } from 'node:child_process';
+ * import { once } from 'node:events';
+ * const ls = spawn('ls', ['-lh', '/usr']);
+ *
+ * ls.stdout.on('data', (data) => {
+ * console.log(`stdout: ${data}`);
+ * });
+ *
+ * ls.stderr.on('data', (data) => {
+ * console.error(`stderr: ${data}`);
+ * });
+ *
+ * const [code] = await once(ls, 'close');
+ * console.log(`child process exited with code ${code}`);
+ * ```
+ *
+ * Example: A very elaborate way to run `ps ax | grep ssh`
+ *
+ * ```js
+ * import { spawn } from 'node:child_process';
+ * const ps = spawn('ps', ['ax']);
+ * const grep = spawn('grep', ['ssh']);
+ *
+ * ps.stdout.on('data', (data) => {
+ * grep.stdin.write(data);
+ * });
+ *
+ * ps.stderr.on('data', (data) => {
+ * console.error(`ps stderr: ${data}`);
+ * });
+ *
+ * ps.on('close', (code) => {
+ * if (code !== 0) {
+ * console.log(`ps process exited with code ${code}`);
+ * }
+ * grep.stdin.end();
+ * });
+ *
+ * grep.stdout.on('data', (data) => {
+ * console.log(data.toString());
+ * });
+ *
+ * grep.stderr.on('data', (data) => {
+ * console.error(`grep stderr: ${data}`);
+ * });
+ *
+ * grep.on('close', (code) => {
+ * if (code !== 0) {
+ * console.log(`grep process exited with code ${code}`);
+ * }
+ * });
+ * ```
+ *
+ * Example of checking for failed `spawn`:
+ *
+ * ```js
+ * import { spawn } from 'node:child_process';
+ * const subprocess = spawn('bad_command');
+ *
+ * subprocess.on('error', (err) => {
+ * console.error('Failed to start subprocess.');
+ * });
+ * ```
+ *
+ * Certain platforms (macOS, Linux) will use the value of `argv[0]` for the process
+ * title while others (Windows, SunOS) will use `command`.
+ *
+ * Node.js overwrites `argv[0]` with `process.execPath` on startup, so `process.argv[0]` in a Node.js child process will not match the `argv0` parameter passed to `spawn` from the parent. Retrieve
+ * it with the `process.argv0` property instead.
+ *
+ * If the `signal` option is enabled, calling `.abort()` on the corresponding `AbortController` is similar to calling `.kill()` on the child process except
+ * the error passed to the callback will be an `AbortError`:
+ *
+ * ```js
+ * import { spawn } from 'node:child_process';
+ * const controller = new AbortController();
+ * const { signal } = controller;
+ * const grep = spawn('grep', ['ssh'], { signal });
+ * grep.on('error', (err) => {
+ * // This will be called with err being an AbortError if the controller aborts
+ * });
+ * controller.abort(); // Stops the child process
+ * ```
+ * @since v0.1.90
+ * @param command The command to run.
+ * @param args List of string arguments.
+ */
+ function spawn(command: string, options?: SpawnOptionsWithoutStdio): ChildProcessWithoutNullStreams;
+ function spawn(
+ command: string,
+ options: SpawnOptionsWithStdioTuple,
+ ): ChildProcessByStdio;
+ function spawn(
+ command: string,
+ options: SpawnOptionsWithStdioTuple,
+ ): ChildProcessByStdio;
+ function spawn(
+ command: string,
+ options: SpawnOptionsWithStdioTuple,
+ ): ChildProcessByStdio;
+ function spawn(
+ command: string,
+ options: SpawnOptionsWithStdioTuple,
+ ): ChildProcessByStdio;
+ function spawn(
+ command: string,
+ options: SpawnOptionsWithStdioTuple,
+ ): ChildProcessByStdio;
+ function spawn(
+ command: string,
+ options: SpawnOptionsWithStdioTuple,
+ ): ChildProcessByStdio;
+ function spawn(
+ command: string,
+ options: SpawnOptionsWithStdioTuple,
+ ): ChildProcessByStdio;
+ function spawn(
+ command: string,
+ options: SpawnOptionsWithStdioTuple,
+ ): ChildProcessByStdio;
+ function spawn(command: string, options: SpawnOptions): ChildProcess;
+ // overloads of spawn with 'args'
+ function spawn(
+ command: string,
+ args?: readonly string[],
+ options?: SpawnOptionsWithoutStdio,
+ ): ChildProcessWithoutNullStreams;
+ function spawn(
+ command: string,
+ args: readonly string[],
+ options: SpawnOptionsWithStdioTuple,
+ ): ChildProcessByStdio;
+ function spawn(
+ command: string,
+ args: readonly string[],
+ options: SpawnOptionsWithStdioTuple,
+ ): ChildProcessByStdio;
+ function spawn(
+ command: string,
+ args: readonly string[],
+ options: SpawnOptionsWithStdioTuple,
+ ): ChildProcessByStdio;
+ function spawn(
+ command: string,
+ args: readonly string[],
+ options: SpawnOptionsWithStdioTuple,
+ ): ChildProcessByStdio;
+ function spawn(
+ command: string,
+ args: readonly string[],
+ options: SpawnOptionsWithStdioTuple,
+ ): ChildProcessByStdio;
+ function spawn(
+ command: string,
+ args: readonly string[],
+ options: SpawnOptionsWithStdioTuple,
+ ): ChildProcessByStdio;
+ function spawn(
+ command: string,
+ args: readonly string[],
+ options: SpawnOptionsWithStdioTuple,
+ ): ChildProcessByStdio;
+ function spawn(
+ command: string,
+ args: readonly string[],
+ options: SpawnOptionsWithStdioTuple,
+ ): ChildProcessByStdio;
+ function spawn(command: string, args: readonly string[], options: SpawnOptions): ChildProcess;
+ interface ExecOptions extends CommonOptions {
+ shell?: string | undefined;
+ signal?: AbortSignal | undefined;
+ maxBuffer?: number | undefined;
+ killSignal?: NodeJS.Signals | number | undefined;
+ encoding?: string | null | undefined;
+ }
+ interface ExecOptionsWithStringEncoding extends ExecOptions {
+ encoding?: BufferEncoding | undefined;
+ }
+ interface ExecOptionsWithBufferEncoding extends ExecOptions {
+ encoding: "buffer" | null; // specify `null`.
+ }
+ // TODO: Just Plain Wrong™ (see also nodejs/node#57392)
+ interface ExecException extends Error {
+ cmd?: string;
+ killed?: boolean;
+ code?: number;
+ signal?: NodeJS.Signals;
+ stdout?: string;
+ stderr?: string;
+ }
+ /**
+ * Spawns a shell then executes the `command` within that shell, buffering any
+ * generated output. The `command` string passed to the exec function is processed
+ * directly by the shell and special characters (vary based on [shell](https://en.wikipedia.org/wiki/List_of_command-line_interpreters))
+ * need to be dealt with accordingly:
+ *
+ * ```js
+ * import { exec } from 'node:child_process';
+ *
+ * exec('"/path/to/test file/test.sh" arg1 arg2');
+ * // Double quotes are used so that the space in the path is not interpreted as
+ * // a delimiter of multiple arguments.
+ *
+ * exec('echo "The \\$HOME variable is $HOME"');
+ * // The $HOME variable is escaped in the first instance, but not in the second.
+ * ```
+ *
+ * **Never pass unsanitized user input to this function. Any input containing shell**
+ * **metacharacters may be used to trigger arbitrary command execution.**
+ *
+ * If a `callback` function is provided, it is called with the arguments `(error, stdout, stderr)`. On success, `error` will be `null`. On error, `error` will be an instance of `Error`. The
+ * `error.code` property will be
+ * the exit code of the process. By convention, any exit code other than `0` indicates an error. `error.signal` will be the signal that terminated the
+ * process.
+ *
+ * The `stdout` and `stderr` arguments passed to the callback will contain the
+ * stdout and stderr output of the child process. By default, Node.js will decode
+ * the output as UTF-8 and pass strings to the callback. The `encoding` option
+ * can be used to specify the character encoding used to decode the stdout and
+ * stderr output. If `encoding` is `'buffer'`, or an unrecognized character
+ * encoding, `Buffer` objects will be passed to the callback instead.
+ *
+ * ```js
+ * import { exec } from 'node:child_process';
+ * exec('cat *.js missing_file | wc -l', (error, stdout, stderr) => {
+ * if (error) {
+ * console.error(`exec error: ${error}`);
+ * return;
+ * }
+ * console.log(`stdout: ${stdout}`);
+ * console.error(`stderr: ${stderr}`);
+ * });
+ * ```
+ *
+ * If `timeout` is greater than `0`, the parent will send the signal
+ * identified by the `killSignal` property (the default is `'SIGTERM'`) if the
+ * child runs longer than `timeout` milliseconds.
+ *
+ * Unlike the [`exec(3)`](http://man7.org/linux/man-pages/man3/exec.3.html) POSIX system call, `child_process.exec()` does not replace
+ * the existing process and uses a shell to execute the command.
+ *
+ * If this method is invoked as its `util.promisify()` ed version, it returns
+ * a `Promise` for an `Object` with `stdout` and `stderr` properties. The returned `ChildProcess` instance is attached to the `Promise` as a `child` property. In
+ * case of an error (including any error resulting in an exit code other than 0), a
+ * rejected promise is returned, with the same `error` object given in the
+ * callback, but with two additional properties `stdout` and `stderr`.
+ *
+ * ```js
+ * import util from 'node:util';
+ * import child_process from 'node:child_process';
+ * const exec = util.promisify(child_process.exec);
+ *
+ * async function lsExample() {
+ * const { stdout, stderr } = await exec('ls');
+ * console.log('stdout:', stdout);
+ * console.error('stderr:', stderr);
+ * }
+ * lsExample();
+ * ```
+ *
+ * If the `signal` option is enabled, calling `.abort()` on the corresponding `AbortController` is similar to calling `.kill()` on the child process except
+ * the error passed to the callback will be an `AbortError`:
+ *
+ * ```js
+ * import { exec } from 'node:child_process';
+ * const controller = new AbortController();
+ * const { signal } = controller;
+ * const child = exec('grep ssh', { signal }, (error) => {
+ * console.error(error); // an AbortError
+ * });
+ * controller.abort();
+ * ```
+ * @since v0.1.90
+ * @param command The command to run, with space-separated arguments.
+ * @param callback called with the output when process terminates.
+ */
+ function exec(
+ command: string,
+ callback?: (error: ExecException | null, stdout: string, stderr: string) => void,
+ ): ChildProcess;
+ // `options` with `"buffer"` or `null` for `encoding` means stdout/stderr are definitely `Buffer`.
+ function exec(
+ command: string,
+ options: ExecOptionsWithBufferEncoding,
+ callback?: (error: ExecException | null, stdout: NonSharedBuffer, stderr: NonSharedBuffer) => void,
+ ): ChildProcess;
+ // `options` with well-known or absent `encoding` means stdout/stderr are definitely `string`.
+ function exec(
+ command: string,
+ options: ExecOptionsWithStringEncoding,
+ callback?: (error: ExecException | null, stdout: string, stderr: string) => void,
+ ): ChildProcess;
+ // fallback if nothing else matches. Worst case is always `string | Buffer`.
+ function exec(
+ command: string,
+ options: ExecOptions | undefined | null,
+ callback?: (
+ error: ExecException | null,
+ stdout: string | NonSharedBuffer,
+ stderr: string | NonSharedBuffer,
+ ) => void,
+ ): ChildProcess;
+ interface PromiseWithChild extends Promise {
+ child: ChildProcess;
+ }
+ namespace exec {
+ function __promisify__(command: string): PromiseWithChild<{
+ stdout: string;
+ stderr: string;
+ }>;
+ function __promisify__(
+ command: string,
+ options: ExecOptionsWithBufferEncoding,
+ ): PromiseWithChild<{
+ stdout: NonSharedBuffer;
+ stderr: NonSharedBuffer;
+ }>;
+ function __promisify__(
+ command: string,
+ options: ExecOptionsWithStringEncoding,
+ ): PromiseWithChild<{
+ stdout: string;
+ stderr: string;
+ }>;
+ function __promisify__(
+ command: string,
+ options: ExecOptions | undefined | null,
+ ): PromiseWithChild<{
+ stdout: string | NonSharedBuffer;
+ stderr: string | NonSharedBuffer;
+ }>;
+ }
+ interface ExecFileOptions extends CommonOptions, Abortable {
+ maxBuffer?: number | undefined;
+ killSignal?: NodeJS.Signals | number | undefined;
+ windowsVerbatimArguments?: boolean | undefined;
+ shell?: boolean | string | undefined;
+ signal?: AbortSignal | undefined;
+ encoding?: string | null | undefined;
+ }
+ interface ExecFileOptionsWithStringEncoding extends ExecFileOptions {
+ encoding?: BufferEncoding | undefined;
+ }
+ interface ExecFileOptionsWithBufferEncoding extends ExecFileOptions {
+ encoding: "buffer" | null;
+ }
+ /** @deprecated Use `ExecFileOptions` instead. */
+ interface ExecFileOptionsWithOtherEncoding extends ExecFileOptions {}
+ // TODO: execFile exceptions can take many forms... this accurately describes none of them
+ type ExecFileException =
+ & Omit
+ & Omit
+ & { code?: string | number | null };
+ /**
+ * The `child_process.execFile()` function is similar to {@link exec} except that it does not spawn a shell by default. Rather, the specified
+ * executable `file` is spawned directly as a new process making it slightly more
+ * efficient than {@link exec}.
+ *
+ * The same options as {@link exec} are supported. Since a shell is
+ * not spawned, behaviors such as I/O redirection and file globbing are not
+ * supported.
+ *
+ * ```js
+ * import { execFile } from 'node:child_process';
+ * const child = execFile('node', ['--version'], (error, stdout, stderr) => {
+ * if (error) {
+ * throw error;
+ * }
+ * console.log(stdout);
+ * });
+ * ```
+ *
+ * The `stdout` and `stderr` arguments passed to the callback will contain the
+ * stdout and stderr output of the child process. By default, Node.js will decode
+ * the output as UTF-8 and pass strings to the callback. The `encoding` option
+ * can be used to specify the character encoding used to decode the stdout and
+ * stderr output. If `encoding` is `'buffer'`, or an unrecognized character
+ * encoding, `Buffer` objects will be passed to the callback instead.
+ *
+ * If this method is invoked as its `util.promisify()` ed version, it returns
+ * a `Promise` for an `Object` with `stdout` and `stderr` properties. The returned `ChildProcess` instance is attached to the `Promise` as a `child` property. In
+ * case of an error (including any error resulting in an exit code other than 0), a
+ * rejected promise is returned, with the same `error` object given in the
+ * callback, but with two additional properties `stdout` and `stderr`.
+ *
+ * ```js
+ * import util from 'node:util';
+ * import child_process from 'node:child_process';
+ * const execFile = util.promisify(child_process.execFile);
+ * async function getVersion() {
+ * const { stdout } = await execFile('node', ['--version']);
+ * console.log(stdout);
+ * }
+ * getVersion();
+ * ```
+ *
+ * **If the `shell` option is enabled, do not pass unsanitized user input to this**
+ * **function. Any input containing shell metacharacters may be used to trigger**
+ * **arbitrary command execution.**
+ *
+ * If the `signal` option is enabled, calling `.abort()` on the corresponding `AbortController` is similar to calling `.kill()` on the child process except
+ * the error passed to the callback will be an `AbortError`:
+ *
+ * ```js
+ * import { execFile } from 'node:child_process';
+ * const controller = new AbortController();
+ * const { signal } = controller;
+ * const child = execFile('node', ['--version'], { signal }, (error) => {
+ * console.error(error); // an AbortError
+ * });
+ * controller.abort();
+ * ```
+ * @since v0.1.91
+ * @param file The name or path of the executable file to run.
+ * @param args List of string arguments.
+ * @param callback Called with the output when process terminates.
+ */
+ // no `options` definitely means stdout/stderr are `string`.
+ function execFile(
+ file: string,
+ callback?: (error: ExecFileException | null, stdout: string, stderr: string) => void,
+ ): ChildProcess;
+ function execFile(
+ file: string,
+ args: readonly string[] | undefined | null,
+ callback?: (error: ExecFileException | null, stdout: string, stderr: string) => void,
+ ): ChildProcess;
+ // `options` with `"buffer"` or `null` for `encoding` means stdout/stderr are definitely `Buffer`.
+ function execFile(
+ file: string,
+ options: ExecFileOptionsWithBufferEncoding,
+ callback?: (error: ExecFileException | null, stdout: NonSharedBuffer, stderr: NonSharedBuffer) => void,
+ ): ChildProcess;
+ function execFile(
+ file: string,
+ args: readonly string[] | undefined | null,
+ options: ExecFileOptionsWithBufferEncoding,
+ callback?: (error: ExecFileException | null, stdout: NonSharedBuffer, stderr: NonSharedBuffer) => void,
+ ): ChildProcess;
+ // `options` with well-known or absent `encoding` means stdout/stderr are definitely `string`.
+ function execFile(
+ file: string,
+ options: ExecFileOptionsWithStringEncoding,
+ callback?: (error: ExecFileException | null, stdout: string, stderr: string) => void,
+ ): ChildProcess;
+ function execFile(
+ file: string,
+ args: readonly string[] | undefined | null,
+ options: ExecFileOptionsWithStringEncoding,
+ callback?: (error: ExecFileException | null, stdout: string, stderr: string) => void,
+ ): ChildProcess;
+ // fallback if nothing else matches. Worst case is always `string | Buffer`.
+ function execFile(
+ file: string,
+ options: ExecFileOptions | undefined | null,
+ callback:
+ | ((
+ error: ExecFileException | null,
+ stdout: string | NonSharedBuffer,
+ stderr: string | NonSharedBuffer,
+ ) => void)
+ | undefined
+ | null,
+ ): ChildProcess;
+ function execFile(
+ file: string,
+ args: readonly string[] | undefined | null,
+ options: ExecFileOptions | undefined | null,
+ callback:
+ | ((
+ error: ExecFileException | null,
+ stdout: string | NonSharedBuffer,
+ stderr: string | NonSharedBuffer,
+ ) => void)
+ | undefined
+ | null,
+ ): ChildProcess;
+ namespace execFile {
+ function __promisify__(file: string): PromiseWithChild<{
+ stdout: string;
+ stderr: string;
+ }>;
+ function __promisify__(
+ file: string,
+ args: readonly string[] | undefined | null,
+ ): PromiseWithChild<{
+ stdout: string;
+ stderr: string;
+ }>;
+ function __promisify__(
+ file: string,
+ options: ExecFileOptionsWithBufferEncoding,
+ ): PromiseWithChild<{
+ stdout: NonSharedBuffer;
+ stderr: NonSharedBuffer;
+ }>;
+ function __promisify__(
+ file: string,
+ args: readonly string[] | undefined | null,
+ options: ExecFileOptionsWithBufferEncoding,
+ ): PromiseWithChild<{
+ stdout: NonSharedBuffer;
+ stderr: NonSharedBuffer;
+ }>;
+ function __promisify__(
+ file: string,
+ options: ExecFileOptionsWithStringEncoding,
+ ): PromiseWithChild<{
+ stdout: string;
+ stderr: string;
+ }>;
+ function __promisify__(
+ file: string,
+ args: readonly string[] | undefined | null,
+ options: ExecFileOptionsWithStringEncoding,
+ ): PromiseWithChild<{
+ stdout: string;
+ stderr: string;
+ }>;
+ function __promisify__(
+ file: string,
+ options: ExecFileOptions | undefined | null,
+ ): PromiseWithChild<{
+ stdout: string | NonSharedBuffer;
+ stderr: string | NonSharedBuffer;
+ }>;
+ function __promisify__(
+ file: string,
+ args: readonly string[] | undefined | null,
+ options: ExecFileOptions | undefined | null,
+ ): PromiseWithChild<{
+ stdout: string | NonSharedBuffer;
+ stderr: string | NonSharedBuffer;
+ }>;
+ }
+ interface ForkOptions extends ProcessEnvOptions, MessagingOptions, Abortable {
+ execPath?: string | undefined;
+ execArgv?: string[] | undefined;
+ silent?: boolean | undefined;
+ /**
+ * Can be set to 'pipe', 'inherit', 'overlapped', or 'ignore', or an array of these strings.
+ * If passed as an array, the first element is used for `stdin`, the second for
+ * `stdout`, and the third for `stderr`. A fourth element can be used to
+ * specify the `stdio` behavior beyond the standard streams. See
+ * {@link ChildProcess.stdio} for more information.
+ *
+ * @default 'pipe'
+ */
+ stdio?: StdioOptions | undefined;
+ detached?: boolean | undefined;
+ windowsVerbatimArguments?: boolean | undefined;
+ }
+ /**
+ * The `child_process.fork()` method is a special case of {@link spawn} used specifically to spawn new Node.js processes.
+ * Like {@link spawn}, a `ChildProcess` object is returned. The
+ * returned `ChildProcess` will have an additional communication channel
+ * built-in that allows messages to be passed back and forth between the parent and
+ * child. See `subprocess.send()` for details.
+ *
+ * Keep in mind that spawned Node.js child processes are
+ * independent of the parent with exception of the IPC communication channel
+ * that is established between the two. Each process has its own memory, with
+ * their own V8 instances. Because of the additional resource allocations
+ * required, spawning a large number of child Node.js processes is not
+ * recommended.
+ *
+ * By default, `child_process.fork()` will spawn new Node.js instances using the `process.execPath` of the parent process. The `execPath` property in the `options` object allows for an alternative
+ * execution path to be used.
+ *
+ * Node.js processes launched with a custom `execPath` will communicate with the
+ * parent process using the file descriptor (fd) identified using the
+ * environment variable `NODE_CHANNEL_FD` on the child process.
+ *
+ * Unlike the [`fork(2)`](http://man7.org/linux/man-pages/man2/fork.2.html) POSIX system call, `child_process.fork()` does not clone the
+ * current process.
+ *
+ * The `shell` option available in {@link spawn} is not supported by `child_process.fork()` and will be ignored if set.
+ *
+ * If the `signal` option is enabled, calling `.abort()` on the corresponding `AbortController` is similar to calling `.kill()` on the child process except
+ * the error passed to the callback will be an `AbortError`:
+ *
+ * ```js
+ * if (process.argv[2] === 'child') {
+ * setTimeout(() => {
+ * console.log(`Hello from ${process.argv[2]}!`);
+ * }, 1_000);
+ * } else {
+ * import { fork } from 'node:child_process';
+ * const controller = new AbortController();
+ * const { signal } = controller;
+ * const child = fork(__filename, ['child'], { signal });
+ * child.on('error', (err) => {
+ * // This will be called with err being an AbortError if the controller aborts
+ * });
+ * controller.abort(); // Stops the child process
+ * }
+ * ```
+ * @since v0.5.0
+ * @param modulePath The module to run in the child.
+ * @param args List of string arguments.
+ */
+ function fork(modulePath: string | URL, options?: ForkOptions): ChildProcess;
+ function fork(modulePath: string | URL, args?: readonly string[], options?: ForkOptions): ChildProcess;
+ interface SpawnSyncOptions extends CommonSpawnOptions {
+ input?: string | NodeJS.ArrayBufferView | undefined;
+ maxBuffer?: number | undefined;
+ encoding?: BufferEncoding | "buffer" | null | undefined;
+ }
+ interface SpawnSyncOptionsWithStringEncoding extends SpawnSyncOptions {
+ encoding: BufferEncoding;
+ }
+ interface SpawnSyncOptionsWithBufferEncoding extends SpawnSyncOptions {
+ encoding?: "buffer" | null | undefined;
+ }
+ interface SpawnSyncReturns {
+ pid: number;
+ output: Array;
+ stdout: T;
+ stderr: T;
+ status: number | null;
+ signal: NodeJS.Signals | null;
+ error?: Error;
+ }
+ /**
+ * The `child_process.spawnSync()` method is generally identical to {@link spawn} with the exception that the function will not return
+ * until the child process has fully closed. When a timeout has been encountered
+ * and `killSignal` is sent, the method won't return until the process has
+ * completely exited. If the process intercepts and handles the `SIGTERM` signal
+ * and doesn't exit, the parent process will wait until the child process has
+ * exited.
+ *
+ * **If the `shell` option is enabled, do not pass unsanitized user input to this**
+ * **function. Any input containing shell metacharacters may be used to trigger**
+ * **arbitrary command execution.**
+ * @since v0.11.12
+ * @param command The command to run.
+ * @param args List of string arguments.
+ */
+ function spawnSync(command: string): SpawnSyncReturns;
+ function spawnSync(command: string, options: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns;
+ function spawnSync(command: string, options: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns