diff --git a/.gitignore b/.gitignore index f5110d5c10..3560499710 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,8 @@ target/ # dotenv environment variables file .env +.envrc +.direnv # .vscode workspace settings file .vscode/settings.json diff --git a/Cargo.lock b/Cargo.lock index 50a05a9dce..9effd6aefc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -557,6 +557,28 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" +[[package]] +name = "aws-lc-rs" +version = "1.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a054912289d18629dc78375ba2c3726a3afe3ff71b4edba9dedfca0e3446d1fc" +dependencies = [ + "aws-lc-sys", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.39.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83a25cf98105baa966497416dbd42565ce3a8cf8dbfd59803ec9ad46f3126399" +dependencies = [ + "cc", + "cmake", + "dunce", + "fs_extra", +] + [[package]] name = "backtrace" version = "0.3.74" @@ -886,10 +908,11 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.19" +version = "1.2.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e3a13707ac958681c13b39b458c073d0d9bc8a22cb1b2f4c8e55eb72c13f362" +checksum = "43c5703da9466b66a946814e1adf53ea2c90f10063b86290cc9eb67ce3478a20" dependencies = [ + "find-msvc-tools", "jobserver", "libc", "shlex", @@ -968,7 +991,7 @@ dependencies = [ "iana-time-zone", "num-traits", "serde", - "windows-link", + "windows-link 0.1.1", ] [[package]] @@ -1024,6 +1047,15 @@ dependencies = [ "error-code", ] +[[package]] +name = "cmake" +version = "0.1.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0f78a02292a74a88ac736019ab962ece0bc380e3f977bf72e376c5d78ff0678" +dependencies = [ + "cc", +] + [[package]] name = "colorchoice" version = "1.0.3" @@ -1224,6 +1256,12 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "critical-section" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" + [[package]] name = "crossbeam-channel" version = "0.5.15" @@ -1233,6 +1271,15 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + [[package]] name = "crossbeam-queue" version = "0.3.12" @@ -1764,6 +1811,18 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3d8a32ae18130a3c84dd492d4215c3d913c3b07c6b63c2eb3eb7ff1101ab7bf" +[[package]] +name = "enum-as-inner" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1e6a265c649f3f5979b601d26f1d05ada116434c87741c9493cb56218f76cbc" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "syn 2.0.100", +] + [[package]] name = "enumflags2" version = "0.7.11" @@ -1931,6 +1990,12 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + [[package]] name = "fixedbitset" version = "0.4.2" @@ -2021,6 +2086,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + [[package]] name = "fsevent-sys" version = "4.1.0" @@ -2611,6 +2682,52 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hickory-proto" +version = "0.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8a6fe56c0038198998a6f217ca4e7ef3a5e51f46163bd6dd60b5c71ca6c6502" +dependencies = [ + "async-trait", + "cfg-if", + "data-encoding", + "enum-as-inner", + "futures-channel", + "futures-io", + "futures-util", + "idna", + "ipnet", + "once_cell", + "rand 0.9.0", + "ring", + "thiserror 2.0.12", + "tinyvec", + "tokio", + "tracing", + "url", +] + +[[package]] +name = "hickory-resolver" +version = "0.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc62a9a99b0bfb44d2ab95a7208ac952d31060efc16241c87eaf36406fecf87a" +dependencies = [ + "cfg-if", + "futures-util", + "hickory-proto", + "ipconfig", + "moka", + "once_cell", + "parking_lot", + "rand 0.9.0", + "resolv-conf", + "smallvec", + "thiserror 2.0.12", + "tokio", + "tracing", +] + [[package]] name = "hkdf" version = "0.12.4" @@ -2736,7 +2853,6 @@ dependencies = [ "hyper", "hyper-util", "rustls", - "rustls-native-certs", "rustls-pki-types", "tokio", "tokio-rustls", @@ -2778,12 +2894,12 @@ dependencies = [ "libc", "percent-encoding", "pin-project-lite", - "socket2", + "socket2 0.5.9", "system-configuration", "tokio", "tower-service", "tracing", - "windows-registry", + "windows-registry 0.5.1", ] [[package]] @@ -3091,6 +3207,19 @@ dependencies = [ "zeroize", ] +[[package]] +name = "ipconfig" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d40460c0ce33d6ce4b0630ad68ff63d6661961c48b6dba35e5a4d81cfb48222" +dependencies = [ + "socket2 0.6.3", + "widestring", + "windows-registry 0.6.1", + "windows-result 0.4.1", + "windows-sys 0.61.2", +] + [[package]] name = "ipnet" version = "2.11.0" @@ -3623,6 +3752,23 @@ dependencies = [ "tokio", ] +[[package]] +name = "moka" +version = "0.12.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957228ad12042ee839f93c8f257b62b4c0ab5eaae1d4fa60de53b27c9d7c5046" +dependencies = [ + "crossbeam-channel", + "crossbeam-epoch", + "crossbeam-utils", + "equivalent", + "parking_lot", + "portable-atomic", + "smallvec", + "tagptr", + "uuid", +] + [[package]] name = "muda" version = "0.17.1" @@ -4125,6 +4271,10 @@ name = "once_cell" version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +dependencies = [ + "critical-section", + "portable-atomic", +] [[package]] name = "opaque-debug" @@ -4614,6 +4764,12 @@ dependencies = [ "universal-hash", ] +[[package]] +name = "portable-atomic" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" + [[package]] name = "powerfmt" version = "0.2.0" @@ -4775,7 +4931,7 @@ dependencies = [ "quinn-udp", "rustc-hash", "rustls", - "socket2", + "socket2 0.5.9", "thiserror 2.0.12", "tokio", "tracing", @@ -4788,6 +4944,7 @@ version = "0.11.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "434b42fec591c96ef50e21e886936e66d3cc3f737104fdb9b737c40ffb94c098" dependencies = [ + "aws-lc-rs", "bytes", "getrandom 0.3.2", "lru-slab", @@ -4812,7 +4969,7 @@ dependencies = [ "cfg_aliases", "libc", "once_cell", - "socket2", + "socket2 0.5.9", "tracing", "windows-sys 0.59.0", ] @@ -5043,13 +5200,8 @@ checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" dependencies = [ "base64 0.22.1", "bytes", - "cookie", - "cookie_store", - "encoding_rs", - "futures-channel", "futures-core", "futures-util", - "h2", "http", "http-body", "http-body-util", @@ -5059,14 +5211,11 @@ dependencies = [ "hyper-util", "js-sys", "log", - "mime", - "mime_guess", "native-tls", "percent-encoding", "pin-project-lite", "quinn", "rustls", - "rustls-native-certs", "rustls-pki-types", "serde", "serde_json", @@ -5095,8 +5244,14 @@ checksum = "04e9018c9d814e5f30cc16a0f03271aeab3571e609612d9fe78c1aa8d11c2f62" dependencies = [ "base64 0.22.1", "bytes", + "cookie", + "cookie_store", + "encoding_rs", + "futures-channel", "futures-core", "futures-util", + "h2", + "hickory-resolver", "http", "http-body", "http-body-util", @@ -5106,9 +5261,13 @@ dependencies = [ "hyper-util", "js-sys", "log", + "mime", + "mime_guess", "native-tls", + "once_cell", "percent-encoding", "pin-project-lite", + "quinn", "rustls", "rustls-pki-types", "rustls-platform-verifier", @@ -5129,6 +5288,12 @@ dependencies = [ "web-sys", ] +[[package]] +name = "resolv-conf" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e061d1b48cb8d38042de4ae0a7a6401009d6143dc80d2e2d6f31f0bdd6470c7" + [[package]] name = "rfc6979" version = "0.4.0" @@ -5338,6 +5503,7 @@ version = "0.23.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7160e3e10bf4535308537f3c4e1641468cd0e485175d6163087c0393c7d46643" dependencies = [ + "aws-lc-rs", "once_cell", "ring", "rustls-pki-types", @@ -5401,6 +5567,7 @@ version = "0.103.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df33b2b81ac578cabaf06b89b0631153a3f416b0a886e8a7a1707fb51abbd1ef" dependencies = [ + "aws-lc-rs", "ring", "rustls-pki-types", "untrusted", @@ -5884,6 +6051,16 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "socket2" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" +dependencies = [ + "libc", + "windows-sys 0.60.2", +] + [[package]] name = "softbuffer" version = "0.4.6" @@ -6390,6 +6567,12 @@ dependencies = [ "version-compare", ] +[[package]] +name = "tagptr" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b2093cf4c8eb1e67749a6762251bc9cd836b6fc171623bd0a9d324d37af2417" + [[package]] name = "tao" version = "0.34.5" @@ -6678,8 +6861,8 @@ dependencies = [ "thiserror 2.0.12", "tracing", "url", - "windows-registry", - "windows-result", + "windows-registry 0.5.1", + "windows-result 0.3.2", ] [[package]] @@ -6770,7 +6953,7 @@ dependencies = [ "data-url", "http", "regex", - "reqwest 0.12.28", + "reqwest 0.13.1", "schemars", "serde", "serde_json", @@ -7370,7 +7553,7 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2", + "socket2 0.5.9", "tokio-macros", "tracing", "windows-sys 0.52.0", @@ -8323,6 +8506,12 @@ dependencies = [ "wasite", ] +[[package]] +name = "widestring" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72069c3113ab32ab29e5584db3c6ec55d416895e60715417b5b883a357c3e471" + [[package]] name = "win7-notifications" version = "0.4.5" @@ -8401,7 +8590,7 @@ dependencies = [ "windows-collections", "windows-core", "windows-future", - "windows-link", + "windows-link 0.1.1", "windows-numerics", ] @@ -8422,9 +8611,9 @@ checksum = "4763c1de310c86d75a878046489e2e5ba02c649d185f21c67d4cf8a56d098980" dependencies = [ "windows-implement", "windows-interface", - "windows-link", - "windows-result", - "windows-strings", + "windows-link 0.1.1", + "windows-result 0.3.2", + "windows-strings 0.4.0", ] [[package]] @@ -8434,7 +8623,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a1d6bbefcb7b60acd19828e1bc965da6fcf18a7e39490c5f8be71e54a19ba32" dependencies = [ "windows-core", - "windows-link", + "windows-link 0.1.1", ] [[package]] @@ -8465,6 +8654,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38" +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + [[package]] name = "windows-numerics" version = "0.2.0" @@ -8472,7 +8667,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1" dependencies = [ "windows-core", - "windows-link", + "windows-link 0.1.1", ] [[package]] @@ -8481,9 +8676,20 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad1da3e436dc7653dfdf3da67332e22bff09bb0e28b0239e1624499c7830842e" dependencies = [ - "windows-link", - "windows-result", - "windows-strings", + "windows-link 0.1.1", + "windows-result 0.3.2", + "windows-strings 0.4.0", +] + +[[package]] +name = "windows-registry" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02752bf7fbdcce7f2a27a742f798510f3e5ad88dbe84871e5168e2120c3d5720" +dependencies = [ + "windows-link 0.2.1", + "windows-result 0.4.1", + "windows-strings 0.5.1", ] [[package]] @@ -8492,7 +8698,16 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c64fd11a4fd95df68efcfee5f44a294fe71b8bc6a91993e2791938abcc712252" dependencies = [ - "windows-link", + "windows-link 0.1.1", +] + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link 0.2.1", ] [[package]] @@ -8501,7 +8716,16 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a2ba9642430ee452d5a7aa78d72907ebe8cfda358e8cb7918a2050581322f97" dependencies = [ - "windows-link", + "windows-link 0.1.1", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link 0.2.1", ] [[package]] @@ -8549,6 +8773,15 @@ dependencies = [ "windows-targets 0.53.2", ] +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link 0.2.1", +] + [[package]] name = "windows-targets" version = "0.42.2" @@ -8617,7 +8850,7 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e04a5c6627e310a23ad2358483286c7df260c964eb2d003d8efd6d0f4e79265c" dependencies = [ - "windows-link", + "windows-link 0.1.1", ] [[package]] diff --git a/README.md b/README.md index cdf239bcf5..196c548840 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ This repo and all plugins require a Rust version of at least **1.77.2** | [stronghold](plugins/stronghold) | Encrypted, secure database. | ✅ | ✅ | ✅ | ? | ? | | [updater](plugins/updater) | In-app updates for Tauri applications. | ✅ | ✅ | ✅ | ❌ | ❌ | | [upload](plugins/upload) | Tauri plugin for file uploads through HTTP. | ✅ | ✅ | ✅ | ✅ | ✅ | -| [websocket](plugins/websocket) | Open a WebSocket connection using a Rust client in JS. | ✅ | ✅ | ✅ | ? | ? | +| [websocket](plugins/websocket) | Open a WebSocket connection using a Rust client in JS. | ✅ | ✅ | ✅ | ✅ | ✅ | | [window-state](plugins/window-state) | Persist window sizes and positions. | ✅ | ✅ | ✅ | ❌ | ❌ | - ✅: (Partially) Supported diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000000..bfafb5a7a3 --- /dev/null +++ b/flake.lock @@ -0,0 +1,100 @@ +{ + "nodes": { + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1755585599, + "narHash": "sha256-tl/0cnsqB/Yt7DbaGMel2RLa7QG5elA8lkaOXli6VdY=", + "owner": "nix-community", + "repo": "fenix", + "rev": "6ed03ef4c8ec36d193c18e06b9ecddde78fb7e42", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1755186698, + "narHash": "sha256-wNO3+Ks2jZJ4nTHMuks+cxAiVBGNuEBXsT29Bz6HASo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "fbcf476f790d8a217c3eab4e12033dc4a0f6d23c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "fenix": "fenix", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1755504847, + "narHash": "sha256-VX0B9hwhJypCGqncVVLC+SmeMVd/GAYbJZ0MiiUn2Pk=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "a905e3b21b144d77e1b304e49f3264f6f8d4db75", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000000..73e3bb2dd6 --- /dev/null +++ b/flake.nix @@ -0,0 +1,66 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + fenix.url = "github:nix-community/fenix"; + fenix.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = + { + self, + nixpkgs, + flake-utils, + fenix, + }: + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = import nixpkgs { + system = system; + }; + + packages = with pkgs; [ + curl + wget + pkg-config + + cargo-tauri + cargo-info + cargo-udeps + + ( + with fenix.packages.${system}; + combine [ + complete.rustc + complete.rust-src + complete.cargo + complete.clippy + complete.rustfmt + complete.rust-analyzer + ] + ) + ]; + + libraries = with pkgs; [ + gtk3 + libsoup_3 + webkitgtk_4_1 + cairo + gdk-pixbuf + glib + dbus + openssl + librsvg + ]; + in + { + devShell = pkgs.mkShell { + buildInputs = packages ++ libraries; + + LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath libraries}:$LD_LIBRARY_PATH"; + XDG_DATA_DIRS = "${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}:${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}:$XDG_DATA_DIRS"; + }; + } + ); +} diff --git a/plugins/http/Cargo.toml b/plugins/http/Cargo.toml index 51aee7d5dc..6610db819f 100644 --- a/plugins/http/Cargo.toml +++ b/plugins/http/Cargo.toml @@ -34,7 +34,7 @@ tauri-plugin-fs = { path = "../fs", version = "2.5.0" } urlpattern = "0.3" regex = "1" http = "1" -reqwest = { version = "0.12", default-features = false } +reqwest = { version = "0.13", default-features = false } url = { workspace = true } data-url = "0.3" cookie_store = { version = "0.22", optional = true, features = ["serde"] } @@ -43,10 +43,9 @@ tracing = { workspace = true, optional = true } [features] default = [ - "rustls-tls", + "rustls", "http2", "charset", - "macos-system-configuration", "cookies", ] multipart = ["reqwest/multipart"] @@ -54,22 +53,19 @@ json = ["reqwest/json"] stream = ["reqwest/stream"] native-tls = ["reqwest/native-tls"] native-tls-vendored = ["reqwest/native-tls-vendored"] -native-tls-alpn = ["reqwest/native-tls-alpn"] -rustls-tls = ["reqwest/rustls-tls"] -rustls-tls-manual-roots = ["reqwest/rustls-tls-manual-roots"] -rustls-tls-webpki-roots = ["reqwest/rustls-tls-webpki-roots"] -rustls-tls-native-roots = ["reqwest/rustls-tls-native-roots"] +native-tls-no-alpn = ["reqwest/native-tls-no-alpn"] +rustls = ["reqwest/rustls"] +rustls-no-provider = ["reqwest/rustls-no-provider"] blocking = ["reqwest/blocking"] cookies = ["reqwest/cookies", "dep:cookie_store", "dep:bytes"] gzip = ["reqwest/gzip"] brotli = ["reqwest/brotli"] deflate = ["reqwest/deflate"] zstd = ["reqwest/zstd"] -trust-dns = ["reqwest/trust-dns"] +hickory-dns = ["reqwest/hickory-dns"] socks = ["reqwest/socks"] http2 = ["reqwest/http2"] charset = ["reqwest/charset"] -macos-system-configuration = ["reqwest/macos-system-configuration"] unsafe-headers = [] tracing = ["dep:tracing"] dangerous-settings = [] diff --git a/plugins/http/src/lib.rs b/plugins/http/src/lib.rs index 364d3bfffc..04ca8466ef 100644 --- a/plugins/http/src/lib.rs +++ b/plugins/http/src/lib.rs @@ -6,8 +6,8 @@ pub use reqwest; use tauri::{ - plugin::{Builder, TauriPlugin}, Manager, Runtime, + plugin::{Builder, TauriPlugin}, }; pub use error::{Error, Result}; @@ -21,9 +21,9 @@ mod scope; #[cfg(feature = "cookies")] const COOKIES_FILENAME: &str = ".cookies"; -pub(crate) struct Http { +pub struct Http { #[cfg(feature = "cookies")] - cookies_jar: std::sync::Arc, + pub cookies_jar: std::sync::Arc, } pub fn init() -> TauriPlugin { diff --git a/plugins/websocket/Cargo.toml b/plugins/websocket/Cargo.toml index fcdf0db089..9d5724801f 100644 --- a/plugins/websocket/Cargo.toml +++ b/plugins/websocket/Cargo.toml @@ -32,7 +32,7 @@ futures-util = "0.3" tokio = { version = "1", features = ["net", "sync"] } tokio-tungstenite = { version = "0.28" } rustls = { version = "0.23", default-features = false, features = [ - "ring", + "aws_lc_rs", ], optional = true } [features] diff --git a/plugins/websocket/src/lib.rs b/plugins/websocket/src/lib.rs index 9743e2cde0..e4b6aa8afb 100644 --- a/plugins/websocket/src/lib.rs +++ b/plugins/websocket/src/lib.rs @@ -9,13 +9,16 @@ html_favicon_url = "https://github.com/tauri-apps/tauri/raw/dev/app-icon.png" )] -use futures_util::{stream::SplitSink, SinkExt, StreamExt}; -use http::header::{HeaderName, HeaderValue}; -use serde::{ser::Serializer, Deserialize, Serialize}; +use futures_util::{SinkExt, StreamExt, stream::SplitSink}; +use http::{ + HeaderMap, + header::{HeaderName, HeaderValue}, +}; +use serde::{Deserialize, Serialize, ser::Serializer}; use tauri::{ + AppHandle, Manager, Runtime, State, Window, ipc::Channel, plugin::{Builder as PluginBuilder, TauriPlugin}, - Manager, Runtime, State, Window, }; use tokio::{net::TcpStream, sync::Mutex}; #[cfg(any( @@ -31,12 +34,12 @@ use tokio_tungstenite::connect_async_tls_with_config; )))] use tokio_tungstenite::connect_async_with_config; use tokio_tungstenite::{ + Connector, MaybeTlsStream, WebSocketStream, tungstenite::{ + Message, client::IntoClientRequest, protocol::{CloseFrame as ProtocolCloseFrame, WebSocketConfig}, - Message, }, - Connector, MaybeTlsStream, WebSocketStream, }; use std::collections::HashMap; @@ -159,7 +162,7 @@ async fn connect( config: Option, ) -> Result { let id = rand::random(); - let mut request = url.into_client_request()?; + let mut request = url.as_str().into_client_request()?; if let Some(headers) = config.as_ref().and_then(|c| c.headers.as_ref()) { for (k, v) in headers { @@ -169,6 +172,10 @@ async fn connect( } } + if let Some(state) = window.app_handle().try_state::>() { + (state.inner().0)(url, request.headers_mut(), window.app_handle()); + } + #[cfg(any( feature = "rustls-tls", feature = "rustls-tls-native-roots", @@ -266,27 +273,45 @@ async fn send( } pub fn init() -> TauriPlugin { - Builder::default().build() + Builder::new().build() } -#[derive(Default)] -pub struct Builder { +type RqCb = + Box, &AppHandle) + Send + Sync + 'static>; + +/// Struct to provide concrete type for the manager +struct RequestCallback(RqCb); + +pub struct Builder { tls_connector: Option, + merge_headers: Option>, } -impl Builder { +impl Builder +where + R: Runtime, +{ pub fn new() -> Self { Self { tls_connector: None, + merge_headers: None, } } + /// add a callback which is able to modify the initial headers of the http upgrade request. + /// This is useful for scenarios where the frontend may not know all the required headers that must be sent. + /// e.g. in the scenario of http-only cookies + pub fn merge_header_callback(mut self, cb: RqCb) -> Self { + self.merge_headers.replace(RequestCallback(cb)); + self + } + pub fn tls_connector(mut self, connector: Connector) -> Self { self.tls_connector.replace(connector); self } - pub fn build(self) -> TauriPlugin { + pub fn build(self) -> TauriPlugin { PluginBuilder::new("websocket") .invoke_handler(tauri::generate_handler![connect, send]) .setup(|app, _api| { @@ -296,10 +321,15 @@ impl Builder { && rustls::crypto::CryptoProvider::get_default().is_none() { // This can only fail if there is already a default provider which we checked for already. - let _ = rustls::crypto::ring::default_provider().install_default(); + let _ = rustls::crypto::aws_lc_rs::default_provider().install_default(); } app.manage(ConnectionManager::default()); + + if let Some(cb) = self.merge_headers { + app.manage(cb); + } + #[cfg(any( feature = "rustls-tls", feature = "rustls-tls-native-roots",