/** * @file In-process biometric keychain backend — the sockeye `keychain.node` * N-API addon, loaded lazily and OPTIONALLY. The addon (built by sockeye's * `keychain-addon-builder`, published as `@socketsecurity/sockeye`, with * `@socketaddon/keychain-*` as the legacy republish) exposes the shared * keystore-infra core: macOS Keychain items behind a Secure-Enclave biometric * ACL, so a read is gated on Touch ID instead of a password prompt. This * slots between the sockeye broker and the CLI keychain in `secrets/find.ts` * `resolve()`: the broker is preferred when its daemon runs (one unlock * serves many processes), this addon covers the no-daemon case in-process, * and the `security`-CLI read remains the biometric-less floor. Same * self-gating contract as `./broker`: absence is a fall-through, never an * error. The addon is missing on non-macOS platforms, on machines that never * installed it, and in CI — all of those return `undefined` from every * function here, and the resolve chain moves on. Load order: * `SOCKET_KEYCHAIN_ADDON_PATH` env override first (a built `keychain.node` * path, the escape hatch for local sockeye builds), then the per-platform npm * package. */ import type { SecretSlot } from './types.js'; /** * The addon's N-API surface, as exported by sockeye's `keychain_napi.cc` * (`get` / `set` / `del`). Every function takes `(service, account)` leading * params; `set` adds the value. */ export interface KeychainAddon { del(service: string, account: string): boolean; get(service: string, account: string): string | undefined; set(service: string, account: string, value: string): void; } /** * The loaded addon, or `undefined` when unavailable. Cached for the process: * a native `require` is not retried per read, matching the broker's * socket-stat-once behavior in spirit. */ export declare function getKeychainAddon(): KeychainAddon | undefined; export declare function loadAddon(): KeychainAddon | undefined; /** * Read a secret through the biometric addon, or `undefined` when the addon is * unavailable, the item is absent, or the user cancels the biometric prompt. * Never throws: every failure is a fall-through so `resolve()` can continue * to the CLI keychain. */ export declare function readSecretBiometric(slot: SecretSlot): string | undefined; /** * Test injection point and embedder override. Passing an addon forces it; * passing `undefined` forces ABSENCE (reads fall through). To return to lazy * detection on the next read, pass `undefined` with `{ probe: true }`. */ export declare function setKeychainAddon(addon: KeychainAddon | undefined, options?: { probe?: boolean | undefined; } | undefined): void; /** * Write a secret through the biometric addon so the stored item carries the * Secure-Enclave ACL. Returns `false` (rather than throwing) when the addon * is unavailable, so callers can fall back to `writeSecret` and report which * protection level the value ended up with. */ export declare function writeSecretBiometric(slot: SecretSlot, value: string): boolean;