11import { RequestInterface } from "./request" ;
22export { RequestInterface } from "./request" ;
33
4+ interface AuthStrategyInterface {
5+ ( options ?: any ) : AuthInterface ;
6+ }
7+ interface AuthInterface {
8+ ( options ?: any ) : Promise < unknown > ;
9+ }
10+
11+ type AuthStrategyAndOptions < AuthStrategy extends AuthStrategyInterface > = {
12+ authStrategy : AuthStrategy ;
13+ auth : Parameters < AuthStrategy > [ 0 ] ;
14+ } ;
15+
416/**
517 * Global Octokit interfaces that can be extended as needed.
618 */
719export namespace Octokit {
820 interface Options {
21+ /**
22+ * API version. Defaults to `"github.com"`.
23+ *
24+ * In order to set it a GitHub Enterprise Version such as "ghes-3.1",
25+ * install the according `@octokit-next/types-rest-api-ghes-*` package,
26+ * such as `@octokit-next/types-rest-api-ghes-3.1`.
27+ */
928 version ?: keyof Octokit . ApiVersions ;
1029
1130 /**
@@ -22,6 +41,22 @@ export namespace Octokit {
2241 */
2342 userAgent ?: string ;
2443
44+ // /**
45+ // * Auth strategy function
46+ // *
47+ // * @see https://github.com/octokit/auth.js
48+ // */
49+ // authStrategy?: AuthStrategyInterface;
50+
51+ // /**
52+ // * Auth strategy options. Can be set to an access token. If `authStrategy`
53+ // * option is set, the auth option must be set to the authentication strategy options.
54+ // */
55+ // auth?: String | Record<string, unknown>;
56+
57+ /**
58+ * Request options passed as default `{ request }` options to every request.
59+ */
2560 request ?: RequestOptions ;
2661 }
2762
@@ -120,7 +155,8 @@ export namespace Octokit {
120155
121156export declare class Octokit <
122157 TVersion extends keyof Octokit . ApiVersions = "github.com" ,
123- TOptions extends Octokit . Options = Octokit . Options
158+ TOptions extends Octokit . Options = Octokit . Options ,
159+ TAuthStrategy extends AuthStrategyInterface | never = never
124160> {
125161 /**
126162 * Pass one or multiple plugin functions to extend the `Octokit` class.
@@ -216,7 +252,23 @@ export declare class Octokit<
216252 */
217253 options : { version : TVersion } & TOptions ;
218254
219- constructor ( options : { version ?: TVersion } & TOptions ) ;
255+ /**
256+ * Constructor without setting `authStrategy`
257+ *
258+ * You can optionally set the `auth` option to an access token string in order
259+ * to authenticate requests.
260+ */
261+ constructor ( options : { version ?: TVersion } & { auth ?: string } & TOptions ) ;
262+
263+ /**
264+ * Constructor with setting `authStrategy`
265+ *
266+ * The `auth` option must be set to whatever the function passed as `authStrategy` accepts
267+ */
268+ constructor (
269+ options : { version ?: TVersion } & AuthStrategyAndOptions < TAuthStrategy > &
270+ TOptions
271+ ) ;
220272
221273 request : RequestInterface < TVersion > ;
222274}
0 commit comments