@encharm/cws 4.3.0 → 4.4.0
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.
- package/README.md +5 -7
- package/dist/bindings/cws_darwin_arm64_node108.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node115.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node83.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node93.node +0 -0
- package/dist/bindings/cws_darwin_x64_node108.node +0 -0
- package/dist/bindings/cws_darwin_x64_node115.node +0 -0
- package/dist/bindings/cws_darwin_x64_node83.node +0 -0
- package/dist/bindings/cws_darwin_x64_node93.node +0 -0
- package/dist/bindings/cws_linux_arm64_node108.node +0 -0
- package/dist/bindings/cws_linux_arm64_node115.node +0 -0
- package/dist/bindings/cws_linux_arm64_node83.node +0 -0
- package/dist/bindings/cws_linux_arm64_node93.node +0 -0
- package/dist/bindings/cws_linux_x64_node108.node +0 -0
- package/dist/bindings/cws_linux_x64_node115.node +0 -0
- package/dist/bindings/cws_linux_x64_node83.node +0 -0
- package/dist/bindings/cws_linux_x64_node93.node +0 -0
- package/dist/bindings/cws_win32_x64_node108.node +0 -0
- package/dist/bindings/cws_win32_x64_node115.node +0 -0
- package/dist/bindings/cws_win32_x64_node83.node +0 -0
- package/dist/bindings/cws_win32_x64_node93.node +0 -0
- package/dist/shared.js +1 -1
- package/package.json +5 -5
- package/src/Addon.cpp +4 -12
- package/src/Addon.h +55 -90
- package/src/Socket.h +1 -0
- package/src/cSNode.cpp +3 -8
- package/src/headers/20/acorn_version.h +6 -0
- package/src/headers/20/aliased_buffer-inl.h +243 -0
- package/src/headers/20/aliased_buffer.h +206 -0
- package/src/headers/20/aliased_struct-inl.h +54 -0
- package/src/headers/20/aliased_struct.h +63 -0
- package/src/headers/20/async_wrap-inl.h +93 -0
- package/src/headers/20/async_wrap.h +252 -0
- package/src/headers/20/base64-inl.h +193 -0
- package/src/headers/20/base64.h +53 -0
- package/src/headers/20/base64_version.h +6 -0
- package/src/headers/20/base_object-inl.h +316 -0
- package/src/headers/20/base_object.h +320 -0
- package/src/headers/20/base_object_types.h +73 -0
- package/src/headers/20/blob_serializer_deserializer-inl.h +361 -0
- package/src/headers/20/blob_serializer_deserializer.h +132 -0
- package/src/headers/20/callback_queue-inl.h +97 -0
- package/src/headers/20/callback_queue.h +79 -0
- package/src/headers/20/cares_wrap.h +524 -0
- package/src/headers/20/cjs_module_lexer_version.h +6 -0
- package/src/headers/20/cleanup_queue-inl.h +62 -0
- package/src/headers/20/cleanup_queue.h +85 -0
- package/src/headers/20/connect_wrap.h +26 -0
- package/src/headers/20/connection_wrap.h +29 -0
- package/src/headers/20/cppgc/DEPS +8 -0
- package/src/headers/20/cppgc/OWNERS +2 -0
- package/src/headers/20/cppgc/README.md +135 -0
- package/src/headers/20/cppgc/allocation.h +310 -0
- package/src/headers/20/cppgc/common.h +28 -0
- package/src/headers/20/cppgc/cross-thread-persistent.h +466 -0
- package/src/headers/20/cppgc/custom-space.h +97 -0
- package/src/headers/20/cppgc/default-platform.h +67 -0
- package/src/headers/20/cppgc/ephemeron-pair.h +30 -0
- package/src/headers/20/cppgc/explicit-management.h +100 -0
- package/src/headers/20/cppgc/garbage-collected.h +106 -0
- package/src/headers/20/cppgc/heap-consistency.h +309 -0
- package/src/headers/20/cppgc/heap-handle.h +48 -0
- package/src/headers/20/cppgc/heap-state.h +82 -0
- package/src/headers/20/cppgc/heap-statistics.h +120 -0
- package/src/headers/20/cppgc/heap.h +202 -0
- package/src/headers/20/cppgc/internal/api-constants.h +68 -0
- package/src/headers/20/cppgc/internal/atomic-entry-flag.h +48 -0
- package/src/headers/20/cppgc/internal/base-page-handle.h +45 -0
- package/src/headers/20/cppgc/internal/caged-heap-local-data.h +111 -0
- package/src/headers/20/cppgc/internal/caged-heap.h +61 -0
- package/src/headers/20/cppgc/internal/compiler-specific.h +38 -0
- package/src/headers/20/cppgc/internal/finalizer-trait.h +93 -0
- package/src/headers/20/cppgc/internal/gc-info.h +157 -0
- package/src/headers/20/cppgc/internal/logging.h +50 -0
- package/src/headers/20/cppgc/internal/member-storage.h +248 -0
- package/src/headers/20/cppgc/internal/name-trait.h +137 -0
- package/src/headers/20/cppgc/internal/persistent-node.h +214 -0
- package/src/headers/20/cppgc/internal/pointer-policies.h +243 -0
- package/src/headers/20/cppgc/internal/write-barrier.h +487 -0
- package/src/headers/20/cppgc/liveness-broker.h +78 -0
- package/src/headers/20/cppgc/macros.h +35 -0
- package/src/headers/20/cppgc/member.h +604 -0
- package/src/headers/20/cppgc/name-provider.h +65 -0
- package/src/headers/20/cppgc/object-size-trait.h +58 -0
- package/src/headers/20/cppgc/persistent.h +373 -0
- package/src/headers/20/cppgc/platform.h +158 -0
- package/src/headers/20/cppgc/prefinalizer.h +75 -0
- package/src/headers/20/cppgc/process-heap-statistics.h +36 -0
- package/src/headers/20/cppgc/sentinel-pointer.h +32 -0
- package/src/headers/20/cppgc/source-location.h +92 -0
- package/src/headers/20/cppgc/testing.h +106 -0
- package/src/headers/20/cppgc/trace-trait.h +120 -0
- package/src/headers/20/cppgc/type-traits.h +250 -0
- package/src/headers/20/cppgc/visitor.h +426 -0
- package/src/headers/20/crypto/crypto_clienthello.h +131 -0
- package/src/headers/20/crypto/crypto_context.h +160 -0
- package/src/headers/20/crypto/crypto_keys.h +416 -0
- package/src/headers/20/crypto/crypto_tls.h +295 -0
- package/src/headers/20/crypto/crypto_util.h +805 -0
- package/src/headers/20/crypto_clienthello.h +131 -0
- package/src/headers/20/debug_utils-inl.h +226 -0
- package/src/headers/20/debug_utils.h +188 -0
- package/src/headers/20/diagnosticfilename-inl.h +33 -0
- package/src/headers/20/encoding_binding.h +59 -0
- package/src/headers/20/env-inl.h +923 -0
- package/src/headers/20/env.h +1193 -0
- package/src/headers/20/env_properties.h +444 -0
- package/src/headers/20/handle_wrap.h +123 -0
- package/src/headers/20/histogram-inl.h +107 -0
- package/src/headers/20/histogram.h +240 -0
- package/src/headers/20/inspector_agent.h +144 -0
- package/src/headers/20/inspector_io.h +78 -0
- package/src/headers/20/inspector_profiler.h +149 -0
- package/src/headers/20/inspector_socket.h +60 -0
- package/src/headers/20/inspector_socket_server.h +110 -0
- package/src/headers/20/js_native_api.h +591 -0
- package/src/headers/20/js_native_api_types.h +168 -0
- package/src/headers/20/js_native_api_v8.h +426 -0
- package/src/headers/20/js_native_api_v8_internals.h +39 -0
- package/src/headers/20/js_stream.h +52 -0
- package/src/headers/20/json_parser.h +38 -0
- package/src/headers/20/json_utils.h +172 -0
- package/src/headers/20/memory_tracker-inl.h +356 -0
- package/src/headers/20/memory_tracker.h +289 -0
- package/src/headers/20/module_wrap.h +117 -0
- package/src/headers/20/node.h +1514 -0
- package/src/headers/20/node_api.h +260 -0
- package/src/headers/20/node_api_internals.h +42 -0
- package/src/headers/20/node_api_types.h +52 -0
- package/src/headers/20/node_binding.h +142 -0
- package/src/headers/20/node_blob.h +159 -0
- package/src/headers/20/node_bob-inl.h +36 -0
- package/src/headers/20/node_bob.h +107 -0
- package/src/headers/20/node_buffer.h +92 -0
- package/src/headers/20/node_builtins.h +197 -0
- package/src/headers/20/node_constants.h +79 -0
- package/src/headers/20/node_context_data.h +98 -0
- package/src/headers/20/node_contextify.h +182 -0
- package/src/headers/20/node_crypto.h +56 -0
- package/src/headers/20/node_dir.h +52 -0
- package/src/headers/20/node_dotenv.h +37 -0
- package/src/headers/20/node_errors.h +313 -0
- package/src/headers/20/node_exit_code.h +54 -0
- package/src/headers/20/node_external_reference.h +172 -0
- package/src/headers/20/node_file-inl.h +357 -0
- package/src/headers/20/node_file.h +524 -0
- package/src/headers/20/node_http2.h +1146 -0
- package/src/headers/20/node_http2_state.h +147 -0
- package/src/headers/20/node_http_common-inl.h +201 -0
- package/src/headers/20/node_http_common.h +532 -0
- package/src/headers/20/node_i18n.h +145 -0
- package/src/headers/20/node_internals.h +443 -0
- package/src/headers/20/node_main_instance.h +67 -0
- package/src/headers/20/node_mem-inl.h +112 -0
- package/src/headers/20/node_mem.h +45 -0
- package/src/headers/20/node_messaging.h +377 -0
- package/src/headers/20/node_metadata.h +138 -0
- package/src/headers/20/node_mutex.h +323 -0
- package/src/headers/20/node_object_wrap.h +132 -0
- package/src/headers/20/node_options-inl.h +478 -0
- package/src/headers/20/node_options.h +538 -0
- package/src/headers/20/node_perf.h +166 -0
- package/src/headers/20/node_perf_common.h +98 -0
- package/src/headers/20/node_platform.h +195 -0
- package/src/headers/20/node_process-inl.h +26 -0
- package/src/headers/20/node_process.h +99 -0
- package/src/headers/20/node_realm-inl.h +139 -0
- package/src/headers/20/node_realm.h +184 -0
- package/src/headers/20/node_report.h +42 -0
- package/src/headers/20/node_revert.h +82 -0
- package/src/headers/20/node_root_certs.h +3443 -0
- package/src/headers/20/node_sea.h +56 -0
- package/src/headers/20/node_shadow_realm.h +46 -0
- package/src/headers/20/node_snapshot_builder.h +54 -0
- package/src/headers/20/node_snapshotable.h +164 -0
- package/src/headers/20/node_sockaddr-inl.h +266 -0
- package/src/headers/20/node_sockaddr.h +405 -0
- package/src/headers/20/node_stat_watcher.h +73 -0
- package/src/headers/20/node_threadsafe_cow-inl.h +54 -0
- package/src/headers/20/node_threadsafe_cow.h +105 -0
- package/src/headers/20/node_union_bytes.h +81 -0
- package/src/headers/20/node_url.h +92 -0
- package/src/headers/20/node_v8.h +77 -0
- package/src/headers/20/node_v8_platform-inl.h +205 -0
- package/src/headers/20/node_version.h +109 -0
- package/src/headers/20/node_wasi.h +184 -0
- package/src/headers/20/node_wasm_web_api.h +55 -0
- package/src/headers/20/node_watchdog.h +154 -0
- package/src/headers/20/node_worker.h +151 -0
- package/src/headers/20/permission/child_process_permission.h +28 -0
- package/src/headers/20/permission/fs_permission.h +152 -0
- package/src/headers/20/permission/permission.h +71 -0
- package/src/headers/20/permission/permission_base.h +49 -0
- package/src/headers/20/permission/worker_permission.h +28 -0
- package/src/headers/20/pipe_wrap.h +80 -0
- package/src/headers/20/req_wrap-inl.h +171 -0
- package/src/headers/20/req_wrap.h +77 -0
- package/src/headers/20/spawn_sync.h +242 -0
- package/src/headers/20/stream_base-inl.h +173 -0
- package/src/headers/20/stream_base.h +469 -0
- package/src/headers/20/stream_pipe.h +76 -0
- package/src/headers/20/stream_wrap.h +131 -0
- package/src/headers/20/string_bytes.h +120 -0
- package/src/headers/20/string_decoder-inl.h +37 -0
- package/src/headers/20/string_decoder.h +50 -0
- package/src/headers/20/string_search.h +638 -0
- package/src/headers/20/tcp_wrap.h +105 -0
- package/src/headers/20/threadpoolwork-inl.h +70 -0
- package/src/headers/20/timer_wrap-inl.h +32 -0
- package/src/headers/20/timer_wrap.h +85 -0
- package/src/headers/20/timers.h +70 -0
- package/src/headers/20/tracing/agent.h +195 -0
- package/src/headers/20/tracing/trace_event.h +720 -0
- package/src/headers/20/tracing/trace_event_common.h +1109 -0
- package/src/headers/20/tty_wrap.h +65 -0
- package/src/headers/20/udp_wrap.h +227 -0
- package/src/headers/20/undici_version.h +6 -0
- package/src/headers/20/util-inl.h +623 -0
- package/src/headers/20/util.h +988 -0
- package/src/headers/20/v8-cppgc.h +245 -0
- package/src/headers/20/v8-fast-api-calls.h +957 -0
- package/dist/bindings/cws_darwin_arm64_node64.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node72.node +0 -0
- package/dist/bindings/cws_darwin_arm64_node79.node +0 -0
- package/dist/bindings/cws_darwin_x64_node64.node +0 -0
- package/dist/bindings/cws_darwin_x64_node72.node +0 -0
- package/dist/bindings/cws_darwin_x64_node79.node +0 -0
- package/dist/bindings/cws_linux_x64_node64.node +0 -0
- package/dist/bindings/cws_linux_x64_node72.node +0 -0
- package/dist/bindings/cws_linux_x64_node79.node +0 -0
- package/dist/bindings/cws_win32_x64_node64.node +0 -0
- package/dist/bindings/cws_win32_x64_node72.node +0 -0
- package/dist/bindings/cws_win32_x64_node79.node +0 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
#ifndef SRC_NODE_CONTEXTIFY_H_
|
|
2
|
+
#define SRC_NODE_CONTEXTIFY_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include "base_object-inl.h"
|
|
7
|
+
#include "node_context_data.h"
|
|
8
|
+
#include "node_errors.h"
|
|
9
|
+
|
|
10
|
+
namespace node {
|
|
11
|
+
class ExternalReferenceRegistry;
|
|
12
|
+
|
|
13
|
+
namespace contextify {
|
|
14
|
+
|
|
15
|
+
struct ContextOptions {
|
|
16
|
+
v8::Local<v8::String> name;
|
|
17
|
+
v8::Local<v8::String> origin;
|
|
18
|
+
v8::Local<v8::Boolean> allow_code_gen_strings;
|
|
19
|
+
v8::Local<v8::Boolean> allow_code_gen_wasm;
|
|
20
|
+
std::unique_ptr<v8::MicrotaskQueue> own_microtask_queue;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
class ContextifyContext : public BaseObject {
|
|
24
|
+
public:
|
|
25
|
+
ContextifyContext(Environment* env,
|
|
26
|
+
v8::Local<v8::Object> wrapper,
|
|
27
|
+
v8::Local<v8::Context> v8_context,
|
|
28
|
+
ContextOptions* options);
|
|
29
|
+
~ContextifyContext();
|
|
30
|
+
|
|
31
|
+
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
32
|
+
SET_MEMORY_INFO_NAME(ContextifyContext)
|
|
33
|
+
SET_SELF_SIZE(ContextifyContext)
|
|
34
|
+
|
|
35
|
+
static v8::MaybeLocal<v8::Context> CreateV8Context(
|
|
36
|
+
v8::Isolate* isolate,
|
|
37
|
+
v8::Local<v8::ObjectTemplate> object_template,
|
|
38
|
+
const SnapshotData* snapshot_data,
|
|
39
|
+
v8::MicrotaskQueue* queue);
|
|
40
|
+
static void CreatePerIsolateProperties(IsolateData* isolate_data,
|
|
41
|
+
v8::Local<v8::ObjectTemplate> target);
|
|
42
|
+
static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
|
|
43
|
+
|
|
44
|
+
static ContextifyContext* ContextFromContextifiedSandbox(
|
|
45
|
+
Environment* env,
|
|
46
|
+
const v8::Local<v8::Object>& sandbox);
|
|
47
|
+
|
|
48
|
+
inline v8::Local<v8::Context> context() const {
|
|
49
|
+
return PersistentToLocal::Default(env()->isolate(), context_);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
inline v8::Local<v8::Object> global_proxy() const {
|
|
53
|
+
return context()->Global();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
inline v8::Local<v8::Object> sandbox() const {
|
|
57
|
+
return context()->GetEmbedderData(ContextEmbedderIndex::kSandboxObject)
|
|
58
|
+
.As<v8::Object>();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
inline v8::MicrotaskQueue* microtask_queue() const {
|
|
62
|
+
return microtask_queue_.get();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
template <typename T>
|
|
66
|
+
static ContextifyContext* Get(const v8::PropertyCallbackInfo<T>& args);
|
|
67
|
+
static ContextifyContext* Get(v8::Local<v8::Object> object);
|
|
68
|
+
|
|
69
|
+
static void InitializeGlobalTemplates(IsolateData* isolate_data);
|
|
70
|
+
|
|
71
|
+
private:
|
|
72
|
+
static BaseObjectPtr<ContextifyContext> New(Environment* env,
|
|
73
|
+
v8::Local<v8::Object> sandbox_obj,
|
|
74
|
+
ContextOptions* options);
|
|
75
|
+
// Initialize a context created from CreateV8Context()
|
|
76
|
+
static BaseObjectPtr<ContextifyContext> New(v8::Local<v8::Context> ctx,
|
|
77
|
+
Environment* env,
|
|
78
|
+
v8::Local<v8::Object> sandbox_obj,
|
|
79
|
+
ContextOptions* options);
|
|
80
|
+
|
|
81
|
+
static bool IsStillInitializing(const ContextifyContext* ctx);
|
|
82
|
+
static void MakeContext(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
83
|
+
static void IsContext(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
84
|
+
static void CompileFunction(
|
|
85
|
+
const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
86
|
+
static void WeakCallback(
|
|
87
|
+
const v8::WeakCallbackInfo<ContextifyContext>& data);
|
|
88
|
+
static void PropertyGetterCallback(
|
|
89
|
+
v8::Local<v8::Name> property,
|
|
90
|
+
const v8::PropertyCallbackInfo<v8::Value>& args);
|
|
91
|
+
static void PropertySetterCallback(
|
|
92
|
+
v8::Local<v8::Name> property,
|
|
93
|
+
v8::Local<v8::Value> value,
|
|
94
|
+
const v8::PropertyCallbackInfo<v8::Value>& args);
|
|
95
|
+
static void PropertyDescriptorCallback(
|
|
96
|
+
v8::Local<v8::Name> property,
|
|
97
|
+
const v8::PropertyCallbackInfo<v8::Value>& args);
|
|
98
|
+
static void PropertyDefinerCallback(
|
|
99
|
+
v8::Local<v8::Name> property,
|
|
100
|
+
const v8::PropertyDescriptor& desc,
|
|
101
|
+
const v8::PropertyCallbackInfo<v8::Value>& args);
|
|
102
|
+
static void PropertyDeleterCallback(
|
|
103
|
+
v8::Local<v8::Name> property,
|
|
104
|
+
const v8::PropertyCallbackInfo<v8::Boolean>& args);
|
|
105
|
+
static void PropertyEnumeratorCallback(
|
|
106
|
+
const v8::PropertyCallbackInfo<v8::Array>& args);
|
|
107
|
+
static void IndexedPropertyGetterCallback(
|
|
108
|
+
uint32_t index,
|
|
109
|
+
const v8::PropertyCallbackInfo<v8::Value>& args);
|
|
110
|
+
static void IndexedPropertySetterCallback(
|
|
111
|
+
uint32_t index,
|
|
112
|
+
v8::Local<v8::Value> value,
|
|
113
|
+
const v8::PropertyCallbackInfo<v8::Value>& args);
|
|
114
|
+
static void IndexedPropertyDescriptorCallback(
|
|
115
|
+
uint32_t index,
|
|
116
|
+
const v8::PropertyCallbackInfo<v8::Value>& args);
|
|
117
|
+
static void IndexedPropertyDefinerCallback(
|
|
118
|
+
uint32_t index,
|
|
119
|
+
const v8::PropertyDescriptor& desc,
|
|
120
|
+
const v8::PropertyCallbackInfo<v8::Value>& args);
|
|
121
|
+
static void IndexedPropertyDeleterCallback(
|
|
122
|
+
uint32_t index,
|
|
123
|
+
const v8::PropertyCallbackInfo<v8::Boolean>& args);
|
|
124
|
+
|
|
125
|
+
v8::Global<v8::Context> context_;
|
|
126
|
+
std::unique_ptr<v8::MicrotaskQueue> microtask_queue_;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
class ContextifyScript : public BaseObject {
|
|
130
|
+
public:
|
|
131
|
+
enum InternalFields {
|
|
132
|
+
kUnboundScriptSlot = BaseObject::kInternalFieldCount,
|
|
133
|
+
kInternalFieldCount
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
SET_NO_MEMORY_INFO()
|
|
137
|
+
SET_MEMORY_INFO_NAME(ContextifyScript)
|
|
138
|
+
SET_SELF_SIZE(ContextifyScript)
|
|
139
|
+
|
|
140
|
+
ContextifyScript(Environment* env, v8::Local<v8::Object> object);
|
|
141
|
+
~ContextifyScript() override;
|
|
142
|
+
|
|
143
|
+
static void CreatePerIsolateProperties(IsolateData* isolate_data,
|
|
144
|
+
v8::Local<v8::ObjectTemplate> target);
|
|
145
|
+
static void RegisterExternalReferences(ExternalReferenceRegistry* registry);
|
|
146
|
+
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
147
|
+
static bool InstanceOf(Environment* env, const v8::Local<v8::Value>& args);
|
|
148
|
+
static void CreateCachedData(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
149
|
+
static void RunInContext(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
150
|
+
static bool EvalMachine(v8::Local<v8::Context> context,
|
|
151
|
+
Environment* env,
|
|
152
|
+
const int64_t timeout,
|
|
153
|
+
const bool display_errors,
|
|
154
|
+
const bool break_on_sigint,
|
|
155
|
+
const bool break_on_first_line,
|
|
156
|
+
v8::MicrotaskQueue* microtask_queue,
|
|
157
|
+
const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
158
|
+
|
|
159
|
+
private:
|
|
160
|
+
v8::Global<v8::UnboundScript> script_;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
v8::Maybe<bool> StoreCodeCacheResult(
|
|
164
|
+
Environment* env,
|
|
165
|
+
v8::Local<v8::Object> target,
|
|
166
|
+
v8::ScriptCompiler::CompileOptions compile_options,
|
|
167
|
+
const v8::ScriptCompiler::Source& source,
|
|
168
|
+
bool produce_cached_data,
|
|
169
|
+
std::unique_ptr<v8::ScriptCompiler::CachedData> new_cached_data);
|
|
170
|
+
|
|
171
|
+
v8::MaybeLocal<v8::Function> CompileFunction(
|
|
172
|
+
v8::Local<v8::Context> context,
|
|
173
|
+
v8::Local<v8::String> filename,
|
|
174
|
+
v8::Local<v8::String> content,
|
|
175
|
+
std::vector<v8::Local<v8::String>>* parameters);
|
|
176
|
+
|
|
177
|
+
} // namespace contextify
|
|
178
|
+
} // namespace node
|
|
179
|
+
|
|
180
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
181
|
+
|
|
182
|
+
#endif // SRC_NODE_CONTEXTIFY_H_
|
|
@@ -0,0 +1,56 @@
|
|
|
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_NODE_CRYPTO_H_
|
|
23
|
+
#define SRC_NODE_CRYPTO_H_
|
|
24
|
+
|
|
25
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
26
|
+
|
|
27
|
+
// All of the crypto definitions previously contained in this header
|
|
28
|
+
// have been split across multiple headers in src/crypto. This header
|
|
29
|
+
// remains for convenience for any code that still imports it. New
|
|
30
|
+
// code should include the relevant src/crypto headers directly.
|
|
31
|
+
#include "crypto/crypto_aes.h"
|
|
32
|
+
#include "crypto/crypto_bio.h"
|
|
33
|
+
#include "crypto/crypto_cipher.h"
|
|
34
|
+
#include "crypto/crypto_context.h"
|
|
35
|
+
#include "crypto/crypto_dh.h"
|
|
36
|
+
#include "crypto/crypto_dsa.h"
|
|
37
|
+
#include "crypto/crypto_ec.h"
|
|
38
|
+
#include "crypto/crypto_hash.h"
|
|
39
|
+
#include "crypto/crypto_hkdf.h"
|
|
40
|
+
#include "crypto/crypto_hmac.h"
|
|
41
|
+
#include "crypto/crypto_keygen.h"
|
|
42
|
+
#include "crypto/crypto_keys.h"
|
|
43
|
+
#include "crypto/crypto_pbkdf2.h"
|
|
44
|
+
#include "crypto/crypto_random.h"
|
|
45
|
+
#include "crypto/crypto_rsa.h"
|
|
46
|
+
#include "crypto/crypto_scrypt.h"
|
|
47
|
+
#include "crypto/crypto_sig.h"
|
|
48
|
+
#include "crypto/crypto_spkac.h"
|
|
49
|
+
#include "crypto/crypto_timing.h"
|
|
50
|
+
#include "crypto/crypto_tls.h"
|
|
51
|
+
#include "crypto/crypto_util.h"
|
|
52
|
+
#include "crypto/crypto_x509.h"
|
|
53
|
+
|
|
54
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
55
|
+
|
|
56
|
+
#endif // SRC_NODE_CRYPTO_H_
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#ifndef SRC_NODE_DIR_H_
|
|
2
|
+
#define SRC_NODE_DIR_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include "node_file.h"
|
|
7
|
+
|
|
8
|
+
namespace node {
|
|
9
|
+
|
|
10
|
+
namespace fs_dir {
|
|
11
|
+
|
|
12
|
+
// Needed to propagate `uv_dir_t`.
|
|
13
|
+
class DirHandle : public AsyncWrap {
|
|
14
|
+
public:
|
|
15
|
+
static DirHandle* New(Environment* env, uv_dir_t* dir);
|
|
16
|
+
~DirHandle() override;
|
|
17
|
+
|
|
18
|
+
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
19
|
+
static void Read(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
20
|
+
static void Close(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
21
|
+
|
|
22
|
+
inline uv_dir_t* dir() { return dir_; }
|
|
23
|
+
|
|
24
|
+
void MemoryInfo(MemoryTracker* tracker) const override;
|
|
25
|
+
SET_MEMORY_INFO_NAME(DirHandle)
|
|
26
|
+
SET_SELF_SIZE(DirHandle)
|
|
27
|
+
|
|
28
|
+
DirHandle(const DirHandle&) = delete;
|
|
29
|
+
DirHandle& operator=(const DirHandle&) = delete;
|
|
30
|
+
DirHandle(const DirHandle&&) = delete;
|
|
31
|
+
DirHandle& operator=(const DirHandle&&) = delete;
|
|
32
|
+
|
|
33
|
+
private:
|
|
34
|
+
DirHandle(Environment* env, v8::Local<v8::Object> obj, uv_dir_t* dir);
|
|
35
|
+
|
|
36
|
+
// Synchronous close that emits a warning
|
|
37
|
+
void GCClose();
|
|
38
|
+
|
|
39
|
+
uv_dir_t* dir_;
|
|
40
|
+
// Multiple entries are read through a single libuv call.
|
|
41
|
+
std::vector<uv_dirent_t> dirents_;
|
|
42
|
+
bool closing_ = false;
|
|
43
|
+
bool closed_ = false;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
} // namespace fs_dir
|
|
47
|
+
|
|
48
|
+
} // namespace node
|
|
49
|
+
|
|
50
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
51
|
+
|
|
52
|
+
#endif // SRC_NODE_DIR_H_
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#ifndef SRC_NODE_DOTENV_H_
|
|
2
|
+
#define SRC_NODE_DOTENV_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include "util-inl.h"
|
|
7
|
+
|
|
8
|
+
#include <map>
|
|
9
|
+
|
|
10
|
+
namespace node {
|
|
11
|
+
|
|
12
|
+
class Dotenv {
|
|
13
|
+
public:
|
|
14
|
+
Dotenv() = default;
|
|
15
|
+
Dotenv(const Dotenv& d) = default;
|
|
16
|
+
Dotenv(Dotenv&& d) noexcept = default;
|
|
17
|
+
Dotenv& operator=(Dotenv&& d) noexcept = default;
|
|
18
|
+
Dotenv& operator=(const Dotenv& d) = default;
|
|
19
|
+
~Dotenv() = default;
|
|
20
|
+
|
|
21
|
+
void ParsePath(const std::string_view path);
|
|
22
|
+
void AssignNodeOptionsIfAvailable(std::string* node_options);
|
|
23
|
+
void SetEnvironment(Environment* env);
|
|
24
|
+
|
|
25
|
+
static std::vector<std::string> GetPathFromArgs(
|
|
26
|
+
const std::vector<std::string>& args);
|
|
27
|
+
|
|
28
|
+
private:
|
|
29
|
+
void ParseLine(const std::string_view line);
|
|
30
|
+
std::map<std::string, std::string> store_;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
} // namespace node
|
|
34
|
+
|
|
35
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
36
|
+
|
|
37
|
+
#endif // SRC_NODE_DOTENV_H_
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
#ifndef SRC_NODE_ERRORS_H_
|
|
2
|
+
#define SRC_NODE_ERRORS_H_
|
|
3
|
+
|
|
4
|
+
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
5
|
+
|
|
6
|
+
#include "debug_utils-inl.h"
|
|
7
|
+
#include "env.h"
|
|
8
|
+
#include "v8.h"
|
|
9
|
+
|
|
10
|
+
// Use ostringstream to print exact-width integer types
|
|
11
|
+
// because the format specifiers are not available on AIX.
|
|
12
|
+
#include <sstream>
|
|
13
|
+
|
|
14
|
+
namespace node {
|
|
15
|
+
|
|
16
|
+
enum ErrorHandlingMode { CONTEXTIFY_ERROR, FATAL_ERROR, MODULE_ERROR };
|
|
17
|
+
void AppendExceptionLine(Environment* env,
|
|
18
|
+
v8::Local<v8::Value> er,
|
|
19
|
+
v8::Local<v8::Message> message,
|
|
20
|
+
enum ErrorHandlingMode mode);
|
|
21
|
+
|
|
22
|
+
[[noreturn]] void OnFatalError(const char* location, const char* message);
|
|
23
|
+
[[noreturn]] void OOMErrorHandler(const char* location,
|
|
24
|
+
const v8::OOMDetails& details);
|
|
25
|
+
|
|
26
|
+
// Helpers to construct errors similar to the ones provided by
|
|
27
|
+
// lib/internal/errors.js.
|
|
28
|
+
// Example: with `V(ERR_INVALID_ARG_TYPE, TypeError)`, there will be
|
|
29
|
+
// `node::ERR_INVALID_ARG_TYPE(isolate, "message")` returning
|
|
30
|
+
// a `Local<Value>` containing the TypeError with proper code and message
|
|
31
|
+
|
|
32
|
+
#define ERRORS_WITH_CODE(V) \
|
|
33
|
+
V(ERR_ACCESS_DENIED, Error) \
|
|
34
|
+
V(ERR_BUFFER_CONTEXT_NOT_AVAILABLE, Error) \
|
|
35
|
+
V(ERR_BUFFER_OUT_OF_BOUNDS, RangeError) \
|
|
36
|
+
V(ERR_BUFFER_TOO_LARGE, Error) \
|
|
37
|
+
V(ERR_CLOSED_MESSAGE_PORT, Error) \
|
|
38
|
+
V(ERR_CONSTRUCT_CALL_REQUIRED, TypeError) \
|
|
39
|
+
V(ERR_CONSTRUCT_CALL_INVALID, TypeError) \
|
|
40
|
+
V(ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED, Error) \
|
|
41
|
+
V(ERR_CRYPTO_INITIALIZATION_FAILED, Error) \
|
|
42
|
+
V(ERR_CRYPTO_INVALID_AUTH_TAG, TypeError) \
|
|
43
|
+
V(ERR_CRYPTO_INVALID_COUNTER, TypeError) \
|
|
44
|
+
V(ERR_CRYPTO_INVALID_CURVE, TypeError) \
|
|
45
|
+
V(ERR_CRYPTO_INVALID_DIGEST, TypeError) \
|
|
46
|
+
V(ERR_CRYPTO_INVALID_IV, TypeError) \
|
|
47
|
+
V(ERR_CRYPTO_INVALID_JWK, TypeError) \
|
|
48
|
+
V(ERR_CRYPTO_INVALID_KEYLEN, RangeError) \
|
|
49
|
+
V(ERR_CRYPTO_INVALID_KEYPAIR, RangeError) \
|
|
50
|
+
V(ERR_CRYPTO_INVALID_KEYTYPE, RangeError) \
|
|
51
|
+
V(ERR_CRYPTO_INVALID_MESSAGELEN, RangeError) \
|
|
52
|
+
V(ERR_CRYPTO_INVALID_SCRYPT_PARAMS, RangeError) \
|
|
53
|
+
V(ERR_CRYPTO_INVALID_STATE, Error) \
|
|
54
|
+
V(ERR_CRYPTO_INVALID_TAG_LENGTH, RangeError) \
|
|
55
|
+
V(ERR_CRYPTO_JWK_UNSUPPORTED_CURVE, Error) \
|
|
56
|
+
V(ERR_CRYPTO_JWK_UNSUPPORTED_KEY_TYPE, Error) \
|
|
57
|
+
V(ERR_CRYPTO_OPERATION_FAILED, Error) \
|
|
58
|
+
V(ERR_CRYPTO_TIMING_SAFE_EQUAL_LENGTH, RangeError) \
|
|
59
|
+
V(ERR_CRYPTO_UNKNOWN_CIPHER, Error) \
|
|
60
|
+
V(ERR_CRYPTO_UNKNOWN_DH_GROUP, Error) \
|
|
61
|
+
V(ERR_CRYPTO_UNSUPPORTED_OPERATION, Error) \
|
|
62
|
+
V(ERR_CRYPTO_JOB_INIT_FAILED, Error) \
|
|
63
|
+
V(ERR_DLOPEN_DISABLED, Error) \
|
|
64
|
+
V(ERR_DLOPEN_FAILED, Error) \
|
|
65
|
+
V(ERR_ENCODING_INVALID_ENCODED_DATA, TypeError) \
|
|
66
|
+
V(ERR_EXECUTION_ENVIRONMENT_NOT_AVAILABLE, Error) \
|
|
67
|
+
V(ERR_ILLEGAL_CONSTRUCTOR, Error) \
|
|
68
|
+
V(ERR_INVALID_ADDRESS, Error) \
|
|
69
|
+
V(ERR_INVALID_ARG_VALUE, TypeError) \
|
|
70
|
+
V(ERR_OSSL_EVP_INVALID_DIGEST, Error) \
|
|
71
|
+
V(ERR_INVALID_ARG_TYPE, TypeError) \
|
|
72
|
+
V(ERR_INVALID_FILE_URL_HOST, TypeError) \
|
|
73
|
+
V(ERR_INVALID_FILE_URL_PATH, TypeError) \
|
|
74
|
+
V(ERR_INVALID_OBJECT_DEFINE_PROPERTY, TypeError) \
|
|
75
|
+
V(ERR_INVALID_MODULE, Error) \
|
|
76
|
+
V(ERR_INVALID_STATE, Error) \
|
|
77
|
+
V(ERR_INVALID_THIS, TypeError) \
|
|
78
|
+
V(ERR_INVALID_TRANSFER_OBJECT, TypeError) \
|
|
79
|
+
V(ERR_INVALID_URL, TypeError) \
|
|
80
|
+
V(ERR_INVALID_URL_SCHEME, TypeError) \
|
|
81
|
+
V(ERR_MEMORY_ALLOCATION_FAILED, Error) \
|
|
82
|
+
V(ERR_MESSAGE_TARGET_CONTEXT_UNAVAILABLE, Error) \
|
|
83
|
+
V(ERR_MISSING_ARGS, TypeError) \
|
|
84
|
+
V(ERR_MISSING_TRANSFERABLE_IN_TRANSFER_LIST, TypeError) \
|
|
85
|
+
V(ERR_MISSING_PASSPHRASE, TypeError) \
|
|
86
|
+
V(ERR_MISSING_PLATFORM_FOR_WORKER, Error) \
|
|
87
|
+
V(ERR_MODULE_NOT_FOUND, Error) \
|
|
88
|
+
V(ERR_NON_CONTEXT_AWARE_DISABLED, Error) \
|
|
89
|
+
V(ERR_OUT_OF_RANGE, RangeError) \
|
|
90
|
+
V(ERR_SCRIPT_EXECUTION_INTERRUPTED, Error) \
|
|
91
|
+
V(ERR_SCRIPT_EXECUTION_TIMEOUT, Error) \
|
|
92
|
+
V(ERR_STRING_TOO_LONG, Error) \
|
|
93
|
+
V(ERR_TLS_INVALID_PROTOCOL_METHOD, TypeError) \
|
|
94
|
+
V(ERR_TLS_PSK_SET_IDENTIY_HINT_FAILED, Error) \
|
|
95
|
+
V(ERR_VM_MODULE_CACHED_DATA_REJECTED, Error) \
|
|
96
|
+
V(ERR_VM_MODULE_LINK_FAILURE, Error) \
|
|
97
|
+
V(ERR_WASI_NOT_STARTED, Error) \
|
|
98
|
+
V(ERR_WORKER_INIT_FAILED, Error) \
|
|
99
|
+
V(ERR_PROTO_ACCESS, Error)
|
|
100
|
+
|
|
101
|
+
#define V(code, type) \
|
|
102
|
+
template <typename... Args> \
|
|
103
|
+
inline v8::Local<v8::Value> code( \
|
|
104
|
+
v8::Isolate* isolate, const char* format, Args&&... args) { \
|
|
105
|
+
std::string message = SPrintF(format, std::forward<Args>(args)...); \
|
|
106
|
+
v8::Local<v8::String> js_code = OneByteString(isolate, #code); \
|
|
107
|
+
v8::Local<v8::String> js_msg = \
|
|
108
|
+
OneByteString(isolate, message.c_str(), message.length()); \
|
|
109
|
+
v8::Local<v8::Object> e = v8::Exception::type(js_msg) \
|
|
110
|
+
->ToObject(isolate->GetCurrentContext()) \
|
|
111
|
+
.ToLocalChecked(); \
|
|
112
|
+
e->Set(isolate->GetCurrentContext(), \
|
|
113
|
+
OneByteString(isolate, "code"), \
|
|
114
|
+
js_code) \
|
|
115
|
+
.Check(); \
|
|
116
|
+
return e; \
|
|
117
|
+
} \
|
|
118
|
+
template <typename... Args> \
|
|
119
|
+
inline void THROW_##code( \
|
|
120
|
+
v8::Isolate* isolate, const char* format, Args&&... args) { \
|
|
121
|
+
isolate->ThrowException( \
|
|
122
|
+
code(isolate, format, std::forward<Args>(args)...)); \
|
|
123
|
+
} \
|
|
124
|
+
template <typename... Args> \
|
|
125
|
+
inline void THROW_##code( \
|
|
126
|
+
Environment* env, const char* format, Args&&... args) { \
|
|
127
|
+
THROW_##code(env->isolate(), format, std::forward<Args>(args)...); \
|
|
128
|
+
}
|
|
129
|
+
ERRORS_WITH_CODE(V)
|
|
130
|
+
#undef V
|
|
131
|
+
|
|
132
|
+
// Errors with predefined static messages
|
|
133
|
+
|
|
134
|
+
#define PREDEFINED_ERROR_MESSAGES(V) \
|
|
135
|
+
V(ERR_ACCESS_DENIED, "Access to this API has been restricted") \
|
|
136
|
+
V(ERR_BUFFER_CONTEXT_NOT_AVAILABLE, \
|
|
137
|
+
"Buffer is not available for the current Context") \
|
|
138
|
+
V(ERR_CLOSED_MESSAGE_PORT, "Cannot send data on closed MessagePort") \
|
|
139
|
+
V(ERR_CONSTRUCT_CALL_INVALID, "Constructor cannot be called") \
|
|
140
|
+
V(ERR_CONSTRUCT_CALL_REQUIRED, "Cannot call constructor without `new`") \
|
|
141
|
+
V(ERR_CRYPTO_INITIALIZATION_FAILED, "Initialization failed") \
|
|
142
|
+
V(ERR_CRYPTO_INVALID_AUTH_TAG, "Invalid authentication tag") \
|
|
143
|
+
V(ERR_CRYPTO_INVALID_COUNTER, "Invalid counter") \
|
|
144
|
+
V(ERR_CRYPTO_INVALID_CURVE, "Invalid EC curve name") \
|
|
145
|
+
V(ERR_CRYPTO_INVALID_DIGEST, "Invalid digest") \
|
|
146
|
+
V(ERR_CRYPTO_INVALID_IV, "Invalid initialization vector") \
|
|
147
|
+
V(ERR_CRYPTO_INVALID_JWK, "Invalid JWK format") \
|
|
148
|
+
V(ERR_CRYPTO_INVALID_KEYLEN, "Invalid key length") \
|
|
149
|
+
V(ERR_CRYPTO_INVALID_KEYPAIR, "Invalid key pair") \
|
|
150
|
+
V(ERR_CRYPTO_INVALID_KEYTYPE, "Invalid key type") \
|
|
151
|
+
V(ERR_CRYPTO_INVALID_MESSAGELEN, "Invalid message length") \
|
|
152
|
+
V(ERR_CRYPTO_INVALID_SCRYPT_PARAMS, "Invalid scrypt params") \
|
|
153
|
+
V(ERR_CRYPTO_INVALID_STATE, "Invalid state") \
|
|
154
|
+
V(ERR_CRYPTO_INVALID_TAG_LENGTH, "Invalid taglength") \
|
|
155
|
+
V(ERR_CRYPTO_JWK_UNSUPPORTED_KEY_TYPE, "Unsupported JWK Key Type.") \
|
|
156
|
+
V(ERR_CRYPTO_OPERATION_FAILED, "Operation failed") \
|
|
157
|
+
V(ERR_CRYPTO_TIMING_SAFE_EQUAL_LENGTH, \
|
|
158
|
+
"Input buffers must have the same byte length") \
|
|
159
|
+
V(ERR_CRYPTO_UNKNOWN_CIPHER, "Unknown cipher") \
|
|
160
|
+
V(ERR_CRYPTO_UNKNOWN_DH_GROUP, "Unknown DH group") \
|
|
161
|
+
V(ERR_CRYPTO_UNSUPPORTED_OPERATION, "Unsupported crypto operation") \
|
|
162
|
+
V(ERR_CRYPTO_JOB_INIT_FAILED, "Failed to initialize crypto job config") \
|
|
163
|
+
V(ERR_DLOPEN_FAILED, "DLOpen failed") \
|
|
164
|
+
V(ERR_EXECUTION_ENVIRONMENT_NOT_AVAILABLE, \
|
|
165
|
+
"Context not associated with Node.js environment") \
|
|
166
|
+
V(ERR_ILLEGAL_CONSTRUCTOR, "Illegal constructor") \
|
|
167
|
+
V(ERR_INVALID_ADDRESS, "Invalid socket address") \
|
|
168
|
+
V(ERR_INVALID_MODULE, "No such module") \
|
|
169
|
+
V(ERR_INVALID_STATE, "Invalid state") \
|
|
170
|
+
V(ERR_INVALID_THIS, "Value of \"this\" is the wrong type") \
|
|
171
|
+
V(ERR_INVALID_TRANSFER_OBJECT, "Found invalid object in transferList") \
|
|
172
|
+
V(ERR_INVALID_URL_SCHEME, "The URL must be of scheme file:") \
|
|
173
|
+
V(ERR_MEMORY_ALLOCATION_FAILED, "Failed to allocate memory") \
|
|
174
|
+
V(ERR_OSSL_EVP_INVALID_DIGEST, "Invalid digest used") \
|
|
175
|
+
V(ERR_MESSAGE_TARGET_CONTEXT_UNAVAILABLE, \
|
|
176
|
+
"A message object could not be deserialized successfully in the target " \
|
|
177
|
+
"vm.Context") \
|
|
178
|
+
V(ERR_MISSING_TRANSFERABLE_IN_TRANSFER_LIST, \
|
|
179
|
+
"Object that needs transfer was found in message but not listed " \
|
|
180
|
+
"in transferList") \
|
|
181
|
+
V(ERR_MISSING_PLATFORM_FOR_WORKER, \
|
|
182
|
+
"The V8 platform used by this instance of Node does not support " \
|
|
183
|
+
"creating Workers") \
|
|
184
|
+
V(ERR_NON_CONTEXT_AWARE_DISABLED, \
|
|
185
|
+
"Loading non context-aware native addons has been disabled") \
|
|
186
|
+
V(ERR_SCRIPT_EXECUTION_INTERRUPTED, \
|
|
187
|
+
"Script execution was interrupted by `SIGINT`") \
|
|
188
|
+
V(ERR_TLS_PSK_SET_IDENTIY_HINT_FAILED, "Failed to set PSK identity hint") \
|
|
189
|
+
V(ERR_WASI_NOT_STARTED, "wasi.start() has not been called") \
|
|
190
|
+
V(ERR_WORKER_INIT_FAILED, "Worker initialization failure") \
|
|
191
|
+
V(ERR_PROTO_ACCESS, \
|
|
192
|
+
"Accessing Object.prototype.__proto__ has been " \
|
|
193
|
+
"disallowed with --disable-proto=throw")
|
|
194
|
+
|
|
195
|
+
#define V(code, message) \
|
|
196
|
+
inline v8::Local<v8::Value> code(v8::Isolate* isolate) { \
|
|
197
|
+
return code(isolate, message); \
|
|
198
|
+
} \
|
|
199
|
+
inline void THROW_ ## code(v8::Isolate* isolate) { \
|
|
200
|
+
isolate->ThrowException(code(isolate, message)); \
|
|
201
|
+
} \
|
|
202
|
+
inline void THROW_ ## code(Environment* env) { \
|
|
203
|
+
THROW_ ## code(env->isolate()); \
|
|
204
|
+
}
|
|
205
|
+
PREDEFINED_ERROR_MESSAGES(V)
|
|
206
|
+
#undef V
|
|
207
|
+
|
|
208
|
+
// Errors with predefined non-static messages
|
|
209
|
+
inline void THROW_ERR_SCRIPT_EXECUTION_TIMEOUT(Environment* env,
|
|
210
|
+
int64_t timeout) {
|
|
211
|
+
std::ostringstream message;
|
|
212
|
+
message << "Script execution timed out after ";
|
|
213
|
+
message << timeout << "ms";
|
|
214
|
+
THROW_ERR_SCRIPT_EXECUTION_TIMEOUT(env, message.str().c_str());
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
inline v8::Local<v8::Value> ERR_BUFFER_TOO_LARGE(v8::Isolate* isolate) {
|
|
218
|
+
char message[128];
|
|
219
|
+
snprintf(message, sizeof(message),
|
|
220
|
+
"Cannot create a Buffer larger than 0x%zx bytes",
|
|
221
|
+
v8::TypedArray::kMaxLength);
|
|
222
|
+
return ERR_BUFFER_TOO_LARGE(isolate, message);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
inline v8::Local<v8::Value> ERR_STRING_TOO_LONG(v8::Isolate* isolate) {
|
|
226
|
+
char message[128];
|
|
227
|
+
snprintf(message, sizeof(message),
|
|
228
|
+
"Cannot create a string longer than 0x%x characters",
|
|
229
|
+
v8::String::kMaxLength);
|
|
230
|
+
return ERR_STRING_TOO_LONG(isolate, message);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
#define THROW_AND_RETURN_IF_NOT_BUFFER(env, val, prefix) \
|
|
234
|
+
do { \
|
|
235
|
+
if (!Buffer::HasInstance(val)) \
|
|
236
|
+
return node::THROW_ERR_INVALID_ARG_TYPE(env, \
|
|
237
|
+
prefix " must be a buffer"); \
|
|
238
|
+
} while (0)
|
|
239
|
+
|
|
240
|
+
#define THROW_AND_RETURN_IF_NOT_STRING(env, val, prefix) \
|
|
241
|
+
do { \
|
|
242
|
+
if (!val->IsString()) \
|
|
243
|
+
return node::THROW_ERR_INVALID_ARG_TYPE(env, \
|
|
244
|
+
prefix " must be a string"); \
|
|
245
|
+
} while (0)
|
|
246
|
+
|
|
247
|
+
namespace errors {
|
|
248
|
+
|
|
249
|
+
class TryCatchScope : public v8::TryCatch {
|
|
250
|
+
public:
|
|
251
|
+
enum class CatchMode { kNormal, kFatal };
|
|
252
|
+
|
|
253
|
+
explicit TryCatchScope(Environment* env, CatchMode mode = CatchMode::kNormal)
|
|
254
|
+
: v8::TryCatch(env->isolate()), env_(env), mode_(mode) {}
|
|
255
|
+
~TryCatchScope();
|
|
256
|
+
|
|
257
|
+
// Since the dtor is not virtual we need to make sure no one creates
|
|
258
|
+
// object of it in the free store that might be held by polymorphic pointers.
|
|
259
|
+
void* operator new(std::size_t count) = delete;
|
|
260
|
+
void* operator new[](std::size_t count) = delete;
|
|
261
|
+
TryCatchScope(TryCatchScope&) = delete;
|
|
262
|
+
TryCatchScope(TryCatchScope&&) = delete;
|
|
263
|
+
TryCatchScope operator=(TryCatchScope&) = delete;
|
|
264
|
+
TryCatchScope operator=(TryCatchScope&&) = delete;
|
|
265
|
+
|
|
266
|
+
private:
|
|
267
|
+
Environment* env_;
|
|
268
|
+
CatchMode mode_;
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
// Trigger the global uncaught exception handler `process._fatalException`
|
|
272
|
+
// in JS land (which emits the 'uncaughtException' event). If that returns
|
|
273
|
+
// true, continue program execution, otherwise exit the process.
|
|
274
|
+
void TriggerUncaughtException(v8::Isolate* isolate,
|
|
275
|
+
const v8::TryCatch& try_catch);
|
|
276
|
+
void TriggerUncaughtException(v8::Isolate* isolate,
|
|
277
|
+
v8::Local<v8::Value> error,
|
|
278
|
+
v8::Local<v8::Message> message,
|
|
279
|
+
bool from_promise = false);
|
|
280
|
+
|
|
281
|
+
const char* errno_string(int errorno);
|
|
282
|
+
void PerIsolateMessageListener(v8::Local<v8::Message> message,
|
|
283
|
+
v8::Local<v8::Value> error);
|
|
284
|
+
|
|
285
|
+
void DecorateErrorStack(Environment* env,
|
|
286
|
+
const errors::TryCatchScope& try_catch);
|
|
287
|
+
|
|
288
|
+
class PrinterTryCatch : public v8::TryCatch {
|
|
289
|
+
public:
|
|
290
|
+
enum PrintSourceLine { kPrintSourceLine, kDontPrintSourceLine };
|
|
291
|
+
explicit PrinterTryCatch(v8::Isolate* isolate,
|
|
292
|
+
PrintSourceLine print_source_line)
|
|
293
|
+
: v8::TryCatch(isolate),
|
|
294
|
+
isolate_(isolate),
|
|
295
|
+
print_source_line_(print_source_line) {}
|
|
296
|
+
~PrinterTryCatch();
|
|
297
|
+
|
|
298
|
+
private:
|
|
299
|
+
v8::Isolate* isolate_;
|
|
300
|
+
PrintSourceLine print_source_line_;
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
} // namespace errors
|
|
304
|
+
|
|
305
|
+
v8::ModifyCodeGenerationFromStringsResult ModifyCodeGenerationFromStrings(
|
|
306
|
+
v8::Local<v8::Context> context,
|
|
307
|
+
v8::Local<v8::Value> source,
|
|
308
|
+
bool is_code_like);
|
|
309
|
+
} // namespace node
|
|
310
|
+
|
|
311
|
+
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
312
|
+
|
|
313
|
+
#endif // SRC_NODE_ERRORS_H_
|