import { AsyncCreatable } from '@salesforce/kit'; import { OAuth2Config } from 'jsforce'; import { JsonMap, Nullable } from '@salesforce/ts-types'; import { AuthInfo } from './org'; export interface DeviceCodeResponse extends JsonMap { device_code: string; interval: number; user_code: string; verification_uri: string; } export interface DeviceCodePollingResponse extends JsonMap { access_token: string; refresh_token: string; signature: string; scope: string; instance_url: string; id: string; token_type: string; issued_at: string; } /** * Handles device based login flows * * Usage: * ``` * const oauthConfig = { * loginUrl: this.flags.instanceurl, * clientId: this.flags.clientid, * }; * const deviceOauthService = await DeviceOauthService.create(oauthConfig); * const loginData = await deviceOauthService.requestDeviceLogin(); * console.log(loginData); * const approval = await deviceOauthService.awaitDeviceApproval(loginData); * const authInfo = await deviceOauthService.authorizeAndSave(approval); * ``` */ export declare class DeviceOauthService extends AsyncCreatable { static RESPONSE_TYPE: string; static GRANT_TYPE: string; static SCOPE: string; private static POLLING_COUNT_MAX; private logger; private options; private pollingCount; constructor(options: OAuth2Config); /** * Begin the authorization flow by requesting the login * * @returns {Promise} */ requestDeviceLogin(): Promise; /** * Polls the server until successful response OR max attempts have been made * * @returns {Promise>} */ awaitDeviceApproval(loginData: DeviceCodeResponse): Promise>; /** * Creates and saves new AuthInfo * * @returns {Promise} */ authorizeAndSave(approval: DeviceCodePollingResponse): Promise; protected init(): Promise; private getLoginOptions; private getPollingOptions; private getDeviceFlowRequestUrl; private poll; private shouldContinuePolling; private pollForDeviceApproval; }