UNPKG

1.52 kBTypeScriptView Raw
1export interface OAuth2Options {
2 authzServiceUrl?: string | undefined;
3 tokenServiceUrl?: string | undefined;
4 clientId?: string | undefined;
5 clientSecret?: string | undefined;
6 httpProxy?: string | undefined;
7 loginUrl?: string | undefined;
8 proxyUrl?: string | undefined;
9 redirectUri?: string | undefined;
10 refreshToken?: string | undefined;
11 revokeServiceUrl?: string | undefined;
12 authCode?: string | undefined;
13 privateKeyFile?: string | undefined;
14 privateKey?: string | undefined; // 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 | undefined,
35 state?: string | undefined
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}