import type { SensitiveInfoItem } from '../sensitive-info.nitro'; import { type AsyncState, type HookMutationResult } from './types'; import { type UseSecretItemOptions } from './useSecretItem'; /** * Configuration object for {@link useSecret}. * Combines the read options from {@link useSecretItem} with mutation convenience flags. */ export type UseSecretOptions = UseSecretItemOptions; /** * Result bag returned by {@link useSecret}. */ export interface UseSecretResult extends AsyncState { /** Persist a new value for the tracked secret and refresh the cache. */ readonly saveSecret: (value: string) => Promise; /** Delete the tracked secret from secure storage. */ readonly deleteSecret: () => Promise; /** Re-run the underlying fetch even if `skip` is enabled. */ readonly refetch: () => Promise; } /** * Maintains a secure item while exposing imperative helpers to mutate or refresh it. * * Combines a read subscription (via {@link useSecretItem}) with `saveSecret` / `deleteSecret` * helpers that automatically refresh the cached entry on success. * * @param key - Identifier of the secret to track. Changing the key triggers a fresh fetch. * @param options - Storage scoping plus hook flags (`skip`, `includeValue`). * @returns A {@link UseSecretResult} with `data`/`error`/`isLoading`/`isPending` state and the * `saveSecret`, `deleteSecret`, `refetch` helpers. * * @remarks * - Mutation helpers never throw \u2014 they resolve with a {@link HookMutationResult} discriminated * union. Branch with `if (!result.success)`. * - If you only need read access, prefer {@link useSecretItem} \u2014 lighter result shape. * * @example * ```tsx * const { data, isLoading, saveSecret, deleteSecret } = useSecret('refreshToken', { * service: 'com.example.session', * }) * * await saveSecret(nextToken) * await deleteSecret() * ``` * * @see {@link useSecretItem} * @see {@link setItem} * @see {@link deleteItem} */ export declare function useSecret(key: string, options?: UseSecretOptions): UseSecretResult; //# sourceMappingURL=useSecret.d.ts.map