/** * Running one Harness authorization flow in a terminal. * * This module implements nothing about any provider's login. Harness's * authorization seam owns the protocol and hands a surface exactly two things * to render — a notice, which is one-way and may carry a page and a code, and a * prompt, which is `text`, `secret`, or `select`. That vocabulary is * deliberately smaller than any one provider's, so a surface that renders one * flow renders all of them: OAuth, device code, and a key typed into a * provider library's own prompt arrive here as the same three shapes. * * Where each half goes is the terminal-specific decision: * * - A **notice** is committed to native scrollback. A sign-in URL and a device * code are the two things a person most needs to select and copy, and this * frontend's whole premise is that finished rows belong to the terminal's own * buffer rather than to a redrawn region that will scroll them away. * - A **prompt** is a bounded overlay, because it takes the keyboard. * * Cancelling is done by aborting the attempt's signal rather than by rejecting * with the seam's decline error, which this package cannot import. The seam * treats a withdrawn attempt and a declined prompt as the same outcome — * `cancelled`, not a failure — so the observable result is identical. * @module dshline/connect/authorize */ import type { Context } from '@deepseek-ai/cordis'; import type { AuthorizationNoticeRead, ConnectAuthorization } from './harness.ts'; import type { ConnectActionOutcome } from './actions.ts'; /** What running one flow needs from its owner. */ export interface AuthorizeSpec { /** Context carrying the slot registry, for the prompt overlays. */ readonly ctx: Context; /** The authorization seam. */ readonly authorization: ConnectAuthorization; /** The credential record to authorize. */ readonly key: string; /** User-facing name of what is being authorized. */ readonly label: string; /** Which of the flow's methods to run; omitted takes the flow's first. */ readonly method?: string; /** * Withdraws the attempt from outside. * * The browser that started a sign-in owns this: an OAuth flow can sit waiting * on a browser callback with no prompt on screen, so closing Connect has to * take the attempt down through the seam's own lifecycle rather than walking * away from it and letting a prompt or a notice arrive over whatever the * reader is looking at next. */ readonly signal?: AbortSignal; /** Write finished rows into the terminal's own scrollback. */ readonly commit: (lines: readonly string[]) => void; } /** * Rows one notice becomes in the transcript. * * The page and the code are given lines of their own, unindented past a short * gutter, because a reader is about to select them with the mouse: burying a * URL inside a sentence makes a double-click take the sentence with it. * @param notice - what the flow reported. * @param label - what is being authorized. * @returns the lines to commit. */ export declare function noticeLines(notice: AuthorizationNoticeRead, label: string): string[]; /** * Run one authorization flow and report how it ended. * * The attempt owns an `AbortController` this function holds: dismissing a * prompt aborts it, which withdraws the whole attempt through the seam's own * lifecycle rather than leaving a flow prompting into a closed overlay. * @param spec - the seam, the key, and where notices go. * @returns what Harness answered, worded for the transcript. */ export declare function runAuthorization(spec: AuthorizeSpec): Promise; //# sourceMappingURL=authorize.d.ts.map