forked from fastify/fastify-oauth2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.d.ts
More file actions
72 lines (61 loc) · 1.95 KB
/
index.d.ts
File metadata and controls
72 lines (61 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import * as fastify from 'fastify';
import * as http from 'http';
declare function fastifyOauth2(
instance: fastify.FastifyInstance<http.Server, http.IncomingMessage, http.ServerResponse>,
options: fastifyOauth2.FastifyOAuth2Options,
callback: (err?: fastify.FastifyError) => void,
): void;
declare namespace fastifyOauth2 {
const FACEBOOK_CONFIGURATION: ProviderConfiguration;
const GITHUB_CONFIGURATION: ProviderConfiguration;
const LINKEDIN_CONFIGURATION: ProviderConfiguration;
const GOOGLE_CONFIGURATION: ProviderConfiguration;
const MICROSOFT_CONFIGURATION: ProviderConfiguration;
const SPOTIFY_CONFIGURATION: ProviderConfiguration;
const VKONTAKTE_CONFIGURATION: ProviderConfiguration;
interface OAuth2Token {
token_type: 'bearer';
access_token: string;
refresh_token?: string;
expires_in: number;
}
interface OAuth2Namespace {
getAccessTokenFromAuthorizationCodeFlow(
request: fastify.FastifyRequest<http.IncomingMessage>,
): Promise<OAuth2Token>;
getAccessTokenFromAuthorizationCodeFlow(
request: fastify.FastifyRequest<http.IncomingMessage>,
callback: (token: OAuth2Token) => void,
): void;
getNewAccessTokenUsingRefreshToken(
refreshToken: string,
params: Object,
callback: (token: OAuth2Token) => void,
): void;
getNewAccessTokenUsingRefreshToken(refreshToken: string, params: Object): Promise<OAuth2Token>;
}
interface ProviderConfiguration {
authorizeHost: string;
authorizePath: string;
tokenHost: string;
tokenPath: string;
}
interface Credentials {
client: {
id: string;
secret: string;
};
auth: ProviderConfiguration;
}
interface FastifyOAuth2Options {
name: string;
scope: string[];
credentials: Credentials;
callbackUri: string;
callbackUriParams?: Object;
generateStateFunction?: Function;
checkStateFunction?: Function;
startRedirectPath: string;
}
}
export = fastifyOauth2;