diff --git a/CHANGELOG.md b/CHANGELOG.md index a2d05b4..a1f99b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Libcurl.js Changelog: +## v0.6.16 (10/2/24): +- Fix a bug with `Headers` objects and `Request` objects not being properly handled when passed into `libcurl.fetch` +- Errors thrown are now `Error` or `TypeError` objects instead of plain strings + ## v0.6.15 (9/6/24): - WolfSSL has been downgraded to v5.6.6 due to an upstream regression diff --git a/client/fragments/wisp_support.js b/client/fragments/wisp_support.js index f60c561..aad3fcb 100644 --- a/client/fragments/wisp_support.js +++ b/client/fragments/wisp_support.js @@ -9,7 +9,7 @@ try { ws = new WebSocket(url); } else if (typeof api.transport === "string") { - throw "invalid transport type"; + throw new TypeError("invalid transport type"); } else { //custom transports ws = new api.transport(url); diff --git a/client/javascript/http.js b/client/javascript/http.js index 62ea7cd..fa36f4b 100644 --- a/client/javascript/http.js +++ b/client/javascript/http.js @@ -67,13 +67,13 @@ class HTTPSession extends CurlSession { } if (error > 0) { error_msg(`Request "${url}" failed with error code ${error}: ${get_error_str(error)}`); - reject(`Request failed with error code ${error}: ${get_error_str(error)}`); + reject(new TypeError(`Request failed with error code ${error}: ${get_error_str(error)}`)); } else if (error === -1) { reject(new DOMException("The operation was aborted.")); } else if (error === -2) { - reject("Request failed because redirects were disallowed."); + reject(new TypeError("Request failed because redirects were disallowed.")); } this.remove_request(http_handle); http_handle = null; diff --git a/client/javascript/main.js b/client/javascript/main.js index b867dba..9af1bb4 100644 --- a/client/javascript/main.js +++ b/client/javascript/main.js @@ -139,7 +139,7 @@ api = { CurlWebSocket: CurlWebSocket, TLSSocket: TLSSocket, HTTPSession: HTTPSession, - fetch() {throw "not ready"}, + fetch() {throw new Error("not ready")}, get copyright() {return copyright_notice}, get version() {return get_version()}, diff --git a/client/javascript/session.js b/client/javascript/session.js index 6259f79..3d7fce5 100644 --- a/client/javascript/session.js +++ b/client/javascript/session.js @@ -24,7 +24,7 @@ class CurlSession { assert_ready() { if (!this.session_ptr) { - throw "session has been removed"; + throw new Error("session has been removed"); } } diff --git a/client/javascript/util.js b/client/javascript/util.js index 2ee579d..13fced1 100644 --- a/client/javascript/util.js +++ b/client/javascript/util.js @@ -70,7 +70,7 @@ function data_to_array(data) { return new Uint8Array(data.buffer); } - throw "invalid data type to be sent"; + throw new TypeError("invalid data type to be sent"); } //c function wrapper diff --git a/client/javascript/ws_polyfill.js b/client/javascript/ws_polyfill.js index 2f79795..a9b8b0c 100644 --- a/client/javascript/ws_polyfill.js +++ b/client/javascript/ws_polyfill.js @@ -62,7 +62,7 @@ class FakeWebSocket extends EventTarget { converted = data.buffer; } else { - throw "invalid binaryType string"; + throw new TypeError("invalid binaryType string"); } } diff --git a/client/package.json b/client/package.json index 1238adf..064001a 100644 --- a/client/package.json +++ b/client/package.json @@ -1,15 +1,12 @@ { "name": "libcurl.js", - "version": "0.6.15", - "description": "An experimental port of libcurl to WebAssembly for use in the browser.", + "version": "0.6.16", + "description": "A port of libcurl to WebAssembly, for proxying HTTPS requests from the browser with full TLS encryption", "main": "libcurl.mjs", "exports": { ".": "./libcurl.mjs", "./bundled": "./libcurl_full.mjs" }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, "repository": { "type": "git", "url": "git+https://github.com/ading2210/libcurl.js.git" diff --git a/client/tests/run.sh b/client/tests/run.sh index cacfa51..e456682 100755 --- a/client/tests/run.sh +++ b/client/tests/run.sh @@ -4,7 +4,7 @@ set -e trap "exit" INT TERM trap "kill 0" EXIT -../server/run.sh --static=$(pwd) >/dev/null & +../server/run.sh --static=$(pwd) --log-level=WARN >/dev/null & echo -n "waiting for wisp server to start" i=0 diff --git a/server/run.sh b/server/run.sh index aa59930..519388d 100755 --- a/server/run.sh +++ b/server/run.sh @@ -13,7 +13,7 @@ if [ ! -d "$SERVER_PATH.venv" ]; then fi source $SERVER_PATH/.venv/bin/activate -if ! python3 -c "import websockets, asyncudp" 2> /dev/null; then +if ! python3 -c "import websockets, asyncudp, uvloop" 2> /dev/null; then pip3 install -e $SERVER_PATH fi diff --git a/server/wisp_server b/server/wisp_server index b7cfab0..78f872c 160000 --- a/server/wisp_server +++ b/server/wisp_server @@ -1 +1 @@ -Subproject commit b7cfab072b04dbd4345aedaf5e47c9e0d57ab873 +Subproject commit 78f872c8e5b180e26ec09cc126e841e12ac75c36