Fixes Patches Creation & More

Working with files / Paths fixed

Websocket PingPongs (There is no data behind this just PingPong)

Storing User Profiles correctly

Added necessary dependencies and initial code support for: - X.509
certificate handling via x509/pkcs8 crates - Key generation and crypto
operations via x448/sha2 - Structured hex encoding and base64 encoding
This commit is contained in:
Alex Emmet 2025-09-23 20:26:48 +00:00
commit 0d07ddf851
23 changed files with 887 additions and 266 deletions

View file

@ -1,12 +1,13 @@
use std::time::Duration;
use std::collections::HashMap;
use uuid::Uuid;
use reqwest::header::CONTENT_TYPE;
use json::JsonValue;
use reqwest::{Client, Response};
use crate::users::user_profile::UserProfile;
use crate::data::communication::{CommunicationType, CommunicationValue, DataTypes};
use crate::users::user_profile::UserProfile;
use hex;
use json::JsonValue;
use reqwest::header::CONTENT_TYPE;
use reqwest::{Client, Response};
use sha2::{Digest, Sha256};
use std::collections::HashMap;
use std::time::Duration;
use uuid::Uuid;
#[derive(Debug, Clone)]
pub struct AuthUser {
pub created_at: i64,
@ -32,23 +33,29 @@ impl AuthConnector {
}
pub async fn unregister_user(user_id: Uuid, reset_token: &str) -> Option<bool> {
let url = format!("https:/auth.tensamin.methanium.net//api/delete/{}/", user_id);
let url = format!("https:/auth.tensamin.methanium.net/api/delete/{}/", user_id);
let client = Self::client();
let mut payload = JsonValue::new_object();
payload["reset_token"] = reset_token.into();
let res = client.post(&url)
let res = client
.post(&url)
.header(CONTENT_TYPE, "application/json")
.body(payload.dump()).send().await.ok()?;
.body(payload.dump())
.send()
.await
.ok()?;
let json = res.text().await.ok()?;
let cv = CommunicationValue::from_json(&json);
Option::from(cv.is_type(CommunicationType::Success))
}
pub async fn get_uuid(username: &str) -> Option<Uuid> {
let url = format!("https://auth.tensamin.methanium.net/api/get/uuid/{}/", username);
let url = format!(
"https://auth.tensamin.methanium.net/api/get/uuid/{}/",
username
);
let client = Self::client();
let res = client.get(&url).send().await.ok()?;
let json = res.text().await.ok()?;
@ -71,15 +78,30 @@ impl AuthConnector {
}
Some(AuthUser {
created_at: cv.get_data(DataTypes::CreatedAt).unwrap().to_string().parse::<i64>().unwrap_or(-1),
created_at: cv
.get_data(DataTypes::CreatedAt)
.unwrap()
.to_string()
.parse::<i64>()
.unwrap_or(-1),
username: cv.get_data(DataTypes::Username).unwrap().to_string(),
display: cv.get_data(DataTypes::Display).unwrap().to_string(),
avatar: cv.get_data(DataTypes::Avatar).unwrap().to_string(),
about: cv.get_data(DataTypes::About).unwrap().to_string(),
status: cv.get_data(DataTypes::Status).unwrap().to_string(),
public_key: cv.get_data(DataTypes::PublicKey).unwrap().to_string(),
sub_level: cv.get_data(DataTypes::SubLevel).unwrap().to_string().parse::<i32>().unwrap_or(-1),
sub_end: cv.get_data(DataTypes::SubEnd).unwrap().to_string().parse::<i32>().unwrap_or(-1),
sub_level: cv
.get_data(DataTypes::SubLevel)
.unwrap()
.to_string()
.parse::<i32>()
.unwrap_or(-1),
sub_end: cv
.get_data(DataTypes::SubEnd)
.unwrap()
.to_string()
.parse::<i32>()
.unwrap_or(-1),
})
}
@ -108,14 +130,16 @@ impl AuthConnector {
let res = client
.post(url)
.header(CONTENT_TYPE, "application/json")
.body(payload.dump())
.body(payload.to_string())
.send()
.await;
.await
.unwrap();
match res {
Ok(resp) => Self::handle_response(resp).await,
Err(_) => false,
}
println!("Status: {}", res.status());
let body = res.text().await.unwrap();
println!("Response body:\n{}", body);
CommunicationValue::from_json(&body).is_type(CommunicationType::Success)
}
pub async fn migrate_user(user_profile: &mut UserProfile, iota_id: &str) -> bool {
@ -152,6 +176,4 @@ impl AuthConnector {
Err(_) => false,
}
}
}
}