import type { EndpointOptions, RequestParameters, Route, RequestInterface, OctokitResponse } from "@octokit/types"; import * as AuthOAuthUser from "@octokit/auth-oauth-user"; import * as DeviceTypes from "@octokit/auth-oauth-device"; export type ClientType = "oauth-app" | "github-app"; export type OAuthAppStrategyOptions = { clientType?: "oauth-app"; clientId: string; clientSecret: string; request?: RequestInterface; }; export type GitHubAppStrategyOptions = { clientType: "github-app"; clientId: string; clientSecret: string; request?: RequestInterface; }; export type AppAuthOptions = { type: "oauth-app"; }; export type WebFlowAuthOptions = { type: "oauth-user"; code: string; redirectUrl?: string; state?: string; }; export type OAuthAppDeviceFlowAuthOptions = { type: "oauth-user"; onVerification: DeviceTypes.OAuthAppStrategyOptions["onVerification"]; scopes?: string[]; }; export type GitHubAppDeviceFlowAuthOptions = { type: "oauth-user"; onVerification: DeviceTypes.OAuthAppStrategyOptions["onVerification"]; }; export type AppAuthentication = { type: "oauth-app"; clientId: string; clientSecret: string; clientType: ClientType; headers: { authorization: string; }; }; export type OAuthAppUserAuthentication = AuthOAuthUser.OAuthAppAuthentication; export type GitHubAppUserAuthentication = AuthOAuthUser.GitHubAppAuthentication; export type GitHubAppUserAuthenticationWithExpiration = AuthOAuthUser.GitHubAppAuthenticationWithExpiration; export type FactoryOAuthAppWebFlowOptions = OAuthAppStrategyOptions & Omit & { clientType: "oauth-app"; }; export type FactoryOAuthAppDeviceFlowOptions = OAuthAppStrategyOptions & Omit & { clientType: "oauth-app"; }; export type FactoryGitHubAppWebFlowOptions = GitHubAppStrategyOptions & Omit; export type FactoryGitHubAppDeviceFlowOptions = GitHubAppStrategyOptions & Omit; export interface FactoryOAuthAppWebFlow { (options: FactoryOAuthAppWebFlowOptions): T; } export interface FactoryOAuthAppDeviceFlow { (options: FactoryOAuthAppDeviceFlowOptions): T; } export interface FactoryGitHubWebFlow { (options: FactoryGitHubAppWebFlowOptions): T; } export interface FactoryGitHubDeviceFlow { (options: FactoryGitHubAppDeviceFlowOptions): T; } export interface OAuthAppAuthInterface { (options: AppAuthOptions): Promise; (options: WebFlowAuthOptions & { factory: FactoryOAuthAppWebFlow; }): Promise; (options: OAuthAppDeviceFlowAuthOptions & { factory: FactoryOAuthAppDeviceFlow; }): Promise; (options: WebFlowAuthOptions): Promise; (options: OAuthAppDeviceFlowAuthOptions): Promise; hook(request: RequestInterface, route: Route | EndpointOptions, parameters?: RequestParameters): Promise>; } export interface GitHubAuthInterface { (options?: AppAuthOptions): Promise; (options: WebFlowAuthOptions & { factory: FactoryGitHubWebFlow; }): Promise; (options: GitHubAppDeviceFlowAuthOptions & { factory: FactoryGitHubDeviceFlow; }): Promise; (options?: WebFlowAuthOptions): Promise; (options?: GitHubAppDeviceFlowAuthOptions): Promise; hook(request: RequestInterface, route: Route | EndpointOptions, parameters?: RequestParameters): Promise>; } export type OAuthAppState = OAuthAppStrategyOptions & { clientType: "oauth-app"; request: RequestInterface; }; export type GitHubAppState = GitHubAppStrategyOptions & { clientType: "github-app"; request: RequestInterface; };