expo-passkey
Version:
Passkey authentication for Expo apps with Better Auth integration
76 lines • 3.42 kB
TypeScript
/**
* @file Storage utilities
* @module expo-passkey/utils/storage
*/
import type { ExpoPasskeyClientOptions, StorageKeys } from "../../types/client";
/**
* Credential metadata stored with each credential ID
*/
export interface CredentialMetadata {
userId: string;
credentialId: string;
rpId?: string;
registeredAt: string;
lastUsedAt: string;
deviceName?: string;
displayName?: string;
crossPlatform?: boolean;
originalPlatform?: string;
}
/**
* Gets storage keys based on the client options
* @param options Client options with optional storage prefix
* @returns Storage keys with the configured prefix
*/
export declare function getStorageKeys(options?: ExpoPasskeyClientOptions): StorageKeys;
/**
* Stores a credential ID with metadata in secure storage
* @param credentialId The credential ID to store
* @param userId The user ID associated with the credential
* @param options Client options with optional storage prefix
* @param additionalMetadata Additional metadata to store with the credential
* @returns Promise resolving when credential is stored
*/
export declare function storeCredentialId(credentialId: string, userId: string, options?: ExpoPasskeyClientOptions, additionalMetadata?: Partial<CredentialMetadata>): Promise<void>;
/**
* Gets all stored credential metadata
* @param options Client options with optional storage prefix
* @returns Promise resolving to an object mapping credential IDs to their metadata
*/
export declare function getCredentialMetadata(options?: ExpoPasskeyClientOptions): Promise<Record<string, CredentialMetadata>>;
/**
* Gets credential IDs for a specific user
* @param userId User ID to filter credentials by
* @param options Client options with optional storage prefix
* @returns Promise resolving to array of credential IDs for the user
*/
export declare function getUserCredentialIds(userId: string, options?: ExpoPasskeyClientOptions): Promise<string[]>;
/**
* Updates the last used timestamp for a credential
* @param credentialId The credential ID to update
* @param options Client options with optional storage prefix
* @returns Promise resolving when credential is updated
*/
export declare function updateCredentialLastUsed(credentialId: string, options?: ExpoPasskeyClientOptions): Promise<void>;
/**
* Removes a credential ID from storage
* @param credentialId The credential ID to remove
* @param options Client options with optional storage prefix
* @returns Promise resolving when credential is removed
*/
export declare function removeCredentialId(credentialId: string, options?: ExpoPasskeyClientOptions): Promise<void>;
/**
* Checks if a credential ID exists in storage
* @param credentialId The credential ID to check
* @param options Client options with optional storage prefix
* @returns Promise resolving to boolean indicating if credential exists
*/
export declare function hasCredentialId(credentialId: string, options?: ExpoPasskeyClientOptions): Promise<boolean>;
/**
* Gets the user ID associated with a credential ID
* @param credentialId The credential ID to get user ID for
* @param options Client options with optional storage prefix
* @returns Promise resolving to user ID or null if not found
*/
export declare function getUserIdForCredential(credentialId: string, options?: ExpoPasskeyClientOptions): Promise<string | null>;
//# sourceMappingURL=storage.d.ts.map