From b6c897bd0fd91417a97789ec8ca281eff7935d14 Mon Sep 17 00:00:00 2001 From: Davide Baldo Date: Fri, 18 Aug 2023 12:07:17 +0200 Subject: [PATCH] feat(rust): added ockam:// scheme association in app for linux and mac --- Cargo.lock | 233 ++++++++---------- Cargo.toml | 5 + .../rust/ockam/ockam_app/Cargo.toml | 3 +- .../rust/ockam/ockam_app/src/app/events.rs | 1 + .../rust/ockam/ockam_app/src/app/mod.rs | 7 +- .../rust/ockam/ockam_app/src/app/process.rs | 6 + .../ockam/ockam_app/src/enroll/tray_menu.rs | 5 +- .../rust/ockam/ockam_app/src/lib.rs | 29 +++ .../ockam/ockam_app/src/linux_url_plugin.rs | 69 ++++++ .../rust/ockam/ockam_app/tauri.conf.json | 10 +- 10 files changed, 228 insertions(+), 140 deletions(-) create mode 100644 implementations/rust/ockam/ockam_app/src/linux_url_plugin.rs diff --git a/Cargo.lock b/Cargo.lock index ec2ed420c66..3ffac88fd69 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -188,9 +188,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.73" +version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f768393e7fabd388fe8409b13faa4d93ab0fef35db1508438dfdb066918bcf38" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" [[package]] name = "arrayref" @@ -339,7 +339,7 @@ checksum = "0e97ce7de6cf12de5d7226c73f5ba9811622f4db3a5b91b55c53e987e5f91cba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -356,7 +356,7 @@ checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -1279,9 +1279,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.21" +version = "4.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c27cdf28c0f604ba3f512b0c9a409f8de8513e4816705deb0498b627e7c3a3fd" +checksum = "b417ae4361bca3f5de378294fc7472d3c4ed86a5ef9f49e93ae722f432aae8d2" dependencies = [ "clap_builder", "clap_derive", @@ -1290,9 +1290,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.3.21" +version = "4.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08a9f1ab5e9f01a9b81f202e8562eb9a10de70abf9eaeac1be465c28b75aa4aa" +checksum = "9c90dc0f0e42c64bff177ca9d7be6fcc9ddb0f26a6e062174a61c84dd6c644d4" dependencies = [ "anstream", "anstyle", @@ -1308,7 +1308,7 @@ version = "4.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5fc443334c81a804575546c5a8a79b4913b50e28d69232903604cada1de817ce" dependencies = [ - "clap 4.3.21", + "clap 4.3.22", ] [[package]] @@ -1320,7 +1320,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -1335,7 +1335,7 @@ version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f2e32b579dae093c2424a8b7e2bea09c89da01e1ce5065eb2f0a6f1cc15cc1f" dependencies = [ - "clap 4.3.21", + "clap 4.3.22", "roff", ] @@ -1782,7 +1782,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331" dependencies = [ "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -1871,7 +1871,7 @@ checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -1919,7 +1919,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -1941,7 +1941,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core 0.20.3", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -2213,7 +2213,7 @@ dependencies = [ "darling 0.20.3", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -2224,9 +2224,9 @@ checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" [[package]] name = "dyn-clone" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "304e6508efa593091e97a9abbc10f90aa7ca635b6d2784feff3c89d41dd12272" +checksum = "bbfc4744c1b8f2a09adc0e55242f60b1af195d88596bd8700be74418c056c555" [[package]] name = "ecdsa" @@ -2394,7 +2394,7 @@ checksum = "5e9a1f9f7d83e59740248a6e14ecf93929ade55027844dfcea78beafccc15745" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -2490,9 +2490,9 @@ dependencies = [ [[package]] name = "fake" -version = "2.6.1" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a44c765350db469b774425ff1c833890b16ceb9612fb5d7c4bbdf4a1b55f876" +checksum = "7ba4cf08f2dafea0d018ba7051d6e90c78911c6e7438d9b7b029945379b2ac07" dependencies = [ "dummy", "rand 0.8.5", @@ -2661,7 +2661,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -2807,7 +2807,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -3870,9 +3870,9 @@ checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" [[package]] name = "libp2p-identity" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a38d6012784fe4cc14e6d443eb415b11fc7c456dc15d9f0d90d9b70bc7ac3ec1" +checksum = "686e73aff5e23efbb99bc85340ea6fd8686986aa7b283a881ba182cfca535ca9" dependencies = [ "bs58", "log", @@ -3893,25 +3893,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "libxdo" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00333b8756a3d28e78def82067a377de7fa61b24909000aeaa2b446a948d14db" -dependencies = [ - "libxdo-sys", -] - -[[package]] -name = "libxdo-sys" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db23b9e7e2b7831bbd8aac0bbeeeb7b68cbebc162b227e7052e8e55829a09212" -dependencies = [ - "libc", - "x11", -] - [[package]] name = "line-wrap" version = "0.1.1" @@ -4109,7 +4090,7 @@ checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -4199,7 +4180,7 @@ checksum = "c92f7fdae7086c11a137efb265ea1c20ed565dd8b17fcc1eda8e7e9a215b99ee" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -4264,9 +4245,9 @@ dependencies = [ [[package]] name = "muda" -version = "0.8.2" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47e33f46fb20f85553edb85e30a6a5231567f4103276ccdb5a2050613d253b1d" +checksum = "a7de0cd2fdb9ef32781658513eab9080a22b3a9775955019daaf1f54bd37753a" dependencies = [ "cocoa 0.25.0", "crossbeam-channel", @@ -4274,7 +4255,6 @@ dependencies = [ "gdk-pixbuf", "gtk", "keyboard-types", - "libxdo", "objc", "once_cell", "png", @@ -4681,7 +4661,6 @@ version = "0.1.0" dependencies = [ "log", "miette", - "muda", "ockam", "ockam_api", "ockam_command", @@ -4695,7 +4674,6 @@ dependencies = [ "tauri-plugin-log", "tauri-plugin-positioner", "tauri-plugin-window", - "tauri-runtime", "thiserror", "tokio", "tracing", @@ -4710,7 +4688,7 @@ dependencies = [ "async-recursion", "async-trait", "base64-url", - "clap 4.3.21", + "clap 4.3.22", "clap_complete", "clap_mangen", "cli-table", @@ -4868,7 +4846,7 @@ version = "0.30.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -5137,7 +5115,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -5260,7 +5238,7 @@ dependencies = [ "libc", "redox_syscall 0.3.5", "smallvec", - "windows-targets 0.48.2", + "windows-targets 0.48.3", ] [[package]] @@ -5441,7 +5419,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -5494,9 +5472,9 @@ dependencies = [ [[package]] name = "png" -version = "0.17.9" +version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59871cc5b6cce7eaccca5a802b4173377a1c2ba90654246789a8fa2334426d11" +checksum = "dd75bf2d8dd3702b9707cdbc56a5b9ef42cec752eb8b3bafc01234558442aa64" dependencies = [ "bitflags 1.3.2", "crc32fast", @@ -5719,9 +5697,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.32" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -6176,7 +6154,7 @@ checksum = "5a32af5427251d2e4be14fc151eabe18abb4a7aad5efee7044da9f096c906a43" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -6372,14 +6350,14 @@ checksum = "aafe972d60b0b9bee71a91b92fee2d4fb3c9d7e8f6b179aa99f27203d99a4816" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] name = "serde_json" -version = "1.0.104" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c" +checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" dependencies = [ "itoa 1.0.9", "ryu", @@ -6394,7 +6372,7 @@ checksum = "8725e1dfadb3a50f7e5ce0b1a540466f6ed3fe7a0fca2ac2b8b831d31316bd00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -6444,7 +6422,7 @@ dependencies = [ "darling 0.20.3", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -6482,7 +6460,7 @@ checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -7006,9 +6984,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.28" +version = "2.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" +checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a" dependencies = [ "proc-macro2", "quote", @@ -7066,9 +7044,9 @@ dependencies = [ [[package]] name = "tao" -version = "0.22.0" +version = "0.22.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60279ecb16c33a6cef45cd37a9602455c190942d20e360bd8499bff49f2a48f3" +checksum = "9f76221bce9db3af6b2b9cca4e92d8ea46c4cc88d785bc4b1a5cbcaab06f0b56" dependencies = [ "bitflags 1.3.2", "cairo-rs", @@ -7133,8 +7111,7 @@ checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a" [[package]] name = "tauri" version = "2.0.0-alpha.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fad0a5c32ce9e3e9862fb8cd433abf63e65ffea9b80dcc44d3d991e6794ea9a6" +source = "git+https://github.com/davide-baldo/tauri.git?branch=add-url-scheme#e14f090c905b7350b2bc5dac06a1a84ff64e55bf" dependencies = [ "anyhow", "bytes 1.4.0", @@ -7182,8 +7159,7 @@ dependencies = [ [[package]] name = "tauri-build" version = "2.0.0-alpha.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc47d3c84f4aeac397cd956267f3b8060c5a2dba78288a5ccf9a8b7a8c1e7025" +source = "git+https://github.com/davide-baldo/tauri.git?branch=add-url-scheme#e14f090c905b7350b2bc5dac06a1a84ff64e55bf" dependencies = [ "anyhow", "cargo_toml", @@ -7202,8 +7178,7 @@ dependencies = [ [[package]] name = "tauri-codegen" version = "2.0.0-alpha.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f98a67c7ef3cb3c25de91fe1fa16cc3681997f6ec99da0a7496d6feae2ea91e" +source = "git+https://github.com/davide-baldo/tauri.git?branch=add-url-scheme#e14f090c905b7350b2bc5dac06a1a84ff64e55bf" dependencies = [ "base64 0.21.2", "brotli", @@ -7228,8 +7203,7 @@ dependencies = [ [[package]] name = "tauri-macros" version = "2.0.0-alpha.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b01cb5f945c71e040c5d191c32598565ae26cc266a9d5d4f7dd2dc324c5cfdd0" +source = "git+https://github.com/davide-baldo/tauri.git?branch=add-url-scheme#e14f090c905b7350b2bc5dac06a1a84ff64e55bf" dependencies = [ "heck 0.4.1", "proc-macro2", @@ -7288,8 +7262,7 @@ dependencies = [ [[package]] name = "tauri-runtime" version = "1.0.0-alpha.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5ba2ea1c0b7a2c3e53259edc3c78527e9f40fa7b45f73c52ab5165e42f9d18a" +source = "git+https://github.com/davide-baldo/tauri.git?branch=add-url-scheme#e14f090c905b7350b2bc5dac06a1a84ff64e55bf" dependencies = [ "gtk", "http", @@ -7309,8 +7282,7 @@ dependencies = [ [[package]] name = "tauri-runtime-wry" version = "1.0.0-alpha.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "095d8a6cb312211bd0ed6b51f078be2e5bba4e3244b5fdbe39fce2ebfc0d7a15" +source = "git+https://github.com/davide-baldo/tauri.git?branch=add-url-scheme#e14f090c905b7350b2bc5dac06a1a84ff64e55bf" dependencies = [ "cocoa 0.24.1", "gtk", @@ -7330,8 +7302,7 @@ dependencies = [ [[package]] name = "tauri-utils" version = "2.0.0-alpha.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06bcd7c6f67fd6371dcc22da7d7f26ec12c4eae26ad7bc54943bb9f35b5db302" +source = "git+https://github.com/davide-baldo/tauri.git?branch=add-url-scheme#e14f090c905b7350b2bc5dac06a1a84ff64e55bf" dependencies = [ "brotli", "ctor", @@ -7476,22 +7447,22 @@ checksum = "8eaa81235c7058867fa8c0e7314f33dcce9c215f535d1913822a2b3f5e289f3c" [[package]] name = "thiserror" -version = "1.0.45" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dedd246497092a89beedfe2c9f176d44c1b672ea6090edc20544ade01fbb7ea0" +checksum = "97a802ec30afc17eee47b2855fc72e0c4cd62be9b4efe6591edde0ec5bd68d8f" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.45" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d7b1fadccbbc7e19ea64708629f9d8dccd007c260d66485f20a6d41bc1cf4b3" +checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -7563,9 +7534,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.31.0" +version = "1.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40de3a2ba249dcb097e01be5e67a5ff53cf250397715a071a81543e8a832a920" +checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" dependencies = [ "backtrace", "bytes 1.4.0", @@ -7599,7 +7570,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -7765,7 +7736,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -7832,9 +7803,9 @@ dependencies = [ [[package]] name = "tray-icon" -version = "0.8.1" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b0e5bec13da15e62330e9bcf8b9fd42489b5acfe29ac8fec7ed659dbee21d9" +checksum = "6b164327e17101c78ba3dfdf879b977027ef1bd7855668ac30063de21fc02447" dependencies = [ "cocoa 0.25.0", "core-graphics 0.23.1", @@ -7866,9 +7837,9 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "trybuild" -version = "1.0.82" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a84e0202ea606ba5ebee8507ab2bfbe89b98551ed9b8f0be198109275cff284b" +checksum = "6df60d81823ed9c520ee897489573da4b1d79ffbe006b8134f46de1a1aa03555" dependencies = [ "basic-toml", "dissimilar", @@ -8207,7 +8178,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", "wasm-bindgen-shared", ] @@ -8241,7 +8212,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -8361,7 +8332,7 @@ checksum = "ac1345798ecd8122468840bcdf1b95e5dc6d2206c5e4b0eafa078d061f59c9bc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] @@ -8429,7 +8400,7 @@ checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ "windows-implement", "windows-interface", - "windows-targets 0.48.2", + "windows-targets 0.48.3", ] [[package]] @@ -8485,7 +8456,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.2", + "windows-targets 0.48.3", ] [[package]] @@ -8505,17 +8476,17 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.48.2" +version = "0.48.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1eeca1c172a285ee6c2c84c341ccea837e7c01b12fbb2d0fe3c9e550ce49ec8" +checksum = "27f51fb4c64f8b770a823c043c7fad036323e1c48f55287b7bbb7987b2fcdf3b" dependencies = [ - "windows_aarch64_gnullvm 0.48.2", - "windows_aarch64_msvc 0.48.2", - "windows_i686_gnu 0.48.2", - "windows_i686_msvc 0.48.2", - "windows_x86_64_gnu 0.48.2", - "windows_x86_64_gnullvm 0.48.2", - "windows_x86_64_msvc 0.48.2", + "windows_aarch64_gnullvm 0.48.3", + "windows_aarch64_msvc 0.48.3", + "windows_i686_gnu 0.48.3", + "windows_i686_msvc 0.48.3", + "windows_x86_64_gnu 0.48.3", + "windows_x86_64_gnullvm 0.48.3", + "windows_x86_64_msvc 0.48.3", ] [[package]] @@ -8532,9 +8503,9 @@ checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.2" +version = "0.48.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b10d0c968ba7f6166195e13d593af609ec2e3d24f916f081690695cf5eaffb2f" +checksum = "fde1bb55ae4ce76a597a8566d82c57432bc69c039449d61572a7a353da28f68c" [[package]] name = "windows_aarch64_msvc" @@ -8544,9 +8515,9 @@ checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_aarch64_msvc" -version = "0.48.2" +version = "0.48.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "571d8d4e62f26d4932099a9efe89660e8bd5087775a2ab5cdd8b747b811f1058" +checksum = "1513e8d48365a78adad7322fd6b5e4c4e99d92a69db8df2d435b25b1f1f286d4" [[package]] name = "windows_i686_gnu" @@ -8556,9 +8527,9 @@ checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_gnu" -version = "0.48.2" +version = "0.48.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2229ad223e178db5fbbc8bd8d3835e51e566b8474bfca58d2e6150c48bb723cd" +checksum = "60587c0265d2b842298f5858e1a5d79d146f9ee0c37be5782e92a6eb5e1d7a83" [[package]] name = "windows_i686_msvc" @@ -8568,9 +8539,9 @@ checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_i686_msvc" -version = "0.48.2" +version = "0.48.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "600956e2d840c194eedfc5d18f8242bc2e17c7775b6684488af3a9fff6fe3287" +checksum = "224fe0e0ffff5d2ea6a29f82026c8f43870038a0ffc247aa95a52b47df381ac4" [[package]] name = "windows_x86_64_gnu" @@ -8580,9 +8551,9 @@ checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnu" -version = "0.48.2" +version = "0.48.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea99ff3f8b49fb7a8e0d305e5aec485bd068c2ba691b6e277d29eaeac945868a" +checksum = "62fc52a0f50a088de499712cbc012df7ebd94e2d6eb948435449d76a6287e7ad" [[package]] name = "windows_x86_64_gnullvm" @@ -8592,9 +8563,9 @@ checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.2" +version = "0.48.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1a05a1ece9a7a0d5a7ccf30ba2c33e3a61a30e042ffd247567d1de1d94120d" +checksum = "2093925509d91ea3d69bcd20238f4c2ecdb1a29d3c281d026a09705d0dd35f3d" [[package]] name = "windows_x86_64_msvc" @@ -8604,15 +8575,15 @@ checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "windows_x86_64_msvc" -version = "0.48.2" +version = "0.48.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d419259aba16b663966e29e6d7c6ecfa0bb8425818bb96f6f1f3c3eb71a6e7b9" +checksum = "b6ade45bc8bf02ae2aa34a9d54ba660a1a58204da34ba793c00d83ca3730b5f1" [[package]] name = "winnow" -version = "0.5.10" +version = "0.5.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5504cc7644f4b593cbc05c4a55bf9bd4e94b867c3c0bd440934174d50482427d" +checksum = "d09770118a7eb1ccaf4a594a221334119a44a814fcb0d31c5b85e83e97227a97" dependencies = [ "memchr", ] @@ -8638,9 +8609,9 @@ dependencies = [ [[package]] name = "wry" -version = "0.31.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c6289018fa3cbc051c13f4ae1a102d80c3f35a527456c75567eb2cad6989020" +checksum = "07bf838a5430184dfe0b1f568af7998a455c0df75a1df300a3894e0f181e7408" dependencies = [ "base64 0.21.2", "block", @@ -8821,7 +8792,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.29", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 3867805ce16..1b85d93f0aa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,3 +49,8 @@ inherits = "test" opt-level = 2 [profile.dev.package.adler] opt-level = 1 + +[patch.crates-io] +# temporary fork for url scheme - https://github.com/build-trust/ockam/issues/5667 +tauri = { git = "https://github.com/build-trust/tauri.git", branch="add-url-scheme" } +tauri-build = { git = "https://github.com/build-trust/tauri.git", branch="add-url-scheme" } diff --git a/implementations/rust/ockam/ockam_app/Cargo.toml b/implementations/rust/ockam/ockam_app/Cargo.toml index fe9dcbcd662..2da41fbfd1b 100644 --- a/implementations/rust/ockam/ockam_app/Cargo.toml +++ b/implementations/rust/ockam/ockam_app/Cargo.toml @@ -47,9 +47,8 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" tauri = { version = "2.0.0-alpha.11", features = ["tray-icon"] } tauri-plugin-log = "2.0.0-alpha.1" -tauri-plugin-positioner = { version = "2.0.0-alpha.1", features = ["tray-icon"]} +tauri-plugin-positioner = { version = "2.0.0-alpha.1", features = ["tray-icon"] } tauri-plugin-window = "2.0.0-alpha.1" -tauri-runtime = "1.0.0-alpha.0" thiserror = "1.0.40" tokio = { version = "1.30.0", features = ["time"] } tracing = "0.1" diff --git a/implementations/rust/ockam/ockam_app/src/app/events.rs b/implementations/rust/ockam/ockam_app/src/app/events.rs index 57def1d305d..42904253529 100644 --- a/implementations/rust/ockam/ockam_app/src/app/events.rs +++ b/implementations/rust/ockam/ockam_app/src/app/events.rs @@ -1 +1,2 @@ pub const SYSTEM_TRAY_ON_UPDATE: &str = "app/system_tray/on_update"; +pub const URL_OPEN: &str = "app/url/open"; diff --git a/implementations/rust/ockam/ockam_app/src/app/mod.rs b/implementations/rust/ockam/ockam_app/src/app/mod.rs index c58c0319a4f..21acd8c0b24 100644 --- a/implementations/rust/ockam/ockam_app/src/app/mod.rs +++ b/implementations/rust/ockam/ockam_app/src/app/mod.rs @@ -1,3 +1,4 @@ +use log::debug; use std::error::Error; use tauri::tray::TrayIconBuilder; @@ -40,8 +41,12 @@ pub fn setup_app(app: &mut App) -> Result<(), Box> { app_handle .tray() .unwrap() - .set_menu(Some(build_tray_menu(&app_handle).await.clone())) + .set_menu(Some(build_tray_menu(&app_handle).await)) }); }); + + app.listen_global(events::URL_OPEN, move |event| { + debug!("URL_OPEN event received: {}", event.payload().unwrap_or("")); + }); Ok(()) } diff --git a/implementations/rust/ockam/ockam_app/src/app/process.rs b/implementations/rust/ockam/ockam_app/src/app/process.rs index ca252bc243d..d049d39288b 100644 --- a/implementations/rust/ockam/ockam_app/src/app/process.rs +++ b/implementations/rust/ockam/ockam_app/src/app/process.rs @@ -3,6 +3,12 @@ use tauri::{AppHandle, Manager, RunEvent, Wry}; /// This is the function dispatching application events pub fn process_application_event(app: &AppHandle, event: RunEvent) { match event { + #[cfg(any(target_os = "macos", target_os = "ios"))] + RunEvent::Opened { urls } => { + urls.into_iter().for_each(|url| { + app.trigger_global(crate::app::events::URL_OPEN, Some(url.into())); + }); + } RunEvent::ExitRequested { api, .. } => { api.prevent_exit(); } diff --git a/implementations/rust/ockam/ockam_app/src/enroll/tray_menu.rs b/implementations/rust/ockam/ockam_app/src/enroll/tray_menu.rs index ceeb9a362b5..d5dd4df814a 100644 --- a/implementations/rust/ockam/ockam_app/src/enroll/tray_menu.rs +++ b/implementations/rust/ockam/ockam_app/src/enroll/tray_menu.rs @@ -1,10 +1,7 @@ use crate::app::AppState; +use crate::enroll::enroll_user::enroll_user; use tauri::menu::{IconMenuItem, MenuBuilder, MenuItem, NativeIcon}; use tauri::{AppHandle, Manager, Runtime, State}; -#[cfg(target_os = "macos")] -use tauri_runtime::menu::NativeImage; - -use crate::enroll::enroll_user::enroll_user; pub const ENROLL_MENU_HEADER_ID: &str = "enroll-header"; pub const ENROLL_MENU_ID: &str = "enroll"; diff --git a/implementations/rust/ockam/ockam_app/src/lib.rs b/implementations/rust/ockam/ockam_app/src/lib.rs index d6db6ba4afb..32428ced133 100644 --- a/implementations/rust/ockam/ockam_app/src/lib.rs +++ b/implementations/rust/ockam/ockam_app/src/lib.rs @@ -7,6 +7,8 @@ mod enroll; mod error; #[cfg(feature = "invitations")] mod invitations; +#[cfg(target_os = "linux")] +mod linux_url_plugin; mod options; mod platform; #[cfg(feature = "invitations")] @@ -15,6 +17,29 @@ mod shared_service; #[cfg_attr(mobile, tauri::mobile_entry_point)] pub fn run() { + //On linux only, to handle ockam:// link argument from args we check if + //the app is already running, send a packet to it via unix socket. + //Using unix socket rather than ockam, to fully separate concerns. + #[cfg(target_os = "linux")] + { + use std::io::Write; + use std::os::unix::net::UnixStream; + + let mut args = std::env::args(); + args.next(); //skip the first argument which is the executable name + let args: Vec = args.collect(); + + //if we can connect to the socket then the app is already running + //if it's not running yet the arguments will be checked upon startup + if !args.is_empty() && args[0].starts_with("ockam:") { + if let Ok(mut stream) = UnixStream::connect(linux_url_plugin::open_url_sock_path()) { + stream.write_all(args[0].as_bytes()).unwrap(); + stream.flush().unwrap(); + return; + } + } + } + // For now, the application only consists of a system tray with several menu items #[cfg_attr(not(feature = "invitations"), allow(unused_mut))] let mut builder = tauri::Builder::default() @@ -29,6 +54,10 @@ pub fn run() { { builder = builder.plugin(projects::plugin::init()); builder = builder.plugin(invitations::plugin::init()); + #[cfg(target_os = "linux")] + { + builder = builder.plugin(linux_url_plugin::init()); + } } let mut app = builder diff --git a/implementations/rust/ockam/ockam_app/src/linux_url_plugin.rs b/implementations/rust/ockam/ockam_app/src/linux_url_plugin.rs new file mode 100644 index 00000000000..f69b2394474 --- /dev/null +++ b/implementations/rust/ockam/ockam_app/src/linux_url_plugin.rs @@ -0,0 +1,69 @@ +use log::{info, warn}; +use std::os::unix::fs::PermissionsExt; +use std::time::Duration; + +use tauri::{ + async_runtime::spawn, + plugin::{Builder, TauriPlugin}, + Manager, Runtime, +}; +use tokio::io::AsyncReadExt; +use tokio::net::UnixListener; +use tokio::time::sleep; + +pub(crate) fn open_url_sock_path() -> String { + let runtime_directory = std::env::var("XDG_RUNTIME_DIR").unwrap_or("/tmp".to_string()); + format!("{runtime_directory}/ockam-open-url-sock") +} +const ONLY_WRITE_FROM_USER_PERMISSIONS: u32 = 0o200; + +pub(crate) fn init() -> TauriPlugin { + Builder::new("linux-url") + .setup(|app, _api| { + let handle = app.clone(); + spawn(async move { + let sock_path = &open_url_sock_path(); + //bind fails if the file already exists + let _ = std::fs::remove_file(sock_path); + let listener = UnixListener::bind(sock_path) + .unwrap_or_else(|_| panic!("cannot listener on {sock_path}")); + //only allow the current user to write to the socket + std::fs::set_permissions( + sock_path, + std::fs::Permissions::from_mode(ONLY_WRITE_FROM_USER_PERMISSIONS), + ) + .unwrap_or_else(|_| panic!("cannot set permissions on {sock_path}")); + + //wait a bit to let the app start + sleep(Duration::from_millis(250)).await; + + //check if we had an ockam:// argument passed to us + if let Some(url) = std::env::args().nth(1) { + if url.starts_with("ockam:") { + info!("received url: {}", url); + handle.trigger_global(crate::app::events::URL_OPEN, Some(url)); + } else { + warn!("ignored argument: {}", url); + } + } + + while let Ok((mut stream, _)) = listener.accept().await { + let mut buffer = [0; 4096]; + if let Ok(read_bytes) = stream.read(&mut buffer).await { + if let Ok(url) = String::from_utf8(buffer[..read_bytes].to_vec()) { + if url.starts_with("ockam:") { + info!("received url: {}", url); + handle.trigger_global(crate::app::events::URL_OPEN, Some(url)); + } else { + warn!("ignored url: {}", url); + } + } + } + //every connection is used only once + drop(stream); + } + }); + Ok(()) + }) + .build() +} diff --git a/implementations/rust/ockam/ockam_app/tauri.conf.json b/implementations/rust/ockam/ockam_app/tauri.conf.json index f408158abf4..3b2c42d035c 100644 --- a/implementations/rust/ockam/ockam_app/tauri.conf.json +++ b/implementations/rust/ockam/ockam_app/tauri.conf.json @@ -16,7 +16,7 @@ "version": "0.1.0" }, "tauri": { - "tray-icon": { + "trayIcon": { "iconPath": "icons/icon.png", "iconAsTemplate": true }, @@ -25,8 +25,14 @@ "category": "DeveloperTool", "copyright": "", "deb": { - "desktopTemplate": "packaging/linux/application-description-template" + "depends": [] }, + "schemeAssociations": [ + { + "scheme": ["ockam"], + "role": "Editor" + } + ], "externalBin": [], "icon": [ "icons/32x32.png",