import type { RotationResult, SensitiveInfoOptions } from '../sensitive-info.nitro'; import { type HookError, type HookMutationResult } from './types'; export interface UseKeyRotationOptions extends SensitiveInfoOptions { /** When `true`, rotations eagerly re-encrypt all entries. Defaults to `false` (lazy). */ readonly reEncryptEagerly?: boolean; } /** Per-call overrides accepted by {@link UseKeyRotationResult.rotate}. */ export interface RotateCallOptions { readonly reEncryptEagerly?: boolean; } export interface UseKeyRotationResult { /** Most recent rotation result, if any. */ readonly lastResult: RotationResult | null; /** Current error bag for rotation operations. */ readonly error: HookError | null; /** True while a rotation call is in flight. */ readonly isRotating: boolean; /** * Trigger a master-key rotation for the configured service. Pass * `{ reEncryptEagerly: true }` to override the hook-level default for this call only. */ readonly rotate: (overrides?: RotateCallOptions) => Promise; /** Imperatively read the active key version from the native module. */ readonly readVersion: () => Promise; } /** * Provides a minimal wrapper around {@link rotateKeys} / {@link getKeyVersion} with loading, * result, and error state wired up for UI consumption. * * @param options - Storage scoping plus a `reEncryptEagerly` default for the `rotate()` helper. * @returns A {@link UseKeyRotationResult} with `lastResult`, `error`, `isRotating`, and the * imperative `rotate` / `readVersion` helpers. * * @remarks * - `rotate({ reEncryptEagerly: true })` may trigger one biometric prompt **per protected entry**. * Prefer the default lazy rotation unless you have a compliance reason to migrate ciphertext * immediately. * - `rotate()` never throws \u2014 it resolves with a {@link HookMutationResult}. * * @example * ```tsx * const { rotate, readVersion, isRotating, lastResult } = useKeyRotation({ * service: 'com.example.auth', * }) * * await rotate() // lazy: returns immediately * await rotate({ reEncryptEagerly: true }) // eager: re-encrypts every entry now * const version = await readVersion() * ``` * * @see {@link rotateKeys} * @see {@link getKeyVersion} */ export declare function useKeyRotation(options?: UseKeyRotationOptions): UseKeyRotationResult; //# sourceMappingURL=useKeyRotation.d.ts.map