/** * Factory functions for KeyPersistence. * * Provides convenient ways to create KeyPersistence instances * with auto-detection of storage backend. * * @module @frontmcp/utils/key-persistence */ import type { StorageAdapter } from '../../storage/types'; import { KeyPersistence } from './key-persistence'; import type { CreateKeyPersistenceOptions } from './types'; /** * Create a KeyPersistence instance with auto-detected storage. * * In Node.js: Uses filesystem storage at `.frontmcp/keys/` by default * In browser: Uses IndexedDB (persistent) with localStorage fallback * Fallback: Memory storage (keys lost on restart) * * @param options - Configuration options * @returns KeyPersistence instance (storage already connected) * * @example * ```typescript * // Auto-detect storage * const keys = await createKeyPersistence(); * * // Force memory storage * const memKeys = await createKeyPersistence({ type: 'memory' }); * * // Force IndexedDB (browser) * const idbKeys = await createKeyPersistence({ type: 'indexeddb' }); * * // Force localStorage (browser) * const lsKeys = await createKeyPersistence({ type: 'localstorage' }); * * // Custom directory for filesystem * const fsKeys = await createKeyPersistence({ * type: 'filesystem', * baseDir: '.my-app/keys', * }); * ``` */ export declare function createKeyPersistence(options?: CreateKeyPersistenceOptions): Promise; /** * Create a KeyPersistence instance with an explicit storage adapter. * * Use this when you want to provide your own storage backend * (e.g., Redis, custom adapter). * * Note: The storage adapter must already be connected. * * @param storage - Connected storage adapter * @param options - Additional options * @returns KeyPersistence instance * * @example * ```typescript * import { createStorage } from '@frontmcp/utils'; * * // Use Redis for distributed key storage * const redis = await createStorage({ type: 'redis' }); * const keys = createKeyPersistenceWithStorage(redis); * ``` */ export declare function createKeyPersistenceWithStorage(storage: StorageAdapter, options?: Pick): KeyPersistence;