Compare commits

...

7 Commits

Author SHA1 Message Date
Ciro Spaciari
69d43d2476 add back 2024-09-06 18:45:33 -07:00
Ciro Spaciari
8110173225 revert this part for now 2024-09-06 18:43:30 -07:00
Ciro Spaciari
976e84335c remove console 2024-09-06 18:13:30 -07:00
Ciro Spaciari
d48673c635 keepalive 2024-09-06 18:13:30 -07:00
cirospaciari
7d4b43c7de Apply formatting changes 2024-09-06 18:13:30 -07:00
Ciro Spaciari
a2a81d1a66 more 2024-09-06 18:13:30 -07:00
Ciro Spaciari
ae145f1a20 proxy +rejectUnauthorized 2024-09-06 18:13:30 -07:00
10 changed files with 141 additions and 64 deletions

View File

@@ -60,10 +60,15 @@ public:
Type type() const { return m_type; }
#if ASSERT_ENABLED
virtual void checkValidityForEventTarget(EventTarget&) {}
virtual void checkValidityForEventTarget(EventTarget&)
{
}
#endif
virtual JSC::JSObject* jsFunction() const { return nullptr; }
virtual JSC::JSObject* jsFunction() const
{
return nullptr;
}
virtual JSC::JSObject* wrapper() const { return nullptr; }
protected:

View File

@@ -53,8 +53,8 @@ public:
protected:
JSDOMConstructorBase(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction functionForConstruct, JSC::NativeFunction functionForCall = nullptr)
: Base(vm, structure,
functionForCall ? functionForCall : callThrowTypeErrorForJSDOMConstructor,
functionForConstruct ? functionForConstruct : callThrowTypeErrorForJSDOMConstructor)
functionForCall ? functionForCall : callThrowTypeErrorForJSDOMConstructor,
functionForConstruct ? functionForConstruct : callThrowTypeErrorForJSDOMConstructor)
{
}
};

View File

@@ -164,7 +164,8 @@ JSC_DEFINE_CUSTOM_GETTER(jsTextDecoderStreamConstructor, (JSGlobalObject * lexic
JSC::GCClient::IsoSubspace* JSTextDecoderStream::subspaceForImpl(JSC::VM& vm)
{
return WebCore::subspaceForImpl<JSTextDecoderStream, UseCustomHeapCellType::No>(vm, [](auto& spaces) { return spaces.m_clientSubspaceForTextDecoderStream.get(); }, [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForTextDecoderStream = std::forward<decltype(space)>(space); }, [](auto& spaces) { return spaces.m_subspaceForTextDecoderStream.get(); }, [](auto& spaces, auto&& space) { spaces.m_subspaceForTextDecoderStream = std::forward<decltype(space)>(space); });
return WebCore::subspaceForImpl<JSTextDecoderStream, UseCustomHeapCellType::No>(
vm, [](auto& spaces) { return spaces.m_clientSubspaceForTextDecoderStream.get(); }, [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForTextDecoderStream = std::forward<decltype(space)>(space); }, [](auto& spaces) { return spaces.m_subspaceForTextDecoderStream.get(); }, [](auto& spaces, auto&& space) { spaces.m_subspaceForTextDecoderStream = std::forward<decltype(space)>(space); });
}
}

View File

@@ -162,7 +162,8 @@ JSC_DEFINE_CUSTOM_GETTER(jsTextEncoderStreamConstructor, (JSGlobalObject * lexic
JSC::GCClient::IsoSubspace* JSTextEncoderStream::subspaceForImpl(JSC::VM& vm)
{
return WebCore::subspaceForImpl<JSTextEncoderStream, UseCustomHeapCellType::No>(vm, [](auto& spaces) { return spaces.m_clientSubspaceForTextEncoderStream.get(); }, [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForTextEncoderStream = std::forward<decltype(space)>(space); }, [](auto& spaces) { return spaces.m_subspaceForTextEncoderStream.get(); }, [](auto& spaces, auto&& space) { spaces.m_subspaceForTextEncoderStream = std::forward<decltype(space)>(space); });
return WebCore::subspaceForImpl<JSTextEncoderStream, UseCustomHeapCellType::No>(
vm, [](auto& spaces) { return spaces.m_clientSubspaceForTextEncoderStream.get(); }, [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForTextEncoderStream = std::forward<decltype(space)>(space); }, [](auto& spaces) { return spaces.m_subspaceForTextEncoderStream.get(); }, [](auto& spaces, auto&& space) { spaces.m_subspaceForTextEncoderStream = std::forward<decltype(space)>(space); });
}
}

View File

@@ -75,6 +75,7 @@ template<> struct HashTraits<WebCore::MessagePortIdentifier> : GenericHashTraits
static bool isDeletedValue(const WebCore::MessagePortIdentifier& slot) { return slot.processIdentifier.isHashTableDeletedValue(); }
};
template<> struct DefaultHash<WebCore::MessagePortIdentifier> : MessagePortIdentifierHash {};
template<> struct DefaultHash<WebCore::MessagePortIdentifier> : MessagePortIdentifierHash {
};
} // namespace WTF

