aboutsummaryrefslogtreecommitdiffstats
path: root/ui/backend
diff options
context:
space:
mode:
authorEllie Huxtable <ellie@elliehuxtable.com>2024-05-28 14:54:05 +0100
committerGitHub <noreply@github.com>2024-05-28 14:54:05 +0100
commitfc4dfe4fffce05c91f6766024891bdb39b2a3299 (patch)
treea9a0923645a4e6f6047f25db0d2f4f25a984b4b0 /ui/backend
parentchore(deps): bump uuid from 1.7.0 to 1.8.0 (#2047) (diff)
downloadatuin-fc4dfe4fffce05c91f6766024891bdb39b2a3299.zip
feat(ui): use correct username on welcome screen (#2050)
* wip * fetch and use username
Diffstat (limited to 'ui/backend')
-rw-r--r--ui/backend/Cargo.lock200
-rw-r--r--ui/backend/Cargo.toml1
-rw-r--r--ui/backend/capabilities/migrated.json6
-rw-r--r--ui/backend/src/main.rs9
4 files changed, 194 insertions, 22 deletions
diff --git a/ui/backend/Cargo.lock b/ui/backend/Cargo.lock
index 9f659db1..253a6994 100644
--- a/ui/backend/Cargo.lock
+++ b/ui/backend/Cargo.lock
@@ -202,6 +202,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c59bdb34bc650a32731b31bd8f0829cc15d24a708ee31559e0bb34f2bc320cba"
[[package]]
+name = "atomic-waker"
+version = "1.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
+
+[[package]]
name = "atomic-write-file"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -217,7 +223,7 @@ version = "18.2.0"
dependencies = [
"async-trait",
"atuin-common",
- "base64 0.21.7",
+ "base64 0.22.1",
"clap",
"config",
"crypto_secretbox",
@@ -296,7 +302,7 @@ dependencies = [
"async-trait",
"atuin-client",
"atuin-common",
- "base64 0.21.7",
+ "base64 0.22.1",
"crossterm",
"directories",
"eyre",
@@ -1054,6 +1060,12 @@ dependencies = [
]
[[package]]
+name = "data-url"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c297a1c74b71ae29df00c3e22dd9534821d60eb9af5a0192823fa2acea70c2a"
+
+[[package]]
name = "der"
version = "0.7.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1909,6 +1921,25 @@ dependencies = [
]
[[package]]
+name = "h2"
+version = "0.4.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab"
+dependencies = [
+ "atomic-waker",
+ "bytes",
+ "fnv",
+ "futures-core",
+ "futures-sink",
+ "http 1.1.0",
+ "indexmap 2.2.6",
+ "slab",
+ "tokio",
+ "tokio-util",
+ "tracing",
+]
+
+[[package]]
name = "hashbrown"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2079,7 +2110,7 @@ dependencies = [
"futures-channel",
"futures-core",
"futures-util",
- "h2",
+ "h2 0.3.26",
"http 0.2.12",
"http-body 0.4.6",
"httparse",
@@ -2102,6 +2133,7 @@ dependencies = [
"bytes",
"futures-channel",
"futures-util",
+ "h2 0.4.5",
"http 1.1.0",
"http-body 1.0.0",
"httparse",
@@ -2121,9 +2153,26 @@ dependencies = [
"futures-util",
"http 0.2.12",
"hyper 0.14.28",
- "rustls",
+ "rustls 0.21.12",
+ "tokio",
+ "tokio-rustls 0.24.1",
+]
+
+[[package]]
+name = "hyper-rustls"
+version = "0.26.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a0bea761b46ae2b24eb4aef630d8d1c398157b6fc29e6350ecf090a0b70c952c"
+dependencies = [
+ "futures-util",
+ "http 1.1.0",
+ "hyper 1.3.1",
+ "hyper-util",
+ "rustls 0.22.4",
+ "rustls-pki-types",
"tokio",
- "tokio-rustls",
+ "tokio-rustls 0.25.0",
+ "tower-service",
]
[[package]]
@@ -3648,11 +3697,11 @@ dependencies = [
"encoding_rs",
"futures-core",
"futures-util",
- "h2",
+ "h2 0.3.26",
"http 0.2.12",
"http-body 0.4.6",
"hyper 0.14.28",
- "hyper-rustls",
+ "hyper-rustls 0.24.2",
"ipnet",
"js-sys",
"log",
@@ -3660,16 +3709,16 @@ dependencies = [
"once_cell",
"percent-encoding",
"pin-project-lite",
- "rustls",
+ "rustls 0.21.12",
"rustls-native-certs",
- "rustls-pemfile",
+ "rustls-pemfile 1.0.4",
"serde",
"serde_json",
"serde_urlencoded",
"sync_wrapper",
"system-configuration",
"tokio",
- "tokio-rustls",
+ "tokio-rustls 0.24.1",
"tower-service",
"url",
"wasm-bindgen",
@@ -3686,12 +3735,15 @@ checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10"
dependencies = [
"base64 0.22.1",
"bytes",
+ "encoding_rs",
"futures-core",
"futures-util",
+ "h2 0.4.5",
"http 1.1.0",
"http-body 1.0.0",
"http-body-util",
"hyper 1.3.1",
+ "hyper-rustls 0.26.0",
"hyper-util",
"ipnet",
"js-sys",
@@ -3700,11 +3752,16 @@ dependencies = [
"once_cell",
"percent-encoding",
"pin-project-lite",
+ "rustls 0.22.4",
+ "rustls-pemfile 2.1.2",
+ "rustls-pki-types",
"serde",
"serde_json",
"serde_urlencoded",
"sync_wrapper",
+ "system-configuration",
"tokio",
+ "tokio-rustls 0.25.0",
"tokio-util",
"tower-service",
"url",
@@ -3712,6 +3769,7 @@ dependencies = [
"wasm-bindgen-futures",
"wasm-streams",
"web-sys",
+ "webpki-roots 0.26.1",
"winreg 0.52.0",
]
@@ -3797,18 +3855,32 @@ checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e"
dependencies = [
"log",
"ring",
- "rustls-webpki",
+ "rustls-webpki 0.101.7",
"sct",
]
[[package]]
+name = "rustls"
+version = "0.22.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432"
+dependencies = [
+ "log",
+ "ring",
+ "rustls-pki-types",
+ "rustls-webpki 0.102.4",
+ "subtle",
+ "zeroize",
+]
+
+[[package]]
name = "rustls-native-certs"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00"
dependencies = [
"openssl-probe",
- "rustls-pemfile",
+ "rustls-pemfile 1.0.4",
"schannel",
"security-framework",
]
@@ -3823,6 +3895,22 @@ dependencies = [
]
[[package]]
+name = "rustls-pemfile"
+version = "2.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d"
+dependencies = [
+ "base64 0.22.1",
+ "rustls-pki-types",
+]
+
+[[package]]
+name = "rustls-pki-types"
+version = "1.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d"
+
+[[package]]
name = "rustls-webpki"
version = "0.101.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3833,6 +3921,17 @@ dependencies = [
]
[[package]]
+name = "rustls-webpki"
+version = "0.102.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ff448f7e92e913c4b7d4c6d8e4540a1724b319b4152b8aef6d4cf8339712b33e"
+dependencies = [
+ "ring",
+ "rustls-pki-types",
+ "untrusted",
+]
+
+[[package]]
name = "rustversion"
version = "1.0.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -4014,18 +4113,18 @@ dependencies = [
[[package]]
name = "serde"
-version = "1.0.200"
+version = "1.0.202"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ddc6f9cc94d67c0e21aaf7eda3a010fd3af78ebf6e096aa6e2e13c79749cce4f"
+checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
-version = "1.0.200"
+version = "1.0.202"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "856f046b9400cee3c8c94ed572ecdb752444c24528c035cd35882aad6f492bcb"
+checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838"
dependencies = [
"proc-macro2",
"quote",
@@ -4410,8 +4509,8 @@ dependencies = [
"once_cell",
"paste",
"percent-encoding",
- "rustls",
- "rustls-pemfile",
+ "rustls 0.21.12",
+ "rustls-pemfile 1.0.4",
"serde",
"serde_json",
"sha2",
@@ -4424,7 +4523,7 @@ dependencies = [
"tracing",
"url",
"uuid",
- "webpki-roots",
+ "webpki-roots 0.25.4",
]
[[package]]
@@ -4944,6 +5043,46 @@ dependencies = [
]
[[package]]
+name = "tauri-plugin-fs"
+version = "2.0.0-beta.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "35377195c6923beda5f29482a16b492d431de964389fca9aaf81a0f7e908023f"
+dependencies = [
+ "anyhow",
+ "glob",
+ "schemars",
+ "serde",
+ "serde_json",
+ "serde_repr",
+ "tauri",
+ "tauri-plugin",
+ "thiserror",
+ "url",
+ "uuid",
+]
+
+[[package]]
+name = "tauri-plugin-http"
+version = "2.0.0-beta.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ec2c535106b7a8c2e7c5abdb4b81568b185f0b00bb0d64c37e06a5f0a9729155"
+dependencies = [
+ "data-url",
+ "http 1.1.0",
+ "regex",
+ "reqwest 0.12.4",
+ "schemars",
+ "serde",
+ "serde_json",
+ "tauri",
+ "tauri-plugin",
+ "tauri-plugin-fs",
+ "thiserror",
+ "url",
+ "urlpattern",
+]
+
+[[package]]
name = "tauri-plugin-sql"
version = "2.0.0-beta.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -5192,7 +5331,18 @@ version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081"
dependencies = [
- "rustls",
+ "rustls 0.21.12",
+ "tokio",
+]
+
+[[package]]
+name = "tokio-rustls"
+version = "0.25.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f"
+dependencies = [
+ "rustls 0.22.4",
+ "rustls-pki-types",
"tokio",
]
@@ -5445,6 +5595,7 @@ dependencies = [
"syntect",
"tauri",
"tauri-build",
+ "tauri-plugin-http",
"tauri-plugin-sql",
"time",
"uuid",
@@ -5832,6 +5983,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1"
[[package]]
+name = "webpki-roots"
+version = "0.26.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b3de34ae270483955a94f4b21bdaaeb83d508bb84a01435f393818edb0012009"
+dependencies = [
+ "rustls-pki-types",
+]
+
+[[package]]
name = "webview2-com"
version = "0.30.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/ui/backend/Cargo.toml b/ui/backend/Cargo.toml
index 55bfccaa..782f8c9a 100644
--- a/ui/backend/Cargo.toml
+++ b/ui/backend/Cargo.toml
@@ -24,6 +24,7 @@ serde_json = "1.0"
time = "0.3.36"
uuid = "1.7.0"
syntect = "5.2.0"
+tauri-plugin-http = "2.0.0-beta"
[dependencies.sqlx]
version = "=0.7.3"
diff --git a/ui/backend/capabilities/migrated.json b/ui/backend/capabilities/migrated.json
index 70b8b077..ae4f101b 100644
--- a/ui/backend/capabilities/migrated.json
+++ b/ui/backend/capabilities/migrated.json
@@ -13,7 +13,11 @@
"tray:default",
"sql:allow-load",
"sql:allow-execute",
- "sql:allow-select"
+ "sql:allow-select",
+ {
+ "identifier": "http:default",
+ "allow": ["https://api.atuin.sh/*"]
+ }
],
"platforms": ["linux", "macOS", "windows", "android", "iOS"]
}
diff --git a/ui/backend/src/main.rs b/ui/backend/src/main.rs
index ce248d61..1616bff6 100644
--- a/ui/backend/src/main.rs
+++ b/ui/backend/src/main.rs
@@ -76,6 +76,11 @@ async fn config() -> Result<Settings, String> {
}
#[tauri::command]
+async fn session() -> Result<String, String> {
+ Settings::new().map_err(|e|e.to_string())?.session_token().map_err(|e|e.to_string())
+}
+
+#[tauri::command]
async fn home_info() -> Result<HomeInfo, String> {
let settings = Settings::new().map_err(|e| e.to_string())?;
let record_store_path = PathBuf::from(settings.record_store_path.as_str());
@@ -85,7 +90,7 @@ async fn home_info() -> Result<HomeInfo, String> {
let client = atuin_client::api_client::Client::new(
&settings.sync_address,
- &settings.session_token,
+ settings.session_token().map_err(|e|e.to_string())?.as_str(),
settings.network_connect_timeout,
settings.network_timeout,
)
@@ -132,6 +137,7 @@ fn main() {
aliases,
home_info,
config,
+ session,
dotfiles::aliases::import_aliases,
dotfiles::aliases::delete_alias,
dotfiles::aliases::set_alias,
@@ -140,6 +146,7 @@ fn main() {
dotfiles::vars::set_var,
])
.plugin(tauri_plugin_sql::Builder::default().build())
+ .plugin(tauri_plugin_http::init())
.run(tauri::generate_context!())
.expect("error while running tauri application");
}