1 | import { AsyncCreatable } from '@salesforce/kit';
|
2 | import { OAuth2Config } from '@jsforce/jsforce-node';
|
3 | import { JsonMap, Nullable } from '@salesforce/ts-types';
|
4 | import { AuthInfo } from './org/authInfo';
|
5 | export type DeviceCodeResponse = {
|
6 | device_code: string;
|
7 | interval: number;
|
8 | user_code: string;
|
9 | verification_uri: string;
|
10 | } & JsonMap;
|
11 | export type DeviceCodePollingResponse = {
|
12 | access_token: string;
|
13 | refresh_token: string;
|
14 | signature: string;
|
15 | scope: string;
|
16 | instance_url: string;
|
17 | id: string;
|
18 | token_type: string;
|
19 | issued_at: string;
|
20 | } & JsonMap;
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 | export declare class DeviceOauthService extends AsyncCreatable<OAuth2Config> {
|
38 | static RESPONSE_TYPE: string;
|
39 | static GRANT_TYPE: string;
|
40 | static SCOPE: string;
|
41 | private static POLLING_COUNT_MAX;
|
42 | private logger;
|
43 | private options;
|
44 | private pollingCount;
|
45 | constructor(options: OAuth2Config);
|
46 | /**
|
47 | * Begin the authorization flow by requesting the login
|
48 | *
|
49 | * @returns {Promise<DeviceCodeResponse>}
|
50 | */
|
51 | requestDeviceLogin(): Promise<DeviceCodeResponse>;
|
52 | |
53 |
|
54 |
|
55 |
|
56 |
|
57 | awaitDeviceApproval(loginData: DeviceCodeResponse): Promise<Nullable<DeviceCodePollingResponse>>;
|
58 | |
59 |
|
60 |
|
61 |
|
62 |
|
63 | authorizeAndSave(approval: DeviceCodePollingResponse): Promise<AuthInfo>;
|
64 | protected init(): Promise<void>;
|
65 | private getLoginOptions;
|
66 | private getPollingOptions;
|
67 | private getDeviceFlowRequestUrl;
|
68 | private poll;
|
69 | private shouldContinuePolling;
|
70 | private pollForDeviceApproval;
|
71 | }
|