build: use our patch system to apply patches to upstream node (#19270)

This points our node repo at upstream (nodejs/node) and uses the base node tag as the target ref.  We then use our existing patch system and patch files to apply our changes on top of node.  This unifies how we patch upstream repos and makes our node patches easier to reason, view, understand and most importantly reduce.
This commit is contained in:
Samuel Attard 2019-07-16 10:23:04 -07:00 коммит произвёл Jeremy Apthorp
Родитель 4d547bdd3a
Коммит 9a7426dc25
57 изменённых файлов: 5056 добавлений и 3 удалений

4
DEPS
Просмотреть файл

@ -12,7 +12,7 @@ vars = {
'chromium_version':
'5a48e127c8cb8ae827f4fead0b527079194b9899',
'node_version':
'cbb519597cf085e7d759080c6a6b8f1c4dab85bc',
'v12.4.0',
'nan_version':
'2ee313aaca52e2b478965ac50eb5082520380d1b',
@ -78,7 +78,7 @@ deps = {
'condition': 'checkout_nan and process_deps',
},
'src/third_party/electron_node': {
'url': (Var("electron_git")) + '/node.git@' + (Var("node_version")),
'url': (Var("nodejs_git")) + '/node.git@' + (Var("node_version")),
'condition': 'checkout_node and process_deps',
},
'src/electron/vendor/pyyaml': {

Просмотреть файл

@ -5,5 +5,7 @@
"src/electron/patches/swiftshader": "src/third_party/swiftshader",
"src/electron/patches/v8": "src/v8"
"src/electron/patches/v8": "src/v8",
"src/electron/patches/node": "src/third_party/electron_node"
}

54
patches/node/.patches Normal file
Просмотреть файл

@ -0,0 +1,54 @@
make_module_globalpaths_a_reference.patch
fix_don_t_create_console_window_when_creating_process.patch
refactor_alter_child_process_fork_to_use_execute_script_with.patch
feat_add_uv_loop_watcher_queue_code.patch
feat_initialize_asar_support.patch
export_nativemodule.patch
expose_get_builtin_module_function.patch
fix_expose_traceeventhelper.patch
fix_build_and_expose_inspector_agent.patch
fix_expose_internalcallbackscope.patch
build_add_gn_build_files.patch
fix_export_debugoptions.patch
fix_add_default_values_for_enable_lto_and_build_v8_with_gn_in.patch
feat_add_new_built_with_electron_variable_to_config_gypi.patch
feat_add_flags_for_low-level_hooks_and_exceptions.patch
export_environment_knodecontexttagptr.patch
fix_export_libuv_symbols_73.patch
fix_expose_tracing_agent_and_use_tracing_tracingcontroller_instead.patch
fix_use_bssl_bn_bn2bin_padded_for_ossl_s_bn_bn2binpad.patch
pass_all_globals_through_require.patch
call_process_log_from_fallback_stream_on_windows.patch
fixme_use_redefined_version_of_internalmodulestat.patch
fixme_remove_async_id_assertion_check.patch
src_use_check_false_in_switch_default_case.patch
fixme_comment_trace_event_macro.patch
fix_export_node_abort_and_assert.patch
fix_make_it_possible_to_change_nobrowserglobals_at_runtime.patch
fix_key_gen_apis_are_not_available_in_boringssl.patch
fix_do_not_define_debugoptions_s_constructors_in_header.patch
src_disable_node_use_v8_platform_in_node_options.patch
feat_add_original-fs_module.patch
build_allow_embedders_to_override_the_node_module_version_define.patch
refactor_allow_embedder_overriding_of_internal_fs_calls.patch
chore_add_ability_to_prevent_warn_non_context-aware_native_modules.patch
fsevents_fix_file_event_reporting.patch
src_only_run_preloadmodules_if_the_preload_array_is_not_empty.patch
src_read_break_node_first_line_from_the_inspect_options.patch
chore_allow_the_node_entrypoint_to_be_a_builtin_module.patch
inherit_electron_crashpad_pipe_name_in_child_process.patch
allow_embedder_to_insert_js_data_into_nativemoduleloader.patch
chore_update_gn_files_for_file_movement.patch
fixme_revert_crypto_add_support_for_rsa-pss_keys.patch
build_fix_gn_build_scripts_and_js2c_for_node_12_4_and_embedder_use.patch
chore_re-add_compileandcall_this_should_be_added_as_a_helper_in.patch
chore_remove_unused_private_runtimeagent_member_env.patch
src_add_missing_option_parser_template_for_the_debugoptionsparser.patch
src_expose_maybeinitializecontext_to_allow_existing_contexts.patch
fix_don_t_define_building_v8_shared_in_component_builds_109.patch
chore_fix_js2c_hacks_for_original-fs.patch
chore_remove_sysinfo-memory_from_build_files.patch
fix_make_js2c_normalize_paths_before_splitting_on_separaters.patch
fix_extern_the_nativemoduleenv_and_options_parser_for_debug_builds.patch
fix_ensure_js2c_maps_internal-fs_streams.patch
chore_read_nobrowserglobals_from_global_not_process.patch

Просмотреть файл

@ -0,0 +1,30 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: deepak1556 <hop2deep@gmail.com>
Date: Tue, 26 Feb 2019 17:04:14 -0800
Subject: Allow embedder to insert JS data into NativeModuleLoader
diff --git a/src/node_native_module.cc b/src/node_native_module.cc
index 814adb620dcf8a459bbede11714e9ccd7f4e0b3e..04a706d15f2ab682f8d4ae972abee8986494f7a7 100644
--- a/src/node_native_module.cc
+++ b/src/node_native_module.cc
@@ -23,6 +23,7 @@ NativeModuleLoader NativeModuleLoader::instance_;
NativeModuleLoader::NativeModuleLoader() : config_(GetConfig()) {
LoadJavaScriptSource();
+ LoadEmbedderJavaScriptSource();
}
NativeModuleLoader* NativeModuleLoader::GetInstance() {
diff --git a/src/node_native_module.h b/src/node_native_module.h
index fabaea75686161f488a03349e07049a513b98fad..5a6b01dc12fb77d5f8c26a1153ead2a1b2a8d061 100644
--- a/src/node_native_module.h
+++ b/src/node_native_module.h
@@ -44,6 +44,7 @@ class NativeModuleLoader {
// Generated by tools/js2c.py as node_javascript.cc
void LoadJavaScriptSource(); // Loads data into source_
+ void LoadEmbedderJavaScriptSource(); // Loads embedder data into source_
UnionBytes GetConfig(); // Return data for config.gypi
bool Exists(const char* id);

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,159 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <sattard@slack-corp.com>
Date: Tue, 16 Apr 2019 15:12:14 -0700
Subject: build: allow embedders to override the NODE_MODULE_VERSION define
diff --git a/BUILD.gn b/BUILD.gn
index 028b0ae16ffac1fc89128f2f994680923a500a36..b5912d4d671db27761be4c6283ed5e21818c5b04 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -37,6 +37,9 @@ declare_args() {
# `sourceUrl` and `headersUrl`. When compiling a release build, this will
# default to https://nodejs.org/download/release/')
node_release_urlbase = ""
+
+ # Allows embedders to override the NODE_MODULE_VERSION define
+ node_module_version = ""
}
assert(!node_use_dtrace, "node_use_dtrace not supported in GN")
@@ -145,6 +148,9 @@ config("node_internal_config") {
"NODE_WANT_INTERNALS=1",
"NODE_IMPLEMENTATION",
]
+ if (node_module_version != "") {
+ defines += [ "NODE_MODULE_VERSION=" + node_module_version ]
+ }
if (is_component_build) {
defines += [
"BUILDING_V8_SHARED",
@@ -200,14 +206,14 @@ config("node_internal_config") {
component("node_lib") {
deps = [
":node_js2c",
- "//third_party/brotli:enc",
- "//third_party/brotli:dec",
"deps/cares",
"deps/histogram",
"deps/http_parser",
"deps/llhttp",
"deps/nghttp2",
"deps/zlib",
+ "//third_party/brotli:dec",
+ "//third_party/brotli:enc",
"//v8:v8_libplatform",
]
public_deps = [
@@ -255,8 +261,8 @@ component("node_lib") {
"src/inspector_agent.h",
"src/inspector_io.cc",
"src/inspector_io.h",
- "src/inspector_profiler.cc",
"src/inspector_js_api.cc",
+ "src/inspector_profiler.cc",
"src/inspector_socket.cc",
"src/inspector_socket.h",
"src/inspector_socket_server.cc",
@@ -323,6 +329,20 @@ copy("node_gypi_headers") {
]
}
+action("node_version_header") {
+ inputs = [
+ "src/node_version.h",
+ ]
+ outputs = [
+ "$node_headers_dir/include/node/node_version.h",
+ ]
+ script = "tools/generate_node_version_header.py"
+ args = [ rebase_path("src/node_version.h"), rebase_path(outputs[0]) ]
+ if (node_module_version != "") {
+ args += [ "$node_module_version" ]
+ }
+}
+
action("tar_headers") {
deps = [
":copy_headers",
@@ -341,6 +361,7 @@ group("copy_headers") {
public_deps = header_groups + [
":zlib_headers",
":node_gypi_headers",
+ ":node_version_header",
]
}
diff --git a/filenames.json b/filenames.json
index 615b82d3d78d63c8441172d65f008914756fdb7e..86d89280e74d7365ab2782517fb779fc072bf0bf 100644
--- a/filenames.json
+++ b/filenames.json
@@ -11,8 +11,7 @@
"src/node_api.h",
"src/node_api_types.h",
"src/node_buffer.h",
- "src/node_object_wrap.h",
- "src/node_version.h"
+ "src/node_object_wrap.h"
]
},
{
diff --git a/src/node_version.h b/src/node_version.h
index 1c04b102721f891c6b657702b7f8585137647e04..a9f8a9c8cbfd3996906eb400388aaa99ef77f547 100644
--- a/src/node_version.h
+++ b/src/node_version.h
@@ -89,7 +89,10 @@
* version matching should open a pull request to reserve a number in this
* registry.
*/
+// Electron sets NODE_MODULE_VERSION in their GN configuration
+#ifndef NODE_MODULE_VERSION
#define NODE_MODULE_VERSION 72
+#endif
// the NAPI_VERSION provided by this version of the runtime
#define NAPI_VERSION 4
diff --git a/tools/generate_gn_filenames_json.py b/tools/generate_gn_filenames_json.py
index 28e97bcb9aed0a8c0bbfa0e00ba914aa923d4bba..41f0138dfa9f610de1f8267080fa15e8bd9e0325 100755
--- a/tools/generate_gn_filenames_json.py
+++ b/tools/generate_gn_filenames_json.py
@@ -49,7 +49,7 @@ if __name__ == '__main__':
def add_headers(files, dest_dir):
if 'src/node.h' in files:
- files = [f for f in files if f.endswith('.h')]
+ files = [f for f in files if f.endswith('.h') and f != 'src/node_version.h']
elif any(f.startswith('deps/v8/') for f in files):
files = [f.replace('deps/v8/', '//v8/', 1) for f in files]
hs = {'files': sorted(files), 'dest_dir': dest_dir}
diff --git a/tools/generate_node_version_header.py b/tools/generate_node_version_header.py
new file mode 100755
index 0000000000000000000000000000000000000000..3088ae4bdf814ae255c9805ebd393b2eee17e941
--- /dev/null
+++ b/tools/generate_node_version_header.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+import re
+import sys
+
+node_version_file = sys.argv[1]
+out_file = sys.argv[2]
+NMV = None
+if len(sys.argv) > 3:
+ NMV = sys.argv[3]
+
+with open(node_version_file, 'r') as in_file, open(out_file, 'w') as out_file:
+ changed = False
+ contents = in_file.read()
+ new_contents = re.sub(
+ r'^#define NODE_MODULE_VERSION [0-9]+$',
+ '#define NODE_MODULE_VERSION ' + NMV,
+ contents,
+ flags=re.MULTILINE)
+
+ changed = contents != new_contents
+
+ if not changed and NMV is not None:
+ raise Exception("Did not modify the NMV from nodes value, this value MUST differ from node")
+
+ out_file.writelines(new_contents)

Просмотреть файл

@ -0,0 +1,149 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <sattard@slack-corp.com>
Date: Fri, 28 Jun 2019 17:13:38 -0700
Subject: build: fix GN build scripts and js2c for node 12.4 and embedder use
cases
diff --git a/BUILD.gn b/BUILD.gn
index c722975a4bc82b46192b0e72f4995fce243fa5bf..77b2ed2978682c1a171346339ded5f2638c27fd9 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -96,9 +96,7 @@ chdir_action("node_js2c") {
cwd = "$target_gen_dir/js2c_inputs"
script = "tools/js2c.py"
- args = rebase_path(outputs)
- args += library_files
- args += rebase_path(macro_inputs + config_gypi)
+ args = library_files + rebase_path(macro_inputs + config_gypi) + ["--target"] + rebase_path(outputs)
}
config("node_features") {
@@ -113,6 +111,8 @@ config("node_features") {
} else {
defines += [ "HAVE_OPENSSL=0" ]
}
+ # boringssl does not support SSL_trace, let's disable it
+ defines += ["OPENSSL_NO_SSL_TRACE=1"]
if (v8_enable_i18n_support) {
defines += [ "NODE_HAVE_I18N_SUPPORT=1" ]
} else {
diff --git a/src/inspector/BUILD.gn b/src/inspector/BUILD.gn
index ebf5e610d675e53ad4af40e92d5217995ed8f577..48ad85e895b6111223119fafa57c13ba75cdbeae 100644
--- a/src/inspector/BUILD.gn
+++ b/src/inspector/BUILD.gn
@@ -68,7 +68,7 @@ action("protocol_generated_sources") {
inputs = [
"$target_gen_dir/node_protocol_config.json",
- "$target_gen_dir/node_protocol.json",
+ "$target_gen_dir/src/node_protocol.json",
"$inspector_protocol_dir/lib/base_string_adapter_cc.template",
"$inspector_protocol_dir/lib/base_string_adapter_h.template",
"$inspector_protocol_dir/lib/Allocator_h.template",
@@ -151,13 +151,13 @@ generate_protocol_json("node_protocol_json") {
"node_protocol.pdl",
]
outputs = [
- "$target_gen_dir/node_protocol.json",
+ "$target_gen_dir/src/node_protocol.json",
]
}
generate_protocol_json("v8_protocol_json") {
sources = [
- "//v8/src/inspector/js_protocol.pdl",
+ "//v8/include/js_protocol.pdl",
]
outputs = [
"$target_gen_dir/js_protocol.json",
@@ -171,7 +171,7 @@ action("concatenate_protocols") {
]
inputs = [
"$target_gen_dir/js_protocol.json",
- "$target_gen_dir/node_protocol.json",
+ "$target_gen_dir/src/node_protocol.json",
]
outputs = [
"$target_gen_dir/concatenated_protocol.json",
diff --git a/tools/js2c.py b/tools/js2c.py
index 87cca4eaf7c909e1f871287d7f019f701a05dd0f..c7a90f6eaeb9f5789ffb86c070132551f4275354 100755
--- a/tools/js2c.py
+++ b/tools/js2c.py
@@ -187,13 +187,15 @@ namespace native_module {{
{0}
-void NativeModuleLoader::LoadJavaScriptSource() {{
+void NativeModuleLoader::Load{4}JavaScriptSource() {{
{1}
}}
+#if {2}
UnionBytes NativeModuleLoader::GetConfig() {{
- return UnionBytes(config_raw, {2}); // config.gypi
+ return UnionBytes(config_raw, {3}); // config.gypi
}}
+#endif
}} // namespace native_module
@@ -273,9 +275,9 @@ def NormalizeFileName(filename):
return os.path.splitext(filename)[0]
-def JS2C(source_files, target):
+def JS2C(source_files, target, only_js):
# Process input from all *macro.py files
- consts, macros = ReadMacros(source_files['.py'])
+ consts, macros = ReadMacros([] if only_js else source_files['.py'])
# Build source code lines
definitions = []
@@ -294,13 +296,15 @@ def JS2C(source_files, target):
elif filename == 'internal/fs/streams.js':
AddModule('original-fs/streams', lines.replace("require('fs')", "require('original-fs')"))
- config_def, config_size = handle_config_gypi(source_files['config.gypi'])
- definitions.append(config_def)
+ config_size = 0
+ if not only_js:
+ config_def, config_size = handle_config_gypi(source_files['config.gypi'])
+ definitions.append(config_def)
# Emit result
definitions = ''.join(definitions)
initializers = '\n '.join(initializers)
- out = TEMPLATE.format(definitions, initializers, config_size)
+ out = TEMPLATE.format(definitions, initializers, '0' if only_js else '1', config_size, 'Embedder' if only_js else '')
write_if_chaged(out, target)
@@ -353,17 +357,21 @@ def main():
)
parser.add_argument('--target', help='output file')
parser.add_argument('--verbose', action='store_true', help='output file')
+ parser.add_argument('--only-js', action='store_true', help='do not require or parse any config.gypi files')
parser.add_argument('sources', nargs='*', help='input files')
options = parser.parse_args()
global is_verbose
is_verbose = options.verbose
source_files = functools.reduce(SourceFileByExt, options.sources, {})
# Should have exactly 3 types: `.js`, `.py`, and `.gypi`
- assert len(source_files) == 3
- # Currently config.gypi is the only `.gypi` file allowed
- assert source_files['.gypi'] == ['config.gypi']
- source_files['config.gypi'] = source_files.pop('.gypi')[0]
- JS2C(source_files, options.target)
+ if options.only_js:
+ assert len(source_files) == 1
+ else:
+ assert len(source_files) == 3
+ # Currently config.gypi is the only `.gypi` file allowed
+ assert source_files['.gypi'][0].endswith('config.gypi')
+ source_files['config.gypi'] = source_files.pop('.gypi')[0]
+ JS2C(source_files, options.target, options.only_js)
if __name__ == "__main__":

Просмотреть файл

@ -0,0 +1,23 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Kevin Sawicki <kevinsawicki@gmail.com>
Date: Wed, 12 Oct 2016 09:43:26 -0700
Subject: Call process.log from fallback stream on Windows
(cherry picked from commit d31e629b4f2daf3500a485caab2b2990a41e3ad4)
diff --git a/lib/internal/process/stdio.js b/lib/internal/process/stdio.js
index 61892165999d92704e49d0748c5e1d3d4d9582b7..0ea488c944b8fc8e21064476180c2b417c6e1125 100644
--- a/lib/internal/process/stdio.js
+++ b/lib/internal/process/stdio.js
@@ -192,6 +192,11 @@ function createWritableStdioStream(fd) {
const { Writable } = require('stream');
stream = new Writable({
write(buf, enc, cb) {
+ if (process.platform === 'win32' &&
+ process.env.ELECTRON_RUN_AS_NODE &&
+ !process.env.ELECTRON_NO_ATTACH_CONSOLE) {
+ process.log(buf.toString());
+ }
cb();
}
});

Просмотреть файл

@ -0,0 +1,63 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <sattard@slack-corp.com>
Date: Wed, 22 May 2019 13:34:18 -0700
Subject: chore: add ability to prevent / warn non context-aware native modules
being loaded
diff --git a/src/env.h b/src/env.h
index b97d024a0e8396ebd21b96bd7f1a9473abfefe9b..23ad7569d31bc534247ed373819bc291a4f4bfe6 100644
--- a/src/env.h
+++ b/src/env.h
@@ -827,6 +827,15 @@ class Environment : public MemoryRetainer {
uint64_t thread_id = kNoThreadId);
~Environment();
+ void ForceOnlyContextAwareNativeModules() {
+ force_context_aware_ = true;
+ }
+ void WarnNonContextAwareNativeModules() {
+ warn_non_context_aware_ = true;
+ }
+ bool force_context_aware() { return force_context_aware_; }
+ bool warn_non_context_aware() { return warn_non_context_aware_; }
+
void InitializeLibuv(bool start_profiler_idle_notifier);
v8::MaybeLocal<v8::Object> ProcessCliArgs(
const std::vector<std::string>& args,
@@ -1177,6 +1186,9 @@ class Environment : public MemoryRetainer {
inline void ThrowError(v8::Local<v8::Value> (*fun)(v8::Local<v8::String>),
const char* errmsg);
+ bool force_context_aware_ = false;
+ bool warn_non_context_aware_ = false;
+
std::list<binding::DLib> loaded_addons_;
v8::Isolate* const isolate_;
IsolateData* const isolate_data_;
diff --git a/src/node_binding.cc b/src/node_binding.cc
index 99c2406036e1874af253c61239e7736867813af8..117bc2891118e67ca7b10a33ba7e1fbebc973dbb 100644
--- a/src/node_binding.cc
+++ b/src/node_binding.cc
@@ -2,6 +2,7 @@
#include <atomic>
#include "env-inl.h"
#include "node_native_module_env.h"
+#include "node_process.h"
#include "util.h"
#if HAVE_OPENSSL
@@ -470,6 +471,13 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
}
if (mp != nullptr) {
+ if (mp->nm_context_register_func == nullptr) {
+ if (env->force_context_aware()) {
+ env->ThrowError("Loading non context-aware native modules has been disabled in this process. This means you have loaded a non context-aware native module with app.allowRendererProcessReuse set to true. See https://github.com/electron/electron/issues/18397 for more information");
+ } else if (env->warn_non_context_aware()) {
+ ProcessEmitWarningGeneric(env, "Loading non context-aware native modules in the renderer process is deprecated and will stop working at some point in the future, please see https://github.com/electron/electron/issues/18397 for more information", "Electron");
+ }
+ }
mp->nm_dso_handle = dlib->handle_;
dlib->SaveInGlobalHandleMap(mp);
} else {

Просмотреть файл

@ -0,0 +1,44 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <samuel.r.attard@gmail.com>
Date: Mon, 3 Jun 2019 01:05:58 -0700
Subject: chore: allow the node entrypoint to be a builtin module
This floats two patches onto the node 12 branch that I don't think we can upstream.
The default behavior of node is to `path.resolve(firstArg)` to figure out what JS file to load. Issue here is that we use that for `browser/init.js` which now doesn't exist on disk. This adds an exception that won't affect user code to allow node to boot-up internal modules (in this case anything in the `electron/js2c` scope.
Similar to the above, the loader uses `process.argv[1]` to figure out when to break for `--inspect-brk` this updates the logic to use an Electron provided `process._firstFileName`
diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js
index a998b095fb067ab6ca35cc276ac6a9a7c38dcf30..68ca0cefa4cf663cded9155bc4f2f226d807b577 100644
--- a/lib/internal/bootstrap/pre_execution.js
+++ b/lib/internal/bootstrap/pre_execution.js
@@ -70,8 +70,10 @@ function patchProcessObject(expandArgv1) {
if (expandArgv1 && process.argv[1] && !process.argv[1].startsWith('-')) {
// Expand process.argv[1] into a full path.
+ if (!process.argv[1] || !process.argv[1].startsWith('electron/js2c')) {
const path = require('path');
process.argv[1] = path.resolve(process.argv[1]);
+ }
}
// TODO(joyeecheung): most of these should be deprecated and removed,
diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js
index a643a77aec6398acfeae7f2e8e526d60c3b4453c..397cd8067849957599927bc033e3904964ac8c70 100644
--- a/lib/internal/modules/cjs/loader.js
+++ b/lib/internal/modules/cjs/loader.js
@@ -751,6 +751,13 @@ Module.prototype._compile = function(content, filename) {
if (getOptionValue('--inspect-brk') && process._eval == null) {
if (!resolvedArgv) {
// We enter the repl if we're not given a filename argument.
+ // process._firstFileName is used by Embedders to tell node what
+ // the first "real" file is when they use themselves as the entry
+ // point
+ if (process._firstFileName) {
+ resolvedArgv = process._firstFileName
+ delete process._firstFileName
+ } else
if (process.argv[1]) {
resolvedArgv = Module._resolveFilename(process.argv[1], null, false);
} else {

Просмотреть файл

@ -0,0 +1,40 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <sattard@slack-corp.com>
Date: Mon, 15 Jul 2019 10:26:42 -0700
Subject: chore: fix js2c hacks for original-fs
diff --git a/tools/js2c.py b/tools/js2c.py
index c7a90f6eaeb9f5789ffb86c070132551f4275354..4b0b631c46901c8ff01341c8d7f63c13008a5798 100755
--- a/tools/js2c.py
+++ b/tools/js2c.py
@@ -245,8 +245,8 @@ def GetDefinition(var, source, step=30):
return definition, len(code_points)
-def AddModule(filename, consts, macros, definitions, initializers):
- code = ReadFile(filename)
+def AddModule(filename, consts, macros, definitions, initializers, FileReadFn=ReadFile):
+ code = FileReadFn(filename)
code = ExpandConstants(code, consts)
code = ExpandMacros(code, macros)
name = NormalizeFileName(filename)
@@ -286,15 +286,15 @@ def JS2C(source_files, target, only_js):
for filename in source_files['.js']:
AddModule(filename, consts, macros, definitions, initializers)
# Electron: Expose fs module without asar support.
- if filename == 'fs.js':
+ if filename == 'lib/fs.js':
# Node's 'fs' and 'internal/fs/streams' have a lazy-loaded circular
# dependency. So to expose the unmodified Node 'fs' functionality here,
# we have to copy both 'fs' *and* 'internal/fs/streams' and modify the
# copies to depend on each other instead of on our asarified 'fs' code.
# See https://github.com/electron/electron/pull/16028 for more.
- AddModule('original-fs', lines.replace("require('internal/fs/streams')", "require('original-fs/streams')"))
+ AddModule('lib/original-fs.js', consts, macros, definitions, initializers, lambda _: ReadFile(filename).replace("require('internal/fs/streams')", "require('internal/original-fs/streams')"))
elif filename == 'internal/fs/streams.js':
- AddModule('original-fs/streams', lines.replace("require('fs')", "require('original-fs')"))
+ AddModule('lib/internal/original-fs/streams.js', consts, macros, definitions, initializers, lambda _: ReadFile(filename).replace("require('fs')", "require('original-fs')"))
config_size = 0
if not only_js:

Просмотреть файл

@ -0,0 +1,56 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <sattard@slack-corp.com>
Date: Fri, 28 Jun 2019 17:13:54 -0700
Subject: chore: re-add CompileAndCall, this should be added as a helper in
electron
diff --git a/src/node_native_module_env.cc b/src/node_native_module_env.cc
index 31536000fc8d2f9ce9589ef8e31cb55439fbd28d..6cb49b3b6def15a38ce1ba51da11af2567cb84ec 100644
--- a/src/node_native_module_env.cc
+++ b/src/node_native_module_env.cc
@@ -151,6 +151,22 @@ MaybeLocal<Function> NativeModuleEnv::LookupAndCompile(
return maybe;
}
+MaybeLocal<Value> NativeModuleEnv::CompileAndCall(
+ Local<Context> context,
+ const char* id,
+ std::vector<Local<String>>* parameters,
+ std::vector<Local<Value>>* arguments,
+ Environment* optional_env) {
+ Isolate* isolate = context->GetIsolate();
+ MaybeLocal<Function> compiled = LookupAndCompile(context, id, parameters, optional_env);
+ if (compiled.IsEmpty()) {
+ return MaybeLocal<Value>();
+ }
+ Local<Function> fn = compiled.ToLocalChecked().As<Function>();
+ return fn->Call(
+ context, v8::Null(isolate), arguments->size(), arguments->data());
+}
+
// TODO(joyeecheung): It is somewhat confusing that Class::Initialize
// is used to initialize to the binding, but it is the current convention.
// Rename this across the code base to something that makes more sense.
diff --git a/src/node_native_module_env.h b/src/node_native_module_env.h
index f662c67be50d404ee5b6cf6e2b8dd5991c59e723..b91a5059cd1f19d87e5876c372f3ded60681a5df 100644
--- a/src/node_native_module_env.h
+++ b/src/node_native_module_env.h
@@ -24,6 +24,17 @@ class NativeModuleEnv {
const char* id,
std::vector<v8::Local<v8::String>>* parameters,
Environment* optional_env);
+ // Run a script with JS source bundled inside the binary as if it's wrapped
+ // in a function called with a null receiver and arguments specified in C++.
+ // The returned value is empty if an exception is encountered.
+ // JS code run with this method can assume that their top-level
+ // declarations won't affect the global scope.
+ static v8::MaybeLocal<v8::Value> CompileAndCall(
+ v8::Local<v8::Context> context,
+ const char* id,
+ std::vector<v8::Local<v8::String>>* parameters,
+ std::vector<v8::Local<v8::Value>>* arguments,
+ Environment* optional_env);
static v8::Local<v8::Object> GetSourceObject(v8::Local<v8::Context> context);
// Returns config.gypi as a JSON string

Просмотреть файл

@ -0,0 +1,19 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <sattard@slack-corp.com>
Date: Mon, 15 Jul 2019 17:45:02 -0700
Subject: chore: read _noBrowserGlobals from global not process
diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js
index 6f096ff3abce7d4b08a174a159217a9ac012f2b2..48c430e966e449397475887b4a65b9aea9021924 100644
--- a/lib/internal/bootstrap/node.js
+++ b/lib/internal/bootstrap/node.js
@@ -168,7 +168,7 @@ const {
queueMicrotask
} = require('internal/process/task_queues');
-if (!process._noBrowserGlobals) {
+if (!global._noBrowserGlobals) {
// Override global console from the one provided by the VM
// to the one implemented by Node.js
// https://console.spec.whatwg.org/#console-namespace

Просмотреть файл

@ -0,0 +1,19 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <sattard@slack-corp.com>
Date: Mon, 15 Jul 2019 11:11:52 -0700
Subject: chore: remove sysinfo-memory from build files
Refs: https://github.com/libuv/libuv/commit/3a1be725326bfe637355c461bd77993c0fda2173
diff --git a/deps/uv/BUILD.gn b/deps/uv/BUILD.gn
index 7370980c52ea03ca02eae3488930432f1857c6fb..4674bdd48b4bfc9b7152377b8cd0984d1cf42562 100644
--- a/deps/uv/BUILD.gn
+++ b/deps/uv/BUILD.gn
@@ -170,7 +170,6 @@ static_library("uv") {
"src/unix/linux-syscalls.h",
"src/unix/procfs-exepath.c",
"src/unix/sysinfo-loadavg.c",
- "src/unix/sysinfo-memory.c",
]
libs += [
"dl",

Просмотреть файл

@ -0,0 +1,91 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Wed, 3 Jul 2019 09:29:26 -0700
Subject: chore: remove unused private RuntimeAgent member env
Removed in https://github.com/nodejs/node/pull/28036; this patch can
be removed when we update to v12.5.0
diff --git a/filenames.json b/filenames.json
index edb0b215088118f567c5ad5e5969d1eb5ef661a3..873fff0fac775b2a1276d6dff493146e5cd5ea2d 100644
--- a/filenames.json
+++ b/filenames.json
@@ -307,6 +307,7 @@
"src/node_env_var.cc",
"src/node_errors.cc",
"src/node_file.cc",
+ "src/node_snapshot_stub.cc",
"src/node_http_parser_llhttp.cc",
"src/node_http_parser_traditional.cc",
"src/node_http2.cc",
diff --git a/src/inspector/BUILD.gn b/src/inspector/BUILD.gn
index 48ad85e895b6111223119fafa57c13ba75cdbeae..ebe2c7f11a210817294e1fc1da02e2ae60244b9b 100644
--- a/src/inspector/BUILD.gn
+++ b/src/inspector/BUILD.gn
@@ -10,6 +10,8 @@ _protocol_generated = [
"protocol/NodeWorker.h",
"protocol/NodeTracing.cpp",
"protocol/NodeTracing.h",
+ "protocol/NodeRuntime.cpp",
+ "protocol/NodeRuntime.h"
]
# These are from node_protocol_config.json
@@ -41,6 +43,8 @@ source_set("inspector") {
"worker_agent.h",
"worker_inspector.cc",
"worker_inspector.h",
+ "runtime_agent.cc",
+ "runtime_agent.h",
]
sources += rebase_path(_protocol_generated,
".",
diff --git a/src/inspector/runtime_agent.cc b/src/inspector/runtime_agent.cc
index 4056140e70349377105ca190e54fbe61b489004f..037a77dbb9d044f2ada1191729599c72ea730687 100644
--- a/src/inspector/runtime_agent.cc
+++ b/src/inspector/runtime_agent.cc
@@ -7,8 +7,8 @@ namespace node {
namespace inspector {
namespace protocol {
-RuntimeAgent::RuntimeAgent(Environment* env)
- : notify_when_waiting_for_disconnect_(false), env_(env) {}
+RuntimeAgent::RuntimeAgent()
+ : notify_when_waiting_for_disconnect_(false) {}
void RuntimeAgent::Wire(UberDispatcher* dispatcher) {
frontend_ = std::make_unique<NodeRuntime::Frontend>(dispatcher->channel());
diff --git a/src/inspector/runtime_agent.h b/src/inspector/runtime_agent.h
index 63fc2a897caf21e7bf6987fff07d0e6413fc31fa..a408f9a438a339a8df2a5f5b9b9ac7d228948975 100644
--- a/src/inspector/runtime_agent.h
+++ b/src/inspector/runtime_agent.h
@@ -12,7 +12,7 @@ namespace protocol {
class RuntimeAgent : public NodeRuntime::Backend {
public:
- explicit RuntimeAgent(Environment* env);
+ explicit RuntimeAgent();
void Wire(UberDispatcher* dispatcher);
@@ -23,7 +23,6 @@ class RuntimeAgent : public NodeRuntime::Backend {
private:
std::shared_ptr<NodeRuntime::Frontend> frontend_;
bool notify_when_waiting_for_disconnect_;
- Environment* env_;
};
} // namespace protocol
} // namespace inspector
diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc
index b208fad547fb5af9a1ff3988428e205a2a9ef39f..674ad4611a400de1e8f53fcb21214cb9f8de4442 100644
--- a/src/inspector_agent.cc
+++ b/src/inspector_agent.cc
@@ -239,7 +239,7 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel,
tracing_agent_->Wire(node_dispatcher_.get());
worker_agent_ = std::make_unique<protocol::WorkerAgent>(worker_manager);
worker_agent_->Wire(node_dispatcher_.get());
- runtime_agent_ = std::make_unique<protocol::RuntimeAgent>(env);
+ runtime_agent_ = std::make_unique<protocol::RuntimeAgent>();
runtime_agent_->Wire(node_dispatcher_.get());
}

Просмотреть файл

@ -0,0 +1,141 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Fri, 21 Jun 2019 10:23:11 -0700
Subject: chore: update GN files for file movement
diff --git a/BUILD.gn b/BUILD.gn
index b5912d4d671db27761be4c6283ed5e21818c5b04..c722975a4bc82b46192b0e72f4995fce243fa5bf 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -78,14 +78,14 @@ chdir_action("node_js2c") {
macro_inputs = []
if (!node_use_dtrace && !node_use_etw) {
- macro_inputs += [ "src/notrace_macros.py" ]
+ macro_inputs += [ "tools/js2c_macros/notrace_macros.py" ]
}
if (node_debug_lib) {
- macro_inputs += [ "tools/nodcheck_macros.py" ]
+ macro_inputs += [ "tools/js2c_macros/nodcheck_macros.py" ]
} else {
- macro_inputs += [ "tools/dcheck_macros.py" ]
+ macro_inputs += [ "tools/js2c_macros/dcheck_macros.py" ]
}
- macro_inputs += [ "tools/check_macros.py" ]
+ macro_inputs += [ "tools/js2c_macros/check_macros.py" ]
config_gypi = [ "$target_gen_dir/config.gypi" ]
diff --git a/filenames.json b/filenames.json
index 86d89280e74d7365ab2782517fb779fc072bf0bf..edb0b215088118f567c5ad5e5969d1eb5ef661a3 100644
--- a/filenames.json
+++ b/filenames.json
@@ -67,11 +67,11 @@
}
],
"library_files": [
- "lib/internal/bootstrap/primordials.js",
- "lib/internal/bootstrap/cache.js",
+ "lib/internal/bootstrap/environment.js",
"lib/internal/bootstrap/loaders.js",
"lib/internal/bootstrap/node.js",
"lib/internal/bootstrap/pre_execution.js",
+ "lib/internal/per_context/primordials.js",
"lib/internal/per_context/setup.js",
"lib/internal/per_context/domexception.js",
"lib/async_hooks.js",
@@ -210,7 +210,6 @@
"lib/internal/process/worker_thread_only.js",
"lib/internal/process/report.js",
"lib/internal/process/task_queues.js",
- "lib/internal/profiler.js",
"lib/internal/querystring.js",
"lib/internal/readline.js",
"lib/internal/repl.js",
@@ -264,9 +263,16 @@
"deps/node-inspect/lib/internal/inspect_client.js",
"deps/node-inspect/lib/internal/inspect_repl.js",
"deps/acorn/acorn/dist/acorn.js",
- "deps/acorn/acorn-walk/dist/walk.js"
+ "deps/acorn/acorn-walk/dist/walk.js",
+ "deps/acorn-plugins/acorn-bigint/index.js",
+ "deps/acorn-plugins/acorn-class-fields/index.js",
+ "deps/acorn-plugins/acorn-numeric-separator/index.js",
+ "deps/acorn-plugins/acorn-private-class-elements/index.js",
+ "deps/acorn-plugins/acorn-private-methods/index.js",
+ "deps/acorn-plugins/acorn-static-class-features/index.js"
],
"node_sources": [
+ "src/api/async_resource.cc",
"src/api/callback.cc",
"src/api/encoding.cc",
"src/api/environment.cc",
@@ -305,9 +311,11 @@
"src/node_http_parser_traditional.cc",
"src/node_http2.cc",
"src/node_i18n.cc",
+ "src/node_main_instance.cc",
"src/node_messaging.cc",
"src/node_metadata.cc",
"src/node_native_module.cc",
+ "src/node_native_module_env.cc",
"src/node_options.cc",
"src/node_os.cc",
"src/node_perf.cc",
@@ -383,16 +391,17 @@
"src/node_http2_state.h",
"src/node_i18n.h",
"src/node_internals.h",
+ "src/node_main_instance.h",
"src/node_messaging.h",
"src/node_metadata.h",
"src/node_mutex.h",
"src/node_native_module.h",
+ "src/node_native_module_env.h",
"src/node_object_wrap.h",
"src/node_options.h",
"src/node_options-inl.h",
"src/node_perf.h",
"src/node_perf_common.h",
- "src/node_persistent.h",
"src/node_platform.h",
"src/node_process.h",
"src/node_revert.h",
diff --git a/src/inspector/BUILD.gn b/src/inspector/BUILD.gn
index 0e1a5a22315989d5b0b4b6462330b3d693a43228..ebf5e610d675e53ad4af40e92d5217995ed8f577 100644
--- a/src/inspector/BUILD.gn
+++ b/src/inspector/BUILD.gn
@@ -69,9 +69,10 @@ action("protocol_generated_sources") {
inputs = [
"$target_gen_dir/node_protocol_config.json",
"$target_gen_dir/node_protocol.json",
+ "$inspector_protocol_dir/lib/base_string_adapter_cc.template",
+ "$inspector_protocol_dir/lib/base_string_adapter_h.template",
"$inspector_protocol_dir/lib/Allocator_h.template",
"$inspector_protocol_dir/lib/Array_h.template",
- "$inspector_protocol_dir/lib/Collections_h.template",
"$inspector_protocol_dir/lib/DispatcherBase_cpp.template",
"$inspector_protocol_dir/lib/DispatcherBase_h.template",
"$inspector_protocol_dir/lib/ErrorSupport_cpp.template",
diff --git a/tools/js2c.py b/tools/js2c.py
index 3e6ad7d5e12888e26a2b4eaa2eff7e2421b630f7..87cca4eaf7c909e1f871287d7f019f701a05dd0f 100755
--- a/tools/js2c.py
+++ b/tools/js2c.py
@@ -284,14 +284,14 @@ def JS2C(source_files, target):
for filename in source_files['.js']:
AddModule(filename, consts, macros, definitions, initializers)
# Electron: Expose fs module without asar support.
- if name == 'fs.js':
+ if filename == 'fs.js':
# Node's 'fs' and 'internal/fs/streams' have a lazy-loaded circular
# dependency. So to expose the unmodified Node 'fs' functionality here,
# we have to copy both 'fs' *and* 'internal/fs/streams' and modify the
# copies to depend on each other instead of on our asarified 'fs' code.
# See https://github.com/electron/electron/pull/16028 for more.
AddModule('original-fs', lines.replace("require('internal/fs/streams')", "require('original-fs/streams')"))
- elif name == 'internal/fs/streams.js':
+ elif filename == 'internal/fs/streams.js':
AddModule('original-fs/streams', lines.replace("require('fs')", "require('original-fs')"))
config_def, config_size = handle_config_gypi(source_files['config.gypi'])

Просмотреть файл

@ -0,0 +1,19 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jeremy Apthorp <nornagon@nornagon.net>
Date: Tue, 2 Oct 2018 17:09:15 -0700
Subject: export Environment::kNodeContextTagPtr
diff --git a/src/env.h b/src/env.h
index 0c6dbe3c8f581f92fc9f437cb340cfc16d509c1e..b97d024a0e8396ebd21b96bd7f1a9473abfefe9b 100644
--- a/src/env.h
+++ b/src/env.h
@@ -1245,7 +1245,7 @@ class Environment : public MemoryRetainer {
uint64_t thread_id_;
std::unordered_set<worker::Worker*> sub_worker_contexts_;
- static void* const kNodeContextTagPtr;
+ NODE_EXTERN static void* const kNodeContextTagPtr;
static int const kNodeContextTag;
#if HAVE_INSPECTOR

Просмотреть файл

@ -0,0 +1,22 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cheng Zhao <zcbenz@gmail.com>
Date: Sun, 27 Mar 2016 14:43:14 +0900
Subject: Export NativeModule
This is used by atom for doing module compile cache.
(cherry picked from commit 83b45fddb9a36c1376f7a2b5c70717e37b6f0133)
diff --git a/lib/internal/bootstrap/loaders.js b/lib/internal/bootstrap/loaders.js
index bf63de07613b4d19d95607f404139e587319f11d..b99858fa9df3d817fb7a4614366154e4fbc560c8 100644
--- a/lib/internal/bootstrap/loaders.js
+++ b/lib/internal/bootstrap/loaders.js
@@ -168,6 +168,8 @@ NativeModule.exposeInternals = function() {
}
};
+process.NativeModule = NativeModule;
+
const {
moduleIds,
compileFunction

Просмотреть файл

@ -0,0 +1,23 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Thiago de Arruda <tpadilha84@gmail.com>
Date: Mon, 6 Mar 2017 10:42:34 -0300
Subject: Expose `get_builtin_module` function
This is a requirement for electron/electron#8815, which exposes some builtin
modules to sandboxed renderers.
(cherry picked from commit 4c058a6cb5331eef1c7f51c042dd074a2d4f9234)
diff --git a/src/node_binding.h b/src/node_binding.h
index dd94fab36a0e8fcb453ba82091f6284e8193c00d..b2aa45b7e85127f645f43d5fce0050fd488f2668 100644
--- a/src/node_binding.h
+++ b/src/node_binding.h
@@ -93,6 +93,8 @@ void GetInternalBinding(const v8::FunctionCallbackInfo<v8::Value>& args);
void GetLinkedBinding(const v8::FunctionCallbackInfo<v8::Value>& args);
void DLOpen(const v8::FunctionCallbackInfo<v8::Value>& args);
+NODE_EXTERN node_module* get_linked_module(const char *name);
+
} // namespace binding
} // namespace node

Просмотреть файл

@ -0,0 +1,121 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Thu, 13 Sep 2018 08:42:22 -0700
Subject: feat: add flags for low-level hooks and exceptions
This commit adds two new exposed methods to `node.cc`, `InitGeneric` and
`LoadEnvironmentGeneric` that allow for control of which mode Node
should run, which i have called `standalone_mode` and
`upstream_node_mode`. Default behavior of `Init` and `LoadEnvironment`
remain the same.
We have 3 modes when running Node in Electron:
1. In the main process, we want to have a full Node environment, but
with signal handlers and other low level things disabled
2. In renderer process, we want Node to reuse the web page's context
3. In `ELECTRON_RUN_AS_NODE`, we want Node to run as it runs officially
by default
For modes 1 and 3, we have Node create a new V8 context with a Node
Environment on it. However, for mode 2, since the V8 context is created
by blink for web frames and web workers we make Node create the Node
Environment on the V8 context of blink, so no new V8 context is created.
As a result, a renderer process may have multiple Node Environments in it.
diff --git a/src/env.cc b/src/env.cc
index bc43fac963bbc334ccf5c5e3895e9dbd568bcdb4..a942a880e93b11cbc0cfb3c86d3950bd7f261e77 100644
--- a/src/env.cc
+++ b/src/env.cc
@@ -318,6 +318,12 @@ Environment::Environment(IsolateData* isolate_data,
if (options_->no_force_async_hooks_checks) {
async_hooks_.no_force_checks();
}
+
+ // TODO(addaleax): the per-isolate state should not be controlled by
+ // a single Environment.
+ if (g_standalone_mode) {
+ isolate()->SetPromiseRejectCallback(task_queue::PromiseRejectCallback);
+ }
}
CompileFnEntry::CompileFnEntry(Environment* env, uint32_t id)
diff --git a/src/node.cc b/src/node.cc
index f8b6fa6f33b67394ca68acabd4df0c64653083fe..eff0be6fef1274cd4210811bdc377702ca70b2a2 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -27,6 +27,7 @@
#include "env-inl.h"
#include "memory_tracker-inl.h"
#include "node_binding.h"
+#include "node_errors.h"
#include "node_internals.h"
#include "node_main_instance.h"
#include "node_metadata.h"
@@ -131,6 +132,9 @@ using v8::Undefined;
using v8::V8;
using v8::Value;
+bool g_standalone_mode = true;
+bool g_upstream_node_mode = true;
+
namespace per_process {
// node_revert.h
@@ -224,6 +228,12 @@ MaybeLocal<Value> ExecuteBootstrapper(Environment* env,
MaybeLocal<Value> RunBootstrapping(Environment* env) {
CHECK(!env->has_run_bootstrapping_code());
+ if (g_standalone_mode) {
+ env->isolate()->AddMessageListener(errors::PerIsolateMessageListener);
+ }
+ if (g_upstream_node_mode) {
+ env->isolate()->SetFatalErrorHandler(OnFatalError);
+ }
EscapableHandleScope scope(env->isolate());
Isolate* isolate = env->isolate();
@@ -618,7 +628,9 @@ int InitializeNodeWithArgs(std::vector<std::string>* argv,
binding::RegisterBuiltinModules();
// Make inherited handles noninheritable.
- uv_disable_stdio_inheritance();
+ if (g_upstream_node_mode) {
+ uv_disable_stdio_inheritance();
+ }
#ifdef NODE_REPORT
// Cache the original command line to be
@@ -720,6 +732,9 @@ int InitializeNodeWithArgs(std::vector<std::string>* argv,
}
#endif
+ if (g_upstream_node_mode) {
+ // NOTE(jeremy): indentation is intentionally wrong here, to ease rebasing.
+
const int exit_code = ProcessGlobalArgs(argv, exec_argv, errors, false);
if (exit_code != 0) return exit_code;
@@ -742,6 +757,8 @@ int InitializeNodeWithArgs(std::vector<std::string>* argv,
per_process::metadata.versions.InitializeIntlVersions();
#endif
+ } // g_upstream_node_mode
+
NativeModuleEnv::InitializeCodeCache();
// We should set node_is_initialized here instead of in node::Start,
diff --git a/src/node.h b/src/node.h
index 5098dc9c7e77df62b90e4332c6695dfb48b430a0..9df33dfb47e591728c9502fea8152e4344b2b275 100644
--- a/src/node.h
+++ b/src/node.h
@@ -203,6 +203,9 @@ namespace node {
class IsolateData;
class Environment;
+// Whether node should open some low level hooks.
+NODE_EXTERN extern bool g_standalone_mode;
+NODE_EXTERN extern bool g_upstream_node_mode;
// TODO(addaleax): Officially deprecate this and replace it with something
// better suited for a public embedder API.

Просмотреть файл

@ -0,0 +1,19 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Tue, 2 Oct 2018 11:39:58 -0700
Subject: feat: add new built_with_electron variable to config.gypi
diff --git a/tools/generate_config_gypi.py b/tools/generate_config_gypi.py
index 01f62d4ae6e3b9d539444e3dff069f0011353caa..d8b279f590c115108d5dca879747de7b0c9f1934 100644
--- a/tools/generate_config_gypi.py
+++ b/tools/generate_config_gypi.py
@@ -5,7 +5,7 @@ import sys
def main(args):
out = args[0]
with open(out, 'w') as f:
- f.write("{'variables':{}}\n")
+ f.write("{'variables':{'built_with_electron': 1}}\n")
if __name__ == '__main__':
main(sys.argv[1:])

Просмотреть файл

@ -0,0 +1,27 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cheng Zhao <zcbenz@gmail.com>
Date: Thu, 11 Apr 2019 17:16:13 +0900
Subject: feat: add original-fs module
diff --git a/tools/js2c.py b/tools/js2c.py
index 68152c499ce610d759b5abd659340957efb864d6..3e6ad7d5e12888e26a2b4eaa2eff7e2421b630f7 100755
--- a/tools/js2c.py
+++ b/tools/js2c.py
@@ -283,6 +283,16 @@ def JS2C(source_files, target):
for filename in source_files['.js']:
AddModule(filename, consts, macros, definitions, initializers)
+ # Electron: Expose fs module without asar support.
+ if name == 'fs.js':
+ # Node's 'fs' and 'internal/fs/streams' have a lazy-loaded circular
+ # dependency. So to expose the unmodified Node 'fs' functionality here,
+ # we have to copy both 'fs' *and* 'internal/fs/streams' and modify the
+ # copies to depend on each other instead of on our asarified 'fs' code.
+ # See https://github.com/electron/electron/pull/16028 for more.
+ AddModule('original-fs', lines.replace("require('internal/fs/streams')", "require('original-fs/streams')"))
+ elif name == 'internal/fs/streams.js':
+ AddModule('original-fs/streams', lines.replace("require('fs')", "require('original-fs')"))
config_def, config_size = handle_config_gypi(source_files['config.gypi'])
definitions.append(config_def)

Просмотреть файл

@ -0,0 +1,59 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Mon, 30 Jul 2018 10:34:54 -0700
Subject: feat: add uv_loop watcher_queue code
Electron's Node Integration works by listening to Node's backend file descriptor in a separate thread; when an event is ready the backend file descriptor will trigger a new event for it, and the main thread will then iterate the libuv loop. For certain operations (ex. adding a timeout task) the backend file descriptor isn't informed, & as a result the main thread doesn't know it needs to iterate the libuv loop so the timeout task will never execute until something else trigger a new event. This commit should be removed when https://github.com/libuv/libuv/pull/1921 is merged
diff --git a/deps/uv/include/uv.h b/deps/uv/include/uv.h
index f97801cec2f41b104fae591277ffbb94c3b2f299..da648b3efd5948843c485d65035ae29c79eebc69 100644
--- a/deps/uv/include/uv.h
+++ b/deps/uv/include/uv.h
@@ -1657,6 +1657,8 @@ union uv_any_req {
struct uv_loop_s {
/* User data - use this for whatever. */
void* data;
+ /* Callback when loop's watcher queue updates. */
+ void (*on_watcher_queue_updated)(uv_loop_t*);
/* Loop reference counting. */
unsigned int active_handles;
void* handle_queue[2];
diff --git a/deps/uv/src/unix/core.c b/deps/uv/src/unix/core.c
index 3bada900ebdc41c3acc823b9e4f74306afe2449f..1397d2cff770c732c18aba96ccfb6aaab2e36c17 100644
--- a/deps/uv/src/unix/core.c
+++ b/deps/uv/src/unix/core.c
@@ -865,8 +865,11 @@ void uv__io_start(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
return;
#endif
- if (QUEUE_EMPTY(&w->watcher_queue))
+ if (QUEUE_EMPTY(&w->watcher_queue)) {
QUEUE_INSERT_TAIL(&loop->watcher_queue, &w->watcher_queue);
+ if (loop->on_watcher_queue_updated)
+ loop->on_watcher_queue_updated(loop);
+ }
if (loop->watchers[w->fd] == NULL) {
loop->watchers[w->fd] = w;
@@ -902,8 +905,11 @@ void uv__io_stop(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
w->events = 0;
}
}
- else if (QUEUE_EMPTY(&w->watcher_queue))
+ else if (QUEUE_EMPTY(&w->watcher_queue)) {
QUEUE_INSERT_TAIL(&loop->watcher_queue, &w->watcher_queue);
+ if (loop->on_watcher_queue_updated)
+ loop->on_watcher_queue_updated(loop);
+ }
}
@@ -920,6 +926,8 @@ void uv__io_close(uv_loop_t* loop, uv__io_t* w) {
void uv__io_feed(uv_loop_t* loop, uv__io_t* w) {
if (QUEUE_EMPTY(&w->pending_queue))
QUEUE_INSERT_TAIL(&loop->pending_queue, &w->pending_queue);
+ if (loop->on_watcher_queue_updated)
+ loop->on_watcher_queue_updated(loop);
}

Просмотреть файл

@ -0,0 +1,42 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Thu, 13 Sep 2018 08:56:07 -0700
Subject: feat: initialize asar support
diff --git a/lib/internal/bootstrap/loaders.js b/lib/internal/bootstrap/loaders.js
index 7a98e4c96c87d4738829aadf1969ee90eda3876a..bf63de07613b4d19d95607f404139e587319f11d 100644
--- a/lib/internal/bootstrap/loaders.js
+++ b/lib/internal/bootstrap/loaders.js
@@ -189,6 +189,8 @@ function nativeModuleRequire(id) {
return mod.compile();
}
+NativeModule.require = nativeModuleRequire
+
NativeModule.exists = function(id) {
return NativeModule.map.has(id);
};
diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js
index 24d25158f9e8adf5f2265504a21daa5ed96f517a..2351268eae27af7ae759dccb599c071e146ece71 100644
--- a/lib/internal/bootstrap/pre_execution.js
+++ b/lib/internal/bootstrap/pre_execution.js
@@ -51,6 +51,7 @@ function prepareMainThreadExecution(expandArgv1 = false) {
initializeCJSLoader();
initializeESMLoader();
loadPreloadModules();
+ setupAsarSupport();
}
function patchProcessObject(expandArgv1) {
@@ -393,6 +394,10 @@ function loadPreloadModules() {
}
}
+function setupAsarSupport() {
+ process._linkedBinding('atom_common_asar').initAsarSupport(require);
+}
+
module.exports = {
patchProcessObject,
setupCoverageHooks,

Просмотреть файл

@ -0,0 +1,36 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jeremy Apthorp <nornagon@nornagon.net>
Date: Wed, 19 Sep 2018 12:20:44 -0700
Subject: fix: add default values for 'enable_lto' and 'build_v8_with_gn' in
common.gypi
common.gypi is a file that's included in the node header bundle, despite
the fact that we do not build node with gyp.
diff --git a/common.gypi b/common.gypi
index 223043e55194c32493ccb9913295ec65d09a270c..bb60a045c1132bf3a16d0b773ba34e5e9efb0f0c 100644
--- a/common.gypi
+++ b/common.gypi
@@ -72,6 +72,22 @@
##### end V8 defaults #####
+ # When building native modules using 'npm install' with the system npm,
+ # node-gyp uses the `process.config` of the system npm to fill config.gypi.
+ # If the system npm is not as recent as Electron's node headers, which is
+ # likely, these variables will be missing from that config.gypi, and as a
+ # result, node-gyp will fail when building the native module with an error
+ # like:
+ #
+ # gyp: name 'enable_lto' is not defined while evaluating condition
+ # 'enable_lto=="true"' in binding.gyp while trying to load binding.gyp
+ #
+ # We set default values here to avoid that error message, even though these
+ # aren't technically accurate, because most native modules don't depend on
+ # these values being accurate.
+ 'build_v8_with_gn': 'false',
+ 'enable_lto%': 'false',
+
'conditions': [
['target_arch=="arm64"', {
# Disabled pending https://github.com/nodejs/node/issues/23913.

Просмотреть файл

@ -0,0 +1,65 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Mon, 30 Jul 2018 15:18:11 -0700
Subject: fix: build and expose inspector agent
Node inspector initialization happens in a different start-up function in node.cc, which we don't call in Electron. This allows for us to use the inspector agent in electron/atom/browser/node_debugger.cc
diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc
index 8a12c2dddf7493a1c2a5f5deff7114d35ffa4f76..b208fad547fb5af9a1ff3988428e205a2a9ef39f 100644
--- a/src/inspector_agent.cc
+++ b/src/inspector_agent.cc
@@ -217,7 +217,7 @@ const int CONTEXT_GROUP_ID = 1;
std::string GetWorkerLabel(node::Environment* env) {
std::ostringstream result;
- result << "Worker[" << env->thread_id() << "]";
+ result << "Electron Worker[" << env->thread_id() << "]";
return result.str();
}
@@ -461,7 +461,7 @@ class NodeInspectorClient : public V8InspectorClient {
client_ = V8Inspector::create(env->isolate(), this);
// TODO(bnoordhuis) Make name configurable from src/node.cc.
std::string name =
- is_main_ ? GetHumanReadableProcessName() : GetWorkerLabel(env);
+ is_main_ ? "Electron Main Context" : GetWorkerLabel(env);
ContextInfo info(name);
info.is_default = true;
contextCreated(env->context(), info);
diff --git a/src/inspector_agent.h b/src/inspector_agent.h
index 1c2bde0da73e846159843a8c32879f227a8f0dd7..133e2187dcd6fed9cb3a2d13eb646ef5e9851e01 100644
--- a/src/inspector_agent.h
+++ b/src/inspector_agent.h
@@ -6,7 +6,9 @@
#error("This header can only be used when inspector is enabled")
#endif
+#include "node.h"
#include "node_options.h"
+#include "node_platform.h"
#include "v8.h"
#include <cstddef>
@@ -40,7 +42,7 @@ class InspectorSessionDelegate {
= 0;
};
-class Agent {
+class NODE_EXTERN Agent {
public:
explicit Agent(node::Environment* env);
~Agent();
diff --git a/src/inspector_io.cc b/src/inspector_io.cc
index 223e3592a1fc0901575153f2ec000dcaac37ea1f..d500d15b07c249f973c41967b5510f69429117b7 100644
--- a/src/inspector_io.cc
+++ b/src/inspector_io.cc
@@ -13,6 +13,8 @@
#include "util-inl.h"
#include "zlib.h"
+#include "libplatform/libplatform.h"
+
#include <deque>
#include <cstring>
#include <vector>

Просмотреть файл

@ -0,0 +1,54 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cheng Zhao <zcbenz@gmail.com>
Date: Fri, 29 Mar 2019 17:17:30 +0900
Subject: fix: do not define DebugOptions's constructors in header
The e3ca89ef49 changed NODE_EXTERN to always expose symbols for
DebugOptions, and since the constructors of DebugOptions are defined in
header, the compiler would end up generating no constructor
implementations for DebugOptions.
Which means we would encounter crash when constructors of DebugOptions
is called.
By putting the definitions of constructors into the implementation file,
we can avoid this problem.
diff --git a/src/node_options.cc b/src/node_options.cc
index 79e69a031dfc6331e0022b6354c909a36ae51c51..a85b650d2e75b5c7dd8018d9af76ac88d0d741aa 100644
--- a/src/node_options.cc
+++ b/src/node_options.cc
@@ -26,6 +26,12 @@ Mutex cli_options_mutex;
std::shared_ptr<PerProcessOptions> cli_options{new PerProcessOptions()};
} // namespace per_process
+DebugOptions::DebugOptions() = default;
+DebugOptions::DebugOptions(const DebugOptions&) = default;
+DebugOptions::DebugOptions(DebugOptions&&) = default;
+DebugOptions& DebugOptions::operator=(const DebugOptions&) = default;
+DebugOptions& DebugOptions::operator=(DebugOptions&&) = default;
+
void DebugOptions::CheckOptions(std::vector<std::string>* errors) {
#if !NODE_USE_V8_PLATFORM
if (inspector_enabled) {
diff --git a/src/node_options.h b/src/node_options.h
index ddc18552611724e7e995862964dff616b1b9b66d..c79b08ad09c183ad24faf864fb8ba4692b527c70 100644
--- a/src/node_options.h
+++ b/src/node_options.h
@@ -56,11 +56,11 @@ class Options {
// per-Isolate, rather than per-Environment.
class NODE_EXTERN DebugOptions : public Options {
public:
- DebugOptions() = default;
- DebugOptions(const DebugOptions&) = default;
- DebugOptions& operator=(const DebugOptions&) = default;
- DebugOptions(DebugOptions&&) = default;
- DebugOptions& operator=(DebugOptions&&) = default;
+ DebugOptions();
+ DebugOptions(const DebugOptions&);
+ DebugOptions& operator=(const DebugOptions&);
+ DebugOptions(DebugOptions&&);
+ DebugOptions& operator=(DebugOptions&&);
// --inspect
bool inspector_enabled = false;

Просмотреть файл

@ -0,0 +1,21 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Mon, 30 Jul 2018 10:23:05 -0700
Subject: fix: don't create console window when creating process
This commit prevents console windows from being spawned when creating processes to better align with what Windows users expect and should be removed when upgrading to a version that includes https://github.com/nodejs/node/pull/21316
diff --git a/deps/uv/src/win/process.c b/deps/uv/src/win/process.c
index f9c53de0af007961b0d269651d368fd83717976a..fa1a76a2e6626e15bdd0681626fc82c9ca6907fe 100644
--- a/deps/uv/src/win/process.c
+++ b/deps/uv/src/win/process.c
@@ -1099,6 +1099,9 @@ int uv_spawn(uv_loop_t* loop,
process_flags |= DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP;
}
+ /* Don't create console window. */
+ process_flags |= CREATE_NO_WINDOW;
+
if (!CreateProcessW(application_path,
arguments,
NULL,

Просмотреть файл

@ -0,0 +1,20 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jeremy Apthorp <jeremya@chromium.org>
Date: Wed, 3 Jul 2019 09:58:01 -0700
Subject: fix: don't define BUILDING_V8_SHARED in component builds (#109)
diff --git a/BUILD.gn b/BUILD.gn
index 77b2ed2978682c1a171346339ded5f2638c27fd9..f27c13b312a60d9b5c7ea0948b347ab0936ab3f8 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -153,9 +153,6 @@ config("node_internal_config") {
}
if (is_component_build) {
defines += [
- "BUILDING_V8_SHARED",
- "BUILDING_V8_PLATFORM_SHARED",
- "BUILDING_V8_BASE_SHARED",
"NODE_SHARED_MODE",
]
}

Просмотреть файл

@ -0,0 +1,19 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <sattard@slack-corp.com>
Date: Mon, 15 Jul 2019 17:44:47 -0700
Subject: fix: ensure js2c maps internal-fs/streams
diff --git a/tools/js2c.py b/tools/js2c.py
index 4e63ceefe1ff41d2105c3d71980c4f5f5ad11a30..27c9ca57c3ad6188282d43ce1efdb53efd1161bc 100755
--- a/tools/js2c.py
+++ b/tools/js2c.py
@@ -293,7 +293,7 @@ def JS2C(source_files, target, only_js):
# copies to depend on each other instead of on our asarified 'fs' code.
# See https://github.com/electron/electron/pull/16028 for more.
AddModule('lib/original-fs.js', consts, macros, definitions, initializers, lambda _: ReadFile(filename).replace("require('internal/fs/streams')", "require('internal/original-fs/streams')"))
- elif filename == 'internal/fs/streams.js':
+ elif filename == 'lib/internal/fs/streams.js':
AddModule('lib/internal/original-fs/streams.js', consts, macros, definitions, initializers, lambda _: ReadFile(filename).replace("require('fs')", "require('original-fs')"))
config_size = 0

Просмотреть файл

@ -0,0 +1,56 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Nitish Sakhawalkar <nitsakh@icloud.com>
Date: Thu, 11 Apr 2019 11:50:49 -0700
Subject: fix: export DebugOptions
diff --git a/src/node_options.cc b/src/node_options.cc
index 35094d66323d551c1bd1ea4430441444b7210299..79e69a031dfc6331e0022b6354c909a36ae51c51 100644
--- a/src/node_options.cc
+++ b/src/node_options.cc
@@ -187,11 +187,6 @@ void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors) {
namespace options_parser {
-class DebugOptionsParser : public OptionsParser<DebugOptions> {
- public:
- DebugOptionsParser();
-};
-
class EnvironmentOptionsParser : public OptionsParser<EnvironmentOptions> {
public:
EnvironmentOptionsParser();
diff --git a/src/node_options.h b/src/node_options.h
index 174f5369854a6a2bfc11d03ab4f251fe74ea9c8f..ddc18552611724e7e995862964dff616b1b9b66d 100644
--- a/src/node_options.h
+++ b/src/node_options.h
@@ -54,7 +54,7 @@ class Options {
// to keep them separate since they are a group of options applying to a very
// specific part of Node. It might also make more sense for them to be
// per-Isolate, rather than per-Environment.
-class DebugOptions : public Options {
+class NODE_EXTERN DebugOptions : public Options {
public:
DebugOptions() = default;
DebugOptions(const DebugOptions&) = default;
@@ -227,7 +227,7 @@ class PerProcessOptions : public Options {
namespace options_parser {
-HostPort SplitHostPort(const std::string& arg,
+HostPort NODE_EXTERN SplitHostPort(const std::string& arg,
std::vector<std::string>* errors);
void GetOptions(const v8::FunctionCallbackInfo<v8::Value>& args);
@@ -420,6 +420,11 @@ class OptionsParser {
friend void GetOptions(const v8::FunctionCallbackInfo<v8::Value>& args);
};
+class NODE_EXTERN DebugOptionsParser : public OptionsParser<DebugOptions> {
+ public:
+ DebugOptionsParser();
+};
+
using StringVector = std::vector<std::string>;
template <class OptionsType, class = Options>
void Parse(

Просмотреть файл

@ -0,0 +1,31 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jeremy Apthorp <nornagon@nornagon.net>
Date: Thu, 11 Oct 2018 16:24:57 -0700
Subject: fix: export libuv symbols (#73)
Closes electron/electron#15075
diff --git a/deps/uv/BUILD.gn b/deps/uv/BUILD.gn
index b62fac6738ae74788faa6e5dcc705b81d8325ece..7370980c52ea03ca02eae3488930432f1857c6fb 100644
--- a/deps/uv/BUILD.gn
+++ b/deps/uv/BUILD.gn
@@ -29,6 +29,9 @@ static_library("uv") {
defines = []
+ # This only has an effect on Windows, where it will cause libuv's symbols to be exported in node.lib
+ defines += [ "BUILDING_UV_SHARED=1" ]
+
cflags_c = [
"-Wno-bitwise-op-parentheses",
"-Wno-implicit-function-declaration",
@@ -180,9 +183,4 @@ static_library("uv") {
"src/unix/kqueue.c",
]
}
- if (is_component_build && is_win) {
- defines += [
- "BUILDING_UV_SHARED=1",
- ]
- }
}

Просмотреть файл

@ -0,0 +1,50 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Nitish Sakhawalkar <nitsakh@icloud.com>
Date: Wed, 27 Mar 2019 14:17:15 -0700
Subject: fix: Export node::Abort and Assert
diff --git a/src/node_errors.cc b/src/node_errors.cc
index 603c9e415c3f546c621793afd13ee58bcc4280be..20098777e290bfa66dc430c08eaad78e4c232266 100644
--- a/src/node_errors.cc
+++ b/src/node_errors.cc
@@ -241,13 +241,13 @@ void AppendExceptionLine(Environment* env,
.FromMaybe(false));
}
-[[noreturn]] void Abort() {
+[[noreturn]] void NODE_EXTERN Abort() {
DumpBacktrace(stderr);
fflush(stderr);
ABORT_NO_BACKTRACE();
}
-[[noreturn]] void Assert(const AssertionInfo& info) {
+[[noreturn]] void NODE_EXTERN Assert(const AssertionInfo& info) {
char name[1024];
GetHumanReadableProcessName(&name);
diff --git a/src/util.h b/src/util.h
index a94e88f232fd3116fa842aed4d02a78fd0c54ffc..62ae0fe6e6beb77e456bff352246505531ec2005 100644
--- a/src/util.h
+++ b/src/util.h
@@ -24,6 +24,8 @@
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
+
+#include "node.h"
#include "v8.h"
#include <cassert>
@@ -103,8 +105,8 @@ struct AssertionInfo {
const char* message;
const char* function;
};
-[[noreturn]] void Assert(const AssertionInfo& info);
-[[noreturn]] void Abort();
+[[noreturn]] void NODE_EXTERN Assert(const AssertionInfo& info);
+[[noreturn]] void NODE_EXTERN Abort();
void DumpBacktrace(FILE* fp);
// Windows 8+ does not like abort() in Release mode

Просмотреть файл

@ -0,0 +1,20 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: deepak1556 <hop2deep@gmail.com>
Date: Sat, 6 Jan 2018 18:28:10 +0530
Subject: fix: expose InternalCallbackScope
This commit exposes InternalCallbackScope in order to allow us access to kAllowEmptyResource for usage https://github.com/electron/electron/blob/master/atom/common/api/atom_bindings.cc\#L108. We should look to accomplish this another way so we no longer need to do this, as in verbose mode the regular CallBack Scope doesn't swallow errors and so we can otherwise use it.
diff --git a/src/node_internals.h b/src/node_internals.h
index 21625e60232bbe586b312dc4928bcefdf507b229..9811c02d5438cd7008d3990f89b7161355e87cfc 100644
--- a/src/node_internals.h
+++ b/src/node_internals.h
@@ -197,7 +197,7 @@ v8::MaybeLocal<v8::Value> InternalMakeCallback(
v8::Local<v8::Value> argv[],
async_context asyncContext);
-class InternalCallbackScope {
+class NODE_EXTERN InternalCallbackScope {
public:
// Tell the constructor whether its `object` parameter may be empty or not.
enum ResourceExpectation { kRequireResource, kAllowEmptyResource };

Просмотреть файл

@ -0,0 +1,20 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Mon, 30 Jul 2018 13:08:34 -0700
Subject: fix: expose TraceEventHelper
Node required tracing controller to be initialized, otherwise a crash would occur. Changed in concert with https://github.com/electron/electron/commit/0e5b6f93000e4718c9e35332ddbd0f6b76cdd585\#diff-0cdfa12fff513e022fac830c6af9c19a
diff --git a/src/tracing/trace_event.h b/src/tracing/trace_event.h
index 590cb592fc054f90ffc85052985087db6c3c3463..4a398106d77e5e0f7c16448fa952c637833cfede 100644
--- a/src/tracing/trace_event.h
+++ b/src/tracing/trace_event.h
@@ -310,7 +310,7 @@ const int kZeroNumArgs = 0;
const decltype(nullptr) kGlobalScope = nullptr;
const uint64_t kNoId = 0;
-class TraceEventHelper {
+class NODE_EXTERN TraceEventHelper {
public:
static TracingController* GetTracingController();
static Agent* GetAgent();

Просмотреть файл

@ -0,0 +1,43 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <sattard@atlassian.com>
Date: Fri, 26 Oct 2018 15:35:13 +1100
Subject: fix: expose tracing::Agent and use tracing::TracingController instead
of v8::TracingController
diff --git a/src/api/environment.cc b/src/api/environment.cc
index eeeef7442d834ace51a6c6be11058d21e4995a99..bfc849d362a18bc7cd499584a439a1d29f0864f8 100644
--- a/src/api/environment.cc
+++ b/src/api/environment.cc
@@ -319,6 +319,10 @@ MultiIsolatePlatform* GetMainThreadMultiIsolatePlatform() {
return per_process::v8_platform.Platform();
}
+node::tracing::Agent* CreateAgent() {
+ return new node::tracing::Agent();
+}
+
MultiIsolatePlatform* CreatePlatform(
int thread_pool_size,
node::tracing::TracingController* tracing_controller) {
diff --git a/src/node.h b/src/node.h
index 9df33dfb47e591728c9502fea8152e4344b2b275..dca89e212c89df19d0b97d748e3649392fec000c 100644
--- a/src/node.h
+++ b/src/node.h
@@ -108,6 +108,7 @@ namespace node {
namespace tracing {
+class Agent;
class TracingController;
}
@@ -334,6 +335,8 @@ NODE_EXTERN Environment* GetCurrentEnvironment(v8::Local<v8::Context> context);
// it returns nullptr.
NODE_EXTERN MultiIsolatePlatform* GetMainThreadMultiIsolatePlatform();
+NODE_EXTERN node::tracing::Agent* CreateAgent();
+
NODE_EXTERN MultiIsolatePlatform* CreatePlatform(
int thread_pool_size,
node::tracing::TracingController* tracing_controller);

Просмотреть файл

@ -0,0 +1,41 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <sattard@slack-corp.com>
Date: Mon, 15 Jul 2019 14:20:10 -0700
Subject: fix: extern the NativeModuleEnv and options parser for debug builds
diff --git a/src/node_native_module_env.h b/src/node_native_module_env.h
index b91a5059cd1f19d87e5876c372f3ded60681a5df..f81cf8dfb892a8ddd9084c5d9477b17867cae82d 100644
--- a/src/node_native_module_env.h
+++ b/src/node_native_module_env.h
@@ -12,7 +12,7 @@ namespace native_module {
extern const bool has_code_cache;
-class NativeModuleEnv {
+class NODE_EXTERN NativeModuleEnv {
public:
static void Initialize(v8::Local<v8::Object> target,
v8::Local<v8::Value> unused,
diff --git a/src/node_options.h b/src/node_options.h
index c79b08ad09c183ad24faf864fb8ba4692b527c70..a116b2fdaad590c8999142d18b9b81dac67b5359 100644
--- a/src/node_options.h
+++ b/src/node_options.h
@@ -44,7 +44,7 @@ class HostPort {
int port_;
};
-class Options {
+class NODE_EXTERN Options {
public:
virtual void CheckOptions(std::vector<std::string>* errors) {}
virtual ~Options() = default;
@@ -427,7 +427,7 @@ class NODE_EXTERN DebugOptionsParser : public OptionsParser<DebugOptions> {
using StringVector = std::vector<std::string>;
template <class OptionsType, class = Options>
-void Parse(
+void NODE_EXTERN Parse(
StringVector* const args, StringVector* const exec_args,
StringVector* const v8_args, OptionsType* const options,
OptionEnvvarSettings required_env_settings, StringVector* const errors);

Просмотреть файл

@ -0,0 +1,95 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cheng Zhao <zcbenz@gmail.com>
Date: Fri, 29 Mar 2019 16:50:56 +0900
Subject: fix: key gen APIs are not available in BoringSSL
This will make Node's key pair generation APIs fail.
diff --git a/src/node_crypto.cc b/src/node_crypto.cc
index f232c9571ae5452996955b7bc149da663ee7d56a..4b6eccd7fe96d185c28def27ff3d0da3e26e950f 100644
--- a/src/node_crypto.cc
+++ b/src/node_crypto.cc
@@ -290,24 +290,14 @@ Maybe<bool> Decorate(Environment* env, Local<Object> obj,
V(BIO) \
V(PKCS7) \
V(X509V3) \
- V(PKCS12) \
V(RAND) \
- V(DSO) \
V(ENGINE) \
V(OCSP) \
V(UI) \
V(COMP) \
V(ECDSA) \
V(ECDH) \
- V(OSSL_STORE) \
- V(FIPS) \
- V(CMS) \
- V(TS) \
V(HMAC) \
- V(CT) \
- V(ASYNC) \
- V(KDF) \
- V(SM2) \
V(USER) \
#define V(name) case ERR_LIB_##name: lib = #name "_"; break;
@@ -2487,8 +2477,11 @@ void SSLWrap<Base>::GetEphemeralKeyInfo(
.Check();
break;
case EVP_PKEY_EC:
+ // FIXME(zcbenz): This is not available in BoringSSL.
+#if 0
case EVP_PKEY_X25519:
case EVP_PKEY_X448:
+#endif
{
const char* curve_name;
if (kid == EVP_PKEY_EC) {
@@ -3742,12 +3735,15 @@ Local<Value> KeyObject::GetAsymmetricKeyType() const {
return env()->crypto_ec_string();
case EVP_PKEY_ED25519:
return env()->crypto_ed25519_string();
+ // FIXME(zcbenz): This is not available in BoringSSL.
+#if 0
case EVP_PKEY_ED448:
return env()->crypto_ed448_string();
case EVP_PKEY_X25519:
return env()->crypto_x25519_string();
case EVP_PKEY_X448:
return env()->crypto_x448_string();
+#endif
default:
return Undefined(env()->isolate());
}
@@ -6196,6 +6192,8 @@ class DSAKeyPairGenerationConfig : public KeyPairGenerationConfig {
if (EVP_PKEY_paramgen_init(param_ctx.get()) <= 0)
return nullptr;
+ // FIXME(zcbenz): This is not available in BoringSSL.
+#if 0
if (EVP_PKEY_CTX_set_dsa_paramgen_bits(param_ctx.get(), modulus_bits_) <= 0)
return nullptr;
@@ -6215,6 +6213,8 @@ class DSAKeyPairGenerationConfig : public KeyPairGenerationConfig {
EVPKeyCtxPointer key_ctx(EVP_PKEY_CTX_new(params.get(), nullptr));
return key_ctx;
+#endif
+ return nullptr;
}
private:
@@ -6906,9 +6906,12 @@ void Initialize(Local<Object> target,
env->SetMethod(target, "generateKeyPairEC", GenerateKeyPairEC);
env->SetMethod(target, "generateKeyPairNid", GenerateKeyPairNid);
NODE_DEFINE_CONSTANT(target, EVP_PKEY_ED25519);
+ // FIXME(zcbenz): This is not available in BoringSSL.
+#if 0
NODE_DEFINE_CONSTANT(target, EVP_PKEY_ED448);
NODE_DEFINE_CONSTANT(target, EVP_PKEY_X25519);
NODE_DEFINE_CONSTANT(target, EVP_PKEY_X448);
+#endif
NODE_DEFINE_CONSTANT(target, OPENSSL_EC_NAMED_CURVE);
NODE_DEFINE_CONSTANT(target, OPENSSL_EC_EXPLICIT_CURVE);
NODE_DEFINE_CONSTANT(target, kKeyEncodingPKCS1);

Просмотреть файл

@ -0,0 +1,23 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cheng Zhao <zcbenz@gmail.com>
Date: Fri, 29 Mar 2019 16:21:42 +0900
Subject: fix: make it possible to change noBrowserGlobals at runtime
This is a temporary hack in responding to Node's change:
https://github.com/nodejs/node/pull/26228
We need to figure out a better solution.
diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js
index 8dee38a0e71698258bee7642f9b91c5c8b9060c2..1cdf79dfaa9aecc4ac3bcb05212514929b80603d 100644
--- a/lib/internal/bootstrap/node.js
+++ b/lib/internal/bootstrap/node.js
@@ -164,7 +164,7 @@ const {
queueMicrotask
} = require('internal/process/task_queues');
-if (!config.noBrowserGlobals) {
+if (!process._noBrowserGlobals) {
// Override global console from the one provided by the VM
// to the one implemented by Node.js
// https://console.spec.whatwg.org/#console-namespace

Просмотреть файл

@ -0,0 +1,19 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <sattard@slack-corp.com>
Date: Mon, 15 Jul 2019 11:41:22 -0700
Subject: fix: make js2c normalize paths before splitting on separaters
diff --git a/tools/js2c.py b/tools/js2c.py
index 4b0b631c46901c8ff01341c8d7f63c13008a5798..4e63ceefe1ff41d2105c3d71980c4f5f5ad11a30 100755
--- a/tools/js2c.py
+++ b/tools/js2c.py
@@ -258,7 +258,7 @@ def AddModule(filename, consts, macros, definitions, initializers, FileReadFn=Re
initializers.append(initializer)
def NormalizeFileName(filename):
- split = filename.split(os.path.sep)
+ split = os.path.normpath(filename).split(os.path.sep)
if split[0] == 'deps':
split = ['internal'] + split
else: # `lib/**/*.js` so drop the 'lib' part

Просмотреть файл

@ -0,0 +1,48 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: deepak1556 <hop2deep@gmail.com>
Date: Wed, 19 Dec 2018 08:54:45 +0530
Subject: fix: use bssl BN_bn2bin_padded for ossl's BN_bn2binpad
Also note that BN_bn2bin_padded returns 1 on success instead of size
diff --git a/src/node_crypto.cc b/src/node_crypto.cc
index a5710dc33b62b9b53174318aed62d8e7fe3a52b9..2143117ec3b782ce307bcb3c7183594bc233d5e8 100644
--- a/src/node_crypto.cc
+++ b/src/node_crypto.cc
@@ -5404,9 +5404,9 @@ void DiffieHellman::GenerateKeys(const FunctionCallbackInfo<Value>& args) {
const int size = BN_num_bytes(pub_key);
CHECK_GE(size, 0);
AllocatedBuffer data = env->AllocateManaged(size);
- CHECK_EQ(size,
- BN_bn2binpad(
- pub_key, reinterpret_cast<unsigned char*>(data.data()), size));
+ CHECK_EQ(
+ 1,
+ BN_bn2bin_padded(reinterpret_cast<unsigned char*>(data.data()), size, pub_key));
args.GetReturnValue().Set(data.ToBuffer().ToLocalChecked());
}
@@ -5426,8 +5426,8 @@ void DiffieHellman::GetField(const FunctionCallbackInfo<Value>& args,
CHECK_GE(size, 0);
AllocatedBuffer data = env->AllocateManaged(size);
CHECK_EQ(
- size,
- BN_bn2binpad(num, reinterpret_cast<unsigned char*>(data.data()), size));
+ 1,
+ BN_bn2bin_padded(reinterpret_cast<unsigned char*>(data.data()), size, num));
args.GetReturnValue().Set(data.ToBuffer().ToLocalChecked());
}
@@ -5750,9 +5750,9 @@ void ECDH::GetPrivateKey(const FunctionCallbackInfo<Value>& args) {
const int size = BN_num_bytes(b);
AllocatedBuffer out = env->AllocateManaged(size);
- CHECK_EQ(size, BN_bn2binpad(b,
- reinterpret_cast<unsigned char*>(out.data()),
- size));
+ CHECK_EQ(1, BN_bn2bin_padded(reinterpret_cast<unsigned char*>(out.data()),
+ size,
+ b));
Local<Object> buf = out.ToBuffer().ToLocalChecked();
args.GetReturnValue().Set(buf);

Просмотреть файл

@ -0,0 +1,24 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Nitish Sakhawalkar <nitsakh@icloud.com>
Date: Tue, 26 Mar 2019 11:28:05 -0700
Subject: fixme: Comment trace event macro
diff --git a/src/node_internals.h b/src/node_internals.h
index 9811c02d5438cd7008d3990f89b7161355e87cfc..3a92c530b1dd262fd12893ac35e6d229594f0792 100644
--- a/src/node_internals.h
+++ b/src/node_internals.h
@@ -348,10 +348,11 @@ class TraceEventScope {
TraceEventScope(const char* category,
const char* name,
void* id) : category_(category), name_(name), id_(id) {
- TRACE_EVENT_NESTABLE_ASYNC_BEGIN0(category_, name_, id_);
+ // TRACE_EVENT_NESTABLE_ASYNC_BEGIN0(category_, name_, id_);
+ (void) category_; (void)name_; (void)id_;
}
~TraceEventScope() {
- TRACE_EVENT_NESTABLE_ASYNC_END0(category_, name_, id_);
+ // TRACE_EVENT_NESTABLE_ASYNC_END0(category_, name_, id_);
}
private:

Просмотреть файл

@ -0,0 +1,25 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Thu, 13 Sep 2018 09:08:10 -0700
Subject: FIXME: remove async_id assertion check
diff --git a/src/api/callback.cc b/src/api/callback.cc
index 52a8da35b671d196331b858ba46be04aecf1e0be..43ccfafd9f2c85e23a9ea6277e88e4864e287905 100644
--- a/src/api/callback.cc
+++ b/src/api/callback.cc
@@ -103,12 +103,14 @@ void InternalCallbackScope::Close() {
env_->isolate()->RunMicrotasks();
}
+#if 0 // FIXME(codebytere): figure out why this check fails/causes crash
// Make sure the stack unwound properly. If there are nested MakeCallback's
// then it should return early and not reach this code.
if (env_->async_hooks()->fields()[AsyncHooks::kTotals]) {
CHECK_EQ(env_->execution_async_id(), 0);
CHECK_EQ(env_->trigger_async_id(), 0);
}
+#endif
if (!tick_info->has_tick_scheduled() && !tick_info->has_rejection_to_warn()) {
return;

Просмотреть файл

@ -0,0 +1,912 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <sattard@slack-corp.com>
Date: Fri, 28 Jun 2019 16:52:24 -0700
Subject: fixme: Revert "crypto: add support for RSA-PSS keys"
This reverts commit 969bd1eb7b56fda3573ad3d41745a491f2b06dde.
diff --git a/lib/internal/crypto/keygen.js b/lib/internal/crypto/keygen.js
index f646f436f7678a293f4742ee8abec9646509c2a6..2c577383f9828bafa11a0cac12d350b3c6023e00 100644
--- a/lib/internal/crypto/keygen.js
+++ b/lib/internal/crypto/keygen.js
@@ -5,7 +5,6 @@ const { Object } = primordials;
const { AsyncWrap, Providers } = internalBinding('async_wrap');
const {
generateKeyPairRSA,
- generateKeyPairRSAPSS,
generateKeyPairDSA,
generateKeyPairEC,
generateKeyPairNid,
@@ -144,7 +143,6 @@ function check(type, options, callback) {
let impl;
switch (type) {
case 'rsa':
- case 'rsa-pss':
{
const { modulusLength } = needOptions();
if (!isUint32(modulusLength))
@@ -157,27 +155,10 @@ function check(type, options, callback) {
throw new ERR_INVALID_OPT_VALUE('publicExponent', publicExponent);
}
- if (type === 'rsa') {
- impl = (wrap) => generateKeyPairRSA(modulusLength, publicExponent,
- publicFormat, publicType,
- privateFormat, privateType,
- cipher, passphrase, wrap);
- break;
- }
-
- const { hash, mgf1Hash, saltLength } = options;
- if (hash !== undefined && typeof hash !== 'string')
- throw new ERR_INVALID_OPT_VALUE('hash', hash);
- if (mgf1Hash !== undefined && typeof mgf1Hash !== 'string')
- throw new ERR_INVALID_OPT_VALUE('mgf1Hash', mgf1Hash);
- if (saltLength !== undefined && !isUint32(saltLength))
- throw new ERR_INVALID_OPT_VALUE('saltLength', saltLength);
-
- impl = (wrap) => generateKeyPairRSAPSS(modulusLength, publicExponent,
- hash, mgf1Hash, saltLength,
- publicFormat, publicType,
- privateFormat, privateType,
- cipher, passphrase, wrap);
+ impl = (wrap) => generateKeyPairRSA(modulusLength, publicExponent,
+ publicFormat, publicType,
+ privateFormat, privateType,
+ cipher, passphrase, wrap);
}
break;
case 'dsa':
@@ -246,7 +227,8 @@ function check(type, options, callback) {
break;
default:
throw new ERR_INVALID_ARG_VALUE('type', type,
- 'must be a supported key type');
+ "must be one of 'rsa', 'dsa', 'ec', " +
+ "'ed25519', 'ed448', 'x25519', 'x448'");
}
if (options) {
diff --git a/lib/internal/crypto/sig.js b/lib/internal/crypto/sig.js
index b6a3376e735094f970ef61a52ef9bb6d6101647a..bb70c2305fd44cfea46a8df5e65d1af5a86d40db 100644
--- a/lib/internal/crypto/sig.js
+++ b/lib/internal/crypto/sig.js
@@ -14,6 +14,10 @@ const {
signOneShot: _signOneShot,
verifyOneShot: _verifyOneShot
} = internalBinding('crypto');
+const {
+ RSA_PSS_SALTLEN_AUTO,
+ RSA_PKCS1_PADDING
+} = internalBinding('constants').crypto;
const {
getDefaultEncoding,
kHandle,
@@ -54,14 +58,14 @@ Sign.prototype.update = function update(data, encoding) {
};
function getPadding(options) {
- return getIntOption('padding', options);
+ return getIntOption('padding', RSA_PKCS1_PADDING, options);
}
function getSaltLength(options) {
- return getIntOption('saltLength', options);
+ return getIntOption('saltLength', RSA_PSS_SALTLEN_AUTO, options);
}
-function getIntOption(name, options) {
+function getIntOption(name, defaultValue, options) {
const value = options[name];
if (value !== undefined) {
if (value === value >> 0) {
@@ -70,7 +74,7 @@ function getIntOption(name, options) {
throw new ERR_INVALID_OPT_VALUE(name, value);
}
}
- return undefined;
+ return defaultValue;
}
Sign.prototype.sign = function sign(options, encoding) {
diff --git a/src/env.h b/src/env.h
index 23ad7569d31bc534247ed373819bc291a4f4bfe6..8047b2c98398f0344274ec824abab88007ae5c3f 100644
--- a/src/env.h
+++ b/src/env.h
@@ -165,7 +165,6 @@ constexpr size_t kFsStatsBufferLength = kFsStatsFieldsNumber * 2;
V(crypto_x25519_string, "x25519") \
V(crypto_x448_string, "x448") \
V(crypto_rsa_string, "rsa") \
- V(crypto_rsa_pss_string, "rsa-pss") \
V(cwd_string, "cwd") \
V(data_string, "data") \
V(dest_string, "dest") \
diff --git a/src/node_crypto.cc b/src/node_crypto.cc
index 4b6eccd7fe96d185c28def27ff3d0da3e26e950f..70e9b2ddafc8aaa46063c5957c70d7a83ab99f9c 100644
--- a/src/node_crypto.cc
+++ b/src/node_crypto.cc
@@ -3727,8 +3727,6 @@ Local<Value> KeyObject::GetAsymmetricKeyType() const {
switch (EVP_PKEY_id(this->asymmetric_key_.get())) {
case EVP_PKEY_RSA:
return env()->crypto_rsa_string();
- case EVP_PKEY_RSA_PSS:
- return env()->crypto_rsa_pss_string();
case EVP_PKEY_DSA:
return env()->crypto_dsa_string();
case EVP_PKEY_EC:
@@ -4726,14 +4724,13 @@ void SignBase::CheckThrow(SignBase::Error error) {
static bool ApplyRSAOptions(const ManagedEVPPKey& pkey,
EVP_PKEY_CTX* pkctx,
int padding,
- const Maybe<int>& salt_len) {
+ int salt_len) {
if (EVP_PKEY_id(pkey.get()) == EVP_PKEY_RSA ||
- EVP_PKEY_id(pkey.get()) == EVP_PKEY_RSA2 ||
- EVP_PKEY_id(pkey.get()) == EVP_PKEY_RSA_PSS) {
+ EVP_PKEY_id(pkey.get()) == EVP_PKEY_RSA2) {
if (EVP_PKEY_CTX_set_rsa_padding(pkctx, padding) <= 0)
return false;
- if (padding == RSA_PKCS1_PSS_PADDING && salt_len.IsJust()) {
- if (EVP_PKEY_CTX_set_rsa_pss_saltlen(pkctx, salt_len.FromJust()) <= 0)
+ if (padding == RSA_PKCS1_PSS_PADDING) {
+ if (EVP_PKEY_CTX_set_rsa_pss_saltlen(pkctx, salt_len) <= 0)
return false;
}
}
@@ -4784,16 +4781,11 @@ void Sign::SignUpdate(const FunctionCallbackInfo<Value>& args) {
sign->CheckThrow(err);
}
-static int GetDefaultSignPadding(const ManagedEVPPKey& key) {
- return EVP_PKEY_id(key.get()) == EVP_PKEY_RSA_PSS ? RSA_PKCS1_PSS_PADDING :
- RSA_PKCS1_PADDING;
-}
-
static AllocatedBuffer Node_SignFinal(Environment* env,
EVPMDPointer&& mdctx,
const ManagedEVPPKey& pkey,
int padding,
- Maybe<int> pss_salt_len) {
+ int pss_salt_len) {
unsigned char m[EVP_MAX_MD_SIZE];
unsigned int m_len;
@@ -4826,7 +4818,7 @@ static AllocatedBuffer Node_SignFinal(Environment* env,
Sign::SignResult Sign::SignFinal(
const ManagedEVPPKey& pkey,
int padding,
- const Maybe<int>& salt_len) {
+ int salt_len) {
if (!mdctx_)
return SignResult(kSignNotInitialised);
@@ -4877,17 +4869,11 @@ void Sign::SignFinal(const FunctionCallbackInfo<Value>& args) {
if (!key)
return;
- int padding = GetDefaultSignPadding(key);
- if (!args[offset]->IsUndefined()) {
- CHECK(args[offset]->IsInt32());
- padding = args[offset].As<Int32>()->Value();
- }
+ CHECK(args[offset]->IsInt32());
+ int padding = args[offset].As<Int32>()->Value();
- Maybe<int> salt_len = Nothing<int>();
- if (!args[offset + 1]->IsUndefined()) {
- CHECK(args[offset + 1]->IsInt32());
- salt_len = Just<int>(args[offset + 1].As<Int32>()->Value());
- }
+ CHECK(args[offset + 1]->IsInt32());
+ int salt_len = args[offset + 1].As<Int32>()->Value();
SignResult ret = sign->SignFinal(
key,
@@ -4948,17 +4934,11 @@ void SignOneShot(const FunctionCallbackInfo<Value>& args) {
return CheckThrow(env, SignBase::Error::kSignUnknownDigest);
}
- int rsa_padding = GetDefaultSignPadding(key);
- if (!args[offset + 2]->IsUndefined()) {
- CHECK(args[offset + 2]->IsInt32());
- rsa_padding = args[offset + 2].As<Int32>()->Value();
- }
+ CHECK(args[offset + 2]->IsInt32());
+ int rsa_padding = args[offset + 2].As<Int32>()->Value();
- Maybe<int> rsa_salt_len = Nothing<int>();
- if (!args[offset + 3]->IsUndefined()) {
- CHECK(args[offset + 3]->IsInt32());
- rsa_salt_len = Just<int>(args[offset + 3].As<Int32>()->Value());
- }
+ CHECK(args[offset + 3]->IsInt32());
+ int rsa_salt_len = args[offset + 3].As<Int32>()->Value();
EVP_PKEY_CTX* pkctx = nullptr;
EVPMDPointer mdctx(EVP_MD_CTX_new());
@@ -5036,7 +5016,7 @@ SignBase::Error Verify::VerifyFinal(const ManagedEVPPKey& pkey,
const char* sig,
int siglen,
int padding,
- const Maybe<int>& saltlen,
+ int saltlen,
bool* verify_result) {
if (!mdctx_)
return kSignNotInitialised;
@@ -5080,17 +5060,11 @@ void Verify::VerifyFinal(const FunctionCallbackInfo<Value>& args) {
ArrayBufferViewContents<char> hbuf(args[offset]);
- int padding = GetDefaultSignPadding(pkey);
- if (!args[offset + 1]->IsUndefined()) {
- CHECK(args[offset + 1]->IsInt32());
- padding = args[offset + 1].As<Int32>()->Value();
- }
+ CHECK(args[offset + 1]->IsInt32());
+ int padding = args[offset + 1].As<Int32>()->Value();
- Maybe<int> salt_len = Nothing<int>();
- if (!args[offset + 2]->IsUndefined()) {
- CHECK(args[offset + 2]->IsInt32());
- salt_len = Just<int>(args[offset + 2].As<Int32>()->Value());
- }
+ CHECK(args[offset + 2]->IsInt32());
+ int salt_len = args[offset + 2].As<Int32>()->Value();
bool verify_result;
Error err = verify->VerifyFinal(pkey, hbuf.data(), hbuf.length(), padding,
@@ -5123,17 +5097,11 @@ void VerifyOneShot(const FunctionCallbackInfo<Value>& args) {
return CheckThrow(env, SignBase::Error::kSignUnknownDigest);
}
- int rsa_padding = GetDefaultSignPadding(key);
- if (!args[offset + 3]->IsUndefined()) {
- CHECK(args[offset + 3]->IsInt32());
- rsa_padding = args[offset + 3].As<Int32>()->Value();
- }
+ CHECK(args[offset + 3]->IsInt32());
+ int rsa_padding = args[offset + 3].As<Int32>()->Value();
- Maybe<int> rsa_salt_len = Nothing<int>();
- if (!args[offset + 4]->IsUndefined()) {
- CHECK(args[offset + 4]->IsInt32());
- rsa_salt_len = Just<int>(args[offset + 4].As<Int32>()->Value());
- }
+ CHECK(args[offset + 4]->IsInt32());
+ int rsa_salt_len = args[offset + 4].As<Int32>()->Value();
EVP_PKEY_CTX* pkctx = nullptr;
EVPMDPointer mdctx(EVP_MD_CTX_new());
@@ -6137,48 +6105,6 @@ class RSAKeyPairGenerationConfig : public KeyPairGenerationConfig {
const unsigned int exponent_;
};
-class RSAPSSKeyPairGenerationConfig : public RSAKeyPairGenerationConfig {
- public:
- RSAPSSKeyPairGenerationConfig(unsigned int modulus_bits,
- unsigned int exponent,
- const EVP_MD* md,
- const EVP_MD* mgf1_md,
- int saltlen)
- : RSAKeyPairGenerationConfig(modulus_bits, exponent),
- md_(md), mgf1_md_(mgf1_md), saltlen_(saltlen) {}
-
- EVPKeyCtxPointer Setup() override {
- return EVPKeyCtxPointer(EVP_PKEY_CTX_new_id(EVP_PKEY_RSA_PSS, nullptr));
- }
-
- bool Configure(const EVPKeyCtxPointer& ctx) override {
- if (!RSAKeyPairGenerationConfig::Configure(ctx))
- return false;
-
- if (md_ != nullptr) {
- if (EVP_PKEY_CTX_set_rsa_pss_keygen_md(ctx.get(), md_) <= 0)
- return false;
- }
-
- if (mgf1_md_ != nullptr) {
- if (EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md(ctx.get(), mgf1_md_) <= 0)
- return false;
- }
-
- if (saltlen_ >= 0) {
- if (EVP_PKEY_CTX_set_rsa_pss_keygen_saltlen(ctx.get(), saltlen_) <= 0)
- return false;
- }
-
- return true;
- }
-
- private:
- const EVP_MD* md_;
- const EVP_MD* mgf1_md_;
- const int saltlen_;
-};
-
class DSAKeyPairGenerationConfig : public KeyPairGenerationConfig {
public:
DSAKeyPairGenerationConfig(unsigned int modulus_bits, int divisor_bits)
@@ -6412,44 +6338,6 @@ void GenerateKeyPairRSA(const FunctionCallbackInfo<Value>& args) {
GenerateKeyPair(args, 2, std::move(config));
}
-void GenerateKeyPairRSAPSS(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args);
-
- CHECK(args[0]->IsUint32());
- const uint32_t modulus_bits = args[0].As<Uint32>()->Value();
- CHECK(args[1]->IsUint32());
- const uint32_t exponent = args[1].As<Uint32>()->Value();
-
- const EVP_MD* md = nullptr;
- if (!args[2]->IsUndefined()) {
- CHECK(args[2]->IsString());
- String::Utf8Value md_name(env->isolate(), args[2].As<String>());
- md = EVP_get_digestbyname(*md_name);
- if (md == nullptr)
- return env->ThrowTypeError("Digest method not supported");
- }
-
- const EVP_MD* mgf1_md = nullptr;
- if (!args[3]->IsUndefined()) {
- CHECK(args[3]->IsString());
- String::Utf8Value mgf1_md_name(env->isolate(), args[3].As<String>());
- mgf1_md = EVP_get_digestbyname(*mgf1_md_name);
- if (mgf1_md == nullptr)
- return env->ThrowTypeError("Digest method not supported");
- }
-
- int saltlen = -1;
- if (!args[4]->IsUndefined()) {
- CHECK(args[4]->IsInt32());
- saltlen = args[4].As<Int32>()->Value();
- }
-
- std::unique_ptr<KeyPairGenerationConfig> config(
- new RSAPSSKeyPairGenerationConfig(modulus_bits, exponent,
- md, mgf1_md, saltlen));
- GenerateKeyPair(args, 5, std::move(config));
-}
-
void GenerateKeyPairDSA(const FunctionCallbackInfo<Value>& args) {
CHECK(args[0]->IsUint32());
const uint32_t modulus_bits = args[0].As<Uint32>()->Value();
@@ -6901,7 +6789,6 @@ void Initialize(Local<Object> target,
env->SetMethod(target, "pbkdf2", PBKDF2);
env->SetMethod(target, "generateKeyPairRSA", GenerateKeyPairRSA);
- env->SetMethod(target, "generateKeyPairRSAPSS", GenerateKeyPairRSAPSS);
env->SetMethod(target, "generateKeyPairDSA", GenerateKeyPairDSA);
env->SetMethod(target, "generateKeyPairEC", GenerateKeyPairEC);
env->SetMethod(target, "generateKeyPairNid", GenerateKeyPairNid);
diff --git a/src/node_crypto.h b/src/node_crypto.h
index 849b80f4e06268ca442e1d78ff60225d52077ce8..b404f0fcd4d1df5da86173955df45bb0eb4923fe 100644
--- a/src/node_crypto.h
+++ b/src/node_crypto.h
@@ -671,7 +671,7 @@ class Sign : public SignBase {
SignResult SignFinal(
const ManagedEVPPKey& pkey,
int padding,
- const v8::Maybe<int>& saltlen);
+ int saltlen);
protected:
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
@@ -692,7 +692,7 @@ class Verify : public SignBase {
const char* sig,
int siglen,
int padding,
- const v8::Maybe<int>& saltlen,
+ int saltlen,
bool* verify_result);
protected:
diff --git a/test/fixtures/keys/Makefile b/test/fixtures/keys/Makefile
index 81fe36a81331eb1d1d1696763c887d252ac4fef9..3be2cd6655f7e60e5b3a92c4be0fea50c64d14df 100644
--- a/test/fixtures/keys/Makefile
+++ b/test/fixtures/keys/Makefile
@@ -37,12 +37,6 @@ all: \
rsa_public_1024.pem \
rsa_public_2048.pem \
rsa_public_4096.pem \
- rsa_pss_private_2048.pem \
- rsa_pss_private_2048_sha256_sha256_16.pem \
- rsa_pss_private_2048_sha512_sha256_20.pem \
- rsa_pss_public_2048.pem \
- rsa_pss_public_2048_sha256_sha256_16.pem \
- rsa_pss_public_2048_sha512_sha256_20.pem \
#
# Create Certificate Authority: ca1
@@ -580,24 +574,6 @@ rsa_public_2048.pem: rsa_private_2048.pem
rsa_public_4096.pem: rsa_private_4096.pem
openssl rsa -in rsa_private_4096.pem -pubout -out rsa_public_4096.pem
-rsa_pss_private_2048.pem:
- openssl genpkey -algorithm RSA-PSS -pkeyopt rsa_keygen_bits:2048 -pkeyopt rsa_keygen_pubexp:65537 -out rsa_pss_private_2048.pem
-
-rsa_pss_private_2048_sha256_sha256_16.pem:
- openssl genpkey -algorithm RSA-PSS -pkeyopt rsa_keygen_bits:2048 -pkeyopt rsa_keygen_pubexp:65537 -pkeyopt rsa_pss_keygen_md:sha256 -pkeyopt rsa_pss_keygen_mgf1_md:sha256 -pkeyopt rsa_pss_keygen_saltlen:16 -out rsa_pss_private_2048_sha256_sha256_16.pem
-
-rsa_pss_private_2048_sha512_sha256_20.pem:
- openssl genpkey -algorithm RSA-PSS -pkeyopt rsa_keygen_bits:2048 -pkeyopt rsa_keygen_pubexp:65537 -pkeyopt rsa_pss_keygen_md:sha512 -pkeyopt rsa_pss_keygen_mgf1_md:sha256 -pkeyopt rsa_pss_keygen_saltlen:20 -out rsa_pss_private_2048_sha512_sha256_20.pem
-
-rsa_pss_public_2048.pem: rsa_pss_private_2048.pem
- openssl pkey -in rsa_pss_private_2048.pem -pubout -out rsa_pss_public_2048.pem
-
-rsa_pss_public_2048_sha256_sha256_16.pem: rsa_pss_private_2048_sha256_sha256_16.pem
- openssl pkey -in rsa_pss_private_2048_sha256_sha256_16.pem -pubout -out rsa_pss_public_2048_sha256_sha256_16.pem
-
-rsa_pss_public_2048_sha512_sha256_20.pem: rsa_pss_private_2048_sha512_sha256_20.pem
- openssl pkey -in rsa_pss_private_2048_sha512_sha256_20.pem -pubout -out rsa_pss_public_2048_sha512_sha256_20.pem
-
clean:
rm -f *.pfx *.pem *.srl ca2-database.txt ca2-serial fake-startcom-root-serial *.print *.old fake-startcom-root-issued-certs/*.pem
@> fake-startcom-root-database.txt
diff --git a/test/fixtures/keys/rsa_pss_private_2048.pem b/test/fixtures/keys/rsa_pss_private_2048.pem
deleted file mode 100644
index ffca137a71219fb6a801c7a905f6607672acb168..0000000000000000000000000000000000000000
--- a/test/fixtures/keys/rsa_pss_private_2048.pem
+++ /dev/null
@@ -1,28 +0,0 @@
------BEGIN PRIVATE KEY-----
-MIIEvAIBADALBgkqhkiG9w0BAQoEggSoMIIEpAIBAAKCAQEAy4OMdS84PlgI5CRL
-bdbud9Ru7vprFr2YNNUmdT7D3YgApiv8CjzKXLiVDnbMET+lwmtag/EcZsxVCKov
-su30pYASBriHOiMVYui9+ZaJoQ9yI6lOjG1RbuUBJXNSjHBJxqBqmcgZOb1mdRr/
-eXzpAMWJ3hfuLojU2+zUSJ3/rvepepcLFG2q9nA0+PJskJ7Pnh3L0ydnv3U3hduM
-n5OVfm/Jx1FPyZpD184tJff+N+MY3s3hIcfuOnL9Pl4RPGeaTC4T1o460NaG6bG7
-c2Whg6NOaVgaFIaiNbrTTNCpVjeTyalsTXYlQQ3hiKjst0Q7pfFEkJDo8qiqLad1
-Msl59wIDAQABAoIBAQC6G8aqs0/f02nuGDLSc6cH9kCsUlz0ItW6GuJcfdVoFSNi
-0v5d7lGwkSveWk0ryOSw8rOHzUqHx3xLvDZ6jpkXcBMMClu/kq3QEb8JK90YaKOc
-cQvf52h83Pc7ZEatH1KYTcKudwp6fvXfSZ0vYEdD6WG2tHOgIollxSIsdjCHs1qi
-7baNHdK9T4DveuEZNcZ+LraZ1haHmFeqIPcy+KvpGuTaLCg5FPhH2jsIkw9apr7i
-iFLi+IJ7S5Bn/8XShmJWk4hPyx0jtIkC5r2iJnHf4x+XYWZfdo7oew3Dg6Pa7T6r
-I164Nnaw0u0LvO4gQdvYaJ/j9A602nHTp7Tsq8chAoGBAOtVHgIqpmdzwR5KjotW
-LuGXDdO9X6Xfge9ca2MlWH1jOj+zqEV7JtrjnZAzzOgP2kgqzpIR71Njs8wkaxTJ
-Tle0Ke6R/ghU9YOQgRByKjqJfQXHZnYFPsMg0diNYLroJ4SG8LO4+2SygTYZ4eKL
-qU0bda3QvQ7FL+rTNQBy01b9AoGBAN1jEQI80JxCT7AMvXE6nObIhbkASHte4yOE
-1CBwcOuBEGcuvMOvQVMzKITgea6+kgsu4ids4dM5PTPapQgpKqIIQ2/eSesaf56g
-73clGGSTPHJP0v+EfKg4+GYJf8o2swT0xDHkgWLgjjdsncB9hATc2j6DvHeau18d
-pgCLz9kDAoGAXl/SGvhTp2UqayVnKMW1I07agrGNLA4II5+iiS4u4InskCNSNhr/
-KATj6TJ82AuTdCGGmdmLapuvPQzVzI42VsGvlzcA8wJvOwW2XIwMF1GPy8N9eZL8
-6m+89+Uqh4oWXvVmjgx+9JEJdFLI3Xs4t+1tMfll+AhoAPoWZUmnK1kCgYAvEBxR
-iXQfg8lE97BeHcO1G/OxfGnsMCPBLT+bFcwrhGhkRv9B6kPM2BdJCB9WEpUhY3oY
-P4FSUdy85UIoFfhGMdOEOJEmNZ/jrPq7LVueJd63vlhwkU2exV2o82QDLNWpvA7p
-PFZ1Gp+hEKoIfaZPElQi7gZmtrIWaksb2pz42QKBgQCct9NP2qJfqeS4206RDnfv
-M238/O2lNhLWdSwY0g+tcN+I1sGs3+4vvrm95cxwAmXZyIM11wjdMcAPNxibodY7
-vufsebPHDBA0j0yuTjGkXefUKd1GdO88i5fppzxB7prDX9//DsWWrFhIMMRNYe0Q
-aeHd/NPuHcjZKcnaVBgukQ==
------END PRIVATE KEY-----
diff --git a/test/fixtures/keys/rsa_pss_private_2048_sha256_sha256_16.pem b/test/fixtures/keys/rsa_pss_private_2048_sha256_sha256_16.pem
deleted file mode 100644
index ea4597015401d52dcfdf23c73ee9403b1a0dbbaf..0000000000000000000000000000000000000000
--- a/test/fixtures/keys/rsa_pss_private_2048_sha256_sha256_16.pem
+++ /dev/null
@@ -1,29 +0,0 @@
------BEGIN PRIVATE KEY-----
-MIIE7wIBADA9BgkqhkiG9w0BAQowMKANMAsGCWCGSAFlAwQCAaEaMBgGCSqGSIb3
-DQEBCDALBglghkgBZQMEAgGiAwIBEASCBKkwggSlAgEAAoIBAQDfqNM4C+QtD73i
-ILqOkqfV8ha3O19jpX8UujIk1Z72bbbuwEzh0+sBw0dD0N8CgkXnePOEEd6q7HNm
-byCNqRpDK6NDvaCMDWgEaD/PlHkRntvKh81IXSMC5imjRfOcZIE/Gnw7h8tanab0
-n75+ODvLJrmEWUG2q79Im1mWMx7Spod+Np6XEY+7I7nAUUWivr35Yx5DeyxY8rxF
-GpsLtGsi7JNQO4aHyeBpj8tz0Fhv23uPywE2nGmPHfnkXWbrTcHGbzYBgEbeSH9K
-UkRwczqDXNOPhtfaEHEFTm0MoeKCnJe1VOjSywev77dV1KZfpVh3Kh0ZRQIe9YOV
-Jhj4lMx3AgMBAAECggEBAIc+IgK5Bg/NfgeXvNdrjPuM+PlxeHvb3h1dfebSGd5v
-d3elZpgDug6F07kJO2Db/4M5mx7YY2m9swZU2j1u7MeDQqU6rDMkBCruEu/lmtPx
-2Hv+ZD6Gux4MqU7mhKmkCJds34Rr16aCwCsZ0WmnfViZoQKLqnXYIsG31pNBdDjx
-gke0HhX1LkA9yTVwlk8xOaHPqI4KfsFAyoiiHzyttGDexzb1PzmM0pybAPDMhpN/
-wXp2kLjyzmUmPe2Y2yva69WVWo7qS6joKjY75MQ1t20HYgEL69IApvCPu4CANfi9
-j3FAaV/+WrnhKCi6QyUi5PCI/+AJLsjNQmqTXIdBEoECgYEA+XsgFbeZ6+ZzEHa7
-HyFH6kiyBLd0q7w+ZLPsoOmEApDaP3yXSC7eJU7M/tPUPj8VQMMSK2D6fgmUDwhb
-3mEXFZxf67UlPFsFjweYcBihwy4r8QKBwury6dEbHPSUq4mXFJF5XRQdGqRGkr/F
-8OLZ0MwmHLUzczA67PxP/wF8TsECgYEA5YD4RxxJJYfAk1rFbqHRhNB8UeYVL+Wo
-wsRET1JeFg+S5grLGUga+KBB8Jn7Ahaip7MVE0Iud1cgaDi4WBEJsbJ6oJTlHJEg
-Jq7QAaBafwjeSCSnaEsVBVNvriy2WF7uAomLSKmW6uSUOBBFFt4+G+akG56EfOPc
-7YKBfsf5ITcCgYBvjVZzX307tfeNTQmuibsWTxsKcN2CTNG5RZpw+PlGDG8KJDOg
-2xQJqoqPBzjH/H0MUC03qE1ZPf8uGZa6gL9JsnpRctYLfselhMfsl5b9JxAO3AgZ
-l+S2GAH/mH1BlmwvjjyuGehJmVrVE1r2sviiHCaOf5dZ0h8HCGrco1VqAQKBgQCf
-fYkMofOTSUvjG2mpAHuCOQCsSaDfsFIfSBXQqgUIf7ouc8HAyAM2VOh+NAPj56cR
-s7opsAxqkvnKc+BoEy8Rdl8RyWeO+qvFNicHelBph9gxeod8SvFIyjsKZ7gwoYf1
-63AIBxMCGeeHLodU5Q10hkv1hau8vv2BcPhdCstu8QKBgQDgO4Rr36Pa5rjbNbGN
-PsJqALjthTeU0yaU8hdC7Hc7B/T6npEIhw3s1eNq7e0eeDltqz7tDnY8qysazbQZ
-p1cV5TJ8+gtwGmDoADBnU1NXqX4Squfml6OhNEucpTdjux7JdLVmmQFraOT2Eu5f
-9uuNtA+d8uhBEXhskuvEC552ug==
------END PRIVATE KEY-----
diff --git a/test/fixtures/keys/rsa_pss_private_2048_sha512_sha256_20.pem b/test/fixtures/keys/rsa_pss_private_2048_sha512_sha256_20.pem
deleted file mode 100644
index f8e898980ad25fd03dda0401fe4f18a148d7fb9f..0000000000000000000000000000000000000000
--- a/test/fixtures/keys/rsa_pss_private_2048_sha512_sha256_20.pem
+++ /dev/null
@@ -1,29 +0,0 @@
------BEGIN PRIVATE KEY-----
-MIIE5wIBADA4BgkqhkiG9w0BAQowK6ANMAsGCWCGSAFlAwQCA6EaMBgGCSqGSIb3
-DQEBCDALBglghkgBZQMEAgEEggSmMIIEogIBAAKCAQEAvM9NgMCDqy5dqj5Ua2cZ
-cc4zVr+fCF34bZn63OBeYG8RTJKM3j36lO/yamtfDctDhb87b45CS6ipEr8J57I9
-WF55TNngsn6GNpXgwAe0eFXUnKonuqnGEC7x8r3vkAg99PBKhAtFc5oTaaZDAFKM
-zc5dIC/J0Y+kxhqjCPNI0ydQgZmKBrmYjM9cvbOYgRQL10GrWeJ+XHk2E33endaF
-+4dwjgyrzInt/l6OTkiCL8F59J/htk1GPru9BT6w5yOS/vH6q6FD6uizULVznytd
-lHjgnrVaHJmsqVjrYQa9OAZj9GBrTelBWvQ9b6+FBHUFHBp8HSp82lWCZThPrcZ/
-QwIDAQABAoIBADDzUfWic8CKuc/sbviVdzxRKHBCJ9oEeub3d9mR9gXsZcDDcfAg
-g3nfp6q9gZxS6YOga6llaXyyEnuAufGu/UaO38Xz6tR8BxHZ07YViU11ezTOzJQR
-df82HJZBdf2SlXWOYtNPFMd+16+ZYl+QB19INE6m9Rz2r9KIj2I/qM7NPPVhDRF0
-G4O0Yf2vaPhjoIaewn7xtQ6wmX7pAGcd8dmYEIGGkBi8aY3BVwrRK1X4AmD+oSmE
-wXqR6MQIzD4KdypL4UD1Cb4GoFeVRclXvegOG+EKl0iD+mjTodB4yjoJh98NYe3+
-GtpR/2u3Ltq8RqWpIg8ryShQk/MIqGJ5KpkCgYEA80uNEYWlBt6QGNvVIYrhnw+V
-2nLJWedioKV4H1sr9OLF/7WFOUfsaflpVybnmwfNV15lEyHb/m/sCM9jTrNk1t/q
-qhRnvtmy3kntxWBeoA2o0TRg/XZKWjabZsr/4UE/Ztws2opOvl9x05IYeZlU+PbZ
-B1lX2e+vtMOpllvRr28CgYEAxqtfrYv8brp/fAUqGu/MtdHxQdU1+vE+auN17gam
-ZM6ojIeasX4k2z0Rd/+8Dga9wPgO7hjtFZ2NWD5UwfBiw5U2PVZ6bp3iKSBPGHEh
-RsIR+nw8pFIgsQKoYnVK58tEnfQ31GSupKpYybHbaL5SdId+mfXU86SbKX/MefZX
-g20CgYBjn8hAKI2O5ovy4fHALnJ9A5DFRsOUgN8uERPDIz44pLOXJelLr1vreSnd
-ehzUqrk20Xxp/S9sXMA2S1XK4EKmikI5KungiJxp0bP/Yprcxzsdj2k34LxJfJrd
-2Lo2rtUbdYUYaBIeek7N58EF6feVit8L11XV9APq7UQAQdD3GQKBgBmxuGIdpLw9
-apeDo3pwYS1yxZ0aEi0uXkA8wtfSDFslTy89qogiJGomb8fxT0URIiF+849fseoF
-wm4TQasDiAJ7ndQ5BwSfbsya3R/wIbmhB+o5fy5RYOED0vtI6DMqWumC2GWjz+KE
-FY+gbRwS4V8o1vrajHwmYdrwKGXtskvRAoGADe/EdlCj98r6Zle9giF1C0GDIDTx
-8bR2m+Ogh9ZO218GpDMNaQ/WmbYVPDYMbRSOEA7y2gVkd1OeYhJMF6aYffp3aWhN
-t9g0uojLY0jfEpWBLBQdlYOTl7hOnLWRRcOAKTlHVg+OuD/O/GmdQ2Rg2H/hAWlI
-muuTQPuQTCV1aTc=
------END PRIVATE KEY-----
diff --git a/test/fixtures/keys/rsa_pss_public_2048.pem b/test/fixtures/keys/rsa_pss_public_2048.pem
deleted file mode 100644
index ade38f20a44353a88a28cee53fcdb3e13d25f5f7..0000000000000000000000000000000000000000
--- a/test/fixtures/keys/rsa_pss_public_2048.pem
+++ /dev/null
@@ -1,9 +0,0 @@
------BEGIN PUBLIC KEY-----
-MIIBIDALBgkqhkiG9w0BAQoDggEPADCCAQoCggEBAMuDjHUvOD5YCOQkS23W7nfU
-bu76axa9mDTVJnU+w92IAKYr/Ao8yly4lQ52zBE/pcJrWoPxHGbMVQiqL7Lt9KWA
-Ega4hzojFWLovfmWiaEPciOpToxtUW7lASVzUoxwScagapnIGTm9ZnUa/3l86QDF
-id4X7i6I1Nvs1Eid/673qXqXCxRtqvZwNPjybJCez54dy9MnZ791N4XbjJ+TlX5v
-ycdRT8maQ9fOLSX3/jfjGN7N4SHH7jpy/T5eETxnmkwuE9aOOtDWhumxu3NloYOj
-TmlYGhSGojW600zQqVY3k8mpbE12JUEN4Yio7LdEO6XxRJCQ6PKoqi2ndTLJefcC
-AwEAAQ==
------END PUBLIC KEY-----
diff --git a/test/fixtures/keys/rsa_pss_public_2048_sha256_sha256_16.pem b/test/fixtures/keys/rsa_pss_public_2048_sha256_sha256_16.pem
deleted file mode 100644
index 9f8e15bbe0f8f1805c8cc62239a73d390df41b2a..0000000000000000000000000000000000000000
--- a/test/fixtures/keys/rsa_pss_public_2048_sha256_sha256_16.pem
+++ /dev/null
@@ -1,10 +0,0 @@
------BEGIN PUBLIC KEY-----
-MIIBUjA9BgkqhkiG9w0BAQowMKANMAsGCWCGSAFlAwQCAaEaMBgGCSqGSIb3DQEB
-CDALBglghkgBZQMEAgGiAwIBEAOCAQ8AMIIBCgKCAQEA36jTOAvkLQ+94iC6jpKn
-1fIWtztfY6V/FLoyJNWe9m227sBM4dPrAcNHQ9DfAoJF53jzhBHequxzZm8gjaka
-QyujQ72gjA1oBGg/z5R5EZ7byofNSF0jAuYpo0XznGSBPxp8O4fLWp2m9J++fjg7
-yya5hFlBtqu/SJtZljMe0qaHfjaelxGPuyO5wFFFor69+WMeQ3ssWPK8RRqbC7Rr
-IuyTUDuGh8ngaY/Lc9BYb9t7j8sBNpxpjx355F1m603Bxm82AYBG3kh/SlJEcHM6
-g1zTj4bX2hBxBU5tDKHigpyXtVTo0ssHr++3VdSmX6VYdyodGUUCHvWDlSYY+JTM
-dwIDAQAB
------END PUBLIC KEY-----
diff --git a/test/fixtures/keys/rsa_pss_public_2048_sha512_sha256_20.pem b/test/fixtures/keys/rsa_pss_public_2048_sha512_sha256_20.pem
deleted file mode 100644
index 9ace7d6d2db7945fbe7ad78a059da0fdc7d9b365..0000000000000000000000000000000000000000
--- a/test/fixtures/keys/rsa_pss_public_2048_sha512_sha256_20.pem
+++ /dev/null
@@ -1,10 +0,0 @@
------BEGIN PUBLIC KEY-----
-MIIBTTA4BgkqhkiG9w0BAQowK6ANMAsGCWCGSAFlAwQCA6EaMBgGCSqGSIb3DQEB
-CDALBglghkgBZQMEAgEDggEPADCCAQoCggEBALzPTYDAg6suXao+VGtnGXHOM1a/
-nwhd+G2Z+tzgXmBvEUySjN49+pTv8mprXw3LQ4W/O2+OQkuoqRK/CeeyPVheeUzZ
-4LJ+hjaV4MAHtHhV1JyqJ7qpxhAu8fK975AIPfTwSoQLRXOaE2mmQwBSjM3OXSAv
-ydGPpMYaowjzSNMnUIGZiga5mIzPXL2zmIEUC9dBq1niflx5NhN93p3WhfuHcI4M
-q8yJ7f5ejk5Igi/BefSf4bZNRj67vQU+sOcjkv7x+quhQ+ros1C1c58rXZR44J61
-WhyZrKlY62EGvTgGY/Rga03pQVr0PW+vhQR1BRwafB0qfNpVgmU4T63Gf0MCAwEA
-AQ==
------END PUBLIC KEY-----
diff --git a/test/fixtures/test_unknown_privkey.pem b/test/fixtures/test_unknown_privkey.pem
new file mode 100644
index 0000000000000000000000000000000000000000..4e8e46f04133422128eea2b88a8f378f8b8f842d
--- /dev/null
+++ b/test/fixtures/test_unknown_privkey.pem
@@ -0,0 +1,28 @@
+-----BEGIN PRIVATE KEY-----
+MIIEugIBADALBgkqhkiG9w0BAQoEggSmMIIEogIBAAKCAQEAwMSNbT9SbSHvXmPt
+j1x2Ipk1tUM06301UD91xGcA0232zrIQcKjsPM7bE6YXN0zRxfLJUqalewCk80Ct
+6V+E5XtMHUFQt1Ne8HW9U930KnfnQEyU8UwRPoWWeZQhs+sa8ZfggtfN7gq4/wiS
+KFNNtSJb24NKoLis31P0nILGC4/JewgE0QaFUoOL+Oc3dMhwWg9/H64sSjhI/SGW
+9Sv3M6WcSn7vQCe8oM2vslf3Xm8rHNqZMlXujs7zhRtcr5alKz9BwMJIoGouQrk9
+9cgupdYsddgNh2bC4TQR9BMKHj8tV5Uf3Pbf4EoZOFffCbyBZxmKtsYsmhh2FDLA
+RzNhKwIDAQABAoIBAHBRlj4ziSmBfmG3Q/ImY8chEkQ9lpYn7GqHr2zyv25yQj6J
+Tj72jj+YH9pBCoH0Rr5aCqgX5Y/X/kSmSS8TsvGrd9wL9KX88/KUB+7YAq7EEoBK
+nvZB5kJRwC2y/DhDIv3mCrDyYVDz+nrPWaoZb8u861zqEQ+4yzGNT5fqMs8Ewm8A
+hxg3GA2R6FC2CymZO884XOxlVac6SNURfA+U+xrcMIXbXpok2Z5eh/kMOeIKwmL0
+QEO0U6DEnZm4rJjywu8fEkKbX00YfaDQaiGzRZfvmzkTPIQemXPWARdIvFtJU8Fx
+OWWeMumJD1KiU9ISW4e76l7F8UOviT6jEg9rxFECgYEA96WCEIB+O4aO7+s56kOv
+vQkEXn959lz7e++S9AV3R19PpBCh50l5v9NSjGQlA4FU4AdBB5EmiX/bLZRHFwHI
+KLDsMFuq9id3OPHYIzFP4YjVHTGRPZToJHwy4ePIdZEaeJHY39EEz8oHsSSJlLdm
+o0417RsFAfApW2VN63c3JFcCgYEAx0Um/ATsT4ELguVQ+XlquLQdS12XS7zjcwWv
+PL8UyooSxcjcbLcJB6DRWXM0NOry7KPUCIF4m3KSjIZypV/v2KVFPCfD3vxZcdB7
+xgccqXJMUx7MSs9AMZXTtv5hG7RS5z+ig7Yi/6nzBm21jKYKbFDbqfq8MSfiR6cT
+KjR+RU0CgYAm/iFnlcPKfZpd/mylDTlLi3Lrqii6+NMEJam+0GmCjGhOzeugLjqE
+ULLLtiz5y1Bg4eOEXH9z4PTSzWkQH1Czz3+w8Y4OqhIknjfI+se4HEJqEVbsGlke
+/YtJdAMpN8qyN0ytmQyn5wilBLrA9surZPIqvjlgn77zTBUjwSamiwKBgAqIVS8s
+83CgWYNpq4YELOfmXUYGhGC0czE5M7H6R5cNBUD/BOeaJRgKIAaiWDgT0xM+9Y4d
+icptm+Fhmd2z3HGPCsHLOEco/3FMm74z0ggCypX6IsIxgiscyDv75hYYyej/LA/a
+KK9qxDWqxtXQUOy4uWOapSfT+9ndst2gOKxhAoGAVFcfedCLxummgTtZE91n59pL
+TWTk4GgYpWyv6XbHjYrFW2y18qmn0hmEpO+440So0NmGGDtNnPYNUKY/MPjHScwC
+FoZMFqqnkmshXz0uDx3gMQK2JDmdF+s3VwZq4Rtb3NJ9v4/WMgWftxaUpAm1/aRC
+IHc67mAAez4i8fg2wTQ=
+-----END PRIVATE KEY-----
diff --git a/test/parallel/test-crypto-key-objects.js b/test/parallel/test-crypto-key-objects.js
index 2a3a3ec2f0bff1c581da245e00271da4d756abf5..642e1d6fa01fd8f6e86974a06bc1594aaa6d615b 100644
--- a/test/parallel/test-crypto-key-objects.js
+++ b/test/parallel/test-crypto-key-objects.js
@@ -8,8 +8,6 @@ const assert = require('assert');
const {
createCipheriv,
createDecipheriv,
- createSign,
- createVerify,
createSecretKey,
createPublicKey,
createPrivateKey,
@@ -202,6 +200,13 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem',
});
}
+{
+ // This should not cause a crash: https://github.com/nodejs/node/pull/26786
+ const pem = fixtures.readSync('test_unknown_privkey.pem', 'ascii');
+ const key = createPrivateKey(pem);
+ assert.strictEqual(key.asymmetricKeyType, undefined);
+}
+
[
{ private: fixtures.readSync('test_ed25519_privkey.pem', 'ascii'),
public: fixtures.readSync('test_ed25519_pubkey.pem', 'ascii'),
@@ -281,146 +286,6 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem',
assert.strictEqual(privateKey.type, 'private');
assert.strictEqual(privateKey.asymmetricKeyType, 'dsa');
assert.strictEqual(privateKey.symmetricKeySize, undefined);
-
-}
-
-{
- // Test RSA-PSS.
- {
- // This key pair does not restrict the message digest algorithm or salt
- // length.
- const publicPem = fixtures.readKey('rsa_pss_public_2048.pem');
- const privatePem = fixtures.readKey('rsa_pss_private_2048.pem');
-
- const publicKey = createPublicKey(publicPem);
- const privateKey = createPrivateKey(privatePem);
-
- assert.strictEqual(publicKey.type, 'public');
- assert.strictEqual(publicKey.asymmetricKeyType, 'rsa-pss');
-
- assert.strictEqual(privateKey.type, 'private');
- assert.strictEqual(privateKey.asymmetricKeyType, 'rsa-pss');
-
- for (const key of [privatePem, privateKey]) {
- // Any algorithm should work.
- for (const algo of ['sha1', 'sha256']) {
- // Any salt length should work.
- for (const saltLength of [undefined, 8, 10, 12, 16, 18, 20]) {
- const signature = createSign(algo)
- .update('foo')
- .sign({ key, saltLength });
-
- for (const pkey of [key, publicKey, publicPem]) {
- const okay = createVerify(algo)
- .update('foo')
- .verify({ key: pkey, saltLength }, signature);
-
- assert.ok(okay);
- }
- }
- }
- }
-
- // Exporting the key using PKCS#1 should not work since this would discard
- // any algorithm restrictions.
- common.expectsError(() => {
- publicKey.export({ format: 'pem', type: 'pkcs1' });
- }, {
- code: 'ERR_CRYPTO_INCOMPATIBLE_KEY_OPTIONS'
- });
- }
-
- {
- // This key pair enforces sha256 as the message digest and the MGF1
- // message digest and a salt length of at least 16 bytes.
- const publicPem =
- fixtures.readKey('rsa_pss_public_2048_sha256_sha256_16.pem');
- const privatePem =
- fixtures.readKey('rsa_pss_private_2048_sha256_sha256_16.pem');
-
- const publicKey = createPublicKey(publicPem);
- const privateKey = createPrivateKey(privatePem);
-
- assert.strictEqual(publicKey.type, 'public');
- assert.strictEqual(publicKey.asymmetricKeyType, 'rsa-pss');
-
- assert.strictEqual(privateKey.type, 'private');
- assert.strictEqual(privateKey.asymmetricKeyType, 'rsa-pss');
-
- for (const key of [privatePem, privateKey]) {
- // Signing with anything other than sha256 should fail.
- assert.throws(() => {
- createSign('sha1').sign(key);
- }, /digest not allowed/);
-
- // Signing with salt lengths less than 16 bytes should fail.
- for (const saltLength of [8, 10, 12]) {
- assert.throws(() => {
- createSign('sha1').sign({ key, saltLength });
- }, /pss saltlen too small/);
- }
-
- // Signing with sha256 and appropriate salt lengths should work.
- for (const saltLength of [undefined, 16, 18, 20]) {
- const signature = createSign('sha256')
- .update('foo')
- .sign({ key, saltLength });
-
- for (const pkey of [key, publicKey, publicPem]) {
- const okay = createVerify('sha256')
- .update('foo')
- .verify({ key: pkey, saltLength }, signature);
-
- assert.ok(okay);
- }
- }
- }
- }
-
- {
- // This key enforces sha512 as the message digest and sha256 as the MGF1
- // message digest.
- const publicPem =
- fixtures.readKey('rsa_pss_public_2048_sha512_sha256_20.pem');
- const privatePem =
- fixtures.readKey('rsa_pss_private_2048_sha512_sha256_20.pem');
-
- const publicKey = createPublicKey(publicPem);
- const privateKey = createPrivateKey(privatePem);
-
- assert.strictEqual(publicKey.type, 'public');
- assert.strictEqual(publicKey.asymmetricKeyType, 'rsa-pss');
-
- assert.strictEqual(privateKey.type, 'private');
- assert.strictEqual(privateKey.asymmetricKeyType, 'rsa-pss');
-
- // Node.js usually uses the same hash function for the message and for MGF1.
- // However, when a different MGF1 message digest algorithm has been
- // specified as part of the key, it should automatically switch to that.
- // This behavior is required by sections 3.1 and 3.3 of RFC4055.
- for (const key of [privatePem, privateKey]) {
- // sha256 matches the MGF1 hash function and should be used internally,
- // but it should not be permitted as the main message digest algorithm.
- for (const algo of ['sha1', 'sha256']) {
- assert.throws(() => {
- createSign(algo).sign(key);
- }, /digest not allowed/);
- }
-
- // sha512 should produce a valid signature.
- const signature = createSign('sha512')
- .update('foo')
- .sign(key);
-
- for (const pkey of [key, publicKey, publicPem]) {
- const okay = createVerify('sha512')
- .update('foo')
- .verify(pkey, signature);
-
- assert.ok(okay);
- }
- }
- }
}
{
diff --git a/test/parallel/test-crypto-keygen.js b/test/parallel/test-crypto-keygen.js
index 8c3432e06cb6471b0fa0f042cfb0efdedab603f5..ab86c10ef1ea7e4b582db683b90a375ba6e5d2fc 100644
--- a/test/parallel/test-crypto-keygen.js
+++ b/test/parallel/test-crypto-keygen.js
@@ -6,15 +6,12 @@ if (!common.hasCrypto)
const assert = require('assert');
const {
- constants,
createSign,
createVerify,
generateKeyPair,
generateKeyPairSync,
publicEncrypt,
- privateDecrypt,
- sign,
- verify
+ privateDecrypt
} = require('crypto');
const { promisify } = require('util');
@@ -43,24 +40,13 @@ function testEncryptDecrypt(publicKey, privateKey) {
// Tests that a key pair can be used for signing / verification.
function testSignVerify(publicKey, privateKey) {
- const message = Buffer.from('Hello Node.js world!');
-
- function oldSign(algo, data, key) {
- return createSign(algo).update(data).sign(key);
- }
-
- function oldVerify(algo, data, key, signature) {
- return createVerify(algo).update(data).verify(key, signature);
- }
-
- for (const signFn of [sign, oldSign]) {
- const signature = signFn('SHA256', message, privateKey);
- for (const verifyFn of [verify, oldVerify]) {
- for (const key of [publicKey, privateKey]) {
- const okay = verifyFn('SHA256', message, key, signature);
- assert(okay);
- }
- }
+ const message = 'Hello Node.js world!';
+ const signature = createSign('SHA256').update(message)
+ .sign(privateKey, 'hex');
+ for (const key of [publicKey, privateKey]) {
+ const okay = createVerify('SHA256').update(message)
+ .verify(key, signature, 'hex');
+ assert(okay);
}
}
@@ -265,43 +251,6 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
}));
}
-{
- // Test RSA-PSS.
- generateKeyPair('rsa-pss', {
- modulusLength: 512,
- saltLength: 16,
- hash: 'sha256',
- mgf1Hash: 'sha256'
- }, common.mustCall((err, publicKey, privateKey) => {
- assert.ifError(err);
-
- assert.strictEqual(publicKey.type, 'public');
- assert.strictEqual(publicKey.asymmetricKeyType, 'rsa-pss');
-
- assert.strictEqual(privateKey.type, 'private');
- assert.strictEqual(privateKey.asymmetricKeyType, 'rsa-pss');
-
- // Unlike RSA, RSA-PSS does not allow encryption.
- assert.throws(() => {
- testEncryptDecrypt(publicKey, privateKey);
- }, /operation not supported for this keytype/);
-
- // RSA-PSS also does not permit signing with PKCS1 padding.
- assert.throws(() => {
- testSignVerify({
- key: publicKey,
- padding: constants.RSA_PKCS1_PADDING
- }, {
- key: privateKey,
- padding: constants.RSA_PKCS1_PADDING
- });
- }, /illegal or unsupported padding mode/);
-
- // The padding should correctly default to RSA_PKCS1_PSS_PADDING now.
- testSignVerify(publicKey, privateKey);
- }));
-}
-
{
const privateKeyEncoding = {
type: 'pkcs8',
@@ -606,7 +555,9 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
common.expectsError(() => generateKeyPairSync('rsa2', {}), {
type: TypeError,
code: 'ERR_INVALID_ARG_VALUE',
- message: "The argument 'type' must be a supported key type. Received 'rsa2'"
+ message: "The argument 'type' must be one of " +
+ "'rsa', 'dsa', 'ec', 'ed25519', 'ed448'," +
+ " 'x25519', 'x448'. Received 'rsa2'"
});
}

Просмотреть файл

@ -0,0 +1,24 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Thu, 13 Sep 2018 09:10:02 -0700
Subject: FIXME: use redefined version of internalModuleStat
Instantiate redefined version of the internalModuleStat function
(see lib/common/asar.js in the electron/electron repo). For some reason
this has to be done after the upgrade to the Node.js v8.7.0. `const
internalModuleStat` in the very beginning of the file holds a reference
to a native Node.js implementation of the function.
diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js
index a8d7786d644bc4129d96c63ffe58bd4909496219..6b881d22deef7164cb5c6e0ceb1daff0b8dc5c62 100644
--- a/lib/internal/modules/cjs/loader.js
+++ b/lib/internal/modules/cjs/loader.js
@@ -85,6 +85,8 @@ const relativeResolveCache = Object.create(null);
let requireDepth = 0;
let statCache = null;
function stat(filename) {
+ // FIXME(codebytere): determine why this needs to be done and remove
+ const internalModuleStat = process.binding('fs').internalModuleStat;
filename = path.toNamespacedPath(filename);
if (statCache !== null) {
const result = statCache.get(filename);

Просмотреть файл

@ -0,0 +1,213 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ben Noordhuis <info@bnoordhuis.nl>
Date: Mon, 27 May 2019 14:31:53 +0200
Subject: fsevents: fix file event reporting
Commit 2d2af38 ("fsevents: really watch files with fsevents on macos
10.7+") from last November introduced a regression where events that
were previously reported as UV_RENAME were now reported as UV_CHANGE.
This commit rectifies that.
Fixes: https://github.com/nodejs/node/issues/27869
diff --git a/deps/uv/src/unix/fsevents.c b/deps/uv/src/unix/fsevents.c
index ddacda31fef87eee131fc2ee2ff46cc88be429d9..911023a6562319af5e9e3412ddbfd2ca14f77b05 100644
--- a/deps/uv/src/unix/fsevents.c
+++ b/deps/uv/src/unix/fsevents.c
@@ -49,19 +49,9 @@ void uv__fsevents_loop_delete(uv_loop_t* loop) {
#include <CoreFoundation/CFRunLoop.h>
#include <CoreServices/CoreServices.h>
-/* These are macros to avoid "initializer element is not constant" errors
+/* Macro to avoid "initializer element is not constant" errors
* with old versions of gcc.
*/
-#define kFSEventsModified (kFSEventStreamEventFlagItemFinderInfoMod | \
- kFSEventStreamEventFlagItemModified | \
- kFSEventStreamEventFlagItemInodeMetaMod | \
- kFSEventStreamEventFlagItemChangeOwner | \
- kFSEventStreamEventFlagItemXattrMod)
-
-#define kFSEventsRenamed (kFSEventStreamEventFlagItemCreated | \
- kFSEventStreamEventFlagItemRemoved | \
- kFSEventStreamEventFlagItemRenamed)
-
#define kFSEventsSystem (kFSEventStreamEventFlagUserDropped | \
kFSEventStreamEventFlagKernelDropped | \
kFSEventStreamEventFlagEventIdsWrapped | \
@@ -289,8 +279,6 @@ static void uv__fsevents_event_cb(ConstFSEventStreamRef streamRef,
path--;
len++;
}
- /* Created and Removed seem to be always set, but don't make sense */
- flags &= ~kFSEventsRenamed;
} else {
/* Skip forward slash */
path++;
@@ -311,12 +299,12 @@ static void uv__fsevents_event_cb(ConstFSEventStreamRef streamRef,
memset(event, 0, sizeof(*event));
memcpy(event->path, path, len + 1);
- event->events = UV_RENAME;
+ event->events = UV_CHANGE;
- if (0 == (flags & kFSEventsRenamed)) {
- if (0 != (flags & kFSEventsModified) ||
- 0 == (flags & kFSEventStreamEventFlagItemIsDir))
- event->events = UV_CHANGE;
+ if ((flags & kFSEventStreamEventFlagItemIsDir) ||
+ (flags & kFSEventStreamEventFlagItemRemoved) ||
+ (flags & kFSEventStreamEventFlagItemRenamed)) {
+ event->events = UV_RENAME;
}
QUEUE_INSERT_TAIL(&head, &event->member);
diff --git a/deps/uv/test/test-fs-event.c b/deps/uv/test/test-fs-event.c
index ea34bd63a70625c3e2c60d5a1bbb087c5f0bbb2e..38d722a27ef1a78717726272d54578c734280242 100644
--- a/deps/uv/test/test-fs-event.c
+++ b/deps/uv/test/test-fs-event.c
@@ -62,6 +62,15 @@ static char fs_event_filename[1024];
static int timer_cb_touch_called;
static int timer_cb_exact_called;
+static void expect_filename(const char* path, const char* expected) {
+#if defined(__APPLE__) || defined(_WIN32) || defined(__linux__)
+ ASSERT(0 == strcmp(path, expected));
+#else
+ if (path != NULL)
+ ASSERT(0 == strcmp(path, expected));
+#endif
+}
+
static void fs_event_fail(uv_fs_event_t* handle,
const char* filename,
int events,
@@ -130,11 +139,7 @@ static void fs_event_cb_dir(uv_fs_event_t* handle, const char* filename,
ASSERT(handle == &fs_event);
ASSERT(status == 0);
ASSERT(events == UV_CHANGE);
- #if defined(__APPLE__) || defined(_WIN32) || defined(__linux__)
- ASSERT(strcmp(filename, "file1") == 0);
- #else
- ASSERT(filename == NULL || strcmp(filename, "file1") == 0);
- #endif
+ expect_filename(filename, "file1");
ASSERT(0 == uv_fs_event_stop(handle));
uv_close((uv_handle_t*)handle, close_cb);
}
@@ -312,11 +317,7 @@ static void fs_event_cb_file(uv_fs_event_t* handle, const char* filename,
ASSERT(handle == &fs_event);
ASSERT(status == 0);
ASSERT(events == UV_CHANGE);
- #if defined(__APPLE__) || defined(_WIN32) || defined(__linux__)
- ASSERT(strcmp(filename, "file2") == 0);
- #else
- ASSERT(filename == NULL || strcmp(filename, "file2") == 0);
- #endif
+ expect_filename(filename, "file2");
ASSERT(0 == uv_fs_event_stop(handle));
uv_close((uv_handle_t*)handle, close_cb);
}
@@ -339,11 +340,7 @@ static void fs_event_cb_file_current_dir(uv_fs_event_t* handle,
ASSERT(handle == &fs_event);
ASSERT(status == 0);
ASSERT(events == UV_CHANGE);
- #if defined(__APPLE__) || defined(_WIN32) || defined(__linux__)
- ASSERT(strcmp(filename, "watch_file") == 0);
- #else
- ASSERT(filename == NULL || strcmp(filename, "watch_file") == 0);
- #endif
+ expect_filename(filename, "watch_file");
/* Regression test for SunOS: touch should generate just one event. */
{
@@ -619,6 +616,69 @@ TEST_IMPL(fs_event_watch_file_exact_path) {
return 0;
}
+static void file_remove_cb(uv_fs_event_t* handle,
+ const char* path,
+ int events,
+ int status) {
+ fs_event_cb_called++;
+
+ expect_filename(path, "file1");
+ /* TODO(bnoordhuis) Harmonize the behavior across platforms. Right now
+ * this test merely ensures the status quo doesn't regress.
+ */
+#if defined(_AIX) || defined(__linux__)
+ ASSERT(UV_CHANGE == events);
+#else
+ ASSERT(UV_RENAME == events);
+#endif
+ ASSERT(0 == status);
+
+ uv_close((uv_handle_t*) handle, NULL);
+}
+
+static void file_remove_next(uv_timer_t* handle) {
+ uv_close((uv_handle_t*) handle, NULL);
+ remove("watch_dir/file1");
+}
+
+static void file_remove_start(uv_timer_t* handle) {
+ uv_fs_event_t* watcher;
+ uv_loop_t* loop;
+
+ loop = handle->loop;
+ watcher = handle->data;
+
+ ASSERT(0 == uv_fs_event_init(loop, watcher));
+ ASSERT(0 == uv_fs_event_start(watcher, file_remove_cb, "watch_dir/file1", 0));
+ ASSERT(0 == uv_timer_start(handle, file_remove_next, 50, 0));
+}
+
+TEST_IMPL(fs_event_watch_file_remove) {
+ uv_fs_event_t watcher;
+ uv_timer_t timer;
+ uv_loop_t* loop;
+
+#if defined(__MVS__)
+ RETURN_SKIP("test does not work on this OS");
+#endif
+
+ remove("watch_dir/file1");
+ remove("watch_dir/");
+ create_dir("watch_dir");
+ create_file("watch_dir/file1");
+
+ loop = uv_default_loop();
+ timer.data = &watcher;
+
+ ASSERT(0 == uv_timer_init(loop, &timer));
+ ASSERT(0 == uv_timer_start(&timer, file_remove_start, 500, 0));
+ ASSERT(0 == uv_run(loop, UV_RUN_DEFAULT));
+ ASSERT(1 == fs_event_cb_called);
+
+ MAKE_VALGRIND_HAPPY();
+ return 0;
+}
+
TEST_IMPL(fs_event_watch_file_twice) {
#if defined(NO_FS_EVENTS)
RETURN_SKIP(NO_FS_EVENTS);
diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h
index 8886b07c8a74736208d5614257f832f59d79633a..3e758a1d2cbe104a691d362411770006d1494bae 100644
--- a/deps/uv/test/test-list.h
+++ b/deps/uv/test/test-list.h
@@ -333,6 +333,7 @@ TEST_DECLARE (fs_event_watch_dir_short_path)
#endif
TEST_DECLARE (fs_event_watch_file)
TEST_DECLARE (fs_event_watch_file_exact_path)
+TEST_DECLARE (fs_event_watch_file_remove)
TEST_DECLARE (fs_event_watch_file_twice)
TEST_DECLARE (fs_event_watch_file_current_dir)
#ifdef _WIN32
@@ -920,6 +921,7 @@ TASK_LIST_START
#endif
TEST_ENTRY (fs_event_watch_file)
TEST_ENTRY (fs_event_watch_file_exact_path)
+ TEST_ENTRY (fs_event_watch_file_remove)
TEST_ENTRY (fs_event_watch_file_twice)
TEST_ENTRY (fs_event_watch_file_current_dir)
#ifdef _WIN32

Просмотреть файл

@ -0,0 +1,22 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cheng Zhao <zcbenz@gmail.com>
Date: Tue, 4 Jun 2019 17:42:11 +0900
Subject: Inherit ELECTRON_CRASHPAD_PIPE_NAME in child process
This is required for crashReporter to work correctly in node process.
diff --git a/lib/child_process.js b/lib/child_process.js
index 8934a90f8d5c0557689eba80512802a38a8072ec..a60985173b5b1b7937cd32e69f5cce2128b5af66 100644
--- a/lib/child_process.js
+++ b/lib/child_process.js
@@ -108,6 +108,10 @@ function fork(modulePath /* , args, options */) {
options.env.ELECTRON_RUN_AS_NODE = 1;
+ if (process.platform === 'win32') {
+ options.env.ELECTRON_CRASHPAD_PIPE_NAME = process.env.ELECTRON_CRASHPAD_PIPE_NAME;
+ }
+
if (!options.execPath && process.type && process.platform == 'darwin') {
options.execPath = process.helperExecPath;
}

Просмотреть файл

@ -0,0 +1,26 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cheng Zhao <zcbenz@gmail.com>
Date: Sun, 14 Apr 2013 15:54:46 +0800
Subject: Make Module.globalPaths a reference.
We need to hack the search paths of the require function so we can
load libraries from embedded applications without modifications of
node's module code.
(cherry picked from commit 76ba048c37588ee32636817fa7b8dffc64330cbf)
diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js
index 2798032fd962398cfd267709644c890377f61b59..1fb197c6c220693b6124f44fbe4b02dd97bcfc4f 100644
--- a/lib/internal/modules/cjs/loader.js
+++ b/lib/internal/modules/cjs/loader.js
@@ -914,8 +914,8 @@ Module._initPaths = function() {
modulePaths = paths;
- // Clone as a shallow copy, for introspection.
- Module.globalPaths = modulePaths.slice(0);
+ // clone as a shallow copy, for introspection.
+ Module.globalPaths = modulePaths;
};
Module._preloadModules = function(requests) {

Просмотреть файл

@ -0,0 +1,40 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cheng Zhao <zcbenz@gmail.com>
Date: Sun, 27 Mar 2016 14:42:26 +0900
Subject: Pass all globals through "require"
(cherry picked from commit 7d015419cb7a0ecfe6728431a4ed2056cd411d62)
diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js
index 1fb197c6c220693b6124f44fbe4b02dd97bcfc4f..a8d7786d644bc4129d96c63ffe58bd4909496219 100644
--- a/lib/internal/modules/cjs/loader.js
+++ b/lib/internal/modules/cjs/loader.js
@@ -71,6 +71,13 @@ const {
CHAR_COLON
} = require('internal/constants');
+// Store the "global" variable from global scope into a local scope, so we can
+// still reference it from this file even after we deleted the "global" variable
+// from the global scope.
+const localGlobal = global;
+// Do the same for "Buffer".
+const localBuffer = Buffer;
+
const isWindows = process.platform === 'win32';
const relativeResolveCache = Object.create(null);
@@ -769,10 +776,12 @@ Module.prototype._compile = function(content, filename) {
if (requireDepth === 0) statCache = new Map();
if (inspectorWrapper) {
result = inspectorWrapper(compiledWrapper, thisValue, exports,
- require, module, filename, dirname);
+ require, module, filename, dirname, process,
+ localGlobal, localBuffer);
} else {
result = compiledWrapper.call(thisValue, exports, require, module,
- filename, dirname);
+ filename, dirname, process, localGlobal,
+ localBuffer);
}
if (requireDepth === 0) statCache = null;
return result;

Просмотреть файл

@ -0,0 +1,62 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <sattard@slack-corp.com>
Date: Mon, 22 Apr 2019 13:23:37 -0700
Subject: refactor: allow embedder overriding of internal FS calls
diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js
index 1cdf79dfaa9aecc4ac3bcb05212514929b80603d..6f096ff3abce7d4b08a174a159217a9ac012f2b2 100644
--- a/lib/internal/bootstrap/node.js
+++ b/lib/internal/bootstrap/node.js
@@ -65,6 +65,10 @@ if (ownsProcessState) {
);
}
+// NOTE: Electron deletes this references before user code runs so that
+// internalBinding is not leaked to user code
+process.internalBinding = internalBinding;
+
// process.config is serialized config.gypi
process.config = JSON.parse(internalBinding('native_module').config);
diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js
index 6b881d22deef7164cb5c6e0ceb1daff0b8dc5c62..a643a77aec6398acfeae7f2e8e526d60c3b4453c 100644
--- a/lib/internal/modules/cjs/loader.js
+++ b/lib/internal/modules/cjs/loader.js
@@ -31,10 +31,7 @@ const assert = require('internal/assert');
const fs = require('fs');
const internalFS = require('internal/fs/utils');
const path = require('path');
-const {
- internalModuleReadJSON,
- internalModuleStat
-} = internalBinding('fs');
+const internalFsBinding = internalBinding('fs');
const { safeGetenv } = internalBinding('credentials');
const {
makeRequireFunction,
@@ -85,14 +82,12 @@ const relativeResolveCache = Object.create(null);
let requireDepth = 0;
let statCache = null;
function stat(filename) {
- // FIXME(codebytere): determine why this needs to be done and remove
- const internalModuleStat = process.binding('fs').internalModuleStat;
filename = path.toNamespacedPath(filename);
if (statCache !== null) {
const result = statCache.get(filename);
if (result !== undefined) return result;
}
- const result = internalModuleStat(filename);
+ const result = internalFsBinding.internalModuleStat(filename);
if (statCache !== null) statCache.set(filename, result);
return result;
}
@@ -199,7 +194,7 @@ function readPackage(requestPath) {
return entry;
const jsonPath = path.resolve(requestPath, 'package.json');
- const json = internalModuleReadJSON(path.toNamespacedPath(jsonPath));
+ const json = internalFsBinding.internalModuleReadJSON(path.toNamespacedPath(jsonPath));
if (json === undefined) {
return false;

Просмотреть файл

@ -0,0 +1,29 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Mon, 30 Jul 2018 10:30:35 -0700
Subject: refactor: alter child_process.fork to use execute script with
Electron
When forking a child script, we setup a special environment to make the Electron binary run like the upstream node. On Mac, we use the helper app as node binary.
diff --git a/lib/child_process.js b/lib/child_process.js
index 66be7611dc958721aa67603396ac9dcc0b9737b0..8934a90f8d5c0557689eba80512802a38a8072ec 100644
--- a/lib/child_process.js
+++ b/lib/child_process.js
@@ -102,6 +102,16 @@ function fork(modulePath /* , args, options */) {
throw new ERR_CHILD_PROCESS_IPC_REQUIRED('options.stdio');
}
+ if (!options.env) {
+ options.env = Object.create(process.env);
+ }
+
+ options.env.ELECTRON_RUN_AS_NODE = 1;
+
+ if (!options.execPath && process.type && process.platform == 'darwin') {
+ options.execPath = process.helperExecPath;
+ }
+
options.execPath = options.execPath || process.execPath;
options.shell = false;

Просмотреть файл

@ -0,0 +1,32 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <sattard@slack-corp.com>
Date: Thu, 4 Jul 2019 15:28:22 -0700
Subject: src: add missing option parser template for the DebugOptionsParser
This allows embedders to run `node::options_parser::Parse` for a
`node::DebugOptions`.
This can be removed once https://github.com/nodejs/node/pull/28543 is
merged and available in our node fork.
diff --git a/src/node_options.cc b/src/node_options.cc
index b619aca56f88f44a00aaa1d38e95ab1e55b63ad0..4689a3e405be5fbbe3bb960940b48276669d8bc6 100644
--- a/src/node_options.cc
+++ b/src/node_options.cc
@@ -217,6 +217,16 @@ class PerProcessOptionsParser : public OptionsParser<PerProcessOptions> {
#if HAVE_INSPECTOR
const DebugOptionsParser _dop_instance{};
const EnvironmentOptionsParser _eop_instance{_dop_instance};
+
+template <>
+void Parse(
+ StringVector* const args, StringVector* const exec_args,
+ StringVector* const v8_args,
+ DebugOptions* const options,
+ OptionEnvvarSettings required_env_settings, StringVector* const errors) {
+ _dop_instance.Parse(
+ args, exec_args, v8_args, options, required_env_settings, errors);
+}
#else
const EnvironmentOptionsParser _eop_instance{};
#endif // HAVE_INSPECTOR

Просмотреть файл

@ -0,0 +1,20 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Nitish Sakhawalkar <nitsakh@icloud.com>
Date: Thu, 4 Apr 2019 16:45:35 -0700
Subject: src: Disable NODE_USE_V8_PLATFORM in node_options
Electron does not set NODE_USE_V8_PLATFORM. If inspector is enabled when NODE_USE_V8_PLATFORM is false, then there's an error. We want to ignore that, use our own v8 platform but still use the node inspector
diff --git a/src/node_options.cc b/src/node_options.cc
index a85b650d2e75b5c7dd8018d9af76ac88d0d741aa..b619aca56f88f44a00aaa1d38e95ab1e55b63ad0 100644
--- a/src/node_options.cc
+++ b/src/node_options.cc
@@ -33,7 +33,7 @@ DebugOptions& DebugOptions::operator=(const DebugOptions&) = default;
DebugOptions& DebugOptions::operator=(DebugOptions&&) = default;
void DebugOptions::CheckOptions(std::vector<std::string>* errors) {
-#if !NODE_USE_V8_PLATFORM
+#if 0
if (inspector_enabled) {
errors->push_back("Inspector is not available when Node is compiled "
"--without-v8-platform");

Просмотреть файл

@ -0,0 +1,47 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <sattard@slack-corp.com>
Date: Thu, 4 Jul 2019 15:57:09 -0700
Subject: src: expose MaybeInitializeContext to allow existing contexts
Splits the node.js specific tweak intialization of NewContext into a new
helper MaybeInitializeContext so that embedders with existing contexts
can still use them in a node Environment now that primordials are
initialized and required so early.
diff --git a/src/api/environment.cc b/src/api/environment.cc
index bfc849d362a18bc7cd499584a439a1d29f0864f8..e313460a13ced7e7a9982db6f4a988699ec56111 100644
--- a/src/api/environment.cc
+++ b/src/api/environment.cc
@@ -362,6 +362,13 @@ Local<Context> NewContext(Isolate* isolate,
Local<ObjectTemplate> object_template) {
auto context = Context::New(isolate, nullptr, object_template);
if (context.IsEmpty()) return context;
+
+ return MaybeInitializeContext(context, object_template);
+}
+
+Local<Context> MaybeInitializeContext(Local<Context> context,
+ Local<ObjectTemplate> object_template) {
+ Isolate* isolate = context->GetIsolate();
HandleScope handle_scope(isolate);
context->SetEmbedderData(ContextEmbedderIndex::kAllowWasmCodeGeneration,
diff --git a/src/node.h b/src/node.h
index dca89e212c89df19d0b97d748e3649392fec000c..de007ed97a52c17cff8b8917d25f2383d5bbae6a 100644
--- a/src/node.h
+++ b/src/node.h
@@ -303,6 +303,14 @@ NODE_EXTERN v8::Local<v8::Context> NewContext(
v8::Local<v8::ObjectTemplate> object_template =
v8::Local<v8::ObjectTemplate>());
+// Runs Node.js-specific tweaks on an already constructed context
+// This is not dead code, it is exposed for embedders so that they
+// can construct their own context and still use it in a node Environment.
+NODE_EXTERN v8::Local<v8::Context> MaybeInitializeContext(
+ v8::Local<v8::Context> context,
+ v8::Local<v8::ObjectTemplate> object_template =
+ v8::Local<v8::ObjectTemplate>());
+
// If `platform` is passed, it will be used to register new Worker instances.
// It can be `nullptr`, in which case creating new Workers inside of
// Environments that use this `IsolateData` will not work.

Просмотреть файл

@ -0,0 +1,19 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <samuel.r.attard@gmail.com>
Date: Sun, 2 Jun 2019 00:27:17 -0700
Subject: src: only run preloadModules if the preload array is not empty
diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js
index 2351268eae27af7ae759dccb599c071e146ece71..a998b095fb067ab6ca35cc276ac6a9a7c38dcf30 100644
--- a/lib/internal/bootstrap/pre_execution.js
+++ b/lib/internal/bootstrap/pre_execution.js
@@ -386,7 +386,7 @@ function initializeFrozenIntrinsics() {
function loadPreloadModules() {
// For user code, we preload modules if `-r` is passed
const preloadModules = getOptionValue('--require');
- if (preloadModules) {
+ if (preloadModules && preloadModules.length > 0) {
const {
_preloadModules
} = require('internal/modules/cjs/loader');

Просмотреть файл

@ -0,0 +1,21 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <samuel.r.attard@gmail.com>
Date: Sun, 2 Jun 2019 12:43:59 -0700
Subject: src: read break_node_first_line from the inspect options
There are cases where the debug_options() on the env are
different to the options that were passed into inspector::Agent.
diff --git a/src/node.cc b/src/node.cc
index eff0be6fef1274cd4210811bdc377702ca70b2a2..c0a8bdd28a403b399f2766e40b2fe90e76fca849 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -271,7 +271,7 @@ MaybeLocal<Value> RunBootstrapping(Environment* env) {
env->set_primordials(primordials.As<Object>());
#if HAVE_INSPECTOR
- if (env->options()->debug_options().break_node_first_line) {
+ if (env->inspector_agent()->options().break_node_first_line) {
env->inspector_agent()->PauseOnNextJavascriptStatement(
"Break at bootstrap");
}

Просмотреть файл

@ -0,0 +1,20 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Nitish Sakhawalkar <nitsakh@icloud.com>
Date: Thu, 7 Mar 2019 17:02:13 -0800
Subject: src: use CHECK(false) in switch default case
Porting https://github.com/nodejs/node/pull/26502
diff --git a/src/node_crypto.cc b/src/node_crypto.cc
index 2143117ec3b782ce307bcb3c7183594bc233d5e8..f232c9571ae5452996955b7bc149da663ee7d56a 100644
--- a/src/node_crypto.cc
+++ b/src/node_crypto.cc
@@ -3476,7 +3476,7 @@ static ManagedEVPPKey GetPublicOrPrivateKeyFromJs(
is_public = false;
break;
default:
- UNREACHABLE("Invalid key encoding type");
+ CHECK(false);
}
if (is_public) {