Files
codex/codex-rs/user-verification/src/lib.rs
T
bdavis-oai 1b7c025258 Report biometric type in user verification responses (#60948)
## What changed

Add `biometricType` to `userVerification/verify` responses as context alongside the signed `proof`. Successful Touch ID protected signing reports `"fingerprint"`; an unknown method reports `null`. Responses from older servers that omit the field remain supported.

Carry the native method through the verification provider and app-server protocol, and update the experimental protocol exports and API documentation.

## Testing

Add coverage for responses without `biometricType` and for returning `"fingerprint"` separately from the proof. Update existing verification coverage to check the `null` case.

GitOrigin-RevId: c82e84a325a4d9ab1e5262e5100ffc1a043bd97e
2026-11-12 00:44:27 +00:00

93 lines
3.2 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//! Device credentials and signing, independent of RPC routing, UI, and backend registration.
mod credential;
mod error;
mod guard;
mod key_namespace;
#[cfg(any(target_os = "macos", test))]
mod lifecycle_lock;
#[cfg(any(target_os = "macos", test))]
mod native_operation;
#[cfg(any(target_os = "macos", test))]
mod platform_macos;
#[cfg(not(target_os = "macos"))]
mod unsupported;
pub use credential::UserVerificationBiometricType;
pub use credential::UserVerificationKeyCreation;
pub use credential::UserVerificationKeyDeletion;
pub use credential::UserVerificationKeyInfo;
pub use credential::UserVerificationProof;
pub use credential::UserVerificationRequest;
pub use credential::UserVerificationStatus;
pub use error::UserVerificationCancellationReason;
pub use error::UserVerificationError;
pub use error::UserVerificationFailureReason;
pub use error::UserVerificationUnavailableReason;
pub use guard::UserVerificationRequestGuard;
pub use key_namespace::UserVerificationKeyNamespace;
use std::sync::Arc;
/// Performs local credential operations for one captured account-user identity.
/// Implementations never perform network registration. Blocking implementations must run off
/// the async executor and check the guard after waiting, before effects, and before returning.
pub trait UserVerificationProvider: Send + Sync {
/// Reads local readiness without creating credentials or prompting for authentication.
fn status(
&self,
guard: &UserVerificationRequestGuard,
) -> Result<UserVerificationStatus, UserVerificationError>;
/// Creates a protected key only if none exists. Success does not mean server enrollment.
fn ensure_key(
&self,
guard: &UserVerificationRequestGuard,
) -> Result<UserVerificationKeyCreation, UserVerificationError>;
/// Removes the local key idempotently. Backend revocation belongs to the caller.
fn delete(
&self,
guard: &UserVerificationRequestGuard,
) -> Result<UserVerificationKeyDeletion, UserVerificationError>;
/// Authenticates and signs 1–4096 challenge bytes without interpreting an elicitation.
/// The caller owns approval UI, request correlation, and the captured identity check.
fn verify(
&self,
request: &UserVerificationRequest,
guard: &UserVerificationRequestGuard,
) -> Result<UserVerificationProof, UserVerificationError>;
}
/// Reports whether this build contains a native provider, independently of local readiness.
pub fn platform_supported() -> bool {
cfg!(target_os = "macos")
}
/// Probes biometric hardware without reading credentials, prompting, or checking enrollment.
/// This performs local OS work; async callers should run it off their executor during setup.
pub fn device_supported() -> bool {
#[cfg(target_os = "macos")]
{
platform_macos::device_supported()
}
#[cfg(not(target_os = "macos"))]
{
false
}
}
pub fn platform_provider(
namespace: UserVerificationKeyNamespace,
) -> Arc<dyn UserVerificationProvider> {
#[cfg(target_os = "macos")]
{
Arc::new(platform_macos::NativeProvider { namespace })
}
#[cfg(not(target_os = "macos"))]
{
let _ = namespace.label;
Arc::new(unsupported::UnsupportedProvider)
}
}