@types/node 25.3.5 → 25.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
node/tls.d.ts CHANGED
@@ -210,6 +210,7 @@ declare module "node:tls" {
210
210
  interface TLSSocketEventMap extends net.SocketEventMap {
211
211
  "keylog": [line: NonSharedBuffer];
212
212
  "OCSPResponse": [response: NonSharedBuffer];
213
+ "secure": [];
213
214
  "secureConnect": [];
214
215
  "session": [session: NonSharedBuffer];
215
216
  }
@@ -551,8 +552,12 @@ declare module "node:tls" {
551
552
  */
552
553
  requestCert?: boolean | undefined;
553
554
  /**
554
- * An array of strings or a Buffer naming possible ALPN protocols.
555
- * (Protocols should be ordered by their priority.)
555
+ * An array of strings, or a single `Buffer`, `TypedArray`, or `DataView` containing the supported
556
+ * ALPN protocols. Buffers should have the format `[len][name][len][name]...`
557
+ * e.g. `'\x08http/1.1\x08http/1.0'`, where the `len` byte is the length of the
558
+ * next protocol name. Passing an array is usually much simpler, e.g.
559
+ * `['http/1.1', 'http/1.0']`. Protocols earlier in the list have higher
560
+ * preference than those later.
556
561
  */
557
562
  ALPNProtocols?: readonly string[] | NodeJS.ArrayBufferView | undefined;
558
563
  /**
node/url.d.ts CHANGED
@@ -334,6 +334,19 @@ declare module "node:url" {
334
334
  * new URL('file:///hello world').pathname; // Incorrect: /hello%20world
335
335
  * fileURLToPath('file:///hello world'); // Correct: /hello world (POSIX)
336
336
  * ```
337
+ *
338
+ * **Security Considerations:**
339
+ *
340
+ * This function decodes percent-encoded characters, including encoded dot-segments
341
+ * (`%2e` as `.` and `%2e%2e` as `..`), and then normalizes the resulting path.
342
+ * This means that encoded directory traversal sequences (such as `%2e%2e`) are
343
+ * decoded and processed as actual path traversal, even though encoded slashes
344
+ * (`%2F`, `%5C`) are correctly rejected.
345
+ *
346
+ * **Applications must not rely on `fileURLToPath()` alone to prevent directory
347
+ * traversal attacks.** Always perform explicit path validation and security checks
348
+ * on the returned path value to ensure it remains within expected boundaries
349
+ * before using it for file system operations.
337
350
  * @since v10.12.0
338
351
  * @param url The file URL string or URL object to convert to a path.
339
352
  * @return The fully-resolved platform-specific Node.js file path.
@@ -344,6 +357,15 @@ declare module "node:url" {
344
357
  * representation of the path, a `Buffer` is returned. This conversion is
345
358
  * helpful when the input URL contains percent-encoded segments that are
346
359
  * not valid UTF-8 / Unicode sequences.
360
+ *
361
+ * **Security Considerations:**
362
+ *
363
+ * This function has the same security considerations as `url.fileURLToPath()`.
364
+ * It decodes percent-encoded characters, including encoded dot-segments
365
+ * (`%2e` as `.` and `%2e%2e` as `..`), and normalizes the path. **Applications
366
+ * must not rely on this function alone to prevent directory traversal attacks.**
367
+ * Always perform explicit path validation on the returned buffer value before
368
+ * using it for file system operations.
347
369
  * @since v24.3.0
348
370
  * @param url The file URL string or URL object to convert to a path.
349
371
  * @returns The fully-resolved platform-specific Node.js file path
node/util.d.ts CHANGED
@@ -308,6 +308,9 @@ declare module "node:util" {
308
308
  * Returns an array of call site objects containing the stack of
309
309
  * the caller function.
310
310
  *
311
+ * Unlike accessing an `error.stack`, the result returned from this API is not
312
+ * interfered with `Error.prepareStackTrace`.
313
+ *
311
314
  * ```js
312
315
  * import { getCallSites } from 'node:util';
313
316
  *
@@ -320,7 +323,7 @@ declare module "node:util" {
320
323
  * console.log(`Function Name: ${callSite.functionName}`);
321
324
  * console.log(`Script Name: ${callSite.scriptName}`);
322
325
  * console.log(`Line Number: ${callSite.lineNumber}`);
323
- * console.log(`Column Number: ${callSite.column}`);
326
+ * console.log(`Column Number: ${callSite.columnNumber}`);
324
327
  * });
325
328
  * // CallSite 1:
326
329
  * // Function Name: exampleFunction
@@ -750,6 +753,28 @@ declare module "node:util" {
750
753
  * @legacy Use ES2015 class syntax and `extends` keyword instead.
751
754
  */
752
755
  export function inherits(constructor: unknown, superConstructor: unknown): void;
756
+ /**
757
+ * The `util.convertProcessSignalToExitCode()` method converts a signal name to its
758
+ * corresponding POSIX exit code. Following the POSIX standard, the exit code
759
+ * for a process terminated by a signal is calculated as `128 + signal number`.
760
+ *
761
+ * If `signal` is not a valid signal name, then an error will be thrown. See
762
+ * [`signal(7)`](https://man7.org/linux/man-pages/man7/signal.7.html) for a list of valid signals.
763
+ *
764
+ * ```js
765
+ * import { convertProcessSignalToExitCode } from 'node:util';
766
+ *
767
+ * console.log(convertProcessSignalToExitCode('SIGTERM')); // 143 (128 + 15)
768
+ * console.log(convertProcessSignalToExitCode('SIGKILL')); // 137 (128 + 9)
769
+ * ```
770
+ *
771
+ * This is particularly useful when working with processes to determine
772
+ * the exit code based on the signal that terminated the process.
773
+ * @since v25.4.0
774
+ * @param signal A signal name (e.g. `'SIGTERM'`)
775
+ * @returns The exit code corresponding to `signal`
776
+ */
777
+ export function convertProcessSignalToExitCode(signal: NodeJS.Signals): number;
753
778
  export type DebugLoggerFunction = (msg: string, ...param: unknown[]) => void;
754
779
  export interface DebugLogger extends DebugLoggerFunction {
755
780
  /**
@@ -804,7 +829,7 @@ declare module "node:util" {
804
829
  *
805
830
  * ```js
806
831
  * import { debuglog } from 'node:util';
807
- * const log = debuglog('foo');
832
+ * const log = debuglog('foo-bar');
808
833
  *
809
834
  * log('hi there, it\'s foo-bar [%d]', 2333);
810
835
  * ```
node/v8.d.ts CHANGED
@@ -95,7 +95,7 @@ declare module "node:v8" {
95
95
  * buffers and external strings.
96
96
  *
97
97
  * `total_allocated_bytes` The value of total allocated bytes since the Isolate
98
- * creation
98
+ * creation.
99
99
  *
100
100
  * ```js
101
101
  * {
@@ -112,7 +112,8 @@ declare module "node:v8" {
112
112
  * number_of_detached_contexts: 0,
113
113
  * total_global_handles_size: 8192,
114
114
  * used_global_handles_size: 3296,
115
- * external_memory: 318824
115
+ * external_memory: 318824,
116
+ * total_allocated_bytes: 45224088
116
117
  * }
117
118
  * ```
118
119
  * @since v1.0.0
@@ -308,7 +309,6 @@ declare module "node:v8" {
308
309
  * ```
309
310
  * @param ctor The constructor that can be used to search on the prototype chain in order to filter target objects in the heap.
310
311
  * @since v20.13.0
311
- * @experimental
312
312
  */
313
313
  function queryObjects(ctor: Function): number | string[];
314
314
  function queryObjects(ctor: Function, options: { format: "count" }): number;
@@ -737,6 +737,11 @@ declare module "node:v8" {
737
737
  * @since v19.6.0, v18.15.0
738
738
  */
739
739
  stop(): GCProfilerResult;
740
+ /**
741
+ * Stop collecting GC data, and discard the profile.
742
+ * @since v25.5.0
743
+ */
744
+ [Symbol.dispose](): void;
740
745
  }
741
746
  interface GCProfilerResult {
742
747
  version: number;
node/worker_threads.d.ts CHANGED
@@ -33,8 +33,8 @@
33
33
  * workerData: script,
34
34
  * });
35
35
  * worker.on('message', resolve);
36
- * worker.on('error', reject);
37
- * worker.on('exit', (code) => {
36
+ * worker.once('error', reject);
37
+ * worker.once('exit', (code) => {
38
38
  * if (code !== 0)
39
39
  * reject(new Error(`Worker stopped with exit code ${code}`));
40
40
  * });