1 | import { AsyncOptionalCreatable } from '@salesforce/kit';
|
2 | import { AuthInfoConfig } from './config/authInfoConfig';
|
3 | export declare type AuthConfigs = Map<string, AuthInfoConfig>;
|
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 authConfigs = await remover.findAuthConfigs(
|
22 | * example@mycompany.com
|
23 | * );
|
24 | * const usernames = [...authConfigs.keys()];
|
25 | * for (const username of usernames) {
|
26 | * await remover.removeAuth(username);
|
27 | * }
|
28 | * ```
|
29 | */
|
30 | export declare class AuthRemover extends AsyncOptionalCreatable {
|
31 | authConfigs: AuthConfigs;
|
32 | private globalConfig;
|
33 | private localConfig;
|
34 | private logger;
|
35 | private aliases;
|
36 | /**
|
37 | * Removes the authentication and any configs or aliases associated with it
|
38 | *
|
39 | * @param usernameOrAlias the username or alias that you want to remove
|
40 | */
|
41 | removeAuth(usernameOrAlias: string): Promise<void>;
|
42 | /**
|
43 | * Removes all authentication files and any configs or aliases associated with them
|
44 | */
|
45 | removeAllAuths(): Promise<void>;
|
46 | /**
|
47 | * Finds authorization files for username/alias in the global .sfdx folder
|
48 | * **Throws** *{@link SfdxError}{ name: 'NoOrgFound' }* if no username, alias, or defaultusername
|
49 | *
|
50 | * @param usernameOrAlias username or alias of the auth you want to find, defaults to the configured defaultusername
|
51 | * @returns {Promise<AuthConfigs>}
|
52 | */
|
53 | findAuthConfigs(usernameOrAlias?: string): Promise<AuthConfigs>;
|
54 | /**
|
55 | * Finds all authorization files in the global .sfdx folder
|
56 | *
|
57 | * @returns {Promise<AuthConfigs>}
|
58 | */
|
59 | findAllAuthConfigs(): Promise<AuthConfigs>;
|
60 | protected init(): Promise<void>;
|
61 | /**
|
62 | * Returns the username for a given alias if the alias exists.
|
63 | *
|
64 | * @param usernameOrAlias username or alias
|
65 | * @returns {Promise<string>}
|
66 | */
|
67 | private resolveUsername;
|
68 | /**
|
69 | * Instantiates config class
|
70 | *
|
71 | * @param isGlobal
|
72 | * @returns {Promise<Nullable<Config>>}
|
73 | */
|
74 | private getConfig;
|
75 | /**
|
76 | * Filters the provided authorization file names for ones that belong to the
|
77 | * the configured defaultusername
|
78 | * **Throws** *{@link SfdxError}{ name: 'NoOrgFound' }* if no defaultusername is not configured
|
79 | *
|
80 | * @param authFiles array of authorization file names
|
81 | * @returns {Promise<string[]>}
|
82 | */
|
83 | private filterAuthFilesForDefaultUsername;
|
84 | /**
|
85 | * Instantiates the AuthInfoConfig class for each auth file
|
86 | *
|
87 | * @param filenames array of authorizaiton file names
|
88 | * @returns {Promise<AuthConfigs>}
|
89 | */
|
90 | private initAuthInfoConfigs;
|
91 | /**
|
92 | * Returns aliases for provided username
|
93 | *
|
94 | * @param username username that's been aliased
|
95 | * @returns {Promise<string[]>}
|
96 | */
|
97 | private getAliases;
|
98 | /**
|
99 | * Unsets any configured values (both global and local) for provided username
|
100 | *
|
101 | * @param username username that you want to remove from config files
|
102 | */
|
103 | private unsetConfigValues;
|
104 | /**
|
105 | * Unsets any aliases for provided username
|
106 | *
|
107 | * @param username username that you want to remove from aliases
|
108 | */
|
109 | private unsetAliases;
|
110 | /**
|
111 | * Deletes the authtorizaton file for provided username
|
112 | *
|
113 | * @param username username that you want to delete
|
114 | */
|
115 | private unlinkConfigFile;
|
116 | }
|