@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
@@ -8,6 +8,38 @@ const mocks = require('@contrast/test/mocks');
8
8
  const proxyquire = require('proxyquire');
9
9
 
10
10
  describe('agentify sources', function () {
11
+ let core, api, ServerMock, reqMock, resMock, onFinishedMock;
12
+
13
+ beforeEach(function () {
14
+ ({ core } = initProtectFixture());
15
+ ServerMock = function ServerMock() {
16
+ this.e = new EventEmitter();
17
+ };
18
+ ServerMock.prototype.emit = function (...args) {
19
+ this.e.emit(...args);
20
+ };
21
+ ServerMock.prototype.on = function (...args) {
22
+ this.e.on(...args);
23
+ };
24
+ api = {
25
+ Server: ServerMock,
26
+ createServer() {
27
+ return new ServerMock();
28
+ },
29
+ createSecureServer() {
30
+ return new ServerMock();
31
+ }
32
+ };
33
+ reqMock = mocks.incomingMessage();
34
+ // resMock = new EventEmitter();
35
+ onFinishedMock = sinon.stub();
36
+
37
+ core.depHooks.resolve.withArgs(sinon.match({ name: 'http' })).yields(api);
38
+ proxyquire('.', {
39
+ 'on-finished': onFinishedMock,
40
+ })(core).install();
41
+ });
42
+
11
43
  [
12
44
  {
13
45
  name: 'http',
@@ -24,41 +56,9 @@ describe('agentify sources', function () {
24
56
  protocol: 'https',
25
57
  serverType: 'https',
26
58
  },
27
- }
59
+ },
28
60
  ].forEach(({ name, method, expected }) => {
29
61
  describe(`${name} sources using ${method || 'Server'}()`, function () {
30
- let core, api, ServerMock, reqMock, resMock, onFinishedMock;
31
-
32
- beforeEach(function () {
33
- ({ core } = initProtectFixture());
34
- ServerMock = function ServerMock() {
35
- this.e = new EventEmitter();
36
- };
37
- ServerMock.prototype.emit = function (...args) {
38
- this.e.emit(...args);
39
- };
40
- ServerMock.prototype.on = function (...args) {
41
- this.e.on(...args);
42
- };
43
- api = {
44
- Server: ServerMock,
45
- createServer() {
46
- return new ServerMock();
47
- },
48
- createSecureServer() {
49
- return new ServerMock();
50
- }
51
- };
52
- reqMock = mocks.incomingMessage();
53
- // resMock = new EventEmitter();
54
- onFinishedMock = sinon.stub();
55
-
56
- core.depHooks.resolve.withArgs(sinon.match({ name: 'http' })).yields(api);
57
- proxyquire('.', {
58
- 'on-finished': onFinishedMock,
59
- })(core).install();
60
- });
61
-
62
62
  it('"request" events run in scope with correct sourceInfo', function () {
63
63
  const server = method ? api[method]() : new ServerMock();
64
64
  let store;
@@ -88,7 +88,52 @@ describe('agentify sources', function () {
88
88
 
89
89
  server.emit('foo', reqMock, resMock);
90
90
  expect(store).to.be.undefined;
91
+ expect(onFinishedMock).not.to.have.been.called;
91
92
  });
92
93
  });
93
94
  });
95
+
96
+ it('"upgrade" events run in scope with correct sourceInfo', function () {
97
+ const server = new ServerMock();
98
+ const socketMock = new EventEmitter();
99
+ let store;
100
+ let socketEventStore;
101
+
102
+ reqMock.rawHeaders.push('upgrade', 'websocket');
103
+
104
+ server.on('upgrade', function () {
105
+ store = core.scopes.sources.getStore();
106
+ });
107
+
108
+ server.emit('upgrade', reqMock, socketMock);
109
+
110
+ expect(store.sourceInfo).to.deep.include({
111
+ port: 8080,
112
+ protocol: 'http',
113
+ serverType: 'http',
114
+ });
115
+
116
+ socketMock.on('some-message', function() {
117
+ socketEventStore = core.scopes.sources.getStore();
118
+ });
119
+ socketMock.emit('some-message');
120
+
121
+ expect(store).to.equal(socketEventStore);
122
+ });
123
+
124
+ it('"upgrade" events do not run in scope if not "websocket"', function () {
125
+ const server = new ServerMock();
126
+ const socketMock = new EventEmitter();
127
+ let store;
128
+
129
+ reqMock.rawHeaders.push('upgrade', 'h2c');
130
+
131
+ server.on('upgrade', function () {
132
+ store = core.scopes.sources.getStore();
133
+ });
134
+
135
+ server.emit('upgrade', reqMock, socketMock);
136
+
137
+ expect(store).to.be.undefined;
138
+ });
94
139
  });
@@ -53,7 +53,7 @@ class HttpSourceInfo {
53
53
  this.httpVersion = raw.httpVersion;
54
54
  this.ip = raw.socket.remoteAddress ? StringPrototypeReplace.call(raw.socket.remoteAddress, /::ffff:/, '') : undefined;
55
55
  this.port = raw.socket.address?.()?.port || 0;
56
- this.protocol = serverType == 'http' ? 'http' : 'https'; // todo
56
+ this.protocol = serverType == 'http' ? 'http' : 'https';
57
57
  this.serverType = serverType;
58
58
  this.time = Date.now();
59
59
  this.method = StringPrototypeToLowerCase.call(raw.method);
@@ -62,20 +62,11 @@ class HttpSourceInfo {
62
62
  for (let i = 0; i < raw.rawHeaders.length; i += 2) {
63
63
  const iNext = i + 1;
64
64
  const headerName = StringPrototypeToLowerCase.call(raw.rawHeaders[i]);
65
-
66
65
  headerName == 'content-type' && (this.contentType = raw.rawHeaders[iNext]);
67
-
68
66
  this.rawHeaders[i] = headerName;
69
67
  this.rawHeaders[iNext] = headerName == 'content-type' ?
70
68
  StringPrototypeToLowerCase.call(raw.rawHeaders[iNext]) :
71
69
  raw.rawHeaders[iNext];
72
-
73
- if (
74
- headerName == 'upgrade' &&
75
- StringPrototypeToLowerCase.call(this.rawHeaders[iNext]) == 'websocket'
76
- ) {
77
- this.protocol = 'ws';
78
- }
79
70
  }
80
71
 
81
72
  const idx = raw.url.indexOf('?');
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/sources",
3
- "version": "1.3.1",
3
+ "version": "1.5.0",
4
4
  "description": "Instruments to have incoming messages run in async-local request scope.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -9,8 +9,8 @@
9
9
  "author": "",
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
- "@contrast/common": "1.37.0",
13
- "@contrast/core": "1.57.1",
12
+ "@contrast/common": "1.38.0",
13
+ "@contrast/core": "1.59.0",
14
14
  "on-finished": "^2.4.1"
15
15
  }
16
16
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/telemetry",
3
- "version": "1.32.1",
3
+ "version": "1.34.0",
4
4
  "description": "Telemetry reporting for the Contrast Node.js agent.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
@@ -19,10 +19,10 @@
19
19
  "test": "bash ../scripts/test.sh"
20
20
  },
21
21
  "dependencies": {
22
- "@contrast/common": "1.37.0",
23
- "@contrast/config": "1.52.1",
24
- "@contrast/core": "1.57.1",
25
- "@contrast/logger": "1.30.1",
22
+ "@contrast/common": "1.38.0",
23
+ "@contrast/config": "1.54.0",
24
+ "@contrast/core": "1.59.0",
25
+ "@contrast/logger": "1.32.0",
26
26
  "axios": "^1.12.2",
27
27
  "getmac": "^6.3.0"
28
28
  }
@@ -8,7 +8,7 @@ This package contains type definitions for node (https://nodejs.org/).
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Thu, 18 Sep 2025 00:04:03 GMT
11
+ * Last updated: Tue, 28 Oct 2025 17:37:26 GMT
12
12
  * Dependencies: [undici-types](https://npmjs.com/package/undici-types)
13
13
 
14
14
  # Credits
@@ -1,8 +1,111 @@
1
+ /**
2
+ * In strict assertion mode, non-strict methods behave like their corresponding
3
+ * strict methods. For example, `assert.deepEqual()` will behave like
4
+ * `assert.deepStrictEqual()`.
5
+ *
6
+ * In strict assertion mode, error messages for objects display a diff. In legacy
7
+ * assertion mode, error messages for objects display the objects, often truncated.
8
+ *
9
+ * To use strict assertion mode:
10
+ *
11
+ * ```js
12
+ * import { strict as assert } from 'node:assert';
13
+ * ```
14
+ *
15
+ * ```js
16
+ * import assert from 'node:assert/strict';
17
+ * ```
18
+ *
19
+ * Example error diff:
20
+ *
21
+ * ```js
22
+ * import { strict as assert } from 'node:assert';
23
+ *
24
+ * assert.deepEqual([[[1, 2, 3]], 4, 5], [[[1, 2, '3']], 4, 5]);
25
+ * // AssertionError: Expected inputs to be strictly deep-equal:
26
+ * // + actual - expected ... Lines skipped
27
+ * //
28
+ * // [
29
+ * // [
30
+ * // ...
31
+ * // 2,
32
+ * // + 3
33
+ * // - '3'
34
+ * // ],
35
+ * // ...
36
+ * // 5
37
+ * // ]
38
+ * ```
39
+ *
40
+ * To deactivate the colors, use the `NO_COLOR` or `NODE_DISABLE_COLORS`
41
+ * environment variables. This will also deactivate the colors in the REPL. For
42
+ * more on color support in terminal environments, read the tty
43
+ * [`getColorDepth()`](https://nodejs.org/docs/latest-v24.x/api/tty.html#writestreamgetcolordepthenv) documentation.
44
+ * @since v15.0.0
45
+ * @see [source](https://github.com/nodejs/node/blob/v24.x/lib/assert/strict.js)
46
+ */
1
47
  declare module "assert/strict" {
2
- import { strict } from "node:assert";
48
+ import {
49
+ Assert,
50
+ AssertionError,
51
+ AssertionErrorOptions,
52
+ AssertOptions,
53
+ AssertPredicate,
54
+ AssertStrict,
55
+ CallTracker,
56
+ CallTrackerCall,
57
+ CallTrackerReportInformation,
58
+ deepStrictEqual,
59
+ doesNotMatch,
60
+ doesNotReject,
61
+ doesNotThrow,
62
+ fail,
63
+ ifError,
64
+ match,
65
+ notDeepStrictEqual,
66
+ notStrictEqual,
67
+ ok,
68
+ partialDeepStrictEqual,
69
+ rejects,
70
+ strictEqual,
71
+ throws,
72
+ } from "node:assert";
73
+ function strict(value: unknown, message?: string | Error): asserts value;
74
+ namespace strict {
75
+ export {
76
+ Assert,
77
+ AssertionError,
78
+ AssertionErrorOptions,
79
+ AssertOptions,
80
+ AssertPredicate,
81
+ AssertStrict,
82
+ CallTracker,
83
+ CallTrackerCall,
84
+ CallTrackerReportInformation,
85
+ deepStrictEqual,
86
+ deepStrictEqual as deepEqual,
87
+ doesNotMatch,
88
+ doesNotReject,
89
+ doesNotThrow,
90
+ fail,
91
+ ifError,
92
+ match,
93
+ notDeepStrictEqual,
94
+ notDeepStrictEqual as notDeepEqual,
95
+ notStrictEqual,
96
+ notStrictEqual as notEqual,
97
+ ok,
98
+ partialDeepStrictEqual,
99
+ rejects,
100
+ strict,
101
+ strictEqual,
102
+ strictEqual as equal,
103
+ throws,
104
+ };
105
+ }
3
106
  export = strict;
4
107
  }
5
108
  declare module "node:assert/strict" {
6
- import { strict } from "node:assert";
109
+ import strict = require("assert/strict");
7
110
  export = strict;
8
111
  }
@@ -4,17 +4,163 @@
4
4
  * @see [source](https://github.com/nodejs/node/blob/v24.x/lib/assert.js)
5
5
  */
6
6
  declare module "assert" {
7
+ import strict = require("assert/strict");
7
8
  /**
8
- * An alias of {@link ok}.
9
+ * An alias of {@link assert.ok}.
9
10
  * @since v0.5.9
10
11
  * @param value The input that is checked for being truthy.
11
12
  */
12
13
  function assert(value: unknown, message?: string | Error): asserts value;
14
+ const kOptions: unique symbol;
13
15
  namespace assert {
16
+ type AssertMethodNames =
17
+ | "deepEqual"
18
+ | "deepStrictEqual"
19
+ | "doesNotMatch"
20
+ | "doesNotReject"
21
+ | "doesNotThrow"
22
+ | "equal"
23
+ | "fail"
24
+ | "ifError"
25
+ | "match"
26
+ | "notDeepEqual"
27
+ | "notDeepStrictEqual"
28
+ | "notEqual"
29
+ | "notStrictEqual"
30
+ | "ok"
31
+ | "partialDeepStrictEqual"
32
+ | "rejects"
33
+ | "strictEqual"
34
+ | "throws";
35
+ interface AssertOptions {
36
+ /**
37
+ * If set to `'full'`, shows the full diff in assertion errors.
38
+ * @default 'simple'
39
+ */
40
+ diff?: "simple" | "full" | undefined;
41
+ /**
42
+ * If set to `true`, non-strict methods behave like their
43
+ * corresponding strict methods.
44
+ * @default true
45
+ */
46
+ strict?: boolean | undefined;
47
+ /**
48
+ * If set to `true`, skips prototype and constructor
49
+ * comparison in deep equality checks.
50
+ * @since v24.9.0
51
+ * @default false
52
+ */
53
+ skipPrototype?: boolean | undefined;
54
+ }
55
+ interface Assert extends Pick<typeof assert, AssertMethodNames> {
56
+ readonly [kOptions]: AssertOptions & { strict: false };
57
+ }
58
+ interface AssertStrict extends Pick<typeof strict, AssertMethodNames> {
59
+ readonly [kOptions]: AssertOptions & { strict: true };
60
+ }
61
+ /**
62
+ * The `Assert` class allows creating independent assertion instances with custom options.
63
+ * @since v24.6.0
64
+ */
65
+ var Assert: {
66
+ /**
67
+ * Creates a new assertion instance. The `diff` option controls the verbosity of diffs in assertion error messages.
68
+ *
69
+ * ```js
70
+ * const { Assert } = require('node:assert');
71
+ * const assertInstance = new Assert({ diff: 'full' });
72
+ * assertInstance.deepStrictEqual({ a: 1 }, { a: 2 });
73
+ * // Shows a full diff in the error message.
74
+ * ```
75
+ *
76
+ * **Important**: When destructuring assertion methods from an `Assert` instance,
77
+ * the methods lose their connection to the instance's configuration options (such
78
+ * as `diff`, `strict`, and `skipPrototype` settings).
79
+ * The destructured methods will fall back to default behavior instead.
80
+ *
81
+ * ```js
82
+ * const myAssert = new Assert({ diff: 'full' });
83
+ *
84
+ * // This works as expected - uses 'full' diff
85
+ * myAssert.strictEqual({ a: 1 }, { b: { c: 1 } });
86
+ *
87
+ * // This loses the 'full' diff setting - falls back to default 'simple' diff
88
+ * const { strictEqual } = myAssert;
89
+ * strictEqual({ a: 1 }, { b: { c: 1 } });
90
+ * ```
91
+ *
92
+ * The `skipPrototype` option affects all deep equality methods:
93
+ *
94
+ * ```js
95
+ * class Foo {
96
+ * constructor(a) {
97
+ * this.a = a;
98
+ * }
99
+ * }
100
+ *
101
+ * class Bar {
102
+ * constructor(a) {
103
+ * this.a = a;
104
+ * }
105
+ * }
106
+ *
107
+ * const foo = new Foo(1);
108
+ * const bar = new Bar(1);
109
+ *
110
+ * // Default behavior - fails due to different constructors
111
+ * const assert1 = new Assert();
112
+ * assert1.deepStrictEqual(foo, bar); // AssertionError
113
+ *
114
+ * // Skip prototype comparison - passes if properties are equal
115
+ * const assert2 = new Assert({ skipPrototype: true });
116
+ * assert2.deepStrictEqual(foo, bar); // OK
117
+ * ```
118
+ *
119
+ * When destructured, methods lose access to the instance's `this` context and revert to default assertion behavior
120
+ * (diff: 'simple', non-strict mode).
121
+ * To maintain custom options when using destructured methods, avoid
122
+ * destructuring and call methods directly on the instance.
123
+ * @since v24.6.0
124
+ */
125
+ new(
126
+ options?: AssertOptions & { strict?: true | undefined },
127
+ ): AssertStrict;
128
+ new(
129
+ options: AssertOptions,
130
+ ): Assert;
131
+ };
132
+ interface AssertionErrorOptions {
133
+ /**
134
+ * If provided, the error message is set to this value.
135
+ */
136
+ message?: string | undefined;
137
+ /**
138
+ * The `actual` property on the error instance.
139
+ */
140
+ actual?: unknown;
141
+ /**
142
+ * The `expected` property on the error instance.
143
+ */
144
+ expected?: unknown;
145
+ /**
146
+ * The `operator` property on the error instance.
147
+ */
148
+ operator?: string | undefined;
149
+ /**
150
+ * If provided, the generated stack trace omits frames before this function.
151
+ */
152
+ stackStartFn?: Function | undefined;
153
+ /**
154
+ * If set to `'full'`, shows the full diff in assertion errors.
155
+ * @default 'simple'
156
+ */
157
+ diff?: "simple" | "full" | undefined;
158
+ }
14
159
  /**
15
160
  * Indicates the failure of an assertion. All errors thrown by the `node:assert` module will be instances of the `AssertionError` class.
16
161
  */
17
162
  class AssertionError extends Error {
163
+ constructor(options: AssertionErrorOptions);
18
164
  /**
19
165
  * Set to the `actual` argument for methods such as {@link assert.strictEqual()}.
20
166
  */
@@ -23,10 +169,6 @@ declare module "assert" {
23
169
  * Set to the `expected` argument for methods such as {@link assert.strictEqual()}.
24
170
  */
25
171
  expected: unknown;
26
- /**
27
- * Set to the passed in operator value.
28
- */
29
- operator: string;
30
172
  /**
31
173
  * Indicates if the message was auto-generated (`true`) or not.
32
174
  */
@@ -35,19 +177,10 @@ declare module "assert" {
35
177
  * Value is always `ERR_ASSERTION` to show that the error is an assertion error.
36
178
  */
37
179
  code: "ERR_ASSERTION";
38
- constructor(options?: {
39
- /** If provided, the error message is set to this value. */
40
- message?: string | undefined;
41
- /** The `actual` property on the error instance. */
42
- actual?: unknown | undefined;
43
- /** The `expected` property on the error instance. */
44
- expected?: unknown | undefined;
45
- /** The `operator` property on the error instance. */
46
- operator?: string | undefined;
47
- /** If provided, the generated stack trace omits frames before this function. */
48
- // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
49
- stackStartFn?: Function | undefined;
50
- });
180
+ /**
181
+ * Set to the passed in operator value.
182
+ */
183
+ operator: string;
51
184
  }
52
185
  /**
53
186
  * This feature is deprecated and will be removed in a future version.
@@ -970,83 +1103,9 @@ declare module "assert" {
970
1103
  * @since v22.13.0
971
1104
  */
972
1105
  function partialDeepStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void;
973
- /**
974
- * In strict assertion mode, non-strict methods behave like their corresponding strict methods. For example,
975
- * {@link deepEqual} will behave like {@link deepStrictEqual}.
976
- *
977
- * In strict assertion mode, error messages for objects display a diff. In legacy assertion mode, error
978
- * messages for objects display the objects, often truncated.
979
- *
980
- * To use strict assertion mode:
981
- *
982
- * ```js
983
- * import { strict as assert } from 'node:assert';
984
- * import assert from 'node:assert/strict';
985
- * ```
986
- *
987
- * Example error diff:
988
- *
989
- * ```js
990
- * import { strict as assert } from 'node:assert';
991
- *
992
- * assert.deepEqual([[[1, 2, 3]], 4, 5], [[[1, 2, '3']], 4, 5]);
993
- * // AssertionError: Expected inputs to be strictly deep-equal:
994
- * // + actual - expected ... Lines skipped
995
- * //
996
- * // [
997
- * // [
998
- * // ...
999
- * // 2,
1000
- * // + 3
1001
- * // - '3'
1002
- * // ],
1003
- * // ...
1004
- * // 5
1005
- * // ]
1006
- * ```
1007
- *
1008
- * To deactivate the colors, use the `NO_COLOR` or `NODE_DISABLE_COLORS` environment variables. This will also
1009
- * deactivate the colors in the REPL. For more on color support in terminal environments, read the tty
1010
- * `getColorDepth()` documentation.
1011
- *
1012
- * @since v15.0.0, v13.9.0, v12.16.2, v9.9.0
1013
- */
1014
- namespace strict {
1015
- type AssertionError = assert.AssertionError;
1016
- type AssertPredicate = assert.AssertPredicate;
1017
- type CallTrackerCall = assert.CallTrackerCall;
1018
- type CallTrackerReportInformation = assert.CallTrackerReportInformation;
1019
- }
1020
- const strict:
1021
- & Omit<
1022
- typeof assert,
1023
- | "equal"
1024
- | "notEqual"
1025
- | "deepEqual"
1026
- | "notDeepEqual"
1027
- | "ok"
1028
- | "strictEqual"
1029
- | "deepStrictEqual"
1030
- | "ifError"
1031
- | "strict"
1032
- | "AssertionError"
1033
- >
1034
- & {
1035
- (value: unknown, message?: string | Error): asserts value;
1036
- equal: typeof strictEqual;
1037
- notEqual: typeof notStrictEqual;
1038
- deepEqual: typeof deepStrictEqual;
1039
- notDeepEqual: typeof notDeepStrictEqual;
1040
- // Mapped types and assertion functions are incompatible?
1041
- // TS2775: Assertions require every name in the call target
1042
- // to be declared with an explicit type annotation.
1043
- ok: typeof ok;
1044
- strictEqual: typeof strictEqual;
1045
- deepStrictEqual: typeof deepStrictEqual;
1046
- ifError: typeof ifError;
1047
- strict: typeof strict;
1048
- AssertionError: typeof AssertionError;
1049
- };
1106
+ }
1107
+ namespace assert {
1108
+ export { strict };
1050
1109
  }
1051
1110
  export = assert;
1052
1111
  }
@@ -451,7 +451,16 @@ declare module "buffer" {
451
451
  */
452
452
  subarray(start?: number, end?: number): Buffer<TArrayBuffer>;
453
453
  }
454
+ // TODO: remove globals in future version
455
+ /**
456
+ * @deprecated This is intended for internal use, and will be removed once `@types/node` no longer supports
457
+ * TypeScript versions earlier than 5.7.
458
+ */
454
459
  type NonSharedBuffer = Buffer<ArrayBuffer>;
460
+ /**
461
+ * @deprecated This is intended for internal use, and will be removed once `@types/node` no longer supports
462
+ * TypeScript versions earlier than 5.7.
463
+ */
455
464
  type AllowSharedBuffer = Buffer<ArrayBufferLike>;
456
465
  }
457
466
  /** @deprecated Use `Buffer.allocUnsafeSlow()` instead. */
@@ -59,7 +59,7 @@ declare module "buffer" {
59
59
  * @since v19.4.0, v18.14.0
60
60
  * @param input The input to validate.
61
61
  */
62
- export function isUtf8(input: Buffer | ArrayBuffer | NodeJS.TypedArray): boolean;
62
+ export function isUtf8(input: ArrayBuffer | NodeJS.TypedArray): boolean;
63
63
  /**
64
64
  * This function returns `true` if `input` contains only valid ASCII-encoded data,
65
65
  * including the case in which `input` is empty.
@@ -68,7 +68,7 @@ declare module "buffer" {
68
68
  * @since v19.6.0, v18.15.0
69
69
  * @param input The input to validate.
70
70
  */
71
- export function isAscii(input: Buffer | ArrayBuffer | NodeJS.TypedArray): boolean;
71
+ export function isAscii(input: ArrayBuffer | NodeJS.TypedArray): boolean;
72
72
  export let INSPECT_MAX_BYTES: number;
73
73
  export const kMaxLength: number;
74
74
  export const kStringMaxLength: number;
@@ -113,7 +113,11 @@ declare module "buffer" {
113
113
  * @param fromEnc The current encoding.
114
114
  * @param toEnc To target encoding.
115
115
  */
116
- export function transcode(source: Uint8Array, fromEnc: TranscodeEncoding, toEnc: TranscodeEncoding): Buffer;
116
+ export function transcode(
117
+ source: Uint8Array,
118
+ fromEnc: TranscodeEncoding,
119
+ toEnc: TranscodeEncoding,
120
+ ): NonSharedBuffer;
117
121
  /**
118
122
  * Resolves a `'blob:nodedata:...'` an associated `Blob` object registered using
119
123
  * a prior call to `URL.createObjectURL()`.
@@ -330,7 +334,7 @@ declare module "buffer" {
330
334
  * @return The number of bytes contained within `string`.
331
335
  */
332
336
  byteLength(
333
- string: string | Buffer | NodeJS.ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
337
+ string: string | NodeJS.ArrayBufferView | ArrayBufferLike,
334
338
  encoding?: BufferEncoding,
335
339
  ): number;
336
340
  /**