1
1
import * as fastify from 'fastify' ;
2
2
import * as http from 'http' ;
3
3
4
-
5
- export interface OAuth2Token {
6
- token_type : 'bearer' ;
7
- access_token : string ;
8
- refresh_token ?: string ;
9
- expires_in : number
10
- }
11
-
12
- export interface OAuth2Namespace {
13
- getAccessTokenFromAuthorizationCodeFlow (
14
- request : fastify . FastifyRequest < http . IncomingMessage > ,
15
- ) : Promise < OAuth2Token >
16
-
17
- getAccessTokenFromAuthorizationCodeFlow (
18
- request : fastify . FastifyRequest < http . IncomingMessage > ,
19
- callback : ( token : OAuth2Token ) => void
20
- ) : void
21
-
22
- getNewAccessTokenUsingRefreshToken (
23
- refreshToken : string ,
24
- params : Object ,
25
- callback : ( token : OAuth2Token ) => void
26
- ) : void
27
-
28
- getNewAccessTokenUsingRefreshToken (
29
- refreshToken : string ,
30
- params : Object ,
31
- ) : Promise < OAuth2Token >
32
- }
33
-
34
- export interface ProviderConfiguration {
35
- authorizeHost : string ;
36
- authorizePath : string ;
37
- tokenHost : string ;
38
- tokenPath : string ;
39
- }
40
-
41
- export interface Credentials {
42
- client : {
43
- id : string ;
44
- secret : string ;
45
- } ;
46
- auth : ProviderConfiguration ;
47
- }
48
-
49
- export interface FastifyOAuth2Options {
50
- name : string ;
51
- scope : string [ ] ;
52
- credentials : Credentials ;
53
- callbackUri : string ;
54
- callbackUriParams ?: Object ;
55
- generateStateFunction ?: Function ;
56
- checkStateFunction ?: Function ;
57
- startRedirectPath : string ;
58
- }
59
-
60
-
61
4
declare function fastifyOauth2 (
62
5
instance : fastify . FastifyInstance < http . Server , http . IncomingMessage , http . ServerResponse > ,
63
- options : FastifyOAuth2Options ,
6
+ options : fastifyOauth2 . FastifyOAuth2Options ,
64
7
callback : ( err ?: fastify . FastifyError ) => void
65
8
) : void ;
66
9
67
-
68
10
declare namespace fastifyOauth2 {
69
11
const FACEBOOK_CONFIGURATION : ProviderConfiguration ;
70
12
const GITHUB_CONFIGURATION : ProviderConfiguration ;
@@ -73,8 +15,61 @@ declare namespace fastifyOauth2 {
73
15
const MICROSOFT_CONFIGURATION : ProviderConfiguration ;
74
16
const SPOTIFY_CONFIGURATION : ProviderConfiguration ;
75
17
const VKONTAKTE_CONFIGURATION : ProviderConfiguration ;
76
- }
77
-
78
- export default fastifyOauth2 ;
79
18
19
+ interface OAuth2Token {
20
+ token_type : 'bearer' ;
21
+ access_token : string ;
22
+ refresh_token ?: string ;
23
+ expires_in : number
24
+ }
25
+
26
+ interface OAuth2Namespace {
27
+ getAccessTokenFromAuthorizationCodeFlow (
28
+ request : fastify . FastifyRequest < http . IncomingMessage > ,
29
+ ) : Promise < OAuth2Token >
30
+
31
+ getAccessTokenFromAuthorizationCodeFlow (
32
+ request : fastify . FastifyRequest < http . IncomingMessage > ,
33
+ callback : ( token : OAuth2Token ) => void
34
+ ) : void
35
+
36
+ getNewAccessTokenUsingRefreshToken (
37
+ refreshToken : string ,
38
+ params : Object ,
39
+ callback : ( token : OAuth2Token ) => void
40
+ ) : void
41
+
42
+ getNewAccessTokenUsingRefreshToken (
43
+ refreshToken : string ,
44
+ params : Object ,
45
+ ) : Promise < OAuth2Token >
46
+ }
47
+
48
+ interface ProviderConfiguration {
49
+ authorizeHost : string ;
50
+ authorizePath : string ;
51
+ tokenHost : string ;
52
+ tokenPath : string ;
53
+ }
54
+
55
+ interface Credentials {
56
+ client : {
57
+ id : string ;
58
+ secret : string ;
59
+ } ;
60
+ auth : ProviderConfiguration ;
61
+ }
62
+
63
+ interface FastifyOAuth2Options {
64
+ name : string ;
65
+ scope : string [ ] ;
66
+ credentials : Credentials ;
67
+ callbackUri : string ;
68
+ callbackUriParams ?: Object ;
69
+ generateStateFunction ?: Function ;
70
+ checkStateFunction ?: Function ;
71
+ startRedirectPath : string ;
72
+ }
73
+ }
80
74
75
+ export = fastifyOauth2 ;
0 commit comments