@@ -11,18 +11,18 @@ import {
11
11
} from "./types" ;
12
12
import { oauthRequest } from "./utils" ;
13
13
14
- type OAuthAppOptionsWithoutClientSecret = {
14
+ export type ExchangeDeviceCodeOAuthAppOptionsWithoutClientSecret = {
15
15
clientType : "oauth-app" ;
16
16
clientId : string ;
17
17
code : string ;
18
18
redirectUrl ?: string ;
19
19
state ?: string ;
20
20
request ?: RequestInterface ;
21
21
} ;
22
- type OAuthAppOptions = OAuthAppOptionsWithoutClientSecret & {
22
+ export type ExchangeDeviceCodeOAuthAppOptions = ExchangeDeviceCodeOAuthAppOptionsWithoutClientSecret & {
23
23
clientSecret : string ;
24
24
} ;
25
- type GitHubAppOptionsWithoutClientSecret = {
25
+ export type ExchangeDeviceCodeGitHubAppOptionsWithoutClientSecret = {
26
26
clientType : "github-app" ;
27
27
clientId : string ;
28
28
code : string ;
@@ -31,7 +31,7 @@ type GitHubAppOptionsWithoutClientSecret = {
31
31
request ?: RequestInterface ;
32
32
} ;
33
33
34
- type GitHubAppOptions = GitHubAppOptionsWithoutClientSecret & {
34
+ export type ExchangeDeviceCodeGitHubAppOptions = ExchangeDeviceCodeGitHubAppOptionsWithoutClientSecret & {
35
35
clientSecret : string ;
36
36
} ;
37
37
@@ -48,78 +48,67 @@ type GitHubAppAuthenticationWithExpirationWithoutClientSecret = Omit<
48
48
"clientSecret"
49
49
> ;
50
50
51
+ export type ExchangeDeviceCodeOAuthAppResponse = OctokitResponse < OAuthAppCreateTokenResponseData > & {
52
+ authentication : OAuthAppAuthentication ;
53
+ } ;
54
+
55
+ export type ExchangeDeviceCodeOAuthAppResponseWithoutClientSecret = OctokitResponse < OAuthAppCreateTokenResponseData > & {
56
+ authentication : OAuthAppAuthenticationWithoutClientSecret ;
57
+ } ;
58
+
59
+ export type ExchangeDeviceCodeGitHubAppResponse = OctokitResponse <
60
+ | GitHubAppCreateTokenResponseData
61
+ | GitHubAppCreateTokenWithExpirationResponseData
62
+ > & {
63
+ authentication :
64
+ | GitHubAppAuthentication
65
+ | GitHubAppAuthenticationWithExpiration ;
66
+ } ;
67
+
68
+ export type ExchangeDeviceCodeGitHubAppResponseWithoutClientSecret = OctokitResponse <
69
+ | GitHubAppCreateTokenResponseData
70
+ | GitHubAppCreateTokenWithExpirationResponseData
71
+ > & {
72
+ authentication :
73
+ | GitHubAppAuthenticationWithoutClientSecret
74
+ | GitHubAppAuthenticationWithExpirationWithoutClientSecret ;
75
+ } ;
76
+
51
77
/**
52
78
* Exchange the code from GitHub's OAuth Web flow for OAuth Apps.
53
79
*/
54
80
export async function exchangeDeviceCode (
55
- options : OAuthAppOptions
56
- ) : Promise <
57
- OctokitResponse < OAuthAppCreateTokenResponseData > & {
58
- authentication : OAuthAppAuthentication ;
59
- }
60
- > ;
81
+ options : ExchangeDeviceCodeOAuthAppOptions
82
+ ) : Promise < ExchangeDeviceCodeOAuthAppResponse > ;
61
83
62
84
/**
63
85
* Exchange the code from GitHub's OAuth Web flow for OAuth Apps without clientSecret
64
86
*/
65
87
export async function exchangeDeviceCode (
66
- options : OAuthAppOptionsWithoutClientSecret
67
- ) : Promise <
68
- OctokitResponse < OAuthAppCreateTokenResponseData > & {
69
- authentication : OAuthAppAuthenticationWithoutClientSecret ;
70
- }
71
- > ;
88
+ options : ExchangeDeviceCodeOAuthAppOptionsWithoutClientSecret
89
+ ) : Promise < ExchangeDeviceCodeOAuthAppResponseWithoutClientSecret > ;
72
90
73
91
/**
74
92
* Exchange the code from GitHub's OAuth Web flow for GitHub Apps. `scopes` are not supported by GitHub Apps.
75
93
*/
76
94
export async function exchangeDeviceCode (
77
- options : GitHubAppOptions
78
- ) : Promise <
79
- OctokitResponse <
80
- | GitHubAppCreateTokenResponseData
81
- | GitHubAppCreateTokenWithExpirationResponseData
82
- > & {
83
- authentication :
84
- | GitHubAppAuthentication
85
- | GitHubAppAuthenticationWithExpiration ;
86
- }
87
- > ;
95
+ options : ExchangeDeviceCodeGitHubAppOptions
96
+ ) : Promise < ExchangeDeviceCodeGitHubAppResponse > ;
88
97
89
98
/**
90
99
* Exchange the code from GitHub's OAuth Web flow for GitHub Apps without using `clientSecret`. `scopes` are not supported by GitHub Apps.
91
100
*/
92
101
export async function exchangeDeviceCode (
93
- options : GitHubAppOptionsWithoutClientSecret
94
- ) : Promise <
95
- OctokitResponse <
96
- | GitHubAppCreateTokenResponseData
97
- | GitHubAppCreateTokenWithExpirationResponseData
98
- > & {
99
- authentication :
100
- | GitHubAppAuthenticationWithoutClientSecret
101
- | GitHubAppAuthenticationWithExpirationWithoutClientSecret ;
102
- }
103
- > ;
102
+ options : ExchangeDeviceCodeGitHubAppOptionsWithoutClientSecret
103
+ ) : Promise < ExchangeDeviceCodeGitHubAppResponseWithoutClientSecret > ;
104
104
105
105
export async function exchangeDeviceCode (
106
106
options :
107
- | OAuthAppOptions
108
- | GitHubAppOptions
109
- | OAuthAppOptionsWithoutClientSecret
110
- | GitHubAppOptionsWithoutClientSecret
111
- ) : Promise <
112
- OctokitResponse <
113
- | GitHubAppCreateTokenWithExpirationResponseData
114
- | GitHubAppCreateTokenResponseData
115
- | GitHubAppCreateTokenWithExpirationResponseData
116
- | OAuthAppAuthenticationWithoutClientSecret
117
- | GitHubAppAuthenticationWithoutClientSecret
118
- | GitHubAppAuthenticationWithExpirationWithoutClientSecret
119
- > & {
120
- authentication : any ;
121
- }
122
- > {
107
+ | ExchangeDeviceCodeOAuthAppOptions
108
+ | ExchangeDeviceCodeGitHubAppOptions
109
+ | ExchangeDeviceCodeOAuthAppOptionsWithoutClientSecret
110
+ | ExchangeDeviceCodeGitHubAppOptionsWithoutClientSecret
111
+ ) : Promise < any > {
123
112
const request =
124
113
options . request ||
125
114
/* istanbul ignore next: we always pass a custom request in tests */
0 commit comments