From 8ac93492ce21c5e5b56ea24fc696a9ebb4cb2d64 Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Fri, 19 Jul 2024 10:16:55 -0400 Subject: [PATCH] lib: disallow destructuring internalBinding output --- lib/eslint.config_partial.mjs | 14 ++++ lib/fs.js | 94 ++++++++++++------------- lib/tty.js | 8 +-- lib/v8.js | 19 ++--- lib/vm.js | 27 +++---- typings/globals.d.ts | 6 ++ typings/internalBinding/contextify.d.ts | 8 +++ typings/internalBinding/heap_utils.d.ts | 4 ++ typings/internalBinding/symbols.d.ts | 2 + typings/internalBinding/tty.d.ts | 15 ++++ 10 files changed, 115 insertions(+), 82 deletions(-) create mode 100644 typings/internalBinding/contextify.d.ts create mode 100644 typings/internalBinding/heap_utils.d.ts create mode 100644 typings/internalBinding/tty.d.ts diff --git a/lib/eslint.config_partial.mjs b/lib/eslint.config_partial.mjs index a51fafafaf1592..5ee36c31c76107 100644 --- a/lib/eslint.config_partial.mjs +++ b/lib/eslint.config_partial.mjs @@ -509,4 +509,18 @@ export default [ ], }, }, + { + files: [ + 'lib/*.js', + ], + rules: { + 'no-restricted-syntax': [ + ...noRestrictedSyntax, + { + selector: 'VariableDeclarator:has(.init.callee[name="internalBinding"]) > ObjectPattern', + message: 'We should not destructure internalBinding objects', + }, + ], + }, + }, ]; diff --git a/lib/fs.js b/lib/fs.js index 2119554c0e72c1..30837eb26d903a 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -43,7 +43,7 @@ const { uncurryThis, } = primordials; -const { fs: constants } = internalBinding('constants'); +const constants = internalBinding('constants'); const { S_IFIFO, S_IFLNK, @@ -56,7 +56,7 @@ const { X_OK, O_WRONLY, O_SYMLINK, -} = constants; +} = constants.fs; const pathModule = require('path'); const { isAbsolute } = pathModule; @@ -79,10 +79,6 @@ const { }, } = require('internal/errors'); -const { - FSReqCallback, - statValues, -} = binding; const { toPathIfFileURL } = require('internal/url'); const { customPromisifyArgs: kCustomPromisifyArgsSymbol, @@ -227,7 +223,7 @@ function access(path, mode, callback) { path = getValidatedPath(path); callback = makeCallback(callback); - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = callback; binding.access(path, mode, req); } @@ -301,7 +297,7 @@ function readFileAfterOpen(err, fd) { context.fd = fd; - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = readFileAfterStat; req.context = context; binding.fstat(fd, false, req); @@ -381,7 +377,7 @@ function readFile(path, options, callback) { return; const flagsNumber = stringToFlags(options.flag, 'options.flag'); - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.context = context; req.oncomplete = readFileAfterOpen; binding.open(getValidatedPath(path), flagsNumber, 0o666, req); @@ -504,7 +500,7 @@ function close(fd, callback = defaultCloseCallback) { if (callback !== defaultCloseCallback) callback = makeCallback(callback); - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = callback; binding.close(fd, req); } @@ -544,7 +540,7 @@ function open(path, flags, mode, callback) { const flagsNumber = stringToFlags(flags); callback = makeCallback(callback); - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = callback; binding.open(path, flagsNumber, mode, req); @@ -671,7 +667,7 @@ function read(fd, buffer, offsetOrOptions, length, position, callback) { callback(err, bytesRead || 0, buffer); } - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = wrapper; binding.read(fd, buffer, offset, length, position, req); @@ -763,7 +759,7 @@ function readv(fd, buffers, position, callback) { callback ||= position; validateFunction(callback, 'cb'); - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = wrapper; if (typeof position !== 'number') @@ -840,7 +836,7 @@ function write(fd, buffer, offsetOrOptions, length, position, callback) { position = null; validateOffsetLengthWrite(offset, length, buffer.byteLength); - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = wrapper; binding.writeBuffer(fd, buffer, offset, length, position, req); return; @@ -863,7 +859,7 @@ function write(fd, buffer, offsetOrOptions, length, position, callback) { callback = position; validateFunction(callback, 'cb'); - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = wrapper; binding.writeString(fd, str, offset, length, req); } @@ -952,7 +948,7 @@ function writev(fd, buffers, position, callback) { return; } - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = wrapper; if (typeof position !== 'number') @@ -999,7 +995,7 @@ function writevSync(fd, buffers, position) { */ function rename(oldPath, newPath, callback) { callback = makeCallback(callback); - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = callback; binding.rename( getValidatedPath(oldPath, 'oldPath'), @@ -1047,7 +1043,7 @@ function truncate(path, len, callback) { validateFunction(callback, 'cb'); fs.open(path, 'r+', (er, fd) => { if (er) return callback(er); - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = function oncomplete(er) { fs.close(fd, (er2) => { callback(aggregateTwoErrors(er2, er)); @@ -1097,7 +1093,7 @@ function ftruncate(fd, len = 0, callback) { len = MathMax(0, len); callback = makeCallback(callback); - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = callback; binding.ftruncate(fd, len, req); } @@ -1154,7 +1150,7 @@ function rmdir(path, options, callback) { true, (err, options) => { if (err === false) { - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = callback; binding.rmdir(path, req); return; @@ -1168,7 +1164,7 @@ function rmdir(path, options, callback) { }); } else { validateRmdirOptions(options); - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = callback; binding.rmdir(path, req); } @@ -1255,7 +1251,7 @@ function rmSync(path, options) { * @returns {void} */ function fdatasync(fd, callback) { - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = makeCallback(callback); binding.fdatasync(fd, req); } @@ -1279,7 +1275,7 @@ function fdatasyncSync(fd) { * @returns {void} */ function fsync(fd, callback) { - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = makeCallback(callback); binding.fsync(fd, req); } @@ -1322,7 +1318,7 @@ function mkdir(path, options, callback) { validateBoolean(recursive, 'options.recursive'); - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = callback; binding.mkdir( path, @@ -1454,7 +1450,7 @@ function readdir(path, options, callback) { return; } - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); if (!options.withFileTypes) { req.oncomplete = callback; } else { @@ -1522,7 +1518,7 @@ function fstat(fd, options = { bigint: false }, callback) { } callback = makeStatsCallback(callback); - const req = new FSReqCallback(options.bigint); + const req = new binding.FSReqCallback(options.bigint); req.oncomplete = callback; binding.fstat(fd, options.bigint, req); } @@ -1550,7 +1546,7 @@ function lstat(path, options = { bigint: false }, callback) { return; } - const req = new FSReqCallback(options.bigint); + const req = new binding.FSReqCallback(options.bigint); req.oncomplete = callback; binding.lstat(path, options.bigint, req); } @@ -1572,7 +1568,7 @@ function stat(path, options = { bigint: false }, callback) { } callback = makeStatsCallback(callback); - const req = new FSReqCallback(options.bigint); + const req = new binding.FSReqCallback(options.bigint); req.oncomplete = callback; binding.stat(getValidatedPath(path), options.bigint, req); } @@ -1584,7 +1580,7 @@ function statfs(path, options = { bigint: false }, callback) { } validateFunction(callback, 'cb'); path = getValidatedPath(path); - const req = new FSReqCallback(options.bigint); + const req = new binding.FSReqCallback(options.bigint); req.oncomplete = (err, stats) => { if (err) { return callback(err); @@ -1680,7 +1676,7 @@ function statfsSync(path, options = { bigint: false }) { function readlink(path, options, callback) { callback = makeCallback(typeof options === 'function' ? options : callback); options = getOptions(options); - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = callback; binding.readlink(getValidatedPath(path), options.encoding, req); } @@ -1750,7 +1746,7 @@ function symlink(target, path, type, callback) { resolvedType, path); - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = callback; binding.symlink( destination, @@ -1766,7 +1762,7 @@ function symlink(target, path, type, callback) { const destination = preprocessSymlinkDestination(target, type, path); const flags = stringToSymlinkType(type); - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = callback; binding.symlink(destination, path, flags, req); } @@ -1824,7 +1820,7 @@ function link(existingPath, newPath, callback) { existingPath = getValidatedPath(existingPath, 'existingPath'); newPath = getValidatedPath(newPath, 'newPath'); - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = callback; binding.link(existingPath, newPath, req); @@ -1855,7 +1851,7 @@ function linkSync(existingPath, newPath) { */ function unlink(path, callback) { callback = makeCallback(callback); - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = callback; binding.unlink(getValidatedPath(path), req); } @@ -1885,7 +1881,7 @@ function fchmod(fd, mode, callback) { return; } - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = callback; binding.fchmod(fd, mode, req); } @@ -1961,7 +1957,7 @@ function chmod(path, mode, callback) { mode = parseFileMode(mode, 'mode'); callback = makeCallback(callback); - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = callback; binding.chmod(path, mode, req); } @@ -1992,7 +1988,7 @@ function lchown(path, uid, gid, callback) { path = getValidatedPath(path); validateInteger(uid, 'uid', -1, kMaxUserId); validateInteger(gid, 'gid', -1, kMaxUserId); - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = callback; binding.lchown(path, uid, gid, req); } @@ -2028,7 +2024,7 @@ function fchown(fd, uid, gid, callback) { return; } - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = callback; binding.fchown(fd, uid, gid, req); } @@ -2065,7 +2061,7 @@ function chown(path, uid, gid, callback) { validateInteger(uid, 'uid', -1, kMaxUserId); validateInteger(gid, 'gid', -1, kMaxUserId); - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = callback; binding.chown(path, uid, gid, req); } @@ -2098,7 +2094,7 @@ function utimes(path, atime, mtime, callback) { callback = makeCallback(callback); path = getValidatedPath(path); - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = callback; binding.utimes( path, @@ -2138,7 +2134,7 @@ function futimes(fd, atime, mtime, callback) { mtime = toUnixTimestamp(mtime, 'mtime'); callback = makeCallback(callback); - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = callback; binding.futimes(fd, atime, mtime, req); } @@ -2173,7 +2169,7 @@ function lutimes(path, atime, mtime, callback) { callback = makeCallback(callback); path = getValidatedPath(path); - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = callback; binding.lutimes( path, @@ -2685,8 +2681,8 @@ function realpathSync(p, options) { // Continue if not a symlink, break if a pipe/socket if (knownHard.has(base) || cache?.get(base) === base) { - if (isFileType(statValues, S_IFIFO) || - isFileType(statValues, S_IFSOCK)) { + if (isFileType(binding.statValues, S_IFIFO) || + isFileType(binding.statValues, S_IFSOCK)) { break; } continue; @@ -2844,8 +2840,8 @@ function realpath(p, options, callback) { // Continue if not a symlink, break if a pipe/socket if (knownHard.has(base)) { - if (isFileType(statValues, S_IFIFO) || - isFileType(statValues, S_IFSOCK)) { + if (isFileType(binding.statValues, S_IFIFO) || + isFileType(binding.statValues, S_IFSOCK)) { return callback(null, encodeRealpathResult(p, options)); } return process.nextTick(LOOP); @@ -2925,7 +2921,7 @@ realpath.native = (path, options, callback) => { callback = makeCallback(callback || options); options = getOptions(options); path = getValidatedPath(path); - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = callback; binding.realpath(path, options.encoding, req); }; @@ -2947,7 +2943,7 @@ function mkdtemp(prefix, options, callback) { prefix = getValidatedPath(prefix, 'prefix'); warnOnNonPortableTemplate(prefix); - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = callback; binding.mkdtemp(prefix, options.encoding, req); } @@ -2985,7 +2981,7 @@ function copyFile(src, dest, mode, callback) { dest = getValidatedPath(dest, 'dest'); callback = makeCallback(callback); - const req = new FSReqCallback(); + const req = new binding.FSReqCallback(); req.oncomplete = callback; binding.copyFile(src, dest, mode, req); } diff --git a/lib/tty.js b/lib/tty.js index 1a3fa5afe53a41..1e540b20c477f9 100644 --- a/lib/tty.js +++ b/lib/tty.js @@ -28,7 +28,7 @@ const { } = primordials; const net = require('net'); -const { TTY, isTTY } = internalBinding('tty_wrap'); +const binding = internalBinding('tty_wrap'); const { ErrnoException, codes: { @@ -46,7 +46,7 @@ let readline; function isatty(fd) { return NumberIsInteger(fd) && fd >= 0 && fd <= 2147483647 && - isTTY(fd); + binding.isTTY(fd); } function ReadStream(fd, options) { @@ -56,7 +56,7 @@ function ReadStream(fd, options) { throw new ERR_INVALID_FD(fd); const ctx = {}; - const tty = new TTY(fd, ctx); + const tty = new binding.TTY(fd, ctx); if (ctx.code !== undefined) { throw new ERR_TTY_INIT_FAILED(ctx); } @@ -93,7 +93,7 @@ function WriteStream(fd) { throw new ERR_INVALID_FD(fd); const ctx = {}; - const tty = new TTY(fd, ctx); + const tty = new binding.TTY(fd, ctx); if (ctx.code !== undefined) { throw new ERR_TTY_INIT_FAILED(ctx); } diff --git a/lib/v8.js b/lib/v8.js index b687d8709c99a0..ad625855c87654 100644 --- a/lib/v8.js +++ b/lib/v8.js @@ -35,10 +35,8 @@ const { const { Buffer } = require('buffer'); const { validateString, validateUint32 } = require('internal/validators'); -const { - Serializer, - Deserializer, -} = internalBinding('serdes'); +const serdesBinding = internalBinding('serdes'); +const { Serializer, Deserializer } = serdesBinding; const { namespace: startupSnapshot, } = require('internal/v8/startup_snapshot'); @@ -49,14 +47,11 @@ if (internalBinding('config').hasInspector) { } const assert = require('internal/assert'); -const { copy } = internalBinding('buffer'); +const bufferBinding = internalBinding('buffer'); const { inspect } = require('internal/util/inspect'); const { FastBuffer } = require('internal/buffer'); const { getValidatedPath } = require('internal/fs/utils'); -const { - createHeapSnapshotStream, - triggerHeapSnapshot, -} = internalBinding('heap_utils'); +const heapUtilsBinding = internalBinding('heap_utils'); const { HeapSnapshotStream, getHeapSnapshotOptions, @@ -79,7 +74,7 @@ function writeHeapSnapshot(filename, options) { filename = getValidatedPath(filename); } const optionArray = getHeapSnapshotOptions(options); - return triggerHeapSnapshot(filename, optionArray); + return heapUtilsBinding.triggerHeapSnapshot(filename, optionArray); } /** @@ -93,7 +88,7 @@ function writeHeapSnapshot(filename, options) { */ function getHeapSnapshot(options) { const optionArray = getHeapSnapshotOptions(options); - const handle = createHeapSnapshotStream(optionArray); + const handle = heapUtilsBinding.createHeapSnapshotStream(optionArray); assert(handle); return new HeapSnapshotStream(handle); } @@ -368,7 +363,7 @@ class DefaultDeserializer extends Deserializer { } // Copy to an aligned buffer first. const buffer_copy = Buffer.allocUnsafe(byteLength); - copy(this.buffer, buffer_copy, 0, byteOffset, byteOffset + byteLength); + bufferBinding.copy(this.buffer, buffer_copy, 0, byteOffset, byteOffset + byteLength); return new ctor(buffer_copy.buffer, buffer_copy.byteOffset, byteLength / BYTES_PER_ELEMENT); diff --git a/lib/vm.js b/lib/vm.js index e1ad4e30c33b66..d26f3579f1854c 100644 --- a/lib/vm.js +++ b/lib/vm.js @@ -29,12 +29,7 @@ const { Symbol, } = primordials; -const { - ContextifyScript, - makeContext, - constants, - measureMemory: _measureMemory, -} = internalBinding('contextify'); +const contextifyBinding = internalBinding('contextify'); const { ERR_CONTEXT_NOT_INITIALIZED, ERR_INVALID_ARG_TYPE, @@ -63,9 +58,7 @@ const { isContext: _isContext, registerImportModuleDynamically, } = require('internal/vm'); -const { - vm_dynamic_import_main_context_default, -} = internalBinding('symbols'); +const symbolsBinding = internalBinding('symbols'); const kParsingContext = Symbol('script parsing context'); /** @@ -80,7 +73,7 @@ function isContext(object) { return _isContext(object); } -class Script extends ContextifyScript { +class Script extends contextifyBinding.ContextifyScript { constructor(code, options = kEmptyObject) { code = `${code}`; if (typeof options === 'string') { @@ -258,7 +251,7 @@ function createContext(contextObject = {}, options = kEmptyObject) { const hostDefinedOptionId = getHostDefinedOptionId(importModuleDynamically, name); - makeContext(contextObject, name, origin, strings, wasm, microtaskQueue, hostDefinedOptionId); + contextifyBinding.makeContext(contextObject, name, origin, strings, wasm, microtaskQueue, hostDefinedOptionId); // Register the context scope callback after the context was initialized. registerImportModuleDynamically(contextObject, importModuleDynamically); return contextObject; @@ -368,13 +361,13 @@ function compileFunction(code, params, options = kEmptyObject) { } const measureMemoryModes = { - summary: constants.measureMemory.mode.SUMMARY, - detailed: constants.measureMemory.mode.DETAILED, + summary: contextifyBinding.constants.measureMemory.mode.SUMMARY, + detailed: contextifyBinding.constants.measureMemory.mode.DETAILED, }; const measureMemoryExecutions = { - default: constants.measureMemory.execution.DEFAULT, - eager: constants.measureMemory.execution.EAGER, + default: contextifyBinding.constants.measureMemory.execution.DEFAULT, + eager: contextifyBinding.constants.measureMemory.execution.EAGER, }; function measureMemory(options = kEmptyObject) { @@ -383,7 +376,7 @@ function measureMemory(options = kEmptyObject) { const { mode = 'summary', execution = 'default' } = options; validateOneOf(mode, 'options.mode', ['summary', 'detailed']); validateOneOf(execution, 'options.execution', ['default', 'eager']); - const result = _measureMemory(measureMemoryModes[mode], + const result = contextifyBinding.measureMemory(measureMemoryModes[mode], measureMemoryExecutions[execution]); if (result === undefined) { return PromiseReject(new ERR_CONTEXT_NOT_INITIALIZED()); @@ -393,7 +386,7 @@ function measureMemory(options = kEmptyObject) { const vmConstants = { __proto__: null, - USE_MAIN_CONTEXT_DEFAULT_LOADER: vm_dynamic_import_main_context_default, + USE_MAIN_CONTEXT_DEFAULT_LOADER: symbolsBinding.vm_dynamic_import_main_context_default, }; ObjectFreeze(vmConstants); diff --git a/typings/globals.d.ts b/typings/globals.d.ts index e2721c7c480371..d43d28b5794503 100644 --- a/typings/globals.d.ts +++ b/typings/globals.d.ts @@ -1,7 +1,9 @@ import {AsyncWrapBinding} from "./internalBinding/async_wrap"; import {BlobBinding} from "./internalBinding/blob"; import {ConfigBinding} from "./internalBinding/config"; +import {ContextifyBinding} from "./internalBinding/contextify"; import {ConstantsBinding} from "./internalBinding/constants"; +import {HeapUtilsBinding} from "./internalBinding/heap_utils"; import {HttpParserBinding} from "./internalBinding/http_parser"; import {FsBinding} from "./internalBinding/fs"; import {FsDirBinding} from "./internalBinding/fs_dir"; @@ -11,6 +13,7 @@ import {OSBinding} from "./internalBinding/os"; import {SerdesBinding} from "./internalBinding/serdes"; import {SymbolsBinding} from "./internalBinding/symbols"; import {TimersBinding} from "./internalBinding/timers"; +import {TTYBinding} from "./internalBinding/tty"; import {TypesBinding} from "./internalBinding/types"; import {URLBinding} from "./internalBinding/url"; import {UtilBinding} from "./internalBinding/util"; @@ -35,8 +38,10 @@ interface InternalBindingMap { blob: BlobBinding; config: ConfigBinding; constants: ConstantsBinding; + contextify: ContextifyBinding; fs: FsBinding; fs_dir: FsDirBinding; + heap_utils: HeapUtilsBinding; http_parser: HttpParserBinding; messaging: MessagingBinding; modules: ModulesBinding; @@ -45,6 +50,7 @@ interface InternalBindingMap { serdes: SerdesBinding; symbols: SymbolsBinding; timers: TimersBinding; + tty: TTYBinding; types: TypesBinding; url: URLBinding; util: UtilBinding; diff --git a/typings/internalBinding/contextify.d.ts b/typings/internalBinding/contextify.d.ts new file mode 100644 index 00000000000000..dcc9f044b88a97 --- /dev/null +++ b/typings/internalBinding/contextify.d.ts @@ -0,0 +1,8 @@ +export interface ContextifyBinding { + constants: { + measureMemory: Record; + } + measureMemory(mode: string, execution: string): number | undefined; + makeContext(contextObject: unknown, name: string, origin: string, strings: boolean, wasm: boolean, microtaskQueue: boolean, hostDefinedOptionId: string): void; + ContextifyContext: new (code: string, filename?: string, lineOffset?: number, columnOffset?: number, cachedData?: string, produceCachedData?: boolean, parsingContext?: unknown, hostDefinedOptionId?: string) => unknown; +} diff --git a/typings/internalBinding/heap_utils.d.ts b/typings/internalBinding/heap_utils.d.ts new file mode 100644 index 00000000000000..cb7272b73e89e8 --- /dev/null +++ b/typings/internalBinding/heap_utils.d.ts @@ -0,0 +1,4 @@ +export interface HeapUtilsBinding { + createHeapSnapshotStream(options: string[]): unknown; + triggerHeapSnapshot(filename: string, options: string[]): string; +} diff --git a/typings/internalBinding/symbols.d.ts b/typings/internalBinding/symbols.d.ts index 96310970d5cdee..084ea7ef031807 100644 --- a/typings/internalBinding/symbols.d.ts +++ b/typings/internalBinding/symbols.d.ts @@ -9,6 +9,7 @@ export const oninit_symbol: unique symbol; export const owner_symbol: unique symbol; export const onpskexchange_symbol: unique symbol; export const trigger_async_id_symbol: unique symbol; +export const vm_dynamic_import_main_context_default: unique symbol; export interface SymbolsBinding { async_id_symbol: typeof async_id_symbol; @@ -22,4 +23,5 @@ export interface SymbolsBinding { owner_symbol: typeof owner_symbol; onpskexchange_symbol: typeof onpskexchange_symbol; trigger_async_id_symbol: typeof trigger_async_id_symbol; + vm_dynamic_import_main_context_default: typeof vm_dynamic_import_main_context_default; } diff --git a/typings/internalBinding/tty.d.ts b/typings/internalBinding/tty.d.ts new file mode 100644 index 00000000000000..3a47d9ee6a93ec --- /dev/null +++ b/typings/internalBinding/tty.d.ts @@ -0,0 +1,15 @@ +declare namespace InternalTTYBinding { + interface TTYContext { + code?: number; + message?: string; + } + + class TTY { + constructor(fd: number, ctx: TTYContext); + } +} + +export interface TTYBinding { + isTTY(fd: number): boolean; + TTY: typeof InternalTTYBinding.TTY; +}