Skip to content

Commit 33ea841

Browse files
committed
Fix #42
1 parent 12c032e commit 33ea841

File tree

1 file changed

+57
-62
lines changed

1 file changed

+57
-62
lines changed

index.d.ts

Lines changed: 57 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,12 @@
11
import * as fastify from 'fastify';
22
import * as http from 'http';
33

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-
614
declare function fastifyOauth2(
625
instance: fastify.FastifyInstance<http.Server, http.IncomingMessage, http.ServerResponse>,
63-
options: FastifyOAuth2Options,
6+
options: fastifyOauth2.FastifyOAuth2Options,
647
callback: (err?: fastify.FastifyError) => void
658
): void;
669

67-
6810
declare namespace fastifyOauth2 {
6911
const FACEBOOK_CONFIGURATION: ProviderConfiguration;
7012
const GITHUB_CONFIGURATION: ProviderConfiguration;
@@ -73,8 +15,61 @@ declare namespace fastifyOauth2 {
7315
const MICROSOFT_CONFIGURATION: ProviderConfiguration;
7416
const SPOTIFY_CONFIGURATION: ProviderConfiguration;
7517
const VKONTAKTE_CONFIGURATION: ProviderConfiguration;
76-
}
77-
78-
export default fastifyOauth2;
7918

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+
}
8074

75+
export = fastifyOauth2;

0 commit comments

Comments
 (0)