@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,2191 @@
1
+ declare module "node:quic" {
2
+ import { NonSharedBuffer } from "node:buffer";
3
+ import { KeyObject, X509Certificate } from "node:crypto";
4
+ import { FileHandle } from "node:fs/promises";
5
+ import { BlockList, SocketAddress } from "node:net";
6
+ import { Writer } from "node:stream/iter";
7
+ import { CertificateCompressionAlgorithm, EphemeralKeyInfo } from "node:tls";
8
+ /**
9
+ * @since v23.8.0
10
+ */
11
+ type OnSessionCallback = (this: QuicEndpoint, session: QuicSession) => void;
12
+ /**
13
+ * @since v23.8.0
14
+ */
15
+ type OnStreamCallback = (this: QuicSession, stream: QuicStream) => void;
16
+ /**
17
+ * @since v23.8.0
18
+ */
19
+ type OnDatagramCallback = (this: QuicSession, datagram: NodeJS.NonSharedUint8Array, early: boolean) => void;
20
+ /**
21
+ * @since v23.8.0
22
+ */
23
+ type OnDatagramStatusCallback = (
24
+ this: QuicSession,
25
+ id: bigint,
26
+ status: "acknowledged" | "lost" | "abandoned",
27
+ ) => void;
28
+ /**
29
+ * @since v23.8.0
30
+ */
31
+ type OnApplicationCallback = (this: QuicSession, applicationoptions: SessionApplicationOptions) => void;
32
+ /**
33
+ * @since v23.8.0
34
+ */
35
+ type OnPathValidationCallback = (
36
+ this: QuicSession,
37
+ result: "success" | "failure" | "aborted",
38
+ newLocalAddress: SocketAddress,
39
+ newRemoteAddress: SocketAddress,
40
+ oldLocalAddress: SocketAddress | null,
41
+ oldRemoteAddress: SocketAddress | null,
42
+ preferredAddress: boolean,
43
+ ) => void;
44
+ /**
45
+ * @since v23.8.0
46
+ */
47
+ type OnSessionTicketCallback = (this: QuicSession, ticket: object) => void;
48
+ /**
49
+ * @since v23.8.0
50
+ */
51
+ type OnVersionNegotiationCallback = (
52
+ this: QuicSession,
53
+ version: number,
54
+ requestedVersions: number[],
55
+ supportedVersions: number[],
56
+ ) => void;
57
+ /**
58
+ * @since v23.8.0
59
+ */
60
+ type OnHandshakeCallback = (this: QuicSession, info: SessionHandshakeInfo) => void;
61
+ /**
62
+ * @since v26.2.0
63
+ */
64
+ type OnNewTokenCallback = (this: QuicSession, token: NonSharedBuffer, address: SocketAddress) => void;
65
+ /**
66
+ * @since v26.2.0
67
+ */
68
+ type OnOriginCallback = (this: QuicSession, origins: string[]) => void;
69
+ /**
70
+ * Called when TLS key material is available. Only fires when
71
+ * `sessionOptions.keylog` is `true`. Multiple lines are emitted during the
72
+ * TLS 1.3 handshake, each containing a secret label, the client random, and
73
+ * the secret value.
74
+ * @since v26.2.0
75
+ */
76
+ type OnKeylogCallback = (this: QuicSession, line: string) => void;
77
+ /**
78
+ * Called when qlog diagnostic data is available. Only fires when
79
+ * `sessionOptions.qlog` is `true`. The `data` chunks should be
80
+ * concatenated in order to produce the complete qlog output. When `fin` is
81
+ * `true`, no more chunks will be emitted and the concatenated result is a
82
+ * complete JSON-SEQ document.
83
+ * @since v26.2.0
84
+ */
85
+ type OnQlogCallback = (this: QuicSession, data: string, fin: boolean) => void;
86
+ /**
87
+ * @since v23.8.0
88
+ */
89
+ type OnBlockedCallback = (this: QuicStream) => void;
90
+ /**
91
+ * @since v23.8.0
92
+ */
93
+ type OnStreamErrorCallback = (this: QuicStream, error: any) => void;
94
+ /**
95
+ * Called when initial request or response headers are received. For HTTP/3,
96
+ * this delivers request pseudo-headers on the server and response headers
97
+ * on the client.
98
+ * @since v26.2.0
99
+ */
100
+ type OnHeadersCallback = (this: QuicStream, headers: NodeJS.Dict<string | string[]>) => void;
101
+ /**
102
+ * Called when trailing headers are received from the peer.
103
+ * @since v26.2.0
104
+ */
105
+ type OnTrailersCallback = (this: QuicStream, trailers: NodeJS.Dict<string | string[]>) => void;
106
+ /**
107
+ * Called when informational (1xx) headers are received from the server
108
+ * (e.g., 103 Early Hints).
109
+ * @since v26.2.0
110
+ */
111
+ type OnInfoCallback = (this: QuicStream, headers: NodeJS.Dict<string | string[]>) => void;
112
+ /**
113
+ * @since v23.8.0
114
+ */
115
+ interface TransportParams {
116
+ /**
117
+ * The preferred IPv4 address to advertise (only used by servers).
118
+ * @since v23.8.0
119
+ */
120
+ preferredAddressIpv4?: SocketAddress | undefined;
121
+ /**
122
+ * The preferred IPv6 address to advertise (only used by servers)
123
+ * @since v23.8.0
124
+ */
125
+ preferredAddressIpv6?: SocketAddress | undefined;
126
+ /**
127
+ * @since v23.8.0
128
+ */
129
+ initialMaxStreamDataBidiLocal?: bigint | number | undefined;
130
+ /**
131
+ * @since v23.8.0
132
+ */
133
+ initialMaxStreamDataBidiRemote?: bigint | number | undefined;
134
+ /**
135
+ * @since v23.8.0
136
+ */
137
+ initialMaxStreamDataUni?: bigint | number | undefined;
138
+ /**
139
+ * @since v23.8.0
140
+ */
141
+ initialMaxData?: bigint | number | undefined;
142
+ /**
143
+ * @since v23.8.0
144
+ */
145
+ initialMaxStreamsBidi?: bigint | number | undefined;
146
+ /**
147
+ * @since v23.8.0
148
+ */
149
+ initialMaxStreamsUni?: bigint | number | undefined;
150
+ /**
151
+ * @since v23.8.0
152
+ */
153
+ maxIdleTimeout?: bigint | number | undefined;
154
+ /**
155
+ * @since v23.8.0
156
+ */
157
+ activeConnectionIDLimit?: bigint | number | undefined;
158
+ /**
159
+ * @since v23.8.0
160
+ */
161
+ ackDelayExponent?: bigint | number | undefined;
162
+ /**
163
+ * @since v23.8.0
164
+ */
165
+ maxAckDelay?: bigint | number | undefined;
166
+ /**
167
+ * The maximum size in bytes of a DATAGRAM frame payload that this endpoint
168
+ * is willing to receive. Set to `0` to disable datagram support. The peer
169
+ * will not send datagrams larger than this value. The actual maximum size of
170
+ * a datagram that can be _sent_ is determined by the peer's
171
+ * `maxDatagramFrameSize`, not this endpoint's value.
172
+ * @since v23.8.0
173
+ */
174
+ maxDatagramFrameSize?: bigint | number | undefined;
175
+ }
176
+ interface SNIEntry {
177
+ /**
178
+ * The TLS private keys. **Required.**
179
+ */
180
+ keys: KeyObject | readonly KeyObject[];
181
+ /**
182
+ * The TLS certificates. **Required.**
183
+ */
184
+ certs: ArrayBuffer | NodeJS.ArrayBufferView | ReadonlyArray<ArrayBuffer | NodeJS.ArrayBufferView>;
185
+ /**
186
+ * Verify the private key. Default: `false`.
187
+ */
188
+ verifyPrivateKey?: boolean | undefined;
189
+ /**
190
+ * The port to advertise in ORIGIN frames (RFC 9412) for this host name. **Default:** `443`. Only used for HTTP/3 sessions.
191
+ */
192
+ port?: number | undefined;
193
+ /**
194
+ * Whether to include this host name in ORIGIN frames. **Default:** `true`. Set to `false` to exclude a host name
195
+ * from ORIGIN advertisements. Wildcard (`'*'`) entries are always excluded regardless of this setting.
196
+ */
197
+ authoritative?: boolean | undefined;
198
+ }
199
+ /**
200
+ * @since v26.3.0
201
+ */
202
+ interface ApplicationOptions {
203
+ /**
204
+ * Maximum number of header name-value pairs accepted per header block.
205
+ * Headers beyond this limit are silently dropped. **Default:** `128`
206
+ */
207
+ maxHeaderPairs?: bigint | number | undefined;
208
+ /**
209
+ * Maximum total byte length of all header names and values combined per header
210
+ * block. Headers that would push the total over this limit are silently
211
+ * dropped. **Default:** `8192`
212
+ */
213
+ maxHeaderLength?: bigint | number | undefined;
214
+ /**
215
+ * Maximum size of a compressed header field section (QPACK). `0` means
216
+ * unlimited. **Default:** `0`
217
+ */
218
+ maxFieldSectionSize?: bigint | number | undefined;
219
+ /**
220
+ * QPACK dynamic table capacity in bytes. Set to `0` to disable the dynamic
221
+ * table. **Default:** `4096`
222
+ */
223
+ qpackMaxDTableCapacity?: bigint | number | undefined;
224
+ /**
225
+ * QPACK encoder maximum dynamic table capacity. **Default:** `4096`
226
+ */
227
+ qpackEncoderMaxDTableCapacity?: bigint | number | undefined;
228
+ /**
229
+ * Maximum number of streams that can e blocked waiting for QPACK dynamic table
230
+ * updates. **Default:** `100`
231
+ */
232
+ qpackBlockedStreams?: bigint | number | undefined;
233
+ /**
234
+ * Enable the extended CONNECT protocol (RFC 9220). **Default:** `false`
235
+ */
236
+ enableConnectProtocol?: boolean | undefined;
237
+ /**
238
+ * Enable HTTP/3 datagrams (RFC 9297). **Default:** `false`
239
+ */
240
+ enableDatagrams?: boolean | undefined;
241
+ }
242
+ type SessionApplicationOptions = { [K in keyof ApplicationOptions]-?: ApplicationOptions[K] & (bigint | boolean) };
243
+ /**
244
+ * @since v23.8.0
245
+ */
246
+ interface SessionOptions {
247
+ /**
248
+ * An endpoint to use.
249
+ * @since v23.8.0
250
+ */
251
+ endpoint?: EndpointOptions | QuicEndpoint | undefined;
252
+ /**
253
+ * The ALPN (Application-Layer Protocol Negotiation) identifier(s).
254
+ *
255
+ * For **client** sessions, this is a single string specifying the protocol
256
+ * the client wants to use (e.g. `'h3'`).
257
+ *
258
+ * For **server** sessions, this is an array of protocol names in preference
259
+ * order that the server supports (e.g. `['h3', 'h3-29']`). During the TLS
260
+ * handshake, the server selects the first protocol from its list that the
261
+ * client also supports.
262
+ *
263
+ * The negotiated ALPN determines which Application implementation is used
264
+ * for the session. `'h3'` and `'h3-*'` variants select the HTTP/3
265
+ * application; all other values select the default application.
266
+ * @since v26.1.0
267
+ */
268
+ alpn?: string | readonly string[] | undefined;
269
+ /**
270
+ * Application-specific options.
271
+ * @since v26.2.0
272
+ */
273
+ application?: ApplicationOptions | undefined;
274
+ /**
275
+ * The CA certificates to use for client sessions. For server sessions, CA
276
+ * certificates are specified per-identity in the `sessionOptions.sni` map.
277
+ * @since v23.8.0
278
+ */
279
+ ca?: ArrayBuffer | NodeJS.ArrayBufferView | ReadonlyArray<ArrayBuffer | NodeJS.ArrayBufferView> | undefined;
280
+ /**
281
+ * Enables TLS certificate compression ([RFC 8879](https://www.rfc-editor.org/rfc/rfc8879)) for this session. When
282
+ * omitted, certificate compression is disabled.
283
+ *
284
+ * On the server side, the certificate chain is compressed using the first
285
+ * listed algorithm that the client advertises support for. On the client side,
286
+ * the listed algorithms are advertised to the server so that the server may
287
+ * compress its certificate. When client authentication is in use, the option
288
+ * also controls compression of the client's certificate.
289
+ *
290
+ * Compressing the certificate chain is especially useful for QUIC because it
291
+ * reduces the size of the server's first flight, which is bounded by the
292
+ * anti-amplification limit (see [Certificate size and handshake
293
+ * performance](https://nodejs.org/docs/latest-v26.x/api/quic.html#certificate-size-and-handshake-performance)). Certificate compression requires TLS 1.3, which QUIC always
294
+ * uses.
295
+ *
296
+ * At most three algorithms may be specified. The option is silently ignored if
297
+ * Node.js was built against a shared OpenSSL that lacks certificate compression
298
+ * support.
299
+ * @since v26.6.0
300
+ */
301
+ certificateCompression?: readonly CertificateCompressionAlgorithm[] | undefined;
302
+ /**
303
+ * Specifies the congestion control algorithm that will be used.
304
+ * Must be set to one of either `'reno'`, `'cubic'`, or `'bbr'`.
305
+ *
306
+ * This is an advanced option that users typically won't have need to specify.
307
+ * @since v23.8.0
308
+ */
309
+ cc?: `${constants.cc}` | undefined;
310
+ /**
311
+ * The TLS certificates to use for client sessions. For server sessions,
312
+ * certificates are specified per-identity in the `sessionOptions.sni` map.
313
+ * @since v23.8.0
314
+ */
315
+ certs?: ArrayBuffer | NodeJS.ArrayBufferView | ReadonlyArray<ArrayBuffer | NodeJS.ArrayBufferView> | undefined;
316
+ /**
317
+ * The list of supported TLS 1.3 cipher algorithms.
318
+ * @since v23.8.0
319
+ */
320
+ ciphers?: string | undefined;
321
+ /**
322
+ * The CRL to use for client sessions. For server sessions, CRLs are specified
323
+ * per-identity in the `sessionOptions.sni` map.
324
+ * @since v23.8.0
325
+ */
326
+ crl?: ArrayBuffer | NodeJS.ArrayBufferView | ReadonlyArray<ArrayBuffer | NodeJS.ArrayBufferView> | undefined;
327
+ /**
328
+ * When `true`, enables TLS 0-RTT early data for this session. Early data
329
+ * allows the client to send application data before the TLS handshake
330
+ * completes, reducing latency on reconnection when a valid session ticket
331
+ * is available. Set to `false` to disable early data support.
332
+ * @since v26.2.0
333
+ */
334
+ enableEarlyData?: boolean | undefined;
335
+ /**
336
+ * The list of supported TLS 1.3 cipher groups.
337
+ * @since v23.8.0
338
+ */
339
+ groups?: string | undefined;
340
+ /**
341
+ * When `true`, enables TLS key logging for the session. Key material is
342
+ * delivered to the `session.onkeylog` callback in [NSS Key Log Format](https://udn.realityripple.com/docs/Mozilla/Projects/NSS/Key_Log_Format).
343
+ * Each callback invocation receives a single line of key material. The output
344
+ * can be used with tools such as Wireshark to decrypt captured QUIC traffic.
345
+ * @since v23.8.0
346
+ */
347
+ keylog?: boolean | undefined;
348
+ /**
349
+ * The TLS crypto keys to use for client sessions. For server sessions,
350
+ * keys are specified per-identity in the `sessionOptions.sni` map.
351
+ * @since v23.8.0
352
+ */
353
+ keys?: KeyObject | readonly KeyObject[] | undefined;
354
+ /**
355
+ * Specifies the maximum UDP packet payload size.
356
+ * @since v23.8.0
357
+ */
358
+ maxPayloadSize?: bigint | number | undefined;
359
+ /**
360
+ * Specifies the maximum stream flow-control window size.
361
+ * @since v23.8.0
362
+ */
363
+ maxStreamWindow?: bigint | number | undefined;
364
+ /**
365
+ * Specifies the maximum session flow-control window size.
366
+ * @since v23.8.0
367
+ */
368
+ maxWindow?: bigint | number | undefined;
369
+ /**
370
+ * The minimum QUIC version number to allow. This is an advanced option that users
371
+ * typically won't have need to specify.
372
+ * @since v23.8.0
373
+ */
374
+ minVersion?: number | undefined;
375
+ /**
376
+ * When the remote peer advertises a preferred address, this option specifies whether
377
+ * to use it or ignore it. The default is `'ignore'` because honoring a server's
378
+ * preferred address causes the client to migrate its connection to a different IP
379
+ * address, which can be exploited for data exfiltration attacks that are
380
+ * indistinguishable from legitimate QUIC connection migration at the network level.
381
+ * Set to `'use'` only when connecting to trusted servers that require preferred
382
+ * address migration.
383
+ * @since v23.8.0
384
+ */
385
+ preferredAddressPolicy?: "use" | "ignore" | "default" | undefined;
386
+ /**
387
+ * When `true`, enables [qlog](https://datatracker.ietf.org/doc/draft-ietf-quic-qlog-main-schema/) diagnostic output for the session. Qlog data
388
+ * is delivered to the `session.onqlog` callback as chunks of [JSON-SEQ](https://www.rfc-editor.org/rfc/rfc7464)
389
+ * formatted text. The output can be analyzed with qlog visualization tools
390
+ * such as [qvis](https://qvis.quictools.info/).
391
+ * @since v23.8.0
392
+ */
393
+ qlog?: boolean | undefined;
394
+ /**
395
+ * A session ticket to use for 0RTT session resumption.
396
+ * @since v23.8.0
397
+ */
398
+ sessionTicket?: NodeJS.ArrayBufferView | undefined;
399
+ /**
400
+ * Controls which datagram to drop when the pending datagram queue
401
+ * (sized by `session.maxPendingDatagrams`) is full. Must be one of
402
+ * `'drop-oldest'` (discard the oldest queued datagram to make room) or
403
+ * `'drop-newest'` (reject the incoming datagram). Dropped datagrams are
404
+ * reported as lost via the `ondatagramstatus` callback.
405
+ *
406
+ * This option is immutable after session creation.
407
+ * @since v26.2.0
408
+ */
409
+ datagramDropPolicy?: "drop-oldest" | "drop-newest" | undefined;
410
+ /**
411
+ * The maximum time in milliseconds that a peer-initiated stream can be idle
412
+ * (no data received) before it is automatically destroyed. This protects
413
+ * against slowloris-style attacks where a remote peer opens streams but never
414
+ * sends data, holding server resources indefinitely. Only peer-initiated
415
+ * streams are checked — locally-initiated streams are the application's
416
+ * responsibility. Set to `0` to disable.
417
+ *
418
+ * The idle check runs as part of the normal send processing loop, so it adds
419
+ * no additional timers or event loop overhead. The
420
+ * `session.stats.streamsIdleTimedOut` counter tracks how many streams have been
421
+ * destroyed by this mechanism.
422
+ * @since v26.3.0
423
+ */
424
+ streamIdleTimeout?: bigint | number | undefined;
425
+ /**
426
+ * The maximum number of `SendPendingData` cycles a datagram can survive
427
+ * without being sent before it is abandoned. When a datagram cannot be
428
+ * sent due to congestion control or packet size constraints, it remains
429
+ * in the queue and the attempt counter increments. Once the limit is
430
+ * reached, the datagram is dropped and reported as `'abandoned'` via the
431
+ * `ondatagramstatus` callback. Valid range: `1` to `255`.
432
+ * @since v26.2.0
433
+ */
434
+ maxDatagramSendAttempts?: number | undefined;
435
+ /**
436
+ * A multiplier applied to the Probe Timeout (PTO) to compute the draining
437
+ * period duration after receiving a `CONNECTION_CLOSE` frame from the peer.
438
+ * RFC 9000 Section 10.2 requires the draining period to persist for at least
439
+ * three times the current PTO. The valid range is `3` to `255`. Values below
440
+ * `3` are clamped to `3`.
441
+ * @since v26.2.0
442
+ */
443
+ drainingPeriodMultiplier?: number | undefined;
444
+ /**
445
+ * Specifies the keep-alive timeout in milliseconds. When set to a non-zero
446
+ * value, PING frames will be sent automatically to keep the connection alive
447
+ * before the idle timeout fires. The value should be less than the effective
448
+ * idle timeout (`maxIdleTimeout` transport parameter) to be useful.
449
+ * @since v23.8.0
450
+ */
451
+ handshakeTimeout?: bigint | number | undefined;
452
+ /**
453
+ * Controls how the client handles server certificate validation:
454
+ *
455
+ * * `'strict'` — OpenSSL aborts the TLS handshake immediately if the server's
456
+ * certificate fails validation. The `session.opened` promise rejects with a
457
+ * TLS error. The application cannot inspect the certificate or the error
458
+ * details. This is the most secure mode.
459
+ *
460
+ * * `'auto'` — The TLS handshake completes regardless of validation result.
461
+ * If validation fails, the `session.opened` promise is rejected with an error
462
+ * containing the validation reason, and the session is destroyed. The
463
+ * `onhandshake` callback (if set) fires before rejection, allowing diagnostic
464
+ * logging. This is the default and matches the behavior of `tls.connect()`
465
+ * with `rejectUnauthorized: true`.
466
+ *
467
+ * * `'manual'` — The TLS handshake completes regardless of validation result.
468
+ * The `session.opened` promise resolves with the handshake info, which includes
469
+ * `validationErrorReason` and `validationErrorCode` if validation failed. The
470
+ * application is responsible for checking these values and deciding whether to
471
+ * continue. Use this mode for custom validation logic, certificate pinning, or
472
+ * intentionally accepting self-signed certificates.
473
+ * @since v26.3.0
474
+ */
475
+ verifyPeer?: "strict" | "auto" | "manual" | undefined;
476
+ /**
477
+ * The peer server name to target (SNI). Defaults to `'localhost'`.
478
+ * @since v26.1.0
479
+ */
480
+ servername?: string | undefined;
481
+ /**
482
+ * An object mapping host names to TLS identity options for Server Name
483
+ * Indication (SNI) support. This is required for server sessions and must
484
+ * contain at least one entry. The special key `'*'` specifies the optional
485
+ * default/fallback identity used when no other host name matches. If no
486
+ * wildcard entry is provided, connections with unrecognized server names
487
+ * will be rejected with a TLS `unrecognized_name` alert. Each entry may
488
+ * contain:
489
+ * @since v26.1.0
490
+ */
491
+ sni?: Record<string, SNIEntry> | undefined;
492
+ /**
493
+ * True to enable TLS tracing output.
494
+ * @since v23.8.0
495
+ */
496
+ tlsTrace?: boolean | undefined;
497
+ /**
498
+ * An opaque address validation token previously received from the server
499
+ * via the `session.onnewtoken` callback. Providing a valid token on
500
+ * reconnection allows the client to skip the server's address validation,
501
+ * reducing handshake latency.
502
+ * @since v26.2.0
503
+ */
504
+ token?: NodeJS.ArrayBufferView | undefined;
505
+ /**
506
+ * The QUIC transport parameters to use for the session.
507
+ * @since v23.8.0
508
+ */
509
+ transportParams?: TransportParams | undefined;
510
+ /**
511
+ * Specifies the maximum number of unacknowledged packets a session should allow.
512
+ * @since v23.8.0
513
+ */
514
+ unacknowledgedPacketThreshold?: bigint | number | undefined;
515
+ /**
516
+ * If `true`, the peer certificate is verified against the list of supplied CAs.
517
+ * An error is emitted if verification fails; the error can be inspected via
518
+ * the `validationErrorReason` and `validationErrorCode` fields in the
519
+ * handshake callback. If `false`, peer certificate verification errors are
520
+ * ignored.
521
+ */
522
+ rejectUnauthorized?: boolean | undefined;
523
+ /**
524
+ * When `true` (the default), `connect()` will attempt to reuse an existing
525
+ * endpoint rather than creating a new one for each session. This provides
526
+ * connection pooling behavior — multiple sessions can share a single UDP
527
+ * socket. The reuse logic will not return an endpoint that is listening on
528
+ * the same address as the connect target (to prevent CID routing conflicts).
529
+ *
530
+ * Set to `false` to force creation of a new endpoint for the session. This
531
+ * is useful when endpoint isolation is required (e.g., testing stateless
532
+ * reset behavior where source port identity matters).
533
+ * @since v26.2.0
534
+ */
535
+ reuseEndpoint?: boolean | undefined;
536
+ /**
537
+ * True to require verification of TLS client certificate.
538
+ * @since v23.8.0
539
+ */
540
+ verifyClient?: boolean | undefined;
541
+ /**
542
+ * True to require private key verification for client sessions. For server
543
+ * sessions, this option is specified per-identity in the
544
+ * `sessionOptions.sni` map.
545
+ * @since v23.8.0
546
+ */
547
+ verifyPrivateKey?: boolean | undefined;
548
+ /**
549
+ * The QUIC version number to use. This is an advanced option that users typically
550
+ * won't have need to specify.
551
+ * @since v23.8.0
552
+ */
553
+ version?: number | undefined;
554
+ // Undocumented
555
+ onerror?: QuicSession["onerror"] | undefined;
556
+ onstream?: QuicSession["onstream"] | undefined;
557
+ ondatagram?: QuicSession["ondatagram"] | undefined;
558
+ ondatagramstatus?: QuicSession["ondatagramstatus"] | undefined;
559
+ onpathvalidation?: QuicSession["onpathvalidation"] | undefined;
560
+ onsessionticket?: QuicSession["onsessionticket"] | undefined;
561
+ onversionnegotiation?: QuicSession["onversionnegotiation"] | undefined;
562
+ onhandshake?: QuicSession["onhandshake"] | undefined;
563
+ onnewtoken?: QuicSession["onnewtoken"] | undefined;
564
+ onearlyrejected?: QuicSession["onearlyrejected"] | undefined;
565
+ onorigin?: QuicSession["onorigin"] | undefined;
566
+ ongoaway?: QuicSession["ongoaway"] | undefined;
567
+ onkeylog?: QuicSession["onkeylog"] | undefined;
568
+ onqlog?: QuicSession["onqlog"] | undefined;
569
+ onapplication?: QuicSession["onapplication"] | undefined;
570
+ onheaders?: QuicStream["onheaders"] | undefined;
571
+ ontrailers?: QuicStream["ontrailers"] | undefined;
572
+ oninfo?: QuicStream["oninfo"] | undefined;
573
+ onwanttrailers?: QuicStream["onwanttrailers"] | undefined;
574
+ }
575
+ /**
576
+ * Initiate a new client-side session.
577
+ *
578
+ * ```js
579
+ * import { connect } from 'node:quic';
580
+ * import { Buffer } from 'node:buffer';
581
+ *
582
+ * const enc = new TextEncoder();
583
+ * const alpn = 'foo';
584
+ * const client = await connect('123.123.123.123:8888', { alpn });
585
+ * await client.createUnidirectionalStream({
586
+ * body: enc.encode('hello world'),
587
+ * });
588
+ * ```
589
+ *
590
+ * By default, every call to `connect(...)` will create a new local
591
+ * `QuicEndpoint` instance bound to a new random local IP port. To
592
+ * specify the exact local address to use, or to multiplex multiple
593
+ * QUIC sessions over a single local port, pass the `endpoint` option
594
+ * with either a `QuicEndpoint` or `EndpointOptions` as the argument.
595
+ *
596
+ * ```js
597
+ * import { QuicEndpoint, connect } from 'node:quic';
598
+ *
599
+ * const endpoint = new QuicEndpoint({
600
+ * address: '127.0.0.1:1234',
601
+ * });
602
+ *
603
+ * const client = await connect('123.123.123.123:8888', { endpoint });
604
+ * ```
605
+ * @since v23.8.0
606
+ */
607
+ function connect(address: string | SocketAddress, options?: SessionOptions): Promise<QuicSession>;
608
+ /**
609
+ * Configures the endpoint to listen as a server. When a new session is initiated by
610
+ * a remote peer, the given `onsession` callback will be invoked with the created
611
+ * session.
612
+ *
613
+ * ```js
614
+ * import { listen } from 'node:quic';
615
+ *
616
+ * const endpoint = await listen((session) => {
617
+ * // ... handle the session
618
+ * });
619
+ *
620
+ * // Closing the endpoint allows any sessions open when close is called
621
+ * // to complete naturally while preventing new sessions from being
622
+ * // initiated. Once all existing sessions have finished, the endpoint
623
+ * // will be destroyed. The call returns a promise that is resolved once
624
+ * // the endpoint is destroyed.
625
+ * await endpoint.close();
626
+ * ```
627
+ *
628
+ * By default, every call to `listen(...)` will create a new local
629
+ * `QuicEndpoint` instance bound to a new random local IP port. To
630
+ * specify the exact local address to use, or to multiplex multiple
631
+ * QUIC sessions over a single local port, pass the `endpoint` option
632
+ * with either a `QuicEndpoint` or `EndpointOptions` as the argument.
633
+ *
634
+ * At most, any single `QuicEndpoint` can only be configured to listen as
635
+ * a server once.
636
+ * @since v23.8.0
637
+ */
638
+ function listen(onsession: OnSessionCallback, options?: SessionOptions): Promise<QuicEndpoint>;
639
+ interface ListEndpointsOptions {
640
+ /**
641
+ * If `true` (the default), only returns endpoints that are
642
+ * active (not destroyed, not closing, and not busy). If `false` returns all
643
+ * endpoints.
644
+ */
645
+ active?: boolean | undefined;
646
+ }
647
+ /**
648
+ * Returns the list of all `QuicEndpoint` instances. By default, only active
649
+ * endpoints are returned.
650
+ * @since v26.4.0
651
+ */
652
+ function listEndpoints(options?: ListEndpointsOptions): QuicEndpoint[];
653
+ /**
654
+ * The endpoint configuration options passed when constructing a new `QuicEndpoint` instance.
655
+ * @since v23.8.0
656
+ */
657
+ interface EndpointOptions {
658
+ /**
659
+ * If not specified the endpoint will bind to IPv4 `localhost` on a random port.
660
+ * @since v23.8.0
661
+ */
662
+ address?: SocketAddress | string | undefined;
663
+ /**
664
+ * An optional `net.BlockList` instance for filtering incoming packets by
665
+ * source address. When configured, every received UDP packet is checked against
666
+ * the block list before any QUIC processing occurs, minimizing resource
667
+ * expenditure on blocked sources. The block list is evaluated live — rules
668
+ * added to the `BlockList` object after the endpoint is created take effect
669
+ * immediately.
670
+ *
671
+ * See `endpointOptions.blockListPolicy` for how matches are interpreted.
672
+ * @since v26.3.0
673
+ */
674
+ blockList?: BlockList | undefined;
675
+ /**
676
+ * Controls how the `endpointOptions.blockList` is interpreted:
677
+ *
678
+ * * `'deny'` — Packets from addresses matching the block list are dropped.
679
+ * All other addresses are accepted. This is the typical blocklist mode.
680
+ * * `'allow'` — Only packets from addresses matching the block list are
681
+ * accepted. All other addresses are dropped. This is an allowlist mode
682
+ * for restricting access to known clients.
683
+ *
684
+ * If no block list is configured, this option has no effect.
685
+ * @since v26.3.0
686
+ */
687
+ blockListPolicy?: "deny" | "allow" | undefined;
688
+ /**
689
+ * The endpoint maintains an internal cache of validated socket addresses as a
690
+ * performance optimization. This option sets the maximum number of addresses
691
+ * that are cached. This is an advanced option that users typically won't have
692
+ * need to specify.
693
+ * @since v23.8.0
694
+ */
695
+ addressLRUSize?: bigint | number | undefined;
696
+ /**
697
+ * When `true`, the endpoint will not send stateless reset packets in response
698
+ * to packets from unknown connections. Stateless resets allow a peer to detect
699
+ * that a connection has been lost even when the server has no state for it.
700
+ * Disabling them may be useful in testing or when stateless resets are handled
701
+ * at a different layer.
702
+ * @since v26.2.0
703
+ */
704
+ disableStatelessReset?: boolean | undefined;
705
+ /**
706
+ * The number of seconds an endpoint will remain alive after all sessions have
707
+ * closed and it is no longer listening. A value of `0` (default) means the
708
+ * endpoint is only destroyed when explicitly closed via `endpoint.close()` or
709
+ * `endpoint.destroy()`. A positive value starts an idle timer when the endpoint
710
+ * becomes idle; if no new sessions are created before the timer fires, the
711
+ * endpoint is automatically destroyed. This is useful for connection pooling
712
+ * where endpoints should linger briefly for reuse by future `connect()` calls.
713
+ * @since v26.2.0
714
+ */
715
+ idleTimeout?: number | undefined;
716
+ /**
717
+ * When `true`, indicates that the endpoint should bind only to IPv6 addresses.
718
+ * @since v23.8.0
719
+ */
720
+ ipv6Only?: boolean | undefined;
721
+ /**
722
+ * Specifies the maximum number of concurrent sessions allowed per remote IP
723
+ * address (ignoring port). When the limit is reached, new connections from the
724
+ * same IP are refused with `CONNECTION_REFUSED`. A value of `0` disables the
725
+ * limit. The maximum value is `65535`.
726
+ *
727
+ * This limit can also be changed dynamically after construction via
728
+ * `endpoint.maxConnectionsPerHost`.
729
+ * @since v23.8.0
730
+ */
731
+ maxConnectionsPerHost?: number | undefined;
732
+ /**
733
+ * Specifies the maximum total number of concurrent sessions across all remote
734
+ * addresses. When the limit is reached, new connections are refused with
735
+ * `CONNECTION_REFUSED`. A value of `0` disables the limit. The maximum value is
736
+ * `65535`.
737
+ *
738
+ * This limit can also be changed dynamically after construction via
739
+ * `endpoint.maxConnectionsTotal`.
740
+ * @since v23.8.0
741
+ */
742
+ maxConnectionsTotal?: number | undefined;
743
+ /**
744
+ * The maximum number of QUIC retry packets the endpoint will send per second.
745
+ * This is a global rate limit (not per-host) that caps the total server-wide
746
+ * retry response rate, preventing spoofed-source floods from consuming unbounded
747
+ * resources.
748
+ * @since v26.3.0
749
+ */
750
+ retryRate?: number | undefined;
751
+ /**
752
+ * The maximum burst of retry packets allowed before rate limiting takes effect.
753
+ * @since v26.3.0
754
+ */
755
+ retryBurst?: number | undefined;
756
+ /**
757
+ * The maximum number of stateless reset packets the endpoint will send per second.
758
+ * @since v26.3.0
759
+ */
760
+ statelessResetRate?: number | undefined;
761
+ /**
762
+ * The maximum burst of stateless reset packets allowed before rate limiting
763
+ * takes effect.
764
+ * @since v26.3.0
765
+ */
766
+ statelessResetBurst?: number | undefined;
767
+ /**
768
+ * The maximum number of version negotiation packets the endpoint will send per
769
+ * second.
770
+ * @since v26.3.0
771
+ */
772
+ versionNegotiationRate?: number | undefined;
773
+ /**
774
+ * The maximum number of immediate connection close packets the endpoint will
775
+ * send per second.
776
+ * @since v26.3.0
777
+ */
778
+ versionNegotiationBurst?: number | undefined;
779
+ /**
780
+ * The maximum number of immediate connection close packets the endpoint will
781
+ * send per second.
782
+ * @since v26.3.0
783
+ */
784
+ immediateCloseRate?: number | undefined;
785
+ /**
786
+ * The maximum burst of immediate connection close packets allowed before rate
787
+ * limiting takes effect.
788
+ * @since v26.3.0
789
+ */
790
+ immediateCloseBurst?: number | undefined;
791
+ /**
792
+ * The maximum number of new sessions that a single remote address can create per
793
+ * second. This is a per-host rate limit tracked in the address validation LRU
794
+ * cache. It prevents a validated remote address from churning through sessions
795
+ * (rapidly opening and abandoning connections) faster than the server can handle.
796
+ * For benchmarking where traffic comes from a single source, set this to a high
797
+ * value.
798
+ * @since v26.3.0
799
+ */
800
+ sessionCreationRate?: number | undefined;
801
+ /**
802
+ * The maximum burst of new session creations allowed from a single remote address
803
+ * before rate limiting takes effect.
804
+ * @since v26.3.0
805
+ */
806
+ sessionCreationBurst?: number | undefined;
807
+ /**
808
+ * Specifies the length of time a QUIC retry token is considered valid.
809
+ * @since v23.8.0
810
+ */
811
+ retryTokenExpiration?: bigint | number | undefined;
812
+ /**
813
+ * Specifies the 16-byte secret used to generate QUIC retry tokens.
814
+ * @since v23.8.0
815
+ */
816
+ resetTokenSecret?: NodeJS.ArrayBufferView | undefined;
817
+ /**
818
+ * Specifies the length of time a QUIC token is considered valid.
819
+ * @since v23.8.0
820
+ */
821
+ tokenExpiration?: bigint | number | undefined;
822
+ /**
823
+ * Specifies the 16-byte secret used to generate QUIC tokens.
824
+ * @since v23.8.0
825
+ */
826
+ tokenSecret?: NodeJS.ArrayBufferView | undefined;
827
+ /**
828
+ * @since v23.8.0
829
+ */
830
+ udpReceiveBufferSize?: number | undefined;
831
+ /**
832
+ * @since v23.8.0
833
+ */
834
+ udpSendBufferSize?: number | undefined;
835
+ /**
836
+ * @since v23.8.0
837
+ */
838
+ udpTTL?: number | undefined;
839
+ /**
840
+ * When `true`, requires that the endpoint validate peer addresses using retry packets
841
+ * while establishing a new connection.
842
+ * @since v23.8.0
843
+ */
844
+ validateAddress?: boolean | undefined;
845
+ }
846
+ interface SetSNIContextsOptions {
847
+ replace?: boolean | undefined;
848
+ }
849
+ /**
850
+ * A `QuicEndpoint` encapsulates the local UDP-port binding for QUIC. It can be
851
+ * used as both a client and a server.
852
+ * @since v23.8.0
853
+ */
854
+ class QuicEndpoint implements AsyncDisposable {
855
+ constructor(options?: EndpointOptions);
856
+ /**
857
+ * The local UDP socket address to which the endpoint is bound, if any.
858
+ *
859
+ * If the endpoint is not currently bound then the value will be `undefined`. Read only.
860
+ * @since v23.8.0
861
+ */
862
+ readonly address: SocketAddress | undefined;
863
+ /**
864
+ * When `endpoint.busy` is set to true, the endpoint will temporarily reject
865
+ * new sessions from being created. Read/write.
866
+ *
867
+ * ```js
868
+ * // Mark the endpoint busy. New sessions will be prevented.
869
+ * endpoint.busy = true;
870
+ *
871
+ * // Mark the endpoint free. New session will be allowed.
872
+ * endpoint.busy = false;
873
+ * ```
874
+ *
875
+ * The `busy` property is useful when the endpoint is under heavy load and needs to
876
+ * temporarily reject new sessions while it catches up.
877
+ * @since v23.8.0
878
+ */
879
+ busy: boolean;
880
+ /**
881
+ * Gracefully close the endpoint. The endpoint will close and destroy itself when
882
+ * all currently open sessions close. Once called, new sessions will be rejected.
883
+ *
884
+ * Returns a promise that is fulfilled when the endpoint is destroyed.
885
+ * @since v23.8.0
886
+ */
887
+ close(): Promise<void>;
888
+ /**
889
+ * A promise that is fulfilled when the endpoint is destroyed. This will be the same promise that is
890
+ * returned by the `endpoint.close()` function. Read only.
891
+ * @since v23.8.0
892
+ */
893
+ readonly closed: Promise<void>;
894
+ /**
895
+ * True if `endpoint.close()` has been called and closing the endpoint has not yet completed.
896
+ * Read only.
897
+ * @since v23.8.0
898
+ */
899
+ readonly closing: boolean;
900
+ /**
901
+ * Forcefully closes the endpoint by forcing all open sessions to be immediately
902
+ * closed.
903
+ * @since v23.8.0
904
+ */
905
+ destroy(error?: any): void;
906
+ /**
907
+ * True if `endpoint.destroy()` has been called. Read only.
908
+ * @since v23.8.0
909
+ */
910
+ readonly destroyed: boolean;
911
+ /**
912
+ * True if the endpoint is actively listening for incoming connections. Read only.
913
+ * @since v26.2.0
914
+ */
915
+ readonly listening: boolean;
916
+ /**
917
+ * The maximum number of concurrent connections allowed per remote IP address.
918
+ * `0` means unlimited (default). Can be set at construction time via the
919
+ * `maxConnectionsPerHost` option and changed dynamically at any time.
920
+ * The valid range is `0` to `65535`.
921
+ * @since v26.2.0
922
+ */
923
+ maxConnectionsPerHost: number;
924
+ /**
925
+ * The maximum total number of concurrent connections across all remote
926
+ * addresses. `0` means unlimited (default). Can be set at construction time via
927
+ * the `maxConnectionsTotal` option and changed dynamically at any time.
928
+ * The valid range is `0` to `65535`.
929
+ * @since v26.2.0
930
+ */
931
+ maxConnectionsTotal: number;
932
+ /**
933
+ * Replaces or updates the SNI TLS contexts for this endpoint. This allows
934
+ * changing the TLS identity (key/certificate) used for specific host names
935
+ * without restarting the endpoint. Existing sessions are unaffected — only
936
+ * new sessions will use the updated contexts.
937
+ *
938
+ * ```js
939
+ * endpoint.setSNIContexts({
940
+ * 'api.example.com': { keys: [newApiKey], certs: [newApiCert] },
941
+ * });
942
+ *
943
+ * // Replace the entire SNI map
944
+ * endpoint.setSNIContexts({
945
+ * 'api.example.com': { keys: [newApiKey], certs: [newApiCert] },
946
+ * }, { replace: true });
947
+ * ```
948
+ * @since v26.1.0
949
+ * @param entries An object mapping host names to TLS identity options.
950
+ * Each entry must include `keys` and `certs`.
951
+ */
952
+ setSNIContexts(entries: Record<string, SNIEntry>, options?: SetSNIContextsOptions): void;
953
+ /**
954
+ * The statistics collected for an active endpoint. Read only.
955
+ * @since v23.8.0
956
+ */
957
+ readonly stats: QuicEndpoint.Stats;
958
+ /**
959
+ * Calls `endpoint.close()` and returns a promise that fulfills when the
960
+ * endpoint has closed.
961
+ * @since v23.8.0
962
+ */
963
+ [Symbol.asyncDispose](): Promise<void>;
964
+ }
965
+ namespace QuicEndpoint {
966
+ /**
967
+ * A view of the collected statistics for an endpoint.
968
+ * @since v23.8.0
969
+ */
970
+ class Stats {
971
+ private constructor();
972
+ /**
973
+ * A timestamp indicating the moment the endpoint was created. Read only.
974
+ * @since v23.8.0
975
+ */
976
+ readonly createdAt: bigint;
977
+ /**
978
+ * A timestamp indicating the moment the endpoint was destroyed. Read only.
979
+ * @since v23.8.0
980
+ */
981
+ readonly destroyedAt: bigint;
982
+ /**
983
+ * The total number of bytes received by this endpoint. Read only.
984
+ * @since v23.8.0
985
+ */
986
+ readonly bytesReceived: bigint;
987
+ /**
988
+ * The total number of bytes sent by this endpoint. Read only.
989
+ * @since v23.8.0
990
+ */
991
+ readonly bytesSent: bigint;
992
+ /**
993
+ * The total number of QUIC packets successfully received by this endpoint. Read only.
994
+ * @since v23.8.0
995
+ */
996
+ readonly packetsReceived: bigint;
997
+ /**
998
+ * The total number of QUIC packets successfully sent by this endpoint. Read only.
999
+ * @since v23.8.0
1000
+ */
1001
+ readonly packetsSent: bigint;
1002
+ /**
1003
+ * The total number of peer-initiated sessions received by this endpoint. Read only.
1004
+ * @since v23.8.0
1005
+ */
1006
+ readonly serverSessions: bigint;
1007
+ /**
1008
+ * The total number of sessions initiated by this endpoint. Read only.
1009
+ * @since v23.8.0
1010
+ */
1011
+ readonly clientSessions: bigint;
1012
+ /**
1013
+ * The total number of times an initial packet was rejected due to the
1014
+ * endpoint being marked busy. Read only.
1015
+ * @since v23.8.0
1016
+ */
1017
+ readonly serverBusyCount: bigint;
1018
+ /**
1019
+ * The total number of retry packets sent by this endpoint. Read only.
1020
+ * @since v23.8.0
1021
+ */
1022
+ readonly retryCount: bigint;
1023
+ /**
1024
+ * The total number of retry packets dropped by the global rate
1025
+ * limiter. Read only. A non-zero value indicates the endpoint is under retry
1026
+ * flood pressure.
1027
+ * @since v26.3.0
1028
+ */
1029
+ readonly retryRateLimited: bigint;
1030
+ /**
1031
+ * The total number of version negotiation packets sent by this
1032
+ * endpoint. Read only.
1033
+ * @since v23.8.0
1034
+ */
1035
+ readonly versionNegotiationCount: bigint;
1036
+ /**
1037
+ * The total number of version negotiation packets dropped by
1038
+ * the global rate limiter. Read only.
1039
+ * @since v26.3.0
1040
+ */
1041
+ readonly versionNegotiationRateLimited: bigint;
1042
+ /**
1043
+ * The total number of stateless reset packets sent by this
1044
+ * endpoint. Read only.
1045
+ * @since v23.8.0
1046
+ */
1047
+ readonly statelessResetCount: bigint;
1048
+ /**
1049
+ * The total number of stateless reset packets dropped by the
1050
+ * global rate limiter. Read only.
1051
+ * @since v26.3.0
1052
+ */
1053
+ readonly statelessResetRateLimited: bigint;
1054
+ /**
1055
+ * The total number of immediate connection close packets sent
1056
+ * by this endpoint. Read only.
1057
+ * @since v23.8.0
1058
+ */
1059
+ readonly immediateCloseCount: bigint;
1060
+ /**
1061
+ * The total number of immediate connection close packets
1062
+ * dropped by the global rate limiter. Read only.
1063
+ * @since v26.3.0
1064
+ */
1065
+ readonly immediateCloseRateLimited: bigint;
1066
+ /**
1067
+ * The total number of session creation attempts dropped by the
1068
+ * per-host rate limiter. Read only. A non-zero value indicates one or more
1069
+ * remote addresses are creating sessions faster than the configured rate allows.
1070
+ * @since v26.3.0
1071
+ */
1072
+ readonly sessionCreationRateLimited: bigint;
1073
+ /**
1074
+ * The total number of incoming packets dropped by the
1075
+ * block list filter. Read only.
1076
+ * @since v26.3.0
1077
+ */
1078
+ readonly packetsBlocked: bigint;
1079
+ }
1080
+ }
1081
+ interface CreateStreamOptions {
1082
+ /**
1083
+ * The outbound body source. See `stream.setBody()` for details on
1084
+ * supported types. When omitted, the stream's outgoing side remains
1085
+ * writable with no body queued; no FIN is sent immediately.
1086
+ */
1087
+ body?: StreamBody | undefined;
1088
+ /**
1089
+ * Initial request or response headers to send. Only
1090
+ * used when the session supports headers (e.g. HTTP/3). If `body` is not
1091
+ * specified and `headers` is provided, the stream is treated as
1092
+ * headers-only (terminal).
1093
+ */
1094
+ headers?: NodeJS.Dict<string | readonly string[]> | readonly string[] | undefined;
1095
+ /**
1096
+ * The priority level of the stream. One of `'high'`,
1097
+ * `'default'`, or `'low'`. **Default:** `'default'`.
1098
+ */
1099
+ priority?: "high" | "default" | "low" | undefined;
1100
+ /**
1101
+ * When `true`, data from this stream may be
1102
+ * interleaved with data from other streams of the same priority level.
1103
+ * When `false`, the stream should be completed before same-priority peers.
1104
+ * **Default:** `false`.
1105
+ */
1106
+ incremental?: boolean | undefined;
1107
+ /**
1108
+ * The maximum number of bytes that the writer
1109
+ * will buffer before `writeSync()` returns `false`. When the buffered
1110
+ * data exceeds this limit, the caller should wait for drain before
1111
+ * writing more. **Default:** `65536` (64 KB).
1112
+ */
1113
+ highWaterMark?: number | undefined;
1114
+ /**
1115
+ * Callback for received initial response headers.
1116
+ * Called with `(headers)`.
1117
+ */
1118
+ onheaders?: QuicStream["onheaders"] | undefined;
1119
+ /**
1120
+ * Callback for received trailing headers.
1121
+ * Called with `(trailers)`.
1122
+ */
1123
+ ontrailers?: QuicStream["ontrailers"] | undefined;
1124
+ /**
1125
+ * Callback for received informational (1xx) headers.
1126
+ * Called with `(headers)`.
1127
+ */
1128
+ oninfo?: QuicStream["oninfo"] | undefined;
1129
+ /**
1130
+ * Callback when trailers should be sent.
1131
+ */
1132
+ onwanttrailers?: QuicStream["onwanttrailers"] | undefined;
1133
+ }
1134
+ interface SessionDestroyOptions {
1135
+ /**
1136
+ * The error code to include in the `CONNECTION_CLOSE`
1137
+ * frame sent to the peer. **Default:** `0` (no error).
1138
+ */
1139
+ code?: bigint | number | undefined;
1140
+ /**
1141
+ * Either `'transport'` or `'application'`. Determines the
1142
+ * error code namespace used in the `CONNECTION_CLOSE` frame. When `'transport'`
1143
+ * (the default), the frame type is `0x1c` and the code is interpreted as a QUIC
1144
+ * transport error. When `'application'`, the frame type is `0x1d` and the code
1145
+ * is application-specific. **Default:** `'transport'`.
1146
+ */
1147
+ type?: "transport" | "application" | undefined;
1148
+ /**
1149
+ * An optional human-readable reason string included in
1150
+ * the `CONNECTION_CLOSE` frame. Per RFC 9000, this is for diagnostic purposes
1151
+ * only and should not be used for machine-readable error descriptions.
1152
+ */
1153
+ reason?: string | undefined;
1154
+ }
1155
+ interface SessionHandshakeInfo {
1156
+ /**
1157
+ * The local socket address.
1158
+ */
1159
+ local: SocketAddress;
1160
+ /**
1161
+ * The remote socket address.
1162
+ */
1163
+ remote: SocketAddress;
1164
+ /**
1165
+ * The SNI server name negotiated during the handshake.
1166
+ */
1167
+ servername: string;
1168
+ /**
1169
+ * The ALPN protocol negotiated during the handshake.
1170
+ */
1171
+ protocol: string;
1172
+ /**
1173
+ * The name of the negotiated TLS cipher suite.
1174
+ */
1175
+ cipher: string;
1176
+ /**
1177
+ * The TLS protocol version of the cipher suite
1178
+ * (e.g., `'TLSv1.3'`).
1179
+ */
1180
+ cipherVersion: string;
1181
+ /**
1182
+ * If certificate validation failed, the
1183
+ * reason string. Empty string if validation succeeded.
1184
+ */
1185
+ validationErrorReason: string;
1186
+ /**
1187
+ * If certificate validation failed, the
1188
+ * error code. `0` if validation succeeded.
1189
+ */
1190
+ validationErrorCode: number;
1191
+ /**
1192
+ * Whether 0-RTT early data was attempted.
1193
+ */
1194
+ earlyDataAttempted: boolean;
1195
+ /**
1196
+ * Whether 0-RTT early data was accepted by
1197
+ * the server.
1198
+ */
1199
+ earlyDataAccepted: boolean;
1200
+ }
1201
+ interface SessionPath {
1202
+ local: SocketAddress;
1203
+ remote: SocketAddress;
1204
+ }
1205
+ /**
1206
+ * A `QuicSession` represents the local side of a QUIC connection.
1207
+ * @since v23.8.0
1208
+ */
1209
+ class QuicSession implements AsyncDisposable {
1210
+ private constructor();
1211
+ /**
1212
+ * The current application-level options for this session. These include settings
1213
+ * that are specific to the negotiated application protocol (e.g. HTTP/3) and may
1214
+ * be negotiated separately from the transport parameters. Read only.
1215
+ * @since v26.3.0
1216
+ */
1217
+ readonly applicationOptions: SessionApplicationOptions;
1218
+ /**
1219
+ * Initiate a graceful close of the session. Existing streams will be allowed
1220
+ * to complete but no new streams will be opened. Once all streams have closed,
1221
+ * the session will be destroyed. The returned promise will be fulfilled once
1222
+ * the session has been destroyed. If a non-zero `code` is specified, the
1223
+ * promise will reject with an `ERR_QUIC_TRANSPORT_ERROR` or
1224
+ * `ERR_QUIC_APPLICATION_ERROR` depending on the `type`.
1225
+ * @since v23.8.0
1226
+ */
1227
+ close(options?: SessionDestroyOptions): Promise<void>;
1228
+ /**
1229
+ * A promise that is fulfilled once the TLS handshake completes successfully.
1230
+ * The resolved value contains information about the established session
1231
+ * including the negotiated protocol, cipher suite, certificate validation
1232
+ * status, and 0-RTT early data status.
1233
+ *
1234
+ * If the handshake fails or the session is destroyed before the handshake
1235
+ * completes, the promise will be rejected.
1236
+ * @since v26.2.0
1237
+ */
1238
+ readonly opened: Promise<SessionHandshakeInfo>;
1239
+ /**
1240
+ * A promise that is fulfilled once the session is destroyed.
1241
+ * @since v23.8.0
1242
+ */
1243
+ readonly closed: Promise<void>;
1244
+ /**
1245
+ * True if `session.close()` has been called and the session has not yet
1246
+ * been destroyed. Read only.
1247
+ * @since v26.2.0
1248
+ */
1249
+ readonly closing: boolean;
1250
+ /**
1251
+ * Immediately destroy the session. All streams will be destroyed and the
1252
+ * session will be closed. If `error` is provided and [`session.onerror`][] is
1253
+ * set, the `onerror` callback is invoked before destruction. The
1254
+ * `session.closed` promise will reject with the error. If `options` is
1255
+ * provided, the `CONNECTION_CLOSE` frame sent to the peer will include the
1256
+ * specified error code, type, and reason.
1257
+ * @since v23.8.0
1258
+ */
1259
+ destroy(error?: any, options?: SessionDestroyOptions): void;
1260
+ /**
1261
+ * True if `session.destroy()` has been called. Read only.
1262
+ * @since v23.8.0
1263
+ */
1264
+ readonly destroyed: boolean;
1265
+ /**
1266
+ * The endpoint that created this session. Returns `null` if the session
1267
+ * has been destroyed. Read only.
1268
+ * @since v23.8.0
1269
+ */
1270
+ readonly endpoint: QuicEndpoint | null;
1271
+ /**
1272
+ * The callback to invoke when new application options, e.g. HTTP/3 settings arrived.
1273
+ * @since v26.4
1274
+ */
1275
+ onapplication: OnApplicationCallback | undefined;
1276
+ /**
1277
+ * An optional callback invoked when the session is destroyed with an error.
1278
+ * This includes errors caused by user callbacks that throw or reject (see
1279
+ * [Callback error handling](https://nodejs.org/docs/latest-v26.x/api/quic.html#callback-error-handling)). The callback receives a single argument: the
1280
+ * error that triggered the destruction. If the `onerror` callback itself throws
1281
+ * or returns a promise that rejects, the error is surfaced as an uncaught
1282
+ * exception. Read/write.
1283
+ *
1284
+ * Can also be set via the `onerror` option in `quic.connect()` or
1285
+ * `quic.listen()`.
1286
+ * @since v26.2.0
1287
+ */
1288
+ onerror: ((this: QuicSession, error: any) => void) | undefined;
1289
+ /**
1290
+ * The callback to invoke when a new stream is initiated by a remote peer. Read/write.
1291
+ * @since v23.8.0
1292
+ */
1293
+ onstream: OnStreamCallback | undefined;
1294
+ /**
1295
+ * The callback to invoke when the server rejects 0-RTT early data. When
1296
+ * this fires, all streams that were opened during the 0-RTT phase have
1297
+ * been destroyed. The application should re-open streams if needed.
1298
+ * Read/write.
1299
+ *
1300
+ * This callback only fires on the client side when the server rejects
1301
+ * the client's 0-RTT attempt. The connection falls back to 1-RTT and
1302
+ * continues normally.
1303
+ * @since v26.2.0
1304
+ */
1305
+ onearlyrejected: ((this: QuicSession) => void) | undefined;
1306
+ /**
1307
+ * The callback to invoke when a new datagram is received from a remote peer. Read/write.
1308
+ * @since v23.8.0
1309
+ */
1310
+ ondatagram: OnDatagramCallback | undefined;
1311
+ /**
1312
+ * The callback to invoke when the status of a datagram is updated. Read/write.
1313
+ * @since v23.8.0
1314
+ */
1315
+ ondatagramstatus: OnDatagramStatusCallback | undefined;
1316
+ /**
1317
+ * The callback to invoke when the path validation is updated. Read/write.
1318
+ * @since v23.8.0
1319
+ */
1320
+ onpathvalidation: OnPathValidationCallback | undefined;
1321
+ /**
1322
+ * The callback to invoke when a new session ticket is received. Read/write.
1323
+ * @since v23.8.0
1324
+ */
1325
+ onsessionticket: OnSessionTicketCallback | undefined;
1326
+ /**
1327
+ * The callback to invoke when a version negotiation is initiated. Read/write.
1328
+ * @since v23.8.0
1329
+ */
1330
+ onversionnegotiation: OnVersionNegotiationCallback | undefined;
1331
+ /**
1332
+ * The callback to invoke when the TLS handshake is completed. Read/write.
1333
+ * @since v23.8.0
1334
+ */
1335
+ onhandshake: OnHandshakeCallback | undefined;
1336
+ /**
1337
+ * The callback to invoke when a NEW\_TOKEN token is received from the server.
1338
+ * The token can be passed as the `token` option on a future connection to
1339
+ * the same server to skip address validation. Read/write.
1340
+ * @since v26.2.0
1341
+ */
1342
+ onnewtoken: OnNewTokenCallback | undefined;
1343
+ /**
1344
+ * The callback to invoke when an ORIGIN frame (RFC 9412) is received from
1345
+ * the server, indicating which origins the server is authoritative for.
1346
+ * Read/write.
1347
+ * @since v26.2.0
1348
+ */
1349
+ onorigin: OnOriginCallback | undefined;
1350
+ /**
1351
+ * The callback to invoke when the peer sends an HTTP/3 GOAWAY frame,
1352
+ * indicating it is initiating a graceful shutdown. The callback receives
1353
+ * `(lastStreamId)` where `lastStreamId` is a `{bigint}`:
1354
+ *
1355
+ * * When `lastStreamId` is `-1n`, the peer sent a shutdown notice (intent
1356
+ * to close) without specifying a stream boundary. All existing streams
1357
+ * may still be processed.
1358
+ * * When `lastStreamId` is `>= 0n`, it is the highest stream ID the peer
1359
+ * may have processed. Streams with IDs above this value were NOT
1360
+ * processed and can be safely retried on a new connection.
1361
+ *
1362
+ * After GOAWAY is received, `session.createBidirectionalStream()` will
1363
+ * throw `ERR_INVALID_STATE`. Existing streams continue until they
1364
+ * complete or the session closes.
1365
+ *
1366
+ * This callback is only relevant for HTTP/3 sessions. Read/write.
1367
+ * @since v26.2.0
1368
+ */
1369
+ ongoaway: ((this: QuicSession, lastStreamId: bigint) => void) | undefined;
1370
+ /**
1371
+ * The callback to invoke when TLS key material is available. Requires
1372
+ * `sessionOptions.keylog` to be `true`. Each invocation receives a single
1373
+ * line of [NSS Key Log Format](https://udn.realityripple.com/docs/Mozilla/Projects/NSS/Key_Log_Format) text (including a trailing newline). This is
1374
+ * useful for decrypting packet captures with tools like Wireshark. Read/write.
1375
+ *
1376
+ * Can also be set via the `onkeylog` option in `quic.connect()` or
1377
+ * `quic.listen()`.
1378
+ * @since v26.2.0
1379
+ */
1380
+ onkeylog: OnKeylogCallback | undefined;
1381
+ /**
1382
+ * The callback to invoke when qlog data is available. Requires
1383
+ * `sessionOptions.qlog` to be `true`. The callback receives a string
1384
+ * chunk of [JSON-SEQ](https://www.rfc-editor.org/rfc/rfc7464) formatted qlog data and a boolean `fin` flag. When
1385
+ * `fin` is `true`, the chunk is the final qlog output for this session and
1386
+ * the concatenated chunks form a complete qlog trace. Read/write.
1387
+ *
1388
+ * Qlog data arrives during the connection lifecycle. The first chunk contains
1389
+ * the qlog header with format metadata. Subsequent chunks contain trace
1390
+ * events. The final chunk (with `fin` set to `true`) is emitted during
1391
+ * session destruction and completes the JSON-SEQ output.
1392
+ *
1393
+ * Can also be set via the `onqlog` option in `quic.connect()` or
1394
+ * `quic.listen()`.
1395
+ * @since v26.2.0
1396
+ */
1397
+ onqlog: OnQlogCallback | undefined;
1398
+ /**
1399
+ * Open a new bidirectional stream. If the `body` option is not specified,
1400
+ * the stream's outgoing side remains writable and no FIN is sent
1401
+ * immediately. The `priority` and `incremental`
1402
+ * options are only used when the session supports priority (e.g. HTTP/3).
1403
+ * The `headers`, `onheaders`, `ontrailers`, `oninfo`, and `onwanttrailers`
1404
+ * options are only used when the session supports headers (e.g. HTTP/3).
1405
+ * @since v23.8.0
1406
+ */
1407
+ createBidirectionalStream(options?: CreateStreamOptions): Promise<QuicStream>;
1408
+ /**
1409
+ * Open a new unidirectional stream. If the `body` option is not specified,
1410
+ * the stream's outgoing side remains writable and no FIN is sent
1411
+ * immediately. The `priority` and `incremental`
1412
+ * options are only used when the session supports priority (e.g. HTTP/3).
1413
+ * @since v23.8.0
1414
+ */
1415
+ createUnidirectionalStream(options?: CreateStreamOptions): Promise<QuicStream>;
1416
+ /**
1417
+ * The local and remote socket addresses associated with the session. Read only.
1418
+ * @since v23.8.0
1419
+ */
1420
+ path: SessionPath | undefined;
1421
+ /**
1422
+ * Sends an unreliable datagram to the remote peer, returning a promise for
1423
+ * the datagram ID.
1424
+ *
1425
+ * If `datagram` is a string, it will be encoded using the specified `encoding`.
1426
+ *
1427
+ * If `datagram` is an `ArrayBufferView`, the bytes are copied into an
1428
+ * internal buffer; the caller's source buffer is unchanged and may be reused
1429
+ * or mutated immediately after the call returns. Callers that want to ensure
1430
+ * their source cannot be mutated after the call (for example, when handing
1431
+ * the buffer off to another async consumer) can call
1432
+ * `ArrayBuffer.prototype.transfer()` themselves before passing the buffer.
1433
+ *
1434
+ * If `datagram` is a `Promise`, it will be awaited before sending. If the
1435
+ * session closes while awaiting, `0n` is returned silently (datagrams are
1436
+ * inherently unreliable).
1437
+ *
1438
+ * If the datagram payload is zero-length (empty string after encoding, detached
1439
+ * buffer, or zero-length view), `0n` is returned and no datagram is sent.
1440
+ *
1441
+ * For HTTP/3 sessions, the peer must advertise `SETTINGS_H3_DATAGRAM=1`
1442
+ * (via `application: { enableDatagrams: true }`) for datagrams to be sent.
1443
+ * If the peer's setting is `0`, `sendDatagram()` returns `0n` (per RFC 9297
1444
+ * §3, an endpoint MUST NOT send HTTP Datagrams unless the peer indicated
1445
+ * support).
1446
+ *
1447
+ * Datagrams cannot be fragmented — each must fit within a single QUIC packet.
1448
+ * The maximum datagram size is determined by the peer's
1449
+ * `maxDatagramFrameSize` transport parameter (which the peer advertises during
1450
+ * the handshake). If the peer sets this to `0`, datagrams are not supported
1451
+ * and `0n` will be returned. If the datagram exceeds the peer's limit, it
1452
+ * will be silently dropped and `0n` returned. The local
1453
+ * `maxDatagramFrameSize` transport parameter (default: `1200` bytes) controls
1454
+ * what this endpoint advertises to the peer as its own maximum.
1455
+ * @since v23.8.0
1456
+ * @param encoding The encoding to use if `datagram` is a string.
1457
+ * **Default:** `'utf8'`.
1458
+ */
1459
+ sendDatagram(
1460
+ datagram: string | NodeJS.ArrayBufferView | Promise<string | NodeJS.ArrayBufferView>,
1461
+ encoding?: BufferEncoding,
1462
+ ): Promise<bigint>;
1463
+ /**
1464
+ * The SNI (Server Name Indication) host name associated with the session. This is
1465
+ * `null` before the client hello is processed. Once the hello has been
1466
+ * processed, this is either the host name string or `false` if the handshake
1467
+ * had no SNI.
1468
+ * @since v26.6.0
1469
+ */
1470
+ readonly servername: string | false | null;
1471
+ /**
1472
+ * The negotiated ALPN protocol. This is `null` before the client hello is
1473
+ * processed. Once ALPN has been negotiated, this is the protocol string. ALPN
1474
+ * is mandatory in QUIC so this is never `false` on successful connections,
1475
+ * unlike `node:tls` where this is optional.
1476
+ * @since v26.6.0
1477
+ */
1478
+ readonly alpnProtocol: string | null;
1479
+ /**
1480
+ * The local certificate as a `crypto.X509Certificate` instance. Server
1481
+ * sessions return the certificate configured for the negotiated SNI host.
1482
+ * Client sessions return `undefined` unless a client certificate was sent.
1483
+ * Returns `undefined` if the session is destroyed.
1484
+ * @since v26.2.0
1485
+ */
1486
+ readonly certificate: X509Certificate | undefined;
1487
+ /**
1488
+ * The peer's certificate as a `crypto.X509Certificate` instance. Returns
1489
+ * `undefined` if the peer did not present a certificate or the session is
1490
+ * destroyed.
1491
+ * @since v26.2.0
1492
+ */
1493
+ readonly peerCertificate: X509Certificate | undefined;
1494
+ /**
1495
+ * The ephemeral key information for the session, with properties such as
1496
+ * `type`, `name`, and `size`. Only available on client sessions. Returns
1497
+ * `undefined` for server sessions or if the session is destroyed.
1498
+ * @since v26.2.0
1499
+ */
1500
+ readonly ephemeralKeyInfo: EphemeralKeyInfo | undefined;
1501
+ /**
1502
+ * The maximum datagram payload size in bytes that the peer will accept.
1503
+ * This is derived from the peer's `maxDatagramFrameSize` transport
1504
+ * parameter minus the DATAGRAM frame overhead (type byte and variable-length
1505
+ * integer encoding). Returns `0` if the peer does not support datagrams or
1506
+ * if the handshake has not yet completed. Datagrams larger than this value
1507
+ * will not be sent.
1508
+ * @since v26.2.0
1509
+ */
1510
+ readonly maxDatagramSize: number;
1511
+ /**
1512
+ * The maximum number of datagrams that can be queued for sending. Datagrams
1513
+ * are queued when `sendDatagram()` is called and sent opportunistically
1514
+ * alongside stream data by the packet serialization loop. When the queue
1515
+ * is full, the `sessionOptions.datagramDropPolicy` determines whether
1516
+ * the oldest or newest datagram is dropped. Dropped datagrams are reported
1517
+ * as lost via the `ondatagramstatus` callback.
1518
+ *
1519
+ * This property can be changed dynamically to adjust queue capacity
1520
+ * based on application activity or memory pressure. The valid range
1521
+ * is `0` to `65535`.
1522
+ * @since v26.2.0
1523
+ */
1524
+ maxPendingDatagrams: number;
1525
+ /**
1526
+ * Return the current statistics for the session. Read only.
1527
+ * @since v23.8.0
1528
+ */
1529
+ readonly stats: QuicSession.Stats;
1530
+ /**
1531
+ * Initiate a key update for the session.
1532
+ * @since v23.8.0
1533
+ */
1534
+ updateKey(): void;
1535
+ /**
1536
+ * Calls `session.close()` and returns a promise that fulfills when the
1537
+ * session has closed.
1538
+ * @since v23.8.0
1539
+ */
1540
+ [Symbol.asyncDispose](): Promise<void>;
1541
+ }
1542
+ namespace QuicSession {
1543
+ /**
1544
+ * @since v23.8.0
1545
+ */
1546
+ class Stats {
1547
+ private constructor();
1548
+ /**
1549
+ * @since v23.8.0
1550
+ */
1551
+ readonly createdAt: bigint;
1552
+ /**
1553
+ * @since v23.8.0
1554
+ */
1555
+ readonly closingAt: bigint;
1556
+ /**
1557
+ * @since v23.8.0
1558
+ */
1559
+ readonly handshakeCompletedAt: bigint;
1560
+ /**
1561
+ * @since v23.8.0
1562
+ */
1563
+ readonly handshakeConfirmedAt: bigint;
1564
+ /**
1565
+ * @since v23.8.0
1566
+ */
1567
+ readonly bytesReceived: bigint;
1568
+ /**
1569
+ * @since v23.8.0
1570
+ */
1571
+ readonly bytesSent: bigint;
1572
+ /**
1573
+ * @since v23.8.0
1574
+ */
1575
+ readonly bidiInStreamCount: bigint;
1576
+ /**
1577
+ * @since v23.8.0
1578
+ */
1579
+ readonly bidiOutStreamCount: bigint;
1580
+ /**
1581
+ * @since v23.8.0
1582
+ */
1583
+ readonly uniInStreamCount: bigint;
1584
+ /**
1585
+ * @since v23.8.0
1586
+ */
1587
+ readonly uniOutStreamCount: bigint;
1588
+ /**
1589
+ * @since v23.8.0
1590
+ */
1591
+ readonly maxBytesInFlight: bigint;
1592
+ /**
1593
+ * @since v23.8.0
1594
+ */
1595
+ readonly bytesInFlight: bigint;
1596
+ /**
1597
+ * @since v23.8.0
1598
+ */
1599
+ readonly blockCount: bigint;
1600
+ /**
1601
+ * @since v23.8.0
1602
+ */
1603
+ readonly cwnd: bigint;
1604
+ /**
1605
+ * @since v23.8.0
1606
+ */
1607
+ readonly latestRtt: bigint;
1608
+ /**
1609
+ * @since v23.8.0
1610
+ */
1611
+ readonly minRtt: bigint;
1612
+ /**
1613
+ * @since v23.8.0
1614
+ */
1615
+ readonly rttVar: bigint;
1616
+ /**
1617
+ * @since v23.8.0
1618
+ */
1619
+ readonly smoothedRtt: bigint;
1620
+ /**
1621
+ * @since v23.8.0
1622
+ */
1623
+ readonly ssthresh: bigint;
1624
+ /**
1625
+ * @since v23.8.0
1626
+ */
1627
+ readonly datagramsReceived: bigint;
1628
+ /**
1629
+ * @since v23.8.0
1630
+ */
1631
+ readonly datagramsSent: bigint;
1632
+ /**
1633
+ * @since v23.8.0
1634
+ */
1635
+ readonly datagramsAcknowledged: bigint;
1636
+ /**
1637
+ * @since v23.8.0
1638
+ */
1639
+ readonly datagramsLost: bigint;
1640
+ /**
1641
+ * The total number of peer-initiated streams destroyed by the
1642
+ * stream idle timeout. Read only.
1643
+ * @since v26.3.0
1644
+ */
1645
+ readonly streamsIdleTimedOut: bigint;
1646
+ }
1647
+ }
1648
+ interface QuicErrorOptions {
1649
+ /**
1650
+ * The numeric QUIC error code. Numbers
1651
+ * are coerced to `BigInt`. Must be a non-negative 62-bit unsigned
1652
+ * varint (`0n <= errorCode <= 2n ** 62n - 1n`).
1653
+ */
1654
+ errorCode?: bigint | number | undefined;
1655
+ /**
1656
+ * The Node.js-style error code string assigned to
1657
+ * `error.code`. Defaults to `'ERR_QUIC_STREAM_ABORTED'`.
1658
+ */
1659
+ code?: string | undefined;
1660
+ /**
1661
+ * Either `'application'` (default) or `'transport'`.
1662
+ * Indicates whether the code is defined by the negotiated
1663
+ * application protocol (e.g. RFC 9114 for HTTP/3) or by the QUIC
1664
+ * transport layer (RFC 9000). Stream resets always carry application
1665
+ * codes, so the default is `'application'`.
1666
+ */
1667
+ type?: "application" | "transport" | undefined;
1668
+ }
1669
+ /**
1670
+ * A `QuicError` is an `Error` subclass that carries an explicit numeric
1671
+ * QUIC error code. Use it to abort a QUIC stream or session with a
1672
+ * specific application-protocol-defined error code rather than letting
1673
+ * the implementation pick a generic fallback.
1674
+ *
1675
+ * The class is exported from `node:quic`:
1676
+ *
1677
+ * ```js
1678
+ * import { QuicError } from 'node:quic';
1679
+ * ```
1680
+ *
1681
+ * When a `QuicError` is supplied to APIs that emit a wire frame
1682
+ * (`writer.fail()`, `stream.destroy()`), the QUIC stack uses
1683
+ * `error.errorCode` as the wire code for the resulting frame.
1684
+ * When any other value is supplied (for example a plain `Error`), the
1685
+ * implementation falls back to the negotiated application protocol's
1686
+ * "internal error" code (`H3_INTERNAL_ERROR` (`0x102`) for HTTP/3, or
1687
+ * the QUIC transport-layer `INTERNAL_ERROR` (`0x1`) for raw QUIC).
1688
+ *
1689
+ * The Node.js error code (`error.code`) defaults to
1690
+ * `'ERR_QUIC_STREAM_ABORTED'`. Callers who need a more specific code
1691
+ * string can override it via `options.code` — the numeric QUIC code
1692
+ * is unaffected.
1693
+ *
1694
+ * The Node.js error code is fixed at `'ERR_QUIC_STREAM_ABORTED'` so that
1695
+ * catch blocks can distinguish a `QuicError` from other Node.js errors
1696
+ * without checking the prototype chain. The numeric QUIC code lives on
1697
+ * the separate `error.errorCode` property to avoid colliding with
1698
+ * the Node.js convention that `error.code` is a string.
1699
+ * @since v26.2.0
1700
+ * @experimental
1701
+ */
1702
+ class QuicError extends Error {
1703
+ /**
1704
+ * ```js
1705
+ * import { QuicError } from 'node:quic';
1706
+ *
1707
+ * const err = new QuicError('rejecting stream', { errorCode: 0x10cn });
1708
+ * console.log(err.code); // 'ERR_QUIC_STREAM_ABORTED'
1709
+ * console.log(err.errorCode); // 268n
1710
+ * console.log(err.type); // 'application'
1711
+ *
1712
+ * const custom = new QuicError('custom failure', {
1713
+ * errorCode: 0x10cn,
1714
+ * code: 'ERR_MY_QUIC_FAILURE',
1715
+ * });
1716
+ * console.log(custom.code); // 'ERR_MY_QUIC_FAILURE'
1717
+ * ```
1718
+ * @param message A human-readable description of the error.
1719
+ */
1720
+ constructor(message: string, options?: QuicErrorOptions);
1721
+ /**
1722
+ * The numeric QUIC error code carried by this error.
1723
+ * @since v26.2.0
1724
+ */
1725
+ readonly errorCode: bigint;
1726
+ /**
1727
+ * Either `'application'` or `'transport'`. Indicates the namespace of
1728
+ * `error.errorCode`.
1729
+ * @since v26.2.0
1730
+ */
1731
+ readonly type: "application" | "transport";
1732
+ }
1733
+ type StreamBody =
1734
+ | null
1735
+ | string
1736
+ | ArrayBufferLike
1737
+ | NodeJS.ArrayBufferView
1738
+ | Blob
1739
+ | FileHandle
1740
+ | Iterable<string | Uint8Array>
1741
+ | AsyncIterable<string | Uint8Array>
1742
+ | Promise<StreamBody>;
1743
+ interface StreamPriority {
1744
+ /**
1745
+ * One of `'high'`, `'default'`, or `'low'`.
1746
+ */
1747
+ level: "high" | "default" | "low";
1748
+ /**
1749
+ * Whether the stream data should be interleaved
1750
+ * with other streams of the same priority level.
1751
+ */
1752
+ incremental: boolean;
1753
+ }
1754
+ interface StreamDestroyOptions {
1755
+ /**
1756
+ * The application error code to include in the
1757
+ * `RESET_STREAM` and `STOP_SENDING` frames sent to the peer. Numbers are
1758
+ * coerced to `BigInt`. When omitted, the wire code is derived from `error`
1759
+ * (see below).
1760
+ */
1761
+ code?: bigint | number | undefined;
1762
+ /**
1763
+ * An optional human-readable reason string. Accepted for
1764
+ * symmetry with `session.close()` and `session.destroy()`, but
1765
+ * **not transmitted on the wire** — neither `RESET_STREAM` nor
1766
+ * `STOP_SENDING` carry a reason field. Provided for application logging
1767
+ * and for use by the `stream.onerror` callback.
1768
+ */
1769
+ reason?: string | undefined;
1770
+ }
1771
+ interface StreamSendHeadersOptions {
1772
+ /**
1773
+ * If `true`, the stream is closed for sending
1774
+ * after the headers (no body will follow). **Default:** `false`.
1775
+ */
1776
+ terminal?: boolean | undefined;
1777
+ }
1778
+ /**
1779
+ * @since v23.8.0
1780
+ */
1781
+ class QuicStream {
1782
+ private constructor();
1783
+ /**
1784
+ * A promise that is fulfilled when the stream is fully closed. It resolves
1785
+ * when the stream closes cleanly (including idle timeout). It rejects with
1786
+ * an `ERR_QUIC_APPLICATION_ERROR` or `ERR_QUIC_TRANSPORT_ERROR` when the
1787
+ * stream is closed due to a QUIC error (e.g., stream reset by the peer,
1788
+ * CONNECTION\_CLOSE with a non-zero error code).
1789
+ * @since v23.8.0
1790
+ */
1791
+ readonly closed: Promise<void>;
1792
+ /**
1793
+ * Immediately and abruptly destroys the stream. If `error` is provided and
1794
+ * `stream.onerror` is set, the `onerror` callback is invoked before
1795
+ * destruction. The `stream.closed` promise rejects with the error.
1796
+ *
1797
+ * When the stream is destroyed with an `error` (or with an explicit
1798
+ * `options.code`), the QUIC stack signals the abort to the peer:
1799
+ *
1800
+ * * If the writable side is still open, a `RESET_STREAM` frame is sent.
1801
+ * * If the readable side is still open (a bidirectional stream, or a
1802
+ * remote-initiated unidirectional stream), a `STOP_SENDING` frame is sent.
1803
+ *
1804
+ * Both frames carry the same wire code, resolved with the following
1805
+ * precedence:
1806
+ *
1807
+ * 1. `options.code`, when explicitly provided.
1808
+ * 2. [`error.errorCode`][], when `error` is a [`QuicError`][].
1809
+ * 3. The negotiated application protocol's "internal error" code
1810
+ * (`H3_INTERNAL_ERROR` (`0x102`) for HTTP/3, or the QUIC transport-layer
1811
+ * `INTERNAL_ERROR` (`0x1`) for raw QUIC).
1812
+ *
1813
+ * A clean destroy — no `error` and no `options.code` — does not emit
1814
+ * `RESET_STREAM` or `STOP_SENDING`; the stream's existing close machinery
1815
+ * handles teardown.
1816
+ *
1817
+ * See [Aborting a stream](https://nodejs.org/docs/latest-v26.x/api/quic.html#aborting-a-stream) for an overview of the available stream-abort
1818
+ * APIs.
1819
+ * @since v23.8.0
1820
+ */
1821
+ destroy(error?: any, options?: StreamDestroyOptions): void;
1822
+ /**
1823
+ * True if `stream.destroy()` has been called.
1824
+ * @since v23.8.0
1825
+ */
1826
+ readonly destroyed: boolean;
1827
+ /**
1828
+ * True if any data on this stream was received as 0-RTT (early data)
1829
+ * before the TLS handshake completed. Early data is less secure and
1830
+ * could potentially be replayed by an attacker. Applications should
1831
+ * treat early data with appropriate caution.
1832
+ *
1833
+ * This property is only meaningful on the server side. On the client
1834
+ * side, it is always `false`.
1835
+ * @since v26.2.0
1836
+ */
1837
+ readonly early: boolean;
1838
+ /**
1839
+ * The directionality of the stream, or `null` if the stream has been destroyed
1840
+ * or is still pending. Read only.
1841
+ * @since v23.8.0
1842
+ */
1843
+ readonly direction: "bidi" | "uni" | null;
1844
+ /**
1845
+ * The maximum number of bytes that the writer will buffer before
1846
+ * `writeSync()` returns `false`. When the buffered data exceeds this limit,
1847
+ * the caller should wait for drain before writing more.
1848
+ *
1849
+ * The value can be changed dynamically at any time. This is particularly
1850
+ * useful for streams received via the `onstream` callback, where the
1851
+ * default (65536) may need to be adjusted based on application needs.
1852
+ * The valid range is `0` to `4294967295`.
1853
+ * @since v26.2.0
1854
+ */
1855
+ highWaterMark: number;
1856
+ /**
1857
+ * The stream ID, or `null` if the stream has been destroyed or is still
1858
+ * pending. Read only.
1859
+ * @since v23.8.0
1860
+ */
1861
+ readonly id: bigint | null;
1862
+ /**
1863
+ * An optional callback invoked when the stream is destroyed with an error.
1864
+ * This includes errors caused by user callbacks that throw or reject (see
1865
+ * [Callback error handling](https://nodejs.org/docs/latest-26.x/api/quic.html#callback-error-handling)). The callback receives a single argument: the
1866
+ * error that triggered the destruction. If the `onerror` callback itself throws
1867
+ * or returns a promise that rejects, the error is surfaced as an uncaught
1868
+ * exception. Read/write.
1869
+ * @since v26.2.0
1870
+ */
1871
+ onerror: ((this: QuicStream, error: any) => void) | undefined;
1872
+ /**
1873
+ * The callback to invoke when the stream is blocked. Read/write.
1874
+ * @since v23.8.0
1875
+ */
1876
+ onblocked: OnBlockedCallback | undefined;
1877
+ /**
1878
+ * The callback to invoke when the peer aborts a direction of the stream by
1879
+ * sending a `RESET_STREAM` frame (the peer abandons their writable side, so
1880
+ * no further data will arrive on our readable side) or a `STOP_SENDING`
1881
+ * frame (the peer asks us to stop writing on our writable side).
1882
+ *
1883
+ * The callback receives a Node.js error whose `errorCode` (`bigint`)
1884
+ * property carries the application error code from the wire frame.
1885
+ *
1886
+ * The stream is **not** automatically destroyed when this callback fires —
1887
+ * the application chooses how to react. Common patterns are: ignore (and
1888
+ * continue using the still-active direction on a bidirectional stream),
1889
+ * abort the other direction with `writer.fail()`, or tear down the
1890
+ * whole stream with `stream.destroy()`. Read/write.
1891
+ * @since v23.8.0
1892
+ */
1893
+ onreset: OnStreamErrorCallback | undefined;
1894
+ /**
1895
+ * The buffered initial headers received on this stream, or `undefined` if the
1896
+ * application does not support headers or no headers have been received yet.
1897
+ * For server-side streams, this contains the request headers (e.g., `:method`,
1898
+ * `:path`, `:scheme`). For client-side streams, this contains the response
1899
+ * headers (e.g., `:status`).
1900
+ *
1901
+ * Header names are lowercase strings. Multi-value headers are represented as
1902
+ * arrays. The object has `__proto__: null`.
1903
+ * @since v26.2.0
1904
+ */
1905
+ readonly headers: NodeJS.Dict<string | string[]> | undefined;
1906
+ /**
1907
+ * The callback to invoke when initial headers are received on the stream. The
1908
+ * callback receives `(headers)` where `headers` is an object (same format as
1909
+ * `stream.headers`). For HTTP/3, this delivers request pseudo-headers on the
1910
+ * server side and response headers on the client side. Throws
1911
+ * `ERR_INVALID_STATE` if set on a session that does not support headers.
1912
+ * Read/write.
1913
+ * @since v26.2.0
1914
+ */
1915
+ onheaders: ((this: QuicStream, headers: NodeJS.Dict<string | string[]>) => void) | undefined;
1916
+ /**
1917
+ * The callback to invoke when trailing headers are received from the peer.
1918
+ * The callback receives `(trailers)` where `trailers` is an object in the
1919
+ * same format as `stream.headers`. Throws `ERR_INVALID_STATE` if set on a
1920
+ * session that does not support headers. Read/write.
1921
+ * @since v26.2.0
1922
+ */
1923
+ ontrailers: ((this: QuicStream, trailers: NodeJS.Dict<string | string[]>) => void) | undefined;
1924
+ /**
1925
+ * The callback to invoke when informational (1xx) headers are received from
1926
+ * the server. The callback receives `(headers)` where `headers` is an object
1927
+ * in the same format as `stream.headers`. Informational headers are sent
1928
+ * before the final response (e.g., 103 Early Hints). Throws
1929
+ * `ERR_INVALID_STATE` if set on a session that does not support headers.
1930
+ * Read/write.
1931
+ * @since v26.2.0
1932
+ */
1933
+ oninfo: ((this: QuicStream, headers: NodeJS.Dict<string | string[]>) => void) | undefined;
1934
+ /**
1935
+ * The callback to invoke when the application is ready for trailing headers
1936
+ * to be sent. This is called synchronously — the user must call
1937
+ * `stream.sendTrailers()` within this callback. Throws
1938
+ * `ERR_INVALID_STATE` if set on a session that does not support headers.
1939
+ * Read/write.
1940
+ * @since v26.2.0
1941
+ */
1942
+ onwanttrailers: ((this: QuicStream) => void) | undefined;
1943
+ /**
1944
+ * Set trailing headers to be sent automatically when the application requests
1945
+ * them. This is an alternative to the `stream.onwanttrailers` callback
1946
+ * for cases where the trailers are known before the body completes. Throws
1947
+ * `ERR_INVALID_STATE` if set on a session that does not support headers.
1948
+ * Read/write.
1949
+ * @since v26.2.0
1950
+ */
1951
+ pendingTrailers: NodeJS.Dict<string | string[]> | undefined;
1952
+ /**
1953
+ * Sends initial or response headers on the stream. For client-side streams,
1954
+ * this sends request headers. For server-side streams, this sends response
1955
+ * headers. Throws `ERR_INVALID_STATE` if the session does not support headers.
1956
+ * @since v26.2.0
1957
+ * @param headers Header object with string keys and string or
1958
+ * string-array values. Pseudo-headers (`:method`, `:path`, etc.) must
1959
+ * appear before regular headers.
1960
+ */
1961
+ sendHeaders(headers: NodeJS.Dict<string | string[]>, options?: StreamSendHeadersOptions): boolean;
1962
+ /**
1963
+ * Sends informational (1xx) response headers. Server only. Throws
1964
+ * `ERR_INVALID_STATE` if the session does not support headers.
1965
+ * @since v26.2.0
1966
+ * @param headers Header object. Must include `:status` with a 1xx
1967
+ * value (e.g., `{ ':status': '103', 'link': '</style.css>; rel=preload' }`).
1968
+ */
1969
+ sendInformationalHeaders(headers: NodeJS.Dict<string | string[]>): boolean;
1970
+ /**
1971
+ * Sends trailing headers on the stream. Must be called synchronously during
1972
+ * the `stream.onwanttrailers` callback, or set ahead of time via
1973
+ * `stream.pendingTrailers`. Throws `ERR_INVALID_STATE` if the session
1974
+ * does not support headers.
1975
+ * @since v26.2.0
1976
+ * @param headers Trailing header object. Pseudo-headers must not be
1977
+ * included in trailers.
1978
+ */
1979
+ sendTrailers(headers: NodeJS.Dict<string | string[]>): boolean;
1980
+ /**
1981
+ * The current priority of the stream. Returns `null` if the session does not
1982
+ * support priority (e.g. non-HTTP/3) or if the stream has been destroyed.
1983
+ * Read only. Use `stream.setPriority()` to change the priority.
1984
+ *
1985
+ * On client-side HTTP/3 sessions, the value reflects what was set via
1986
+ * `stream.setPriority()`. On server-side HTTP/3 sessions, the value
1987
+ * reflects the peer's requested priority (e.g., from `PRIORITY_UPDATE` frames).
1988
+ * @since v26.2.0
1989
+ */
1990
+ readonly priority: StreamPriority | null;
1991
+ /**
1992
+ * Sets the priority of the stream. Throws `ERR_INVALID_STATE` if the session
1993
+ * does not support priority (e.g. non-HTTP/3). Has no effect if the stream
1994
+ * has been destroyed.
1995
+ * @since v26.2.0
1996
+ */
1997
+ setPriority(options?: NodeJS.PartialOptions<StreamPriority>): void;
1998
+ /**
1999
+ * The stream implements `Symbol.asyncIterator`, making it directly usable
2000
+ * in `for await...of` loops. Each iteration yields a batch of `Uint8Array`
2001
+ * chunks.
2002
+ *
2003
+ * Only one async iterator can be obtained per stream. A second call throws
2004
+ * `ERR_INVALID_STATE`. Non-readable streams (outbound-only unidirectional
2005
+ * or closed) return an immediately-finished iterator.
2006
+ *
2007
+ * ```js
2008
+ * for await (const chunks of stream) {
2009
+ * for (const chunk of chunks) {
2010
+ * // Process each Uint8Array chunk
2011
+ * }
2012
+ * }
2013
+ * ```
2014
+ *
2015
+ * Compatible with stream/iter utilities:
2016
+ *
2017
+ * ```js
2018
+ * import Stream from 'node:stream/iter';
2019
+ * const body = await Stream.bytes(stream);
2020
+ * const text = await Stream.text(stream);
2021
+ * await Stream.pipeTo(stream, someWriter);
2022
+ * ```
2023
+ * @since v26.2.0
2024
+ */
2025
+ [Symbol.asyncIterator](): NodeJS.AsyncIterator<NodeJS.NonSharedUint8Array[]>;
2026
+ /**
2027
+ * Returns a Writer object for pushing data to the stream incrementally.
2028
+ * The Writer implements the stream/iter Writer interface with the
2029
+ * try-sync-fallback-to-async pattern.
2030
+ *
2031
+ * Only available when no `body` source was provided at creation time or via
2032
+ * `stream.setBody()`. Non-writable streams return an already-closed
2033
+ * Writer. Throws `ERR_INVALID_STATE` if the outbound is already configured.
2034
+ *
2035
+ * The Writer has the following methods:
2036
+ *
2037
+ * * `writeSync(chunk)` — Synchronous write. Returns `true` if accepted,
2038
+ * `false` if flow-controlled. Data is NOT accepted on `false`.
2039
+ * * `write(chunk[, options])` — Async write with drain wait. `options.signal`
2040
+ * is checked at entry but not observed during the write.
2041
+ * * `writevSync(chunks)` — Synchronous vectored write. All-or-nothing.
2042
+ * * `writev(chunks[, options])` — Async vectored write.
2043
+ * * `endSync()` — Synchronous close. Returns total bytes or `-1`.
2044
+ * * `end([options])` — Async close.
2045
+ * * `fail(reason)` — Errors the stream (sends `RESET_STREAM` to peer).
2046
+ * When `reason` is a `QuicError`, its `error.errorCode` is used
2047
+ * as the wire code on the resulting `RESET_STREAM` frame; otherwise
2048
+ * the wire code falls back to the negotiated application protocol's
2049
+ * "internal error" code (`H3_INTERNAL_ERROR` (`0x102`) for HTTP/3, or
2050
+ * the QUIC transport-layer `INTERNAL_ERROR` (`0x1`) for raw QUIC).
2051
+ * See `stream.destroy()` for a full-stream abort that also resets
2052
+ * the readable side via `STOP_SENDING`.
2053
+ * * `desiredSize` — Available capacity in bytes, or `null` if closed/errored.
2054
+ *
2055
+ * The bytes from each `writeSync()` / `writevSync()` / `write()` / `writev()`
2056
+ * input chunk are copied into an internal buffer, so the caller's source
2057
+ * buffer is unchanged and may be reused or mutated immediately after the
2058
+ * call returns. Callers that want to ensure a source buffer cannot be
2059
+ * mutated after handing it off can call `ArrayBuffer.prototype.transfer()`
2060
+ * themselves before passing the buffer.
2061
+ * @since v26.2.0
2062
+ */
2063
+ readonly writer: Writer;
2064
+ /**
2065
+ * Sets the outbound body source for the stream. Can only be called once.
2066
+ * Mutually exclusive with `stream.writer`.
2067
+ *
2068
+ * The following body source types are supported:
2069
+ *
2070
+ * * `null` — The writable side is closed immediately (FIN sent with no data).
2071
+ * * `string` — UTF-8 encoded and sent as a single chunk.
2072
+ * * `ArrayBuffer`, `SharedArrayBuffer`, `ArrayBufferView` — Sent as a single
2073
+ * chunk. The bytes are copied into an internal buffer, so the caller's
2074
+ * source buffer is unchanged and may be reused or mutated immediately
2075
+ * after the call returns. Callers wanting to ensure their source cannot
2076
+ * be mutated after handing it off can call
2077
+ * `ArrayBuffer.prototype.transfer()` themselves before passing the buffer.
2078
+ * * `Blob` — Sent from the Blob's underlying data queue.
2079
+ * * {FileHandle} — The file contents are read asynchronously via an
2080
+ * fd-backed data source. The `FileHandle` must be opened for reading
2081
+ * (e.g. via [`fs.promises.open(path, 'r')`][]). Once passed as a body, the
2082
+ * `FileHandle` is locked and cannot be used as a body for another stream.
2083
+ * The `FileHandle` is automatically closed when the stream finishes.
2084
+ * * `AsyncIterable`, `Iterable` — Each yielded chunk (string or
2085
+ * `Uint8Array`) is written incrementally in streaming mode.
2086
+ * * `Promise` — Awaited; the resolved value is used as the body (subject
2087
+ * to the same type rules).
2088
+ *
2089
+ * Throws `ERR_INVALID_STATE` if the outbound is already configured or if
2090
+ * the writer has been accessed.
2091
+ * @since v26.2.0
2092
+ */
2093
+ setBody(body: StreamBody): void;
2094
+ /**
2095
+ * The session that created this stream, or `null` if the stream has been
2096
+ * destroyed. Read only.
2097
+ * @since v23.8.0
2098
+ */
2099
+ readonly session: QuicSession | null;
2100
+ /**
2101
+ * The current statistics for the stream. Read only.
2102
+ * @since v23.8.0
2103
+ */
2104
+ readonly stats: QuicStream.Stats;
2105
+ }
2106
+ namespace QuicStream {
2107
+ /**
2108
+ * @since v23.8.0
2109
+ */
2110
+ class Stats {
2111
+ private constructor();
2112
+ /**
2113
+ * @since v23.8.0
2114
+ */
2115
+ readonly ackedAt: bigint;
2116
+ /**
2117
+ * @since v23.8.0
2118
+ */
2119
+ readonly bytesReceived: bigint;
2120
+ /**
2121
+ * @since v23.8.0
2122
+ */
2123
+ readonly bytesSent: bigint;
2124
+ /**
2125
+ * @since v23.8.0
2126
+ */
2127
+ readonly createdAt: bigint;
2128
+ /**
2129
+ * @since v23.8.0
2130
+ */
2131
+ readonly destroyedAt: bigint;
2132
+ /**
2133
+ * @since v23.8.0
2134
+ */
2135
+ readonly finalSize: bigint;
2136
+ /**
2137
+ * @since v23.8.0
2138
+ */
2139
+ readonly isConnected: bigint;
2140
+ /**
2141
+ * @since v23.8.0
2142
+ */
2143
+ readonly maxOffset: bigint;
2144
+ /**
2145
+ * @since v23.8.0
2146
+ */
2147
+ readonly maxOffsetAcknowledged: bigint;
2148
+ /**
2149
+ * @since v23.8.0
2150
+ */
2151
+ readonly maxOffsetReceived: bigint;
2152
+ /**
2153
+ * @since v23.8.0
2154
+ */
2155
+ readonly openedAt: bigint;
2156
+ /**
2157
+ * @since v23.8.0
2158
+ */
2159
+ readonly receivedAt: bigint;
2160
+ }
2161
+ }
2162
+ /**
2163
+ * An object containing commonly used constants for QUIC configuration.
2164
+ * @since v26.2.0
2165
+ */
2166
+ namespace constants {
2167
+ /**
2168
+ * Congestion control algorithm identifiers, for use with the
2169
+ * `sessionOptions.cc` option:
2170
+ *
2171
+ * * `quic.constants.cc.RENO` — Reno congestion control.
2172
+ * * `quic.constants.cc.CUBIC` — CUBIC congestion control.
2173
+ * * `quic.constants.cc.BBR` — BBR congestion control.
2174
+ */
2175
+ enum cc {
2176
+ RENO = "reno",
2177
+ CUBIC = "cubic",
2178
+ BBR = "bbr",
2179
+ }
2180
+ /**
2181
+ * The default TLS 1.3 cipher suite list used when `sessionOptions.ciphers`
2182
+ * is not specified.
2183
+ */
2184
+ const DEFAULT_CIPHERS: string;
2185
+ /**
2186
+ * The default TLS 1.3 key-exchange group list used when
2187
+ * `sessionOptions.groups` is not specified.
2188
+ */
2189
+ const DEFAULT_GROUPS: string;
2190
+ }
2191
+ }