@encharm/cws 4.4.1 → 4.5.2

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 (606) hide show
  1. package/binding.gyp +1 -1
  2. package/dist/bindings/cws_darwin_arm64_node115.node +0 -0
  3. package/dist/bindings/cws_darwin_arm64_node127.node +0 -0
  4. package/dist/bindings/cws_darwin_arm64_node137.node +0 -0
  5. package/dist/bindings/cws_linux_arm64_node115.node +0 -0
  6. package/dist/bindings/cws_linux_arm64_node127.node +0 -0
  7. package/dist/bindings/cws_linux_x64_node115.node +0 -0
  8. package/dist/bindings/cws_linux_x64_node127.node +0 -0
  9. package/dist/bindings/cws_linux_x64_node137.node +0 -0
  10. package/dist/bindings/cws_win32_x64_node108.node +0 -0
  11. package/dist/bindings/cws_win32_x64_node115.node +0 -0
  12. package/dist/bindings/cws_win32_x64_node127.node +0 -0
  13. package/dist/bindings/cws_win32_x64_node83.node +0 -0
  14. package/dist/bindings/cws_win32_x64_node93.node +0 -0
  15. package/package.json +1 -1
  16. package/src/Addon.h +13 -23
  17. package/src/Socket.h +0 -1
  18. package/src/headers/22/acorn_version.h +6 -0
  19. package/src/headers/22/aliased_buffer-inl.h +243 -0
  20. package/src/headers/22/aliased_buffer.h +206 -0
  21. package/src/headers/{18 → 22}/async_wrap-inl.h +8 -6
  22. package/src/headers/{18 → 22}/async_wrap.h +65 -59
  23. package/src/headers/{18 → 22}/base_object-inl.h +57 -117
  24. package/src/headers/{18 → 22}/base_object.h +58 -30
  25. package/src/headers/22/base_object_types.h +74 -0
  26. package/src/headers/22/blob_serializer_deserializer-inl.h +385 -0
  27. package/src/headers/22/blob_serializer_deserializer.h +132 -0
  28. package/src/headers/{16 → 22}/callback_queue.h +1 -0
  29. package/src/headers/{16 → 22}/cares_wrap.h +27 -20
  30. package/src/headers/22/cjs_module_lexer_version.h +6 -0
  31. package/src/headers/22/cleanup_queue-inl.h +62 -0
  32. package/src/headers/22/cleanup_queue.h +85 -0
  33. package/src/headers/22/compile_cache.h +104 -0
  34. package/src/headers/{18 → 22}/crypto/crypto_clienthello.h +1 -1
  35. package/src/headers/{18 → 22}/crypto/crypto_context.h +31 -7
  36. package/src/headers/{18 → 22}/crypto/crypto_keys.h +118 -148
  37. package/src/headers/{18 → 22}/crypto/crypto_tls.h +20 -5
  38. package/src/headers/{18 → 22}/crypto/crypto_util.h +219 -263
  39. package/src/headers/22/crypto/ncrypto.h +752 -0
  40. package/src/headers/{16 → 22}/debug_utils-inl.h +15 -7
  41. package/src/headers/{18 → 22}/debug_utils.h +25 -19
  42. package/src/headers/22/encoding_binding.h +59 -0
  43. package/src/headers/{14 → 22}/env-inl.h +276 -409
  44. package/src/headers/22/env.h +1266 -0
  45. package/src/headers/22/env_properties.h +497 -0
  46. package/src/headers/{18 → 22}/handle_wrap.h +2 -0
  47. package/src/headers/{18 → 22}/histogram.h +88 -48
  48. package/src/headers/{16 → 22}/inspector_agent.h +17 -1
  49. package/src/headers/{16 → 22}/inspector_profiler.h +15 -13
  50. package/src/headers/22/js_native_api.h +619 -0
  51. package/src/headers/{18 → 22}/js_native_api_types.h +46 -1
  52. package/src/headers/22/js_native_api_v8.h +485 -0
  53. package/src/headers/{18 → 22}/js_native_api_v8_internals.h +6 -0
  54. package/src/headers/22/json_parser.h +40 -0
  55. package/src/headers/{16 → 22}/json_utils.h +19 -8
  56. package/src/headers/{18 → 22}/memory_tracker-inl.h +16 -13
  57. package/src/headers/{14 → 22}/memory_tracker.h +13 -8
  58. package/src/headers/{16 → 22}/module_wrap.h +49 -19
  59. package/src/headers/22/ncrypto/ncrypto.h +752 -0
  60. package/src/headers/{18 → 22}/node.h +465 -68
  61. package/src/headers/{18 → 22}/node_api.h +66 -81
  62. package/src/headers/{18 → 22}/node_api_internals.h +8 -4
  63. package/src/headers/{18 → 22}/node_api_types.h +5 -0
  64. package/src/headers/22/node_binding.h +154 -0
  65. package/src/headers/{18 → 22}/node_blob.h +46 -78
  66. package/src/headers/{18 → 22}/node_bob-inl.h +1 -2
  67. package/src/headers/{18 → 22}/node_bob.h +2 -6
  68. package/src/headers/{18 → 22}/node_buffer.h +1 -1
  69. package/src/headers/22/node_builtins.h +220 -0
  70. package/src/headers/{18 → 22}/node_constants.h +3 -5
  71. package/src/headers/22/node_context_data.h +168 -0
  72. package/src/headers/22/node_contextify.h +199 -0
  73. package/src/headers/{16 → 22}/node_crypto.h +1 -2
  74. package/src/headers/22/node_dotenv.h +45 -0
  75. package/src/headers/{18 → 22}/node_errors.h +86 -27
  76. package/src/headers/22/node_exit_code.h +54 -0
  77. package/src/headers/22/node_external_reference.h +249 -0
  78. package/src/headers/{18 → 22}/node_file-inl.h +127 -30
  79. package/src/headers/{16 → 22}/node_file.h +122 -11
  80. package/src/headers/{18 → 22}/node_http2.h +28 -11
  81. package/src/headers/{16 → 22}/node_http2_state.h +34 -25
  82. package/src/headers/{18 → 22}/node_http_common-inl.h +2 -1
  83. package/src/headers/{18 → 22}/node_http_common.h +56 -55
  84. package/src/headers/{16 → 22}/node_i18n.h +5 -18
  85. package/src/headers/{18 → 22}/node_internals.h +121 -59
  86. package/src/headers/{18 → 22}/node_main_instance.h +4 -31
  87. package/src/headers/{18 → 22}/node_messaging.h +27 -10
  88. package/src/headers/{18 → 22}/node_metadata.h +23 -1
  89. package/src/headers/{18 → 22}/node_options-inl.h +24 -11
  90. package/src/headers/{18 → 22}/node_options.h +124 -39
  91. package/src/headers/{18 → 22}/node_perf.h +0 -2
  92. package/src/headers/{18 → 22}/node_perf_common.h +20 -9
  93. package/src/headers/{18 → 22}/node_platform.h +11 -5
  94. package/src/headers/{18 → 22}/node_process.h +26 -14
  95. package/src/headers/22/node_realm-inl.h +145 -0
  96. package/src/headers/22/node_realm.h +184 -0
  97. package/src/headers/{16 → 22}/node_report.h +13 -17
  98. package/src/headers/{16 → 22}/node_revert.h +3 -3
  99. package/src/headers/{16 → 22}/node_root_certs.h +902 -461
  100. package/src/headers/22/node_sea.h +64 -0
  101. package/src/headers/22/node_shadow_realm.h +46 -0
  102. package/src/headers/22/node_snapshot_builder.h +57 -0
  103. package/src/headers/22/node_snapshotable.h +174 -0
  104. package/src/headers/{18 → 22}/node_sockaddr.h +2 -2
  105. package/src/headers/{16 → 22}/node_stat_watcher.h +2 -1
  106. package/src/headers/22/node_threadsafe_cow-inl.h +54 -0
  107. package/src/headers/22/node_threadsafe_cow.h +105 -0
  108. package/src/headers/22/node_union_bytes.h +81 -0
  109. package/src/headers/22/node_url.h +96 -0
  110. package/src/headers/22/node_v8.h +77 -0
  111. package/src/headers/{14 → 22}/node_v8_platform-inl.h +17 -6
  112. package/src/headers/{16 → 22}/node_version.h +21 -9
  113. package/src/headers/22/node_wasi.h +185 -0
  114. package/src/headers/{14 → 22}/node_watchdog.h +2 -0
  115. package/src/headers/{18 → 22}/node_worker.h +7 -2
  116. package/src/headers/22/permission/child_process_permission.h +31 -0
  117. package/src/headers/22/permission/fs_permission.h +167 -0
  118. package/src/headers/22/permission/inspector_permission.h +31 -0
  119. package/src/headers/22/permission/permission.h +99 -0
  120. package/src/headers/22/permission/permission_base.h +60 -0
  121. package/src/headers/22/permission/wasi_permission.h +31 -0
  122. package/src/headers/22/permission/worker_permission.h +31 -0
  123. package/src/headers/{16 → 22}/req_wrap-inl.h +7 -6
  124. package/src/headers/{14 → 22}/spawn_sync.h +3 -3
  125. package/src/headers/{18 → 22}/stream_base-inl.h +0 -135
  126. package/src/headers/{18 → 22}/stream_base.h +35 -16
  127. package/src/headers/{18 → 22}/stream_pipe.h +3 -4
  128. package/src/headers/{16 → 22}/stream_wrap.h +2 -1
  129. package/src/headers/{18 → 22}/string_bytes.h +5 -14
  130. package/src/headers/{14 → 22}/string_decoder-inl.h +0 -6
  131. package/src/headers/{16 → 22}/string_decoder.h +0 -1
  132. package/src/headers/{18 → 22}/tcp_wrap.h +1 -1
  133. package/src/headers/{18 → 22}/threadpoolwork-inl.h +14 -1
  134. package/src/headers/22/timers.h +76 -0
  135. package/src/headers/{18 → 22}/tracing/trace_event.h +7 -5
  136. package/src/headers/{16 → 22}/udp_wrap.h +8 -5
  137. package/src/headers/22/undici_version.h +6 -0
  138. package/src/headers/{18 → 22}/util-inl.h +97 -127
  139. package/src/headers/{18 → 22}/util.h +293 -106
  140. package/src/headers/{18 → 22}/v8-fast-api-calls.h +103 -58
  141. package/src/headers/24/acorn_version.h +6 -0
  142. package/src/headers/24/addon_permission.h +31 -0
  143. package/src/headers/{16/tracing → 24}/agent.h +1 -1
  144. package/src/headers/24/aliased_buffer-inl.h +244 -0
  145. package/src/headers/24/aliased_buffer.h +206 -0
  146. package/src/headers/24/amaro_version.h +6 -0
  147. package/src/headers/24/application.h +165 -0
  148. package/src/headers/24/async_context_frame.h +33 -0
  149. package/src/headers/{14 → 24}/async_wrap-inl.h +8 -6
  150. package/src/headers/{16 → 24}/async_wrap.h +86 -88
  151. package/src/headers/{16 → 24}/base_object-inl.h +75 -119
  152. package/src/headers/{16 → 24}/base_object.h +84 -40
  153. package/src/headers/24/base_object_types.h +74 -0
  154. package/src/headers/24/bindingdata.h +272 -0
  155. package/src/headers/24/blob_serializer_deserializer-inl.h +385 -0
  156. package/src/headers/24/blob_serializer_deserializer.h +132 -0
  157. package/src/headers/{18 → 24}/callback_queue.h +1 -0
  158. package/src/headers/{18 → 24}/cares_wrap.h +68 -144
  159. package/src/headers/24/child_process_permission.h +31 -0
  160. package/src/headers/24/cid.h +127 -0
  161. package/src/headers/24/cjs_module_lexer_version.h +6 -0
  162. package/src/headers/24/cleanup_queue-inl.h +36 -0
  163. package/src/headers/24/cleanup_queue.h +79 -0
  164. package/src/headers/24/compile_cache.h +113 -0
  165. package/src/headers/24/cppgc_helpers-inl.h +65 -0
  166. package/src/headers/24/cppgc_helpers.h +162 -0
  167. package/src/headers/24/crypto/crypto_aes.h +97 -0
  168. package/src/headers/24/crypto/crypto_argon2.h +86 -0
  169. package/src/headers/{16 → 24}/crypto/crypto_bio.h +8 -9
  170. package/src/headers/24/crypto/crypto_chacha20_poly1305.h +64 -0
  171. package/src/headers/{18 → 24}/crypto/crypto_cipher.h +48 -58
  172. package/src/headers/{16 → 24}/crypto/crypto_clienthello-inl.h +2 -2
  173. package/src/headers/{16 → 24}/crypto/crypto_clienthello.h +1 -1
  174. package/src/headers/24/crypto/crypto_common.h +48 -0
  175. package/src/headers/{16 → 24}/crypto/crypto_context.h +46 -22
  176. package/src/headers/{18 → 24}/crypto/crypto_dh.h +27 -57
  177. package/src/headers/{18 → 24}/crypto/crypto_dsa.h +7 -34
  178. package/src/headers/{18 → 24}/crypto/crypto_ec.h +42 -49
  179. package/src/headers/{18 → 24}/crypto/crypto_hash.h +11 -11
  180. package/src/headers/{18 → 24}/crypto/crypto_hkdf.h +10 -14
  181. package/src/headers/{18 → 24}/crypto/crypto_hmac.h +11 -13
  182. package/src/headers/24/crypto/crypto_kem.h +113 -0
  183. package/src/headers/{18 → 24}/crypto/crypto_keygen.h +59 -74
  184. package/src/headers/{16 → 24}/crypto/crypto_keys.h +134 -154
  185. package/src/headers/24/crypto/crypto_ml_dsa.h +21 -0
  186. package/src/headers/{18 → 24}/crypto/crypto_pbkdf2.h +9 -11
  187. package/src/headers/{18 → 24}/crypto/crypto_random.h +28 -34
  188. package/src/headers/{18 → 24}/crypto/crypto_rsa.h +30 -35
  189. package/src/headers/{18 → 24}/crypto/crypto_scrypt.h +8 -10
  190. package/src/headers/{18 → 24}/crypto/crypto_sig.h +36 -48
  191. package/src/headers/{16 → 24}/crypto/crypto_tls.h +35 -18
  192. package/src/headers/{16 → 24}/crypto/crypto_util.h +183 -321
  193. package/src/headers/24/crypto/crypto_x509.h +140 -0
  194. package/src/headers/24/data.h +148 -0
  195. package/src/headers/{14 → 24}/debug_utils-inl.h +17 -8
  196. package/src/headers/{16 → 24}/debug_utils.h +31 -22
  197. package/src/headers/24/defs.h +254 -0
  198. package/src/headers/24/embedded_data.h +17 -0
  199. package/src/headers/24/encoding_binding.h +60 -0
  200. package/src/headers/24/endpoint.h +421 -0
  201. package/src/headers/{16 → 24}/env-inl.h +198 -540
  202. package/src/headers/24/env.h +1257 -0
  203. package/src/headers/24/env_properties.h +561 -0
  204. package/src/headers/24/fs_permission.h +167 -0
  205. package/src/headers/{16 → 24}/handle_wrap.h +4 -2
  206. package/src/headers/{16 → 24}/histogram-inl.h +34 -15
  207. package/src/headers/24/histogram.h +279 -0
  208. package/src/headers/24/http3.h +44 -0
  209. package/src/headers/{18 → 24}/inspector_agent.h +23 -2
  210. package/src/headers/24/inspector_permission.h +31 -0
  211. package/src/headers/{18 → 24}/inspector_profiler.h +15 -15
  212. package/src/headers/24/io_agent.h +30 -0
  213. package/src/headers/{18 → 24}/js_native_api.h +74 -30
  214. package/src/headers/{16 → 24}/js_native_api_types.h +61 -10
  215. package/src/headers/{18 → 24}/js_native_api_v8.h +205 -160
  216. package/src/headers/{16 → 24}/js_native_api_v8_internals.h +12 -6
  217. package/src/headers/24/json_parser.h +40 -0
  218. package/src/headers/{18 → 24}/json_utils.h +19 -8
  219. package/src/headers/24/logstream.h +81 -0
  220. package/src/headers/24/main_thread_interface.h +116 -0
  221. package/src/headers/{16 → 24}/memory_tracker-inl.h +115 -17
  222. package/src/headers/{16 → 24}/memory_tracker.h +58 -9
  223. package/src/headers/24/module_wrap.h +229 -0
  224. package/src/headers/24/ncrypto.h +1625 -0
  225. package/src/headers/24/network_agent.h +118 -0
  226. package/src/headers/24/network_inspector.h +45 -0
  227. package/src/headers/24/network_resource_manager.h +29 -0
  228. package/src/headers/{16 → 24}/node.h +560 -72
  229. package/src/headers/24/node_api.h +269 -0
  230. package/src/headers/24/node_api_internals.h +46 -0
  231. package/src/headers/{16 → 24}/node_api_types.h +13 -11
  232. package/src/headers/24/node_binding.h +163 -0
  233. package/src/headers/{16 → 24}/node_blob.h +46 -78
  234. package/src/headers/{16 → 24}/node_bob-inl.h +1 -2
  235. package/src/headers/{16 → 24}/node_bob.h +2 -6
  236. package/src/headers/{14 → 24}/node_buffer.h +1 -1
  237. package/src/headers/24/node_builtins.h +223 -0
  238. package/src/headers/24/node_config_file.h +65 -0
  239. package/src/headers/{14 → 24}/node_constants.h +3 -5
  240. package/src/headers/24/node_context_data.h +168 -0
  241. package/src/headers/24/node_contextify.h +261 -0
  242. package/src/headers/{18 → 24}/node_crypto.h +7 -2
  243. package/src/headers/24/node_debug.h +25 -0
  244. package/src/headers/24/node_dotenv.h +45 -0
  245. package/src/headers/{16 → 24}/node_errors.h +146 -32
  246. package/src/headers/24/node_exit_code.h +54 -0
  247. package/src/headers/{18 → 24}/node_external_reference.h +44 -22
  248. package/src/headers/{16 → 24}/node_file-inl.h +156 -50
  249. package/src/headers/{18 → 24}/node_file.h +129 -15
  250. package/src/headers/{16 → 24}/node_http2.h +53 -18
  251. package/src/headers/{14 → 24}/node_http2_state.h +35 -25
  252. package/src/headers/{16 → 24}/node_http_common-inl.h +8 -10
  253. package/src/headers/{16 → 24}/node_http_common.h +63 -59
  254. package/src/headers/{18 → 24}/node_i18n.h +5 -18
  255. package/src/headers/{16 → 24}/node_internals.h +131 -76
  256. package/src/headers/24/node_json.h +24 -0
  257. package/src/headers/24/node_large_page.h +34 -0
  258. package/src/headers/24/node_locks.h +180 -0
  259. package/src/headers/{14 → 24}/node_main_instance.h +15 -44
  260. package/src/headers/{16 → 24}/node_mem-inl.h +7 -7
  261. package/src/headers/{16 → 24}/node_messaging.h +27 -11
  262. package/src/headers/{16 → 24}/node_metadata.h +44 -2
  263. package/src/headers/24/node_modules.h +93 -0
  264. package/src/headers/{16 → 24}/node_options-inl.h +93 -46
  265. package/src/headers/{16 → 24}/node_options.h +251 -63
  266. package/src/headers/{16 → 24}/node_perf.h +6 -25
  267. package/src/headers/{16 → 24}/node_perf_common.h +23 -10
  268. package/src/headers/24/node_platform.h +286 -0
  269. package/src/headers/24/node_process.h +111 -0
  270. package/src/headers/24/node_realm-inl.h +153 -0
  271. package/src/headers/24/node_realm.h +236 -0
  272. package/src/headers/{18 → 24}/node_report.h +13 -17
  273. package/src/headers/{18 → 24}/node_revert.h +3 -3
  274. package/src/headers/{18 → 24}/node_root_certs.h +1010 -710
  275. package/src/headers/24/node_sea.h +74 -0
  276. package/src/headers/24/node_shadow_realm.h +46 -0
  277. package/src/headers/24/node_snapshot_builder.h +57 -0
  278. package/src/headers/24/node_snapshotable.h +174 -0
  279. package/src/headers/{16 → 24}/node_sockaddr-inl.h +11 -20
  280. package/src/headers/{16 → 24}/node_sockaddr.h +9 -20
  281. package/src/headers/24/node_sqlite.h +270 -0
  282. package/src/headers/{18 → 24}/node_stat_watcher.h +2 -1
  283. package/src/headers/24/node_string.h +101 -0
  284. package/src/headers/24/node_task_runner.h +92 -0
  285. package/src/headers/24/node_threadsafe_cow-inl.h +54 -0
  286. package/src/headers/24/node_threadsafe_cow.h +105 -0
  287. package/src/headers/24/node_union_bytes.h +81 -0
  288. package/src/headers/24/node_url.h +101 -0
  289. package/src/headers/24/node_url_pattern.h +118 -0
  290. package/src/headers/24/node_v8.h +77 -0
  291. package/src/headers/{18 → 24}/node_v8_platform-inl.h +22 -31
  292. package/src/headers/{18 → 24}/node_version.h +18 -6
  293. package/src/headers/24/node_wasi.h +185 -0
  294. package/src/headers/24/node_wasm_web_api.h +55 -0
  295. package/src/headers/{18 → 24}/node_watchdog.h +2 -0
  296. package/src/headers/24/node_webstorage.h +60 -0
  297. package/src/headers/{16 → 24}/node_worker.h +24 -10
  298. package/src/headers/24/packet.h +155 -0
  299. package/src/headers/24/path.h +33 -0
  300. package/src/headers/24/permission/addon_permission.h +31 -0
  301. package/src/headers/24/permission/child_process_permission.h +31 -0
  302. package/src/headers/24/permission/fs_permission.h +167 -0
  303. package/src/headers/24/permission/inspector_permission.h +31 -0
  304. package/src/headers/24/permission/permission.h +100 -0
  305. package/src/headers/24/permission/permission_base.h +65 -0
  306. package/src/headers/24/permission/wasi_permission.h +31 -0
  307. package/src/headers/24/permission/worker_permission.h +31 -0
  308. package/src/headers/24/permission.h +100 -0
  309. package/src/headers/24/permission_base.h +65 -0
  310. package/src/headers/24/preferredaddress.h +72 -0
  311. package/src/headers/24/protocol_helper.h +27 -0
  312. package/src/headers/24/queue.h +306 -0
  313. package/src/headers/{18 → 24}/req_wrap-inl.h +12 -6
  314. package/src/headers/{16 → 24}/req_wrap.h +3 -1
  315. package/src/headers/24/runtime_agent.h +41 -0
  316. package/src/headers/24/session.h +528 -0
  317. package/src/headers/24/sessionticket.h +108 -0
  318. package/src/headers/{18 → 24}/spawn_sync.h +9 -8
  319. package/src/headers/{16 → 24}/stream_base-inl.h +3 -133
  320. package/src/headers/{16 → 24}/stream_base.h +43 -19
  321. package/src/headers/{16 → 24}/stream_pipe.h +7 -4
  322. package/src/headers/{18 → 24}/stream_wrap.h +2 -3
  323. package/src/headers/24/streams.h +370 -0
  324. package/src/headers/{16 → 24}/string_bytes.h +8 -21
  325. package/src/headers/{18 → 24}/string_decoder-inl.h +0 -6
  326. package/src/headers/{18 → 24}/string_decoder.h +0 -1
  327. package/src/headers/24/target_agent.h +75 -0
  328. package/src/headers/{16 → 24}/tcp_wrap.h +3 -1
  329. package/src/headers/{14 → 24}/threadpoolwork-inl.h +14 -1
  330. package/src/headers/24/timer_wrap-inl.h +32 -0
  331. package/src/headers/{16 → 24}/timer_wrap.h +7 -4
  332. package/src/headers/24/timers.h +75 -0
  333. package/src/headers/24/tlscontext.h +228 -0
  334. package/src/headers/24/tokens.h +256 -0
  335. package/src/headers/{14/tracing → 24}/trace_event.h +7 -5
  336. package/src/headers/24/traced_value.h +129 -0
  337. package/src/headers/24/tracing_agent.h +43 -0
  338. package/src/headers/24/transportparams.h +166 -0
  339. package/src/headers/{16 → 24}/tty_wrap.h +0 -1
  340. package/src/headers/{18 → 24}/udp_wrap.h +8 -5
  341. package/src/headers/24/undici_version.h +6 -0
  342. package/src/headers/{16 → 24}/util-inl.h +267 -131
  343. package/src/headers/{16 → 24}/util.h +338 -146
  344. package/src/headers/24/v8-external-memory-accounter.h +60 -0
  345. package/src/headers/24/v8-fast-api-calls.h +819 -0
  346. package/src/headers/24/v8-inspector.h +426 -0
  347. package/src/headers/24/wasi_permission.h +31 -0
  348. package/src/headers/24/worker_agent.h +40 -0
  349. package/src/headers/24/worker_inspector.h +124 -0
  350. package/src/headers/24/worker_permission.h +31 -0
  351. package/src/headers/24/zlib_version.h +6 -0
  352. package/dist/bindings/cws_darwin_arm64_node83.node +0 -0
  353. package/dist/bindings/cws_darwin_arm64_node93.node +0 -0
  354. package/dist/bindings/cws_darwin_x64_node83.node +0 -0
  355. package/dist/bindings/cws_darwin_x64_node93.node +0 -0
  356. package/dist/bindings/cws_linux_arm64_node83.node +0 -0
  357. package/dist/bindings/cws_linux_arm64_node93.node +0 -0
  358. package/dist/bindings/cws_linux_x64_node83.node +0 -0
  359. package/dist/bindings/cws_linux_x64_node93.node +0 -0
  360. package/src/headers/14/aliased_buffer.h +0 -263
  361. package/src/headers/14/allocated_buffer-inl.h +0 -110
  362. package/src/headers/14/allocated_buffer.h +0 -73
  363. package/src/headers/14/async_wrap.h +0 -230
  364. package/src/headers/14/base64.h +0 -183
  365. package/src/headers/14/base_object-inl.h +0 -371
  366. package/src/headers/14/base_object.h +0 -281
  367. package/src/headers/14/callback_queue-inl.h +0 -97
  368. package/src/headers/14/callback_queue.h +0 -78
  369. package/src/headers/14/debug_utils.h +0 -181
  370. package/src/headers/14/env.h +0 -1388
  371. package/src/headers/14/handle_wrap.h +0 -117
  372. package/src/headers/14/histogram-inl.h +0 -83
  373. package/src/headers/14/histogram.h +0 -98
  374. package/src/headers/14/inspector_agent.h +0 -149
  375. package/src/headers/14/inspector_profiler.h +0 -137
  376. package/src/headers/14/js_native_api.h +0 -544
  377. package/src/headers/14/js_native_api_types.h +0 -143
  378. package/src/headers/14/js_native_api_v8.h +0 -301
  379. package/src/headers/14/js_native_api_v8_internals.h +0 -38
  380. package/src/headers/14/json_utils.h +0 -161
  381. package/src/headers/14/memory_tracker-inl.h +0 -355
  382. package/src/headers/14/module_wrap.h +0 -99
  383. package/src/headers/14/node.h +0 -1032
  384. package/src/headers/14/node_api.h +0 -255
  385. package/src/headers/14/node_api_types.h +0 -44
  386. package/src/headers/14/node_binding.h +0 -99
  387. package/src/headers/14/node_context_data.h +0 -44
  388. package/src/headers/14/node_contextify.h +0 -161
  389. package/src/headers/14/node_crypto.h +0 -865
  390. package/src/headers/14/node_crypto_bio.h +0 -195
  391. package/src/headers/14/node_crypto_clienthello-inl.h +0 -91
  392. package/src/headers/14/node_crypto_clienthello.h +0 -132
  393. package/src/headers/14/node_crypto_common.h +0 -138
  394. package/src/headers/14/node_crypto_groups.h +0 -415
  395. package/src/headers/14/node_dtrace.h +0 -86
  396. package/src/headers/14/node_errors.h +0 -214
  397. package/src/headers/14/node_file-inl.h +0 -306
  398. package/src/headers/14/node_file.h +0 -417
  399. package/src/headers/14/node_http2.h +0 -1191
  400. package/src/headers/14/node_http_common-inl.h +0 -194
  401. package/src/headers/14/node_http_common.h +0 -529
  402. package/src/headers/14/node_i18n.h +0 -144
  403. package/src/headers/14/node_internals.h +0 -405
  404. package/src/headers/14/node_mem.h +0 -45
  405. package/src/headers/14/node_messaging.h +0 -303
  406. package/src/headers/14/node_metadata.h +0 -109
  407. package/src/headers/14/node_mutex.h +0 -247
  408. package/src/headers/14/node_native_module.h +0 -101
  409. package/src/headers/14/node_native_module_env.h +0 -66
  410. package/src/headers/14/node_options-inl.h +0 -451
  411. package/src/headers/14/node_options.h +0 -481
  412. package/src/headers/14/node_perf.h +0 -181
  413. package/src/headers/14/node_perf_common.h +0 -97
  414. package/src/headers/14/node_platform.h +0 -189
  415. package/src/headers/14/node_process.h +0 -40
  416. package/src/headers/14/node_report.h +0 -47
  417. package/src/headers/14/node_revert.h +0 -72
  418. package/src/headers/14/node_root_certs.h +0 -3458
  419. package/src/headers/14/node_sockaddr-inl.h +0 -170
  420. package/src/headers/14/node_sockaddr.h +0 -123
  421. package/src/headers/14/node_stat_watcher.h +0 -70
  422. package/src/headers/14/node_union_bytes.h +0 -103
  423. package/src/headers/14/node_url.h +0 -188
  424. package/src/headers/14/node_version.h +0 -98
  425. package/src/headers/14/node_wasi.h +0 -108
  426. package/src/headers/14/node_win32_etw_provider-inl.h +0 -287
  427. package/src/headers/14/node_win32_etw_provider.h +0 -99
  428. package/src/headers/14/node_worker.h +0 -141
  429. package/src/headers/14/pipe_wrap.h +0 -78
  430. package/src/headers/14/req_wrap-inl.h +0 -170
  431. package/src/headers/14/req_wrap.h +0 -77
  432. package/src/headers/14/stream_base-inl.h +0 -275
  433. package/src/headers/14/stream_base.h +0 -434
  434. package/src/headers/14/stream_pipe.h +0 -73
  435. package/src/headers/14/stream_wrap.h +0 -130
  436. package/src/headers/14/string_bytes.h +0 -129
  437. package/src/headers/14/string_decoder.h +0 -50
  438. package/src/headers/14/string_search.h +0 -638
  439. package/src/headers/14/tcp_wrap.h +0 -101
  440. package/src/headers/14/tls_wrap.h +0 -222
  441. package/src/headers/14/tracing/agent.h +0 -195
  442. package/src/headers/14/tracing/traced_value.h +0 -70
  443. package/src/headers/14/tty_wrap.h +0 -64
  444. package/src/headers/14/udp_wrap.h +0 -227
  445. package/src/headers/14/util-inl.h +0 -566
  446. package/src/headers/14/util.h +0 -804
  447. package/src/headers/14/v8abbr.h +0 -124
  448. package/src/headers/16/aliased_buffer.h +0 -315
  449. package/src/headers/16/allocated_buffer-inl.h +0 -110
  450. package/src/headers/16/allocated_buffer.h +0 -73
  451. package/src/headers/16/async_wrap-inl.h +0 -94
  452. package/src/headers/16/base64-inl.h +0 -189
  453. package/src/headers/16/base64.h +0 -69
  454. package/src/headers/16/crypto/crypto_aes.h +0 -89
  455. package/src/headers/16/crypto/crypto_cipher.h +0 -286
  456. package/src/headers/16/crypto/crypto_common.h +0 -187
  457. package/src/headers/16/crypto/crypto_dh.h +0 -157
  458. package/src/headers/16/crypto/crypto_dsa.h +0 -76
  459. package/src/headers/16/crypto/crypto_ec.h +0 -169
  460. package/src/headers/16/crypto/crypto_groups.h +0 -415
  461. package/src/headers/16/crypto/crypto_hash.h +0 -89
  462. package/src/headers/16/crypto/crypto_hkdf.h +0 -66
  463. package/src/headers/16/crypto/crypto_hmac.h +0 -94
  464. package/src/headers/16/crypto/crypto_keygen.h +0 -301
  465. package/src/headers/16/crypto/crypto_pbkdf2.h +0 -76
  466. package/src/headers/16/crypto/crypto_random.h +0 -130
  467. package/src/headers/16/crypto/crypto_rsa.h +0 -141
  468. package/src/headers/16/crypto/crypto_scrypt.h +0 -87
  469. package/src/headers/16/crypto/crypto_sig.h +0 -167
  470. package/src/headers/16/crypto/crypto_spkac.h +0 -20
  471. package/src/headers/16/crypto/crypto_timing.h +0 -20
  472. package/src/headers/16/crypto/crypto_x509.h +0 -141
  473. package/src/headers/16/env.h +0 -1629
  474. package/src/headers/16/histogram.h +0 -216
  475. package/src/headers/16/js_native_api.h +0 -561
  476. package/src/headers/16/js_native_api_v8.h +0 -451
  477. package/src/headers/16/node.d +0 -315
  478. package/src/headers/16/node.stp +0 -146
  479. package/src/headers/16/node_api.h +0 -275
  480. package/src/headers/16/node_api_internals.h +0 -30
  481. package/src/headers/16/node_binding.h +0 -99
  482. package/src/headers/16/node_buffer.h +0 -92
  483. package/src/headers/16/node_constants.h +0 -84
  484. package/src/headers/16/node_context_data.h +0 -44
  485. package/src/headers/16/node_contextify.h +0 -196
  486. package/src/headers/16/node_dtrace.h +0 -86
  487. package/src/headers/16/node_external_reference.h +0 -129
  488. package/src/headers/16/node_main_instance.h +0 -103
  489. package/src/headers/16/node_native_module.h +0 -101
  490. package/src/headers/16/node_native_module_env.h +0 -68
  491. package/src/headers/16/node_platform.h +0 -192
  492. package/src/headers/16/node_process.h +0 -43
  493. package/src/headers/16/node_provider.d +0 -80
  494. package/src/headers/16/node_snapshotable.h +0 -137
  495. package/src/headers/16/node_union_bytes.h +0 -103
  496. package/src/headers/16/node_url.h +0 -205
  497. package/src/headers/16/node_v8.h +0 -41
  498. package/src/headers/16/node_v8_platform-inl.h +0 -194
  499. package/src/headers/16/node_wasi.h +0 -108
  500. package/src/headers/16/node_watchdog.h +0 -152
  501. package/src/headers/16/node_win32_etw_provider-inl.h +0 -288
  502. package/src/headers/16/node_win32_etw_provider.h +0 -99
  503. package/src/headers/16/spawn_sync.h +0 -242
  504. package/src/headers/16/string_decoder-inl.h +0 -37
  505. package/src/headers/16/string_search.h +0 -638
  506. package/src/headers/16/threadpoolwork-inl.h +0 -57
  507. package/src/headers/16/tracing/node_trace_buffer.h +0 -83
  508. package/src/headers/16/tracing/node_trace_writer.h +0 -75
  509. package/src/headers/16/tracing/trace_event.h +0 -720
  510. package/src/headers/16/tracing/traced_value.h +0 -70
  511. package/src/headers/16/v8abbr.h +0 -123
  512. package/src/headers/16/v8ustack.d +0 -695
  513. package/src/headers/18/aliased_buffer.h +0 -315
  514. package/src/headers/18/aliased_struct-inl.h +0 -54
  515. package/src/headers/18/aliased_struct.h +0 -63
  516. package/src/headers/18/base64-inl.h +0 -189
  517. package/src/headers/18/base64.h +0 -69
  518. package/src/headers/18/connect_wrap.h +0 -26
  519. package/src/headers/18/connection_wrap.h +0 -30
  520. package/src/headers/18/crypto/crypto_aes.h +0 -89
  521. package/src/headers/18/crypto/crypto_bio.h +0 -194
  522. package/src/headers/18/crypto/crypto_clienthello-inl.h +0 -90
  523. package/src/headers/18/crypto/crypto_common.h +0 -151
  524. package/src/headers/18/crypto/crypto_groups.h +0 -415
  525. package/src/headers/18/crypto/crypto_x509.h +0 -143
  526. package/src/headers/18/debug_utils-inl.h +0 -223
  527. package/src/headers/18/diagnosticfilename-inl.h +0 -33
  528. package/src/headers/18/env-inl.h +0 -1308
  529. package/src/headers/18/env.h +0 -1667
  530. package/src/headers/18/inspector_io.h +0 -78
  531. package/src/headers/18/inspector_socket.h +0 -60
  532. package/src/headers/18/inspector_socket_server.h +0 -110
  533. package/src/headers/18/js_stream.h +0 -52
  534. package/src/headers/18/memory_tracker.h +0 -284
  535. package/src/headers/18/module_wrap.h +0 -116
  536. package/src/headers/18/node_binding.h +0 -99
  537. package/src/headers/18/node_context_data.h +0 -44
  538. package/src/headers/18/node_contextify.h +0 -196
  539. package/src/headers/18/node_dir.h +0 -52
  540. package/src/headers/18/node_dtrace.h +0 -86
  541. package/src/headers/18/node_http2_state.h +0 -149
  542. package/src/headers/18/node_mem-inl.h +0 -112
  543. package/src/headers/18/node_native_module.h +0 -109
  544. package/src/headers/18/node_native_module_env.h +0 -71
  545. package/src/headers/18/node_object_wrap.h +0 -132
  546. package/src/headers/18/node_snapshot_builder.h +0 -43
  547. package/src/headers/18/node_snapshotable.h +0 -130
  548. package/src/headers/18/node_union_bytes.h +0 -103
  549. package/src/headers/18/node_url.h +0 -205
  550. package/src/headers/18/node_v8.h +0 -41
  551. package/src/headers/18/node_wasi.h +0 -108
  552. package/src/headers/18/node_win32_etw_provider-inl.h +0 -288
  553. package/src/headers/18/node_win32_etw_provider.h +0 -99
  554. package/src/headers/18/string_search.h +0 -638
  555. package/src/headers/18/tracing/node_trace_buffer.h +0 -83
  556. package/src/headers/18/tracing/node_trace_writer.h +0 -75
  557. package/src/headers/18/tracing/trace_event_common.h +0 -1109
  558. package/src/headers/18/tracing/traced_value.h +0 -70
  559. package/src/headers/18/v8abbr.h +0 -123
  560. /package/src/headers/{14 → 22}/aliased_struct-inl.h +0 -0
  561. /package/src/headers/{14 → 22}/aliased_struct.h +0 -0
  562. /package/src/headers/{16 → 22}/callback_queue-inl.h +0 -0
  563. /package/src/headers/{14 → 22}/connect_wrap.h +0 -0
  564. /package/src/headers/{14 → 22}/connection_wrap.h +0 -0
  565. /package/src/headers/{14 → 22}/diagnosticfilename-inl.h +0 -0
  566. /package/src/headers/{18 → 22}/histogram-inl.h +0 -0
  567. /package/src/headers/{14 → 22}/inspector_io.h +0 -0
  568. /package/src/headers/{14 → 22}/inspector_socket.h +0 -0
  569. /package/src/headers/{14 → 22}/inspector_socket_server.h +0 -0
  570. /package/src/headers/{14 → 22}/js_stream.h +0 -0
  571. /package/src/headers/{14 → 22}/node_dir.h +0 -0
  572. /package/src/headers/{14 → 22}/node_mem-inl.h +0 -0
  573. /package/src/headers/{16 → 22}/node_mem.h +0 -0
  574. /package/src/headers/{16 → 22}/node_mutex.h +0 -0
  575. /package/src/headers/{14 → 22}/node_object_wrap.h +0 -0
  576. /package/src/headers/{16 → 22}/node_process-inl.h +0 -0
  577. /package/src/headers/{18 → 22}/node_sockaddr-inl.h +0 -0
  578. /package/src/headers/{18 → 22}/node_wasm_web_api.h +0 -0
  579. /package/src/headers/{16 → 22}/pipe_wrap.h +0 -0
  580. /package/src/headers/{18 → 22}/req_wrap.h +0 -0
  581. /package/src/headers/{18 → 22}/timer_wrap-inl.h +0 -0
  582. /package/src/headers/{18 → 22}/timer_wrap.h +0 -0
  583. /package/src/headers/{18 → 22}/tracing/agent.h +0 -0
  584. /package/src/headers/{14 → 22}/tracing/trace_event_common.h +0 -0
  585. /package/src/headers/{18 → 22}/tty_wrap.h +0 -0
  586. /package/src/headers/{16 → 24}/aliased_struct-inl.h +0 -0
  587. /package/src/headers/{16 → 24}/aliased_struct.h +0 -0
  588. /package/src/headers/{18 → 24}/callback_queue-inl.h +0 -0
  589. /package/src/headers/{16 → 24}/connect_wrap.h +0 -0
  590. /package/src/headers/{16 → 24}/connection_wrap.h +0 -0
  591. /package/src/headers/{18 → 24}/crypto/crypto_spkac.h +0 -0
  592. /package/src/headers/{18 → 24}/crypto/crypto_timing.h +0 -0
  593. /package/src/headers/{16 → 24}/diagnosticfilename-inl.h +0 -0
  594. /package/src/headers/{16 → 24}/inspector_io.h +0 -0
  595. /package/src/headers/{16 → 24}/inspector_socket.h +0 -0
  596. /package/src/headers/{16 → 24}/inspector_socket_server.h +0 -0
  597. /package/src/headers/{16 → 24}/js_stream.h +0 -0
  598. /package/src/headers/{16 → 24}/node_dir.h +0 -0
  599. /package/src/headers/{18 → 24}/node_mem.h +0 -0
  600. /package/src/headers/{18 → 24}/node_mutex.h +0 -0
  601. /package/src/headers/{16 → 24}/node_object_wrap.h +0 -0
  602. /package/src/headers/{18 → 24}/node_process-inl.h +0 -0
  603. /package/src/headers/{14/tracing → 24}/node_trace_buffer.h +0 -0
  604. /package/src/headers/{14/tracing → 24}/node_trace_writer.h +0 -0
  605. /package/src/headers/{18 → 24}/pipe_wrap.h +0 -0
  606. /package/src/headers/{16/tracing → 24}/trace_event_common.h +0 -0
