Skip to main content

fastauth_plugin_passkey/
model.rs

1//! The `passkey` table.
2
3use fastauth_core::plugin_prelude::*;
4
5/// A row of `passkey`: one registered WebAuthn credential. The columns are Better Auth's, in
6/// snake case, so a Better Auth passkey table carries over.
7#[derive(Model, Clone, Debug, PartialEq, Eq)]
8#[model(table = "passkey")]
9pub struct PasskeyRow {
10    #[model(id)]
11    pub id: Id,
12    /// The name the user gave it, if any.
13    pub name: Option<String>,
14    /// The credential's COSE public key, base64 (Better Auth's encoding).
15    pub public_key: String,
16    #[model(references = User, on_delete = Cascade, index)]
17    pub user_id: Id,
18    /// The credential id, base64url without padding: what browsers send as `id`.
19    #[model(unique)]
20    pub credential_id: String,
21    /// The authenticator's signature counter as of the last sign-in. Zero for authenticators
22    /// that don't count (most synced passkeys).
23    pub counter: i64,
24    /// `singleDevice`, or `multiDevice` when the credential may be synced (backup eligible).
25    pub device_type: String,
26    /// Whether the credential is backed up (synced) right now.
27    pub backed_up: bool,
28    /// The browser's transport hints, comma-separated (`internal,hybrid`).
29    pub transports: Option<String>,
30    #[model(default = now)]
31    pub created_at: OffsetDateTime,
32    /// The authenticator model's AAGUID, all zeros when the authenticator hides it.
33    pub aaguid: Option<String>,
34}