use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use serde_json::Value;
/// The signed-in user, as returned by `auth_me`.
#[derive(Debug, Serialize, JsonSchema)]
pub struct MeResponse {
pub id: i64,
pub name: String,
pub email: Option<String>,
pub roles: Vec<String>,
}
/// Arguments of `auth_email_start`.
#[derive(Debug, Deserialize, JsonSchema)]
pub struct EmailRequest {
pub email: String,
}
/// Arguments of `auth_email_verify`.
#[derive(Debug, Deserialize, JsonSchema)]
pub struct VerifyRequest {
pub email: String,
/// The 6-digit code from the email.
pub code: String,
/// Signing in through a customer-facing app (a storefront): the session
/// only reaches the tools meant for customers.
#[serde(default)]
pub customer: bool,
}
/// Arguments of `auth_passkey_register_finish` and `auth_passkey_login_finish`.
#[derive(Debug, Deserialize, JsonSchema)]
pub struct PasskeyRequest {
/// The `id` from the matching `_start` tool.
pub id: String,
/// The browser's `PublicKeyCredential.toJSON()`.
pub credential: Value,
/// For `auth_passkey_login_finish`: as in `auth_email_verify`.
#[serde(default)]
pub customer: bool,
}
/// A new session: send `token` as `Authorization: Bearer <token>`.
#[derive(Debug, Serialize, JsonSchema)]
pub struct SessionResponse {
pub token: String,
}
/// A passkey ceremony: pass `options` to
/// `PublicKeyCredential.parse{Creation,Request}OptionsFromJSON`.
#[derive(Debug, Serialize, JsonSchema)]
pub struct ChallengeResponse {
pub id: String,
pub options: Value,
}
#[derive(Debug, Serialize, JsonSchema)]
pub struct DoneResponse {
pub ok: bool,
}