mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 18:25:13 +08:00
Keep scheme-only and option-gated builtin exposure rules in the JavaScript loader. Leave option registration and code-cache categorization with their native owners. Assisted-by: Codex Signed-off-by: sjungwon03 <sjungwon03@gmail.com> PR-URL: https://github.com/nodejs/node/pull/66292 Refs: https://github.com/nodejs/node/pull/65418 Refs: https://github.com/nodejs/node/pull/65964 Refs: https://github.com/nodejs/node/pull/65920 Refs: https://github.com/nodejs/node/pull/65840 Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
const {
|
|
Error,
|
|
StringPrototypeStartsWith,
|
|
globalThis,
|
|
} = primordials;
|
|
|
|
process.emitWarning(
|
|
'These APIs are for internal testing only. Do not use them.',
|
|
'internal/test/binding');
|
|
|
|
function filteredInternalBinding(id) {
|
|
// Disallows internal bindings with names that start with 'internal_only'
|
|
// which means it should not be exposed to users even with
|
|
// --expose-internals.
|
|
if (StringPrototypeStartsWith(id, 'internal_only')) {
|
|
// This code is only intended for internal errors and is not documented.
|
|
// Do not use the normal error system.
|
|
// eslint-disable-next-line no-restricted-syntax
|
|
const error = new Error(`No such binding: ${id}`);
|
|
error.code = 'ERR_INVALID_MODULE';
|
|
throw error;
|
|
}
|
|
return internalBinding(id);
|
|
}
|
|
|
|
if (module.isPreloading) {
|
|
globalThis.internalBinding = filteredInternalBinding;
|
|
globalThis.primordials = primordials;
|
|
}
|
|
|
|
module.exports = {
|
|
internalBinding: filteredInternalBinding,
|
|
primordials,
|
|
getBuiltinModulePolicies() {
|
|
return require('internal/bootstrap/realm').BuiltinModule.getBuiltinModulePolicies();
|
|
},
|
|
};
|