Skip to main content

polyester/models/
auth.rs

1//! Auth-related SDK models.
2
3use std::fmt;
4
5use serde::{Deserialize, Serialize};
6
7#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
8pub struct MeResult {
9    pub account_id: String,
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub api_key_id: Option<String>,
12    #[serde(skip_serializing_if = "Option::is_none")]
13    pub username: Option<String>,
14    #[serde(skip_serializing_if = "Option::is_none")]
15    pub root_smart_account_address: Option<String>,
16}
17
18#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]
19pub struct UserProfile {
20    pub username: String,
21    pub bio: String,
22    pub website: String,
23    pub twitter: String,
24    pub twitter_verified: bool,
25    pub discord: String,
26    pub discord_verified: bool,
27    pub avatar_url: String,
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub created_at_ms: Option<i64>,
30    #[serde(skip_serializing_if = "Option::is_none")]
31    pub next_username_change_at_ms: Option<i64>,
32    pub vip_tier: i32,
33    pub username_unlocked: bool,
34}
35
36#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]
37pub struct UsernameHistoryEntry {
38    pub username: String,
39    #[serde(skip_serializing_if = "Option::is_none")]
40    pub changed_at_ms: Option<i64>,
41}
42
43#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]
44pub struct UsernameHistoryList {
45    pub entries: Vec<UsernameHistoryEntry>,
46}
47
48#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]
49pub struct AccountIdentity {
50    pub account_id: String,
51    pub username: String,
52    pub avatar_url: String,
53    pub root_smart_account_address: String,
54}
55
56/// Locally generated Ed25519 keypair for API key creation.
57///
58/// [`Debug`] redacts secret material so accidental logging cannot leak the
59/// private key. Read `secret_key_hex` / `secret_key` explicitly when you need
60/// the secret.
61#[derive(Clone, PartialEq, Eq)]
62pub struct Ed25519Keypair {
63    pub public_key_hex: String,
64    pub secret_key_hex: String,
65    pub public_key: Vec<u8>,
66    pub secret_key: Vec<u8>,
67}
68
69impl fmt::Debug for Ed25519Keypair {
70    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
71        f.debug_struct("Ed25519Keypair")
72            .field("public_key_hex", &self.public_key_hex)
73            .field("secret_key_hex", &"[REDACTED]")
74            .field("public_key", &self.public_key)
75            .field("secret_key", &"[REDACTED]")
76            .finish()
77    }
78}