UNPKG

1.57 kBTypeScriptView Raw
1import { EndpointOptions } from "./EndpointOptions";
2import { OctokitResponse } from "./OctokitResponse";
3import { RequestInterface } from "./RequestInterface";
4import { RequestParameters } from "./RequestParameters";
5import { Route } from "./Route";
6/**
7 * Interface to implement complex authentication strategies for Octokit.
8 * An object Implementing the AuthInterface can directly be passed as the
9 * `auth` option in the Octokit constructor.
10 *
11 * For the official implementations of the most common authentication
12 * strategies, see https://github.com/octokit/auth.js
13 */
14export interface AuthInterface<AuthOptions extends any[], Authentication extends any> {
15 (...args: AuthOptions): Promise<Authentication>;
16 hook: {
17 /**
18 * Sends a request using the passed `request` instance
19 *
20 * @param {object} endpoint Must set `method` and `url`. Plus URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
21 */
22 <T = any>(request: RequestInterface, options: EndpointOptions): Promise<OctokitResponse<T>>;
23 /**
24 * Sends a request using the passed `request` instance
25 *
26 * @param {string} route Request method + URL. Example: `'GET /orgs/{org}'`
27 * @param {object} [parameters] URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
28 */
29 <T = any>(request: RequestInterface, route: Route, parameters?: RequestParameters): Promise<OctokitResponse<T>>;
30 };
31}