/** * iframe-token service * * Mints short-lived signed tokens for iframe embeds talking to the * vibecontrols-agent. Replaces the previous Referer/api-key-in-URL flow * dropped by the agent in Phase C. * * Backend route: POST /api/agent/iframe-token * Request: { pathPrefix: string, ttlSeconds?: number } * Response: { token: string, expiresAt: string } // ISO-8601 * * Hard limit: ttlSeconds <= 600 (agent enforces; we cap client-side too). */ export declare const MAX_IFRAME_TOKEN_TTL_SECONDS = 600; export declare function isAllowedAgentIframePrefix(prefix: string): boolean; export interface IframeTokenResponse { token: string; expiresAt: string; } export interface IframeTokenAutoRefreshHandle { /** Cancels the pending refresh timer. Idempotent. */ cancel: () => void; } /** * Mint an iframe token for the given agent + path prefix. * * @param agentId The agent's GraphQL id. * @param profile Profile name on the agent that owns this iframe token (canonical URL hierarchy). * @param pathPrefix Iframe path prefix the token should authorize (e.g. '/git', '/ui/graphiql'). * @param ttlSeconds Token lifetime; clamped to (0, 600]. */ export declare function mintIframeToken(agentId: string, profile: string, pathPrefix: string, ttlSeconds?: number): Promise; /** * Mint a v2 scoped iframe token bound to an allow-list of path prefixes. * UI plugins use this so a single token can reach both `/ui/` * (where the iframe HTML lives) and the plugin's REST surface * (e.g. `/api/profiles/*\//*`) without exposing the master apiKey. * * Agent enforces the prefix list on every request via * `verifyIframeToken` — calls outside the declared prefixes are rejected * regardless of how the iframe acquired the token. */ export declare function mintScopedIframeToken(agentId: string, profile: string, pathPrefixes: string[], ttlSeconds?: number): Promise; /** * Schedule an auto-refresh that re-mints the token ~60s before expiry. * Returns a handle whose `cancel()` clears the timer. * * Caller is responsible for re-rendering / updating iframe `src` on each * refresh by reacting to the `onRefresh` callback's payload. */ export declare function scheduleIframeTokenRefresh(agentId: string, profile: string, pathPrefix: string, current: IframeTokenResponse, onRefresh: (next: IframeTokenResponse) => void, onError?: (err: Error) => void, ttlSeconds?: number): IframeTokenAutoRefreshHandle; /** * Scoped-token variant of {@link scheduleIframeTokenRefresh}. Re-mints a * v2 token bound to the same prefix allow-list ~60s before expiry. Used by * UI plugins whose iframe also calls the plugin's profile-scoped REST * surface, so the refreshed token keeps authorizing both `/ui/` * and `/api/profiles///*`. */ export declare function scheduleScopedIframeTokenRefresh(agentId: string, profile: string, pathPrefixes: string[], current: IframeTokenResponse, onRefresh: (next: IframeTokenResponse) => void, onError?: (err: Error) => void, ttlSeconds?: number): IframeTokenAutoRefreshHandle; /** * Append the iframe token as a `#vt=` URL fragment to the given URL * (F5 — security cutover, primary entry point for /ui/ embeds). * * Fragments never reach the server, never appear in proxy access logs, * never land in the browser's Referer header on outbound sub-requests, * and aren't persisted by middlebox URL loggers. The agent's bootstrap * shim at `/ui/` reads the fragment client-side and POSTs it to * `/api/agent/ui-exchange`, which trades the single-use iframe token * for a path-scoped HttpOnly cookie (`vt_ui_`). Subsequent * sub-resource requests under `/ui//` auto-attach the cookie. * * Use this for any new iframe embed. The legacy * `appendIframeTokenParam(url, token)` helper was removed as part of * the F5 residual hard-cutover — the Ungit surface at * `/api/plugins//ui` is now behind an equivalent host-level * cookie shim (sibling of the F5 `/ui/` shim) that exchanges * the `#vt=` fragment for a path-scoped HttpOnly cookie. There are * no remaining `?vt=` URL-query callers. */ export declare function appendIframeTokenFragment(url: string, token: string): string; /** * `?vt=` query-string fallback for embeds whose upstream reverse * proxy validates the entry document via query auth and issues its own * session cookie (e.g. the external `vibe-plugin-tool-git` Ungit proxy at * `/git/`). Top-level iframe navigation cannot inject headers, so the * single-use ticket lives in the URL once; the proxy strips it before * forwarding upstream and immediately swaps it for a SameSite=None * HttpOnly session cookie. * * The exposure is narrow: * - F6 makes every iframe token single-use (replay → 401). * - F7 strips the token from the proxy's upstream forwards. * - F10 enforces Origin/CSRF on non-GET/HEAD sub-requests. * * Do NOT use for new embeds. Prefer `appendIframeTokenFragment`. */ export declare function appendIframeTokenQuery(url: string, token: string): string;