@openclaw/slack 2026.10.1 → 2026.10.5-beta.1

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 (195) hide show
  1. package/dist/.setup/account-configured-zcR9TJJN.mjs +35 -0
  2. package/dist/.setup/{account-inspect-Cs-7DXXW.mjs → account-inspect-D58VVDjk.mjs} +15 -35
  3. package/dist/.setup/{accounts-CDgkV7Cm.mjs → accounts-BMg9YLIv.mjs} +44 -53
  4. package/dist/.setup/{action-runtime-DJ1daRAZ.mjs → action-runtime-BiRZNsIG.mjs} +20 -22
  5. package/dist/.setup/action-runtime.runtime-C5xceJoS.mjs +2 -0
  6. package/dist/.setup/{actions-DDoAJnrH.mjs → actions-KGKwTAKO.mjs} +34 -43
  7. package/dist/.setup/{approval-handler.runtime-BcE_shWc.mjs → approval-handler.runtime-DYrsG2Ox.mjs} +44 -70
  8. package/dist/.setup/{approval-message-updates-EgKGmFXx.mjs → approval-message-updates-CwdDew9i.mjs} +1 -1
  9. package/dist/.setup/{channel-DgKSu8Iv.mjs → channel-C7MY-Hhg.mjs} +138 -97
  10. package/dist/.setup/{channel-type-B9zYYzBU.mjs → channel-type-NjX2SwvS.mjs} +3 -3
  11. package/dist/.setup/{channel.setup-BYIlwbQ7.mjs → channel.setup-BFpQowO3.mjs} +7 -14
  12. package/dist/.setup/{directory-config-B_by7zrc.mjs → directory-config-BEDZPfDn.mjs} +1 -1
  13. package/dist/.setup/{directory-live-C48wazJt.mjs → directory-live-FipfeCwt.mjs} +33 -36
  14. package/dist/.setup/{message-tool-api-CcjLPN3v.mjs → message-tool-api-C7im5ETh.mjs} +2 -2
  15. package/dist/.setup/{monitor-BuYBDmm7.mjs → monitor-BnN2px0N.mjs} +609 -801
  16. package/dist/.setup/{outbound-adapter-BZFkK-mw.mjs → outbound-adapter-4HdGq-8r.mjs} +4 -4
  17. package/dist/.setup/{pipeline.runtime-CIepKmZt.mjs → pipeline.runtime-ByPbC6MN.mjs} +287 -365
  18. package/dist/.setup/{policy-KKTqEiDv.mjs → policy-BaY9_eh1.mjs} +2 -2
  19. package/dist/.setup/{probe-BVlJ3dp0.mjs → probe-CyX52GtD.mjs} +54 -61
  20. package/dist/.setup/{relay-source-CC3h6M7y.mjs → relay-source-CVfH-fBO.mjs} +28 -45
  21. package/dist/.setup/{replies-DHbuthIR.mjs → replies-WmfwvQxc.mjs} +38 -49
  22. package/dist/.setup/{reply-blocks-CKnO4BSG.mjs → reply-blocks-rqHQ_3pr.mjs} +87 -138
  23. package/dist/.setup/{resolve-channels-HR0TgArR.mjs → resolve-channels-B96cgprw.mjs} +17 -41
  24. package/dist/.setup/{resolve-users-BNYBhF0q.mjs → resolve-users-Xz9aPdns.mjs} +22 -58
  25. package/dist/.setup/{scopes-DrDbyUH2.mjs → scopes-aMcMHhXk.mjs} +1 -1
  26. package/dist/.setup/{send-CgPI3Zj8.mjs → send-CLmsR42r.mjs} +157 -284
  27. package/dist/.setup/{session-status-D46GHwOV.mjs → session-status-CcXe10zN.mjs} +181 -238
  28. package/dist/.setup/{setup-plugin-api-ZrHs0N4U.mjs → setup-plugin-api-D92P5p51.mjs} +1 -1
  29. package/dist/.setup/{setup-surface-83lxvE2y.mjs → setup-surface-368jx6Uc.mjs} +6 -6
  30. package/dist/.setup/{shared-VtmYNj-v.mjs → shared-CtprVh_G.mjs} +5 -5
  31. package/dist/.setup/{slash-dispatch.runtime-gBj_uaLM.mjs → slash-dispatch.runtime-Dzwj6TPI.mjs} +1 -1
  32. package/dist/account-inspect-api.js +1 -1
  33. package/dist/api.js +12 -12
  34. package/dist/channel-plugin-api.js +1 -1
  35. package/dist/configured-state.js +6 -13
  36. package/dist/directory-contract-api.js +1 -1
  37. package/dist/message-tool-api.js +1 -1
  38. package/dist/runtime-api.js +10 -10
  39. package/dist/setup-entry.js +1 -1
  40. package/dist/setup-plugin-api.js +1 -1
  41. package/node_modules/@slack/types/dist/block-kit/block-elements.d.ts +1 -1
  42. package/node_modules/@slack/types/dist/block-kit/block-elements.d.ts.map +1 -1
  43. package/node_modules/@slack/types/dist/block-kit/blocks.d.ts +79 -4
  44. package/node_modules/@slack/types/dist/block-kit/blocks.d.ts.map +1 -1
  45. package/node_modules/@slack/types/dist/block-kit/composition-objects.d.ts +17 -0
  46. package/node_modules/@slack/types/dist/block-kit/composition-objects.d.ts.map +1 -1
  47. package/node_modules/@slack/types/package.json +1 -1
  48. package/node_modules/@slack/web-api/dist/methods.d.ts +49 -2
  49. package/node_modules/@slack/web-api/dist/methods.d.ts.map +1 -1
  50. package/node_modules/@slack/web-api/dist/methods.js +47 -0
  51. package/node_modules/@slack/web-api/dist/methods.js.map +1 -1
  52. package/node_modules/@slack/web-api/dist/types/request/agents.d.ts +186 -0
  53. package/node_modules/@slack/web-api/dist/types/request/agents.d.ts.map +1 -1
  54. package/node_modules/@slack/web-api/dist/types/request/index.d.ts +1 -1
  55. package/node_modules/@slack/web-api/dist/types/request/index.d.ts.map +1 -1
  56. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsArchiveResponse.d.ts +9 -0
  57. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsArchiveResponse.d.ts.map +1 -0
  58. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsArchiveResponse.js +11 -0
  59. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsArchiveResponse.js.map +1 -0
  60. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsCreateResponse.d.ts +10 -0
  61. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsCreateResponse.d.ts.map +1 -0
  62. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsCreateResponse.js +11 -0
  63. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsCreateResponse.js.map +1 -0
  64. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsGetCanvasResponse.d.ts +29 -0
  65. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsGetCanvasResponse.d.ts.map +1 -0
  66. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsGetCanvasResponse.js +11 -0
  67. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsGetCanvasResponse.js.map +1 -0
  68. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsListViewsResponse.d.ts +18 -0
  69. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsListViewsResponse.d.ts.map +1 -0
  70. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsListViewsResponse.js +11 -0
  71. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsListViewsResponse.js.map +1 -0
  72. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsRemoveViewResponse.d.ts +11 -0
  73. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsRemoveViewResponse.d.ts.map +1 -0
  74. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsRemoveViewResponse.js +11 -0
  75. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsRemoveViewResponse.js.map +1 -0
  76. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetCanvasContentResponse.d.ts +11 -0
  77. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetCanvasContentResponse.d.ts.map +1 -0
  78. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetCanvasContentResponse.js +11 -0
  79. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetCanvasContentResponse.js.map +1 -0
  80. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetCommandsResponse.d.ts +11 -0
  81. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetCommandsResponse.d.ts.map +1 -0
  82. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetCommandsResponse.js +11 -0
  83. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetCommandsResponse.js.map +1 -0
  84. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetPropertiesResponse.d.ts +10 -0
  85. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetPropertiesResponse.d.ts.map +1 -0
  86. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetPropertiesResponse.js +11 -0
  87. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetPropertiesResponse.js.map +1 -0
  88. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetViewResponse.d.ts +15 -0
  89. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetViewResponse.d.ts.map +1 -0
  90. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetViewResponse.js +11 -0
  91. package/node_modules/@slack/web-api/dist/types/response/AgentsConversationsSetViewResponse.js.map +1 -0
  92. package/node_modules/@slack/web-api/dist/types/response/ConversationsInfoResponse.d.ts +31 -0
  93. package/node_modules/@slack/web-api/dist/types/response/ConversationsInfoResponse.d.ts.map +1 -1
  94. package/node_modules/@slack/web-api/dist/types/response/index.d.ts +9 -0
  95. package/node_modules/@slack/web-api/dist/types/response/index.d.ts.map +1 -1
  96. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/LICENSE +21 -0
  97. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/README.md +15 -0
  98. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/assert/strict.d.ts +68 -0
  99. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/assert.d.ts +1077 -0
  100. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/async_hooks.d.ts +711 -0
  101. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/buffer.buffer.d.ts +471 -0
  102. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/buffer.d.ts +1800 -0
  103. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/child_process.d.ts +1361 -0
  104. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/cluster.d.ts +432 -0
  105. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/console.d.ts +93 -0
  106. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/constants.d.ts +14 -0
  107. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/crypto.d.ts +3964 -0
  108. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/dgram.d.ts +652 -0
  109. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/diagnostics_channel.d.ts +794 -0
  110. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/dns/promises.d.ts +497 -0
  111. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/dns.d.ts +876 -0
  112. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/domain.d.ts +150 -0
  113. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/events.d.ts +1008 -0
  114. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/ffi.d.ts +500 -0
  115. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/fs/promises.d.ts +1477 -0
  116. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/fs.d.ts +4803 -0
  117. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/globals.d.ts +150 -0
  118. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/globals.typedarray.d.ts +101 -0
  119. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/http.d.ts +2218 -0
  120. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/http2.d.ts +2498 -0
  121. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/https.d.ts +400 -0
  122. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/index.d.ts +116 -0
  123. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/inspector/promises.d.ts +35 -0
  124. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/inspector.d.ts +265 -0
  125. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/inspector.generated.d.ts +4406 -0
  126. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/module.d.ts +726 -0
  127. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/net.d.ts +1074 -0
  128. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/os.d.ts +498 -0
  129. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/package.json +155 -0
  130. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/path/posix.d.ts +8 -0
  131. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/path/win32.d.ts +8 -0
  132. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/path.d.ts +178 -0
  133. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/perf_hooks.d.ts +617 -0
  134. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/process.d.ts +2269 -0
  135. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/punycode.d.ts +89 -0
  136. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/querystring.d.ts +139 -0
  137. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/quic.d.ts +2191 -0
  138. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/readline/promises.d.ts +158 -0
  139. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/readline.d.ts +508 -0
  140. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/repl.d.ts +420 -0
  141. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/sea.d.ts +47 -0
  142. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/sqlite.d.ts +1140 -0
  143. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/stream/consumers.d.ts +114 -0
  144. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/stream/iter.d.ts +449 -0
  145. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/stream/promises.d.ts +211 -0
  146. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/stream/web.d.ts +320 -0
  147. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/stream.d.ts +1806 -0
  148. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/string_decoder.d.ts +27 -0
  149. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/test/reporters.d.ts +60 -0
  150. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/test.d.ts +2558 -0
  151. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/timers/promises.d.ts +93 -0
  152. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/timers.d.ts +149 -0
  153. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/tls.d.ts +1232 -0
  154. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/trace_events.d.ts +103 -0
  155. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +467 -0
  156. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +71 -0
  157. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +36 -0
  158. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/ts5.6/index.d.ts +118 -0
  159. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +72 -0
  160. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/ts5.7/index.d.ts +118 -0
  161. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/tty.d.ts +226 -0
  162. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/url.d.ts +556 -0
  163. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/util/types.d.ts +558 -0
  164. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/util.d.ts +1677 -0
  165. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/v8.d.ts +1059 -0
  166. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/vfs.d.ts +211 -0
  167. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/vm.d.ts +1137 -0
  168. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/wasi.d.ts +131 -0
  169. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/abortcontroller.d.ts +59 -0
  170. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/blob.d.ts +23 -0
  171. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/console.d.ts +9 -0
  172. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/crypto.d.ts +39 -0
  173. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/domexception.d.ts +83 -0
  174. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/encoding.d.ts +11 -0
  175. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/events.d.ts +106 -0
  176. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/fetch.d.ts +69 -0
  177. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/importmeta.d.ts +13 -0
  178. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/messaging.d.ts +23 -0
  179. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/navigator.d.ts +25 -0
  180. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/performance.d.ts +45 -0
  181. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/storage.d.ts +24 -0
  182. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/streams.d.ts +119 -0
  183. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/timers.d.ts +44 -0
  184. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/web-globals/url.d.ts +24 -0
  185. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/worker_threads.d.ts +672 -0
  186. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/zlib/iter.d.ts +131 -0
  187. package/node_modules/@slack/web-api/node_modules/@slack/logger/node_modules/@types/node/zlib.d.ts +606 -0
  188. package/node_modules/@slack/web-api/node_modules/@types/node/README.md +2 -2
  189. package/node_modules/@slack/web-api/node_modules/@types/node/package.json +2 -17
  190. package/node_modules/@slack/web-api/package.json +2 -2
  191. package/openclaw.plugin.json +0 -3
  192. package/package.json +6 -14
  193. package/dist/.setup/account-configured-sUohAxZr.mjs +0 -33
  194. package/dist/.setup/action-runtime.runtime-CdWL2mLC.mjs +0 -2
  195. package/dist/control-ui/2f4b1e827be6b68ced2ea0d8b7da8529a4eafbe72be27ee37e1064bdd530ec10/index.js +0 -1
