/** * Classification of hyperlink targets that arrive from the terminal. * * OSC 8 lets an application decouple a link's *text* from its *target*, which * is the same primitive that makes `` phishable: the cell grid can read * `https://your-bank.example` while the target is something else entirely. The * regex link detection this supplements could not express that — a URL had to * literally appear on screen to be clickable — so accepting OSC 8 is what * introduces the risk, and it has to be paid for here. * * Three outcomes, in the spirit of Ghostty's classifier: * * - `allow` — a well-known safe scheme with nothing deceptive in it. * - `confirm` — plausible but unverifiable: custom schemes, `file:`, embedded * credentials, non-ASCII hosts. The user is shown the real target * and decides. * - `deny` — never openable: script-executing or content-inlining schemes, * and anything containing characters that can hide what the URL * actually says. * * The invariant this module exists to protect: **no URL is ever rendered to the * user as raw text.** Always display `assessment.display`, never * `assessment.raw`. A URL that has passed classification can still contain * codepoints that reorder or erase neighbouring text when drawn. */ export type UrlVerdict = "allow" | "confirm" | "deny"; export type UrlReason = "ok" | "empty" | "too-long" | "hidden-characters" | "no-scheme" | "dangerous-scheme" | "remote-file" | "local-file" | "custom-scheme" | "embedded-credentials" | "deceptive-host"; export interface UrlAssessment { verdict: UrlVerdict; reason: UrlReason; /** One-line explanation, suitable for a confirmation dialog. */ detail: string; /** * The URL with every non-printable, invisible, or direction-altering * codepoint replaced by a visible `` escape. Safe to render as text. * This is the only form that should ever be shown to a user. */ display: string; /** The target exactly as the application sent it. Never render this. */ raw: string; } /** * Render a URL so that what the user reads is what the URL contains. Every * codepoint that would otherwise be invisible or reorder its neighbours is * replaced by a literal ``. * * Applied unconditionally, including to URLs that pass classification — * escaping only the rejected ones would mean the safe-looking preview is the * one you cannot trust. */ export declare function escapeUrlForDisplay(url: string): string; /** * Classify a hyperlink target from the terminal. * * Pure and synchronous — call it on hover to build a preview and again on click * to decide what to do, rather than caching a verdict across the two. */ export declare function assessUrl(rawUrl: string): UrlAssessment; /** * Default activation policy: open `allow` outright, prompt on `confirm`, refuse * `deny`. Returns whether the link was opened. * * Embedders that want their own dialog should classify with {@link assessUrl} * and handle the verdict themselves rather than dropping the check — the * classification, not the dialog, is what makes this safe. */ export declare function openUrlSafely(rawUrl: string, open?: (url: string) => void): boolean; //# sourceMappingURL=urlSecurity.d.ts.map