UNPKG

2.88 kBTypeScriptView Raw
1import { AsyncOptionalCreatable } from '@salesforce/kit';
2import { JsonMap } from '@salesforce/ts-types';
3import { AuthFields } from '.';
4/**
5 * Handles the removing of authorizations, which includes deleting the auth file
6 * in the global .sfdx folder, deleting any configs that are associated with the username/alias,
7 * and deleting any aliases associated with the username
8 *
9 * ```
10 * const remover = await AuthRemover.create();
11 * await remover.removeAuth('example@mycompany.com');
12 * ```
13 *
14 * ```
15 * const remover = await AuthRemover.create();
16 * await remover.removeAllAuths();
17 * ```
18 *
19 * ```
20 * const remover = await AuthRemover.create();
21 * const auth = await remover.findAuth(
22 * example@mycompany.com
23 * );
24 * await remover.removeAuth(auth.username);
25 * ```
26 */
27export declare class AuthRemover extends AsyncOptionalCreatable {
28 private config;
29 private stateAggregator;
30 private logger;
31 /**
32 * Removes the authentication and any configs or aliases associated with it
33 *
34 * @param usernameOrAlias the username or alias that you want to remove
35 */
36 removeAuth(usernameOrAlias: string): Promise<void>;
37 /**
38 * Removes all authentication files and any configs or aliases associated with them
39 */
40 removeAllAuths(): Promise<void>;
41 /**
42 * Finds authorization files for username/alias in the global .sfdx folder
43 * **Throws** *{@link SfError}{ name: 'TargetOrgNotSetError' }* if no target-org
44 * **Throws** *{@link SfError}{ name: 'NamedOrgNotFoundError' }* if specified user is not found
45 *
46 * @param usernameOrAlias username or alias of the auth you want to find, defaults to the configured target-org
47 * @returns {Promise<SfOrg>}
48 */
49 findAuth(usernameOrAlias?: string): Promise<AuthFields>;
50 /**
51 * Finds all org authorizations in the global info file (.sf/sf.json)
52 *
53 * @returns {Record<string, AuthFields>}
54 */
55 findAllAuths(): Record<string, AuthFields & JsonMap>;
56 protected init(): Promise<void>;
57 /**
58 * Returns the username for a given alias if the alias exists.
59 *
60 * @param usernameOrAlias username or alias
61 * @returns {Promise<string>}
62 */
63 private resolveUsername;
64 /**
65 * @returns {string}
66 */
67 private getTargetOrg;
68 /**
69 * Returns aliases for provided username
70 *
71 * @param username username that's been aliased
72 * @returns {Promise<string[]>}
73 */
74 private getAliases;
75 /**
76 * Unsets any configured values (both global and local) for provided username
77 *
78 * @param username username that you want to remove from config files
79 */
80 private unsetConfigValues;
81 /**
82 * Unsets any aliases for provided username
83 *
84 * @param username username that you want to remove from aliases
85 */
86 private unsetAliases;
87 private unsetTokens;
88}