export interface AppCredentials { id: number; slug: string; /** The app's private key. Only ever held in memory, then handed to `gh secret set` on stdin. */ pem: string; htmlUrl: string; } /** What the GitHub App may do: exactly what the fix job needs on this one repo, nothing else. */ export declare function buildManifest(o: { name: string; redirectUrl: string; repo: string; }): { name: string; url: string; redirect_url: string; description: string; public: boolean; default_permissions: { contents: string; pull_requests: string; issues: string; }; default_events: never[]; }; /** A page that posts the manifest to GitHub, which is how GitHub's manifest flow starts. Needs no dependencies. */ export declare function manifestPage(actionUrl: string, manifest: object): string; /** The short-lived token an app uses to prove who it is to GitHub, before it can ask for an installation token. */ export declare function appJwt(appId: number | string, privateKeyPem: string, nowSeconds?: number): string; /** Trades the one-time code GitHub redirected back with for the app's credentials. GitHub needs no other authentication here. */ export declare function exchangeManifestCode(code: string, f?: typeof fetch): Promise; /** Whether the app is installed on the repo, asked as the app itself (so it also proves the key works). */ export declare function isInstalled(creds: AppCredentials, repo: string, f?: typeof fetch): Promise; export interface ManifestServer { /** Where to send the user's browser. */ url: string; credentials: Promise; close: () => void; } /** * A one-shot local server for GitHub to redirect back to. It listens on 127.0.0.1 only, on a random port, checks the * Host header (against DNS rebinding) and a random `state` (against a stranger's page posting to it), and accepts one * callback: then it closes. */ export declare function startManifestServer(o: { repo: string; ownerType: 'Organization' | 'User'; fetch?: typeof fetch; timeoutMs?: number; name?: string; }): Promise; /** Runs `gh` with optional stdin. Resolves ok=false (never throws) when gh is missing or refuses. */ export type Gh = (args: string[], input?: string) => Promise<{ ok: boolean; out: string; }>; export declare const gh: Gh; /** Sets a repo secret. The value goes through gh's stdin, never a command line, a file or a log. */ export declare function setRepoSecret(name: string, value: string, repo: string, run?: Gh): Promise; export declare const openInBrowser: (url: string) => void; export interface AppOptions { root: string; repo: string; log?: (line: string) => void; open?: (url: string) => void; fetch?: typeof fetch; run?: Gh; /** Where the key goes when `gh` can't store it. Defaults to ~/.blazeresolver. */ keyDir?: string; /** How long to wait for the app to be installed, and how often to check. */ installTimeoutMs?: number; pollMs?: number; serverTimeoutMs?: number; } export interface AppResult { slug: string; appId: number; installed: boolean; /** Names of the repo secrets that were set. */ secrets: string[]; /** Where the private key was saved because gh could not store it, if it could not. */ keyFile?: string; workflowUpdated: boolean; } /** * Creates a GitHub App for this repo through GitHub's manifest flow, stores its credentials as repo secrets, and * switches the workflow to use it. After this the fix job's token is short-lived and scoped to the one repo, and the * pull requests it opens trigger your CI (the built-in token's PRs do not). */ export declare function runApp(opts: AppOptions): Promise; //# sourceMappingURL=app.d.ts.map