@encharm/cws 4.5.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 (237) hide show
  1. package/binding.gyp +1 -1
  2. package/dist/bindings/cws_darwin_arm64_node137.node +0 -0
  3. package/dist/bindings/cws_linux_x64_node137.node +0 -0
  4. package/package.json +1 -1
  5. package/src/Addon.h +6 -1
  6. package/src/headers/24/acorn_version.h +6 -0
  7. package/src/headers/24/addon_permission.h +31 -0
  8. package/src/headers/24/agent.h +195 -0
  9. package/src/headers/24/aliased_buffer-inl.h +244 -0
  10. package/src/headers/24/aliased_buffer.h +206 -0
  11. package/src/headers/24/aliased_struct-inl.h +54 -0
  12. package/src/headers/24/aliased_struct.h +63 -0
  13. package/src/headers/24/amaro_version.h +6 -0
  14. package/src/headers/24/application.h +165 -0
  15. package/src/headers/24/async_context_frame.h +33 -0
  16. package/src/headers/24/async_wrap-inl.h +96 -0
  17. package/src/headers/24/async_wrap.h +244 -0
  18. package/src/headers/24/base_object-inl.h +330 -0
  19. package/src/headers/24/base_object.h +338 -0
  20. package/src/headers/24/base_object_types.h +74 -0
  21. package/src/headers/24/bindingdata.h +272 -0
  22. package/src/headers/24/blob_serializer_deserializer-inl.h +385 -0
  23. package/src/headers/24/blob_serializer_deserializer.h +132 -0
  24. package/src/headers/24/callback_queue-inl.h +97 -0
  25. package/src/headers/24/callback_queue.h +79 -0
  26. package/src/headers/24/cares_wrap.h +447 -0
  27. package/src/headers/24/child_process_permission.h +31 -0
  28. package/src/headers/24/cid.h +127 -0
  29. package/src/headers/24/cjs_module_lexer_version.h +6 -0
  30. package/src/headers/24/cleanup_queue-inl.h +36 -0
  31. package/src/headers/24/cleanup_queue.h +79 -0
  32. package/src/headers/24/compile_cache.h +113 -0
  33. package/src/headers/24/connect_wrap.h +26 -0
  34. package/src/headers/24/connection_wrap.h +30 -0
  35. package/src/headers/24/cppgc_helpers-inl.h +65 -0
  36. package/src/headers/24/cppgc_helpers.h +162 -0
  37. package/src/headers/24/crypto/crypto_aes.h +97 -0
  38. package/src/headers/24/crypto/crypto_argon2.h +86 -0
  39. package/src/headers/24/crypto/crypto_bio.h +193 -0
  40. package/src/headers/24/crypto/crypto_chacha20_poly1305.h +64 -0
  41. package/src/headers/24/crypto/crypto_cipher.h +281 -0
  42. package/src/headers/24/crypto/crypto_clienthello-inl.h +90 -0
  43. package/src/headers/24/crypto/crypto_clienthello.h +131 -0
  44. package/src/headers/24/crypto/crypto_common.h +48 -0
  45. package/src/headers/24/crypto/crypto_context.h +171 -0
  46. package/src/headers/24/crypto/crypto_dh.h +126 -0
  47. package/src/headers/24/crypto/crypto_dsa.h +50 -0
  48. package/src/headers/24/crypto/crypto_ec.h +163 -0
  49. package/src/headers/24/crypto/crypto_hash.h +89 -0
  50. package/src/headers/24/crypto/crypto_hkdf.h +61 -0
  51. package/src/headers/24/crypto/crypto_hmac.h +92 -0
  52. package/src/headers/24/crypto/crypto_kem.h +113 -0
  53. package/src/headers/24/crypto/crypto_keygen.h +290 -0
  54. package/src/headers/24/crypto/crypto_keys.h +392 -0
  55. package/src/headers/24/crypto/crypto_ml_dsa.h +21 -0
  56. package/src/headers/24/crypto/crypto_pbkdf2.h +74 -0
  57. package/src/headers/24/crypto/crypto_random.h +124 -0
  58. package/src/headers/24/crypto/crypto_rsa.h +136 -0
  59. package/src/headers/24/crypto/crypto_scrypt.h +85 -0
  60. package/src/headers/24/crypto/crypto_sig.h +156 -0
  61. package/src/headers/24/crypto/crypto_spkac.h +21 -0
  62. package/src/headers/24/crypto/crypto_timing.h +20 -0
  63. package/src/headers/24/crypto/crypto_tls.h +309 -0
  64. package/src/headers/24/crypto/crypto_util.h +598 -0
  65. package/src/headers/24/crypto/crypto_x509.h +140 -0
  66. package/src/headers/24/data.h +148 -0
  67. package/src/headers/24/debug_utils-inl.h +232 -0
  68. package/src/headers/24/debug_utils.h +193 -0
  69. package/src/headers/24/defs.h +254 -0
  70. package/src/headers/24/diagnosticfilename-inl.h +33 -0
  71. package/src/headers/24/embedded_data.h +17 -0
  72. package/src/headers/24/encoding_binding.h +60 -0
  73. package/src/headers/24/endpoint.h +421 -0
  74. package/src/headers/24/env-inl.h +935 -0
  75. package/src/headers/24/env.h +1257 -0
  76. package/src/headers/24/env_properties.h +561 -0
  77. package/src/headers/24/fs_permission.h +167 -0
  78. package/src/headers/24/handle_wrap.h +123 -0
  79. package/src/headers/24/histogram-inl.h +107 -0
  80. package/src/headers/24/histogram.h +279 -0
  81. package/src/headers/24/http3.h +44 -0
  82. package/src/headers/24/inspector_agent.h +165 -0
  83. package/src/headers/24/inspector_io.h +78 -0
  84. package/src/headers/24/inspector_permission.h +31 -0
  85. package/src/headers/24/inspector_profiler.h +149 -0
  86. package/src/headers/24/inspector_socket.h +60 -0
  87. package/src/headers/24/inspector_socket_server.h +110 -0
  88. package/src/headers/24/io_agent.h +30 -0
  89. package/src/headers/24/js_native_api.h +615 -0
  90. package/src/headers/24/js_native_api_types.h +211 -0
  91. package/src/headers/24/js_native_api_v8.h +485 -0
  92. package/src/headers/24/js_native_api_v8_internals.h +45 -0
  93. package/src/headers/24/js_stream.h +52 -0
  94. package/src/headers/24/json_parser.h +40 -0
  95. package/src/headers/24/json_utils.h +172 -0
  96. package/src/headers/24/logstream.h +81 -0
  97. package/src/headers/24/main_thread_interface.h +116 -0
  98. package/src/headers/24/memory_tracker-inl.h +454 -0
  99. package/src/headers/24/memory_tracker.h +333 -0
  100. package/src/headers/24/module_wrap.h +229 -0
  101. package/src/headers/24/ncrypto.h +1625 -0
  102. package/src/headers/24/network_agent.h +118 -0
  103. package/src/headers/24/network_inspector.h +45 -0
  104. package/src/headers/24/network_resource_manager.h +29 -0
  105. package/src/headers/24/node.h +1620 -0
  106. package/src/headers/24/node_api.h +269 -0
  107. package/src/headers/24/node_api_internals.h +46 -0
  108. package/src/headers/24/node_api_types.h +52 -0
  109. package/src/headers/24/node_binding.h +163 -0
  110. package/src/headers/24/node_blob.h +159 -0
  111. package/src/headers/24/node_bob-inl.h +36 -0
  112. package/src/headers/24/node_bob.h +107 -0
  113. package/src/headers/24/node_buffer.h +92 -0
  114. package/src/headers/24/node_builtins.h +223 -0
  115. package/src/headers/24/node_config_file.h +65 -0
  116. package/src/headers/24/node_constants.h +82 -0
  117. package/src/headers/24/node_context_data.h +168 -0
  118. package/src/headers/24/node_contextify.h +261 -0
  119. package/src/headers/24/node_crypto.h +62 -0
  120. package/src/headers/24/node_debug.h +25 -0
  121. package/src/headers/24/node_dir.h +52 -0
  122. package/src/headers/24/node_dotenv.h +45 -0
  123. package/src/headers/24/node_errors.h +391 -0
  124. package/src/headers/24/node_exit_code.h +54 -0
  125. package/src/headers/24/node_external_reference.h +167 -0
  126. package/src/headers/24/node_file-inl.h +412 -0
  127. package/src/headers/24/node_file.h +540 -0
  128. package/src/headers/24/node_http2.h +1175 -0
  129. package/src/headers/24/node_http2_state.h +159 -0
  130. package/src/headers/24/node_http_common-inl.h +198 -0
  131. package/src/headers/24/node_http_common.h +535 -0
  132. package/src/headers/24/node_i18n.h +132 -0
  133. package/src/headers/24/node_internals.h +476 -0
  134. package/src/headers/24/node_json.h +24 -0
  135. package/src/headers/24/node_large_page.h +34 -0
  136. package/src/headers/24/node_locks.h +180 -0
  137. package/src/headers/24/node_main_instance.h +67 -0
  138. package/src/headers/24/node_mem-inl.h +112 -0
  139. package/src/headers/24/node_mem.h +45 -0
  140. package/src/headers/24/node_messaging.h +389 -0
  141. package/src/headers/24/node_metadata.h +164 -0
  142. package/src/headers/24/node_modules.h +93 -0
  143. package/src/headers/24/node_mutex.h +323 -0
  144. package/src/headers/24/node_object_wrap.h +132 -0
  145. package/src/headers/24/node_options-inl.h +524 -0
  146. package/src/headers/24/node_options.h +682 -0
  147. package/src/headers/24/node_perf.h +166 -0
  148. package/src/headers/24/node_perf_common.h +102 -0
  149. package/src/headers/24/node_platform.h +286 -0
  150. package/src/headers/24/node_process-inl.h +26 -0
  151. package/src/headers/24/node_process.h +111 -0
  152. package/src/headers/24/node_realm-inl.h +153 -0
  153. package/src/headers/24/node_realm.h +236 -0
  154. package/src/headers/24/node_report.h +43 -0
  155. package/src/headers/24/node_revert.h +82 -0
  156. package/src/headers/24/node_root_certs.h +3546 -0
  157. package/src/headers/24/node_sea.h +74 -0
  158. package/src/headers/24/node_shadow_realm.h +46 -0
  159. package/src/headers/24/node_snapshot_builder.h +57 -0
  160. package/src/headers/24/node_snapshotable.h +174 -0
  161. package/src/headers/24/node_sockaddr-inl.h +257 -0
  162. package/src/headers/24/node_sockaddr.h +394 -0
  163. package/src/headers/24/node_sqlite.h +270 -0
  164. package/src/headers/24/node_stat_watcher.h +73 -0
  165. package/src/headers/24/node_string.h +101 -0
  166. package/src/headers/24/node_task_runner.h +92 -0
  167. package/src/headers/24/node_threadsafe_cow-inl.h +54 -0
  168. package/src/headers/24/node_threadsafe_cow.h +105 -0
  169. package/src/headers/24/node_trace_buffer.h +83 -0
  170. package/src/headers/24/node_trace_writer.h +75 -0
  171. package/src/headers/24/node_union_bytes.h +81 -0
  172. package/src/headers/24/node_url.h +101 -0
  173. package/src/headers/24/node_url_pattern.h +118 -0
  174. package/src/headers/24/node_v8.h +77 -0
  175. package/src/headers/24/node_v8_platform-inl.h +185 -0
  176. package/src/headers/24/node_version.h +110 -0
  177. package/src/headers/24/node_wasi.h +185 -0
  178. package/src/headers/24/node_wasm_web_api.h +55 -0
  179. package/src/headers/24/node_watchdog.h +154 -0
  180. package/src/headers/24/node_webstorage.h +60 -0
  181. package/src/headers/24/node_worker.h +159 -0
  182. package/src/headers/24/packet.h +155 -0
  183. package/src/headers/24/path.h +33 -0
  184. package/src/headers/24/permission/addon_permission.h +31 -0
  185. package/src/headers/24/permission/child_process_permission.h +31 -0
  186. package/src/headers/24/permission/fs_permission.h +167 -0
  187. package/src/headers/24/permission/inspector_permission.h +31 -0
  188. package/src/headers/24/permission/permission.h +100 -0
  189. package/src/headers/24/permission/permission_base.h +65 -0
  190. package/src/headers/24/permission/wasi_permission.h +31 -0
  191. package/src/headers/24/permission/worker_permission.h +31 -0
  192. package/src/headers/24/permission.h +100 -0
  193. package/src/headers/24/permission_base.h +65 -0
  194. package/src/headers/24/pipe_wrap.h +80 -0
  195. package/src/headers/24/preferredaddress.h +72 -0
  196. package/src/headers/24/protocol_helper.h +27 -0
  197. package/src/headers/24/queue.h +306 -0
  198. package/src/headers/24/req_wrap-inl.h +176 -0
  199. package/src/headers/24/req_wrap.h +79 -0
  200. package/src/headers/24/runtime_agent.h +41 -0
  201. package/src/headers/24/session.h +528 -0
  202. package/src/headers/24/sessionticket.h +108 -0
  203. package/src/headers/24/spawn_sync.h +243 -0
  204. package/src/headers/24/stream_base-inl.h +173 -0
  205. package/src/headers/24/stream_base.h +478 -0
  206. package/src/headers/24/stream_pipe.h +76 -0
  207. package/src/headers/24/stream_wrap.h +132 -0
  208. package/src/headers/24/streams.h +370 -0
  209. package/src/headers/24/string_bytes.h +109 -0
  210. package/src/headers/24/string_decoder-inl.h +31 -0
  211. package/src/headers/24/string_decoder.h +49 -0
  212. package/src/headers/24/target_agent.h +75 -0
  213. package/src/headers/24/tcp_wrap.h +105 -0
  214. package/src/headers/24/threadpoolwork-inl.h +70 -0
  215. package/src/headers/24/timer_wrap-inl.h +32 -0
  216. package/src/headers/24/timer_wrap.h +87 -0
  217. package/src/headers/24/timers.h +75 -0
  218. package/src/headers/24/tlscontext.h +228 -0
  219. package/src/headers/24/tokens.h +256 -0
  220. package/src/headers/24/trace_event.h +722 -0
  221. package/src/headers/24/trace_event_common.h +1109 -0
  222. package/src/headers/24/traced_value.h +129 -0
  223. package/src/headers/24/tracing_agent.h +43 -0
  224. package/src/headers/24/transportparams.h +166 -0
  225. package/src/headers/24/tty_wrap.h +65 -0
  226. package/src/headers/24/udp_wrap.h +230 -0
  227. package/src/headers/24/undici_version.h +6 -0
  228. package/src/headers/24/util-inl.h +711 -0
  229. package/src/headers/24/util.h +1016 -0
  230. package/src/headers/24/v8-external-memory-accounter.h +60 -0
  231. package/src/headers/24/v8-fast-api-calls.h +819 -0
  232. package/src/headers/24/v8-inspector.h +426 -0
  233. package/src/headers/24/wasi_permission.h +31 -0
  234. package/src/headers/24/worker_agent.h +40 -0
  235. package/src/headers/24/worker_inspector.h +124 -0
  236. package/src/headers/24/worker_permission.h +31 -0
  237. package/src/headers/24/zlib_version.h +6 -0
