UNPKG

1.34 kBTypeScriptView Raw
1export interface OAuth2Options {
2 authzServiceUrl?: string;
3 tokenServiceUrl?: string;
4 clientId?: string;
5 clientSecret?: string;
6 httpProxy?: string;
7 loginUrl?: string;
8 proxyUrl?: string;
9 redirectUri?: string;
10 refreshToken?: string;
11 revokeServiceUrl?: string;
12 authCode?: string;
13 privateKeyFile?: string;
14 privateKey?: string; // Used for sfdx auth files for legacy support reasons
15}
16
17export interface TokenResponse {
18 access_token: string;
19 refresh_token: string;
20}
21
22export class OAuth2 {
23 constructor(options?: OAuth2Options);
24
25 loginUrl: string;
26 authzServiceUrl: string;
27 tokenServiceUrl: string;
28 revokeServiceUrl: string;
29 clientId: string;
30 clientSecret: string;
31 redirectUri: string;
32
33 getAuthorizationUrl(params: {
34 scope?: string,
35 state?: string
36 }): string;
37 refreshToken(code: string, callback?: (err: Error, tokenResponse: TokenResponse) => void): Promise<TokenResponse>;
38 requestToken(code: string, callback?: (err: Error, tokenResponse: TokenResponse) => void): Promise<TokenResponse>;
39 authenticate(username: string, password: string, callback?: (err: Error, tokenResponse: TokenResponse) => void): Promise<TokenResponse>;
40 revokeToken(accessToken: string, callback?: (err: Error, ) => void): Promise<undefined>;
41}