@kungfu-tech/libnode-win32-x64 0.0.0-bootstrap.0 → 22.22.3-kf.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 (343) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +3 -0
  3. package/dist/node/include/acorn_version.h +6 -0
  4. package/dist/node/include/aliased_buffer-inl.h +244 -0
  5. package/dist/node/include/aliased_buffer.h +206 -0
  6. package/dist/node/include/aliased_struct-inl.h +54 -0
  7. package/dist/node/include/aliased_struct.h +63 -0
  8. package/dist/node/include/amaro_version.h +6 -0
  9. package/dist/node/include/async_context_frame.h +33 -0
  10. package/dist/node/include/async_wrap-inl.h +96 -0
  11. package/dist/node/include/async_wrap.h +243 -0
  12. package/dist/node/include/base_object-inl.h +335 -0
  13. package/dist/node/include/base_object.h +342 -0
  14. package/dist/node/include/base_object_types.h +74 -0
  15. package/dist/node/include/blob_serializer_deserializer-inl.h +385 -0
  16. package/dist/node/include/blob_serializer_deserializer.h +132 -0
  17. package/dist/node/include/callback_queue-inl.h +97 -0
  18. package/dist/node/include/callback_queue.h +79 -0
  19. package/dist/node/include/cares_wrap.h +447 -0
  20. package/dist/node/include/cjs_module_lexer_version.h +6 -0
  21. package/dist/node/include/cleanup_queue-inl.h +36 -0
  22. package/dist/node/include/cleanup_queue.h +79 -0
  23. package/dist/node/include/compile_cache.h +104 -0
  24. package/dist/node/include/connect_wrap.h +26 -0
  25. package/dist/node/include/connection_wrap.h +30 -0
  26. package/dist/node/include/cppgc/allocation.h +310 -0
  27. package/dist/node/include/cppgc/common.h +28 -0
  28. package/dist/node/include/cppgc/cross-thread-persistent.h +466 -0
  29. package/dist/node/include/cppgc/custom-space.h +97 -0
  30. package/dist/node/include/cppgc/default-platform.h +67 -0
  31. package/dist/node/include/cppgc/ephemeron-pair.h +30 -0
  32. package/dist/node/include/cppgc/explicit-management.h +100 -0
  33. package/dist/node/include/cppgc/garbage-collected.h +106 -0
  34. package/dist/node/include/cppgc/heap-consistency.h +309 -0
  35. package/dist/node/include/cppgc/heap-handle.h +48 -0
  36. package/dist/node/include/cppgc/heap-state.h +82 -0
  37. package/dist/node/include/cppgc/heap-statistics.h +120 -0
  38. package/dist/node/include/cppgc/heap.h +202 -0
  39. package/dist/node/include/cppgc/internal/api-constants.h +87 -0
  40. package/dist/node/include/cppgc/internal/atomic-entry-flag.h +48 -0
  41. package/dist/node/include/cppgc/internal/base-page-handle.h +45 -0
  42. package/dist/node/include/cppgc/internal/caged-heap-local-data.h +121 -0
  43. package/dist/node/include/cppgc/internal/caged-heap.h +68 -0
  44. package/dist/node/include/cppgc/internal/compiler-specific.h +38 -0
  45. package/dist/node/include/cppgc/internal/finalizer-trait.h +93 -0
  46. package/dist/node/include/cppgc/internal/gc-info.h +148 -0
  47. package/dist/node/include/cppgc/internal/logging.h +50 -0
  48. package/dist/node/include/cppgc/internal/member-storage.h +256 -0
  49. package/dist/node/include/cppgc/internal/name-trait.h +137 -0
  50. package/dist/node/include/cppgc/internal/persistent-node.h +214 -0
  51. package/dist/node/include/cppgc/internal/pointer-policies.h +243 -0
  52. package/dist/node/include/cppgc/internal/write-barrier.h +487 -0
  53. package/dist/node/include/cppgc/liveness-broker.h +78 -0
  54. package/dist/node/include/cppgc/macros.h +35 -0
  55. package/dist/node/include/cppgc/member.h +629 -0
  56. package/dist/node/include/cppgc/name-provider.h +65 -0
  57. package/dist/node/include/cppgc/object-size-trait.h +58 -0
  58. package/dist/node/include/cppgc/persistent.h +377 -0
  59. package/dist/node/include/cppgc/platform.h +163 -0
  60. package/dist/node/include/cppgc/prefinalizer.h +75 -0
  61. package/dist/node/include/cppgc/process-heap-statistics.h +36 -0
  62. package/dist/node/include/cppgc/sentinel-pointer.h +39 -0
  63. package/dist/node/include/cppgc/source-location.h +16 -0
  64. package/dist/node/include/cppgc/testing.h +106 -0
  65. package/dist/node/include/cppgc/trace-trait.h +128 -0
  66. package/dist/node/include/cppgc/type-traits.h +271 -0
  67. package/dist/node/include/cppgc/visitor.h +504 -0
  68. package/dist/node/include/crypto/crypto_aes.h +88 -0
  69. package/dist/node/include/crypto/crypto_bio.h +193 -0
  70. package/dist/node/include/crypto/crypto_cipher.h +293 -0
  71. package/dist/node/include/crypto/crypto_clienthello-inl.h +90 -0
  72. package/dist/node/include/crypto/crypto_clienthello.h +131 -0
  73. package/dist/node/include/crypto/crypto_common.h +64 -0
  74. package/dist/node/include/crypto/crypto_context.h +171 -0
  75. package/dist/node/include/crypto/crypto_dh.h +126 -0
  76. package/dist/node/include/crypto/crypto_dsa.h +52 -0
  77. package/dist/node/include/crypto/crypto_ec.h +164 -0
  78. package/dist/node/include/crypto/crypto_hash.h +91 -0
  79. package/dist/node/include/crypto/crypto_hkdf.h +61 -0
  80. package/dist/node/include/crypto/crypto_hmac.h +92 -0
  81. package/dist/node/include/crypto/crypto_keygen.h +299 -0
  82. package/dist/node/include/crypto/crypto_keys.h +392 -0
  83. package/dist/node/include/crypto/crypto_pbkdf2.h +74 -0
  84. package/dist/node/include/crypto/crypto_random.h +124 -0
  85. package/dist/node/include/crypto/crypto_rsa.h +136 -0
  86. package/dist/node/include/crypto/crypto_scrypt.h +85 -0
  87. package/dist/node/include/crypto/crypto_sig.h +165 -0
  88. package/dist/node/include/crypto/crypto_spkac.h +21 -0
  89. package/dist/node/include/crypto/crypto_timing.h +20 -0
  90. package/dist/node/include/crypto/crypto_tls.h +305 -0
  91. package/dist/node/include/crypto/crypto_util.h +725 -0
  92. package/dist/node/include/crypto/crypto_x509.h +140 -0
  93. package/dist/node/include/dataqueue/queue.h +306 -0
  94. package/dist/node/include/debug_utils-inl.h +278 -0
  95. package/dist/node/include/debug_utils.h +196 -0
  96. package/dist/node/include/diagnosticfilename-inl.h +33 -0
  97. package/dist/node/include/embedded_data.h +17 -0
  98. package/dist/node/include/encoding_binding.h +61 -0
  99. package/dist/node/include/env-inl.h +984 -0
  100. package/dist/node/include/env.h +1287 -0
  101. package/dist/node/include/env_properties.h +540 -0
  102. package/dist/node/include/handle_wrap.h +123 -0
  103. package/dist/node/include/histogram-inl.h +107 -0
  104. package/dist/node/include/histogram.h +279 -0
  105. package/dist/node/include/inspector/io_agent.h +30 -0
  106. package/dist/node/include/inspector/main_thread_interface.h +116 -0
  107. package/dist/node/include/inspector/network_agent.h +94 -0
  108. package/dist/node/include/inspector/network_inspector.h +45 -0
  109. package/dist/node/include/inspector/network_requests_buffer.h +195 -0
  110. package/dist/node/include/inspector/network_resource_manager.h +29 -0
  111. package/dist/node/include/inspector/node_json.h +24 -0
  112. package/dist/node/include/inspector/node_string.h +101 -0
  113. package/dist/node/include/inspector/protocol_helper.h +27 -0
  114. package/dist/node/include/inspector/runtime_agent.h +41 -0
  115. package/dist/node/include/inspector/target_agent.h +75 -0
  116. package/dist/node/include/inspector/tracing_agent.h +43 -0
  117. package/dist/node/include/inspector/worker_agent.h +40 -0
  118. package/dist/node/include/inspector/worker_inspector.h +124 -0
  119. package/dist/node/include/inspector_agent.h +165 -0
  120. package/dist/node/include/inspector_io.h +78 -0
  121. package/dist/node/include/inspector_profiler.h +149 -0
  122. package/dist/node/include/inspector_socket.h +60 -0
  123. package/dist/node/include/inspector_socket_server.h +110 -0
  124. package/dist/node/include/js_native_api.h +607 -0
  125. package/dist/node/include/js_native_api_types.h +226 -0
  126. package/dist/node/include/js_native_api_v8.h +485 -0
  127. package/dist/node/include/js_native_api_v8_internals.h +45 -0
  128. package/dist/node/include/js_stream.h +52 -0
  129. package/dist/node/include/json_utils.h +172 -0
  130. package/dist/node/include/large_pages/node_large_page.h +34 -0
  131. package/dist/node/include/libplatform/libplatform-export.h +29 -0
  132. package/dist/node/include/libplatform/libplatform.h +112 -0
  133. package/dist/node/include/libplatform/v8-tracing.h +333 -0
  134. package/dist/node/include/memory_tracker-inl.h +359 -0
  135. package/dist/node/include/memory_tracker.h +289 -0
  136. package/dist/node/include/module_wrap.h +216 -0
  137. package/dist/node/include/node.h +1593 -0
  138. package/dist/node/include/node_api.h +265 -0
  139. package/dist/node/include/node_api_internals.h +48 -0
  140. package/dist/node/include/node_api_types.h +56 -0
  141. package/dist/node/include/node_binding.h +161 -0
  142. package/dist/node/include/node_blob.h +159 -0
  143. package/dist/node/include/node_bob-inl.h +36 -0
  144. package/dist/node/include/node_bob.h +107 -0
  145. package/dist/node/include/node_buffer.h +92 -0
  146. package/dist/node/include/node_builtins.h +220 -0
  147. package/dist/node/include/node_config_file.h +46 -0
  148. package/dist/node/include/node_constants.h +82 -0
  149. package/dist/node/include/node_context_data.h +168 -0
  150. package/dist/node/include/node_contextify.h +204 -0
  151. package/dist/node/include/node_crypto.h +56 -0
  152. package/dist/node/include/node_debug.h +30 -0
  153. package/dist/node/include/node_dir.h +52 -0
  154. package/dist/node/include/node_dotenv.h +45 -0
  155. package/dist/node/include/node_errors.h +380 -0
  156. package/dist/node/include/node_exit_code.h +54 -0
  157. package/dist/node/include/node_external_reference.h +165 -0
  158. package/dist/node/include/node_file-inl.h +406 -0
  159. package/dist/node/include/node_file.h +537 -0
  160. package/dist/node/include/node_http2.h +1177 -0
  161. package/dist/node/include/node_http2_state.h +159 -0
  162. package/dist/node/include/node_http_common-inl.h +202 -0
  163. package/dist/node/include/node_http_common.h +535 -0
  164. package/dist/node/include/node_i18n.h +132 -0
  165. package/dist/node/include/node_internals.h +483 -0
  166. package/dist/node/include/node_main_instance.h +67 -0
  167. package/dist/node/include/node_mem-inl.h +113 -0
  168. package/dist/node/include/node_mem.h +45 -0
  169. package/dist/node/include/node_messaging.h +389 -0
  170. package/dist/node/include/node_metadata.h +164 -0
  171. package/dist/node/include/node_modules.h +91 -0
  172. package/dist/node/include/node_mutex.h +323 -0
  173. package/dist/node/include/node_object_wrap.h +132 -0
  174. package/dist/node/include/node_options-inl.h +490 -0
  175. package/dist/node/include/node_options.h +615 -0
  176. package/dist/node/include/node_perf.h +166 -0
  177. package/dist/node/include/node_perf_common.h +102 -0
  178. package/dist/node/include/node_platform.h +238 -0
  179. package/dist/node/include/node_process-inl.h +26 -0
  180. package/dist/node/include/node_process.h +112 -0
  181. package/dist/node/include/node_realm-inl.h +151 -0
  182. package/dist/node/include/node_realm.h +183 -0
  183. package/dist/node/include/node_report.h +43 -0
  184. package/dist/node/include/node_revert.h +82 -0
  185. package/dist/node/include/node_root_certs.h +3520 -0
  186. package/dist/node/include/node_sea.h +74 -0
  187. package/dist/node/include/node_shadow_realm.h +46 -0
  188. package/dist/node/include/node_snapshot_builder.h +57 -0
  189. package/dist/node/include/node_snapshotable.h +174 -0
  190. package/dist/node/include/node_sockaddr-inl.h +257 -0
  191. package/dist/node/include/node_sockaddr.h +394 -0
  192. package/dist/node/include/node_sqlite.h +270 -0
  193. package/dist/node/include/node_stat_watcher.h +73 -0
  194. package/dist/node/include/node_task_runner.h +92 -0
  195. package/dist/node/include/node_threadsafe_cow-inl.h +54 -0
  196. package/dist/node/include/node_threadsafe_cow.h +105 -0
  197. package/dist/node/include/node_union_bytes.h +81 -0
  198. package/dist/node/include/node_url.h +96 -0
  199. package/dist/node/include/node_v8.h +77 -0
  200. package/dist/node/include/node_v8_platform-inl.h +185 -0
  201. package/dist/node/include/node_version.h +110 -0
  202. package/dist/node/include/node_wasi.h +184 -0
  203. package/dist/node/include/node_wasm_web_api.h +55 -0
  204. package/dist/node/include/node_watchdog.h +154 -0
  205. package/dist/node/include/node_webstorage.h +60 -0
  206. package/dist/node/include/node_worker.h +158 -0
  207. package/dist/node/include/path.h +33 -0
  208. package/dist/node/include/permission/addon_permission.h +31 -0
  209. package/dist/node/include/permission/child_process_permission.h +31 -0
  210. package/dist/node/include/permission/fs_permission.h +167 -0
  211. package/dist/node/include/permission/inspector_permission.h +31 -0
  212. package/dist/node/include/permission/permission.h +138 -0
  213. package/dist/node/include/permission/permission_base.h +65 -0
  214. package/dist/node/include/permission/wasi_permission.h +31 -0
  215. package/dist/node/include/permission/worker_permission.h +31 -0
  216. package/dist/node/include/pipe_wrap.h +80 -0
  217. package/dist/node/include/quic/application.h +159 -0
  218. package/dist/node/include/quic/bindingdata.h +272 -0
  219. package/dist/node/include/quic/cid.h +127 -0
  220. package/dist/node/include/quic/data.h +148 -0
  221. package/dist/node/include/quic/defs.h +245 -0
  222. package/dist/node/include/quic/endpoint.h +458 -0
  223. package/dist/node/include/quic/http3.h +15 -0
  224. package/dist/node/include/quic/logstream.h +81 -0
  225. package/dist/node/include/quic/packet.h +152 -0
  226. package/dist/node/include/quic/preferredaddress.h +72 -0
  227. package/dist/node/include/quic/session.h +443 -0
  228. package/dist/node/include/quic/sessionticket.h +108 -0
  229. package/dist/node/include/quic/streams.h +232 -0
  230. package/dist/node/include/quic/tlscontext.h +227 -0
  231. package/dist/node/include/quic/tokens.h +256 -0
  232. package/dist/node/include/quic/transportparams.h +165 -0
  233. package/dist/node/include/req_wrap-inl.h +171 -0
  234. package/dist/node/include/req_wrap.h +77 -0
  235. package/dist/node/include/spawn_sync.h +243 -0
  236. package/dist/node/include/stream_base-inl.h +173 -0
  237. package/dist/node/include/stream_base.h +478 -0
  238. package/dist/node/include/stream_pipe.h +76 -0
  239. package/dist/node/include/stream_wrap.h +132 -0
  240. package/dist/node/include/string_bytes.h +113 -0
  241. package/dist/node/include/string_decoder-inl.h +31 -0
  242. package/dist/node/include/string_decoder.h +49 -0
  243. package/dist/node/include/tcp_wrap.h +105 -0
  244. package/dist/node/include/threadpoolwork-inl.h +70 -0
  245. package/dist/node/include/timer_wrap-inl.h +32 -0
  246. package/dist/node/include/timer_wrap.h +85 -0
  247. package/dist/node/include/timers.h +70 -0
  248. package/dist/node/include/tracing/agent.h +195 -0
  249. package/dist/node/include/tracing/node_trace_buffer.h +83 -0
  250. package/dist/node/include/tracing/node_trace_writer.h +75 -0
  251. package/dist/node/include/tracing/trace_event.h +722 -0
  252. package/dist/node/include/tracing/trace_event_common.h +1109 -0
  253. package/dist/node/include/tracing/traced_value.h +129 -0
  254. package/dist/node/include/tty_wrap.h +65 -0
  255. package/dist/node/include/udp_wrap.h +230 -0
  256. package/dist/node/include/undici_version.h +6 -0
  257. package/dist/node/include/util-inl.h +700 -0
  258. package/dist/node/include/util.h +1021 -0
  259. package/dist/node/include/uv/aix.h +32 -0
  260. package/dist/node/include/uv/bsd.h +34 -0
  261. package/dist/node/include/uv/darwin.h +61 -0
  262. package/dist/node/include/uv/errno.h +483 -0
  263. package/dist/node/include/uv/linux.h +34 -0
  264. package/dist/node/include/uv/os390.h +33 -0
  265. package/dist/node/include/uv/posix.h +31 -0
  266. package/dist/node/include/uv/sunos.h +44 -0
  267. package/dist/node/include/uv/threadpool.h +37 -0
  268. package/dist/node/include/uv/tree.h +521 -0
  269. package/dist/node/include/uv/unix.h +512 -0
  270. package/dist/node/include/uv/version.h +43 -0
  271. package/dist/node/include/uv/win.h +698 -0
  272. package/dist/node/include/uv.h +1990 -0
  273. package/dist/node/include/v8-array-buffer.h +525 -0
  274. package/dist/node/include/v8-callbacks.h +462 -0
  275. package/dist/node/include/v8-container.h +183 -0
  276. package/dist/node/include/v8-context.h +485 -0
  277. package/dist/node/include/v8-cppgc.h +245 -0
  278. package/dist/node/include/v8-data.h +80 -0
  279. package/dist/node/include/v8-date.h +48 -0
  280. package/dist/node/include/v8-debug.h +168 -0
  281. package/dist/node/include/v8-embedder-heap.h +82 -0
  282. package/dist/node/include/v8-embedder-state-scope.h +52 -0
  283. package/dist/node/include/v8-exception.h +223 -0
  284. package/dist/node/include/v8-extension.h +62 -0
  285. package/dist/node/include/v8-external.h +37 -0
  286. package/dist/node/include/v8-fast-api-calls.h +984 -0
  287. package/dist/node/include/v8-forward.h +82 -0
  288. package/dist/node/include/v8-function-callback.h +607 -0
  289. package/dist/node/include/v8-function.h +140 -0
  290. package/dist/node/include/v8-handle-base.h +137 -0
  291. package/dist/node/include/v8-initialization.h +289 -0
  292. package/dist/node/include/v8-inspector-protocol.h +13 -0
  293. package/dist/node/include/v8-inspector.h +419 -0
  294. package/dist/node/include/v8-internal.h +1397 -0
  295. package/dist/node/include/v8-isolate.h +1767 -0
  296. package/dist/node/include/v8-json.h +47 -0
  297. package/dist/node/include/v8-local-handle.h +758 -0
  298. package/dist/node/include/v8-locker.h +138 -0
  299. package/dist/node/include/v8-maybe.h +160 -0
  300. package/dist/node/include/v8-memory-span.h +198 -0
  301. package/dist/node/include/v8-message.h +233 -0
  302. package/dist/node/include/v8-metrics.h +264 -0
  303. package/dist/node/include/v8-microtask-queue.h +157 -0
  304. package/dist/node/include/v8-microtask.h +28 -0
  305. package/dist/node/include/v8-object.h +824 -0
  306. package/dist/node/include/v8-persistent-handle.h +582 -0
  307. package/dist/node/include/v8-platform.h +1358 -0
  308. package/dist/node/include/v8-primitive-object.h +118 -0
  309. package/dist/node/include/v8-primitive.h +877 -0
  310. package/dist/node/include/v8-profiler.h +1302 -0
  311. package/dist/node/include/v8-promise.h +174 -0
  312. package/dist/node/include/v8-proxy.h +50 -0
  313. package/dist/node/include/v8-regexp.h +106 -0
  314. package/dist/node/include/v8-script.h +904 -0
  315. package/dist/node/include/v8-snapshot.h +266 -0
  316. package/dist/node/include/v8-source-location.h +92 -0
  317. package/dist/node/include/v8-statistics.h +238 -0
  318. package/dist/node/include/v8-template.h +1297 -0
  319. package/dist/node/include/v8-traced-handle.h +432 -0
  320. package/dist/node/include/v8-typed-array.h +390 -0
  321. package/dist/node/include/v8-unwinder-state.h +31 -0
  322. package/dist/node/include/v8-unwinder.h +132 -0
  323. package/dist/node/include/v8-util.h +665 -0
  324. package/dist/node/include/v8-value-serializer-version.h +24 -0
  325. package/dist/node/include/v8-value-serializer.h +316 -0
  326. package/dist/node/include/v8-value.h +655 -0
  327. package/dist/node/include/v8-version-string.h +38 -0
  328. package/dist/node/include/v8-version.h +20 -0
  329. package/dist/node/include/v8-wasm-trap-handler-posix.h +31 -0
  330. package/dist/node/include/v8-wasm-trap-handler-win.h +28 -0
  331. package/dist/node/include/v8-wasm.h +201 -0
  332. package/dist/node/include/v8-weak-callback-info.h +80 -0
  333. package/dist/node/include/v8.h +88 -0
  334. package/dist/node/include/v8config.h +981 -0
  335. package/dist/node/include/zlib_version.h +6 -0
  336. package/dist/node/libnode.dll +0 -0
  337. package/dist/node/libnode.lib +0 -0
  338. package/dist/node/libnodebuildinfo.json +10 -0
  339. package/dist/node/link_node.lib +0 -0
  340. package/dist/node/link_node.node +0 -0
  341. package/index.js +5 -0
  342. package/libnode.release.json +8 -0
  343. package/package.json +29 -1
