@@ -42,11 +42,10 @@ declare module 'fastify' {
42
42
expectType < fastifyOauth2 . ProviderConfiguration > ( auth ) ;
43
43
expectType < string [ ] > ( scope ) ;
44
44
expectType < fastifyOauth2 . Credentials > ( credentials ) ;
45
- expectType < fastifyOauth2 . Credentials > ( credentials ) ;
46
45
47
46
expectType < void > ( fastifyOauth2 ( server , OAuth2Options , ( ) => { } ) ) ;
48
47
expectError ( fastifyOauth2 ( ) ) ; // error because missing required arguments
49
- expectError ( fastifyOauth2 ( server , { } , ( ) => { } ) ) ; // error because missing required plugin options
48
+ expectError ( fastifyOauth2 ( server , { } , ( ) => { } ) ) ; // error because missing required options
50
49
51
50
expectAssignable < fastifyOauth2 . ProviderConfiguration > ( fastifyOauth2 . FACEBOOK_CONFIGURATION ) ;
52
51
expectAssignable < fastifyOauth2 . ProviderConfiguration > ( fastifyOauth2 . GITHUB_CONFIGURATION ) ;
@@ -59,8 +58,8 @@ expectAssignable<fastifyOauth2.ProviderConfiguration>(fastifyOauth2.VKONTAKTE_CO
59
58
server . get ( '/testOauth/callback' , async request => {
60
59
expectType < fastifyOauth2 . OAuth2Namespace > ( server . testOAuthName ) ;
61
60
62
- const token = await server . testOAuthName . getAccessTokenFromAuthorizationCodeFlow ( request ) ;
63
- expectType < fastifyOauth2 . OAuth2Token > ( token ) ;
61
+ expectType < fastifyOauth2 . OAuth2Token > ( await server . testOAuthName . getAccessTokenFromAuthorizationCodeFlow ( request ) ) ;
62
+ expectType < Promise < fastifyOauth2 . OAuth2Token > > ( server . testOAuthName . getAccessTokenFromAuthorizationCodeFlow ( request ) ) ;
64
63
expectType < void > (
65
64
server . testOAuthName . getAccessTokenFromAuthorizationCodeFlow ( request , ( t : fastifyOauth2 . OAuth2Token ) : void => { } ) ,
66
65
) ;
@@ -71,10 +70,14 @@ server.get('/testOauth/callback', async request => {
71
70
) ; // error because non-Promise function call should return void and have a callback argument
72
71
expectError < void > ( server . testOAuthName . getAccessTokenFromAuthorizationCodeFlow ( request ) ) ; // error because function call does not pass a callback as second argument.
73
72
73
+ const token = await server . testOAuthName . getAccessTokenFromAuthorizationCodeFlow ( request ) ;
74
74
if ( token . refresh_token ) {
75
75
expectType < fastifyOauth2 . OAuth2Token > (
76
76
await server . testOAuthName . getNewAccessTokenUsingRefreshToken ( token . refresh_token , { } ) ,
77
77
) ;
78
+ expectType < Promise < fastifyOauth2 . OAuth2Token > > (
79
+ server . testOAuthName . getNewAccessTokenUsingRefreshToken ( token . refresh_token , { } ) ,
80
+ ) ;
78
81
expectType < void > (
79
82
server . testOAuthName . getNewAccessTokenUsingRefreshToken (
80
83
token . refresh_token ,
0 commit comments