-
Notifications
You must be signed in to change notification settings - Fork 45
/
index.d.ts
36 lines (32 loc) · 1.32 KB
/
index.d.ts
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
import { Context } from 'egg';
import * as OAuth2Server from 'oauth2-server';
import { AuthorizationCode, Token,
AuthorizationCodeModel, ClientCredentialsModel, RefreshTokenModel, PasswordModel, ExtensionModel,
AuthenticateOptions, AuthorizeOptions, ServerOptions, TokenOptions,
} from 'oauth2-server';
declare module 'egg' {
export interface Application {
oAuth2Server: OAuth2;
}
}
type Model = AuthorizationCodeModel | ClientCredentialsModel | RefreshTokenModel | PasswordModel | ExtensionModel;
type ExecuteOptions = AuthenticateOptions | AuthorizeOptions | TokenOptions;
declare class OAuth2 {
constructor(config: ServerOptions, model: Model);
private config: ServerOptions;
private model: Model;
private server: OAuth2Server;
/**
* Authenticates a request.
*/
public authenticate(options?: AuthenticateOptions): (ctx: Context, next: Function) => Promise<void>;
/**
* Authorizes a token request.
*/
public authorize(options?: AuthorizeOptions): (ctx: Context, next: Function) => Promise<void>;
/**
* Retrieves a new token for an authorized token request.
*/
public token(options?: TokenOptions): (ctx: Context, next: Function) => Promise<void>;
private execute(handle: 'authenticate' | 'authorize' | 'token', ctx: Context, options: ExecuteOptions): Promise<AuthorizationCode | Token>;
}