/** * The normalized credentials the CLI connects with. `host` is the bare address {@link ProtectClient.connect} expects (no scheme, port preserved) - we accept the * documented `controller` form in the file (which may carry an `https://` scheme) and normalize it here, so the connect path never has to think about schemes. * `verifyTls` is the file's strict-TLS opt-in, carried through to the connect options under the name the library gives it and left off entirely when the file is * silent, so the library's own default decides. * * @category CLI */ export interface UfpCredentials { host: string; password: string; username: string; verifyTls?: boolean; } /** * The streams an interactive credential prompt reads from and writes to, plus the signal that cancels it. `isTTY` travels with each stream because whether a prompt is * appropriate at all is decided from it - by the caller, not here. * * @category CLI */ export interface InteractivePrompt { input: NodeJS.ReadableStream & { isTTY?: boolean; }; output: NodeJS.WritableStream & { isTTY?: boolean; }; signal?: AbortSignal; } /** * Options for {@link loadCredentials}. The defaults read the real working directory and home directory; tests override them to point at a temporary fixture without * touching the developer's real `~/.ufp.json`. * * `interactive` is the whole mode switch: supplied, a first run with no configuration file asks for credentials instead of failing; absent, discovery behaves exactly * as it always does and an absent file is an error. It is one object rather than loose fields so present-or-absent is the only state there is, and the decision of * whether prompting is appropriate stays with the caller that knows about terminals - this loader is deterministic and never consults ambient state of its own. * * @category CLI */ export interface LoadCredentialsOptions { cwd?: string; home?: string; interactive?: InteractivePrompt; } /** * Locate, parse, validate, and normalize the CLI credentials. The discovery order is `./ufp.json` in the working directory first, then `~/.ufp.json` in the * home directory. The first file that exists wins; a malformed or incomplete file is a hard error (we do not silently fall through to the next location, because a * present-but-broken file is a mistake the operator wants told about, not masked). * * When no file is found and the caller supplied `interactive`, the details are asked for instead: the same normalization and validation the file path uses is applied * to what is typed, and the answers are offered a home in `~/.ufp.json` so the next run finds a file. A broken file is never a prompt - only an absent one is, because * a present file that is wrong is something to fix rather than to type around. * * @param opts - Optional working-directory and home-directory overrides (defaults to the real ones), and the interactive prompt to fall back on. * * @returns The normalized credentials. * * @throws {@link CliError} when no configuration is found and no prompt was offered, or when the one found is unreadable, malformed, or missing a field. * @throws {@link ProtectAbortedError} when an interactive prompt is cancelled. * * @category CLI */ export declare function loadCredentials(opts?: LoadCredentialsOptions): Promise; //# sourceMappingURL=credentials.d.ts.map