File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 11import * as Octokit from "@octokit/rest" ;
22
3+ /**
4+ * An interface providing methods for obtaining access tokens
5+ * or an octokit instance for making HTTP requests.
6+ */
37export interface Credentials {
48 /**
5- * Creates or returns an instance of Octokit.
9+ * Returns an authenticated instance of Octokit.
10+ * May prompt the user to log in and grant permission to use their
11+ * token, if they have not already done so.
612 *
713 * @returns An instance of Octokit.
814 */
915 getOctokit ( ) : Promise < Octokit . Octokit > ;
1016
17+ /**
18+ * Returns an OAuth access token.
19+ * May prompt the user to log in and grant permission to use their
20+ * token, if they have not already done so.
21+ *
22+ * @returns An OAuth access token.
23+ */
1124 getAccessToken ( ) : Promise < string > ;
1225
26+ /**
27+ * Returns an OAuth access token if one is available.
28+ * If a token is not available this will return undefined and
29+ * will not prompt the user to log in.
30+ *
31+ * @returns An OAuth access token, or undefined.
32+ */
1333 getExistingAccessToken ( ) : Promise < string | undefined > ;
1434}
Original file line number Diff line number Diff line change @@ -18,6 +18,10 @@ function makeTestOctokit(octokit: Octokit.Octokit): Credentials {
1818 } ;
1919}
2020
21+ /**
22+ * Get a Credentials instance that calls a stub function instead
23+ * of making real HTTP requests.
24+ */
2125export function testCredentialsWithStub (
2226 requestSpy ?: jest . SpyInstance < RequestInterface < object > > ,
2327) : Credentials {
@@ -29,6 +33,10 @@ export function testCredentialsWithStub(
2933 return makeTestOctokit ( { request } as any ) ;
3034}
3135
36+ /**
37+ * Get a Credentials instance that returns a real octokit instance,
38+ * optionally authenticated with a given token.
39+ */
3240export function testCredentialsWithRealOctokit ( token ?: string ) : Credentials {
3341 return makeTestOctokit ( new Octokit . Octokit ( { auth : token , retry } ) ) ;
3442}
You can’t perform that action at this time.
0 commit comments