import { type CryptoProvider } from '@kokuin/crypto'; import { type FullIdentity, type IdentityProvider, type KeyStore } from '@kokuin/token'; import { ElectronKeyEntry } from './entry.js'; export type ElectronKeyStoreParams = { crypto?: CryptoProvider; /** The electron-store file name. Defaults to `'keystore'`. */ name?: string; allowInsecureStorage?: boolean; /** * Path to a lockfile enabling **cross-process** exclusion on `provideAsync`. * * Absent, nothing touches the filesystem and only the in-process lock applies — two * processes can still both generate a key for a fresh keyID, and the loser's key is lost. * * A **file**, not a directory: one coarse lock per store, not one per keyID. A per-keyID * lockfile would derive its name from an attacker-influenced keyID (`entry('../../etc/x')`), * and `provideAsync` runs once per identity, so serializing across keyIDs costs nothing real. * * Must be on a local filesystem (`link()` is not atomic on NFS). Acquisition is bounded and * throws `TimeoutInterruption` on expiry — it never proceeds unlocked. */ lockPath?: string; }; export declare class ElectronKeyStore implements KeyStore, IdentityProvider { #private; static open(params?: ElectronKeyStoreParams): ElectronKeyStore; constructor(params?: ElectronKeyStoreParams); entry(keyID: string): ElectronKeyEntry; provideIdentity(keyID: string): Promise; /** {@link provideIdentity}, synchronously. Beyond the `IdentityProvider` contract. */ provideIdentitySync(keyID: string): FullIdentity; }