Skip to main content

nautilus_rs/resources/passepartout/
types.rs

1/// A Telegram user profile returned once a login flow completes.
2#[derive(Debug, Clone, serde::Deserialize)]
3pub struct TelegramUser {
4    /// Telegram user ID (numeric, delivered as a string).
5    pub id: String,
6    /// Telegram @username, if the user has one set.
7    #[serde(default)]
8    pub username: Option<String>,
9    /// The user's first name.
10    #[serde(default)]
11    pub first_name: Option<String>,
12    /// URL of the user's profile photo, if available.
13    #[serde(default)]
14    pub photo_url: Option<String>,
15}
16
17/// The result of starting a Passepartout login flow.
18///
19/// Returned by [`Passepartout::login_start`](super::Passepartout::login_start).
20/// Direct the end-user to `deep_link` (a `https://t.me/…` link) and poll
21/// [`Passepartout::login_status`](super::Passepartout::login_status) with the
22/// `nonce` until the flow completes.
23#[derive(Debug, Clone, serde::Deserialize)]
24pub struct LoginStart {
25    /// Opaque one-time value identifying this login attempt.
26    pub nonce: String,
27    /// Telegram deep link the end-user must open to authenticate.
28    pub deep_link: String,
29    /// ISO 8601 timestamp after which the login attempt expires.
30    pub expires_at: String,
31}
32
33/// The current state of a Passepartout login flow.
34///
35/// Returned by [`Passepartout::login_status`](super::Passepartout::login_status).
36/// Inspect `status` — once it reaches a terminal success state the remaining
37/// fields are populated with the issued token and the authenticated user.
38#[derive(Debug, Clone, serde::Deserialize)]
39pub struct LoginStatus {
40    /// Flow state, e.g. `"pending"`, `"completed"`, `"expired"`.
41    pub status: String,
42    /// The issued access token, present once the flow completes.
43    #[serde(default)]
44    pub access_token: Option<String>,
45    /// ISO 8601 expiry timestamp of the access token, when issued.
46    #[serde(default)]
47    pub expires_at: Option<String>,
48    /// The Gate identity ID linked to the Telegram user, when resolved.
49    #[serde(default)]
50    pub identity_id: Option<String>,
51    /// The authenticated Telegram user, present once the flow completes.
52    #[serde(default)]
53    pub user: Option<TelegramUser>,
54}
55
56/// Token validity and claims returned by
57/// [`Passepartout::introspect`](super::Passepartout::introspect).
58#[derive(Debug, Clone, serde::Deserialize)]
59pub struct TokenIntrospection {
60    /// `true` if the token is valid, unexpired, and not revoked.
61    pub active: bool,
62    /// The subject (identity) the token was issued for.
63    #[serde(default)]
64    pub subject: Option<String>,
65    /// Tenant the subject belongs to.
66    #[serde(default)]
67    pub tenant_id: Option<String>,
68    /// Scopes embedded in the token.
69    #[serde(default)]
70    pub scopes: Option<Vec<String>>,
71    /// ISO 8601 expiry timestamp.
72    #[serde(default)]
73    pub expires_at: Option<String>,
74}