View File

@@ -2574,7 +2574,7 @@ SerializationReturnCode CloneSerializer::serialize(JSValue in)
indexStack.last()++;
goto objectStartVisitMember;
}
mapStartState: {
mapStartState : {
ASSERT(inValue.isObject());
if (inputObjectStack.size() > maximumFilterRecursion)
return SerializationReturnCode::StackOverflowError;
@@ -2622,7 +2622,7 @@ SerializationReturnCode CloneSerializer::serialize(JSValue in)
goto mapDataStartVisitEntry;
}
setStartState: {
setStartState : {
ASSERT(inValue.isObject());
if (inputObjectStack.size() > maximumFilterRecursion)
return SerializationReturnCode::StackOverflowError;
@@ -5084,7 +5084,7 @@ DeserializationResult CloneDeserializer::deserialize()
propertyNameStack.removeLast();
goto objectStartVisitMember;
}
mapObjectStartState: {
mapObjectStartState : {
if (outputObjectStack.size() > maximumFilterRecursion)
return std::make_pair(JSValue(), SerializationReturnCode::StackOverflowError);
JSMap* map = JSMap::create(m_lexicalGlobalObject->vm(), m_globalObject->mapStructure());
@@ -5113,7 +5113,7 @@ DeserializationResult CloneDeserializer::deserialize()
goto mapDataStartVisitEntry;
}
setObjectStartState: {
setObjectStartState : {
if (outputObjectStack.size() > maximumFilterRecursion)
return std::make_pair(JSValue(), SerializationReturnCode::StackOverflowError);
JSSet* set = JSSet::create(m_lexicalGlobalObject->vm(), m_globalObject->setStructure());

View File

@@ -2489,21 +2489,23 @@ pub const Fetch = struct {
};
// proxy: string | undefined;
url_proxy_buffer = extract_proxy: {
const objects_to_try = [_]JSC.JSValue{
options_object orelse .zero,
request_init_object orelse .zero,
if (options_object) |obj| obj.get(globalThis, "agent") orelse .zero else .zero,
};
inline for (0..2) |i| {
if (objects_to_try[i] != .zero) {
if (!objects_to_try[i].isEmptyOrUndefinedOrNull()) {
if (objects_to_try[i].get(globalThis, "proxy")) |proxy_arg| {
if (proxy_arg.isString() and proxy_arg.getLength(ctx) > 0) {
var href = JSC.URL.hrefFromJS(proxy_arg, globalThis);
if (href.tag == .Dead) {
const err = JSC.toTypeError(.ERR_INVALID_ARG_VALUE, "fetch() proxy URL is invalid", .{}, ctx);
is_error = true;
return JSPromise.rejectedPromiseValue(globalThis, err);
}
var href = JSC.URL.hrefFromJS(proxy_arg, globalThis);
if (href.tag == .Dead) {
const err = JSC.toTypeError(.ERR_INVALID_ARG_VALUE, "fetch() proxy URL is invalid", .{}, ctx);
is_error = true;
return JSPromise.rejectedPromiseValue(globalThis, err);
}
if (!href.isEmpty()) {
defer href.deref();
const buffer = std.fmt.allocPrint(allocator, "{s}{}", .{ url_proxy_buffer, href }) catch {
globalThis.throwOutOfMemory();

View File

@@ -1580,6 +1580,13 @@ class ClientRequest extends OutgoingMessage {
proxy = `${protocol}//${this.#host}${this.#useDefaultPort ? "" : ":" + this.#port}`;
} else {
url = `${protocol}//${this.#host}${this.#useDefaultPort ? "" : ":" + this.#port}${path}`;
// support agent proxy url/string for http/https
proxy = this.#agent?.proxy;
}
let keepalive = true;
const agentKeepalive = this.#agent?.keepalive;
if (agentKeepalive !== undefined) {
keepalive = agentKeepalive;
}
const tls = protocol === "https:" && this.#tls ? { ...this.#tls, serverName: this.#tls.servername } : undefined;
try {
@@ -1592,6 +1599,7 @@ class ClientRequest extends OutgoingMessage {
timeout: false,
// Disable auto gzip/deflate
decompress: false,
keepalive,
};
if (body && method !== "GET" && method !== "HEAD" && method !== "OPTIONS") {
@@ -1675,7 +1683,6 @@ class ClientRequest extends OutgoingMessage {
constructor(input, options, cb) {
super();
if (typeof input === "string") {
const urlStr = input;
try {
@@ -1791,14 +1798,31 @@ class ClientRequest extends OutgoingMessage {
this.#joinDuplicateHeaders = _joinDuplicateHeaders;
if (options.pfx) {
throw new Error("pfx is not supported");
} else {
const agentPfx = this.#agent?.pfx;
if (agentPfx) throw new Error("pfx is not supported");
}
if (options.rejectUnauthorized !== undefined) this._ensureTls().rejectUnauthorized = options.rejectUnauthorized;
else {
const agentRejectUnauthorized = this.#agent?.rejectUnauthorized;
if (agentRejectUnauthorized !== undefined) this._ensureTls().rejectUnauthorized = agentRejectUnauthorized;
}
if (options.ca) {
if (!isValidTLSArray(options.ca))
throw new TypeError(
"ca argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile",
);
this._ensureTls().ca = options.ca;
} else {
const agentCa = this.#agent?.ca;
if (agentCa) {
if (!isValidTLSArray(agentCa))
throw new TypeError(
"agent ca argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile",
);
this._ensureTls().ca = agentCa;
}
}
if (options.cert) {
if (!isValidTLSArray(options.cert))
@@ -1806,6 +1830,15 @@ class ClientRequest extends OutgoingMessage {
"cert argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile",
);
this._ensureTls().cert = options.cert;
} else {
const agentCert = this.#agent?.cert;
if (agentCert) {
if (!isValidTLSArray(agentCert))
throw new TypeError(
"agent cert argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile",
);
this._ensureTls().cert = agentCert;
}
}
if (options.key) {
if (!isValidTLSArray(options.key))
@@ -1813,23 +1846,57 @@ class ClientRequest extends OutgoingMessage {
"key argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile",
);
this._ensureTls().key = options.key;
} else {
const agentKey = this.#agent?.key;
if (agentKey) {
if (!isValidTLSArray(agentKey))
throw new TypeError(
"agent key argument must be an string, Buffer, TypedArray, BunFile or an array containing string, Buffer, TypedArray or BunFile",
);
this._ensureTls().key = agentKey;
}
}
if (options.passphrase) {
if (typeof options.passphrase !== "string") throw new TypeError("passphrase argument must be a string");
this._ensureTls().passphrase = options.passphrase;
} else {
const agentPassphrase = this.#agent?.passphrase;
if (agentPassphrase) {
if (typeof agentPassphrase !== "string") throw new TypeError("agent passphrase argument must be a string");
this._ensureTls().passphrase = agentPassphrase;
}
}
if (options.ciphers) {
if (typeof options.ciphers !== "string") throw new TypeError("ciphers argument must be a string");
this._ensureTls().ciphers = options.ciphers;
} else {
const agentCiphers = this.#agent?.ciphers;
if (agentCiphers) {
if (typeof agentCiphers !== "string") throw new TypeError("agent ciphers argument must be a string");
this._ensureTls().ciphers = agentCiphers;
}
}
if (options.servername) {
if (typeof options.servername !== "string") throw new TypeError("servername argument must be a string");
this._ensureTls().servername = options.servername;
} else {
const agentServername = this.#agent?.servername;
if (agentServername) {
if (typeof agentServername !== "string") throw new TypeError("agent servername argument must be a string");
this._ensureTls().servername = agentServername;
}
}
if (options.secureOptions) {
if (typeof options.secureOptions !== "number") throw new TypeError("secureOptions argument must be a string");
if (typeof options.secureOptions !== "number") throw new TypeError("secureOptions argument must be a number");
this._ensureTls().secureOptions = options.secureOptions;
} else {
const agentSecureOptions = this.#agent?.secureOptions;
if (agentSecureOptions) {
if (typeof agentSecureOptions !== "number")
throw new TypeError("agent secureOptions argument must be a number");
this._ensureTls().secureOptions = agentSecureOptions;
}
}
this.#path = options.path || "/";
if (cb) {

View File

@@ -1,2 +1,2 @@
[install]
[install]
cache = false

View File

@@ -1,42 +1,42 @@
framework = "next"
origin = "http://localhost:5000"
inline.array = [1234, 4, 5, 6]
[macros]
react-relay = { "graphql" = "node_modules/bun-macro-relay/bun-macro-relay.tsx" }
[install.scopes]
"@mybigcompany2" = { "token" = "123456", "url" = "https://registry.mybigcompany.com" }
"@mybigcompany3" = { "token" = "123456", "url" = "https://registry.mybigcompany.com", "three" = 4 }
[install.scopes."@mybigcompany"]
token = "123456"
url = "https://registry.mybigcompany.com"
[bundle.packages]
"@emotion/react" = true
[install.cache]
dir = "C:\\Windows\\System32"
dir2 = "C:\\Windows\\System32\\🏳️‍🌈"
[dev]
foo = 123
"foo.bar" = "baz"
"abba.baba" = "baba"
dabba = -123
doo = 123.456
one.two.three = 4
[[array]]
entry_one = "one"
entry_two = "two"
[[array]]
entry_one = "three"
[[array.nested]]
entry_one = "four"
framework = "next"
origin = "http://localhost:5000"
inline.array = [1234, 4, 5, 6]
[macros]
react-relay = { "graphql" = "node_modules/bun-macro-relay/bun-macro-relay.tsx" }
[install.scopes]
"@mybigcompany2" = { "token" = "123456", "url" = "https://registry.mybigcompany.com" }
"@mybigcompany3" = { "token" = "123456", "url" = "https://registry.mybigcompany.com", "three" = 4 }
[install.scopes."@mybigcompany"]
token = "123456"
url = "https://registry.mybigcompany.com"
[bundle.packages]
"@emotion/react" = true
[install.cache]
dir = "C:\\Windows\\System32"
dir2 = "C:\\Windows\\System32\\🏳️‍🌈"
[dev]
foo = 123
"foo.bar" = "baz"
"abba.baba" = "baba"
dabba = -123
doo = 123.456
one.two.three = 4
[[array]]
entry_one = "one"
entry_two = "two"
[[array]]
entry_one = "three"
[[array.nested]]
entry_one = "four"