@contrast/agent-bundle 5.45.1 → 5.47.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.
Files changed (189) hide show
  1. package/README.md +1 -1
  2. package/node_modules/@contrast/agent/README.md +1 -1
  3. package/node_modules/@contrast/agent/package.json +12 -12
  4. package/node_modules/@contrast/agentify/package.json +15 -15
  5. package/node_modules/@contrast/architecture-components/package.json +5 -5
  6. package/node_modules/@contrast/assess/lib/{session-configuration → configuration-analysis}/common.js +1 -1
  7. package/node_modules/@contrast/assess/lib/{session-configuration → configuration-analysis}/handlers.js +24 -11
  8. package/node_modules/@contrast/assess/lib/{session-configuration → configuration-analysis}/index.js +6 -4
  9. package/node_modules/@contrast/assess/lib/configuration-analysis/install/apollo-server.js +92 -0
  10. package/node_modules/@contrast/assess/lib/{session-configuration → configuration-analysis}/install/express-session.js +2 -2
  11. package/node_modules/@contrast/assess/lib/{session-configuration → configuration-analysis}/install/fastify-cookie.js +2 -2
  12. package/node_modules/@contrast/assess/lib/configuration-analysis/install/graphql-yoga.js +90 -0
  13. package/node_modules/@contrast/assess/lib/{session-configuration → configuration-analysis}/install/hapi.js +2 -2
  14. package/node_modules/@contrast/assess/lib/{session-configuration → configuration-analysis}/install/koa.js +3 -3
  15. package/node_modules/@contrast/assess/lib/dataflow/propagation/install/string/substring.js +1 -1
  16. package/node_modules/@contrast/assess/lib/dataflow/sources/handler.js +30 -26
  17. package/node_modules/@contrast/assess/lib/dataflow/sources/index.js +2 -0
  18. package/node_modules/@contrast/assess/lib/dataflow/sources/install/fastify-websocket.js +63 -0
  19. package/node_modules/@contrast/assess/lib/dataflow/sources/install/http.js +42 -38
  20. package/node_modules/@contrast/assess/lib/dataflow/sources/install/koa/index.js +1 -1
  21. package/node_modules/@contrast/assess/lib/dataflow/sources/install/koa/koa-bodyparsers.js +76 -48
  22. package/node_modules/@contrast/assess/lib/dataflow/sources/install/koa/koa-multer.js +1 -1
  23. package/node_modules/@contrast/assess/lib/dataflow/sources/install/koa/koa-routers.js +2 -2
  24. package/node_modules/@contrast/assess/lib/dataflow/sources/install/koa/{koa2.js → koa.js} +3 -3
  25. package/node_modules/@contrast/assess/lib/dataflow/sources/install/socket.io.js +80 -0
  26. package/node_modules/@contrast/assess/lib/get-source-context.js +10 -21
  27. package/node_modules/@contrast/assess/lib/index.d.ts +4 -3
  28. package/node_modules/@contrast/assess/lib/index.js +2 -2
  29. package/node_modules/@contrast/assess/lib/make-source-context.js +5 -10
  30. package/node_modules/@contrast/assess/lib/policy.js +400 -0
  31. package/node_modules/@contrast/assess/lib/response-scanning/handlers/index.js +10 -14
  32. package/node_modules/@contrast/assess/package.json +12 -12
  33. package/node_modules/@contrast/common/lib/constants.d.ts +12 -4
  34. package/node_modules/@contrast/common/lib/constants.js +16 -7
  35. package/node_modules/@contrast/common/lib/types.d.ts +5 -1
  36. package/node_modules/@contrast/common/package.json +1 -1
  37. package/node_modules/@contrast/config/lib/common.js +1 -0
  38. package/node_modules/@contrast/config/lib/options.js +14 -0
  39. package/node_modules/@contrast/config/package.json +3 -3
  40. package/node_modules/@contrast/core/package.json +5 -5
  41. package/node_modules/@contrast/deadzones/package.json +5 -5
  42. package/node_modules/@contrast/dep-hooks/lib/package-finder.d.ts +2 -2
  43. package/node_modules/@contrast/dep-hooks/lib/package-finder.js +3 -2
  44. package/node_modules/@contrast/dep-hooks/package.json +4 -4
  45. package/node_modules/@contrast/esm-hooks/README.md +2 -2
  46. package/node_modules/@contrast/esm-hooks/package.json +6 -6
  47. package/node_modules/@contrast/instrumentation/package.json +5 -5
  48. package/node_modules/@contrast/library-analysis/lib/install/library-reporting/dep.json +149 -149
  49. package/node_modules/@contrast/library-analysis/lib/install/library-reporting/index.js +2 -11
  50. package/node_modules/@contrast/library-analysis/lib/install/library-reporting/utils.js +2 -0
  51. package/node_modules/@contrast/library-analysis/lib/install/library-usage/index.js +3 -1
  52. package/node_modules/@contrast/library-analysis/lib/util.js +0 -2
  53. package/node_modules/@contrast/library-analysis/package.json +4 -4
  54. package/node_modules/@contrast/logger/package.json +3 -3
  55. package/node_modules/@contrast/metrics/package.json +6 -6
  56. package/node_modules/@contrast/patcher/package.json +2 -2
  57. package/node_modules/@contrast/protect/lib/error-handlers/index.js +1 -1
  58. package/node_modules/@contrast/protect/lib/error-handlers/install/{koa2.js → koa.js} +4 -4
  59. package/node_modules/@contrast/protect/lib/index.d.ts +1 -1
  60. package/node_modules/@contrast/protect/lib/input-analysis/handlers.js +1 -12
  61. package/node_modules/@contrast/protect/lib/input-analysis/index.js +2 -3
  62. package/node_modules/@contrast/protect/lib/input-analysis/install/koa-bodyparsers.js +92 -0
  63. package/node_modules/@contrast/protect/lib/input-analysis/install/{koa2.js → koa.js} +5 -5
  64. package/node_modules/@contrast/protect/package.json +11 -11
  65. package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/application-activity/translations.js +6 -10
  66. package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/routes-observed.js +4 -0
  67. package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/traces/index.d.ts +1 -1
  68. package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/traces/index.js +1 -1
  69. package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/traces/translations.d.ts +1 -1
  70. package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/traces/translations.js +22 -9
  71. package/node_modules/@contrast/reporter/lib/reporters/file.js +1 -1
  72. package/node_modules/@contrast/reporter/package.json +6 -6
  73. package/node_modules/@contrast/rewriter/package.json +5 -5
  74. package/node_modules/@contrast/route-coverage/lib/index.d.ts +0 -2
  75. package/node_modules/@contrast/route-coverage/lib/index.js +10 -1
  76. package/node_modules/@contrast/route-coverage/lib/install/express/express5.js +16 -1
  77. package/node_modules/@contrast/route-coverage/lib/install/fastify.js +25 -15
  78. package/node_modules/@contrast/route-coverage/lib/install/graphql.js +6 -1
  79. package/node_modules/@contrast/route-coverage/lib/install/koa.js +1 -1
  80. package/node_modules/@contrast/route-coverage/lib/install/socket.io.js +127 -0
  81. package/node_modules/@contrast/route-coverage/package.json +8 -8
  82. package/node_modules/@contrast/scopes/package.json +5 -5
  83. package/node_modules/@contrast/sec-obs/package.json +9 -9
  84. package/node_modules/@contrast/sources/lib/index.js +65 -22
  85. package/node_modules/@contrast/sources/lib/index.test.js +78 -33
  86. package/node_modules/@contrast/sources/lib/source-info.js +1 -10
  87. package/node_modules/@contrast/sources/package.json +3 -3
  88. package/node_modules/@contrast/telemetry/package.json +5 -5
  89. package/node_modules/@types/node/README.md +1 -1
  90. package/node_modules/@types/node/assert/strict.d.ts +105 -2
  91. package/node_modules/@types/node/assert.d.ts +154 -95
  92. package/node_modules/@types/node/buffer.buffer.d.ts +9 -0
  93. package/node_modules/@types/node/buffer.d.ts +8 -4
  94. package/node_modules/@types/node/child_process.d.ts +65 -42
  95. package/node_modules/@types/node/cluster.d.ts +4 -5
  96. package/node_modules/@types/node/crypto.d.ts +1173 -322
  97. package/node_modules/@types/node/dgram.d.ts +9 -8
  98. package/node_modules/@types/node/diagnostics_channel.d.ts +0 -2
  99. package/node_modules/@types/node/dns.d.ts +1 -1
  100. package/node_modules/@types/node/events.d.ts +80 -34
  101. package/node_modules/@types/node/fs/promises.d.ts +39 -21
  102. package/node_modules/@types/node/fs.d.ts +328 -87
  103. package/node_modules/@types/node/globals.d.ts +2 -0
  104. package/node_modules/@types/node/globals.typedarray.d.ts +19 -0
  105. package/node_modules/@types/node/http.d.ts +94 -30
  106. package/node_modules/@types/node/http2.d.ts +178 -52
  107. package/node_modules/@types/node/https.d.ts +91 -62
  108. package/node_modules/@types/node/index.d.ts +2 -0
  109. package/node_modules/@types/node/inspector.d.ts +24 -0
  110. package/node_modules/@types/node/inspector.generated.d.ts +181 -0
  111. package/node_modules/@types/node/net.d.ts +12 -11
  112. package/node_modules/@types/node/os.d.ts +14 -3
  113. package/node_modules/@types/node/package.json +3 -3
  114. package/node_modules/@types/node/perf_hooks.d.ts +6 -8
  115. package/node_modules/@types/node/process.d.ts +12 -23
  116. package/node_modules/@types/node/readline/promises.d.ts +1 -1
  117. package/node_modules/@types/node/sea.d.ts +9 -0
  118. package/node_modules/@types/node/sqlite.d.ts +119 -10
  119. package/node_modules/@types/node/stream/consumers.d.ts +2 -2
  120. package/node_modules/@types/node/stream/web.d.ts +6 -55
  121. package/node_modules/@types/node/stream.d.ts +38 -23
  122. package/node_modules/@types/node/string_decoder.d.ts +2 -2
  123. package/node_modules/@types/node/test.d.ts +31 -26
  124. package/node_modules/@types/node/tls.d.ts +90 -66
  125. package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +10 -2
  126. package/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +16 -0
  127. package/node_modules/@types/node/ts5.6/index.d.ts +2 -0
  128. package/node_modules/@types/node/ts5.7/index.d.ts +2 -0
  129. package/node_modules/@types/node/url.d.ts +8 -3
  130. package/node_modules/@types/node/util.d.ts +17 -3
  131. package/node_modules/@types/node/v8.d.ts +38 -5
  132. package/node_modules/@types/node/vm.d.ts +169 -88
  133. package/node_modules/@types/node/wasi.d.ts +1 -1
  134. package/node_modules/@types/node/web-globals/crypto.d.ts +32 -0
  135. package/node_modules/@types/node/web-globals/events.d.ts +3 -0
  136. package/node_modules/@types/node/web-globals/streams.d.ts +22 -0
  137. package/node_modules/@types/node/worker_threads.d.ts +109 -48
  138. package/node_modules/@types/node/zlib.d.ts +31 -24
  139. package/node_modules/axios/CHANGELOG.md +403 -357
  140. package/node_modules/axios/README.md +80 -49
  141. package/node_modules/axios/dist/axios.js +121 -46
  142. package/node_modules/axios/dist/axios.js.map +1 -1
  143. package/node_modules/axios/dist/axios.min.js +2 -2
  144. package/node_modules/axios/dist/axios.min.js.map +1 -1
  145. package/node_modules/axios/dist/browser/axios.cjs +126 -57
  146. package/node_modules/axios/dist/browser/axios.cjs.map +1 -1
  147. package/node_modules/axios/dist/esm/axios.js +126 -57
  148. package/node_modules/axios/dist/esm/axios.js.map +1 -1
  149. package/node_modules/axios/dist/esm/axios.min.js +2 -2
  150. package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
  151. package/node_modules/axios/dist/node/axios.cjs +346 -97
  152. package/node_modules/axios/dist/node/axios.cjs.map +1 -1
  153. package/node_modules/axios/index.d.cts +4 -0
  154. package/node_modules/axios/index.d.ts +4 -0
  155. package/node_modules/axios/lib/adapters/adapters.js +85 -40
  156. package/node_modules/axios/lib/adapters/fetch.js +1 -1
  157. package/node_modules/axios/lib/adapters/http.js +220 -42
  158. package/node_modules/axios/lib/core/InterceptorManager.js +1 -1
  159. package/node_modules/axios/lib/core/mergeConfig.js +4 -4
  160. package/node_modules/axios/lib/env/data.js +1 -1
  161. package/node_modules/axios/lib/helpers/HttpStatusCode.js +6 -0
  162. package/node_modules/axios/lib/helpers/bind.js +7 -0
  163. package/node_modules/axios/lib/helpers/cookies.js +24 -13
  164. package/node_modules/axios/package.json +9 -4
  165. package/node_modules/detect-libc/lib/filesystem.js +1 -1
  166. package/node_modules/detect-libc/package.json +3 -1
  167. package/node_modules/node-abi/abi_registry.json +12 -2
  168. package/node_modules/node-abi/package.json +3 -6
  169. package/node_modules/semver/classes/range.js +1 -0
  170. package/node_modules/semver/classes/semver.js +19 -5
  171. package/node_modules/semver/internal/identifiers.js +4 -0
  172. package/node_modules/semver/package.json +3 -3
  173. package/node_modules/undici-types/agent.d.ts +1 -4
  174. package/node_modules/undici-types/client.d.ts +0 -2
  175. package/node_modules/undici-types/diagnostics-channel.d.ts +0 -1
  176. package/node_modules/undici-types/dispatcher.d.ts +0 -6
  177. package/node_modules/undici-types/errors.d.ts +5 -15
  178. package/node_modules/undici-types/eventsource.d.ts +6 -1
  179. package/node_modules/undici-types/h2c-client.d.ts +0 -2
  180. package/node_modules/undici-types/index.d.ts +6 -1
  181. package/node_modules/undici-types/interceptors.d.ts +5 -0
  182. package/node_modules/undici-types/mock-interceptor.d.ts +0 -1
  183. package/node_modules/undici-types/package.json +1 -1
  184. package/node_modules/undici-types/snapshot-agent.d.ts +109 -0
  185. package/node_modules/undici-types/webidl.d.ts +82 -21
  186. package/package.json +3 -3
  187. package/node_modules/@contrast/assess/lib/get-policy.js +0 -336
  188. package/node_modules/@contrast/protect/lib/input-analysis/install/koa-body5.js +0 -63
  189. package/node_modules/@contrast/protect/lib/input-analysis/install/koa-bodyparser4.js +0 -64
