/** * Native OS keystore implementation using system credential storage */ import type { KeyPair, KeyStore } from "../core/types.js"; /** * Native OS keystore using system credential storage * * This keystore uses the operating system's native secure credential storage: * - **macOS**: Keychain Access * - **Windows**: Credential Manager (DPAPI) * - **Linux**: keyutils (kernel keyring) or D-Bus Secret Service API * * ## Security Benefits * - Keys stored in OS-level secure storage (not plain files) * - Encrypted by OS using hardware-backed keys when available * - Protected by user's system password/biometrics * - Isolated from other applications * * ## Requirements * - Requires `@napi-rs/keyring` native dependency * - Linux: Uses either keyutils (kernel keyring, no additional requirements) or * D-Bus Secret Service API (requires a daemon like GNOME Keyring or KWallet, * but no additional system libraries like `libsecret`) * * ## Limitations * - Not available in browser environments (use InMemoryKeyStore instead) * - Requires user to be logged in to the system * - Keys are machine-specific (not synced across devices) * * @example * ```typescript * // Use OS keyring for maximum security * const keyStore = new NativeKeyStore() * const near = new Near({ keyStore }) * * // Keys stored in: * // - macOS: Keychain Access > "NEAR Credentials" * // - Windows: Credential Manager > Generic Credentials * // - Linux: GNOME Keyring / KDE Wallet * ``` */ export declare class NativeKeyStore implements KeyStore { private readonly service; /** * Create a new native OS keystore * * @param service - Service name for credential storage (default: "NEAR Credentials") * This appears in Keychain Access (macOS) or Credential Manager (Windows) * * @example * ```typescript * // Default service name * const keyStore = new NativeKeyStore() * * // Custom service name for your app * const keyStore = new NativeKeyStore("MyApp NEAR Keys") * ``` */ constructor(service?: string); /** * Create an Entry instance for keyring operations */ private getEntry; /** * Add a key to the OS keystore * * Stores the key securely in the operating system's credential storage. * The key is encrypted by the OS and protected by the user's system password. * * @param accountId - NEAR account ID (used as credential name) * @param key - Key pair to store * @param options - Optional metadata (stored alongside the key in OS keyring) * * @throws {Error} If keyring access fails (e.g., user denies permission) */ add(accountId: string, key: KeyPair, options?: { seedPhrase?: string; derivationPath?: string; implicitAccountId?: string; }): Promise; /** * Get a key from the OS keystore * * Retrieves and decrypts the key from the operating system's credential storage. * * @param accountId - NEAR account ID * @returns Key pair if found, null otherwise * * @throws {Error} If keyring access fails or key is corrupted */ get(accountId: string): Promise; /** * Remove a key from the OS keystore * * Permanently deletes the credential from the operating system's storage. * * @param accountId - NEAR account ID */ remove(accountId: string): Promise; /** * List all account IDs in the OS keystore * * ⚠️ **Note**: The underlying keyring library doesn't support listing all * credentials for a service. This method returns an empty array. * * If you need to track multiple accounts, maintain a list separately * (e.g., in a config file) and use this keystore only for secure key storage. * * @returns Empty array (OS keyrings don't support enumeration for security) */ list(): Promise; } //# sourceMappingURL=native-keystore.d.ts.map