2018-11-04 20:52:50 +00:00
|
|
|
'use strict';
|
|
|
|
|
2024-04-21 16:53:08 +00:00
|
|
|
const {
|
2024-05-02 22:57:03 +00:00
|
|
|
getCLIOptionsValues,
|
|
|
|
getCLIOptionsInfo,
|
2021-10-07 04:03:10 +00:00
|
|
|
getEmbedderOptions: getEmbedderOptionsFromBinding,
|
2021-08-13 02:03:25 +00:00
|
|
|
} = internalBinding('options');
|
2018-11-04 20:52:50 +00:00
|
|
|
|
2020-04-18 18:25:04 +00:00
|
|
|
let warnOnAllowUnauthorized = true;
|
|
|
|
|
2024-05-02 22:57:03 +00:00
|
|
|
let optionsDict;
|
|
|
|
let cliInfo;
|
2021-10-07 04:03:10 +00:00
|
|
|
let embedderOptions;
|
2021-06-10 15:23:31 +00:00
|
|
|
|
2024-05-02 22:57:03 +00:00
|
|
|
// getCLIOptionsValues() would serialize the option values from C++ land.
|
2021-06-10 15:23:31 +00:00
|
|
|
// It would error if the values are queried before bootstrap is
|
|
|
|
// complete so that we don't accidentally include runtime-dependent
|
|
|
|
// states into a runtime-independent snapshot.
|
2021-10-07 04:03:10 +00:00
|
|
|
function getCLIOptionsFromBinding() {
|
2024-09-24 19:48:15 +00:00
|
|
|
return optionsDict ??= getCLIOptionsValues();
|
2021-06-10 15:23:31 +00:00
|
|
|
}
|
|
|
|
|
2024-05-02 22:57:03 +00:00
|
|
|
function getCLIOptionsInfoFromBinding() {
|
2024-09-24 19:48:15 +00:00
|
|
|
return cliInfo ??= getCLIOptionsInfo();
|
2021-06-10 15:23:31 +00:00
|
|
|
}
|
|
|
|
|
2021-10-07 04:03:10 +00:00
|
|
|
function getEmbedderOptions() {
|
2024-09-24 19:48:15 +00:00
|
|
|
return embedderOptions ??= getEmbedderOptionsFromBinding();
|
2021-10-07 04:03:10 +00:00
|
|
|
}
|
|
|
|
|
2021-06-11 03:28:27 +00:00
|
|
|
function refreshOptions() {
|
2024-05-02 22:57:03 +00:00
|
|
|
optionsDict = undefined;
|
2021-06-11 03:28:27 +00:00
|
|
|
}
|
|
|
|
|
2021-06-13 10:46:35 +00:00
|
|
|
function getOptionValue(optionName) {
|
2024-09-24 19:48:15 +00:00
|
|
|
return getCLIOptionsFromBinding()[optionName];
|
2018-11-04 20:52:50 +00:00
|
|
|
}
|
|
|
|
|
2020-04-18 18:25:04 +00:00
|
|
|
function getAllowUnauthorized() {
|
|
|
|
const allowUnauthorized = process.env.NODE_TLS_REJECT_UNAUTHORIZED === '0';
|
|
|
|
|
|
|
|
if (allowUnauthorized && warnOnAllowUnauthorized) {
|
|
|
|
warnOnAllowUnauthorized = false;
|
|
|
|
process.emitWarning(
|
|
|
|
'Setting the NODE_TLS_REJECT_UNAUTHORIZED ' +
|
|
|
|
'environment variable to \'0\' makes TLS connections ' +
|
|
|
|
'and HTTPS requests insecure by disabling ' +
|
|
|
|
'certificate verification.');
|
|
|
|
}
|
|
|
|
return allowUnauthorized;
|
|
|
|
}
|
|
|
|
|
2018-11-04 20:52:50 +00:00
|
|
|
module.exports = {
|
2024-05-02 22:57:03 +00:00
|
|
|
getCLIOptionsInfo: getCLIOptionsInfoFromBinding,
|
2020-04-18 18:25:04 +00:00
|
|
|
getOptionValue,
|
|
|
|
getAllowUnauthorized,
|
2021-06-11 03:28:27 +00:00
|
|
|
getEmbedderOptions,
|
2023-02-26 10:34:02 +00:00
|
|
|
refreshOptions,
|
2018-11-04 20:52:50 +00:00
|
|
|
};
|