eas-cli
Version:
EAS command line tool
76 lines (75 loc) • 3.11 kB
TypeScript
import { AnalyticsWithOrchestration } from '../analytics/AnalyticsManager';
import { CurrentUserQuery } from '../graphql/generated';
export declare enum UserSecondFactorDeviceMethod {
AUTHENTICATOR = "authenticator",
SMS = "sms"
}
export type LoggedInAuthenticationInfo = {
accessToken: string;
sessionSecret: null;
} | {
accessToken: null;
sessionSecret: string;
};
type Actor = NonNullable<CurrentUserQuery['meActor']>;
export default class SessionManager {
private readonly analytics;
private currentActor;
constructor(analytics: AnalyticsWithOrchestration);
getAccessToken(): string | null;
getSessionSecret(): string | null;
private getSession;
private setSessionAsync;
logoutAsync(): Promise<void>;
getUserAsync(): Promise<Actor | undefined>;
/**
* Ensure that there is a logged-in actor. Show a login prompt if not.
*
* @param nonInteractive whether the log-in prompt if logged-out should be interactive
* @returns logged-in Actor
*/
ensureLoggedInAsync({ nonInteractive, }: {
nonInteractive: boolean;
}): Promise<{
actor: Actor;
authenticationInfo: LoggedInAuthenticationInfo;
}>;
/**
* Prompt the user to log in.
*
* @deprecated Should not be used outside of context functions, except in the AccountLogin command.
*/
showLoginPromptAsync({ nonInteractive, printNewLine, sso, }?: {
nonInteractive?: boolean | undefined;
printNewLine?: boolean | undefined;
sso?: boolean | undefined;
}): Promise<void>;
private ssoLoginAsync;
private loginAsync;
/**
* Prompt for an OTP with the option to cancel the question by answering empty (pressing return key).
*/
private promptForOTPAsync;
/**
* Prompt for user to choose a backup OTP method. If selected method is SMS, a request
* for a new OTP will be sent to that method. Then, prompt for the OTP, and retry the user login.
*/
private promptForBackupOTPAsync;
/**
* Handle the special case error indicating that a second-factor is required for
* authentication.
*
* There are three cases we need to handle:
* 1. User's primary second-factor device was SMS, OTP was automatically sent by the server to that
* device already. In this case we should just prompt for the SMS OTP (or backup code), which the
* user should be receiving shortly. We should give the user a way to cancel and the prompt and move
* to case 3 below.
* 2. User's primary second-factor device is authenticator. In this case we should prompt for authenticator
* OTP (or backup code) and also give the user a way to cancel and move to case 3 below.
* 3. User doesn't have a primary device or doesn't have access to their primary device. In this case
* we should show a picker of the SMS devices that they can have an OTP code sent to, and when
* the user picks one we show a prompt() for the sent OTP.
*/
private retryUsernamePasswordAuthWithOTPAsync;
}
export {};