Skip to main content

PasskeyStore

Trait PasskeyStore 

Source
pub trait PasskeyStore {
    // Required methods
    fn create_passkey<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        user_id: String,
        cred_id: &'life1 str,
        public_key: &'life2 str,
        name: &'life3 str,
        counter: i64,
        created_at: i64,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn get_passkey<'life0, 'life1, 'async_trait>(
        &'life0 self,
        cred_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<StoredPasskey>>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn list_passkeys<'life0, 'async_trait>(
        &'life0 self,
        user_id: String,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<StoredPasskey>>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn delete_passkey<'life0, 'life1, 'async_trait>(
        &'life0 self,
        user_id: String,
        cred_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn update_passkey_counter<'life0, 'life1, 'async_trait>(
        &'life0 self,
        cred_id: &'life1 str,
        new_counter: i64,
        last_used_at: i64,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn update_passkey_name<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        cred_id: &'life1 str,
        new_name: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn save_state<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        id: &'life1 str,
        state_json: &'life2 str,
        expires_at: i64,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn get_state<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<PasskeyState>>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete_state<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

A trait for managing the persistence of passkeys and authentication state.

Implement this trait to connect the passkey library to your chosen database. All methods are async and use async_trait(?Send) for compatibility with WASM.

Required Methods§

Source

fn create_passkey<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, user_id: String, cred_id: &'life1 str, public_key: &'life2 str, name: &'life3 str, counter: i64, created_at: i64, ) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Save a new passkey credential to the database.

  • user_id: The ID of the owner.
  • cred_id: The unique identifier for this credential (Base64url).
  • public_key: The public key material (Base64url-encoded COSE key).
  • name: A human-readable name for the passkey.
  • counter: The initial signature counter.
  • created_at: Creation timestamp in milliseconds.
Source

fn get_passkey<'life0, 'life1, 'async_trait>( &'life0 self, cred_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<StoredPasskey>>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieve a passkey by its credential ID.

Source

fn list_passkeys<'life0, 'async_trait>( &'life0 self, user_id: String, ) -> Pin<Box<dyn Future<Output = Result<Vec<StoredPasskey>>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

List all passkeys associated with a specific user.

Source

fn delete_passkey<'life0, 'life1, 'async_trait>( &'life0 self, user_id: String, cred_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete a passkey. Implementations should verify that user_id owns the cred_id.

Source

fn update_passkey_counter<'life0, 'life1, 'async_trait>( &'life0 self, cred_id: &'life1 str, new_counter: i64, last_used_at: i64, ) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Update the signature counter and last-used timestamp after a successful login.

Source

fn update_passkey_name<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, cred_id: &'life1 str, new_name: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Rename an existing passkey.

Source

fn save_state<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, id: &'life1 str, state_json: &'life2 str, expires_at: i64, ) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Save ephemeral registration or login state (challenges).

The state_json contains internal session data and should be retrievable by id. expires_at is the expiration timestamp in milliseconds.

Source

fn get_state<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<PasskeyState>>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieve ephemeral state by its ID. It should return None if expired.

Source

fn delete_state<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete ephemeral state (e.g., after the session is finished or fails).

Implementors§