In-app store, delta version support (#179)

* fix: windows launch

* feat: add necessary client fixes for store

* fix: keyring fix

* feat: delta version support

* feat: dl/disk progress

* feat: move to jwt auth

* fix: lint
This commit is contained in:
DecDuck
2026-02-06 00:30:27 +11:00
committed by GitHub
parent fc69ae30ab
commit 1f74d35bdc
23 changed files with 808 additions and 284 deletions
+28 -5
View File
@@ -1,10 +1,15 @@
use std::{collections::HashMap, env};
use std::{
collections::HashMap,
env,
time::{Duration, SystemTime, UNIX_EPOCH},
};
use chrono::Utc;
use client::{app_status::AppStatus, user::User};
use database::{DatabaseAuth, interface::borrow_db_checked};
use droplet_rs::ssl::sign_nonce;
use gethostname::gethostname;
use jsonwebtoken::{Algorithm, EncodingKey, Header};
use log::{error, warn};
use serde::{Deserialize, Serialize};
use url::Url;
@@ -60,18 +65,36 @@ impl From<HandshakeResponse> for DatabaseAuth {
}
}
#[derive(Serialize, Deserialize)]
struct Claims {
exp: usize,
nbf: usize,
}
pub fn generate_authorization_header() -> String {
let certs = {
let db = borrow_db_checked();
db.auth.clone().expect("Authorisation not initialised")
};
let nonce = Utc::now().timestamp_millis().to_string();
let system_time: usize = SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap_or(Duration::from_secs(0))
.as_secs() as usize;
let signature =
sign_nonce(certs.private, nonce.clone()).expect("Failed to generate authorisation header");
let claims = Claims {
nbf: system_time,
exp: system_time + 10,
};
format!("Nonce {} {} {}", certs.client_id, nonce, signature)
let jwt = jsonwebtoken::encode(
&Header::new(Algorithm::ES384),
&claims,
&EncodingKey::from_ec_pem(certs.private.as_bytes()).unwrap(),
)
.expect("failed to sign jwt");
format!("JWT {} {}", certs.client_id, jwt)
}
pub async fn fetch_user() -> Result<User, RemoteAccessError> {