@@ -26,6 +26,7 @@
26
26
  * @see [source](https://github.com/nodejs/node/blob/v24.x/lib/dgram.js)
27
27
  */
28
28
  declare module "dgram" {
29
+ import { NonSharedBuffer } from "node:buffer";
29
30
  import { AddressInfo, BlockList } from "node:net";
30
31
  import * as dns from "node:dns";
31
32
  import { Abortable, EventEmitter } from "node:events";
@@ -85,8 +86,8 @@ declare module "dgram" {
85
86
  * @param options Available options are:
86
87
  * @param callback Attached as a listener for `'message'` events. Optional.
87
88
  */
88
- function createSocket(type: SocketType, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
89
- function createSocket(options: SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
89
+ function createSocket(type: SocketType, callback?: (msg: NonSharedBuffer, rinfo: RemoteInfo) => void): Socket;
90
+ function createSocket(options: SocketOptions, callback?: (msg: NonSharedBuffer, rinfo: RemoteInfo) => void): Socket;
90
91
  /**
91
92
  * Encapsulates the datagram functionality.
92
93
  *
@@ -556,37 +557,37 @@ declare module "dgram" {
556
557
  addListener(event: "connect", listener: () => void): this;
557
558
  addListener(event: "error", listener: (err: Error) => void): this;
558
559
  addListener(event: "listening", listener: () => void): this;
559
- addListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
560
+ addListener(event: "message", listener: (msg: NonSharedBuffer, rinfo: RemoteInfo) => void): this;
560
561
  emit(event: string | symbol, ...args: any[]): boolean;
561
562
  emit(event: "close"): boolean;
562
563
  emit(event: "connect"): boolean;
563
564
  emit(event: "error", err: Error): boolean;
564
565
  emit(event: "listening"): boolean;
565
- emit(event: "message", msg: Buffer, rinfo: RemoteInfo): boolean;
566
+ emit(event: "message", msg: NonSharedBuffer, rinfo: RemoteInfo): boolean;
566
567
  on(event: string, listener: (...args: any[]) => void): this;
567
568
  on(event: "close", listener: () => void): this;
568
569
  on(event: "connect", listener: () => void): this;
569
570
  on(event: "error", listener: (err: Error) => void): this;
570
571
  on(event: "listening", listener: () => void): this;
571
- on(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
572
+ on(event: "message", listener: (msg: NonSharedBuffer, rinfo: RemoteInfo) => void): this;
572
573
  once(event: string, listener: (...args: any[]) => void): this;
573
574
  once(event: "close", listener: () => void): this;
574
575
  once(event: "connect", listener: () => void): this;
575
576
  once(event: "error", listener: (err: Error) => void): this;
576
577
  once(event: "listening", listener: () => void): this;
577
- once(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
578
+ once(event: "message", listener: (msg: NonSharedBuffer, rinfo: RemoteInfo) => void): this;
578
579
  prependListener(event: string, listener: (...args: any[]) => void): this;
579
580
  prependListener(event: "close", listener: () => void): this;
580
581
  prependListener(event: "connect", listener: () => void): this;
581
582
  prependListener(event: "error", listener: (err: Error) => void): this;
582
583
  prependListener(event: "listening", listener: () => void): this;
583
- prependListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
584
+ prependListener(event: "message", listener: (msg: NonSharedBuffer, rinfo: RemoteInfo) => void): this;
584
585
  prependOnceListener(event: string, listener: (...args: any[]) => void): this;
585
586
  prependOnceListener(event: "close", listener: () => void): this;
586
587
  prependOnceListener(event: "connect", listener: () => void): this;
587
588
  prependOnceListener(event: "error", listener: (err: Error) => void): this;
588
589
  prependOnceListener(event: "listening", listener: () => void): this;
589
- prependOnceListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
590
+ prependOnceListener(event: "message", listener: (msg: NonSharedBuffer, rinfo: RemoteInfo) => void): this;
590
591
  /**
591
592
  * Calls `socket.close()` and returns a promise that fulfills when the socket has closed.
592
593
  * @since v20.5.0
@@ -189,7 +189,6 @@ declare module "diagnostics_channel" {
189
189
  * });
190
190
  * ```
191
191
  * @since v15.1.0, v14.17.0
192
- * @deprecated Since v18.7.0,v16.17.0 - Use {@link subscribe(name, onMessage)}
193
192
  * @param onMessage The handler to receive channel messages
194
193
  */
195
194
  subscribe(onMessage: ChannelListener): void;
@@ -210,7 +209,6 @@ declare module "diagnostics_channel" {
210
209
  * channel.unsubscribe(onMessage);
211
210
  * ```
212
211
  * @since v15.1.0, v14.17.0
213
- * @deprecated Since v18.7.0,v16.17.0 - Use {@link unsubscribe(name, onMessage)}
214
212
  * @param onMessage The previous subscribed handler to remove
215
213
  * @return `true` if the handler was found, `false` otherwise.
216
214
  */
@@ -829,7 +829,7 @@ declare module "dns" {
829
829
  * The number of tries the resolver will try contacting each name server before giving up.
830
830
  * @default 4
831
831
  */
832
- tries?: number;
832
+ tries?: number | undefined;
833
833
  /**
834
834
  * The max retry timeout, in milliseconds.
835
835
  * @default 0
@@ -36,39 +36,6 @@
36
36
  */
37
37
  declare module "events" {
38
38
  import { AsyncResource, AsyncResourceOptions } from "node:async_hooks";
39
- // NOTE: This class is in the docs but is **not actually exported** by Node.
40
- // If https://github.com/nodejs/node/issues/39903 gets resolved and Node
41
- // actually starts exporting the class, uncomment below.
42
- // import { EventListener, EventListenerObject } from '__dom-events';
43
- // /** The NodeEventTarget is a Node.js-specific extension to EventTarget that emulates a subset of the EventEmitter API. */
44
- // interface NodeEventTarget extends EventTarget {
45
- // /**
46
- // * Node.js-specific extension to the `EventTarget` class that emulates the equivalent `EventEmitter` API.
47
- // * The only difference between `addListener()` and `addEventListener()` is that addListener() will return a reference to the EventTarget.
48
- // */
49
- // addListener(type: string, listener: EventListener | EventListenerObject, options?: { once: boolean }): this;
50
- // /** Node.js-specific extension to the `EventTarget` class that returns an array of event `type` names for which event listeners are registered. */
51
- // eventNames(): string[];
52
- // /** Node.js-specific extension to the `EventTarget` class that returns the number of event listeners registered for the `type`. */
53
- // listenerCount(type: string): number;
54
- // /** Node.js-specific alias for `eventTarget.removeListener()`. */
55
- // off(type: string, listener: EventListener | EventListenerObject): this;
56
- // /** Node.js-specific alias for `eventTarget.addListener()`. */
57
- // on(type: string, listener: EventListener | EventListenerObject, options?: { once: boolean }): this;
58
- // /** Node.js-specific extension to the `EventTarget` class that adds a `once` listener for the given event `type`. This is equivalent to calling `on` with the `once` option set to `true`. */
59
- // once(type: string, listener: EventListener | EventListenerObject): this;
60
- // /**
61
- // * Node.js-specific extension to the `EventTarget` class.
62
- // * If `type` is specified, removes all registered listeners for `type`,
63
- // * otherwise removes all registered listeners.
64
- // */
65
- // removeAllListeners(type: string): this;
66
- // /**
67
- // * Node.js-specific extension to the `EventTarget` class that removes the listener for the given `type`.
68
- // * The only difference between `removeListener()` and `removeEventListener()` is that `removeListener()` will return a reference to the `EventTarget`.
69
- // */
70
- // removeListener(type: string, listener: EventListener | EventListenerObject): this;
71
- // }
72
39
  interface EventEmitterOptions {
73
40
  /**
74
41
  * Enables automatic capturing of promise rejection.
@@ -517,7 +484,7 @@ declare module "events" {
517
484
  * directly rather than as a child class.
518
485
  * @default new.target.name if instantiated as a child class.
519
486
  */
520
- name?: string;
487
+ name?: string | undefined;
521
488
  }
522
489
 
523
490
  /**
@@ -584,6 +551,85 @@ declare module "events" {
584
551
  */
585
552
  readonly asyncResource: EventEmitterReferencingAsyncResource;
586
553
  }
554
+ /**
555
+ * The `NodeEventTarget` is a Node.js-specific extension to `EventTarget`
556
+ * that emulates a subset of the `EventEmitter` API.
557
+ * @since v14.5.0
558
+ */
559
+ export interface NodeEventTarget extends EventTarget {
560
+ /**
561
+ * Node.js-specific extension to the `EventTarget` class that emulates the
562
+ * equivalent `EventEmitter` API. The only difference between `addListener()` and
563
+ * `addEventListener()` is that `addListener()` will return a reference to the
564
+ * `EventTarget`.
565
+ * @since v14.5.0
566
+ */
567
+ addListener(type: string, listener: (arg: any) => void): this;
568
+ /**
569
+ * Node.js-specific extension to the `EventTarget` class that dispatches the
570
+ * `arg` to the list of handlers for `type`.
571
+ * @since v15.2.0
572
+ * @returns `true` if event listeners registered for the `type` exist,
573
+ * otherwise `false`.
574
+ */
575
+ emit(type: string, arg: any): boolean;
576
+ /**
577
+ * Node.js-specific extension to the `EventTarget` class that returns an array
578
+ * of event `type` names for which event listeners are registered.
579
+ * @since 14.5.0
580
+ */
581
+ eventNames(): string[];
582
+ /**
583
+ * Node.js-specific extension to the `EventTarget` class that returns the number
584
+ * of event listeners registered for the `type`.
585
+ * @since v14.5.0
586
+ */
587
+ listenerCount(type: string): number;
588
+ /**
589
+ * Node.js-specific extension to the `EventTarget` class that sets the number
590
+ * of max event listeners as `n`.
591
+ * @since v14.5.0
592
+ */
593
+ setMaxListeners(n: number): void;
594
+ /**
595
+ * Node.js-specific extension to the `EventTarget` class that returns the number
596
+ * of max event listeners.
597
+ * @since v14.5.0
598
+ */
599
+ getMaxListeners(): number;
600
+ /**
601
+ * Node.js-specific alias for `eventTarget.removeEventListener()`.
602
+ * @since v14.5.0
603
+ */
604
+ off(type: string, listener: (arg: any) => void, options?: EventListenerOptions): this;
605
+ /**
606
+ * Node.js-specific alias for `eventTarget.addEventListener()`.
607
+ * @since v14.5.0
608
+ */
609
+ on(type: string, listener: (arg: any) => void): this;
610
+ /**
611
+ * Node.js-specific extension to the `EventTarget` class that adds a `once`
612
+ * listener for the given event `type`. This is equivalent to calling `on`
613
+ * with the `once` option set to `true`.
614
+ * @since v14.5.0
615
+ */
616
+ once(type: string, listener: (arg: any) => void): this;
617
+ /**
618
+ * Node.js-specific extension to the `EventTarget` class. If `type` is specified,
619
+ * removes all registered listeners for `type`, otherwise removes all registered
620
+ * listeners.
621
+ * @since v14.5.0
622
+ */
623
+ removeAllListeners(type?: string): this;
624
+ /**
625
+ * Node.js-specific extension to the `EventTarget` class that removes the
626
+ * `listener` for the given `type`. The only difference between `removeListener()`
627
+ * and `removeEventListener()` is that `removeListener()` will return a reference
628
+ * to the `EventTarget`.
629
+ * @since v14.5.0
630
+ */
631
+ removeListener(type: string, listener: (arg: any) => void, options?: EventListenerOptions): this;
632
+ }
587
633
  }
588
634
  global {
589
635
  namespace NodeJS {
@@ -9,6 +9,7 @@
9
9
  * @since v10.0.0
10
10
  */
11
11
  declare module "fs/promises" {
12
+ import { NonSharedBuffer } from "node:buffer";
12
13
  import { Abortable } from "node:events";
13
14
  import { Stream } from "node:stream";
14
15
  import { ReadableStream } from "node:stream/web";
@@ -31,6 +32,8 @@ declare module "fs/promises" {
31
32
  OpenDirOptions,
32
33
  OpenMode,
33
34
  PathLike,
35
+ ReadOptions,
36
+ ReadOptionsWithBuffer,
34
37
  ReadPosition,
35
38
  ReadStream,
36
39
  ReadVResult,
@@ -59,6 +62,7 @@ declare module "fs/promises" {
59
62
  bytesRead: number;
60
63
  buffer: T;
61
64
  }
65
+ /** @deprecated This interface will be removed in a future version. Use `import { ReadOptionsWithBuffer } from "node:fs"` instead. */
62
66
  interface FileReadOptions<T extends NodeJS.ArrayBufferView = Buffer> {
63
67
  /**
64
68
  * @default `Buffer.alloc(0xffff)`
@@ -237,11 +241,13 @@ declare module "fs/promises" {
237
241
  length?: number | null,
238
242
  position?: ReadPosition | null,
239
243
  ): Promise<FileReadResult<T>>;
240
- read<T extends NodeJS.ArrayBufferView = Buffer>(
244
+ read<T extends NodeJS.ArrayBufferView>(
241
245
  buffer: T,
242
- options?: FileReadOptions<T>,
246
+ options?: ReadOptions,
247
+ ): Promise<FileReadResult<T>>;
248
+ read<T extends NodeJS.ArrayBufferView = NonSharedBuffer>(
249
+ options?: ReadOptionsWithBuffer<T>,
243
250
  ): Promise<FileReadResult<T>>;
244
- read<T extends NodeJS.ArrayBufferView = Buffer>(options?: FileReadOptions<T>): Promise<FileReadResult<T>>;
245
251
  /**
246
252
  * Returns a byte-oriented `ReadableStream` that may be used to read the file's
247
253
  * contents.
@@ -285,7 +291,7 @@ declare module "fs/promises" {
285
291
  options?:
286
292
  | ({ encoding?: null | undefined } & Abortable)
287
293
  | null,
288
- ): Promise<Buffer>;
294
+ ): Promise<NonSharedBuffer>;
289
295
  /**
290
296
  * Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
291
297
  * The `FileHandle` must have been opened for reading.
@@ -304,7 +310,7 @@ declare module "fs/promises" {
304
310
  | (ObjectEncodingOptions & Abortable)
305
311
  | BufferEncoding
306
312
  | null,
307
- ): Promise<string | Buffer>;
313
+ ): Promise<string | NonSharedBuffer>;
308
314
  /**
309
315
  * Convenience method to create a `readline` interface and stream over the file.
310
316
  * See `filehandle.createReadStream()` for the options.
@@ -413,7 +419,7 @@ declare module "fs/promises" {
413
419
  * @param [position='null'] The offset from the beginning of the file where the data from `buffer` should be written. If `position` is not a `number`, the data will be written at the current
414
420
  * position. See the POSIX pwrite(2) documentation for more detail.
415
421
  */
416
- write<TBuffer extends Uint8Array>(
422
+ write<TBuffer extends NodeJS.ArrayBufferView>(
417
423
  buffer: TBuffer,
418
424
  offset?: number | null,
419
425
  length?: number | null,
@@ -452,14 +458,20 @@ declare module "fs/promises" {
452
458
  * @param [position='null'] The offset from the beginning of the file where the data from `buffers` should be written. If `position` is not a `number`, the data will be written at the current
453
459
  * position.
454
460
  */
455
- writev(buffers: readonly NodeJS.ArrayBufferView[], position?: number): Promise<WriteVResult>;
461
+ writev<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
462
+ buffers: TBuffers,
463
+ position?: number,
464
+ ): Promise<WriteVResult<TBuffers>>;
456
465
  /**
457
466
  * Read from a file and write to an array of [ArrayBufferView](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView) s
458
467
  * @since v13.13.0, v12.17.0
459
468
  * @param [position='null'] The offset from the beginning of the file where the data should be read from. If `position` is not a `number`, the data will be read from the current position.
460
469
  * @return Fulfills upon success an object containing two properties:
461
470
  */
462
- readv(buffers: readonly NodeJS.ArrayBufferView[], position?: number): Promise<ReadVResult>;
471
+ readv<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
472
+ buffers: TBuffers,
473
+ position?: number,
474
+ ): Promise<ReadVResult<TBuffers>>;
463
475
  /**
464
476
  * Closes the file handle after waiting for any pending operation on the handle to
465
477
  * complete.
@@ -696,7 +708,7 @@ declare module "fs/promises" {
696
708
  recursive?: boolean | undefined;
697
709
  }
698
710
  | "buffer",
699
- ): Promise<Buffer[]>;
711
+ ): Promise<NonSharedBuffer[]>;
700
712
  /**
701
713
  * Asynchronous readdir(3) - read a directory.
702
714
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -711,7 +723,7 @@ declare module "fs/promises" {
711
723
  })
712
724
  | BufferEncoding
713
725
  | null,
714
- ): Promise<string[] | Buffer[]>;
726
+ ): Promise<string[] | NonSharedBuffer[]>;
715
727
  /**
716
728
  * Asynchronous readdir(3) - read a directory.
717
729
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -736,7 +748,7 @@ declare module "fs/promises" {
736
748
  withFileTypes: true;
737
749
  recursive?: boolean | undefined;
738
750
  },
739
- ): Promise<Dirent<Buffer>[]>;
751
+ ): Promise<Dirent<NonSharedBuffer>[]>;
740
752
  /**
741
753
  * Reads the contents of the symbolic link referred to by `path`. See the POSIX [`readlink(2)`](http://man7.org/linux/man-pages/man2/readlink.2.html) documentation for more detail. The promise is
742
754
  * fulfilled with the`linkString` upon success.
@@ -754,13 +766,16 @@ declare module "fs/promises" {
754
766
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
755
767
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
756
768
  */
757
- function readlink(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;
769
+ function readlink(path: PathLike, options: BufferEncodingOption): Promise<NonSharedBuffer>;
758
770
  /**
759
771
  * Asynchronous readlink(2) - read value of a symbolic link.
760
772
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
761
773
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
762
774
  */
763
- function readlink(path: PathLike, options?: ObjectEncodingOptions | string | null): Promise<string | Buffer>;
775
+ function readlink(
776
+ path: PathLike,
777
+ options?: ObjectEncodingOptions | string | null,
778
+ ): Promise<string | NonSharedBuffer>;
764
779
  /**
765
780
  * Creates a symbolic link.
766
781
  *
@@ -911,7 +926,7 @@ declare module "fs/promises" {
911
926
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
912
927
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
913
928
  */
914
- function realpath(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;
929
+ function realpath(path: PathLike, options: BufferEncodingOption): Promise<NonSharedBuffer>;
915
930
  /**
916
931
  * Asynchronous realpath(3) - return the canonicalized absolute pathname.
917
932
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -920,7 +935,7 @@ declare module "fs/promises" {
920
935
  function realpath(
921
936
  path: PathLike,
922
937
  options?: ObjectEncodingOptions | BufferEncoding | null,
923
- ): Promise<string | Buffer>;
938
+ ): Promise<string | NonSharedBuffer>;
924
939
  /**
925
940
  * Creates a unique temporary directory. A unique directory name is generated by
926
941
  * appending six random characters to the end of the provided `prefix`. Due to
@@ -956,13 +971,16 @@ declare module "fs/promises" {
956
971
  * Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
957
972
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
958
973
  */
959
- function mkdtemp(prefix: string, options: BufferEncodingOption): Promise<Buffer>;
974
+ function mkdtemp(prefix: string, options: BufferEncodingOption): Promise<NonSharedBuffer>;
960
975
  /**
961
976
  * Asynchronously creates a unique temporary directory.
962
977
  * Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
963
978
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
964
979
  */
965
- function mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string | Buffer>;
980
+ function mkdtemp(
981
+ prefix: string,
982
+ options?: ObjectEncodingOptions | BufferEncoding | null,
983
+ ): Promise<string | NonSharedBuffer>;
966
984
  /**
967
985
  * The resulting Promise holds an async-disposable object whose `path` property
968
986
  * holds the created directory path. When the object is disposed, the directory
@@ -1138,7 +1156,7 @@ declare module "fs/promises" {
1138
1156
  flag?: OpenMode | undefined;
1139
1157
  } & Abortable)
1140
1158
  | null,
1141
- ): Promise<Buffer>;
1159
+ ): Promise<NonSharedBuffer>;
1142
1160
  /**
1143
1161
  * Asynchronously reads the entire contents of a file.
1144
1162
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -1174,7 +1192,7 @@ declare module "fs/promises" {
1174
1192
  )
1175
1193
  | BufferEncoding
1176
1194
  | null,
1177
- ): Promise<string | Buffer>;
1195
+ ): Promise<string | NonSharedBuffer>;
1178
1196
  /**
1179
1197
  * Asynchronously open a directory for iterative scanning. See the POSIX [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html) documentation for more detail.
1180
1198
  *
@@ -1251,11 +1269,11 @@ declare module "fs/promises" {
1251
1269
  function watch(
1252
1270
  filename: PathLike,
1253
1271
  options: WatchOptionsWithBufferEncoding | "buffer",
1254
- ): NodeJS.AsyncIterator<FileChangeInfo<Buffer>>;
1272
+ ): NodeJS.AsyncIterator<FileChangeInfo<NonSharedBuffer>>;
1255
1273
  function watch(
1256
1274
  filename: PathLike,
1257
1275
  options: WatchOptions | BufferEncoding | "buffer",
1258
- ): NodeJS.AsyncIterator<FileChangeInfo<string | Buffer>>;
1276
+ ): NodeJS.AsyncIterator<FileChangeInfo<string | NonSharedBuffer>>;
1259
1277
  /**
1260
1278
  * Asynchronously copies the entire directory structure from `src` to `dest`,
1261
1279
  * including subdirectories and files.