/** * GitHub OAuth - Device Flow implementation * * Uses GitHub's Device Flow for CLI authentication: * https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps#device-flow */ import type { Result } from "../types.js"; /** * Device code response from GitHub */ export interface DeviceCodeResponse { device_code: string; user_code: string; verification_uri: string; expires_in: number; interval: number; } /** * Access token response from GitHub */ export interface AccessTokenResponse { access_token: string; token_type: string; scope: string; } /** * OAuth error types */ export interface OAuthError { code: "REQUEST_FAILED" | "AUTHORIZATION_PENDING" | "SLOW_DOWN" | "EXPIRED_TOKEN" | "ACCESS_DENIED" | "UNSUPPORTED_GRANT_TYPE" | "INCORRECT_CLIENT_CREDENTIALS" | "INCORRECT_DEVICE_CODE" | "UNKNOWN_ERROR"; message: string; } /** * GitHub App credentials needed for OAuth */ export interface GitHubAppCredentials { clientId: string; } /** * Request a device code from GitHub * * This is step 1 of the Device Flow - user will need to visit the * verification_uri and enter the user_code */ export declare function requestDeviceCode(credentials: GitHubAppCredentials, scopes?: string[]): Promise>; /** * Poll for access token after user has authorized * * This is step 2 of the Device Flow - poll until the user completes * authorization or the device code expires */ export declare function pollForAccessToken(credentials: GitHubAppCredentials, deviceCode: string): Promise>; /** * Progress callback for polling */ export interface PollProgress { /** Called when polling starts */ onStart?: (deviceCode: DeviceCodeResponse) => void; /** Called on each poll attempt */ onPoll?: (attempt: number) => void; /** Called when user needs to slow down */ onSlowDown?: (newInterval: number) => void; } /** * Complete the Device Flow - request code and poll until authorized * * This combines steps 1 and 2, handling the polling loop with proper * backoff as specified by GitHub */ export declare function completeDeviceFlow(credentials: GitHubAppCredentials, scopes?: string[], progress?: PollProgress): Promise>; //# sourceMappingURL=oauth.d.ts.map