@@ -0,0 +1,65 @@
1
+ #ifndef SRC_PERMISSION_PERMISSION_BASE_H_
2
+ #define SRC_PERMISSION_PERMISSION_BASE_H_
3
+
4
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
+
6
+ #include <map>
7
+ #include <string>
8
+ #include <string_view>
9
+ #include "v8.h"
10
+
11
+ namespace node {
12
+
13
+ class Environment;
14
+
15
+ namespace permission {
16
+
17
+ #define FILESYSTEM_PERMISSIONS(V) \
18
+ V(FileSystem, "fs", PermissionsRoot, "") \
19
+ V(FileSystemRead, "fs.read", FileSystem, "--allow-fs-read") \
20
+ V(FileSystemWrite, "fs.write", FileSystem, "--allow-fs-write")
21
+
22
+ #define CHILD_PROCESS_PERMISSIONS(V) \
23
+ V(ChildProcess, "child", PermissionsRoot, "--allow-child-process")
24
+
25
+ #define WASI_PERMISSIONS(V) V(WASI, "wasi", PermissionsRoot, "--allow-wasi")
26
+
27
+ #define WORKER_THREADS_PERMISSIONS(V) \
28
+ V(WorkerThreads, "worker", PermissionsRoot, "--allow-worker")
29
+
30
+ #define INSPECTOR_PERMISSIONS(V) V(Inspector, "inspector", PermissionsRoot, "")
31
+
32
+ #define ADDON_PERMISSIONS(V) \
33
+ V(Addon, "addon", PermissionsRoot, "--allow-addons")
34
+
35
+ #define PERMISSIONS(V) \
36
+ FILESYSTEM_PERMISSIONS(V) \
37
+ CHILD_PROCESS_PERMISSIONS(V) \
38
+ WASI_PERMISSIONS(V) \
39
+ WORKER_THREADS_PERMISSIONS(V) \
40
+ INSPECTOR_PERMISSIONS(V) \
41
+ ADDON_PERMISSIONS(V)
42
+
43
+ #define V(name, _, __, ___) k##name,
44
+ enum class PermissionScope {
45
+ kPermissionsRoot = -1,
46
+ PERMISSIONS(V) kPermissionsCount
47
+ };
48
+ #undef V
49
+
50
+ class PermissionBase {
51
+ public:
52
+ virtual void Apply(Environment* env,
53
+ const std::vector<std::string>& allow,
54
+ PermissionScope scope) = 0;
55
+ virtual bool is_granted(Environment* env,
56
+ PermissionScope perm,
57
+ const std::string_view& param = "") const = 0;
58
+ };
59
+
60
+ } // namespace permission
61
+
62
+ } // namespace node
63
+
64
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
65
+ #endif // SRC_PERMISSION_PERMISSION_BASE_H_
@@ -0,0 +1,31 @@
1
+ #ifndef SRC_PERMISSION_WASI_PERMISSION_H_
2
+ #define SRC_PERMISSION_WASI_PERMISSION_H_
3
+
4
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
+
6
+ #include <vector>
7
+ #include "permission/permission_base.h"
8
+
9
+ namespace node {
10
+
11
+ namespace permission {
12
+
13
+ class WASIPermission final : public PermissionBase {
14
+ public:
15
+ void Apply(Environment* env,
16
+ const std::vector<std::string>& allow,
17
+ PermissionScope scope) override;
18
+ bool is_granted(Environment* env,
19
+ PermissionScope perm,
20
+ const std::string_view& param = "") const override;
21
+
22
+ private:
23
+ bool deny_all_;
24
+ };
25
+
26
+ } // namespace permission
27
+
28
+ } // namespace node
29
+
30
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
31
+ #endif // SRC_PERMISSION_WASI_PERMISSION_H_
@@ -0,0 +1,31 @@
1
+ #ifndef SRC_PERMISSION_WORKER_PERMISSION_H_
2
+ #define SRC_PERMISSION_WORKER_PERMISSION_H_
3
+
4
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
+
6
+ #include <vector>
7
+ #include "permission/permission_base.h"
8
+
9
+ namespace node {
10
+
11
+ namespace permission {
12
+
13
+ class WorkerPermission final : public PermissionBase {
14
+ public:
15
+ void Apply(Environment* env,
16
+ const std::vector<std::string>& allow,
17
+ PermissionScope scope) override;
18
+ bool is_granted(Environment* env,
19
+ PermissionScope perm,
20
+ const std::string_view& param = "") const override;
21
+
22
+ private:
23
+ bool deny_all_;
24
+ };
25
+
26
+ } // namespace permission
27
+
28
+ } // namespace node
29
+
30
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
31
+ #endif // SRC_PERMISSION_WORKER_PERMISSION_H_
@@ -0,0 +1,80 @@
1
+ // Copyright Joyent, Inc. and other Node contributors.
2
+ //
3
+ // Permission is hereby granted, free of charge, to any person obtaining a
4
+ // copy of this software and associated documentation files (the
5
+ // "Software"), to deal in the Software without restriction, including
6
+ // without limitation the rights to use, copy, modify, merge, publish,
7
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
8
+ // persons to whom the Software is furnished to do so, subject to the
9
+ // following conditions:
10
+ //
11
+ // The above copyright notice and this permission notice shall be included
12
+ // in all copies or substantial portions of the Software.
13
+ //
14
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ #ifndef SRC_PIPE_WRAP_H_
23
+ #define SRC_PIPE_WRAP_H_
24
+
25
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
26
+
27
+ #include "async_wrap.h"
28
+ #include "connection_wrap.h"
29
+
30
+ namespace node {
31
+
32
+ class ExternalReferenceRegistry;
33
+ class Environment;
34
+
35
+ class PipeWrap : public ConnectionWrap<PipeWrap, uv_pipe_t> {
36
+ public:
37
+ enum SocketType {
38
+ SOCKET,
39
+ SERVER,
40
+ IPC
41
+ };
42
+
43
+ static v8::MaybeLocal<v8::Object> Instantiate(Environment* env,
44
+ AsyncWrap* parent,
45
+ SocketType type);
46
+ static void Initialize(v8::Local<v8::Object> target,
47
+ v8::Local<v8::Value> unused,
48
+ v8::Local<v8::Context> context,
49
+ void* priv);
50
+
51
+ static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
52
+ SET_NO_MEMORY_INFO()
53
+ SET_MEMORY_INFO_NAME(PipeWrap)
54
+ SET_SELF_SIZE(PipeWrap)
55
+
56
+ private:
57
+ PipeWrap(Environment* env,
58
+ v8::Local<v8::Object> object,
59
+ ProviderType provider,
60
+ bool ipc);
61
+
62
+ static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
63
+ static void Bind(const v8::FunctionCallbackInfo<v8::Value>& args);
64
+ static void Listen(const v8::FunctionCallbackInfo<v8::Value>& args);
65
+ static void Connect(const v8::FunctionCallbackInfo<v8::Value>& args);
66
+ static void Open(const v8::FunctionCallbackInfo<v8::Value>& args);
67
+
68
+ #ifdef _WIN32
69
+ static void SetPendingInstances(
70
+ const v8::FunctionCallbackInfo<v8::Value>& args);
71
+ #endif
72
+ static void Fchmod(const v8::FunctionCallbackInfo<v8::Value>& args);
73
+ };
74
+
75
+
76
+ } // namespace node
77
+
78
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
79
+
80
+ #endif // SRC_PIPE_WRAP_H_
@@ -0,0 +1,159 @@
1
+ #pragma once
2
+
3
+ #include "quic/defs.h"
4
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
+ #if HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC
6
+
7
+ #include "bindingdata.h"
8
+ #include "defs.h"
9
+ #include "session.h"
10
+ #include "sessionticket.h"
11
+ #include "streams.h"
12
+
13
+ namespace node::quic {
14
+
15
+ // An Application implements the ALPN-protocol specific semantics on behalf
16
+ // of a QUIC Session.
17
+ class Session::Application : public MemoryRetainer {
18
+ public:
19
+ using Options = Session::Application_Options;
20
+
21
+ Application(Session* session, const Options& options);
22
+ DISALLOW_COPY_AND_MOVE(Application)
23
+
24
+ virtual bool Start();
25
+
26
+ // Session will forward all received stream data immediately on to the
27
+ // Application. The only additional processing the Session does is to
28
+ // automatically adjust the session-level flow control window. It is up to
29
+ // the Application to do the same for the Stream-level flow control.
30
+ virtual bool ReceiveStreamData(Stream* stream,
31
+ const uint8_t* data,
32
+ size_t datalen,
33
+ Stream::ReceiveDataFlags flags) = 0;
34
+
35
+ // Session will forward all data acknowledgements for a stream to the
36
+ // Application.
37
+ virtual void AcknowledgeStreamData(Stream* stream, size_t datalen);
38
+
39
+ // Called to determine if a Header can be added to this application.
40
+ // Applications that do not support headers will always return false.
41
+ virtual bool CanAddHeader(size_t current_count,
42
+ size_t current_headers_length,
43
+ size_t this_header_length);
44
+
45
+ // Called to mark the identified stream as being blocked. Not all
46
+ // Application types will support blocked streams, and those that do will do
47
+ // so differently.
48
+ virtual void BlockStream(int64_t id);
49
+
50
+ // Called when the session determines that there is outbound data available
51
+ // to send for the given stream.
52
+ virtual void ResumeStream(int64_t id);
53
+
54
+ // Called when the Session determines that the maximum number of
55
+ // remotely-initiated unidirectional streams has been extended. Not all
56
+ // Application types will require this notification so the default is to do
57
+ // nothing.
58
+ virtual void ExtendMaxStreams(EndpointLabel label,
59
+ Direction direction,
60
+ uint64_t max_streams);
61
+
62
+ // Called when the Session determines that the flow control window for the
63
+ // given stream has been expanded. Not all Application types will require
64
+ // this notification so the default is to do nothing.
65
+ virtual void ExtendMaxStreamData(Stream* stream, uint64_t max_data);
66
+
67
+ // Different Applications may wish to set some application data in the
68
+ // session ticket (e.g. http/3 would set server settings in the application
69
+ // data). By default, there's nothing to set.
70
+ virtual void CollectSessionTicketAppData(
71
+ SessionTicket::AppData* app_data) const;
72
+
73
+ // Different Applications may set some application data in the session
74
+ // ticket (e.g. http/3 would set server settings in the application data).
75
+ // By default, there's nothing to get.
76
+ virtual SessionTicket::AppData::Status ExtractSessionTicketAppData(
77
+ const SessionTicket::AppData& app_data,
78
+ SessionTicket::AppData::Source::Flag flag);
79
+
80
+ // Notifies the Application that the identified stream has been closed.
81
+ virtual void StreamClose(Stream* stream, QuicError error = QuicError());
82
+
83
+ // Notifies the Application that the identified stream has been reset.
84
+ virtual void StreamReset(Stream* stream,
85
+ uint64_t final_size,
86
+ QuicError error);
87
+
88
+ // Notifies the Application that the identified stream should stop sending.
89
+ virtual void StreamStopSending(Stream* stream, QuicError error);
90
+
91
+ // Submits an outbound block of headers for the given stream. Not all
92
+ // Application types will support headers, in which case this function
93
+ // should return false.
94
+ virtual bool SendHeaders(const Stream& stream,
95
+ HeadersKind kind,
96
+ const v8::Local<v8::Array>& headers,
97
+ HeadersFlags flags = HeadersFlags::NONE);
98
+
99
+ // Signals to the Application that it should serialize and transmit any
100
+ // pending session and stream packets it has accumulated.
101
+ void SendPendingData();
102
+
103
+ // Set the priority level of the stream if supported by the application. Not
104
+ // all applications support priorities, in which case this function is a
105
+ // non-op.
106
+ virtual void SetStreamPriority(
107
+ const Stream& stream,
108
+ StreamPriority priority = StreamPriority::DEFAULT,
109
+ StreamPriorityFlags flags = StreamPriorityFlags::NONE);
110
+
111
+ // Get the priority level of the stream if supported by the application. Not
112
+ // all applications support priorities, in which case this function returns
113
+ // the default stream priority.
114
+ virtual StreamPriority GetStreamPriority(const Stream& stream);
115
+
116
+ struct StreamData;
117
+
118
+ virtual int GetStreamData(StreamData* data) = 0;
119
+ virtual bool StreamCommit(StreamData* data, size_t datalen) = 0;
120
+ virtual bool ShouldSetFin(const StreamData& data) = 0;
121
+
122
+ inline Environment* env() const { return session_->env(); }
123
+ inline Session& session() { return *session_; }
124
+ inline const Session& session() const { return *session_; }
125
+
126
+ private:
127
+ Packet* CreateStreamDataPacket();
128
+
129
+ // Write the given stream_data into the buffer.
130
+ ssize_t WriteVStream(PathStorage* path,
131
+ uint8_t* buf,
132
+ ssize_t* ndatalen,
133
+ size_t max_packet_size,
134
+ const StreamData& stream_data);
135
+
136
+ Session* session_;
137
+ };
138
+
139
+ struct Session::Application::StreamData final {
140
+ // The actual number of vectors in the struct, up to kMaxVectorCount.
141
+ size_t count = 0;
142
+ size_t remaining = 0;
143
+ // The stream identifier. If this is a negative value then no stream is
144
+ // identified.
145
+ int64_t id = -1;
146
+ int fin = 0;
147
+ ngtcp2_vec data[kMaxVectorCount]{};
148
+ ngtcp2_vec* buf = data;
149
+ BaseObjectPtr<Stream> stream;
150
+
151
+ inline operator nghttp3_vec() const { return {data[0].base, data[0].len}; }
152
+
153
+ std::string ToString() const;
154
+ };
155
+
156
+ } // namespace node::quic
157
+
158
+ #endif // HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC
159
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
@@ -0,0 +1,272 @@
1
+ #pragma once
2
+
3
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
4
+ #if HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC
5
+
6
+ #include <base_object.h>
7
+ #include <env.h>
8
+ #include <memory_tracker.h>
9
+ #include <nghttp3/nghttp3.h>
10
+ #include <ngtcp2/ngtcp2.h>
11
+ #include <ngtcp2/ngtcp2_crypto.h>
12
+ #include <node.h>
13
+ #include <node_mem.h>
14
+ #include <v8.h>
15
+ #include <unordered_map>
16
+ #include <vector>
17
+ #include "defs.h"
18
+
19
+ namespace node::quic {
20
+
21
+ class Endpoint;
22
+ class Packet;
23
+
24
+ // ============================================================================
25
+
26
+ // The FunctionTemplates the BindingData will store for us.
27
+ #define QUIC_CONSTRUCTORS(V) \
28
+ V(endpoint) \
29
+ V(logstream) \
30
+ V(packet) \
31
+ V(session) \
32
+ V(stream) \
33
+ V(udp)
34
+
35
+ // The callbacks are persistent v8::Function references that are set in the
36
+ // quic::BindingState used to communicate data and events back out to the JS
37
+ // environment. They are set once from the JavaScript side when the
38
+ // internalBinding('quic') is first loaded.
39
+ #define QUIC_JS_CALLBACKS(V) \
40
+ V(endpoint_close, EndpointClose) \
41
+ V(session_new, SessionNew) \
42
+ V(session_close, SessionClose) \
43
+ V(session_datagram, SessionDatagram) \
44
+ V(session_datagram_status, SessionDatagramStatus) \
45
+ V(session_handshake, SessionHandshake) \
46
+ V(session_ticket, SessionTicket) \
47
+ V(session_version_negotiation, SessionVersionNegotiation) \
48
+ V(session_path_validation, SessionPathValidation) \
49
+ V(stream_close, StreamClose) \
50
+ V(stream_created, StreamCreated) \
51
+ V(stream_reset, StreamReset) \
52
+ V(stream_headers, StreamHeaders) \
53
+ V(stream_blocked, StreamBlocked) \
54
+ V(stream_trailers, StreamTrailers)
55
+
56
+ // The various JS strings the implementation uses.
57
+ #define QUIC_STRINGS(V) \
58
+ V(aborted, "aborted") \
59
+ V(acknowledged, "acknowledged") \
60
+ V(ack_delay_exponent, "ackDelayExponent") \
61
+ V(active_connection_id_limit, "activeConnectionIDLimit") \
62
+ V(address_lru_size, "addressLRUSize") \
63
+ V(alpn, "alpn") \
64
+ V(application_options, "application") \
65
+ V(bbr, "bbr") \
66
+ V(ca, "ca") \
67
+ V(certs, "certs") \
68
+ V(cc_algorithm, "cc") \
69
+ V(crl, "crl") \
70
+ V(ciphers, "ciphers") \
71
+ V(cubic, "cubic") \
72
+ V(disable_active_migration, "disableActiveMigration") \
73
+ V(disable_stateless_reset, "disableStatelessReset") \
74
+ V(enable_connect_protocol, "enableConnectProtocol") \
75
+ V(enable_datagrams, "enableDatagrams") \
76
+ V(enable_tls_trace, "tlsTrace") \
77
+ V(endpoint, "Endpoint") \
78
+ V(endpoint_udp, "Endpoint::UDP") \
79
+ V(failure, "failure") \
80
+ V(groups, "groups") \
81
+ V(handshake_timeout, "handshakeTimeout") \
82
+ V(http3_alpn, &NGHTTP3_ALPN_H3[1]) \
83
+ V(initial_max_data, "initialMaxData") \
84
+ V(initial_max_stream_data_bidi_local, "initialMaxStreamDataBidiLocal") \
85
+ V(initial_max_stream_data_bidi_remote, "initialMaxStreamDataBidiRemote") \
86
+ V(initial_max_stream_data_uni, "initialMaxStreamDataUni") \
87
+ V(initial_max_streams_bidi, "initialMaxStreamsBidi") \
88
+ V(initial_max_streams_uni, "initialMaxStreamsUni") \
89
+ V(ipv6_only, "ipv6Only") \
90
+ V(keylog, "keylog") \
91
+ V(keys, "keys") \
92
+ V(logstream, "LogStream") \
93
+ V(lost, "lost") \
94
+ V(max_ack_delay, "maxAckDelay") \
95
+ V(max_connections_per_host, "maxConnectionsPerHost") \
96
+ V(max_connections_total, "maxConnectionsTotal") \
97
+ V(max_datagram_frame_size, "maxDatagramFrameSize") \
98
+ V(max_field_section_size, "maxFieldSectionSize") \
99
+ V(max_header_length, "maxHeaderLength") \
100
+ V(max_header_pairs, "maxHeaderPairs") \
101
+ V(max_idle_timeout, "maxIdleTimeout") \
102
+ V(max_payload_size, "maxPayloadSize") \
103
+ V(max_retries, "maxRetries") \
104
+ V(max_stateless_resets, "maxStatelessResetsPerHost") \
105
+ V(max_stream_window, "maxStreamWindow") \
106
+ V(max_window, "maxWindow") \
107
+ V(min_version, "minVersion") \
108
+ V(no_udp_payload_size_shaping, "noUdpPayloadSizeShaping") \
109
+ V(packetwrap, "PacketWrap") \
110
+ V(preferred_address_strategy, "preferredAddressPolicy") \
111
+ V(qlog, "qlog") \
112
+ V(qpack_blocked_streams, "qpackBlockedStreams") \
113
+ V(qpack_encoder_max_dtable_capacity, "qpackEncoderMaxDTableCapacity") \
114
+ V(qpack_max_dtable_capacity, "qpackMaxDTableCapacity") \
115
+ V(reject_unauthorized, "rejectUnauthorized") \
116
+ V(reno, "reno") \
117
+ V(retry_token_expiration, "retryTokenExpiration") \
118
+ V(reset_token_secret, "resetTokenSecret") \
119
+ V(rx_loss, "rxDiagnosticLoss") \
120
+ V(session, "Session") \
121
+ V(sni, "sni") \
122
+ V(stream, "Stream") \
123
+ V(success, "success") \
124
+ V(tls_options, "tls") \
125
+ V(token_expiration, "tokenExpiration") \
126
+ V(token_secret, "tokenSecret") \
127
+ V(transport_params, "transportParams") \
128
+ V(tx_loss, "txDiagnosticLoss") \
129
+ V(udp_receive_buffer_size, "udpReceiveBufferSize") \
130
+ V(udp_send_buffer_size, "udpSendBufferSize") \
131
+ V(udp_ttl, "udpTTL") \
132
+ V(unacknowledged_packet_threshold, "unacknowledgedPacketThreshold") \
133
+ V(validate_address, "validateAddress") \
134
+ V(verify_client, "verifyClient") \
135
+ V(verify_private_key, "verifyPrivateKey") \
136
+ V(version, "version")
137
+
138
+ // =============================================================================
139
+ // The BindingState object holds state for the internalBinding('quic') binding
140
+ // instance. It is mostly used to hold the persistent constructors, strings, and
141
+ // callback references used for the rest of the implementation.
142
+ //
143
+ // TODO(@jasnell): Make this snapshotable?
144
+ class BindingData final
145
+ : public BaseObject,
146
+ public mem::NgLibMemoryManager<BindingData, ngtcp2_mem> {
147
+ public:
148
+ SET_BINDING_ID(quic_binding_data)
149
+ static void InitPerContext(Realm* realm, v8::Local<v8::Object> target);
150
+ static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
151
+
152
+ static BindingData& Get(Environment* env);
153
+
154
+ BindingData(Realm* realm, v8::Local<v8::Object> object);
155
+ DISALLOW_COPY_AND_MOVE(BindingData)
156
+
157
+ void MemoryInfo(MemoryTracker* tracker) const override;
158
+ SET_MEMORY_INFO_NAME(BindingData)
159
+ SET_SELF_SIZE(BindingData)
160
+
161
+ // NgLibMemoryManager
162
+ operator ngtcp2_mem();
163
+ operator nghttp3_mem();
164
+ void CheckAllocatedSize(size_t previous_size) const;
165
+ void IncreaseAllocatedSize(size_t size);
166
+ void DecreaseAllocatedSize(size_t size);
167
+
168
+ // Installs the set of JavaScript callback functions that are used to
169
+ // bridge out to the JS API.
170
+ static void SetCallbacks(const v8::FunctionCallbackInfo<v8::Value>& args);
171
+
172
+ std::vector<Packet*> packet_freelist;
173
+
174
+ std::unordered_map<Endpoint*, BaseObjectPtr<BaseObject>> listening_endpoints;
175
+
176
+ // Purge the packet free list to free up memory.
177
+ static void FlushPacketFreelist(
178
+ const v8::FunctionCallbackInfo<v8::Value>& args);
179
+
180
+ bool in_ngtcp2_callback_scope = false;
181
+ bool in_nghttp3_callback_scope = false;
182
+
183
+ // The following set up various storage and accessors for common strings,
184
+ // construction templates, and callbacks stored on the BindingData. These
185
+ // are all defined in defs.h
186
+
187
+ #define V(name) \
188
+ void set_##name##_constructor_template( \
189
+ v8::Local<v8::FunctionTemplate> tmpl); \
190
+ v8::Local<v8::FunctionTemplate> name##_constructor_template() const;
191
+ QUIC_CONSTRUCTORS(V)
192
+ #undef V
193
+
194
+ #define V(name, _) \
195
+ void set_##name##_callback(v8::Local<v8::Function> fn); \
196
+ v8::Local<v8::Function> name##_callback() const;
197
+ QUIC_JS_CALLBACKS(V)
198
+ #undef V
199
+
200
+ #define V(name, _) v8::Local<v8::String> name##_string() const;
201
+ QUIC_STRINGS(V)
202
+ #undef V
203
+
204
+ #define V(name, _) v8::Local<v8::String> on_##name##_string() const;
205
+ QUIC_JS_CALLBACKS(V)
206
+ #undef V
207
+
208
+ size_t current_ngtcp2_memory_ = 0;
209
+
210
+ #define V(name) v8::Global<v8::FunctionTemplate> name##_constructor_template_;
211
+ QUIC_CONSTRUCTORS(V)
212
+ #undef V
213
+
214
+ #define V(name, _) v8::Global<v8::Function> name##_callback_;
215
+ QUIC_JS_CALLBACKS(V)
216
+ #undef V
217
+
218
+ #define V(name, _) mutable v8::Eternal<v8::String> name##_string_;
219
+ QUIC_STRINGS(V)
220
+ #undef V
221
+
222
+ #define V(name, _) mutable v8::Eternal<v8::String> on_##name##_string_;
223
+ QUIC_JS_CALLBACKS(V)
224
+ #undef V
225
+ };
226
+
227
+ void IllegalConstructor(const v8::FunctionCallbackInfo<v8::Value>& args);
228
+
229
+ // The ngtcp2 and nghttp3 callbacks have certain restrictions
230
+ // that forbid re-entry. We provide the following scopes for
231
+ // use in those to help protect against it.
232
+ struct NgTcp2CallbackScope {
233
+ Environment* env;
234
+ explicit NgTcp2CallbackScope(Environment* env);
235
+ DISALLOW_COPY_AND_MOVE(NgTcp2CallbackScope)
236
+ ~NgTcp2CallbackScope();
237
+ static bool in_ngtcp2_callback(Environment* env);
238
+ };
239
+
240
+ struct NgHttp3CallbackScope {
241
+ Environment* env;
242
+ explicit NgHttp3CallbackScope(Environment* env);
243
+ DISALLOW_COPY_AND_MOVE(NgHttp3CallbackScope)
244
+ ~NgHttp3CallbackScope();
245
+ static bool in_nghttp3_callback(Environment* env);
246
+ };
247
+
248
+ struct CallbackScopeBase {
249
+ Environment* env;
250
+ v8::Context::Scope context_scope;
251
+ v8::TryCatch try_catch;
252
+
253
+ explicit CallbackScopeBase(Environment* env);
254
+ DISALLOW_COPY_AND_MOVE(CallbackScopeBase)
255
+ ~CallbackScopeBase();
256
+ };
257
+
258
+ // Maintains a strong reference to BaseObject type ptr to keep it alive during
259
+ // a MakeCallback during which it might be destroyed.
260
+ template <typename T>
261
+ struct CallbackScope final : public CallbackScopeBase {
262
+ BaseObjectPtr<T> ref;
263
+ explicit CallbackScope(const T* ptr)
264
+ : CallbackScopeBase(ptr->env()), ref(ptr) {}
265
+ DISALLOW_COPY_AND_MOVE(CallbackScope)
266
+ explicit CallbackScope(T* ptr) : CallbackScopeBase(ptr->env()), ref(ptr) {}
267
+ };
268
+
269
+ } // namespace node::quic
270
+
271
+ #endif // HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC
272
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS