UNPKG

@salesforce/core

Version:

Core libraries to interact with SFDX projects, orgs, and APIs.

117 lines (116 loc) 3.8 kB
import { AsyncOptionalCreatable } from '@salesforce/kit'; import { AuthInfoConfig } from './config/authInfoConfig'; export declare type AuthConfigs = Map<string, AuthInfoConfig>; /** * Handles the removing of authorizations, which includes deleting the auth file * in the global .sfdx folder, deleting any configs that are associated with the username/alias, * and deleting any aliases associated with the username * * ``` * const remover = await AuthRemover.create(); * await remover.removeAuth('example@mycompany.com'); * ``` * * ``` * const remover = await AuthRemover.create(); * await remover.removeAllAuths(); * ``` * * ``` * const remover = await AuthRemover.create(); * const authConfigs = await remover.findAuthConfigs( * example@mycompany.com * ); * const usernames = [...authConfigs.keys()]; * for (const username of usernames) { * await remover.removeAuth(username); * } * ``` */ export declare class AuthRemover extends AsyncOptionalCreatable { authConfigs: AuthConfigs; private globalConfig; private localConfig; private logger; private aliases; /** * Removes the authentication and any configs or aliases associated with it * * @param usernameOrAlias the username or alias that you want to remove */ removeAuth(usernameOrAlias: string): Promise<void>; /** * Removes all authentication files and any configs or aliases associated with them */ removeAllAuths(): Promise<void>; /** * Finds authorization files for username/alias in the global .sfdx folder * **Throws** *{@link SfdxError}{ name: 'NoOrgFound' }* if no username, alias, or defaultusername * * @param usernameOrAlias username or alias of the auth you want to find, defaults to the configured defaultusername * @returns {Promise<AuthConfigs>} */ findAuthConfigs(usernameOrAlias?: string): Promise<AuthConfigs>; /** * Finds all authorization files in the global .sfdx folder * * @returns {Promise<AuthConfigs>} */ findAllAuthConfigs(): Promise<AuthConfigs>; protected init(): Promise<void>; /** * Returns the username for a given alias if the alias exists. * * @param usernameOrAlias username or alias * @returns {Promise<string>} */ private resolveUsername; /** * Instantiates config class * * @param isGlobal * @returns {Promise<Nullable<Config>>} */ private getConfig; /** * Filters the provided authorization file names for ones that belong to the * the configured defaultusername * **Throws** *{@link SfdxError}{ name: 'NoOrgFound' }* if no defaultusername is not configured * * @param authFiles array of authorization file names * @returns {Promise<string[]>} */ private filterAuthFilesForDefaultUsername; /** * Instantiates the AuthInfoConfig class for each auth file * * @param filenames array of authorizaiton file names * @returns {Promise<AuthConfigs>} */ private initAuthInfoConfigs; /** * Returns aliases for provided username * * @param username username that's been aliased * @returns {Promise<string[]>} */ private getAliases; /** * Unsets any configured values (both global and local) for provided username * * @param username username that you want to remove from config files */ private unsetConfigValues; /** * Unsets any aliases for provided username * * @param username username that you want to remove from aliases */ private unsetAliases; /** * Deletes the authtorizaton file for provided username * * @param username username that you want to delete */ private unlinkConfigFile; }