@@ -0,0 +1,1074 @@
1
+ declare module "node:net" {
2
+ import { NonSharedBuffer } from "node:buffer";
3
+ import * as dns from "node:dns";
4
+ import { Abortable, EventEmitter, InternalEventEmitter } from "node:events";
5
+ import * as stream from "node:stream";
6
+ type LookupFunction = (
7
+ hostname: string,
8
+ options: dns.LookupOptions,
9
+ callback: (err: NodeJS.ErrnoException | null, address: string | dns.LookupAddress[], family?: number) => void,
10
+ ) => void;
11
+ interface AddressInfo {
12
+ address: string;
13
+ family: string;
14
+ port: number;
15
+ }
16
+ interface SocketConstructorOpts {
17
+ fd?: number | undefined;
18
+ allowHalfOpen?: boolean | undefined;
19
+ onread?: OnReadOpts | undefined;
20
+ readable?: boolean | undefined;
21
+ writable?: boolean | undefined;
22
+ signal?: AbortSignal | undefined;
23
+ noDelay?: boolean | undefined;
24
+ keepAlive?: boolean | undefined;
25
+ keepAliveInitialDelay?: number | undefined;
26
+ blockList?: BlockList | undefined;
27
+ typeOfService?: number | undefined;
28
+ handle?: BoundSocket | undefined;
29
+ }
30
+ interface OnReadOpts {
31
+ buffer: Uint8Array | (() => Uint8Array);
32
+ /**
33
+ * This function is called for every chunk of incoming data.
34
+ * Two arguments are passed to it: the number of bytes written to `buffer` and a reference to `buffer`.
35
+ * Return `false` from this function to implicitly `pause()` the socket.
36
+ */
37
+ callback(bytesWritten: number, buffer: Uint8Array): boolean;
38
+ }
39
+ interface TcpSocketConnectOpts {
40
+ port: number;
41
+ host?: string | undefined;
42
+ localAddress?: string | undefined;
43
+ localPort?: number | undefined;
44
+ hints?: number | undefined;
45
+ family?: number | undefined;
46
+ lookup?: LookupFunction | undefined;
47
+ /**
48
+ * @since v18.13.0
49
+ */
50
+ autoSelectFamily?: boolean | undefined;
51
+ /**
52
+ * @since v18.13.0
53
+ */
54
+ autoSelectFamilyAttemptTimeout?: number | undefined;
55
+ }
56
+ interface IpcSocketConnectOpts {
57
+ path: string;
58
+ }
59
+ type SocketConnectOpts = TcpSocketConnectOpts | IpcSocketConnectOpts;
60
+ type SocketReadyState = "opening" | "open" | "readOnly" | "writeOnly" | "closed";
61
+ interface SetKeepAliveOptions {
62
+ enable?: boolean | undefined;
63
+ initialDelay?: number | undefined;
64
+ interval?: number | undefined;
65
+ count?: number | undefined;
66
+ }
67
+ interface SocketEventMap extends Omit<stream.DuplexEventMap, "close"> {
68
+ "close": [hadError: boolean];
69
+ "connect": [];
70
+ "connectionAttempt": [ip: string, port: number, family: number];
71
+ "connectionAttemptFailed": [ip: string, port: number, family: number, error: Error];
72
+ "connectionAttemptTimeout": [ip: string, port: number, family: number];
73
+ "data": [data: string | NonSharedBuffer];
74
+ "lookup": [err: Error | null, address: string, family: number | null, host: string];
75
+ "ready": [];
76
+ "timeout": [];
77
+ }
78
+ /**
79
+ * This class is an abstraction of a TCP socket or a streaming `IPC` endpoint
80
+ * (uses named pipes on Windows, and Unix domain sockets otherwise). It is also
81
+ * an `EventEmitter`.
82
+ *
83
+ * A `net.Socket` can be created by the user and used directly to interact with
84
+ * a server. For example, it is returned by {@link createConnection},
85
+ * so the user can use it to talk to the server.
86
+ *
87
+ * It can also be created by Node.js and passed to the user when a connection
88
+ * is received. For example, it is passed to the listeners of a `'connection'` event emitted on a {@link Server}, so the user can use
89
+ * it to interact with the client.
90
+ * @since v0.3.4
91
+ */
92
+ class Socket extends stream.Duplex {
93
+ constructor(options?: SocketConstructorOpts);
94
+ /**
95
+ * Destroys the socket after all data is written. If the `finish` event was already emitted the socket is destroyed immediately.
96
+ * If the socket is still writable it implicitly calls `socket.end()`.
97
+ * @since v0.3.4
98
+ */
99
+ destroySoon(): void;
100
+ /**
101
+ * Sends data on the socket. The second parameter specifies the encoding in the
102
+ * case of a string. It defaults to UTF8 encoding.
103
+ *
104
+ * Returns `true` if the entire data was flushed successfully to the kernel
105
+ * buffer. Returns `false` if all or part of the data was queued in user memory.`'drain'` will be emitted when the buffer is again free.
106
+ *
107
+ * The optional `callback` parameter will be executed when the data is finally
108
+ * written out, which may not be immediately.
109
+ *
110
+ * See `Writable` stream `write()` method for more
111
+ * information.
112
+ * @since v0.1.90
113
+ */
114
+ write(buffer: Uint8Array | string, cb?: (err?: Error | null) => void): boolean;
115
+ /**
116
+ * Sends data on the socket, with an explicit encoding for string data.
117
+ * @see {@link Socket.write} for full details.
118
+ * @since v0.1.90
119
+ * @param [encoding='utf8'] Only used when data is `string`.
120
+ */
121
+ write(str: Uint8Array | string, encoding?: BufferEncoding, cb?: (err?: Error | null) => void): boolean;
122
+ /**
123
+ * Initiate a connection on a given socket.
124
+ *
125
+ * Possible signatures:
126
+ *
127
+ * * `socket.connect(options[, connectListener])`
128
+ * * `socket.connect(path[, connectListener])` for `IPC` connections.
129
+ * * `socket.connect(port[, host][, connectListener])` for TCP connections.
130
+ * * Returns: `net.Socket` The socket itself.
131
+ *
132
+ * This function is asynchronous. When the connection is established, the `'connect'` event will be emitted. If there is a problem connecting,
133
+ * instead of a `'connect'` event, an `'error'` event will be emitted with
134
+ * the error passed to the `'error'` listener.
135
+ * The last parameter `connectListener`, if supplied, will be added as a listener
136
+ * for the `'connect'` event **once**.
137
+ *
138
+ * This function should only be used for reconnecting a socket after`'close'` has been emitted or otherwise it may lead to undefined
139
+ * behavior.
140
+ */
141
+ connect(options: SocketConnectOpts, connectionListener?: () => void): this;
142
+ connect(port: number, host: string, connectionListener?: () => void): this;
143
+ connect(port: number, connectionListener?: () => void): this;
144
+ connect(path: string, connectionListener?: () => void): this;
145
+ /**
146
+ * Set the encoding for the socket as a `Readable Stream`. See `readable.setEncoding()` for more information.
147
+ * @since v0.1.90
148
+ * @return The socket itself.
149
+ */
150
+ setEncoding(encoding?: BufferEncoding): this;
151
+ /**
152
+ * Pauses the reading of data. That is, `'data'` events will not be emitted.
153
+ * Useful to throttle back an upload.
154
+ * @return The socket itself.
155
+ */
156
+ pause(): this;
157
+ /**
158
+ * Close the TCP connection by sending an RST packet and destroy the stream.
159
+ * If this TCP socket is in connecting status, it will send an RST packet and destroy this TCP socket once it is connected.
160
+ * Otherwise, it will call `socket.destroy` with an `ERR_SOCKET_CLOSED` Error.
161
+ * If this is not a TCP socket (for example, a pipe), calling this method will immediately throw an `ERR_INVALID_HANDLE_TYPE` Error.
162
+ * @since v18.3.0, v16.17.0
163
+ */
164
+ resetAndDestroy(): this;
165
+ /**
166
+ * Resumes reading after a call to `socket.pause()`.
167
+ * @return The socket itself.
168
+ */
169
+ resume(): this;
170
+ /**
171
+ * Sets the socket to timeout after `timeout` milliseconds of inactivity on
172
+ * the socket. By default `net.Socket` do not have a timeout.
173
+ *
174
+ * When an idle timeout is triggered the socket will receive a `'timeout'` event but the connection will not be severed. The user must manually call `socket.end()` or `socket.destroy()` to
175
+ * end the connection.
176
+ *
177
+ * ```js
178
+ * socket.setTimeout(3000);
179
+ * socket.on('timeout', () => {
180
+ * console.log('socket timeout');
181
+ * socket.end();
182
+ * });
183
+ * ```
184
+ *
185
+ * If `timeout` is 0, then the existing idle timeout is disabled.
186
+ *
187
+ * The optional `callback` parameter will be added as a one-time listener for the `'timeout'` event.
188
+ * @since v0.1.90
189
+ * @return The socket itself.
190
+ */
191
+ setTimeout(timeout: number, callback?: () => void): this;
192
+ /**
193
+ * Enable/disable the use of Nagle's algorithm.
194
+ *
195
+ * When a TCP connection is created, it will have Nagle's algorithm enabled.
196
+ *
197
+ * Nagle's algorithm delays data before it is sent via the network. It attempts
198
+ * to optimize throughput at the expense of latency.
199
+ *
200
+ * Passing `true` for `noDelay` or not passing an argument will disable Nagle's
201
+ * algorithm for the socket. Passing `false` for `noDelay` will enable Nagle's
202
+ * algorithm.
203
+ * @since v0.1.90
204
+ * @param [noDelay=true]
205
+ * @return The socket itself.
206
+ */
207
+ setNoDelay(noDelay?: boolean): this;
208
+ /**
209
+ * Configure keep-alive using an options object. See `socket.setKeepAlive()`
210
+ * for a description of each property.
211
+ *
212
+ * ```js
213
+ * socket.setKeepAlive({ enable: true, initialDelay: 1000, interval: 1000, count: 10 });
214
+ * ```
215
+ * @since v26.4.0
216
+ * @returns The socket itself.
217
+ */
218
+ setKeepAlive(options: SetKeepAliveOptions): this;
219
+ /**
220
+ * Configure keep-alive using positional arguments. See
221
+ * `socket.setKeepAlive()` for a description of each argument.
222
+ * @since v0.1.92
223
+ * @param enable **Default:** `false`
224
+ * @param initialDelay **Default:** `0`
225
+ * @param interval **Default:** `1000`
226
+ * @param count **Default:** `10`
227
+ * @returns The socket itself.
228
+ */
229
+ setKeepAlive(enable?: boolean, initialDelay?: number, interval?: number, count?: number): this;
230
+ /**
231
+ * Returns the current Type of Service (TOS) field for IPv4 packets or Traffic
232
+ * Class for IPv6 packets for this socket.
233
+ *
234
+ * `setTypeOfService()` may be called before the socket is connected; the value
235
+ * will be cached and applied when the socket establishes a connection.
236
+ * `getTypeOfService()` will return the currently set value even before connection.
237
+ *
238
+ * On some platforms (e.g., Linux), certain TOS/ECN bits may be masked or ignored,
239
+ * and behavior can differ between IPv4 and IPv6 or dual-stack sockets. Callers
240
+ * should verify platform-specific semantics.
241
+ * @since v25.6.0
242
+ * @returns The current TOS value.
243
+ */
244
+ getTypeOfService(): number;
245
+ /**
246
+ * Sets the Type of Service (TOS) field for IPv4 packets or Traffic Class for IPv6
247
+ * Packets sent from this socket. This can be used to prioritize network traffic.
248
+ *
249
+ * `setTypeOfService()` may be called before the socket is connected; the value
250
+ * will be cached and applied when the socket establishes a connection.
251
+ * `getTypeOfService()` will return the currently set value even before connection.
252
+ *
253
+ * On some platforms (e.g., Linux), certain TOS/ECN bits may be masked or ignored,
254
+ * and behavior can differ between IPv4 and IPv6 or dual-stack sockets. Callers
255
+ * should verify platform-specific semantics.
256
+ * @since v25.6.0
257
+ * @param tos The TOS value to set (0-255).
258
+ * @returns The socket itself.
259
+ */
260
+ setTypeOfService(tos: number): this;
261
+ /**
262
+ * Returns the bound `address`, the address `family` name and `port` of the
263
+ * socket as reported by the operating system:`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`
264
+ * @since v0.1.90
265
+ */
266
+ address(): AddressInfo | {};
267
+ /**
268
+ * Calling `unref()` on a socket will allow the program to exit if this is the only
269
+ * active socket in the event system. If the socket is already `unref`ed calling`unref()` again will have no effect.
270
+ * @since v0.9.1
271
+ * @return The socket itself.
272
+ */
273
+ unref(): this;
274
+ /**
275
+ * Opposite of `unref()`, calling `ref()` on a previously `unref`ed socket will _not_ let the program exit if it's the only socket left (the default behavior).
276
+ * If the socket is `ref`ed calling `ref` again will have no effect.
277
+ * @since v0.9.1
278
+ * @return The socket itself.
279
+ */
280
+ ref(): this;
281
+ /**
282
+ * This property is only present if the family autoselection algorithm is enabled in `socket.connect(options)`
283
+ * and it is an array of the addresses that have been attempted.
284
+ *
285
+ * Each address is a string in the form of `$IP:$PORT`.
286
+ * If the connection was successful, then the last address is the one that the socket is currently connected to.
287
+ * @since v19.4.0
288
+ */
289
+ readonly autoSelectFamilyAttemptedAddresses: string[];
290
+ /**
291
+ * This property shows the number of characters buffered for writing. The buffer
292
+ * may contain strings whose length after encoding is not yet known. So this number
293
+ * is only an approximation of the number of bytes in the buffer.
294
+ *
295
+ * `net.Socket` has the property that `socket.write()` always works. This is to
296
+ * help users get up and running quickly. The computer cannot always keep up
297
+ * with the amount of data that is written to a socket. The network connection
298
+ * simply might be too slow. Node.js will internally queue up the data written to a
299
+ * socket and send it out over the wire when it is possible.
300
+ *
301
+ * The consequence of this internal buffering is that memory may grow.
302
+ * Users who experience large or growing `bufferSize` should attempt to
303
+ * "throttle" the data flows in their program with `socket.pause()` and `socket.resume()`.
304
+ * @since v0.3.8
305
+ * @deprecated Since v14.6.0 - Use `writableLength` instead.
306
+ */
307
+ readonly bufferSize: number;
308
+ /**
309
+ * The amount of received bytes.
310
+ * @since v0.5.3
311
+ */
312
+ readonly bytesRead: number;
313
+ /**
314
+ * The amount of bytes sent.
315
+ * @since v0.5.3
316
+ */
317
+ readonly bytesWritten: number;
318
+ /**
319
+ * If `true`, `socket.connect(options[, connectListener])` was
320
+ * called and has not yet finished. It will stay `true` until the socket becomes
321
+ * connected, then it is set to `false` and the `'connect'` event is emitted. Note
322
+ * that the `socket.connect(options[, connectListener])` callback is a listener for the `'connect'` event.
323
+ * @since v6.1.0
324
+ */
325
+ readonly connecting: boolean;
326
+ /**
327
+ * This is `true` if the socket is not connected yet, either because `.connect()`has not yet been called or because it is still in the process of connecting
328
+ * (see `socket.connecting`).
329
+ * @since v11.2.0, v10.16.0
330
+ */
331
+ readonly pending: boolean;
332
+ /**
333
+ * See `writable.destroyed` for further details.
334
+ */
335
+ readonly destroyed: boolean;
336
+ /**
337
+ * The string representation of the local IP address the remote client is
338
+ * connecting on. For example, in a server listening on `'0.0.0.0'`, if a client
339
+ * connects on `'192.168.1.1'`, the value of `socket.localAddress` would be`'192.168.1.1'`.
340
+ * @since v0.9.6
341
+ */
342
+ readonly localAddress?: string;
343
+ /**
344
+ * The numeric representation of the local port. For example, `80` or `21`.
345
+ * @since v0.9.6
346
+ */
347
+ readonly localPort?: number;
348
+ /**
349
+ * The string representation of the local IP family. `'IPv4'` or `'IPv6'`.
350
+ * @since v18.8.0, v16.18.0
351
+ */
352
+ readonly localFamily?: string;
353
+ /**
354
+ * This property represents the state of the connection as a string.
355
+ *
356
+ * * If the socket is connecting, `socket.readyState` is `opening`.
357
+ * * If the socket is readable and writable, it is `open`.
358
+ * * If the socket is readable and not writable, it is `readOnly`.
359
+ * * If the socket is not readable and writable, it is `writeOnly`.
360
+ * * Otherwise, it is `closed`.
361
+ * @since v0.5.0
362
+ */
363
+ readonly readyState: SocketReadyState;
364
+ /**
365
+ * The string representation of the remote IP address. For example,`'74.125.127.100'` or `'2001:4860:a005::68'`. Value may be `undefined` if
366
+ * the socket is destroyed (for example, if the client disconnected).
367
+ * @since v0.5.10
368
+ */
369
+ readonly remoteAddress: string | undefined;
370
+ /**
371
+ * The string representation of the remote IP family. `'IPv4'` or `'IPv6'`. Value may be `undefined` if
372
+ * the socket is destroyed (for example, if the client disconnected).
373
+ * @since v0.11.14
374
+ */
375
+ readonly remoteFamily: string | undefined;
376
+ /**
377
+ * The numeric representation of the remote port. For example, `80` or `21`. Value may be `undefined` if
378
+ * the socket is destroyed (for example, if the client disconnected).
379
+ * @since v0.5.10
380
+ */
381
+ readonly remotePort: number | undefined;
382
+ /**
383
+ * Reference to the server that accepted the socket. This is `null` for sockets
384
+ * that were not accepted by a server.
385
+ * @since v0.3.4
386
+ */
387
+ readonly server: Server | null;
388
+ /**
389
+ * The socket timeout in milliseconds as set by `socket.setTimeout()`.
390
+ * It is `undefined` if a timeout has not been set.
391
+ * @since v10.7.0
392
+ */
393
+ readonly timeout?: number;
394
+ /**
395
+ * Half-closes the socket. i.e., it sends a FIN packet. It is possible the
396
+ * server will still send some data.
397
+ *
398
+ * See `writable.end()` for further details.
399
+ * @since v0.1.90
400
+ * @param callback Optional callback for when the socket is finished.
401
+ * @return The socket itself.
402
+ */
403
+ end(callback?: () => void): this;
404
+ /**
405
+ * Half-closes the socket, with one final chunk of data.
406
+ * @see {@link Socket.end} for full details.
407
+ * @since v0.1.90
408
+ * @param callback Optional callback for when the socket is finished.
409
+ * @return The socket itself.
410
+ */
411
+ end(buffer: Uint8Array | string, callback?: () => void): this;
412
+ /**
413
+ * Half-closes the socket, with one final chunk of data.
414
+ * @see {@link Socket.end} for full details.
415
+ * @since v0.1.90
416
+ * @param [encoding='utf8'] Only used when data is `string`.
417
+ * @param callback Optional callback for when the socket is finished.
418
+ * @return The socket itself.
419
+ */
420
+ end(str: Uint8Array | string, encoding?: BufferEncoding, callback?: () => void): this;
421
+ // #region InternalEventEmitter
422
+ addListener<E extends keyof SocketEventMap>(eventName: E, listener: (...args: SocketEventMap[E]) => void): this;
423
+ addListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
424
+ emit<E extends keyof SocketEventMap>(eventName: E, ...args: SocketEventMap[E]): boolean;
425
+ emit(eventName: string | symbol, ...args: any[]): boolean;
426
+ listenerCount<E extends keyof SocketEventMap>(
427
+ eventName: E,
428
+ listener?: (...args: SocketEventMap[E]) => void,
429
+ ): number;
430
+ listenerCount(eventName: string | symbol, listener?: (...args: any[]) => void): number;
431
+ listeners<E extends keyof SocketEventMap>(eventName: E): ((...args: SocketEventMap[E]) => void)[];
432
+ listeners(eventName: string | symbol): ((...args: any[]) => void)[];
433
+ off<E extends keyof SocketEventMap>(eventName: E, listener: (...args: SocketEventMap[E]) => void): this;
434
+ off(eventName: string | symbol, listener: (...args: any[]) => void): this;
435
+ on<E extends keyof SocketEventMap>(eventName: E, listener: (...args: SocketEventMap[E]) => void): this;
436
+ on(eventName: string | symbol, listener: (...args: any[]) => void): this;
437
+ once<E extends keyof SocketEventMap>(eventName: E, listener: (...args: SocketEventMap[E]) => void): this;
438
+ once(eventName: string | symbol, listener: (...args: any[]) => void): this;
439
+ prependListener<E extends keyof SocketEventMap>(
440
+ eventName: E,
441
+ listener: (...args: SocketEventMap[E]) => void,
442
+ ): this;
443
+ prependListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
444
+ prependOnceListener<E extends keyof SocketEventMap>(
445
+ eventName: E,
446
+ listener: (...args: SocketEventMap[E]) => void,
447
+ ): this;
448
+ prependOnceListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
449
+ rawListeners<E extends keyof SocketEventMap>(eventName: E): ((...args: SocketEventMap[E]) => void)[];
450
+ rawListeners(eventName: string | symbol): ((...args: any[]) => void)[];
451
+ // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
452
+ removeAllListeners<E extends keyof SocketEventMap>(eventName?: E): this;
453
+ removeAllListeners(eventName?: string | symbol): this;
454
+ removeListener<E extends keyof SocketEventMap>(
455
+ eventName: E,
456
+ listener: (...args: SocketEventMap[E]) => void,
457
+ ): this;
458
+ removeListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
459
+ // #endregion
460
+ }
461
+ interface BoundSocketOptions {
462
+ /**
463
+ * Local address to bind. Must be a numeric IP literal; no DNS
464
+ * resolution is performed. **Default:** `'0.0.0.0'`, or `'::'` when
465
+ * `ipv6Only` is `true`.
466
+ */
467
+ host?: string | undefined;
468
+ /**
469
+ * Local port. `0` requests an OS-assigned ephemeral port.
470
+ * **Default:** `0`.
471
+ */
472
+ port?: number | undefined;
473
+ /**
474
+ * Sets `IPV6_V6ONLY`, disabling dual-stack support so the
475
+ * socket binds IPv6 only. Only meaningful for IPv6 binds. **Default:**
476
+ * `false`.
477
+ */
478
+ ipv6Only?: boolean | undefined;
479
+ /**
480
+ * Sets `SO_REUSEPORT`, allowing multiple sockets to bind
481
+ * the same address and port for kernel-level load balancing. Support is
482
+ * platform-dependent. **Default:** `false`.
483
+ */
484
+ reusePort?: boolean | undefined;
485
+ }
486
+ /**
487
+ * Allows for the synchronous creation of a pre-bound socket, that can be passed
488
+ * to `listen()` or `new net.Socket()` later on. For `listen()` this enables
489
+ * synchronous port reservation, while for `new net.Socket()`, it allows control
490
+ * over the local egress port/IP, via `bind(2)` semantics.
491
+ *
492
+ * Adoption transfers ownership of the socket; afterwards `address()` and `close()`
493
+ * throw `ERR_SOCKET_HANDLE_ADOPTED`. A handle that is never adopted must be
494
+ * closed to avoid leaking the socket.
495
+ *
496
+ * When an adopted `BoundSocket` connects to a numeric IP literal, `connect(2)` is
497
+ * issued synchronously, so `socket.localAddress` is resolved once
498
+ * `socket.connect()` returns. Connection failures are still reported via a
499
+ * deferred `'error'` event.
500
+ *
501
+ * ```js
502
+ * import net from 'node:net';
503
+ *
504
+ * const bound = new net.BoundSocket();
505
+ * const { port } = bound.address();
506
+ * console.log(`Reserved port ${port} for server`);
507
+ *
508
+ * const server = net.createServer();
509
+ * server.listen(bound); // Adopt as a server, or pass to new net.Socket() instead.
510
+ * ```
511
+ * @since v26.4.0
512
+ */
513
+ class BoundSocket {
514
+ /**
515
+ * @since v26.4.0
516
+ */
517
+ constructor(options?: BoundSocketOptions);
518
+ /**
519
+ * Returns the bound local address. When bound with `port: 0`, `port` is the
520
+ * OS-assigned ephemeral port.
521
+ * @since v26.4.0
522
+ * @returns An object with `address`, `family`, and `port` properties,
523
+ * as `server.address()` returns.
524
+ */
525
+ address(): AddressInfo;
526
+ /**
527
+ * Returns the file descriptor of the bound socket. Ownership remains with the
528
+ * `BoundSocket`, so the descriptor must not be closed by the caller. The
529
+ * descriptor is only available before the handle is adopted; afterwards it belongs
530
+ * to the adopting `net.Server` or `net.Socket` and `fd()` throws
531
+ * `ERR_SOCKET_HANDLE_ADOPTED`.
532
+ * @since v26.4.0
533
+ * @returns The underlying OS file descriptor, or `-1` on platforms
534
+ * that do not expose one for sockets (such as Windows).
535
+ */
536
+ fd(): number;
537
+ /**
538
+ * Releases the bound socket. Only needed when the handle is never adopted.
539
+ * @since v26.4.0
540
+ */
541
+ close(): void;
542
+ /**
543
+ * Closes the handle if it has not been adopted or closed; otherwise a no-op.
544
+ * @since v26.4.0
545
+ */
546
+ [Symbol.dispose](): void;
547
+ }
548
+ interface ListenOptions extends Abortable {
549
+ backlog?: number | undefined;
550
+ exclusive?: boolean | undefined;
551
+ handle?: BoundSocket | undefined;
552
+ host?: string | undefined;
553
+ /**
554
+ * @default false
555
+ */
556
+ ipv6Only?: boolean | undefined;
557
+ reusePort?: boolean | undefined;
558
+ path?: string | undefined;
559
+ port?: number | undefined;
560
+ readableAll?: boolean | undefined;
561
+ writableAll?: boolean | undefined;
562
+ }
563
+ interface ServerOpts {
564
+ /**
565
+ * Indicates whether half-opened TCP connections are allowed.
566
+ * @default false
567
+ */
568
+ allowHalfOpen?: boolean | undefined;
569
+ /**
570
+ * Indicates whether the socket should be paused on incoming connections.
571
+ * @default false
572
+ */
573
+ pauseOnConnect?: boolean | undefined;
574
+ /**
575
+ * If set to `true`, it disables the use of Nagle's algorithm immediately after a new incoming connection is received.
576
+ * @default false
577
+ * @since v16.5.0
578
+ */
579
+ noDelay?: boolean | undefined;
580
+ /**
581
+ * If set to `true`, it enables keep-alive functionality on the socket immediately after a new incoming connection is received,
582
+ * similarly on what is done in `socket.setKeepAlive([enable][, initialDelay])`.
583
+ * @default false
584
+ * @since v16.5.0
585
+ */
586
+ keepAlive?: boolean | undefined;
587
+ /**
588
+ * If set to a positive number, it sets the initial delay before the first keepalive probe is sent on an idle socket.
589
+ * @default 0
590
+ * @since v16.5.0
591
+ */
592
+ keepAliveInitialDelay?: number | undefined;
593
+ /**
594
+ * Optionally overrides all `net.Socket`s' `readableHighWaterMark` and `writableHighWaterMark`.
595
+ * @default See [stream.getDefaultHighWaterMark()](https://nodejs.org/docs/latest-v26.x/api/stream.html#streamgetdefaulthighwatermarkobjectmode).
596
+ * @since v18.17.0, v20.1.0
597
+ */
598
+ highWaterMark?: number | undefined;
599
+ /**
600
+ * `blockList` can be used for disabling inbound
601
+ * access to specific IP addresses, IP ranges, or IP subnets. This does not
602
+ * work if the server is behind a reverse proxy, NAT, etc. because the address
603
+ * checked against the block list is the address of the proxy, or the one
604
+ * specified by the NAT.
605
+ * @since v22.13.0
606
+ */
607
+ blockList?: BlockList | undefined;
608
+ }
609
+ interface DropArgument {
610
+ localAddress?: string;
611
+ localPort?: number;
612
+ localFamily?: string;
613
+ remoteAddress?: string;
614
+ remotePort?: number;
615
+ remoteFamily?: string;
616
+ }
617
+ interface ServerEventMap {
618
+ "close": [];
619
+ "connection": [socket: Socket];
620
+ "error": [err: Error];
621
+ "listening": [];
622
+ "drop": [data?: DropArgument];
623
+ }
624
+ /**
625
+ * This class is used to create a TCP or `IPC` server.
626
+ * @since v0.1.90
627
+ */
628
+ class Server implements EventEmitter {
629
+ constructor(connectionListener?: (socket: Socket) => void);
630
+ constructor(options?: ServerOpts, connectionListener?: (socket: Socket) => void);
631
+ /**
632
+ * Start a server listening for connections. A `net.Server` can be a TCP or
633
+ * an `IPC` server depending on what it listens to.
634
+ *
635
+ * Possible signatures:
636
+ *
637
+ * * `server.listen(handle[, backlog][, callback])`
638
+ * * `server.listen(options[, callback])`
639
+ * * `server.listen(path[, backlog][, callback])` for `IPC` servers
640
+ * * `server.listen([port[, host[, backlog]]][, callback])` for TCP servers
641
+ *
642
+ * This function is asynchronous. When the server starts listening, the `'listening'` event will be emitted. The last parameter `callback`will be added as a listener for the `'listening'`
643
+ * event.
644
+ *
645
+ * All `listen()` methods can take a `backlog` parameter to specify the maximum
646
+ * length of the queue of pending connections. The actual length will be determined
647
+ * by the OS through sysctl settings such as `tcp_max_syn_backlog` and `somaxconn` on Linux. The default value of this parameter is 511 (not 512).
648
+ *
649
+ * All {@link Socket} are set to `SO_REUSEADDR` (see [`socket(7)`](https://man7.org/linux/man-pages/man7/socket.7.html) for
650
+ * details).
651
+ *
652
+ * The `server.listen()` method can be called again if and only if there was an
653
+ * error during the first `server.listen()` call or `server.close()` has been
654
+ * called. Otherwise, an `ERR_SERVER_ALREADY_LISTEN` error will be thrown.
655
+ *
656
+ * One of the most common errors raised when listening is `EADDRINUSE`.
657
+ * This happens when another server is already listening on the requested`port`/`path`/`handle`. One way to handle this would be to retry
658
+ * after a certain amount of time:
659
+ *
660
+ * ```js
661
+ * server.on('error', (e) => {
662
+ * if (e.code === 'EADDRINUSE') {
663
+ * console.error('Address in use, retrying...');
664
+ * setTimeout(() => {
665
+ * server.close();
666
+ * server.listen(PORT, HOST);
667
+ * }, 1000);
668
+ * }
669
+ * });
670
+ * ```
671
+ */
672
+ listen(port?: number, hostname?: string, backlog?: number, listeningListener?: () => void): this;
673
+ listen(port?: number, hostname?: string, listeningListener?: () => void): this;
674
+ listen(port?: number, backlog?: number, listeningListener?: () => void): this;
675
+ listen(port?: number, listeningListener?: () => void): this;
676
+ listen(path: string, backlog?: number, listeningListener?: () => void): this;
677
+ listen(path: string, listeningListener?: () => void): this;
678
+ listen(options: ListenOptions, listeningListener?: () => void): this;
679
+ listen(handle: any, backlog?: number, listeningListener?: () => void): this;
680
+ listen(handle: any, listeningListener?: () => void): this;
681
+ /**
682
+ * Stops the server from accepting new connections and keeps existing
683
+ * connections. This function is asynchronous, the server is finally closed
684
+ * when all connections are ended and the server emits a `'close'` event.
685
+ * The optional `callback` will be called once the `'close'` event occurs. Unlike
686
+ * that event, it will be called with an `Error` as its only argument if the server
687
+ * was not open when it was closed.
688
+ * @since v0.1.90
689
+ * @param callback Called when the server is closed.
690
+ */
691
+ close(callback?: (err?: Error) => void): this;
692
+ /**
693
+ * Returns the bound `address`, the address `family` name, and `port` of the server
694
+ * as reported by the operating system if listening on an IP socket
695
+ * (useful to find which port was assigned when getting an OS-assigned address):`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`.
696
+ *
697
+ * For a server listening on a pipe or Unix domain socket, the name is returned
698
+ * as a string.
699
+ *
700
+ * ```js
701
+ * const server = net.createServer((socket) => {
702
+ * socket.end('goodbye\n');
703
+ * }).on('error', (err) => {
704
+ * // Handle errors here.
705
+ * throw err;
706
+ * });
707
+ *
708
+ * // Grab an arbitrary unused port.
709
+ * server.listen(() => {
710
+ * console.log('opened server on', server.address());
711
+ * });
712
+ * ```
713
+ *
714
+ * `server.address()` returns `null` before the `'listening'` event has been
715
+ * emitted or after calling `server.close()`.
716
+ * @since v0.1.90
717
+ */
718
+ address(): AddressInfo | string | null;
719
+ /**
720
+ * Asynchronously get the number of concurrent connections on the server. Works
721
+ * when sockets were sent to forks.
722
+ *
723
+ * Callback should take two arguments `err` and `count`.
724
+ * @since v0.9.7
725
+ */
726
+ getConnections(cb: (error: Error | null, count: number) => void): this;
727
+ /**
728
+ * Opposite of `unref()`, calling `ref()` on a previously `unref`ed server will _not_ let the program exit if it's the only server left (the default behavior).
729
+ * If the server is `ref`ed calling `ref()` again will have no effect.
730
+ * @since v0.9.1
731
+ */
732
+ ref(): this;
733
+ /**
734
+ * Calling `unref()` on a server will allow the program to exit if this is the only
735
+ * active server in the event system. If the server is already `unref`ed calling`unref()` again will have no effect.
736
+ * @since v0.9.1
737
+ */
738
+ unref(): this;
739
+ /**
740
+ * Set this property to reject connections when the server's connection count gets
741
+ * high.
742
+ *
743
+ * It is not recommended to use this option once a socket has been sent to a child
744
+ * with `child_process.fork()`.
745
+ * @since v0.2.0
746
+ */
747
+ maxConnections: number;
748
+ connections: number;
749
+ /**
750
+ * Indicates whether or not the server is listening for connections.
751
+ * @since v5.7.0
752
+ */
753
+ readonly listening: boolean;
754
+ /**
755
+ * Calls {@link Server.close()} and returns a promise that fulfills when the server has closed.
756
+ * @since v20.5.0
757
+ */
758
+ [Symbol.asyncDispose](): Promise<void>;
759
+ }
760
+ interface Server extends InternalEventEmitter<ServerEventMap> {}
761
+ type IPVersion = "ipv4" | "ipv6";
762
+ /**
763
+ * The `BlockList` object can be used with some network APIs to specify rules for
764
+ * disabling inbound or outbound access to specific IP addresses, IP ranges, or
765
+ * IP subnets.
766
+ * @since v15.0.0, v14.18.0
767
+ */
768
+ class BlockList {
769
+ /**
770
+ * Adds a rule to block the given IP address.
771
+ * @since v15.0.0, v14.18.0
772
+ * @param address An IPv4 or IPv6 address.
773
+ * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
774
+ */
775
+ addAddress(address: string, type?: IPVersion): void;
776
+ addAddress(address: SocketAddress): void;
777
+ /**
778
+ * Adds a rule to block a range of IP addresses from `start` (inclusive) to`end` (inclusive).
779
+ * @since v15.0.0, v14.18.0
780
+ * @param start The starting IPv4 or IPv6 address in the range.
781
+ * @param end The ending IPv4 or IPv6 address in the range.
782
+ * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
783
+ */
784
+ addRange(start: string, end: string, type?: IPVersion): void;
785
+ addRange(start: SocketAddress, end: SocketAddress): void;
786
+ /**
787
+ * Adds a rule to block a range of IP addresses specified as a subnet mask.
788
+ * @since v15.0.0, v14.18.0
789
+ * @param net The network IPv4 or IPv6 address.
790
+ * @param prefix The number of CIDR prefix bits. For IPv4, this must be a value between `0` and `32`. For IPv6, this must be between `0` and `128`.
791
+ * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
792
+ */
793
+ addSubnet(net: SocketAddress, prefix: number): void;
794
+ addSubnet(net: string, prefix: number, type?: IPVersion): void;
795
+ /**
796
+ * Returns `true` if the given IP address matches any of the rules added to the`BlockList`.
797
+ *
798
+ * ```js
799
+ * const blockList = new net.BlockList();
800
+ * blockList.addAddress('123.123.123.123');
801
+ * blockList.addRange('10.0.0.1', '10.0.0.10');
802
+ * blockList.addSubnet('8592:757c:efae:4e45::', 64, 'ipv6');
803
+ *
804
+ * console.log(blockList.check('123.123.123.123')); // Prints: true
805
+ * console.log(blockList.check('10.0.0.3')); // Prints: true
806
+ * console.log(blockList.check('222.111.111.222')); // Prints: false
807
+ *
808
+ * // IPv6 notation for IPv4 addresses works:
809
+ * console.log(blockList.check('::ffff:7b7b:7b7b', 'ipv6')); // Prints: true
810
+ * console.log(blockList.check('::ffff:123.123.123.123', 'ipv6')); // Prints: true
811
+ * ```
812
+ * @since v15.0.0, v14.18.0
813
+ * @param address The IP address to check
814
+ * @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
815
+ */
816
+ check(address: SocketAddress): boolean;
817
+ check(address: string, type?: IPVersion): boolean;
818
+ /**
819
+ * The list of rules added to the blocklist.
820
+ * @since v15.0.0, v14.18.0
821
+ */
822
+ rules: readonly string[];
823
+ /**
824
+ * Returns `true` if the `value` is a `net.BlockList`.
825
+ * @since v22.13.0
826
+ * @param value Any JS value
827
+ */
828
+ static isBlockList(value: unknown): value is BlockList;
829
+ /**
830
+ * ```js
831
+ * const blockList = new net.BlockList();
832
+ * const data = [
833
+ * 'Subnet: IPv4 192.168.1.0/24',
834
+ * 'Address: IPv4 10.0.0.5',
835
+ * 'Range: IPv4 192.168.2.1-192.168.2.10',
836
+ * 'Range: IPv4 10.0.0.1-10.0.0.10',
837
+ * ];
838
+ * blockList.fromJSON(data);
839
+ * blockList.fromJSON(JSON.stringify(data));
840
+ * ```
841
+ * @since v24.5.0
842
+ * @experimental
843
+ */
844
+ fromJSON(data: string | readonly string[]): void;
845
+ /**
846
+ * @since v24.5.0
847
+ * @experimental
848
+ */
849
+ toJSON(): readonly string[];
850
+ }
851
+ interface TcpNetConnectOpts extends TcpSocketConnectOpts, SocketConstructorOpts {
852
+ timeout?: number | undefined;
853
+ }
854
+ interface IpcNetConnectOpts extends IpcSocketConnectOpts, SocketConstructorOpts {
855
+ timeout?: number | undefined;
856
+ }
857
+ type NetConnectOpts = TcpNetConnectOpts | IpcNetConnectOpts;
858
+ /**
859
+ * Creates a new TCP or `IPC` server.
860
+ *
861
+ * If `allowHalfOpen` is set to `true`, when the other end of the socket
862
+ * signals the end of transmission, the server will only send back the end of
863
+ * transmission when `socket.end()` is explicitly called. For example, in the
864
+ * context of TCP, when a FIN packed is received, a FIN packed is sent
865
+ * back only when `socket.end()` is explicitly called. Until then the
866
+ * connection is half-closed (non-readable but still writable). See `'end'` event and [RFC 1122](https://tools.ietf.org/html/rfc1122) (section 4.2.2.13) for more information.
867
+ *
868
+ * If `pauseOnConnect` is set to `true`, then the socket associated with each
869
+ * incoming connection will be paused, and no data will be read from its handle.
870
+ * This allows connections to be passed between processes without any data being
871
+ * read by the original process. To begin reading data from a paused socket, call `socket.resume()`.
872
+ *
873
+ * The server can be a TCP server or an `IPC` server, depending on what it `listen()` to.
874
+ *
875
+ * Here is an example of a TCP echo server which listens for connections
876
+ * on port 8124:
877
+ *
878
+ * ```js
879
+ * import net from 'node:net';
880
+ * const server = net.createServer((c) => {
881
+ * // 'connection' listener.
882
+ * console.log('client connected');
883
+ * c.on('end', () => {
884
+ * console.log('client disconnected');
885
+ * });
886
+ * c.write('hello\r\n');
887
+ * c.pipe(c);
888
+ * });
889
+ * server.on('error', (err) => {
890
+ * throw err;
891
+ * });
892
+ * server.listen(8124, () => {
893
+ * console.log('server bound');
894
+ * });
895
+ * ```
896
+ *
897
+ * Test this by using `telnet`:
898
+ *
899
+ * ```bash
900
+ * telnet localhost 8124
901
+ * ```
902
+ *
903
+ * To listen on the socket `/tmp/echo.sock`:
904
+ *
905
+ * ```js
906
+ * server.listen('/tmp/echo.sock', () => {
907
+ * console.log('server bound');
908
+ * });
909
+ * ```
910
+ *
911
+ * Use `nc` to connect to a Unix domain socket server:
912
+ *
913
+ * ```bash
914
+ * nc -U /tmp/echo.sock
915
+ * ```
916
+ * @since v0.5.0
917
+ * @param connectionListener Automatically set as a listener for the {@link 'connection'} event.
918
+ */
919
+ function createServer(connectionListener?: (socket: Socket) => void): Server;
920
+ function createServer(options?: ServerOpts, connectionListener?: (socket: Socket) => void): Server;
921
+ /**
922
+ * Aliases to {@link createConnection}.
923
+ *
924
+ * Possible signatures:
925
+ *
926
+ * * {@link connect}
927
+ * * {@link connect} for `IPC` connections.
928
+ * * {@link connect} for TCP connections.
929
+ */
930
+ function connect(options: NetConnectOpts, connectionListener?: () => void): Socket;
931
+ function connect(port: number, host?: string, connectionListener?: () => void): Socket;
932
+ function connect(path: string, connectionListener?: () => void): Socket;
933
+ /**
934
+ * A factory function, which creates a new {@link Socket},
935
+ * immediately initiates connection with `socket.connect()`,
936
+ * then returns the `net.Socket` that starts the connection.
937
+ *
938
+ * When the connection is established, a `'connect'` event will be emitted
939
+ * on the returned socket. The last parameter `connectListener`, if supplied,
940
+ * will be added as a listener for the `'connect'` event **once**.
941
+ *
942
+ * Possible signatures:
943
+ *
944
+ * * {@link createConnection}
945
+ * * {@link createConnection} for `IPC` connections.
946
+ * * {@link createConnection} for TCP connections.
947
+ *
948
+ * The {@link connect} function is an alias to this function.
949
+ */
950
+ function createConnection(options: NetConnectOpts, connectionListener?: () => void): Socket;
951
+ function createConnection(port: number, host?: string, connectionListener?: () => void): Socket;
952
+ function createConnection(path: string, connectionListener?: () => void): Socket;
953
+ /**
954
+ * Gets the current default value of the `autoSelectFamily` option of `socket.connect(options)`.
955
+ * The initial default value is `true`, unless the command line option`--no-network-family-autoselection` is provided.
956
+ * @since v19.4.0
957
+ */
958
+ function getDefaultAutoSelectFamily(): boolean;
959
+ /**
960
+ * Sets the default value of the `autoSelectFamily` option of `socket.connect(options)`.
961
+ * @param value The new default value.
962
+ * The initial default value is `true`, unless the command line option
963
+ * `--no-network-family-autoselection` is provided.
964
+ * @since v19.4.0
965
+ */
966
+ function setDefaultAutoSelectFamily(value: boolean): void;
967
+ /**
968
+ * Gets the current default value of the `autoSelectFamilyAttemptTimeout` option of `socket.connect(options)`.
969
+ * The initial default value is `500` or the value specified via the command line option `--network-family-autoselection-attempt-timeout`.
970
+ * @returns The current default value of the `autoSelectFamilyAttemptTimeout` option.
971
+ * @since v19.8.0, v18.8.0
972
+ */
973
+ function getDefaultAutoSelectFamilyAttemptTimeout(): number;
974
+ /**
975
+ * Sets the default value of the `autoSelectFamilyAttemptTimeout` option of `socket.connect(options)`.
976
+ * @param value The new default value, which must be a positive number. If the number is less than `10`, the value `10` is used instead. The initial default value is `250` or the value specified via the command line
977
+ * option `--network-family-autoselection-attempt-timeout`.
978
+ * @since v19.8.0, v18.8.0
979
+ */
980
+ function setDefaultAutoSelectFamilyAttemptTimeout(value: number): void;
981
+ /**
982
+ * Returns `6` if `input` is an IPv6 address. Returns `4` if `input` is an IPv4
983
+ * address in [dot-decimal notation](https://en.wikipedia.org/wiki/Dot-decimal_notation) with no leading zeroes. Otherwise, returns`0`.
984
+ *
985
+ * ```js
986
+ * net.isIP('::1'); // returns 6
987
+ * net.isIP('127.0.0.1'); // returns 4
988
+ * net.isIP('127.000.000.001'); // returns 0
989
+ * net.isIP('127.0.0.1/24'); // returns 0
990
+ * net.isIP('fhqwhgads'); // returns 0
991
+ * ```
992
+ * @since v0.3.0
993
+ */
994
+ function isIP(input: string): number;
995
+ /**
996
+ * Returns `true` if `input` is an IPv4 address in [dot-decimal notation](https://en.wikipedia.org/wiki/Dot-decimal_notation) with no
997
+ * leading zeroes. Otherwise, returns `false`.
998
+ *
999
+ * ```js
1000
+ * net.isIPv4('127.0.0.1'); // returns true
1001
+ * net.isIPv4('127.000.000.001'); // returns false
1002
+ * net.isIPv4('127.0.0.1/24'); // returns false
1003
+ * net.isIPv4('fhqwhgads'); // returns false
1004
+ * ```
1005
+ * @since v0.3.0
1006
+ */
1007
+ function isIPv4(input: string): boolean;
1008
+ /**
1009
+ * Returns `true` if `input` is an IPv6 address. Otherwise, returns `false`.
1010
+ *
1011
+ * ```js
1012
+ * net.isIPv6('::1'); // returns true
1013
+ * net.isIPv6('fhqwhgads'); // returns false
1014
+ * ```
1015
+ * @since v0.3.0
1016
+ */
1017
+ function isIPv6(input: string): boolean;
1018
+ interface SocketAddressInitOptions {
1019
+ /**
1020
+ * The network address as either an IPv4 or IPv6 string.
1021
+ * @default 127.0.0.1
1022
+ */
1023
+ address?: string | undefined;
1024
+ /**
1025
+ * @default `'ipv4'`
1026
+ */
1027
+ family?: IPVersion | undefined;
1028
+ /**
1029
+ * An IPv6 flow-label used only if `family` is `'ipv6'`.
1030
+ * @default 0
1031
+ */
1032
+ flowlabel?: number | undefined;
1033
+ /**
1034
+ * An IP port.
1035
+ * @default 0
1036
+ */
1037
+ port?: number | undefined;
1038
+ }
1039
+ /**
1040
+ * @since v15.14.0, v14.18.0
1041
+ */
1042
+ class SocketAddress {
1043
+ constructor(options: SocketAddressInitOptions);
1044
+ /**
1045
+ * Either \`'ipv4'\` or \`'ipv6'\`.
1046
+ * @since v15.14.0, v14.18.0
1047
+ */
1048
+ readonly address: string;
1049
+ /**
1050
+ * Either \`'ipv4'\` or \`'ipv6'\`.
1051
+ * @since v15.14.0, v14.18.0
1052
+ */
1053
+ readonly family: IPVersion;
1054
+ /**
1055
+ * @since v15.14.0, v14.18.0
1056
+ */
1057
+ readonly port: number;
1058
+ /**
1059
+ * @since v15.14.0, v14.18.0
1060
+ */
1061
+ readonly flowlabel: number;
1062
+ /**
1063
+ * @since v22.13.0
1064
+ * @param input An input string containing an IP address and optional port,
1065
+ * e.g. `123.1.2.3:1234` or `[1::1]:1234`.
1066
+ * @returns Returns a `SocketAddress` if parsing was successful.
1067
+ * Otherwise returns `undefined`.
1068
+ */
1069
+ static parse(input: string): SocketAddress | undefined;
1070
+ }
1071
+ }
1072
+ declare module "net" {
1073
+ export * from "node:net";
1074
+ }