@salesforce/core
Version:
Core libraries to interact with SFDX projects, orgs, and APIs.
88 lines (87 loc) • 2.86 kB
TypeScript
import { AsyncOptionalCreatable } from '@salesforce/kit';
import { JsonMap } from '@salesforce/ts-types';
import { AuthFields } from './authInfo';
/**
* 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 auth = await remover.findAuth(
* example@mycompany.com
* );
* await remover.removeAuth(auth.username);
* ```
*/
export declare class AuthRemover extends AsyncOptionalCreatable {
private config;
private stateAggregator;
private logger;
/**
* 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 SfError}{ name: 'TargetOrgNotSetError' }* if no target-org
* **Throws** *{@link SfError}{ name: 'NamedOrgNotFoundError' }* if specified user is not found
*
* @param usernameOrAlias username or alias of the auth you want to find, defaults to the configured target-org
* @returns {Promise<SfOrg>}
*/
findAuth(usernameOrAlias?: string): Promise<AuthFields>;
/**
* Finds all org authorizations in the global info file (.sf/sf.json)
*
* @returns {Record<string, AuthFields>}
*/
findAllAuths(): Record<string, AuthFields & JsonMap>;
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;
/**
* @returns {string}
*/
private getTargetOrg;
/**
* 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;
}