@@ -11,18 +11,18 @@ import {
1111} from "./types" ;
1212import { oauthRequest } from "./utils" ;
1313
14- type OAuthAppOptionsWithoutClientSecret = {
14+ export type ExchangeDeviceCodeOAuthAppOptionsWithoutClientSecret = {
1515 clientType : "oauth-app" ;
1616 clientId : string ;
1717 code : string ;
1818 redirectUrl ?: string ;
1919 state ?: string ;
2020 request ?: RequestInterface ;
2121} ;
22- type OAuthAppOptions = OAuthAppOptionsWithoutClientSecret & {
22+ export type ExchangeDeviceCodeOAuthAppOptions = ExchangeDeviceCodeOAuthAppOptionsWithoutClientSecret & {
2323 clientSecret : string ;
2424} ;
25- type GitHubAppOptionsWithoutClientSecret = {
25+ export type ExchangeDeviceCodeGitHubAppOptionsWithoutClientSecret = {
2626 clientType : "github-app" ;
2727 clientId : string ;
2828 code : string ;
@@ -31,7 +31,7 @@ type GitHubAppOptionsWithoutClientSecret = {
3131 request ?: RequestInterface ;
3232} ;
3333
34- type GitHubAppOptions = GitHubAppOptionsWithoutClientSecret & {
34+ export type ExchangeDeviceCodeGitHubAppOptions = ExchangeDeviceCodeGitHubAppOptionsWithoutClientSecret & {
3535 clientSecret : string ;
3636} ;
3737
@@ -48,78 +48,67 @@ type GitHubAppAuthenticationWithExpirationWithoutClientSecret = Omit<
4848 "clientSecret"
4949> ;
5050
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+
5177/**
5278 * Exchange the code from GitHub's OAuth Web flow for OAuth Apps.
5379 */
5480export async function exchangeDeviceCode (
55- options : OAuthAppOptions
56- ) : Promise <
57- OctokitResponse < OAuthAppCreateTokenResponseData > & {
58- authentication : OAuthAppAuthentication ;
59- }
60- > ;
81+ options : ExchangeDeviceCodeOAuthAppOptions
82+ ) : Promise < ExchangeDeviceCodeOAuthAppResponse > ;
6183
6284/**
6385 * Exchange the code from GitHub's OAuth Web flow for OAuth Apps without clientSecret
6486 */
6587export async function exchangeDeviceCode (
66- options : OAuthAppOptionsWithoutClientSecret
67- ) : Promise <
68- OctokitResponse < OAuthAppCreateTokenResponseData > & {
69- authentication : OAuthAppAuthenticationWithoutClientSecret ;
70- }
71- > ;
88+ options : ExchangeDeviceCodeOAuthAppOptionsWithoutClientSecret
89+ ) : Promise < ExchangeDeviceCodeOAuthAppResponseWithoutClientSecret > ;
7290
7391/**
7492 * Exchange the code from GitHub's OAuth Web flow for GitHub Apps. `scopes` are not supported by GitHub Apps.
7593 */
7694export 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 > ;
8897
8998/**
9099 * Exchange the code from GitHub's OAuth Web flow for GitHub Apps without using `clientSecret`. `scopes` are not supported by GitHub Apps.
91100 */
92101export 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 > ;
104104
105105export async function exchangeDeviceCode (
106106 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 > {
123112 const request =
124113 options . request ||
125114 /* istanbul ignore next: we always pass a custom request in tests */
0 commit comments