From a234e067a5dc7837602df3fb5489e826920cc65a Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Tue, 8 Oct 2024 00:34:31 -0700 Subject: [PATCH] Make .get() ignore Object.prototype instead of using getOwn (#14322) --- src/bun.js/api/BunObject.zig | 32 ++++----- src/bun.js/api/JSBundler.zig | 52 +++++++-------- src/bun.js/api/JSTranspiler.zig | 46 ++++++------- src/bun.js/api/bun/socket.zig | 26 ++++---- src/bun.js/api/bun/subprocess.zig | 34 +++++----- src/bun.js/api/bun/udp_socket.zig | 16 ++--- src/bun.js/api/ffi.zig | 10 +-- src/bun.js/api/filesystem_router.zig | 10 +-- src/bun.js/api/glob.zig | 12 ++-- src/bun.js/api/server.zig | 92 +++++++++++++------------- src/bun.js/base.zig | 4 +- src/bun.js/bindings/ObjectBindings.cpp | 76 +++++++++++++++++++++ src/bun.js/bindings/ObjectBindings.h | 16 +++++ src/bun.js/bindings/bindings.cpp | 10 +-- src/bun.js/modules/NodeModuleModule.h | 5 -- src/bun.js/webcore.zig | 8 +-- src/bun.js/webcore/blob.zig | 2 +- src/bun.js/webcore/streams.zig | 2 +- src/bundler.zig | 8 +-- src/css/values/color_js.zig | 6 +- src/dns.zig | 10 +-- 21 files changed, 283 insertions(+), 194 deletions(-) create mode 100644 src/bun.js/bindings/ObjectBindings.cpp create mode 100644 src/bun.js/bindings/ObjectBindings.h diff --git a/src/bun.js/api/BunObject.zig b/src/bun.js/api/BunObject.zig index 242d1ae1c1c468..84d6f8208eebc3 100644 --- a/src/bun.js/api/BunObject.zig +++ b/src/bun.js/api/BunObject.zig @@ -329,11 +329,11 @@ pub fn braces( if (arguments.nextEat()) |opts_val| { if (opts_val.isObject()) { if (comptime bun.Environment.allow_assert) { - if (opts_val.getOwnTruthy(globalThis, "tokenize")) |tokenize_val| { + if (opts_val.getTruthy(globalThis, "tokenize")) |tokenize_val| { tokenize = if (tokenize_val.isBoolean()) tokenize_val.asBoolean() else false; } - if (opts_val.getOwnTruthy(globalThis, "parse")) |tokenize_val| { + if (opts_val.getTruthy(globalThis, "parse")) |tokenize_val| { parse = if (tokenize_val.isBoolean()) tokenize_val.asBoolean() else false; } } @@ -461,11 +461,11 @@ pub fn which( if (arguments.nextEat()) |arg| { if (!arg.isEmptyOrUndefinedOrNull() and arg.isObject()) { - if (arg.getOwn(globalThis, "PATH")) |str_| { + if (arg.get(globalThis, "PATH")) |str_| { path_str = str_.toSlice(globalThis, globalThis.bunVM().allocator); } - if (arg.getOwn(globalThis, "cwd")) |str_| { + if (arg.get(globalThis, "cwd")) |str_| { cwd_str = str_.toSlice(globalThis, globalThis.bunVM().allocator); } } @@ -514,7 +514,7 @@ pub fn inspect( const arg1 = arguments[1]; if (arg1.isObject()) { - if (arg1.getOwnTruthy(globalThis, "depth")) |opt| { + if (arg1.getTruthy(globalThis, "depth")) |opt| { if (opt.isInt32()) { const arg = opt.toInt32(); if (arg < 0) { @@ -779,7 +779,7 @@ pub fn openInEditor( if (arguments.nextEat()) |opts| { if (!opts.isUndefinedOrNull()) { - if (opts.getOwnTruthy(globalThis, "editor")) |editor_val| { + if (opts.getTruthy(globalThis, "editor")) |editor_val| { var sliced = editor_val.toSlice(globalThis, arguments.arena.allocator()); const prev_name = edit.name; @@ -799,11 +799,11 @@ pub fn openInEditor( } } - if (opts.getOwnTruthy(globalThis, "line")) |line_| { + if (opts.getTruthy(globalThis, "line")) |line_| { line = line_.toSlice(globalThis, arguments.arena.allocator()).slice(); } - if (opts.getOwnTruthy(globalThis, "column")) |column_| { + if (opts.getTruthy(globalThis, "column")) |column_| { column = column_.toSlice(globalThis, arguments.arena.allocator()).slice(); } } @@ -1711,7 +1711,7 @@ pub const Crypto = struct { pub fn fromJS(globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) ?Value { if (value.isObject()) { - if (value.getOwnTruthy(globalObject, "algorithm")) |algorithm_value| { + if (value.getTruthy(globalObject, "algorithm")) |algorithm_value| { if (!algorithm_value.isString()) { globalObject.throwInvalidArgumentType("hash", "algorithm", "string"); return null; @@ -1728,7 +1728,7 @@ pub const Crypto = struct { .bcrypt = PasswordObject.Algorithm.Value.bcrpyt_default, }; - if (value.getOwnTruthy(globalObject, "cost")) |rounds_value| { + if (value.getTruthy(globalObject, "cost")) |rounds_value| { if (!rounds_value.isNumber()) { globalObject.throwInvalidArgumentType("hash", "cost", "number"); return null; @@ -1749,7 +1749,7 @@ pub const Crypto = struct { inline .argon2id, .argon2d, .argon2i => |tag| { var argon = Algorithm.Argon2Params{}; - if (value.getOwnTruthy(globalObject, "timeCost")) |time_value| { + if (value.getTruthy(globalObject, "timeCost")) |time_value| { if (!time_value.isNumber()) { globalObject.throwInvalidArgumentType("hash", "timeCost", "number"); return null; @@ -1765,7 +1765,7 @@ pub const Crypto = struct { argon.time_cost = @as(u32, @intCast(time_cost)); } - if (value.getOwnTruthy(globalObject, "memoryCost")) |memory_value| { + if (value.getTruthy(globalObject, "memoryCost")) |memory_value| { if (!memory_value.isNumber()) { globalObject.throwInvalidArgumentType("hash", "memoryCost", "number"); return null; @@ -4599,11 +4599,11 @@ fn stringWidth(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) JSC var ambiguous_as_wide = false; if (options_object.isObject()) { - if (options_object.getOwnTruthy(globalObject, "countAnsiEscapeCodes")) |count_ansi_escapes_value| { + if (options_object.getTruthy(globalObject, "countAnsiEscapeCodes")) |count_ansi_escapes_value| { if (count_ansi_escapes_value.isBoolean()) count_ansi_escapes = count_ansi_escapes_value.toBoolean(); } - if (options_object.getOwnTruthy(globalObject, "ambiguousIsNarrow")) |ambiguous_is_narrow| { + if (options_object.getTruthy(globalObject, "ambiguousIsNarrow")) |ambiguous_is_narrow| { if (ambiguous_is_narrow.isBoolean()) ambiguous_as_wide = !ambiguous_is_narrow.toBoolean(); } @@ -4784,7 +4784,7 @@ pub const JSZlib = struct { library = .zlib; } - if (options_val.getOwnTruthy(globalThis, "library")) |library_value| { + if (options_val.getTruthy(globalThis, "library")) |library_value| { if (!library_value.isString()) { globalThis.throwInvalidArguments("Expected library to be a string", .{}); return .zero; @@ -4911,7 +4911,7 @@ pub const JSZlib = struct { library = .zlib; } - if (options_val.getOwnTruthy(globalThis, "library")) |library_value| { + if (options_val.getTruthy(globalThis, "library")) |library_value| { if (!library_value.isString()) { globalThis.throwInvalidArguments("Expected library to be a string", .{}); return .zero; diff --git a/src/bun.js/api/JSBundler.zig b/src/bun.js/api/JSBundler.zig index 08af5dae854d0a..557e45ee0c8beb 100644 --- a/src/bun.js/api/JSBundler.zig +++ b/src/bun.js/api/JSBundler.zig @@ -109,7 +109,7 @@ pub const JSBundler = struct { return error.JSError; } - if (plugin.getOwnOptional(globalThis, "name", ZigString.Slice) catch null) |slice| { + if (plugin.getOptional(globalThis, "name", ZigString.Slice) catch null) |slice| { defer slice.deinit(); if (slice.len == 0) { globalThis.throwInvalidArguments("Expected plugin to have a non-empty name", .{}); @@ -153,13 +153,13 @@ pub const JSBundler = struct { } } - if (config.getOwnTruthy(globalThis, "macros")) |macros_flag| { + if (config.getTruthy(globalThis, "macros")) |macros_flag| { if (!macros_flag.coerce(bool, globalThis)) { this.no_macros = true; } } - if (try config.getOwnOptional(globalThis, "bytecode", bool)) |bytecode| { + if (try config.getOptional(globalThis, "bytecode", bool)) |bytecode| { this.bytecode = bytecode; if (bytecode) { @@ -169,7 +169,7 @@ pub const JSBundler = struct { } } - if (try config.getOwnOptionalEnum(globalThis, "target", options.Target)) |target| { + if (try config.getOptionalEnum(globalThis, "target", options.Target)) |target| { this.target = target; if (target != .bun and this.bytecode) { @@ -179,18 +179,18 @@ pub const JSBundler = struct { } var has_out_dir = false; - if (try config.getOwnOptional(globalThis, "outdir", ZigString.Slice)) |slice| { + if (try config.getOptional(globalThis, "outdir", ZigString.Slice)) |slice| { defer slice.deinit(); try this.outdir.appendSliceExact(slice.slice()); has_out_dir = true; } - if (try config.getOwnOptional(globalThis, "banner", ZigString.Slice)) |slice| { + if (try config.getOptional(globalThis, "banner", ZigString.Slice)) |slice| { defer slice.deinit(); try this.banner.appendSliceExact(slice.slice()); } - if (config.getOwnTruthy(globalThis, "sourcemap")) |source_map_js| { + if (config.getTruthy(globalThis, "sourcemap")) |source_map_js| { if (bun.FeatureFlags.breaking_changes_1_2 and config.isBoolean()) { if (source_map_js == .true) { this.source_map = if (has_out_dir) @@ -207,11 +207,11 @@ pub const JSBundler = struct { } } - if (try config.getOwnOptionalEnum(globalThis, "packages", options.PackagesOption)) |packages| { + if (try config.getOptionalEnum(globalThis, "packages", options.PackagesOption)) |packages| { this.packages = packages; } - if (try config.getOwnOptionalEnum(globalThis, "format", options.Format)) |format| { + if (try config.getOptionalEnum(globalThis, "format", options.Format)) |format| { this.format = format; if (this.bytecode and format != .cjs) { @@ -220,28 +220,28 @@ pub const JSBundler = struct { } } - // if (try config.getOwnOptional(globalThis, "hot", bool)) |hot| { + // if (try config.getOptional(globalThis, "hot", bool)) |hot| { // this.hot = hot; // } - if (try config.getOwnOptional(globalThis, "splitting", bool)) |hot| { + if (try config.getOptional(globalThis, "splitting", bool)) |hot| { this.code_splitting = hot; } - if (config.getOwnTruthy(globalThis, "minify")) |hot| { + if (config.getTruthy(globalThis, "minify")) |hot| { if (hot.isBoolean()) { const value = hot.coerce(bool, globalThis); this.minify.whitespace = value; this.minify.syntax = value; this.minify.identifiers = value; } else if (hot.isObject()) { - if (try hot.getOwnOptional(globalThis, "whitespace", bool)) |whitespace| { + if (try hot.getOptional(globalThis, "whitespace", bool)) |whitespace| { this.minify.whitespace = whitespace; } - if (try hot.getOwnOptional(globalThis, "syntax", bool)) |syntax| { + if (try hot.getOptional(globalThis, "syntax", bool)) |syntax| { this.minify.syntax = syntax; } - if (try hot.getOwnOptional(globalThis, "identifiers", bool)) |syntax| { + if (try hot.getOptional(globalThis, "identifiers", bool)) |syntax| { this.minify.identifiers = syntax; } } else { @@ -265,19 +265,19 @@ pub const JSBundler = struct { return error.JSError; } - if (config.getOwnTruthy(globalThis, "emitDCEAnnotations")) |flag| { + if (config.getTruthy(globalThis, "emitDCEAnnotations")) |flag| { if (flag.coerce(bool, globalThis)) { this.emit_dce_annotations = true; } } - if (config.getOwnTruthy(globalThis, "ignoreDCEAnnotations")) |flag| { + if (config.getTruthy(globalThis, "ignoreDCEAnnotations")) |flag| { if (flag.coerce(bool, globalThis)) { this.ignore_dce_annotations = true; } } - if (config.getOwnTruthy(globalThis, "conditions")) |conditions_value| { + if (config.getTruthy(globalThis, "conditions")) |conditions_value| { if (conditions_value.isString()) { var slice = conditions_value.toSliceOrNull(globalThis) orelse { globalThis.throwInvalidArguments("Expected conditions to be an array of strings", .{}); @@ -303,7 +303,7 @@ pub const JSBundler = struct { { const path: ZigString.Slice = brk: { - if (try config.getOwnOptional(globalThis, "root", ZigString.Slice)) |slice| { + if (try config.getOptional(globalThis, "root", ZigString.Slice)) |slice| { break :brk slice; } @@ -344,21 +344,21 @@ pub const JSBundler = struct { } } - // if (try config.getOwnOptional(globalThis, "dir", ZigString.Slice)) |slice| { + // if (try config.getOptional(globalThis, "dir", ZigString.Slice)) |slice| { // defer slice.deinit(); // this.appendSliceExact(slice.slice()) catch unreachable; // } else { // this.appendSliceExact(globalThis.bunVM().bundler.fs.top_level_dir) catch unreachable; // } - if (try config.getOwnOptional(globalThis, "publicPath", ZigString.Slice)) |slice| { + if (try config.getOptional(globalThis, "publicPath", ZigString.Slice)) |slice| { defer slice.deinit(); try this.public_path.appendSliceExact(slice.slice()); } - if (config.getOwnTruthy(globalThis, "naming")) |naming| { + if (config.getTruthy(globalThis, "naming")) |naming| { if (naming.isString()) { - if (try config.getOwnOptional(globalThis, "naming", ZigString.Slice)) |slice| { + if (try config.getOptional(globalThis, "naming", ZigString.Slice)) |slice| { defer slice.deinit(); if (!strings.hasPrefixComptime(slice.slice(), "./")) { try this.names.owned_entry_point.appendSliceExact("./"); @@ -367,7 +367,7 @@ pub const JSBundler = struct { this.names.entry_point.data = this.names.owned_entry_point.list.items; } } else if (naming.isObject()) { - if (try naming.getOwnOptional(globalThis, "entry", ZigString.Slice)) |slice| { + if (try naming.getOptional(globalThis, "entry", ZigString.Slice)) |slice| { defer slice.deinit(); if (!strings.hasPrefixComptime(slice.slice(), "./")) { try this.names.owned_entry_point.appendSliceExact("./"); @@ -376,7 +376,7 @@ pub const JSBundler = struct { this.names.entry_point.data = this.names.owned_entry_point.list.items; } - if (try naming.getOwnOptional(globalThis, "chunk", ZigString.Slice)) |slice| { + if (try naming.getOptional(globalThis, "chunk", ZigString.Slice)) |slice| { defer slice.deinit(); if (!strings.hasPrefixComptime(slice.slice(), "./")) { try this.names.owned_chunk.appendSliceExact("./"); @@ -385,7 +385,7 @@ pub const JSBundler = struct { this.names.chunk.data = this.names.owned_chunk.list.items; } - if (try naming.getOwnOptional(globalThis, "asset", ZigString.Slice)) |slice| { + if (try naming.getOptional(globalThis, "asset", ZigString.Slice)) |slice| { defer slice.deinit(); if (!strings.hasPrefixComptime(slice.slice(), "./")) { try this.names.owned_asset.appendSliceExact("./"); diff --git a/src/bun.js/api/JSTranspiler.zig b/src/bun.js/api/JSTranspiler.zig index cdc8c3e1c6d36e..2308ebc5a30b40 100644 --- a/src/bun.js/api/JSTranspiler.zig +++ b/src/bun.js/api/JSTranspiler.zig @@ -329,7 +329,7 @@ fn transformOptionsFromJSC(globalObject: JSC.C.JSContextRef, temp_allocator: std return transpiler; } - if (object.getOwnTruthy(globalObject, "define")) |define| { + if (object.getTruthy(globalObject, "define")) |define| { define: { if (define.isUndefinedOrNull()) { break :define; @@ -378,7 +378,7 @@ fn transformOptionsFromJSC(globalObject: JSC.C.JSContextRef, temp_allocator: std } } - if (object.getOwn(globalThis, "external")) |external| { + if (object.get(globalThis, "external")) |external| { external: { if (external.isUndefinedOrNull()) break :external; @@ -418,7 +418,7 @@ fn transformOptionsFromJSC(globalObject: JSC.C.JSContextRef, temp_allocator: std } } - if (object.getOwn(globalThis, "loader")) |loader| { + if (object.get(globalThis, "loader")) |loader| { if (Loader.fromJS(globalThis, loader, exception)) |resolved| { if (!resolved.isJavaScriptLike()) { JSC.throwInvalidArguments("only JavaScript-like loaders supported for now", .{}, globalObject, exception); @@ -433,7 +433,7 @@ fn transformOptionsFromJSC(globalObject: JSC.C.JSContextRef, temp_allocator: std } } - if (object.getOwn(globalThis, "target")) |target| { + if (object.get(globalThis, "target")) |target| { if (Target.fromJS(globalThis, target, exception)) |resolved| { transpiler.transform.target = resolved.toAPI(); } @@ -443,7 +443,7 @@ fn transformOptionsFromJSC(globalObject: JSC.C.JSContextRef, temp_allocator: std } } - if (object.getOwn(globalThis, "tsconfig")) |tsconfig| { + if (object.get(globalThis, "tsconfig")) |tsconfig| { tsconfig: { if (tsconfig.isUndefinedOrNull()) break :tsconfig; const kind = tsconfig.jsType(); @@ -482,7 +482,7 @@ fn transformOptionsFromJSC(globalObject: JSC.C.JSContextRef, temp_allocator: std else => false, }; - if (object.getOwnTruthy(globalThis, "macro")) |macros| { + if (object.getTruthy(globalThis, "macro")) |macros| { macros: { if (macros.isUndefinedOrNull()) break :macros; if (macros.isBoolean()) { @@ -517,39 +517,39 @@ fn transformOptionsFromJSC(globalObject: JSC.C.JSContextRef, temp_allocator: std } } - if (object.getOwnOptional(globalThis, "autoImportJSX", bool) catch return transpiler) |flag| { + if (object.getOptional(globalThis, "autoImportJSX", bool) catch return transpiler) |flag| { transpiler.runtime.auto_import_jsx = flag; } - if (object.getOwnOptional(globalThis, "allowBunRuntime", bool) catch return transpiler) |flag| { + if (object.getOptional(globalThis, "allowBunRuntime", bool) catch return transpiler) |flag| { transpiler.runtime.allow_runtime = flag; } - if (object.getOwnOptional(globalThis, "inline", bool) catch return transpiler) |flag| { + if (object.getOptional(globalThis, "inline", bool) catch return transpiler) |flag| { transpiler.runtime.inlining = flag; } - if (object.getOwnOptional(globalThis, "minifyWhitespace", bool) catch return transpiler) |flag| { + if (object.getOptional(globalThis, "minifyWhitespace", bool) catch return transpiler) |flag| { transpiler.minify_whitespace = flag; } - if (object.getOwnOptional(globalThis, "deadCodeElimination", bool) catch return transpiler) |flag| { + if (object.getOptional(globalThis, "deadCodeElimination", bool) catch return transpiler) |flag| { transpiler.dead_code_elimination = flag; } - if (object.getOwnTruthy(globalThis, "minify")) |hot| { + if (object.getTruthy(globalThis, "minify")) |hot| { if (hot.isBoolean()) { transpiler.minify_whitespace = hot.coerce(bool, globalThis); transpiler.minify_syntax = transpiler.minify_whitespace; transpiler.minify_identifiers = transpiler.minify_syntax; } else if (hot.isObject()) { - if (try hot.getOwnOptional(globalThis, "whitespace", bool)) |whitespace| { + if (try hot.getOptional(globalThis, "whitespace", bool)) |whitespace| { transpiler.minify_whitespace = whitespace; } - if (try hot.getOwnOptional(globalThis, "syntax", bool)) |syntax| { + if (try hot.getOptional(globalThis, "syntax", bool)) |syntax| { transpiler.minify_syntax = syntax; } - if (try hot.getOwnOptional(globalThis, "identifiers", bool)) |syntax| { + if (try hot.getOptional(globalThis, "identifiers", bool)) |syntax| { transpiler.minify_identifiers = syntax; } } else { @@ -558,7 +558,7 @@ fn transformOptionsFromJSC(globalObject: JSC.C.JSContextRef, temp_allocator: std } } - if (object.getOwn(globalThis, "sourcemap")) |flag| { + if (object.get(globalThis, "sourcemap")) |flag| { if (flag.isBoolean() or flag.isUndefinedOrNull()) { if (flag.toBoolean()) { transpiler.transform.source_map = .@"inline"; @@ -575,21 +575,21 @@ fn transformOptionsFromJSC(globalObject: JSC.C.JSContextRef, temp_allocator: std } } - if (try object.getOwnOptionalEnum(globalThis, "packages", options.PackagesOption)) |packages| { + if (try object.getOptionalEnum(globalThis, "packages", options.PackagesOption)) |packages| { transpiler.transform.packages = packages.toAPI(); } var tree_shaking: ?bool = null; - if (object.getOwnOptional(globalThis, "treeShaking", bool) catch return transpiler) |treeShaking| { + if (object.getOptional(globalThis, "treeShaking", bool) catch return transpiler) |treeShaking| { tree_shaking = treeShaking; } var trim_unused_imports: ?bool = null; - if (object.getOwnOptional(globalThis, "trimUnusedImports", bool) catch return transpiler) |trimUnusedImports| { + if (object.getOptional(globalThis, "trimUnusedImports", bool) catch return transpiler) |trimUnusedImports| { trim_unused_imports = trimUnusedImports; } - if (object.getOwnTruthy(globalThis, "exports")) |exports| { + if (object.getTruthy(globalThis, "exports")) |exports| { if (!exports.isObject()) { JSC.throwInvalidArguments("exports must be an object", .{}, globalObject, exception); return transpiler; @@ -598,7 +598,7 @@ fn transformOptionsFromJSC(globalObject: JSC.C.JSContextRef, temp_allocator: std var replacements = Runtime.Features.ReplaceableExport.Map{}; errdefer replacements.clearAndFree(bun.default_allocator); - if (exports.getOwnTruthy(globalThis, "eliminate")) |eliminate| { + if (exports.getTruthy(globalThis, "eliminate")) |eliminate| { if (!eliminate.jsType().isArray()) { JSC.throwInvalidArguments("exports.eliminate must be an array", .{}, globalObject, exception); return transpiler; @@ -640,7 +640,7 @@ fn transformOptionsFromJSC(globalObject: JSC.C.JSContextRef, temp_allocator: std } } - if (exports.getOwnTruthy(globalThis, "replace")) |replace| { + if (exports.getTruthy(globalThis, "replace")) |replace| { if (!replace.isObject()) { JSC.throwInvalidArguments("replace must be an object", .{}, globalObject, exception); return transpiler; @@ -717,7 +717,7 @@ fn transformOptionsFromJSC(globalObject: JSC.C.JSContextRef, temp_allocator: std transpiler.runtime.replace_exports = replacements; } - if (object.getOwnTruthy(globalThis, "logLevel")) |logLevel| { + if (object.getTruthy(globalThis, "logLevel")) |logLevel| { if (logger.Log.Level.Map.fromJS(globalObject, logLevel)) |level| { transpiler.log.level = level; } else { diff --git a/src/bun.js/api/bun/socket.zig b/src/bun.js/api/bun/socket.zig index 17220320670b19..d2f1d43c03d801 100644 --- a/src/bun.js/api/bun/socket.zig +++ b/src/bun.js/api/bun/socket.zig @@ -239,7 +239,7 @@ const Handlers = struct { .{ "onHandshake", "handshake" }, }; inline for (pairs) |pair| { - if (opts.getOwnTruthyComptime(globalObject, pair.@"1")) |callback_value| { + if (opts.getTruthyComptime(globalObject, pair.@"1")) |callback_value| { if (!callback_value.isCell() or !callback_value.isCallable(globalObject.vm())) { exception.* = JSC.toInvalidArguments(comptime std.fmt.comptimePrint("Expected \"{s}\" callback to be a function", .{pair.@"1"}), .{}, globalObject).asObjectRef(); return null; @@ -254,7 +254,7 @@ const Handlers = struct { return null; } - if (opts.getOwnTruthy(globalObject, "binaryType")) |binary_type_value| { + if (opts.getTruthy(globalObject, "binaryType")) |binary_type_value| { if (!binary_type_value.isString()) { exception.* = JSC.toInvalidArguments("Expected \"binaryType\" to be a string", .{}, globalObject).asObjectRef(); return null; @@ -341,13 +341,13 @@ pub const SocketConfig = struct { } hostname_or_unix: { - if (opts.getOwnTruthy(globalObject, "fd")) |fd_| { + if (opts.getTruthy(globalObject, "fd")) |fd_| { if (fd_.isNumber()) { break :hostname_or_unix; } } - if (opts.getOwnTruthy(globalObject, "unix")) |unix_socket| { + if (opts.getTruthy(globalObject, "unix")) |unix_socket| { if (!unix_socket.isString()) { exception.* = JSC.toInvalidArguments("Expected \"unix\" to be a string", .{}, globalObject).asObjectRef(); return null; @@ -365,17 +365,17 @@ pub const SocketConfig = struct { } } - if (opts.getOwnTruthy(globalObject, "exclusive")) |_| { + if (opts.getTruthy(globalObject, "exclusive")) |_| { exclusive = true; } - if (opts.getOwnTruthy(globalObject, "hostname") orelse opts.getOwnTruthy(globalObject, "host")) |hostname| { + if (opts.getTruthy(globalObject, "hostname") orelse opts.getTruthy(globalObject, "host")) |hostname| { if (!hostname.isString()) { exception.* = JSC.toInvalidArguments("Expected \"hostname\" to be a string", .{}, globalObject).asObjectRef(); return null; } - var port_value = opts.getOwn(globalObject, "port") orelse JSValue.zero; + var port_value = opts.get(globalObject, "port") orelse JSValue.zero; hostname_or_unix = hostname.getZigString(globalObject).toSlice(bun.default_allocator); if (port_value.isEmptyOrUndefinedOrNull() and hostname_or_unix.len > 0) { @@ -423,7 +423,7 @@ pub const SocketConfig = struct { return null; } - var handlers = Handlers.fromJS(globalObject, opts.getOwn(globalObject, "socket") orelse JSValue.zero, exception) orelse { + var handlers = Handlers.fromJS(globalObject, opts.get(globalObject, "socket") orelse JSValue.zero, exception) orelse { hostname_or_unix.deinit(); return null; }; @@ -542,7 +542,7 @@ pub const Listener = struct { var exception: JSC.C.JSValueRef = null; - const socket_obj = opts.getOwn(globalObject, "socket") orelse { + const socket_obj = opts.get(globalObject, "socket") orelse { globalObject.throw("Expected \"socket\" object", .{}); return .zero; }; @@ -1069,7 +1069,7 @@ pub const Listener = struct { vm.eventLoop().ensureWaker(); var connection: Listener.UnixOrHost = blk: { - if (opts.getOwnTruthy(globalObject, "fd")) |fd_| { + if (opts.getTruthy(globalObject, "fd")) |fd_| { if (fd_.isNumber()) { const fd = fd_.asFileDescriptor(); break :blk .{ .fd = fd }; @@ -2308,7 +2308,7 @@ fn NewSocket(comptime ssl: bool) type { var exception: JSC.C.JSValueRef = null; - const socket_obj = opts.getOwn(globalObject, "socket") orelse { + const socket_obj = opts.get(globalObject, "socket") orelse { globalObject.throw("Expected \"socket\" option", .{}); return .zero; }; @@ -3082,7 +3082,7 @@ fn NewSocket(comptime ssl: bool) type { return .zero; } - const socket_obj = opts.getOwn(globalObject, "socket") orelse { + const socket_obj = opts.get(globalObject, "socket") orelse { globalObject.throw("Expected \"socket\" option", .{}); return .zero; }; @@ -4007,7 +4007,7 @@ pub fn jsUpgradeDuplexToTLS(globalObject: *JSC.JSGlobalObject, callframe: *JSC.C return .zero; } - const socket_obj = opts.getOwn(globalObject, "socket") orelse { + const socket_obj = opts.get(globalObject, "socket") orelse { globalObject.throw("Expected \"socket\" option", .{}); return .zero; }; diff --git a/src/bun.js/api/bun/subprocess.zig b/src/bun.js/api/bun/subprocess.zig index 814eb3d6e9cb06..0488615ee91a05 100644 --- a/src/bun.js/api/bun/subprocess.zig +++ b/src/bun.js/api/bun/subprocess.zig @@ -1745,7 +1745,7 @@ pub const Subprocess = struct { } else if (!args.isObject()) { globalThis.throwInvalidArguments("cmd must be an array", .{}); return .zero; - } else if (args.getOwnTruthy(globalThis, "cmd")) |cmd_value_| { + } else if (args.getTruthy(globalThis, "cmd")) |cmd_value_| { cmd_value = cmd_value_; } else { globalThis.throwInvalidArguments("cmd must be an array", .{}); @@ -1753,7 +1753,7 @@ pub const Subprocess = struct { } if (args.isObject()) { - if (args.getOwnTruthy(globalThis, "argv0")) |argv0_| { + if (args.getTruthy(globalThis, "argv0")) |argv0_| { const argv0_str = argv0_.getZigString(globalThis); if (argv0_str.len > 0) { argv0 = argv0_str.toOwnedSliceZ(allocator) catch { @@ -1764,7 +1764,7 @@ pub const Subprocess = struct { } // need to update `cwd` before searching for executable with `Which.which` - if (args.getOwnTruthy(globalThis, "cwd")) |cwd_| { + if (args.getTruthy(globalThis, "cwd")) |cwd_| { const cwd_str = cwd_.getZigString(globalThis); if (cwd_str.len > 0) { cwd = cwd_str.toOwnedSliceZ(allocator) catch { @@ -1849,10 +1849,10 @@ pub const Subprocess = struct { if (args != .zero and args.isObject()) { // This must run before the stdio parsing happens if (!is_sync) { - if (args.getOwnTruthy(globalThis, "ipc")) |val| { + if (args.getTruthy(globalThis, "ipc")) |val| { if (val.isCell() and val.isCallable(globalThis.vm())) { maybe_ipc_mode = ipc_mode: { - if (args.getOwnTruthy(globalThis, "serialization")) |mode_val| { + if (args.getTruthy(globalThis, "serialization")) |mode_val| { if (mode_val.isString()) { break :ipc_mode IPC.Mode.fromJS(globalThis, mode_val) orelse { if (!globalThis.hasException()) { @@ -1875,7 +1875,7 @@ pub const Subprocess = struct { } } - if (args.getOwnTruthy(globalThis, "signal")) |signal_val| { + if (args.getTruthy(globalThis, "signal")) |signal_val| { if (signal_val.as(JSC.WebCore.AbortSignal)) |signal| { abort_signal = signal.ref(); } else { @@ -1883,7 +1883,7 @@ pub const Subprocess = struct { } } - if (args.getOwnTruthy(globalThis, "onDisconnect")) |onDisconnect_| { + if (args.getTruthy(globalThis, "onDisconnect")) |onDisconnect_| { if (!onDisconnect_.isCell() or !onDisconnect_.isCallable(globalThis.vm())) { globalThis.throwInvalidArguments("onDisconnect must be a function or undefined", .{}); return .zero; @@ -1895,7 +1895,7 @@ pub const Subprocess = struct { onDisconnect_.withAsyncContextIfNeeded(globalThis); } - if (args.getOwnTruthy(globalThis, "onExit")) |onExit_| { + if (args.getTruthy(globalThis, "onExit")) |onExit_| { if (!onExit_.isCell() or !onExit_.isCallable(globalThis.vm())) { globalThis.throwInvalidArguments("onExit must be a function or undefined", .{}); return .zero; @@ -1907,7 +1907,7 @@ pub const Subprocess = struct { onExit_.withAsyncContextIfNeeded(globalThis); } - if (args.getOwnTruthy(globalThis, "env")) |object| { + if (args.getTruthy(globalThis, "env")) |object| { if (!object.isObject()) { globalThis.throwInvalidArguments("env must be an object", .{}); return .zero; @@ -1923,7 +1923,7 @@ pub const Subprocess = struct { }; env_array = envp_managed.moveToUnmanaged(); } - if (args.getOwn(globalThis, "stdio")) |stdio_val| { + if (args.get(globalThis, "stdio")) |stdio_val| { if (!stdio_val.isEmptyOrUndefinedOrNull()) { if (stdio_val.jsType().isArray()) { var stdio_iter = stdio_val.arrayIterator(globalThis); @@ -1962,44 +1962,44 @@ pub const Subprocess = struct { } } } else { - if (args.getOwn(globalThis, "stdin")) |value| { + if (args.get(globalThis, "stdin")) |value| { if (!stdio[0].extract(globalThis, 0, value)) return .zero; } - if (args.getOwn(globalThis, "stderr")) |value| { + if (args.get(globalThis, "stderr")) |value| { if (!stdio[2].extract(globalThis, 2, value)) return .zero; } - if (args.getOwn(globalThis, "stdout")) |value| { + if (args.get(globalThis, "stdout")) |value| { if (!stdio[1].extract(globalThis, 1, value)) return .zero; } } if (comptime !is_sync) { - if (args.getOwn(globalThis, "lazy")) |lazy_val| { + if (args.get(globalThis, "lazy")) |lazy_val| { if (lazy_val.isBoolean()) { lazy = lazy_val.toBoolean(); } } } - if (args.getOwn(globalThis, "detached")) |detached_val| { + if (args.get(globalThis, "detached")) |detached_val| { if (detached_val.isBoolean()) { detached = detached_val.toBoolean(); } } if (Environment.isWindows) { - if (args.getOwn(globalThis, "windowsHide")) |val| { + if (args.get(globalThis, "windowsHide")) |val| { if (val.isBoolean()) { windows_hide = val.asBoolean(); } } - if (args.getOwn(globalThis, "windowsVerbatimArguments")) |val| { + if (args.get(globalThis, "windowsVerbatimArguments")) |val| { if (val.isBoolean()) { windows_verbatim_arguments = val.asBoolean(); } diff --git a/src/bun.js/api/bun/udp_socket.zig b/src/bun.js/api/bun/udp_socket.zig index 06caf68275c801..c8252ee664cccc 100644 --- a/src/bun.js/api/bun/udp_socket.zig +++ b/src/bun.js/api/bun/udp_socket.zig @@ -129,7 +129,7 @@ pub const UDPSocketConfig = struct { } const hostname = brk: { - if (options.getOwnTruthy(globalThis, "hostname")) |value| { + if (options.getTruthy(globalThis, "hostname")) |value| { if (!value.isString()) { globalThis.throwInvalidArguments("Expected \"hostname\" to be a string", .{}); return null; @@ -144,7 +144,7 @@ pub const UDPSocketConfig = struct { defer if (globalThis.hasException()) default_allocator.free(hostname); const port: u16 = brk: { - if (options.getOwnTruthy(globalThis, "port")) |value| { + if (options.getTruthy(globalThis, "port")) |value| { const number = value.coerceToInt32(globalThis); if (number < 0 or number > 0xffff) { globalThis.throwInvalidArguments("Expected \"port\" to be an integer between 0 and 65535", .{}); @@ -161,13 +161,13 @@ pub const UDPSocketConfig = struct { .port = port, }; - if (options.getOwnTruthy(globalThis, "socket")) |socket| { + if (options.getTruthy(globalThis, "socket")) |socket| { if (!socket.isObject()) { globalThis.throwInvalidArguments("Expected \"socket\" to be an object", .{}); return null; } - if (options.getOwnTruthy(globalThis, "binaryType")) |value| { + if (options.getTruthy(globalThis, "binaryType")) |value| { if (!value.isString()) { globalThis.throwInvalidArguments("Expected \"socket.binaryType\" to be a string", .{}); return null; @@ -180,7 +180,7 @@ pub const UDPSocketConfig = struct { } inline for (handlers) |handler| { - if (socket.getOwnTruthyComptime(globalThis, handler.@"0")) |value| { + if (socket.getTruthyComptime(globalThis, handler.@"0")) |value| { if (!value.isCell() or !value.isCallable(globalThis.vm())) { globalThis.throwInvalidArguments("Expected \"socket.{s}\" to be a function", .{handler.@"0"}); return null; @@ -198,13 +198,13 @@ pub const UDPSocketConfig = struct { } } - if (options.getOwnTruthy(globalThis, "connect")) |connect| { + if (options.getTruthy(globalThis, "connect")) |connect| { if (!connect.isObject()) { globalThis.throwInvalidArguments("Expected \"connect\" to be an object", .{}); return null; } - const connect_host_js = connect.getOwnTruthy(globalThis, "hostname") orelse { + const connect_host_js = connect.getTruthy(globalThis, "hostname") orelse { globalThis.throwInvalidArguments("Expected \"connect.hostname\" to be a string", .{}); return null; }; @@ -214,7 +214,7 @@ pub const UDPSocketConfig = struct { return null; } - const connect_port_js = connect.getOwnTruthy(globalThis, "port") orelse { + const connect_port_js = connect.getTruthy(globalThis, "port") orelse { globalThis.throwInvalidArguments("Expected \"connect.port\" to be an integer", .{}); return null; }; diff --git a/src/bun.js/api/ffi.zig b/src/bun.js/api/ffi.zig index e0d3a2327dba82..16ffd9407584ec 100644 --- a/src/bun.js/api/ffi.zig +++ b/src/bun.js/api/ffi.zig @@ -655,7 +655,7 @@ pub const FFI = struct { return .zero; } - if (object.getOwnTruthy(globalThis, "flags")) |flags_value| { + if (object.getTruthy(globalThis, "flags")) |flags_value| { if (flags_value.isArray()) { var iter = flags_value.arrayIterator(globalThis); @@ -692,7 +692,7 @@ pub const FFI = struct { return .zero; } - if (object.getOwnTruthy(globalThis, "define")) |define_value| { + if (object.getTruthy(globalThis, "define")) |define_value| { if (define_value.isObject()) { const Iter = JSC.JSPropertyIterator(.{ .include_value = true, .skip_empty_name = true }); var iter = Iter.init(globalThis, define_value); @@ -722,7 +722,7 @@ pub const FFI = struct { return .zero; } - if (object.getOwnTruthy(globalThis, "include")) |include_value| { + if (object.getTruthy(globalThis, "include")) |include_value| { compile_c.include_dirs = StringArray.fromJS(globalThis, include_value, "include"); } @@ -1347,11 +1347,11 @@ pub const FFI = struct { var threadsafe = false; - if (value.getOwnTruthy(global, "threadsafe")) |threadsafe_value| { + if (value.getTruthy(global, "threadsafe")) |threadsafe_value| { threadsafe = threadsafe_value.toBoolean(); } - if (value.getOwnTruthy(global, "returns")) |ret_value| brk: { + if (value.getTruthy(global, "returns")) |ret_value| brk: { if (ret_value.isAnyInt()) { const int = ret_value.toInt32(); switch (int) { diff --git a/src/bun.js/api/filesystem_router.zig b/src/bun.js/api/filesystem_router.zig index a8fa600c079c1e..3083c98bdcae4b 100644 --- a/src/bun.js/api/filesystem_router.zig +++ b/src/bun.js/api/filesystem_router.zig @@ -69,7 +69,7 @@ pub const FileSystemRouter = struct { var asset_prefix_slice: ZigString.Slice = .{}; var out_buf: [bun.MAX_PATH_BYTES * 2]u8 = undefined; - if (argument.getOwn(globalThis, "style")) |style_val| { + if (argument.get(globalThis, "style")) |style_val| { if (!style_val.getZigString(globalThis).eqlComptime("nextjs")) { globalThis.throwInvalidArguments("Only 'nextjs' style is currently implemented", .{}); return null; @@ -79,7 +79,7 @@ pub const FileSystemRouter = struct { return null; } - if (argument.getOwn(globalThis, "dir")) |dir| { + if (argument.get(globalThis, "dir")) |dir| { if (!dir.isString()) { globalThis.throwInvalidArguments("Expected dir to be a string", .{}); return null; @@ -104,7 +104,7 @@ pub const FileSystemRouter = struct { arena.* = bun.ArenaAllocator.init(globalThis.allocator()); const allocator = arena.allocator(); var extensions = std.ArrayList(string).init(allocator); - if (argument.getOwn(globalThis, "fileExtensions")) |file_extensions| { + if (argument.get(globalThis, "fileExtensions")) |file_extensions| { if (!file_extensions.jsType().isArray()) { globalThis.throwInvalidArguments("Expected fileExtensions to be an Array", .{}); origin_str.deinit(); @@ -128,7 +128,7 @@ pub const FileSystemRouter = struct { } } - if (argument.getOwnTruthy(globalThis, "assetPrefix")) |asset_prefix| { + if (argument.getTruthy(globalThis, "assetPrefix")) |asset_prefix| { if (!asset_prefix.isString()) { globalThis.throwInvalidArguments("Expected assetPrefix to be a string", .{}); origin_str.deinit(); @@ -174,7 +174,7 @@ pub const FileSystemRouter = struct { return null; }; - if (argument.getOwn(globalThis, "origin")) |origin| { + if (argument.get(globalThis, "origin")) |origin| { if (!origin.isString()) { globalThis.throwInvalidArguments("Expected origin to be a string", .{}); arena.deinit(); diff --git a/src/bun.js/api/glob.zig b/src/bun.js/api/glob.zig index 5d48b71caa5afb..122aff963b989a 100644 --- a/src/bun.js/api/glob.zig +++ b/src/bun.js/api/glob.zig @@ -120,23 +120,23 @@ const ScanOpts = struct { return null; } - if (optsObj.getOwnTruthy(globalThis, "onlyFiles")) |only_files| { + if (optsObj.getTruthy(globalThis, "onlyFiles")) |only_files| { out.only_files = if (only_files.isBoolean()) only_files.asBoolean() else false; } - if (optsObj.getOwnTruthy(globalThis, "throwErrorOnBrokenSymlink")) |error_on_broken| { + if (optsObj.getTruthy(globalThis, "throwErrorOnBrokenSymlink")) |error_on_broken| { out.error_on_broken_symlinks = if (error_on_broken.isBoolean()) error_on_broken.asBoolean() else false; } - if (optsObj.getOwnTruthy(globalThis, "followSymlinks")) |followSymlinksVal| { + if (optsObj.getTruthy(globalThis, "followSymlinks")) |followSymlinksVal| { out.follow_symlinks = if (followSymlinksVal.isBoolean()) followSymlinksVal.asBoolean() else false; } - if (optsObj.getOwnTruthy(globalThis, "absolute")) |absoluteVal| { + if (optsObj.getTruthy(globalThis, "absolute")) |absoluteVal| { out.absolute = if (absoluteVal.isBoolean()) absoluteVal.asBoolean() else false; } - if (optsObj.getOwnTruthy(globalThis, "cwd")) |cwdVal| { + if (optsObj.getTruthy(globalThis, "cwd")) |cwdVal| { if (!cwdVal.isString()) { globalThis.throw("{s}: invalid `cwd`, not a string", .{fnName}); return null; @@ -152,7 +152,7 @@ const ScanOpts = struct { } } - if (optsObj.getOwnTruthy(globalThis, "dot")) |dot| { + if (optsObj.getTruthy(globalThis, "dot")) |dot| { out.dot = if (dot.isBoolean()) dot.asBoolean() else false; } diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig index be5e09ad249e96..755a6a9d4c5d1b 100644 --- a/src/bun.js/api/server.zig +++ b/src/bun.js/api/server.zig @@ -764,7 +764,7 @@ pub const ServerConfig = struct { result.reject_unauthorized = @intFromBool(vm.getTLSRejectUnauthorized()); // Required - if (obj.getOwnTruthy(global, "keyFile")) |key_file_name| { + if (obj.getTruthy(global, "keyFile")) |key_file_name| { var sliced = key_file_name.toSlice(global, bun.default_allocator); defer sliced.deinit(); if (sliced.len > 0) { @@ -780,7 +780,7 @@ pub const ServerConfig = struct { } } - if (obj.getOwnTruthy(global, "key")) |js_obj| { + if (obj.getTruthy(global, "key")) |js_obj| { if (js_obj.jsType().isArray()) { const count = js_obj.getLength(global); if (count > 0) { @@ -863,7 +863,7 @@ pub const ServerConfig = struct { } } - if (obj.getOwnTruthy(global, "certFile")) |cert_file_name| { + if (obj.getTruthy(global, "certFile")) |cert_file_name| { var sliced = cert_file_name.toSlice(global, bun.default_allocator); defer sliced.deinit(); if (sliced.len > 0) { @@ -878,7 +878,7 @@ pub const ServerConfig = struct { } } - if (obj.getOwnTruthy(global, "ALPNProtocols")) |protocols| { + if (obj.getTruthy(global, "ALPNProtocols")) |protocols| { if (JSC.Node.StringOrBuffer.fromJS(global, arena.allocator(), protocols)) |sb| { defer sb.deinit(); const sliced = sb.slice(); @@ -896,7 +896,7 @@ pub const ServerConfig = struct { } } - if (obj.getOwnTruthy(global, "cert")) |js_obj| { + if (obj.getTruthy(global, "cert")) |js_obj| { if (js_obj.jsType().isArray()) { const count = js_obj.getLength(global); if (count > 0) { @@ -979,7 +979,7 @@ pub const ServerConfig = struct { } } - if (obj.getOwnTruthy(global, "requestCert")) |request_cert| { + if (obj.getTruthy(global, "requestCert")) |request_cert| { if (request_cert.isBoolean()) { result.request_cert = if (request_cert.asBoolean()) 1 else 0; any = true; @@ -990,7 +990,7 @@ pub const ServerConfig = struct { } } - if (obj.getOwnTruthy(global, "rejectUnauthorized")) |reject_unauthorized| { + if (obj.getTruthy(global, "rejectUnauthorized")) |reject_unauthorized| { if (reject_unauthorized.isBoolean()) { result.reject_unauthorized = if (reject_unauthorized.asBoolean()) 1 else 0; any = true; @@ -1001,7 +1001,7 @@ pub const ServerConfig = struct { } } - if (obj.getOwnTruthy(global, "ciphers")) |ssl_ciphers| { + if (obj.getTruthy(global, "ciphers")) |ssl_ciphers| { var sliced = ssl_ciphers.toSlice(global, bun.default_allocator); defer sliced.deinit(); if (sliced.len > 0) { @@ -1011,7 +1011,7 @@ pub const ServerConfig = struct { } } - if (obj.getOwnTruthy(global, "serverName") orelse obj.getOwnTruthy(global, "servername")) |server_name| { + if (obj.getTruthy(global, "serverName") orelse obj.getTruthy(global, "servername")) |server_name| { var sliced = server_name.toSlice(global, bun.default_allocator); defer sliced.deinit(); if (sliced.len > 0) { @@ -1021,7 +1021,7 @@ pub const ServerConfig = struct { } } - if (obj.getOwnTruthy(global, "ca")) |js_obj| { + if (obj.getTruthy(global, "ca")) |js_obj| { if (js_obj.jsType().isArray()) { const count = js_obj.getLength(global); if (count > 0) { @@ -1104,7 +1104,7 @@ pub const ServerConfig = struct { } } - if (obj.getOwnTruthy(global, "caFile")) |ca_file_name| { + if (obj.getTruthy(global, "caFile")) |ca_file_name| { var sliced = ca_file_name.toSlice(global, bun.default_allocator); defer sliced.deinit(); if (sliced.len > 0) { @@ -1118,25 +1118,25 @@ pub const ServerConfig = struct { } // Optional if (any) { - if (obj.getOwnTruthy(global, "secureOptions")) |secure_options| { + if (obj.getTruthy(global, "secureOptions")) |secure_options| { if (secure_options.isNumber()) { result.secure_options = secure_options.toU32(); } } - if (obj.getOwnTruthy(global, "clientRenegotiationLimit")) |client_renegotiation_limit| { + if (obj.getTruthy(global, "clientRenegotiationLimit")) |client_renegotiation_limit| { if (client_renegotiation_limit.isNumber()) { result.client_renegotiation_limit = client_renegotiation_limit.toU32(); } } - if (obj.getOwnTruthy(global, "clientRenegotiationWindow")) |client_renegotiation_window| { + if (obj.getTruthy(global, "clientRenegotiationWindow")) |client_renegotiation_window| { if (client_renegotiation_window.isNumber()) { result.client_renegotiation_window = client_renegotiation_window.toU32(); } } - if (obj.getOwnTruthy(global, "dhParamsFile")) |dh_params_file_name| { + if (obj.getTruthy(global, "dhParamsFile")) |dh_params_file_name| { var sliced = dh_params_file_name.toSlice(global, bun.default_allocator); defer sliced.deinit(); if (sliced.len > 0) { @@ -1149,7 +1149,7 @@ pub const ServerConfig = struct { } } - if (obj.getOwnTruthy(global, "passphrase")) |passphrase| { + if (obj.getTruthy(global, "passphrase")) |passphrase| { var sliced = passphrase.toSlice(global, bun.default_allocator); defer sliced.deinit(); if (sliced.len > 0) { @@ -1157,7 +1157,7 @@ pub const ServerConfig = struct { } } - if (obj.getOwn(global, "lowMemoryMode")) |low_memory_mode| { + if (obj.get(global, "lowMemoryMode")) |low_memory_mode| { if (low_memory_mode.isBoolean() or low_memory_mode.isUndefined()) { result.low_memory_mode = low_memory_mode.toBoolean(); any = true; @@ -1240,7 +1240,7 @@ pub const ServerConfig = struct { return args; } - if (arg.getOwn(global, "static")) |static| { + if (arg.get(global, "static")) |static| { if (!static.isObject()) { JSC.throwInvalidArguments("Bun.serve expects 'static' to be an object shaped like { [pathname: string]: Response }", .{}, global, exception); return args; @@ -1285,7 +1285,7 @@ pub const ServerConfig = struct { if (global.hasException()) return args; - if (arg.getOwn(global, "idleTimeout")) |value| { + if (arg.get(global, "idleTimeout")) |value| { if (!value.isUndefinedOrNull()) { if (!value.isAnyInt()) { JSC.throwInvalidArguments("Bun.serve expects idleTimeout to be an integer", .{}, global, exception); @@ -1303,7 +1303,7 @@ pub const ServerConfig = struct { } } - if (arg.getOwnTruthy(global, "webSocket") orelse arg.getOwnTruthy(global, "websocket")) |websocket_object| { + if (arg.getTruthy(global, "webSocket") orelse arg.getTruthy(global, "websocket")) |websocket_object| { if (!websocket_object.isObject()) { JSC.throwInvalidArguments("Expected websocket to be an object", .{}, global, exception); if (args.ssl_config) |*conf| { @@ -1323,7 +1323,7 @@ pub const ServerConfig = struct { } if (global.hasException()) return args; - if (arg.getOwnTruthy(global, "port")) |port_| { + if (arg.getTruthy(global, "port")) |port_| { args.address.tcp.port = @as( u16, @intCast(@min( @@ -1335,7 +1335,7 @@ pub const ServerConfig = struct { } if (global.hasException()) return args; - if (arg.getOwnTruthy(global, "baseURI")) |baseURI| { + if (arg.getTruthy(global, "baseURI")) |baseURI| { var sliced = baseURI.toSlice(global, bun.default_allocator); if (sliced.len > 0) { @@ -1345,7 +1345,7 @@ pub const ServerConfig = struct { } if (global.hasException()) return args; - if (arg.getOwnTruthy(global, "hostname") orelse arg.getOwnTruthy(global, "host")) |host| { + if (arg.getTruthy(global, "hostname") orelse arg.getTruthy(global, "host")) |host| { const host_str = host.toSlice( global, bun.default_allocator, @@ -1359,7 +1359,7 @@ pub const ServerConfig = struct { } if (global.hasException()) return args; - if (arg.getOwnTruthy(global, "unix")) |unix| { + if (arg.getTruthy(global, "unix")) |unix| { const unix_str = unix.toSlice( global, bun.default_allocator, @@ -1376,7 +1376,7 @@ pub const ServerConfig = struct { } if (global.hasException()) return args; - if (arg.getOwn(global, "id")) |id| { + if (arg.get(global, "id")) |id| { if (id.isUndefinedOrNull()) { args.allow_hot = false; } else { @@ -1394,18 +1394,18 @@ pub const ServerConfig = struct { } if (global.hasException()) return args; - if (arg.getOwn(global, "development")) |dev| { + if (arg.get(global, "development")) |dev| { args.development = dev.coerce(bool, global); args.reuse_port = !args.development; } if (global.hasException()) return args; - if (arg.getOwn(global, "reusePort")) |dev| { + if (arg.get(global, "reusePort")) |dev| { args.reuse_port = dev.coerce(bool, global); } if (global.hasException()) return args; - if (arg.getOwn(global, "inspector")) |inspector| { + if (arg.get(global, "inspector")) |inspector| { args.inspector = inspector.coerce(bool, global); if (args.inspector and !args.development) { @@ -1415,14 +1415,14 @@ pub const ServerConfig = struct { } if (global.hasException()) return args; - if (arg.getOwnTruthy(global, "maxRequestBodySize")) |max_request_body_size| { + if (arg.getTruthy(global, "maxRequestBodySize")) |max_request_body_size| { if (max_request_body_size.isNumber()) { args.max_request_body_size = @as(u64, @intCast(@max(0, max_request_body_size.toInt64()))); } } if (global.hasException()) return args; - if (arg.getOwnTruthyComptime(global, "error")) |onError| { + if (arg.getTruthyComptime(global, "error")) |onError| { if (!onError.isCallable(global.vm())) { JSC.throwInvalidArguments("Expected error to be a function", .{}, global, exception); return args; @@ -4191,7 +4191,7 @@ pub const WebSocketServer = struct { var valid = false; - if (object.getOwnTruthyComptime(globalObject, "message")) |message_| { + if (object.getTruthyComptime(globalObject, "message")) |message_| { if (!message_.isCallable(vm)) { globalObject.throwInvalidArguments("websocket expects a function for the message option", .{}); return null; @@ -4202,7 +4202,7 @@ pub const WebSocketServer = struct { valid = true; } - if (object.getOwnTruthy(globalObject, "open")) |open_| { + if (object.getTruthy(globalObject, "open")) |open_| { if (!open_.isCallable(vm)) { globalObject.throwInvalidArguments("websocket expects a function for the open option", .{}); return null; @@ -4213,7 +4213,7 @@ pub const WebSocketServer = struct { valid = true; } - if (object.getOwnTruthy(globalObject, "close")) |close_| { + if (object.getTruthy(globalObject, "close")) |close_| { if (!close_.isCallable(vm)) { globalObject.throwInvalidArguments("websocket expects a function for the close option", .{}); return null; @@ -4224,7 +4224,7 @@ pub const WebSocketServer = struct { valid = true; } - if (object.getOwnTruthy(globalObject, "drain")) |drain_| { + if (object.getTruthy(globalObject, "drain")) |drain_| { if (!drain_.isCallable(vm)) { globalObject.throwInvalidArguments("websocket expects a function for the drain option", .{}); return null; @@ -4235,7 +4235,7 @@ pub const WebSocketServer = struct { valid = true; } - if (object.getOwnTruthy(globalObject, "onError")) |onError_| { + if (object.getTruthy(globalObject, "onError")) |onError_| { if (!onError_.isCallable(vm)) { globalObject.throwInvalidArguments("websocket expects a function for the onError option", .{}); return null; @@ -4245,7 +4245,7 @@ pub const WebSocketServer = struct { onError.ensureStillAlive(); } - if (object.getOwnTruthy(globalObject, "ping")) |cb| { + if (object.getTruthy(globalObject, "ping")) |cb| { if (!cb.isCallable(vm)) { globalObject.throwInvalidArguments("websocket expects a function for the ping option", .{}); return null; @@ -4255,7 +4255,7 @@ pub const WebSocketServer = struct { valid = true; } - if (object.getOwnTruthy(globalObject, "pong")) |cb| { + if (object.getTruthy(globalObject, "pong")) |cb| { if (!cb.isCallable(vm)) { globalObject.throwInvalidArguments("websocket expects a function for the pong option", .{}); return null; @@ -4354,7 +4354,7 @@ pub const WebSocketServer = struct { return null; } - if (object.getOwn(globalObject, "perMessageDeflate")) |per_message_deflate| { + if (object.get(globalObject, "perMessageDeflate")) |per_message_deflate| { getter: { if (per_message_deflate.isUndefined()) { break :getter; @@ -4369,7 +4369,7 @@ pub const WebSocketServer = struct { break :getter; } - if (per_message_deflate.getOwnTruthy(globalObject, "compress")) |compression| { + if (per_message_deflate.getTruthy(globalObject, "compress")) |compression| { if (compression.isBoolean()) { server.compression |= if (compression.toBoolean()) uws.SHARED_COMPRESSOR else 0; } else if (compression.isString()) { @@ -4389,7 +4389,7 @@ pub const WebSocketServer = struct { } } - if (per_message_deflate.getOwnTruthy(globalObject, "decompress")) |compression| { + if (per_message_deflate.getTruthy(globalObject, "decompress")) |compression| { if (compression.isBoolean()) { server.compression |= if (compression.toBoolean()) uws.SHARED_DECOMPRESSOR else 0; } else if (compression.isString()) { @@ -4411,7 +4411,7 @@ pub const WebSocketServer = struct { } } - if (object.getOwn(globalObject, "maxPayloadLength")) |value| { + if (object.get(globalObject, "maxPayloadLength")) |value| { if (!value.isUndefinedOrNull()) { if (!value.isAnyInt()) { globalObject.throwInvalidArguments("websocket expects maxPayloadLength to be an integer", .{}); @@ -4421,7 +4421,7 @@ pub const WebSocketServer = struct { } } - if (object.getOwn(globalObject, "idleTimeout")) |value| { + if (object.get(globalObject, "idleTimeout")) |value| { if (!value.isUndefinedOrNull()) { if (!value.isAnyInt()) { globalObject.throwInvalidArguments("websocket expects idleTimeout to be an integer", .{}); @@ -4441,7 +4441,7 @@ pub const WebSocketServer = struct { server.idleTimeout = idleTimeout; } } - if (object.getOwn(globalObject, "backpressureLimit")) |value| { + if (object.get(globalObject, "backpressureLimit")) |value| { if (!value.isUndefinedOrNull()) { if (!value.isAnyInt()) { globalObject.throwInvalidArguments("websocket expects backpressureLimit to be an integer", .{}); @@ -4452,7 +4452,7 @@ pub const WebSocketServer = struct { } } - if (object.getOwn(globalObject, "closeOnBackpressureLimit")) |value| { + if (object.get(globalObject, "closeOnBackpressureLimit")) |value| { if (!value.isUndefinedOrNull()) { if (!value.isBoolean()) { globalObject.throwInvalidArguments("websocket expects closeOnBackpressureLimit to be a boolean", .{}); @@ -4463,7 +4463,7 @@ pub const WebSocketServer = struct { } } - if (object.getOwn(globalObject, "sendPings")) |value| { + if (object.get(globalObject, "sendPings")) |value| { if (!value.isUndefinedOrNull()) { if (!value.isBoolean()) { globalObject.throwInvalidArguments("websocket expects sendPings to be a boolean", .{}); @@ -4474,7 +4474,7 @@ pub const WebSocketServer = struct { } } - if (object.getOwn(globalObject, "publishToSelf")) |value| { + if (object.get(globalObject, "publishToSelf")) |value| { if (!value.isUndefinedOrNull()) { if (!value.isBoolean()) { globalObject.throwInvalidArguments("websocket expects publishToSelf to be a boolean", .{}); diff --git a/src/bun.js/base.zig b/src/bun.js/base.zig index d4798870255689..119b3925cc7401 100644 --- a/src/bun.js/base.zig +++ b/src/bun.js/base.zig @@ -1103,7 +1103,7 @@ pub fn wrapInstanceMethod( }, ?JSC.Cloudflare.ContentOptions => { if (iter.nextEat()) |content_arg| { - if (content_arg.getOwn(globalThis.ptr(), "html")) |html_val| { + if (content_arg.get(globalThis.ptr(), "html")) |html_val| { args[i] = .{ .html = html_val.toBoolean() }; } } else { @@ -1267,7 +1267,7 @@ pub fn wrapStaticMethod( }, ?JSC.Cloudflare.ContentOptions => { if (iter.nextEat()) |content_arg| { - if (content_arg.getOwn(globalThis.ptr(), "html")) |html_val| { + if (content_arg.get(globalThis.ptr(), "html")) |html_val| { args[i] = .{ .html = html_val.toBoolean() }; } } else { diff --git a/src/bun.js/bindings/ObjectBindings.cpp b/src/bun.js/bindings/ObjectBindings.cpp new file mode 100644 index 00000000000000..d3ecb8e78ac947 --- /dev/null +++ b/src/bun.js/bindings/ObjectBindings.cpp @@ -0,0 +1,76 @@ +#include "root.h" +#include +#include +#include +#include + +namespace Bun { + +using namespace JSC; + +static bool getNonIndexPropertySlotPrototypePollutionMitigation(JSC::VM& vm, JSObject* object, JSGlobalObject* globalObject, PropertyName propertyName, PropertySlot& slot) +{ + // This method only supports non-index PropertyNames. + ASSERT(!parseIndex(propertyName)); + + auto scope = DECLARE_THROW_SCOPE(vm); + JSObject* objectPrototype = nullptr; + while (true) { + Structure* structure = object->structureID().decode(); + if (LIKELY(!TypeInfo::overridesGetOwnPropertySlot(object->inlineTypeFlags()))) { + if (object->getOwnNonIndexPropertySlot(vm, structure, propertyName, slot)) + return true; + } else { + bool hasSlot = structure->classInfoForCells()->methodTable.getOwnPropertySlot(object, globalObject, propertyName, slot); + RETURN_IF_EXCEPTION(scope, false); + if (hasSlot) + return true; + if (UNLIKELY(slot.isVMInquiry() && slot.isTaintedByOpaqueObject())) + return false; + if (object->type() == ProxyObjectType && slot.internalMethodType() == PropertySlot::InternalMethodType::HasProperty) + return false; + } + JSValue prototype; + if (LIKELY(!structure->typeInfo().overridesGetPrototype() || slot.internalMethodType() == PropertySlot::InternalMethodType::VMInquiry)) + prototype = object->getPrototypeDirect(); + else { + prototype = object->getPrototype(vm, globalObject); + RETURN_IF_EXCEPTION(scope, false); + } + if (!prototype.isObject()) + return false; + object = asObject(prototype); + // -- If we reach the object prototype, we stop. + if (objectPrototype == nullptr) { + objectPrototype = globalObject->objectPrototype(); + } + if (object == objectPrototype) { + return false; + } + } + + return false; +} + +JSC::JSValue getIfPropertyExistsPrototypePollutionMitigation(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSObject* object, const JSC::PropertyName& name) +{ + auto scope = DECLARE_THROW_SCOPE(vm); + auto propertySlot = PropertySlot(object, PropertySlot::InternalMethodType::HasProperty); + auto isDefined = getNonIndexPropertySlotPrototypePollutionMitigation(vm, object, globalObject, name, propertySlot); + + if (!isDefined) { + return {}; + } + + scope.assertNoException(); + JSValue value = propertySlot.getValue(globalObject, name); + RETURN_IF_EXCEPTION(scope, {}); + return value; +} + +JSC::JSValue getIfPropertyExistsPrototypePollutionMitigation(JSC::JSGlobalObject* globalObject, JSC::JSObject* object, const JSC::PropertyName& name) +{ + return getIfPropertyExistsPrototypePollutionMitigation(JSC::getVM(globalObject), globalObject, object, name); +} + +} diff --git a/src/bun.js/bindings/ObjectBindings.h b/src/bun.js/bindings/ObjectBindings.h new file mode 100644 index 00000000000000..8c32283cbb4047 --- /dev/null +++ b/src/bun.js/bindings/ObjectBindings.h @@ -0,0 +1,16 @@ +#pragma once + +namespace Bun { + +JSC::JSValue getIfPropertyExistsPrototypePollutionMitigation(JSC::JSGlobalObject* globalObject, JSC::JSObject* object, const JSC::PropertyName& name); + +/** + * This is `JSObject::getIfPropertyExists`, except it stops when it reaches globalObject->objectPrototype(). + * + * This means that for a prototype pollution attack to work, they would need to modify the specific prototype instead of the generic one shared by most objects. + * + * This method also does not support index properties. + */ +JSC::JSValue getIfPropertyExistsPrototypePollutionMitigation(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSObject* object, const JSC::PropertyName& name); + +} diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp index fb4c7769cad3e9..8409ffa856dd6d 100644 --- a/src/bun.js/bindings/bindings.cpp +++ b/src/bun.js/bindings/bindings.cpp @@ -123,6 +123,7 @@ #include "JavaScriptCore/CustomGetterSetter.h" #include "ErrorStackFrame.h" +#include "ObjectBindings.h" #if OS(DARWIN) #if BUN_DEBUG @@ -3708,23 +3709,24 @@ JSC__JSValue JSC__JSValue__getIfPropertyExistsImpl(JSC__JSValue JSValue0, const auto identifier = JSC::Identifier::fromString(vm, propertyString); const auto property = JSC::PropertyName(identifier); - return JSC::JSValue::encode(object->getIfPropertyExists(globalObject, property)); + return JSC::JSValue::encode(Bun::getIfPropertyExistsPrototypePollutionMitigation(vm, globalObject, object, property)); } extern "C" JSC__JSValue JSC__JSValue__getIfPropertyExistsImplString(JSC__JSValue JSValue0, JSC__JSGlobalObject* globalObject, BunString* propertyName) { ASSERT_NO_PENDING_EXCEPTION(globalObject); JSValue value = JSC::JSValue::decode(JSValue0); - if (UNLIKELY(!value.isObject())) + JSC::JSObject* object = value.getObject(); + if (UNLIKELY(!object)) return JSValue::encode({}); JSC::VM& vm = globalObject->vm(); - JSC::JSObject* object = value.getObject(); + WTF::String propertyNameString = propertyName->tag == BunStringTag::Empty ? WTF::String(""_s) : propertyName->toWTFString(BunString::ZeroCopy); auto identifier = JSC::Identifier::fromString(vm, propertyNameString); auto property = JSC::PropertyName(identifier); - return JSC::JSValue::encode(object->getIfPropertyExists(globalObject, property)); + return JSC::JSValue::encode(Bun::getIfPropertyExistsPrototypePollutionMitigation(vm, globalObject, object, property)); } extern "C" JSC__JSValue JSC__JSValue__getOwn(JSC__JSValue JSValue0, JSC__JSGlobalObject* globalObject, BunString* propertyName) diff --git a/src/bun.js/modules/NodeModuleModule.h b/src/bun.js/modules/NodeModuleModule.h index e51f5c1c382745..6750ff5ad50eac 100644 --- a/src/bun.js/modules/NodeModuleModule.h +++ b/src/bun.js/modules/NodeModuleModule.h @@ -22,11 +22,6 @@ namespace Bun { void addNodeModuleConstructorProperties(JSC::VM &vm, Zig::GlobalObject *globalObject); } - - - - - namespace Zig { void generateNativeModule_NodeModule( diff --git a/src/bun.js/webcore.zig b/src/bun.js/webcore.zig index 87797253b11302..6f58d591eb7621 100644 --- a/src/bun.js/webcore.zig +++ b/src/bun.js/webcore.zig @@ -403,7 +403,7 @@ pub const Crypto = struct { return .zero; } - if (options_value.getOwnTruthy(globalThis, "cost") orelse options_value.getOwnTruthy(globalThis, "N")) |N_value| { + if (options_value.getTruthy(globalThis, "cost") orelse options_value.getTruthy(globalThis, "N")) |N_value| { if (cost != null) return throwInvalidParameter(globalThis); const N_int = N_value.to(i64); if (N_int < 0 or !N_value.isNumber()) { @@ -418,7 +418,7 @@ pub const Crypto = struct { } } - if (options_value.getOwnTruthy(globalThis, "blockSize") orelse options_value.getOwn(globalThis, "r")) |r_value| { + if (options_value.getTruthy(globalThis, "blockSize") orelse options_value.getTruthy(globalThis, "r")) |r_value| { if (blockSize != null) return throwInvalidParameter(globalThis); const r_int = r_value.to(i64); if (r_int < 0 or !r_value.isNumber()) { @@ -433,7 +433,7 @@ pub const Crypto = struct { } } - if (options_value.getOwnTruthy(globalThis, "parallelization") orelse options_value.getOwn(globalThis, "p")) |p_value| { + if (options_value.getTruthy(globalThis, "parallelization") orelse options_value.getTruthy(globalThis, "p")) |p_value| { if (parallelization != null) return throwInvalidParameter(globalThis); const p_int = p_value.to(i64); if (p_int < 0 or !p_value.isNumber()) { @@ -448,7 +448,7 @@ pub const Crypto = struct { } } - if (options_value.getOwnTruthy(globalThis, "maxmem")) |value| { + if (options_value.getTruthy(globalThis, "maxmem")) |value| { const p_int = value.to(i64); if (p_int < 0 or !value.isNumber()) { return throwInvalidParams( diff --git a/src/bun.js/webcore/blob.zig b/src/bun.js/webcore/blob.zig index 069228c7536394..a66967e74cdd47 100644 --- a/src/bun.js/webcore/blob.zig +++ b/src/bun.js/webcore/blob.zig @@ -1018,7 +1018,7 @@ pub const Blob = struct { if (args.nextEat()) |options_object| { if (options_object.isObject()) { - if (options_object.getOwnTruthy(globalThis, "createPath")) |create_directory| { + if (options_object.getTruthy(globalThis, "createPath")) |create_directory| { if (!create_directory.isBoolean()) { globalThis.throwInvalidArgumentType("write", "options.createPath", "boolean"); return .zero; diff --git a/src/bun.js/webcore/streams.zig b/src/bun.js/webcore/streams.zig index 56de7842c7d221..9c2f589f3771f9 100644 --- a/src/bun.js/webcore/streams.zig +++ b/src/bun.js/webcore/streams.zig @@ -533,7 +533,7 @@ pub const StreamStart = union(Tag) { return .{ .empty = {} }; } - if (value.getOwn(globalThis, "chunkSize")) |chunkSize| { + if (value.get(globalThis, "chunkSize")) |chunkSize| { if (chunkSize.isNumber()) return .{ .chunk_size = @as(Blob.SizeType, @intCast(@as(i52, @truncate(chunkSize.toInt64())))) }; } diff --git a/src/bundler.zig b/src/bundler.zig index 32b0c8dba921f0..4c66c6e0e2f17d 100644 --- a/src/bundler.zig +++ b/src/bundler.zig @@ -166,7 +166,7 @@ pub const PluginRunner = struct { bun.String.init(importer), target, ) orelse return null; - const path_value = on_resolve_plugin.getOwn(global, "path") orelse return null; + const path_value = on_resolve_plugin.get(global, "path") orelse return null; if (path_value.isEmptyOrUndefinedOrNull()) return null; if (!path_value.isString()) { log.addError(null, loc, "Expected \"path\" to be a string") catch unreachable; @@ -199,7 +199,7 @@ pub const PluginRunner = struct { } var static_namespace = true; const user_namespace: bun.String = brk: { - if (on_resolve_plugin.getOwn(global, "namespace")) |namespace_value| { + if (on_resolve_plugin.get(global, "namespace")) |namespace_value| { if (!namespace_value.isString()) { log.addError(null, loc, "Expected \"namespace\" to be a string") catch unreachable; return null; @@ -265,7 +265,7 @@ pub const PluginRunner = struct { importer, target, ) orelse return null; - const path_value = on_resolve_plugin.getOwn(global, "path") orelse return null; + const path_value = on_resolve_plugin.get(global, "path") orelse return null; if (path_value.isEmptyOrUndefinedOrNull()) return null; if (!path_value.isString()) { return JSC.ErrorableString.err( @@ -295,7 +295,7 @@ pub const PluginRunner = struct { } var static_namespace = true; const user_namespace: bun.String = brk: { - if (on_resolve_plugin.getOwn(global, "namespace")) |namespace_value| { + if (on_resolve_plugin.get(global, "namespace")) |namespace_value| { if (!namespace_value.isString()) { return JSC.ErrorableString.err( error.JSErrorObject, diff --git a/src/css/values/color_js.zig b/src/css/values/color_js.zig index 23fdda0c5f40e0..95d195a2837684 100644 --- a/src/css/values/color_js.zig +++ b/src/css/values/color_js.zig @@ -230,17 +230,17 @@ pub fn jsFunctionColor(globalThis: *JSC.JSGlobalObject, callFrame: *JSC.CallFram }, } } else if (args[0].isObject()) { - const r = colorIntFromJS(globalThis, args[0].getOwn(globalThis, "r") orelse .zero, "r") orelse return .zero; + const r = colorIntFromJS(globalThis, args[0].get(globalThis, "r") orelse .zero, "r") orelse return .zero; if (globalThis.hasException()) { return .zero; } - const g = colorIntFromJS(globalThis, args[0].getOwn(globalThis, "g") orelse .zero, "g") orelse return .zero; + const g = colorIntFromJS(globalThis, args[0].get(globalThis, "g") orelse .zero, "g") orelse return .zero; if (globalThis.hasException()) { return .zero; } - const b = colorIntFromJS(globalThis, args[0].getOwn(globalThis, "b") orelse .zero, "b") orelse return .zero; + const b = colorIntFromJS(globalThis, args[0].get(globalThis, "b") orelse .zero, "b") orelse return .zero; if (globalThis.hasException()) { return .zero; diff --git a/src/dns.zig b/src/dns.zig index 9490f7ba85e15e..a72765b4b3d68f 100644 --- a/src/dns.zig +++ b/src/dns.zig @@ -74,23 +74,23 @@ pub const GetAddrInfo = struct { if (value.isObject()) { var options = Options{}; - if (value.getOwn(globalObject, "family")) |family| { + if (value.get(globalObject, "family")) |family| { options.family = try Family.fromJS(family, globalObject); } - if (value.getOwn(globalObject, "socketType") orelse value.getOwn(globalObject, "socktype")) |socktype| { + if (value.get(globalObject, "socketType") orelse value.get(globalObject, "socktype")) |socktype| { options.socktype = try SocketType.fromJS(socktype, globalObject); } - if (value.getOwn(globalObject, "protocol")) |protocol| { + if (value.get(globalObject, "protocol")) |protocol| { options.protocol = try Protocol.fromJS(protocol, globalObject); } - if (value.getOwn(globalObject, "backend")) |backend| { + if (value.get(globalObject, "backend")) |backend| { options.backend = try Backend.fromJS(backend, globalObject); } - if (value.getOwn(globalObject, "flags")) |flags| { + if (value.get(globalObject, "flags")) |flags| { if (!flags.isNumber()) return error.InvalidFlags;