@@ -0,0 +1,206 @@
1
+ #ifndef SRC_ALIASED_BUFFER_H_
2
+ #define SRC_ALIASED_BUFFER_H_
3
+
4
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
+
6
+ #include <cinttypes>
7
+ #include "memory_tracker.h"
8
+ #include "v8.h"
9
+
10
+ namespace node {
11
+
12
+ typedef size_t AliasedBufferIndex;
13
+
14
+ /**
15
+ * Do not use this class directly when creating instances of it - use the
16
+ * Aliased*Array defined at the end of this file instead.
17
+ *
18
+ * This class encapsulates the technique of having a native buffer mapped to
19
+ * a JS object. Writes to the native buffer can happen efficiently without
20
+ * going through JS, and the data is then available to user's via the exposed
21
+ * JS object.
22
+ *
23
+ * While this technique is computationally efficient, it is effectively a
24
+ * write to JS program state w/out going through the standard
25
+ * (monitored) API. Thus, any VM capabilities to detect the modification are
26
+ * circumvented.
27
+ *
28
+ * The encapsulation herein provides a placeholder where such writes can be
29
+ * observed. Any notification APIs will be left as a future exercise.
30
+ */
31
+ template <class NativeT, class V8T>
32
+ class AliasedBufferBase final : public MemoryRetainer {
33
+ public:
34
+ static_assert(std::is_scalar_v<NativeT>);
35
+
36
+ AliasedBufferBase(v8::Isolate* isolate,
37
+ size_t count,
38
+ const AliasedBufferIndex* index = nullptr);
39
+
40
+ /**
41
+ * Create an AliasedBufferBase over a sub-region of another aliased buffer.
42
+ * The two will share a v8::ArrayBuffer instance &
43
+ * a native buffer, but will each read/write to different sections of the
44
+ * native buffer.
45
+ *
46
+ * Note that byte_offset must be aligned by sizeof(NativeT).
47
+ */
48
+ // TODO(refack): refactor into a non-owning `AliasedBufferBaseView`
49
+ AliasedBufferBase(
50
+ v8::Isolate* isolate,
51
+ size_t byte_offset,
52
+ size_t count,
53
+ const AliasedBufferBase<uint8_t, v8::Uint8Array>& backing_buffer,
54
+ const AliasedBufferIndex* index = nullptr);
55
+
56
+ AliasedBufferBase(const AliasedBufferBase& that);
57
+
58
+ AliasedBufferIndex Serialize(v8::Local<v8::Context> context,
59
+ v8::SnapshotCreator* creator);
60
+
61
+ void Deserialize(v8::Local<v8::Context> context);
62
+
63
+ AliasedBufferBase& operator=(AliasedBufferBase&& that) noexcept;
64
+
65
+ /**
66
+ * Helper class that is returned from operator[] to support assignment into
67
+ * a specified location.
68
+ */
69
+ class Reference {
70
+ public:
71
+ Reference(AliasedBufferBase* aliased_buffer, const size_t index)
72
+ : aliased_buffer_(aliased_buffer), index_(index) {}
73
+
74
+ Reference(const Reference& that)
75
+ : aliased_buffer_(that.aliased_buffer_),
76
+ index_(that.index_) {
77
+ }
78
+
79
+ Reference& operator=(const NativeT& val) {
80
+ aliased_buffer_->SetValue(index_, val);
81
+ return *this;
82
+ }
83
+
84
+ Reference& operator=(const Reference& val) {
85
+ return *this = static_cast<NativeT>(val);
86
+ }
87
+
88
+ operator NativeT() const {
89
+ return aliased_buffer_->GetValue(index_);
90
+ }
91
+
92
+ Reference& operator+=(const NativeT& val) {
93
+ const NativeT current = aliased_buffer_->GetValue(index_);
94
+ aliased_buffer_->SetValue(index_, current + val);
95
+ return *this;
96
+ }
97
+
98
+ Reference& operator+=(const Reference& val) {
99
+ return this->operator+=(static_cast<NativeT>(val));
100
+ }
101
+
102
+ Reference& operator-=(const NativeT& val) {
103
+ const NativeT current = aliased_buffer_->GetValue(index_);
104
+ aliased_buffer_->SetValue(index_, current - val);
105
+ return *this;
106
+ }
107
+
108
+ private:
109
+ AliasedBufferBase* aliased_buffer_;
110
+ size_t index_;
111
+ };
112
+
113
+ /**
114
+ * Get the underlying v8 TypedArray overlaid on top of the native buffer
115
+ */
116
+ v8::Local<V8T> GetJSArray() const;
117
+
118
+ void Release();
119
+
120
+ /**
121
+ * Make the global reference to the typed array weak. The caller must make
122
+ * sure that no operation can be done on the AliasedBuffer when the typed
123
+ * array becomes unreachable. Usually this means the caller must maintain
124
+ * a JS reference to the typed array from JS object.
125
+ */
126
+ void MakeWeak();
127
+
128
+ /**
129
+ * Get the underlying v8::ArrayBuffer underlying the TypedArray and
130
+ * overlaying the native buffer
131
+ */
132
+ v8::Local<v8::ArrayBuffer> GetArrayBuffer() const;
133
+
134
+ /**
135
+ * Get the underlying native buffer. Note that all reads/writes should occur
136
+ * through the GetValue/SetValue/operator[] methods
137
+ */
138
+ const NativeT* GetNativeBuffer() const;
139
+
140
+ /**
141
+ * Synonym for GetBuffer()
142
+ */
143
+ const NativeT* operator*() const;
144
+
145
+ /**
146
+ * Set position index to given value.
147
+ */
148
+ void SetValue(size_t index, NativeT value);
149
+
150
+ /**
151
+ * Get value at position index
152
+ */
153
+ const NativeT GetValue(size_t index) const;
154
+
155
+ /**
156
+ * Effectively, a synonym for GetValue/SetValue
157
+ */
158
+ Reference operator[](size_t index);
159
+
160
+ NativeT operator[](size_t index) const;
161
+
162
+ size_t Length() const;
163
+
164
+ // Should only be used to extend the array.
165
+ // Should only be used on an owning array, not one created as a sub array of
166
+ // an owning `AliasedBufferBase`.
167
+ void reserve(size_t new_capacity);
168
+
169
+ size_t SelfSize() const override;
170
+
171
+ const char* MemoryInfoName() const override;
172
+ void MemoryInfo(MemoryTracker* tracker) const override;
173
+
174
+ private:
175
+ bool is_valid() const;
176
+ v8::Isolate* isolate_ = nullptr;
177
+ size_t count_ = 0;
178
+ size_t byte_offset_ = 0;
179
+ NativeT* buffer_ = nullptr;
180
+ v8::Global<V8T> js_array_;
181
+
182
+ // Deserialize data
183
+ const AliasedBufferIndex* index_ = nullptr;
184
+ };
185
+
186
+ #define ALIASED_BUFFER_LIST(V) \
187
+ V(int8_t, Int8Array) \
188
+ V(uint8_t, Uint8Array) \
189
+ V(int16_t, Int16Array) \
190
+ V(uint16_t, Uint16Array) \
191
+ V(int32_t, Int32Array) \
192
+ V(uint32_t, Uint32Array) \
193
+ V(float, Float32Array) \
194
+ V(double, Float64Array) \
195
+ V(int64_t, BigInt64Array)
196
+
197
+ #define V(NativeT, V8T) \
198
+ typedef AliasedBufferBase<NativeT, v8::V8T> Aliased##V8T;
199
+ ALIASED_BUFFER_LIST(V)
200
+ #undef V
201
+
202
+ } // namespace node
203
+
204
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
205
+
206
+ #endif // SRC_ALIASED_BUFFER_H_
@@ -0,0 +1,54 @@
1
+ #ifndef SRC_ALIASED_STRUCT_INL_H_
2
+ #define SRC_ALIASED_STRUCT_INL_H_
3
+
4
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
+
6
+ #include "aliased_struct.h"
7
+ #include "v8.h"
8
+ #include <memory>
9
+
10
+ namespace node {
11
+
12
+ template <typename T>
13
+ template <typename... Args>
14
+ AliasedStruct<T>::AliasedStruct(v8::Isolate* isolate, Args&&... args)
15
+ : isolate_(isolate) {
16
+ const v8::HandleScope handle_scope(isolate);
17
+
18
+ store_ = v8::ArrayBuffer::NewBackingStore(isolate, sizeof(T));
19
+ ptr_ = new (store_->Data()) T(std::forward<Args>(args)...);
20
+ DCHECK_NOT_NULL(ptr_);
21
+
22
+ v8::Local<v8::ArrayBuffer> buffer = v8::ArrayBuffer::New(isolate, store_);
23
+ buffer_ = v8::Global<v8::ArrayBuffer>(isolate, buffer);
24
+ }
25
+
26
+ template <typename T>
27
+ AliasedStruct<T>::AliasedStruct(const AliasedStruct& that)
28
+ : AliasedStruct(that.isolate_, *that) {}
29
+
30
+ template <typename T>
31
+ AliasedStruct<T>& AliasedStruct<T>::operator=(
32
+ AliasedStruct<T>&& that) noexcept {
33
+ this->~AliasedStruct();
34
+ isolate_ = that.isolate_;
35
+ store_ = that.store_;
36
+ ptr_ = that.ptr_;
37
+
38
+ buffer_ = std::move(that.buffer_);
39
+
40
+ that.ptr_ = nullptr;
41
+ that.store_.reset();
42
+ return *this;
43
+ }
44
+
45
+ template <typename T>
46
+ AliasedStruct<T>::~AliasedStruct() {
47
+ if (ptr_ != nullptr) ptr_->~T();
48
+ }
49
+
50
+ } // namespace node
51
+
52
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
53
+
54
+ #endif // SRC_ALIASED_STRUCT_INL_H_
@@ -0,0 +1,63 @@
1
+ #ifndef SRC_ALIASED_STRUCT_H_
2
+ #define SRC_ALIASED_STRUCT_H_
3
+
4
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
+
6
+ #include "node_internals.h"
7
+ #include "v8.h"
8
+ #include <memory>
9
+
10
+ namespace node {
11
+
12
+ // AliasedStruct is a utility that allows uses a V8 Backing Store
13
+ // to be exposed to the C++/C side as a struct and to the
14
+ // JavaScript side as an ArrayBuffer to efficiently share
15
+ // data without marshalling. It is similar in nature to
16
+ // AliasedBuffer.
17
+ //
18
+ // struct Foo { int x; }
19
+ //
20
+ // AliasedStruct<Foo> foo;
21
+ // foo->x = 1;
22
+ //
23
+ // Local<ArrayBuffer> ab = foo.GetArrayBuffer();
24
+ template <typename T>
25
+ class AliasedStruct final {
26
+ public:
27
+ template <typename... Args>
28
+ explicit AliasedStruct(v8::Isolate* isolate, Args&&... args);
29
+
30
+ inline AliasedStruct(const AliasedStruct& that);
31
+
32
+ inline ~AliasedStruct();
33
+
34
+ inline AliasedStruct& operator=(AliasedStruct&& that) noexcept;
35
+
36
+ v8::Local<v8::ArrayBuffer> GetArrayBuffer() const {
37
+ return buffer_.Get(isolate_);
38
+ }
39
+
40
+ const T* Data() const { return ptr_; }
41
+
42
+ T* Data() { return ptr_; }
43
+
44
+ const T& operator*() const { return *ptr_; }
45
+
46
+ T& operator*() { return *ptr_; }
47
+
48
+ const T* operator->() const { return ptr_; }
49
+
50
+ T* operator->() { return ptr_; }
51
+
52
+ private:
53
+ v8::Isolate* isolate_;
54
+ std::shared_ptr<v8::BackingStore> store_;
55
+ T* ptr_;
56
+ v8::Global<v8::ArrayBuffer> buffer_;
57
+ };
58
+
59
+ } // namespace node
60
+
61
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
62
+
63
+ #endif // SRC_ALIASED_STRUCT_H_
@@ -0,0 +1,6 @@
1
+ // This is an auto generated file, please do not edit.
2
+ // Refer to tools/dep_updaters/update-amaro.sh
3
+ #ifndef SRC_AMARO_VERSION_H_
4
+ #define SRC_AMARO_VERSION_H_
5
+ #define AMARO_VERSION "1.1.1"
6
+ #endif // SRC_AMARO_VERSION_H_
@@ -0,0 +1,165 @@
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 "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(int64_t stream_id,
31
+ const uint8_t* data,
32
+ size_t datalen,
33
+ const Stream::ReceiveDataFlags& flags,
34
+ void* stream_user_data) = 0;
35
+
36
+ // Session will forward all data acknowledgements for a stream to the
37
+ // Application.
38
+ virtual bool AcknowledgeStreamData(int64_t stream_id, size_t datalen);
39
+
40
+ // Called to determine if a Header can be added to this application.
41
+ // Applications that do not support headers will always return false.
42
+ virtual bool CanAddHeader(size_t current_count,
43
+ size_t current_headers_length,
44
+ size_t this_header_length);
45
+
46
+ // Called to mark the identified stream as being blocked. Not all
47
+ // Application types will support blocked streams, and those that do will do
48
+ // so differently.
49
+ virtual void BlockStream(int64_t id);
50
+
51
+ // Called when the session determines that there is outbound data available
52
+ // to send for the given stream.
53
+ virtual void ResumeStream(int64_t id);
54
+
55
+ // Called when the Session determines that the maximum number of
56
+ // remotely-initiated unidirectional streams has been extended. Not all
57
+ // Application types will require this notification so the default is to do
58
+ // nothing.
59
+ virtual void ExtendMaxStreams(EndpointLabel label,
60
+ Direction direction,
61
+ uint64_t max_streams);
62
+
63
+ // Called when the Session determines that the flow control window for the
64
+ // given stream has been expanded. Not all Application types will require
65
+ // this notification so the default is to do nothing.
66
+ virtual void ExtendMaxStreamData(Stream* stream, uint64_t max_data);
67
+
68
+ // Different Applications may wish to set some application data in the
69
+ // session ticket (e.g. http/3 would set server settings in the application
70
+ // data). By default, there's nothing to set.
71
+ virtual void CollectSessionTicketAppData(
72
+ SessionTicket::AppData* app_data) const;
73
+
74
+ // Different Applications may set some application data in the session
75
+ // ticket (e.g. http/3 would set server settings in the application data).
76
+ // By default, there's nothing to get.
77
+ virtual SessionTicket::AppData::Status ExtractSessionTicketAppData(
78
+ const SessionTicket::AppData& app_data,
79
+ SessionTicket::AppData::Source::Flag flag);
80
+
81
+ // Notifies the Application that the identified stream has been closed.
82
+ virtual void StreamClose(Stream* stream, QuicError&& error = QuicError());
83
+
84
+ // Notifies the Application that the identified stream has been reset.
85
+ virtual void StreamReset(Stream* stream,
86
+ uint64_t final_size,
87
+ QuicError&& error = QuicError());
88
+
89
+ // Notifies the Application that the identified stream should stop sending.
90
+ virtual void StreamStopSending(Stream* stream,
91
+ QuicError&& error = QuicError());
92
+
93
+ // Submits an outbound block of headers for the given stream. Not all
94
+ // Application types will support headers, in which case this function
95
+ // should return false.
96
+ virtual bool SendHeaders(const Stream& stream,
97
+ HeadersKind kind,
98
+ const v8::Local<v8::Array>& headers,
99
+ HeadersFlags flags = HeadersFlags::NONE);
100
+
101
+ // Signals to the Application that it should serialize and transmit any
102
+ // pending session and stream packets it has accumulated.
103
+ void SendPendingData();
104
+
105
+ // Set the priority level of the stream if supported by the application. Not
106
+ // all applications support priorities, in which case this function is a
107
+ // non-op.
108
+ virtual void SetStreamPriority(
109
+ const Stream& stream,
110
+ StreamPriority priority = StreamPriority::DEFAULT,
111
+ StreamPriorityFlags flags = StreamPriorityFlags::NONE);
112
+
113
+ // Get the priority level of the stream if supported by the application. Not
114
+ // all applications support priorities, in which case this function returns
115
+ // the default stream priority.
116
+ virtual StreamPriority GetStreamPriority(const Stream& stream);
117
+
118
+ struct StreamData;
119
+
120
+ virtual int GetStreamData(StreamData* data) = 0;
121
+ virtual bool StreamCommit(StreamData* data, size_t datalen) = 0;
122
+ virtual bool ShouldSetFin(const StreamData& data) = 0;
123
+
124
+ inline Environment* env() const { return session_->env(); }
125
+ inline Session& session() { return *session_; }
126
+ inline const Session& session() const { return *session_; }
127
+
128
+ private:
129
+ BaseObjectPtr<Packet> CreateStreamDataPacket();
130
+
131
+ // Write the given stream_data into the buffer.
132
+ ssize_t WriteVStream(PathStorage* path,
133
+ uint8_t* buf,
134
+ ssize_t* ndatalen,
135
+ size_t max_packet_size,
136
+ const StreamData& stream_data);
137
+
138
+ Session* session_;
139
+ };
140
+
141
+ struct Session::Application::StreamData final {
142
+ // The actual number of vectors in the struct, up to kMaxVectorCount.
143
+ size_t count = 0;
144
+ size_t remaining = 0;
145
+ // The stream identifier. If this is a negative value then no stream is
146
+ // identified.
147
+ int64_t id = -1;
148
+ int fin = 0;
149
+ ngtcp2_vec data[kMaxVectorCount]{};
150
+ BaseObjectPtr<Stream> stream;
151
+
152
+ inline operator nghttp3_vec*() {
153
+ return reinterpret_cast<nghttp3_vec*>(data);
154
+ }
155
+
156
+ inline operator const ngtcp2_vec*() const { return data; }
157
+ inline operator ngtcp2_vec*() { return data; }
158
+
159
+ std::string ToString() const;
160
+ };
161
+
162
+ } // namespace node::quic
163
+
164
+ #endif // HAVE_OPENSSL && NODE_OPENSSL_HAS_QUIC
165
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
@@ -0,0 +1,33 @@
1
+ #ifndef SRC_ASYNC_CONTEXT_FRAME_H_
2
+ #define SRC_ASYNC_CONTEXT_FRAME_H_
3
+
4
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
5
+
6
+ #include "base_object.h"
7
+ #include "v8.h"
8
+
9
+ #include <cstdint>
10
+
11
+ namespace node {
12
+ namespace async_context_frame {
13
+
14
+ class Scope {
15
+ public:
16
+ explicit Scope(v8::Isolate* isolate, v8::Local<v8::Value> object);
17
+ ~Scope();
18
+
19
+ private:
20
+ v8::Isolate* isolate_;
21
+ v8::Global<v8::Value> prior_;
22
+ };
23
+
24
+ v8::Local<v8::Value> current(v8::Isolate* isolate);
25
+ void set(v8::Isolate* isolate, v8::Local<v8::Value> value);
26
+ v8::Local<v8::Value> exchange(v8::Isolate* isolate, v8::Local<v8::Value> value);
27
+
28
+ } // namespace async_context_frame
29
+ } // namespace node
30
+
31
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
32
+
33
+ #endif // SRC_ASYNC_CONTEXT_FRAME_H_
@@ -0,0 +1,96 @@
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_ASYNC_WRAP_INL_H_
23
+ #define SRC_ASYNC_WRAP_INL_H_
24
+
25
+ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
26
+
27
+ #include "async_wrap.h"
28
+ #include "base_object-inl.h"
29
+ #include "node_internals.h"
30
+
31
+ namespace node {
32
+
33
+ inline AsyncWrap::ProviderType AsyncWrap::provider_type() const {
34
+ return provider_type_;
35
+ }
36
+
37
+ inline AsyncWrap::ProviderType AsyncWrap::set_provider_type(
38
+ AsyncWrap::ProviderType provider) {
39
+ provider_type_ = provider;
40
+ return provider_type_;
41
+ }
42
+
43
+ inline double AsyncWrap::get_async_id() const {
44
+ return async_id_;
45
+ }
46
+
47
+
48
+ inline double AsyncWrap::get_trigger_async_id() const {
49
+ return trigger_async_id_;
50
+ }
51
+
52
+ inline v8::Local<v8::Value> AsyncWrap::context_frame() const {
53
+ return context_frame_.Get(env()->isolate());
54
+ }
55
+
56
+ inline v8::MaybeLocal<v8::Value> AsyncWrap::MakeCallback(
57
+ const v8::Local<v8::String> symbol,
58
+ int argc,
59
+ v8::Local<v8::Value>* argv) {
60
+ return MakeCallback(symbol.As<v8::Name>(), argc, argv);
61
+ }
62
+
63
+
64
+ inline v8::MaybeLocal<v8::Value> AsyncWrap::MakeCallback(
65
+ const v8::Local<v8::Symbol> symbol,
66
+ int argc,
67
+ v8::Local<v8::Value>* argv) {
68
+ return MakeCallback(symbol.As<v8::Name>(), argc, argv);
69
+ }
70
+
71
+
72
+ inline v8::MaybeLocal<v8::Value> AsyncWrap::MakeCallback(
73
+ const v8::Local<v8::Name> symbol,
74
+ int argc,
75
+ v8::Local<v8::Value>* argv) {
76
+ v8::Local<v8::Value> cb_v;
77
+ if (!object()->Get(env()->context(), symbol).ToLocal(&cb_v))
78
+ return v8::MaybeLocal<v8::Value>();
79
+ if (!cb_v->IsFunction()) {
80
+ v8::Isolate* isolate = env()->isolate();
81
+ return Undefined(isolate);
82
+ }
83
+ return MakeCallback(cb_v.As<v8::Function>(), argc, argv);
84
+ }
85
+
86
+ // static
87
+ inline v8::Local<v8::FunctionTemplate> AsyncWrap::GetConstructorTemplate(
88
+ Environment* env) {
89
+ return GetConstructorTemplate(env->isolate_data());
90
+ }
91
+
92
+ } // namespace node
93
+
94
+ #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
95
+
96
+ #endif // SRC_ASYNC_WRAP_INL_H_