Initial commit

This commit is contained in:
JP Stringham
2026-03-06 14:55:28 -05:00
commit 1b7b5aa592
11 changed files with 2442 additions and 0 deletions

55
src/json_types.rs Normal file
View File

@@ -0,0 +1,55 @@
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
pub(crate) struct ClientRegistration {
pub client_id: String,
pub client_id_issued_at: u64,
pub grant_types: Vec<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub(crate) struct ClientRegisterReq {
pub client_name: String,
pub client_uri: String,
pub grant_types: Vec<String>,
pub application_type: String,
pub token_endpoint_auth_method: String,
}
#[derive(Debug, Serialize, Deserialize)]
pub(crate) struct AuthMetadata {
pub device_authorization_endpoint: String,
pub token_endpoint: String,
pub registration_endpoint: String,
}
#[derive(Debug, Serialize, Deserialize)]
pub(crate) struct DeviceGrant {
pub device_code: String,
pub user_code: String,
pub verification_uri: String,
pub verification_uri_complete: String,
pub expires_in: u64,
pub interval: u64,
}
#[derive(Debug, Serialize, Deserialize)]
pub(crate) struct AuthorizationToken {
pub token_type: String,
pub access_token: String,
pub refresh_token: String,
pub expires_in: u64,
pub scope: String,
}
#[allow(dead_code)]
pub fn prettify_json_str(json_str: &str) -> Result<String, ()> {
let Ok(json) = serde_json::from_str::<serde_json::value::Value>(json_str) else {
return Err(());
};
match serde_json::to_string_pretty(&json) {
Ok(s) => Ok(s),
Err(_) => Err(()),
}
}