@@ -1,1191 +0,0 @@
1
- #ifndef SRC_NODE_HTTP2_H_
2
- #define SRC_NODE_HTTP2_H_
3
-
4
- #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
-
6
- // FIXME(joyeecheung): nghttp2.h needs stdint.h to compile on Windows
7
- #include <cstdint>
8
- #include "nghttp2/nghttp2.h"
9
-
10
- #include "allocated_buffer.h"
11
- #include "aliased_struct.h"
12
- #include "node_http2_state.h"
13
- #include "node_http_common.h"
14
- #include "node_mem.h"
15
- #include "node_perf.h"
16
- #include "stream_base.h"
17
- #include "string_bytes.h"
18
-
19
- #include <algorithm>
20
- #include <queue>
21
-
22
- namespace node {
23
- namespace http2 {
24
-
25
- // Constants in all caps are exported as user-facing constants
26
- // in JavaScript. Constants using the kName pattern are internal
27
- // only.
28
-
29
- // We strictly limit the number of outstanding unacknowledged PINGS a user
30
- // may send in order to prevent abuse. The current default cap is 10. The
31
- // user may set a different limit using a per Http2Session configuration
32
- // option.
33
- constexpr size_t kDefaultMaxPings = 10;
34
-
35
- // Also strictly limit the number of outstanding SETTINGS frames a user sends
36
- constexpr size_t kDefaultMaxSettings = 10;
37
-
38
- // Default maximum total memory cap for Http2Session.
39
- constexpr uint64_t kDefaultMaxSessionMemory = 10000000;
40
-
41
- // These are the standard HTTP/2 defaults as specified by the RFC
42
- constexpr uint32_t DEFAULT_SETTINGS_HEADER_TABLE_SIZE = 4096;
43
- constexpr uint32_t DEFAULT_SETTINGS_ENABLE_PUSH = 1;
44
- constexpr uint32_t DEFAULT_SETTINGS_MAX_CONCURRENT_STREAMS = 0xffffffffu;
45
- constexpr uint32_t DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE = 65535;
46
- constexpr uint32_t DEFAULT_SETTINGS_MAX_FRAME_SIZE = 16384;
47
- constexpr uint32_t DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE = 65535;
48
- constexpr uint32_t DEFAULT_SETTINGS_ENABLE_CONNECT_PROTOCOL = 0;
49
- constexpr uint32_t MAX_MAX_FRAME_SIZE = 16777215;
50
- constexpr uint32_t MIN_MAX_FRAME_SIZE = DEFAULT_SETTINGS_MAX_FRAME_SIZE;
51
- constexpr uint32_t MAX_INITIAL_WINDOW_SIZE = 2147483647;
52
-
53
- // Stream is not going to have any DATA frames
54
- constexpr int STREAM_OPTION_EMPTY_PAYLOAD = 0x1;
55
-
56
- // Stream might have trailing headers
57
- constexpr int STREAM_OPTION_GET_TRAILERS = 0x2;
58
-
59
- // Http2Stream internal states
60
- constexpr int kStreamStateNone = 0x0;
61
- constexpr int kStreamStateShut = 0x1;
62
- constexpr int kStreamStateReadStart = 0x2;
63
- constexpr int kStreamStateReadPaused = 0x4;
64
- constexpr int kStreamStateClosed = 0x8;
65
- constexpr int kStreamStateDestroyed = 0x10;
66
- constexpr int kStreamStateTrailers = 0x20;
67
-
68
- // Http2Session internal states
69
- constexpr int kSessionStateNone = 0x0;
70
- constexpr int kSessionStateHasScope = 0x1;
71
- constexpr int kSessionStateWriteScheduled = 0x2;
72
- constexpr int kSessionStateClosed = 0x4;
73
- constexpr int kSessionStateClosing = 0x8;
74
- constexpr int kSessionStateSending = 0x10;
75
- constexpr int kSessionStateWriteInProgress = 0x20;
76
- constexpr int kSessionStateReadingStopped = 0x40;
77
- constexpr int kSessionStateReceivePaused = 0x80;
78
-
79
- // The Padding Strategy determines the method by which extra padding is
80
- // selected for HEADERS and DATA frames. These are configurable via the
81
- // options passed in to a Http2Session object.
82
- enum PaddingStrategy {
83
- // No padding strategy. This is the default.
84
- PADDING_STRATEGY_NONE,
85
- // Attempts to ensure that the frame is 8-byte aligned
86
- PADDING_STRATEGY_ALIGNED,
87
- // Padding will ensure all data frames are maxFrameSize
88
- PADDING_STRATEGY_MAX,
89
- // Removed and turned into an alias because it is unreasonably expensive for
90
- // very little benefit.
91
- PADDING_STRATEGY_CALLBACK = PADDING_STRATEGY_ALIGNED
92
- };
93
-
94
- enum SessionType {
95
- NGHTTP2_SESSION_SERVER,
96
- NGHTTP2_SESSION_CLIENT
97
- };
98
-
99
- template <typename T, void(*fn)(T*)>
100
- struct Nghttp2Deleter {
101
- void operator()(T* ptr) const noexcept { fn(ptr); }
102
- };
103
-
104
- using Nghttp2OptionPointer =
105
- std::unique_ptr<nghttp2_option,
106
- Nghttp2Deleter<nghttp2_option, nghttp2_option_del>>;
107
-
108
- using Nghttp2SessionPointer =
109
- std::unique_ptr<nghttp2_session,
110
- Nghttp2Deleter<nghttp2_session, nghttp2_session_del>>;
111
-
112
- using Nghttp2SessionCallbacksPointer =
113
- std::unique_ptr<nghttp2_session_callbacks,
114
- Nghttp2Deleter<nghttp2_session_callbacks,
115
- nghttp2_session_callbacks_del>>;
116
-
117
- struct Http2HeadersTraits {
118
- typedef nghttp2_nv nv_t;
119
- static const uint8_t kNoneFlag = NGHTTP2_NV_FLAG_NONE;
120
- };
121
-
122
- struct Http2RcBufferPointerTraits {
123
- typedef nghttp2_rcbuf rcbuf_t;
124
- typedef nghttp2_vec vector_t;
125
-
126
- static void inc(rcbuf_t* buf) {
127
- CHECK_NOT_NULL(buf);
128
- nghttp2_rcbuf_incref(buf);
129
- }
130
- static void dec(rcbuf_t* buf) {
131
- CHECK_NOT_NULL(buf);
132
- nghttp2_rcbuf_decref(buf);
133
- }
134
- static vector_t get_vec(rcbuf_t* buf) {
135
- CHECK_NOT_NULL(buf);
136
- return nghttp2_rcbuf_get_buf(buf);
137
- }
138
- static bool is_static(const rcbuf_t* buf) {
139
- CHECK_NOT_NULL(buf);
140
- return nghttp2_rcbuf_is_static(buf);
141
- }
142
- };
143
-
144
- using Http2Headers = NgHeaders<Http2HeadersTraits>;
145
- using Http2RcBufferPointer = NgRcBufPointer<Http2RcBufferPointerTraits>;
146
-
147
- struct NgHttp2StreamWrite : public MemoryRetainer {
148
- WriteWrap* req_wrap = nullptr;
149
- uv_buf_t buf;
150
-
151
- inline explicit NgHttp2StreamWrite(uv_buf_t buf_) : buf(buf_) {}
152
- inline NgHttp2StreamWrite(WriteWrap* req, uv_buf_t buf_) :
153
- req_wrap(req), buf(buf_) {}
154
-
155
- void MemoryInfo(MemoryTracker* tracker) const override;
156
- SET_MEMORY_INFO_NAME(NgHttp2StreamWrite)
157
- SET_SELF_SIZE(NgHttp2StreamWrite)
158
- };
159
-
160
- typedef uint32_t(*get_setting)(nghttp2_session* session,
161
- nghttp2_settings_id id);
162
-
163
- class Http2Ping;
164
- class Http2Session;
165
- class Http2Settings;
166
- class Http2Stream;
167
- class Origins;
168
-
169
- // This scope should be present when any call into nghttp2 that may schedule
170
- // data to be written to the underlying transport is made, and schedules
171
- // such a write automatically once the scope is exited.
172
- class Http2Scope {
173
- public:
174
- explicit Http2Scope(Http2Stream* stream);
175
- explicit Http2Scope(Http2Session* session);
176
- ~Http2Scope();
177
-
178
- private:
179
- BaseObjectPtr<Http2Session> session_;
180
- };
181
-
182
- // The Http2Options class is used to parse the options object passed in to
183
- // a Http2Session object and convert those into an appropriate nghttp2_option
184
- // struct. This is the primary mechanism by which the Http2Session object is
185
- // configured.
186
- class Http2Options {
187
- public:
188
- Http2Options(Http2State* http2_state,
189
- SessionType type);
190
-
191
- ~Http2Options() = default;
192
-
193
- nghttp2_option* operator*() const {
194
- return options_.get();
195
- }
196
-
197
- void set_max_header_pairs(uint32_t max) {
198
- max_header_pairs_ = max;
199
- }
200
-
201
- uint32_t max_header_pairs() const {
202
- return max_header_pairs_;
203
- }
204
-
205
- void set_padding_strategy(PaddingStrategy val) {
206
- padding_strategy_ = val;
207
- }
208
-
209
- PaddingStrategy padding_strategy() const {
210
- return padding_strategy_;
211
- }
212
-
213
- void set_max_outstanding_pings(size_t max) {
214
- max_outstanding_pings_ = max;
215
- }
216
-
217
- size_t max_outstanding_pings() const {
218
- return max_outstanding_pings_;
219
- }
220
-
221
- void set_max_outstanding_settings(size_t max) {
222
- max_outstanding_settings_ = max;
223
- }
224
-
225
- size_t max_outstanding_settings() const {
226
- return max_outstanding_settings_;
227
- }
228
-
229
- void set_max_session_memory(uint64_t max) {
230
- max_session_memory_ = max;
231
- }
232
-
233
- uint64_t max_session_memory() const {
234
- return max_session_memory_;
235
- }
236
-
237
- private:
238
- Nghttp2OptionPointer options_;
239
- uint64_t max_session_memory_ = kDefaultMaxSessionMemory;
240
- uint32_t max_header_pairs_ = DEFAULT_MAX_HEADER_LIST_PAIRS;
241
- PaddingStrategy padding_strategy_ = PADDING_STRATEGY_NONE;
242
- size_t max_outstanding_pings_ = kDefaultMaxPings;
243
- size_t max_outstanding_settings_ = kDefaultMaxSettings;
244
- };
245
-
246
- struct Http2Priority : public nghttp2_priority_spec {
247
- Http2Priority(Environment* env,
248
- v8::Local<v8::Value> parent,
249
- v8::Local<v8::Value> weight,
250
- v8::Local<v8::Value> exclusive);
251
- };
252
-
253
- class Http2StreamListener : public StreamListener {
254
- public:
255
- uv_buf_t OnStreamAlloc(size_t suggested_size) override;
256
- void OnStreamRead(ssize_t nread, const uv_buf_t& buf) override;
257
- };
258
-
259
- struct Http2HeaderTraits {
260
- typedef Http2RcBufferPointer rcbufferpointer_t;
261
- typedef Http2Session allocator_t;
262
-
263
- // HTTP/2 does not support identifying header names by token id.
264
- // HTTP/3 will, however, so we prepare for that now.
265
- static const char* ToHttpHeaderName(int32_t token) { return nullptr; }
266
- };
267
-
268
- using Http2Header = NgHeader<Http2HeaderTraits>;
269
-
270
- class Http2Stream : public AsyncWrap,
271
- public StreamBase {
272
- public:
273
- static Http2Stream* New(
274
- Http2Session* session,
275
- int32_t id,
276
- nghttp2_headers_category category = NGHTTP2_HCAT_HEADERS,
277
- int options = 0);
278
- ~Http2Stream() override;
279
-
280
- nghttp2_stream* operator*() const;
281
-
282
- nghttp2_stream* stream() const;
283
-
284
- Http2Session* session() { return session_.get(); }
285
- const Http2Session* session() const { return session_.get(); }
286
-
287
- // Required for StreamBase
288
- int ReadStart() override;
289
-
290
- // Required for StreamBase
291
- int ReadStop() override;
292
-
293
- // Required for StreamBase
294
- ShutdownWrap* CreateShutdownWrap(v8::Local<v8::Object> object) override;
295
- int DoShutdown(ShutdownWrap* req_wrap) override;
296
-
297
- bool HasWantsWrite() const override { return true; }
298
-
299
- // Initiate a response on this stream.
300
- int SubmitResponse(const Http2Headers& headers, int options);
301
-
302
- // Submit informational headers for this stream
303
- int SubmitInfo(const Http2Headers& headers);
304
-
305
- // Submit trailing headers for this stream
306
- int SubmitTrailers(const Http2Headers& headers);
307
- void OnTrailers();
308
-
309
- // Submit a PRIORITY frame for this stream
310
- int SubmitPriority(const Http2Priority& priority, bool silent = false);
311
-
312
- // Submits an RST_STREAM frame using the given code
313
- void SubmitRstStream(const uint32_t code);
314
-
315
- void FlushRstStream();
316
-
317
- // Submits a PUSH_PROMISE frame with this stream as the parent.
318
- Http2Stream* SubmitPushPromise(
319
- const Http2Headers& headers,
320
- int32_t* ret,
321
- int options = 0);
322
-
323
-
324
- void Close(int32_t code);
325
-
326
- // Destroy this stream instance and free all held memory.
327
- void Destroy();
328
-
329
- bool is_destroyed() const {
330
- return flags_ & kStreamStateDestroyed;
331
- }
332
-
333
- bool is_writable() const {
334
- return !(flags_ & kStreamStateShut);
335
- }
336
-
337
- bool is_paused() const {
338
- return flags_ & kStreamStateReadPaused;
339
- }
340
-
341
- bool is_closed() const {
342
- return flags_ & kStreamStateClosed;
343
- }
344
-
345
- bool has_trailers() const {
346
- return flags_ & kStreamStateTrailers;
347
- }
348
-
349
- void set_has_trailers(bool on = true) {
350
- if (on)
351
- flags_ |= kStreamStateTrailers;
352
- else
353
- flags_ &= ~kStreamStateTrailers;
354
- }
355
-
356
- void set_closed() {
357
- flags_ |= kStreamStateClosed;
358
- }
359
-
360
- void set_destroyed() {
361
- flags_ |= kStreamStateDestroyed;
362
- }
363
-
364
- void set_not_writable() {
365
- flags_ |= kStreamStateShut;
366
- }
367
-
368
- void set_reading(bool on = true) {
369
- if (on) {
370
- flags_ |= kStreamStateReadStart;
371
- set_paused(false);
372
- } else {}
373
- }
374
-
375
- void set_paused(bool on = true) {
376
- if (on)
377
- flags_ |= kStreamStateReadPaused;
378
- else
379
- flags_ &= ~kStreamStateReadPaused;
380
- }
381
-
382
- // Returns true if this stream is in the reading state, which occurs when
383
- // the kStreamStateReadStart flag has been set and the
384
- // kStreamStateReadPaused flag is *not* set.
385
- bool is_reading() const {
386
- return flags_ & kStreamStateReadStart && !is_paused();
387
- }
388
-
389
- // Returns the RST_STREAM code used to close this stream
390
- int32_t code() const { return code_; }
391
-
392
- // Returns the stream identifier for this stream
393
- int32_t id() const { return id_; }
394
-
395
- void IncrementAvailableOutboundLength(size_t amount);
396
- void DecrementAvailableOutboundLength(size_t amount);
397
-
398
- bool AddHeader(nghttp2_rcbuf* name, nghttp2_rcbuf* value, uint8_t flags);
399
-
400
- template <typename Fn>
401
- void TransferHeaders(Fn&& fn) {
402
- size_t i = 0;
403
- for (const auto& header : current_headers_ )
404
- fn(header, i++);
405
- current_headers_.clear();
406
- }
407
-
408
- size_t headers_count() const {
409
- return current_headers_.size();
410
- }
411
-
412
- nghttp2_headers_category headers_category() const {
413
- return current_headers_category_;
414
- }
415
-
416
- void StartHeaders(nghttp2_headers_category category);
417
-
418
- // Required for StreamBase
419
- bool IsAlive() override {
420
- return true;
421
- }
422
-
423
- // Required for StreamBase
424
- bool IsClosing() override {
425
- return false;
426
- }
427
-
428
- AsyncWrap* GetAsyncWrap() override { return this; }
429
-
430
- int DoWrite(WriteWrap* w, uv_buf_t* bufs, size_t count,
431
- uv_stream_t* send_handle) override;
432
-
433
- void MemoryInfo(MemoryTracker* tracker) const override;
434
- SET_MEMORY_INFO_NAME(Http2Stream)
435
- SET_SELF_SIZE(Http2Stream)
436
-
437
- std::string diagnostic_name() const override;
438
-
439
- // JavaScript API
440
- static void GetID(const v8::FunctionCallbackInfo<v8::Value>& args);
441
- static void Destroy(const v8::FunctionCallbackInfo<v8::Value>& args);
442
- static void Priority(const v8::FunctionCallbackInfo<v8::Value>& args);
443
- static void PushPromise(const v8::FunctionCallbackInfo<v8::Value>& args);
444
- static void RefreshState(const v8::FunctionCallbackInfo<v8::Value>& args);
445
- static void Info(const v8::FunctionCallbackInfo<v8::Value>& args);
446
- static void Trailers(const v8::FunctionCallbackInfo<v8::Value>& args);
447
- static void Respond(const v8::FunctionCallbackInfo<v8::Value>& args);
448
- static void RstStream(const v8::FunctionCallbackInfo<v8::Value>& args);
449
-
450
- class Provider;
451
-
452
- struct Statistics {
453
- uint64_t start_time;
454
- uint64_t end_time;
455
- uint64_t first_header; // Time first header was received
456
- uint64_t first_byte; // Time first DATA frame byte was received
457
- uint64_t first_byte_sent; // Time first DATA frame byte was sent
458
- uint64_t sent_bytes;
459
- uint64_t received_bytes;
460
- };
461
-
462
- Statistics statistics_ = {};
463
-
464
- private:
465
- Http2Stream(Http2Session* session,
466
- v8::Local<v8::Object> obj,
467
- int32_t id,
468
- nghttp2_headers_category category,
469
- int options);
470
-
471
- void EmitStatistics();
472
-
473
- BaseObjectWeakPtr<Http2Session> session_; // The Parent HTTP/2 Session
474
- int32_t id_ = 0; // The Stream Identifier
475
- int32_t code_ = NGHTTP2_NO_ERROR; // The RST_STREAM code (if any)
476
- int flags_ = kStreamStateNone; // Internal state flags
477
-
478
- uint32_t max_header_pairs_ = DEFAULT_MAX_HEADER_LIST_PAIRS;
479
- uint32_t max_header_length_ = DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE;
480
-
481
- // The Current Headers block... As headers are received for this stream,
482
- // they are temporarily stored here until the OnFrameReceived is called
483
- // signalling the end of the HEADERS frame
484
- nghttp2_headers_category current_headers_category_ = NGHTTP2_HCAT_HEADERS;
485
- uint32_t current_headers_length_ = 0; // total number of octets
486
- std::vector<Http2Header> current_headers_;
487
-
488
- // This keeps track of the amount of data read from the socket while the
489
- // socket was in paused mode. When `ReadStart()` is called (and not before
490
- // then), we tell nghttp2 that we consumed that data to get proper
491
- // backpressure handling.
492
- size_t inbound_consumed_data_while_paused_ = 0;
493
-
494
- // Outbound Data... This is the data written by the JS layer that is
495
- // waiting to be written out to the socket.
496
- std::queue<NgHttp2StreamWrite> queue_;
497
- size_t available_outbound_length_ = 0;
498
-
499
- Http2StreamListener stream_listener_;
500
-
501
- friend class Http2Session;
502
- };
503
-
504
- class Http2Stream::Provider {
505
- public:
506
- Provider(Http2Stream* stream, int options);
507
- explicit Provider(int options);
508
- virtual ~Provider();
509
-
510
- nghttp2_data_provider* operator*() {
511
- return !empty_ ? &provider_ : nullptr;
512
- }
513
-
514
- class FD;
515
- class Stream;
516
- protected:
517
- nghttp2_data_provider provider_;
518
-
519
- private:
520
- bool empty_ = false;
521
- };
522
-
523
- class Http2Stream::Provider::Stream : public Http2Stream::Provider {
524
- public:
525
- Stream(Http2Stream* stream, int options);
526
- explicit Stream(int options);
527
-
528
- static ssize_t OnRead(nghttp2_session* session,
529
- int32_t id,
530
- uint8_t* buf,
531
- size_t length,
532
- uint32_t* flags,
533
- nghttp2_data_source* source,
534
- void* user_data);
535
- };
536
-
537
- struct SessionJSFields {
538
- uint8_t bitfield;
539
- uint8_t priority_listener_count;
540
- uint8_t frame_error_listener_count;
541
- uint32_t max_invalid_frames = 1000;
542
- uint32_t max_rejected_streams = 100;
543
- };
544
-
545
- // Indices for js_fields_, which serves as a way to communicate data with JS
546
- // land fast. In particular, we store information about the number/presence
547
- // of certain event listeners in JS, and skip calls from C++ into JS if they
548
- // are missing.
549
- enum SessionUint8Fields {
550
- kBitfield = offsetof(SessionJSFields, bitfield), // See below
551
- kSessionPriorityListenerCount =
552
- offsetof(SessionJSFields, priority_listener_count),
553
- kSessionFrameErrorListenerCount =
554
- offsetof(SessionJSFields, frame_error_listener_count),
555
- kSessionMaxInvalidFrames = offsetof(SessionJSFields, max_invalid_frames),
556
- kSessionMaxRejectedStreams = offsetof(SessionJSFields, max_rejected_streams),
557
- kSessionUint8FieldCount = sizeof(SessionJSFields)
558
- };
559
-
560
- enum SessionBitfieldFlags {
561
- kSessionHasRemoteSettingsListeners,
562
- kSessionRemoteSettingsIsUpToDate,
563
- kSessionHasPingListeners,
564
- kSessionHasAltsvcListeners
565
- };
566
-
567
- class Http2Session : public AsyncWrap,
568
- public StreamListener,
569
- public mem::NgLibMemoryManager<Http2Session, nghttp2_mem> {
570
- public:
571
- Http2Session(Http2State* http2_state,
572
- v8::Local<v8::Object> wrap,
573
- SessionType type = NGHTTP2_SESSION_SERVER);
574
- ~Http2Session() override;
575
-
576
- StreamBase* underlying_stream() {
577
- return static_cast<StreamBase*>(stream_);
578
- }
579
-
580
- void Close(uint32_t code = NGHTTP2_NO_ERROR,
581
- bool socket_closed = false);
582
-
583
- void Consume(v8::Local<v8::Object> stream);
584
-
585
- void Goaway(uint32_t code, int32_t lastStreamID,
586
- const uint8_t* data, size_t len);
587
-
588
- void AltSvc(int32_t id,
589
- uint8_t* origin,
590
- size_t origin_len,
591
- uint8_t* value,
592
- size_t value_len);
593
-
594
- void Origin(const Origins& origins);
595
-
596
- uint8_t SendPendingData();
597
-
598
- // Submits a new request. If the request is a success, assigned
599
- // will be a pointer to the Http2Stream instance assigned.
600
- // This only works if the session is a client session.
601
- Http2Stream* SubmitRequest(
602
- const Http2Priority& priority,
603
- const Http2Headers& headers,
604
- int32_t* ret,
605
- int options = 0);
606
-
607
- SessionType type() const { return session_type_; }
608
-
609
- nghttp2_session* session() const { return session_.get(); }
610
-
611
- nghttp2_session* operator*() { return session_.get(); }
612
-
613
- uint32_t max_header_pairs() const { return max_header_pairs_; }
614
-
615
- const char* TypeName() const;
616
-
617
- bool is_destroyed() {
618
- return (flags_ & kSessionStateClosed) || session_ == nullptr;
619
- }
620
-
621
- void set_destroyed() {
622
- flags_ |= kSessionStateClosed;
623
- }
624
-
625
- #define IS_FLAG(name, flag) \
626
- bool is_##name() const { return flags_ & flag; } \
627
- void set_##name(bool on = true) { \
628
- if (on) \
629
- flags_ |= flag; \
630
- else \
631
- flags_ &= ~flag; \
632
- }
633
-
634
- IS_FLAG(in_scope, kSessionStateHasScope)
635
- IS_FLAG(write_scheduled, kSessionStateWriteScheduled)
636
- IS_FLAG(closing, kSessionStateClosing)
637
- IS_FLAG(sending, kSessionStateSending)
638
- IS_FLAG(write_in_progress, kSessionStateWriteInProgress)
639
- IS_FLAG(reading_stopped, kSessionStateReadingStopped)
640
- IS_FLAG(receive_paused, kSessionStateReceivePaused)
641
-
642
- #undef IS_FLAG
643
-
644
- // Schedule a write if nghttp2 indicates it wants to write to the socket.
645
- void MaybeScheduleWrite();
646
-
647
- // Stop reading if nghttp2 doesn't want to anymore.
648
- void MaybeStopReading();
649
-
650
- // Returns pointer to the stream, or nullptr if stream does not exist
651
- BaseObjectPtr<Http2Stream> FindStream(int32_t id);
652
-
653
- bool CanAddStream();
654
-
655
- // Adds a stream instance to this session
656
- void AddStream(Http2Stream* stream);
657
-
658
- // Removes a stream instance from this session
659
- BaseObjectPtr<Http2Stream> RemoveStream(int32_t id);
660
-
661
- // Indicates whether there currently exist outgoing buffers for this stream.
662
- bool HasWritesOnSocketForStream(Http2Stream* stream);
663
-
664
- // Write data from stream_buf_ to the session
665
- ssize_t ConsumeHTTP2Data();
666
-
667
- void MemoryInfo(MemoryTracker* tracker) const override;
668
- SET_MEMORY_INFO_NAME(Http2Session)
669
- SET_SELF_SIZE(Http2Session)
670
-
671
- std::string diagnostic_name() const override;
672
-
673
- // Schedule an RstStream for after the current write finishes.
674
- void AddPendingRstStream(int32_t stream_id) {
675
- pending_rst_streams_.emplace_back(stream_id);
676
- }
677
-
678
- bool has_pending_rststream(int32_t stream_id) {
679
- return pending_rst_streams_.end() !=
680
- std::find(pending_rst_streams_.begin(),
681
- pending_rst_streams_.end(),
682
- stream_id);
683
- }
684
-
685
- // Handle reads/writes from the underlying network transport.
686
- uv_buf_t OnStreamAlloc(size_t suggested_size) override;
687
- void OnStreamRead(ssize_t nread, const uv_buf_t& buf) override;
688
- void OnStreamAfterWrite(WriteWrap* w, int status) override;
689
-
690
- // Implementation for mem::NgLibMemoryManager
691
- void CheckAllocatedSize(size_t previous_size) const;
692
- void IncreaseAllocatedSize(size_t size);
693
- void DecreaseAllocatedSize(size_t size);
694
-
695
- // The JavaScript API
696
- static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
697
- static void Consume(const v8::FunctionCallbackInfo<v8::Value>& args);
698
- static void Destroy(const v8::FunctionCallbackInfo<v8::Value>& args);
699
- static void Settings(const v8::FunctionCallbackInfo<v8::Value>& args);
700
- static void Request(const v8::FunctionCallbackInfo<v8::Value>& args);
701
- static void SetNextStreamID(const v8::FunctionCallbackInfo<v8::Value>& args);
702
- static void Goaway(const v8::FunctionCallbackInfo<v8::Value>& args);
703
- static void UpdateChunksSent(const v8::FunctionCallbackInfo<v8::Value>& args);
704
- static void RefreshState(const v8::FunctionCallbackInfo<v8::Value>& args);
705
- static void Ping(const v8::FunctionCallbackInfo<v8::Value>& args);
706
- static void AltSvc(const v8::FunctionCallbackInfo<v8::Value>& args);
707
- static void Origin(const v8::FunctionCallbackInfo<v8::Value>& args);
708
-
709
- template <get_setting fn>
710
- static void RefreshSettings(const v8::FunctionCallbackInfo<v8::Value>& args);
711
-
712
- uv_loop_t* event_loop() const {
713
- return env()->event_loop();
714
- }
715
-
716
- Http2State* http2_state() const { return http2_state_.get(); }
717
-
718
- BaseObjectPtr<Http2Ping> PopPing();
719
- bool AddPing(const uint8_t* data, v8::Local<v8::Function> callback);
720
-
721
- BaseObjectPtr<Http2Settings> PopSettings();
722
- bool AddSettings(v8::Local<v8::Function> callback);
723
-
724
- void IncrementCurrentSessionMemory(uint64_t amount) {
725
- current_session_memory_ += amount;
726
- }
727
-
728
- void DecrementCurrentSessionMemory(uint64_t amount) {
729
- DCHECK_LE(amount, current_session_memory_);
730
- current_session_memory_ -= amount;
731
- }
732
-
733
- // Tell our custom memory allocator that this rcbuf is independent of
734
- // this session now, and may outlive it.
735
- void StopTrackingRcbuf(nghttp2_rcbuf* buf);
736
-
737
- // Returns the current session memory including memory allocated by nghttp2,
738
- // the current outbound storage queue, and pending writes.
739
- uint64_t current_session_memory() const {
740
- uint64_t total = current_session_memory_ + sizeof(Http2Session);
741
- total += current_nghttp2_memory_;
742
- total += outgoing_storage_.size();
743
- return total;
744
- }
745
-
746
- // Return true if current_session_memory + amount is less than the max
747
- bool has_available_session_memory(uint64_t amount) const {
748
- return current_session_memory() + amount <= max_session_memory_;
749
- }
750
-
751
- struct Statistics {
752
- uint64_t start_time;
753
- uint64_t end_time;
754
- uint64_t ping_rtt;
755
- uint64_t data_sent;
756
- uint64_t data_received;
757
- uint32_t frame_count;
758
- uint32_t frame_sent;
759
- int32_t stream_count;
760
- size_t max_concurrent_streams;
761
- double stream_average_duration;
762
- };
763
-
764
- Statistics statistics_ = {};
765
-
766
- private:
767
- void EmitStatistics();
768
-
769
- // Frame Padding Strategies
770
- ssize_t OnDWordAlignedPadding(size_t frameLength,
771
- size_t maxPayloadLen);
772
- ssize_t OnMaxFrameSizePadding(size_t frameLength,
773
- size_t maxPayloadLen);
774
-
775
- // Frame Handler
776
- int HandleDataFrame(const nghttp2_frame* frame);
777
- void HandleGoawayFrame(const nghttp2_frame* frame);
778
- void HandleHeadersFrame(const nghttp2_frame* frame);
779
- void HandlePriorityFrame(const nghttp2_frame* frame);
780
- void HandleSettingsFrame(const nghttp2_frame* frame);
781
- void HandlePingFrame(const nghttp2_frame* frame);
782
- void HandleAltSvcFrame(const nghttp2_frame* frame);
783
- void HandleOriginFrame(const nghttp2_frame* frame);
784
-
785
- // nghttp2 callbacks
786
- static int OnBeginHeadersCallback(
787
- nghttp2_session* session,
788
- const nghttp2_frame* frame,
789
- void* user_data);
790
- static int OnHeaderCallback(
791
- nghttp2_session* session,
792
- const nghttp2_frame* frame,
793
- nghttp2_rcbuf* name,
794
- nghttp2_rcbuf* value,
795
- uint8_t flags,
796
- void* user_data);
797
- static int OnFrameReceive(
798
- nghttp2_session* session,
799
- const nghttp2_frame* frame,
800
- void* user_data);
801
- static int OnFrameNotSent(
802
- nghttp2_session* session,
803
- const nghttp2_frame* frame,
804
- int error_code,
805
- void* user_data);
806
- static int OnFrameSent(
807
- nghttp2_session* session,
808
- const nghttp2_frame* frame,
809
- void* user_data);
810
- static int OnStreamClose(
811
- nghttp2_session* session,
812
- int32_t id,
813
- uint32_t code,
814
- void* user_data);
815
- static int OnInvalidHeader(
816
- nghttp2_session* session,
817
- const nghttp2_frame* frame,
818
- nghttp2_rcbuf* name,
819
- nghttp2_rcbuf* value,
820
- uint8_t flags,
821
- void* user_data);
822
- static int OnDataChunkReceived(
823
- nghttp2_session* session,
824
- uint8_t flags,
825
- int32_t id,
826
- const uint8_t* data,
827
- size_t len,
828
- void* user_data);
829
- static ssize_t OnSelectPadding(
830
- nghttp2_session* session,
831
- const nghttp2_frame* frame,
832
- size_t maxPayloadLen,
833
- void* user_data);
834
- static int OnNghttpError(
835
- nghttp2_session* session,
836
- const char* message,
837
- size_t len,
838
- void* user_data);
839
- static int OnSendData(
840
- nghttp2_session* session,
841
- nghttp2_frame* frame,
842
- const uint8_t* framehd,
843
- size_t length,
844
- nghttp2_data_source* source,
845
- void* user_data);
846
- static int OnInvalidFrame(
847
- nghttp2_session* session,
848
- const nghttp2_frame* frame,
849
- int lib_error_code,
850
- void* user_data);
851
-
852
- struct Callbacks {
853
- explicit Callbacks(bool kHasGetPaddingCallback);
854
-
855
- Nghttp2SessionCallbacksPointer callbacks;
856
- };
857
-
858
- /* Use callback_struct_saved[kHasGetPaddingCallback ? 1 : 0] */
859
- static const Callbacks callback_struct_saved[2];
860
-
861
- // The underlying nghttp2_session handle
862
- Nghttp2SessionPointer session_;
863
-
864
- // JS-accessible numeric fields, as indexed by SessionUint8Fields.
865
- AliasedStruct<SessionJSFields> js_fields_;
866
-
867
- // The session type: client or server
868
- SessionType session_type_;
869
-
870
- // The maximum number of header pairs permitted for streams on this session
871
- uint32_t max_header_pairs_ = DEFAULT_MAX_HEADER_LIST_PAIRS;
872
-
873
- // The maximum amount of memory allocated for this session
874
- uint64_t max_session_memory_ = kDefaultMaxSessionMemory;
875
- uint64_t current_session_memory_ = 0;
876
- // The amount of memory allocated by nghttp2 internals
877
- uint64_t current_nghttp2_memory_ = 0;
878
-
879
- // The collection of active Http2Streams associated with this session
880
- std::unordered_map<int32_t, BaseObjectPtr<Http2Stream>> streams_;
881
-
882
- int flags_ = kSessionStateNone;
883
-
884
- // The StreamBase instance being used for i/o
885
- PaddingStrategy padding_strategy_ = PADDING_STRATEGY_NONE;
886
-
887
- // use this to allow timeout tracking during long-lasting writes
888
- uint32_t chunks_sent_since_last_write_ = 0;
889
-
890
- uv_buf_t stream_buf_ = uv_buf_init(nullptr, 0);
891
- // When processing input data, either stream_buf_ab_ or stream_buf_allocation_
892
- // will be set. stream_buf_ab_ is lazily created from stream_buf_allocation_.
893
- v8::Global<v8::ArrayBuffer> stream_buf_ab_;
894
- AllocatedBuffer stream_buf_allocation_;
895
- size_t stream_buf_offset_ = 0;
896
-
897
- size_t max_outstanding_pings_ = kDefaultMaxPings;
898
- std::queue<BaseObjectPtr<Http2Ping>> outstanding_pings_;
899
-
900
- size_t max_outstanding_settings_ = kDefaultMaxSettings;
901
- std::queue<BaseObjectPtr<Http2Settings>> outstanding_settings_;
902
-
903
- std::vector<NgHttp2StreamWrite> outgoing_buffers_;
904
- std::vector<uint8_t> outgoing_storage_;
905
- size_t outgoing_length_ = 0;
906
- std::vector<int32_t> pending_rst_streams_;
907
- // Count streams that have been rejected while being opened. Exceeding a fixed
908
- // limit will result in the session being destroyed, as an indication of a
909
- // misbehaving peer. This counter is reset once new streams are being
910
- // accepted again.
911
- uint32_t rejected_stream_count_ = 0;
912
- // Also use the invalid frame count as a measure for rejecting input frames.
913
- uint32_t invalid_frame_count_ = 0;
914
-
915
- void PushOutgoingBuffer(NgHttp2StreamWrite&& write);
916
-
917
- BaseObjectPtr<Http2State> http2_state_;
918
-
919
- void CopyDataIntoOutgoing(const uint8_t* src, size_t src_length);
920
- void ClearOutgoing(int status);
921
-
922
- friend class Http2Scope;
923
- friend class Http2StreamListener;
924
- };
925
-
926
- class Http2SessionPerformanceEntry : public performance::PerformanceEntry {
927
- public:
928
- Http2SessionPerformanceEntry(
929
- Http2State* http2_state,
930
- const Http2Session::Statistics& stats,
931
- SessionType type) :
932
- performance::PerformanceEntry(
933
- http2_state->env(), "Http2Session", "http2",
934
- stats.start_time,
935
- stats.end_time),
936
- ping_rtt_(stats.ping_rtt),
937
- data_sent_(stats.data_sent),
938
- data_received_(stats.data_received),
939
- frame_count_(stats.frame_count),
940
- frame_sent_(stats.frame_sent),
941
- stream_count_(stats.stream_count),
942
- max_concurrent_streams_(stats.max_concurrent_streams),
943
- stream_average_duration_(stats.stream_average_duration),
944
- session_type_(type),
945
- http2_state_(http2_state) { }
946
-
947
- uint64_t ping_rtt() const { return ping_rtt_; }
948
- uint64_t data_sent() const { return data_sent_; }
949
- uint64_t data_received() const { return data_received_; }
950
- uint32_t frame_count() const { return frame_count_; }
951
- uint32_t frame_sent() const { return frame_sent_; }
952
- int32_t stream_count() const { return stream_count_; }
953
- size_t max_concurrent_streams() const { return max_concurrent_streams_; }
954
- double stream_average_duration() const { return stream_average_duration_; }
955
- SessionType type() const { return session_type_; }
956
- Http2State* http2_state() const { return http2_state_.get(); }
957
-
958
- void Notify(v8::Local<v8::Value> obj) {
959
- performance::PerformanceEntry::Notify(env(), kind(), obj);
960
- }
961
-
962
- private:
963
- uint64_t ping_rtt_;
964
- uint64_t data_sent_;
965
- uint64_t data_received_;
966
- uint32_t frame_count_;
967
- uint32_t frame_sent_;
968
- int32_t stream_count_;
969
- size_t max_concurrent_streams_;
970
- double stream_average_duration_;
971
- SessionType session_type_;
972
- BaseObjectPtr<Http2State> http2_state_;
973
- };
974
-
975
- class Http2StreamPerformanceEntry
976
- : public performance::PerformanceEntry {
977
- public:
978
- Http2StreamPerformanceEntry(
979
- Http2State* http2_state,
980
- int32_t id,
981
- const Http2Stream::Statistics& stats) :
982
- performance::PerformanceEntry(
983
- http2_state->env(), "Http2Stream", "http2",
984
- stats.start_time,
985
- stats.end_time),
986
- id_(id),
987
- first_header_(stats.first_header),
988
- first_byte_(stats.first_byte),
989
- first_byte_sent_(stats.first_byte_sent),
990
- sent_bytes_(stats.sent_bytes),
991
- received_bytes_(stats.received_bytes),
992
- http2_state_(http2_state) { }
993
-
994
- int32_t id() const { return id_; }
995
- uint64_t first_header() const { return first_header_; }
996
- uint64_t first_byte() const { return first_byte_; }
997
- uint64_t first_byte_sent() const { return first_byte_sent_; }
998
- uint64_t sent_bytes() const { return sent_bytes_; }
999
- uint64_t received_bytes() const { return received_bytes_; }
1000
- Http2State* http2_state() const { return http2_state_.get(); }
1001
-
1002
- void Notify(v8::Local<v8::Value> obj) {
1003
- performance::PerformanceEntry::Notify(env(), kind(), obj);
1004
- }
1005
-
1006
- private:
1007
- int32_t id_;
1008
- uint64_t first_header_;
1009
- uint64_t first_byte_;
1010
- uint64_t first_byte_sent_;
1011
- uint64_t sent_bytes_;
1012
- uint64_t received_bytes_;
1013
- BaseObjectPtr<Http2State> http2_state_;
1014
- };
1015
-
1016
- class Http2Ping : public AsyncWrap {
1017
- public:
1018
- explicit Http2Ping(
1019
- Http2Session* session,
1020
- v8::Local<v8::Object> obj,
1021
- v8::Local<v8::Function> callback);
1022
-
1023
- void MemoryInfo(MemoryTracker* tracker) const override;
1024
- SET_MEMORY_INFO_NAME(Http2Ping)
1025
- SET_SELF_SIZE(Http2Ping)
1026
-
1027
- void Send(const uint8_t* payload);
1028
- void Done(bool ack, const uint8_t* payload = nullptr);
1029
- void DetachFromSession();
1030
-
1031
- v8::Local<v8::Function> callback() const;
1032
-
1033
- private:
1034
- BaseObjectWeakPtr<Http2Session> session_;
1035
- v8::Global<v8::Function> callback_;
1036
- uint64_t startTime_;
1037
- };
1038
-
1039
- // The Http2Settings class is used to parse the settings passed in for
1040
- // an Http2Session, converting those into an array of nghttp2_settings_entry
1041
- // structs.
1042
- class Http2Settings : public AsyncWrap {
1043
- public:
1044
- Http2Settings(Http2Session* session,
1045
- v8::Local<v8::Object> obj,
1046
- v8::Local<v8::Function> callback,
1047
- uint64_t start_time = uv_hrtime());
1048
-
1049
- void MemoryInfo(MemoryTracker* tracker) const override;
1050
- SET_MEMORY_INFO_NAME(Http2Settings)
1051
- SET_SELF_SIZE(Http2Settings)
1052
-
1053
- void Send();
1054
- void Done(bool ack);
1055
-
1056
- v8::Local<v8::Function> callback() const;
1057
-
1058
- // Returns a Buffer instance with the serialized SETTINGS payload
1059
- v8::Local<v8::Value> Pack();
1060
-
1061
- static v8::Local<v8::Value> Pack(Http2State* state);
1062
-
1063
- // Resets the default values in the settings buffer
1064
- static void RefreshDefaults(Http2State* http2_state);
1065
-
1066
- // Update the local or remote settings for the given session
1067
- static void Update(Http2Session* session,
1068
- get_setting fn);
1069
-
1070
- private:
1071
- static size_t Init(
1072
- Http2State* http2_state,
1073
- nghttp2_settings_entry* entries);
1074
-
1075
- static v8::Local<v8::Value> Pack(
1076
- Environment* env,
1077
- size_t count,
1078
- const nghttp2_settings_entry* entries);
1079
-
1080
- BaseObjectWeakPtr<Http2Session> session_;
1081
- v8::Global<v8::Function> callback_;
1082
- uint64_t startTime_;
1083
- size_t count_ = 0;
1084
- nghttp2_settings_entry entries_[IDX_SETTINGS_COUNT];
1085
- };
1086
-
1087
- class Origins {
1088
- public:
1089
- Origins(Environment* env,
1090
- v8::Local<v8::String> origin_string,
1091
- size_t origin_count);
1092
- ~Origins() = default;
1093
-
1094
- const nghttp2_origin_entry* operator*() const {
1095
- return reinterpret_cast<const nghttp2_origin_entry*>(buf_.data());
1096
- }
1097
-
1098
- size_t length() const {
1099
- return count_;
1100
- }
1101
-
1102
- private:
1103
- size_t count_;
1104
- AllocatedBuffer buf_;
1105
- };
1106
-
1107
- #define HTTP2_HIDDEN_CONSTANTS(V) \
1108
- V(NGHTTP2_HCAT_REQUEST) \
1109
- V(NGHTTP2_HCAT_RESPONSE) \
1110
- V(NGHTTP2_HCAT_PUSH_RESPONSE) \
1111
- V(NGHTTP2_HCAT_HEADERS) \
1112
- V(NGHTTP2_NV_FLAG_NONE) \
1113
- V(NGHTTP2_NV_FLAG_NO_INDEX) \
1114
- V(NGHTTP2_ERR_DEFERRED) \
1115
- V(NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE) \
1116
- V(NGHTTP2_ERR_INVALID_ARGUMENT) \
1117
- V(NGHTTP2_ERR_STREAM_CLOSED) \
1118
- V(STREAM_OPTION_EMPTY_PAYLOAD) \
1119
- V(STREAM_OPTION_GET_TRAILERS)
1120
-
1121
- #define HTTP2_ERROR_CODES(V) \
1122
- V(NGHTTP2_NO_ERROR) \
1123
- V(NGHTTP2_PROTOCOL_ERROR) \
1124
- V(NGHTTP2_INTERNAL_ERROR) \
1125
- V(NGHTTP2_FLOW_CONTROL_ERROR) \
1126
- V(NGHTTP2_SETTINGS_TIMEOUT) \
1127
- V(NGHTTP2_STREAM_CLOSED) \
1128
- V(NGHTTP2_FRAME_SIZE_ERROR) \
1129
- V(NGHTTP2_REFUSED_STREAM) \
1130
- V(NGHTTP2_CANCEL) \
1131
- V(NGHTTP2_COMPRESSION_ERROR) \
1132
- V(NGHTTP2_CONNECT_ERROR) \
1133
- V(NGHTTP2_ENHANCE_YOUR_CALM) \
1134
- V(NGHTTP2_INADEQUATE_SECURITY) \
1135
- V(NGHTTP2_HTTP_1_1_REQUIRED) \
1136
-
1137
- #define HTTP2_CONSTANTS(V) \
1138
- V(NGHTTP2_ERR_FRAME_SIZE_ERROR) \
1139
- V(NGHTTP2_SESSION_SERVER) \
1140
- V(NGHTTP2_SESSION_CLIENT) \
1141
- V(NGHTTP2_STREAM_STATE_IDLE) \
1142
- V(NGHTTP2_STREAM_STATE_OPEN) \
1143
- V(NGHTTP2_STREAM_STATE_RESERVED_LOCAL) \
1144
- V(NGHTTP2_STREAM_STATE_RESERVED_REMOTE) \
1145
- V(NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL) \
1146
- V(NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE) \
1147
- V(NGHTTP2_STREAM_STATE_CLOSED) \
1148
- V(NGHTTP2_FLAG_NONE) \
1149
- V(NGHTTP2_FLAG_END_STREAM) \
1150
- V(NGHTTP2_FLAG_END_HEADERS) \
1151
- V(NGHTTP2_FLAG_ACK) \
1152
- V(NGHTTP2_FLAG_PADDED) \
1153
- V(NGHTTP2_FLAG_PRIORITY) \
1154
- V(DEFAULT_SETTINGS_HEADER_TABLE_SIZE) \
1155
- V(DEFAULT_SETTINGS_ENABLE_PUSH) \
1156
- V(DEFAULT_SETTINGS_MAX_CONCURRENT_STREAMS) \
1157
- V(DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE) \
1158
- V(DEFAULT_SETTINGS_MAX_FRAME_SIZE) \
1159
- V(DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE) \
1160
- V(DEFAULT_SETTINGS_ENABLE_CONNECT_PROTOCOL) \
1161
- V(MAX_MAX_FRAME_SIZE) \
1162
- V(MIN_MAX_FRAME_SIZE) \
1163
- V(MAX_INITIAL_WINDOW_SIZE) \
1164
- V(NGHTTP2_SETTINGS_HEADER_TABLE_SIZE) \
1165
- V(NGHTTP2_SETTINGS_ENABLE_PUSH) \
1166
- V(NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS) \
1167
- V(NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE) \
1168
- V(NGHTTP2_SETTINGS_MAX_FRAME_SIZE) \
1169
- V(NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE) \
1170
- V(NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL) \
1171
- V(PADDING_STRATEGY_NONE) \
1172
- V(PADDING_STRATEGY_ALIGNED) \
1173
- V(PADDING_STRATEGY_MAX) \
1174
- V(PADDING_STRATEGY_CALLBACK) \
1175
- HTTP2_ERROR_CODES(V)
1176
-
1177
- #define HTTP2_SETTINGS(V) \
1178
- V(HEADER_TABLE_SIZE) \
1179
- V(ENABLE_PUSH) \
1180
- V(MAX_CONCURRENT_STREAMS) \
1181
- V(INITIAL_WINDOW_SIZE) \
1182
- V(MAX_FRAME_SIZE) \
1183
- V(MAX_HEADER_LIST_SIZE) \
1184
- V(ENABLE_CONNECT_PROTOCOL) \
1185
-
1186
- } // namespace http2
1187
- } // namespace node
1188
-
1189
- #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
1190
-
1191
- #endif // SRC_NODE_HTTP2_H_