@salesforce/plugin-auth 3.1.2 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -14
- package/lib/commands/org/list/auth.js +2 -4
- package/lib/commands/org/list/auth.js.map +1 -1
- package/lib/commands/org/login/access-token.d.ts +9 -10
- package/lib/commands/org/login/access-token.js +8 -5
- package/lib/commands/org/login/access-token.js.map +1 -1
- package/lib/commands/org/login/device.d.ts +3 -4
- package/lib/commands/org/login/device.js +5 -12
- package/lib/commands/org/login/device.js.map +1 -1
- package/lib/commands/org/login/jwt.d.ts +3 -3
- package/lib/commands/org/login/jwt.js +6 -6
- package/lib/commands/org/login/jwt.js.map +1 -1
- package/lib/commands/org/login/sfdx-url.d.ts +5 -4
- package/lib/commands/org/login/sfdx-url.js +28 -10
- package/lib/commands/org/login/sfdx-url.js.map +1 -1
- package/lib/commands/org/login/web.d.ts +10 -13
- package/lib/commands/org/login/web.js +17 -27
- package/lib/commands/org/login/web.js.map +1 -1
- package/lib/commands/org/logout.d.ts +9 -12
- package/lib/commands/org/logout.js +71 -116
- package/lib/commands/org/logout.js.map +1 -1
- package/lib/common.d.ts +5 -3
- package/lib/common.js +30 -23
- package/lib/common.js.map +1 -1
- package/messages/messages.md +0 -4
- package/messages/sfdxurl.store.md +11 -1
- package/oclif.lock +208 -144
- package/oclif.manifest.json +25 -28
- package/package.json +11 -9
- package/lib/authBaseCommand.d.ts +0 -9
- package/lib/authBaseCommand.js +0 -46
- package/lib/authBaseCommand.js.map +0 -1
|
@@ -5,27 +5,26 @@
|
|
|
5
5
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
6
|
*/
|
|
7
7
|
import open, { apps } from 'open';
|
|
8
|
-
import { Flags, loglevel } from '@salesforce/sf-plugins-core';
|
|
8
|
+
import { Flags, SfCommand, loglevel } from '@salesforce/sf-plugins-core';
|
|
9
9
|
import { AuthInfo, Logger, Messages, SfError, WebOAuthServer } from '@salesforce/core';
|
|
10
10
|
import { Env } from '@salesforce/kit';
|
|
11
|
-
import
|
|
12
|
-
import { Common } from '../../../common.js';
|
|
11
|
+
import common from '../../../common.js';
|
|
13
12
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
14
13
|
const messages = Messages.loadMessages('@salesforce/plugin-auth', 'web.login');
|
|
15
14
|
const commonMessages = Messages.loadMessages('@salesforce/plugin-auth', 'messages');
|
|
16
|
-
export default class LoginWeb extends
|
|
15
|
+
export default class LoginWeb extends SfCommand {
|
|
17
16
|
static summary = messages.getMessage('summary');
|
|
18
17
|
static description = messages.getMessage('description');
|
|
19
18
|
static examples = messages.getMessages('examples');
|
|
20
19
|
static deprecateAliases = true;
|
|
21
20
|
static aliases = ['force:auth:web:login', 'auth:web:login'];
|
|
22
21
|
static flags = {
|
|
23
|
-
browser: Flags.
|
|
22
|
+
browser: Flags.option({
|
|
24
23
|
char: 'b',
|
|
25
24
|
summary: messages.getMessage('flags.browser.summary'),
|
|
26
25
|
description: messages.getMessage('flags.browser.description'),
|
|
27
26
|
options: ['chrome', 'edge', 'firefox'], // These are ones supported by "open" package
|
|
28
|
-
}),
|
|
27
|
+
})(),
|
|
29
28
|
'client-id': Flags.string({
|
|
30
29
|
char: 'i',
|
|
31
30
|
summary: commonMessages.getMessage('flags.client-id.summary'),
|
|
@@ -57,12 +56,6 @@ export default class LoginWeb extends AuthBaseCommand {
|
|
|
57
56
|
deprecateAliases: true,
|
|
58
57
|
aliases: ['setalias'],
|
|
59
58
|
}),
|
|
60
|
-
'disable-masking': Flags.boolean({
|
|
61
|
-
summary: commonMessages.getMessage('flags.disable-masking.summary'),
|
|
62
|
-
hidden: true,
|
|
63
|
-
deprecateAliases: true,
|
|
64
|
-
aliases: ['disablemasking'],
|
|
65
|
-
}),
|
|
66
59
|
'no-prompt': Flags.boolean({
|
|
67
60
|
char: 'p',
|
|
68
61
|
summary: commonMessages.getMessage('flags.no-prompt.summary'),
|
|
@@ -73,24 +66,22 @@ export default class LoginWeb extends AuthBaseCommand {
|
|
|
73
66
|
}),
|
|
74
67
|
loglevel,
|
|
75
68
|
};
|
|
76
|
-
flags;
|
|
77
69
|
async run() {
|
|
78
70
|
const { flags } = await this.parse(LoginWeb);
|
|
79
|
-
this.flags = flags;
|
|
80
71
|
if (isSFDXContainerMode()) {
|
|
81
72
|
throw new SfError(messages.getMessage('deviceWarning'), 'DEVICE_WARNING');
|
|
82
73
|
}
|
|
83
|
-
if (await
|
|
74
|
+
if (await common.shouldExitCommand(flags['no-prompt']))
|
|
84
75
|
return {};
|
|
85
76
|
const oauthConfig = {
|
|
86
|
-
loginUrl: await
|
|
77
|
+
loginUrl: await common.resolveLoginUrl(flags['instance-url']?.href),
|
|
87
78
|
clientId: flags['client-id'],
|
|
79
|
+
...(flags['client-id']
|
|
80
|
+
? { clientSecret: await this.secretPrompt({ message: commonMessages.getMessage('clientSecretStdin') }) }
|
|
81
|
+
: {}),
|
|
88
82
|
};
|
|
89
|
-
if (flags['client-id']) {
|
|
90
|
-
oauthConfig.clientSecret = await this.askForClientSecret(flags['disable-masking']);
|
|
91
|
-
}
|
|
92
83
|
try {
|
|
93
|
-
const authInfo = await this.executeLoginFlow(oauthConfig);
|
|
84
|
+
const authInfo = await this.executeLoginFlow(oauthConfig, flags.browser);
|
|
94
85
|
await authInfo.handleAliasAndDefaultSettings({
|
|
95
86
|
alias: flags.alias,
|
|
96
87
|
setDefault: flags['set-default'],
|
|
@@ -103,20 +94,19 @@ export default class LoginWeb extends AuthBaseCommand {
|
|
|
103
94
|
return fields;
|
|
104
95
|
}
|
|
105
96
|
catch (err) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
throw new SfError(messages.getMessage('invalidClientId', [error.message]), undefined, undefined, error);
|
|
97
|
+
Logger.childFromRoot('LoginWebCommand').debug(err);
|
|
98
|
+
if (err instanceof Error && err.name === 'AuthCodeExchangeError') {
|
|
99
|
+
throw new SfError(messages.getMessage('invalidClientId', [err.message]), undefined, undefined, err);
|
|
110
100
|
}
|
|
111
|
-
throw
|
|
101
|
+
throw err;
|
|
112
102
|
}
|
|
113
103
|
}
|
|
114
104
|
// leave it because it's stubbed in the test
|
|
115
105
|
// eslint-disable-next-line class-methods-use-this
|
|
116
|
-
async executeLoginFlow(oauthConfig) {
|
|
106
|
+
async executeLoginFlow(oauthConfig, browser) {
|
|
117
107
|
const oauthServer = await WebOAuthServer.create({ oauthConfig });
|
|
118
108
|
await oauthServer.start();
|
|
119
|
-
const app =
|
|
109
|
+
const app = browser && browser in apps ? browser : undefined;
|
|
120
110
|
const openOptions = app ? { app: { name: apps[app] }, wait: false } : { wait: false };
|
|
121
111
|
await open(oauthServer.getAuthorizationUrl(), openOptions);
|
|
122
112
|
return oauthServer.authorizeAndSave();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../../../src/commands/org/login/web.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,IAAI,EAAE,EAAE,IAAI,EAAW,MAAM,MAAM,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../../../src/commands/org/login/web.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,IAAI,EAAE,EAAE,IAAI,EAAW,MAAM,MAAM,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAc,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAgB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjH,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,MAAM,MAAM,oBAAoB,CAAC;AAExC,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IA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Command } from '../../authBaseCommand.js';
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
3
2
|
export type AuthLogoutResults = string[];
|
|
4
|
-
export default class Logout extends
|
|
3
|
+
export default class Logout extends SfCommand<AuthLogoutResults> {
|
|
5
4
|
static readonly summary: string;
|
|
6
5
|
static readonly description: string;
|
|
7
6
|
static readonly examples: string[];
|
|
8
7
|
static readonly deprecateAliases = true;
|
|
9
|
-
static aliases: string[];
|
|
8
|
+
static readonly aliases: string[];
|
|
10
9
|
static readonly flags: {
|
|
11
|
-
'target-org':
|
|
12
|
-
all:
|
|
13
|
-
'no-prompt':
|
|
14
|
-
loglevel:
|
|
10
|
+
'target-org': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
11
|
+
all: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
12
|
+
'no-prompt': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
13
|
+
loglevel: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
15
14
|
};
|
|
16
|
-
private flags;
|
|
17
|
-
private static buildChoices;
|
|
18
15
|
run(): Promise<AuthLogoutResults>;
|
|
19
|
-
|
|
20
|
-
private
|
|
16
|
+
/** Warning about logging out of a scratch org and losing access to it */
|
|
17
|
+
private maybeWarnScratchOrgs;
|
|
21
18
|
}
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import os from 'node:os';
|
|
8
8
|
import { AuthInfo, AuthRemover, ConfigAggregator, Global, Messages, Mode, OrgConfigProperties, } from '@salesforce/core';
|
|
9
|
-
import
|
|
9
|
+
import checkbox, { Separator } from '@inquirer/checkbox';
|
|
10
|
+
import { Flags, loglevel, SfCommand } from '@salesforce/sf-plugins-core';
|
|
10
11
|
import chalk from 'chalk';
|
|
11
|
-
import { AuthBaseCommand } from '../../authBaseCommand.js';
|
|
12
12
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
13
13
|
const messages = Messages.loadMessages('@salesforce/plugin-auth', 'logout');
|
|
14
14
|
const commonMessages = Messages.loadMessages('@salesforce/plugin-auth', 'messages');
|
|
15
|
-
export default class Logout extends
|
|
15
|
+
export default class Logout extends SfCommand {
|
|
16
16
|
static summary = messages.getMessage('summary');
|
|
17
17
|
static description = messages.getMessage('description');
|
|
18
18
|
static examples = messages.getMessages('examples');
|
|
@@ -42,46 +42,10 @@ export default class Logout extends AuthBaseCommand {
|
|
|
42
42
|
}),
|
|
43
43
|
loglevel,
|
|
44
44
|
};
|
|
45
|
-
flags;
|
|
46
|
-
static buildChoices(orgAuths, all) {
|
|
47
|
-
const maxUsernameLength = Math.max('Username'.length, ...orgAuths.map((orgAuth) => orgAuth.username.length));
|
|
48
|
-
const maxAliasLength = Math.max('Aliases'.length, ...orgAuths.map((orgAuth) => (orgAuth.aliases ? orgAuth.aliases.join(',') : '').length));
|
|
49
|
-
const maxConfigLength = Math.max('Configs'.length, ...orgAuths.map((orgAuth) => (orgAuth.configs ? orgAuth.configs.join(',') : '').length));
|
|
50
|
-
const maxTypeLength = Math.max('Type'.length, ...orgAuths.map((orgAuth) => {
|
|
51
|
-
if (orgAuth.isScratchOrg) {
|
|
52
|
-
return 'Scratch'.length;
|
|
53
|
-
}
|
|
54
|
-
if (orgAuth.isDevHub) {
|
|
55
|
-
return 'DevHub'.length;
|
|
56
|
-
}
|
|
57
|
-
if (orgAuth.isSandbox) {
|
|
58
|
-
return 'Sandbox'.length;
|
|
59
|
-
}
|
|
60
|
-
return 0;
|
|
61
|
-
}));
|
|
62
|
-
const choices = orgAuths
|
|
63
|
-
.map((orgAuth) => {
|
|
64
|
-
const aliasString = (orgAuth.aliases ? orgAuth.aliases.join(',') : '').padEnd(maxAliasLength, ' ');
|
|
65
|
-
const configString = (orgAuth.configs ? orgAuth.configs.join(',') : '').padEnd(maxConfigLength, ' ');
|
|
66
|
-
const typeString = chalk.dim((orgAuth.isScratchOrg ? 'Scratch' : orgAuth.isDevHub ? 'DevHub' : orgAuth.isSandbox ? 'Sandbox' : '').padEnd(maxTypeLength, ' '));
|
|
67
|
-
// username - aliases - configs
|
|
68
|
-
const key = `${chalk.bold(orgAuth.username.padEnd(maxUsernameLength))} | ${typeString} | ${aliasString} | ${chalk.yellowBright(configString)}`;
|
|
69
|
-
return { name: key, value: orgAuth, checked: all, short: `${os.EOL}${orgAuth.username}` };
|
|
70
|
-
})
|
|
71
|
-
.sort((a, b) => a.value.username.localeCompare(b.value.username));
|
|
72
|
-
const userHeader = `${'Username'.padEnd(maxUsernameLength, ' ')}`;
|
|
73
|
-
const aliasHeader = `${'Aliases'.padEnd(maxAliasLength, ' ')}`;
|
|
74
|
-
const configHeader = `${'Configs'.padEnd(maxConfigLength, ' ')}`;
|
|
75
|
-
const typeHeader = `${'Type'.padEnd(maxTypeLength, ' ')}`;
|
|
76
|
-
return [new Separator(` ${userHeader} | ${typeHeader} | ${aliasHeader} | ${configHeader}`), ...choices];
|
|
77
|
-
}
|
|
78
45
|
async run() {
|
|
79
46
|
const { flags } = await this.parse(Logout);
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const remover = await AuthRemover.create();
|
|
83
|
-
let orgAuths = [];
|
|
84
|
-
const targetUsername = this.flags['target-org'] ?? this.configAggregator.getInfo(OrgConfigProperties.TARGET_ORG).value;
|
|
47
|
+
const targetUsername = flags['target-org'] ??
|
|
48
|
+
(await ConfigAggregator.create()).getInfo(OrgConfigProperties.TARGET_ORG).value;
|
|
85
49
|
// if no-prompt, there must be a resolved target-org or --all
|
|
86
50
|
if (flags['no-prompt'] && !targetUsername && !flags.all) {
|
|
87
51
|
throw messages.createError('noOrgSpecifiedWithNoPrompt');
|
|
@@ -89,33 +53,29 @@ export default class Logout extends AuthBaseCommand {
|
|
|
89
53
|
if (this.jsonEnabled() && !targetUsername && !flags.all) {
|
|
90
54
|
throw messages.createError('noOrgSpecifiedWithJson');
|
|
91
55
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
orgAuths = [];
|
|
101
|
-
}
|
|
56
|
+
const shouldFindAllAuths = targetUsername && !flags.all
|
|
57
|
+
? false
|
|
58
|
+
: flags.all || Global.getEnvironmentMode() === Mode.DEMO || !flags['no-prompt'];
|
|
59
|
+
const orgAuths = shouldFindAllAuths
|
|
60
|
+
? await AuthInfo.listAllAuthorizations()
|
|
61
|
+
: targetUsername
|
|
62
|
+
? (await AuthInfo.listAllAuthorizations()).filter((orgAuth) => orgAuth.username === targetUsername || !!orgAuth.aliases?.includes(targetUsername))
|
|
63
|
+
: [];
|
|
102
64
|
if (orgAuths.length === 0) {
|
|
103
|
-
if (
|
|
65
|
+
if (flags['target-org']) {
|
|
104
66
|
// user specified a target org but it was not resolved, issue success message and return
|
|
105
|
-
this.logSuccess(messages.getMessage('logoutOrgCommandSuccess', [
|
|
106
|
-
return [
|
|
67
|
+
this.logSuccess(messages.getMessage('logoutOrgCommandSuccess', [flags['target-org']]));
|
|
68
|
+
return [flags['target-org']];
|
|
107
69
|
}
|
|
108
70
|
this.info(messages.getMessage('noOrgsFound'));
|
|
109
71
|
return [];
|
|
110
72
|
}
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
const loggedOutUsernames = orgs.map((org) => org.username);
|
|
73
|
+
const skipPrompt = flags['no-prompt'] || this.jsonEnabled();
|
|
74
|
+
const selectedOrgs = this.maybeWarnScratchOrgs(skipPrompt ? orgAuths : await promptForOrgsToRemove(orgAuths, flags.all));
|
|
75
|
+
if (skipPrompt || (await this.confirm({ message: getOrgConfirmationMessage(selectedOrgs, orgAuths.length) }))) {
|
|
76
|
+
const remover = await AuthRemover.create();
|
|
77
|
+
const loggedOutUsernames = selectedOrgs.map((org) => org.username);
|
|
78
|
+
await Promise.all(loggedOutUsernames.map((username) => remover.removeAuth(username)));
|
|
119
79
|
this.logSuccess(messages.getMessage('logoutOrgCommandSuccess', [loggedOutUsernames.join(os.EOL)]));
|
|
120
80
|
return loggedOutUsernames;
|
|
121
81
|
}
|
|
@@ -124,62 +84,57 @@ export default class Logout extends AuthBaseCommand {
|
|
|
124
84
|
return [];
|
|
125
85
|
}
|
|
126
86
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
87
|
+
/** Warning about logging out of a scratch org and losing access to it */
|
|
88
|
+
maybeWarnScratchOrgs(orgs) {
|
|
89
|
+
if (orgs.some((org) => org.isScratchOrg)) {
|
|
90
|
+
this.warn(messages.getMessage('warning'));
|
|
130
91
|
}
|
|
131
|
-
return
|
|
92
|
+
return orgs;
|
|
132
93
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
94
|
+
}
|
|
95
|
+
const promptForOrgsToRemove = async (orgAuths, all) => orgAuths.length === 1
|
|
96
|
+
? orgAuths
|
|
97
|
+
: checkbox({
|
|
98
|
+
message: messages.getMessage('prompt.select-envs'),
|
|
99
|
+
// pick the orgs to delete - if flags.all - set each org to selected
|
|
100
|
+
// otherwise prompt the user to select the orgs to delete
|
|
101
|
+
choices: buildChoices(orgAuths, all),
|
|
102
|
+
loop: true,
|
|
103
|
+
});
|
|
104
|
+
const getOrgConfirmationMessage = (selectedOrgs, originalOrgCount) => selectedOrgs.length === originalOrgCount
|
|
105
|
+
? messages.getMessage('prompt.confirm-all')
|
|
106
|
+
: messages.getMessage('prompt.confirm', [selectedOrgs.length, selectedOrgs.length > 1 ? 's' : '']);
|
|
107
|
+
/** A whole bunch of custom formatting to make the list look nicer */
|
|
108
|
+
const buildChoices = (orgAuths, all) => {
|
|
109
|
+
const maxUsernameLength = Math.max('Username'.length, ...orgAuths.map((orgAuth) => orgAuth.username.length));
|
|
110
|
+
const maxAliasLength = Math.max('Aliases'.length, ...orgAuths.map((orgAuth) => (orgAuth.aliases ? orgAuth.aliases.join(',') : '').length));
|
|
111
|
+
const maxConfigLength = Math.max('Configs'.length, ...orgAuths.map((orgAuth) => (orgAuth.configs ? orgAuth.configs.join(',') : '').length));
|
|
112
|
+
const maxTypeLength = Math.max('Type'.length, ...orgAuths.map((orgAuth) => {
|
|
113
|
+
if (orgAuth.isScratchOrg) {
|
|
114
|
+
return 'Scratch'.length;
|
|
136
115
|
}
|
|
137
|
-
if (
|
|
138
|
-
|
|
139
|
-
this.warn(messages.getMessage('warning'));
|
|
140
|
-
}
|
|
141
|
-
if (await this.confirm(messages.getMessage('prompt.confirm.single', [orgAuths[0].username]), 30000, false)) {
|
|
142
|
-
return { orgs: orgAuths, confirmed: true };
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
return { orgs: [], confirmed: false };
|
|
146
|
-
}
|
|
116
|
+
if (orgAuth.isDevHub) {
|
|
117
|
+
return 'DevHub'.length;
|
|
147
118
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return messages.getMessage('prompt.confirm-all');
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
return messages.getMessage('prompt.confirm', [names.length, names.length > 1 ? 's' : '']);
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
type: 'confirm',
|
|
176
|
-
default: false,
|
|
177
|
-
},
|
|
178
|
-
], 30000);
|
|
179
|
-
return {
|
|
180
|
-
orgs: orgs.map((a) => a),
|
|
181
|
-
confirmed,
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
}
|
|
119
|
+
if (orgAuth.isSandbox) {
|
|
120
|
+
return 'Sandbox'.length;
|
|
121
|
+
}
|
|
122
|
+
return 0;
|
|
123
|
+
}));
|
|
124
|
+
const choices = orgAuths
|
|
125
|
+
.map((orgAuth) => {
|
|
126
|
+
const aliasString = (orgAuth.aliases ? orgAuth.aliases.join(',') : '').padEnd(maxAliasLength, ' ');
|
|
127
|
+
const configString = (orgAuth.configs ? orgAuth.configs.join(',') : '').padEnd(maxConfigLength, ' ');
|
|
128
|
+
const typeString = chalk.dim((orgAuth.isScratchOrg ? 'Scratch' : orgAuth.isDevHub ? 'DevHub' : orgAuth.isSandbox ? 'Sandbox' : '').padEnd(maxTypeLength, ' '));
|
|
129
|
+
// username - aliases - configs
|
|
130
|
+
const key = `${chalk.bold(orgAuth.username.padEnd(maxUsernameLength))} | ${typeString} | ${aliasString} | ${chalk.yellowBright(configString)}`;
|
|
131
|
+
return { name: key, value: orgAuth, checked: all, short: `${os.EOL}${orgAuth.username}` };
|
|
132
|
+
})
|
|
133
|
+
.sort((a, b) => a.value.username.localeCompare(b.value.username));
|
|
134
|
+
const userHeader = `${'Username'.padEnd(maxUsernameLength, ' ')}`;
|
|
135
|
+
const aliasHeader = `${'Aliases'.padEnd(maxAliasLength, ' ')}`;
|
|
136
|
+
const configHeader = `${'Configs'.padEnd(maxConfigLength, ' ')}`;
|
|
137
|
+
const typeHeader = `${'Type'.padEnd(maxTypeLength, ' ')}`;
|
|
138
|
+
return [new Separator(` ${userHeader} | ${typeHeader} | ${aliasHeader} | ${configHeader}`), ...choices];
|
|
139
|
+
};
|
|
185
140
|
//# sourceMappingURL=logout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/commands/org/logout.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/commands/org/logout.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO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: (noPrompt?: boolean | undefined) => Promise<boolean>;
|
|
3
|
+
resolveLoginUrl: (instanceUrl?: string | undefined) => Promise<string>;
|
|
4
|
+
};
|
|
5
|
+
export default _default;
|
package/lib/common.js
CHANGED
|
@@ -4,33 +4,33 @@
|
|
|
4
4
|
* Licensed under the BSD 3-Clause license.
|
|
5
5
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
6
|
*/
|
|
7
|
-
import { Logger, SfdcUrl, SfProject, Messages, SfError } from '@salesforce/core';
|
|
7
|
+
import { Logger, SfdcUrl, SfProject, Messages, SfError, Global, Mode } from '@salesforce/core';
|
|
8
8
|
import { getString, isObject } from '@salesforce/ts-types';
|
|
9
|
+
import chalk from 'chalk';
|
|
10
|
+
import { prompts } from '@salesforce/sf-plugins-core';
|
|
9
11
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
10
12
|
const messages = Messages.loadMessages('@salesforce/plugin-auth', 'messages');
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return instanceUrl;
|
|
17
|
-
}
|
|
18
|
-
let loginUrl;
|
|
19
|
-
try {
|
|
20
|
-
const project = await SfProject.resolve();
|
|
21
|
-
const projectJson = await project.resolveProjectConfig();
|
|
22
|
-
loginUrl = getString(projectJson, 'sfdcLoginUrl', SfdcUrl.PRODUCTION);
|
|
23
|
-
}
|
|
24
|
-
catch (err) {
|
|
25
|
-
const message = (isObject(err) ? Reflect.get(err, 'message') ?? err : err);
|
|
26
|
-
logger.debug(`error occurred while trying to determine loginUrl: ${message}`);
|
|
27
|
-
loginUrl = SfdcUrl.PRODUCTION;
|
|
28
|
-
}
|
|
29
|
-
throwIfLightning(loginUrl);
|
|
30
|
-
logger.debug(`loginUrl: ${loginUrl}`);
|
|
31
|
-
return loginUrl;
|
|
13
|
+
const resolveLoginUrl = async (instanceUrl) => {
|
|
14
|
+
const logger = await Logger.child('Common', { tag: 'resolveLoginUrl' });
|
|
15
|
+
if (instanceUrl) {
|
|
16
|
+
throwIfLightning(instanceUrl);
|
|
17
|
+
return instanceUrl;
|
|
32
18
|
}
|
|
33
|
-
|
|
19
|
+
let loginUrl;
|
|
20
|
+
try {
|
|
21
|
+
const project = await SfProject.resolve();
|
|
22
|
+
const projectJson = await project.resolveProjectConfig();
|
|
23
|
+
loginUrl = getString(projectJson, 'sfdcLoginUrl', SfdcUrl.PRODUCTION);
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
const message = (isObject(err) ? Reflect.get(err, 'message') ?? err : err);
|
|
27
|
+
logger.debug(`error occurred while trying to determine loginUrl: ${message}`);
|
|
28
|
+
loginUrl = SfdcUrl.PRODUCTION;
|
|
29
|
+
}
|
|
30
|
+
throwIfLightning(loginUrl);
|
|
31
|
+
logger.debug(`loginUrl: ${loginUrl}`);
|
|
32
|
+
return loginUrl;
|
|
33
|
+
};
|
|
34
34
|
const throwIfLightning = (urlString) => {
|
|
35
35
|
if (urlString?.match(/\.lightning\..*force\.com/)) {
|
|
36
36
|
throw new SfError(messages.getMessage('lightningInstanceUrl'), 'LightningDomain', [
|
|
@@ -38,4 +38,11 @@ const throwIfLightning = (urlString) => {
|
|
|
38
38
|
]);
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
+
const shouldExitCommand = async (noPrompt) => Boolean(noPrompt) || Global.getEnvironmentMode() !== Mode.DEMO
|
|
42
|
+
? false
|
|
43
|
+
: !(await prompts.confirm({ message: chalk.dim(messages.getMessage('warnAuth', ['sf'])), ms: 60000 }));
|
|
44
|
+
export default {
|
|
45
|
+
shouldExitCommand,
|
|
46
|
+
resolveLoginUrl,
|
|
47
|
+
};
|
|
41
48
|
//# sourceMappingURL=common.js.map
|
package/lib/common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|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C,GAAG,CAAW,CAAC;QAC7F,MAAM,CAAC,KAAK,CAAC,sDAAsD,OAAO,EAAE,CAAC,CAAC;QAC9E,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAChC,CAAC;IACD,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAE3B,MAAM,CAAC,KAAK,CAAC,aAAa,QAAQ,EAAE,CAAC,CAAC;IACtC,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,SAAkB,EAAQ,EAAE;IACpD,IAAI,SAAS,EAAE,KAAK,CAAC,2BAA2B,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,sBAAsB,CAAC,EAAE,iBAAiB,EAAE;YAChF,QAAQ,CAAC,UAAU,CAAC,gCAAgC,CAAC;SACtD,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,KAAK,EAAE,QAAkB,EAAoB,EAAE,CACvE,OAAO,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,kBAAkB,EAAE,KAAK,IAAI,CAAC,IAAI;IAC5D,CAAC,CAAC,KAAK;IACP,CAAC,CAAC,CAAC,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,KAAM,EAAE,CAAC,CAAC,CAAC;AAE5G,eAAe;IACb,iBAAiB;IACjB,eAAe;CAChB,CAAC"}
|
package/messages/messages.md
CHANGED
|
@@ -40,10 +40,6 @@ Do you want to authorize this org for use with the Salesforce CLI?
|
|
|
40
40
|
|
|
41
41
|
Don't prompt for confirmation.
|
|
42
42
|
|
|
43
|
-
# flags.disable-masking.summary
|
|
44
|
-
|
|
45
|
-
Disable masking of user input; use with problematic terminals.
|
|
46
|
-
|
|
47
43
|
# clientSecretStdin
|
|
48
44
|
|
|
49
45
|
OAuth client secret of personal connected app? Press Enter if it's not required.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# summary
|
|
2
2
|
|
|
3
|
-
Authorize an org using a Salesforce DX authorization URL stored in a file.
|
|
3
|
+
Authorize an org using a Salesforce DX authorization URL stored in a file or through standard input (stdin).
|
|
4
4
|
|
|
5
5
|
# description
|
|
6
6
|
|
|
@@ -18,10 +18,16 @@ NOTE: The "<%= config.bin %> org display --verbose" command displays the refresh
|
|
|
18
18
|
|
|
19
19
|
You can also create a JSON file that has a top-level property named sfdxAuthUrl whose value is the authorization URL. Finally, you can create a normal text file that includes just the URL and nothing else.
|
|
20
20
|
|
|
21
|
+
Alternatively, you can pipe the SFDX authorization URL through standard input by using the --sfdx-url-stdin flag and providing the '-' character as the value.
|
|
22
|
+
|
|
21
23
|
# flags.sfdx-url-file.summary
|
|
22
24
|
|
|
23
25
|
Path to a file that contains the Salesforce DX authorization URL.
|
|
24
26
|
|
|
27
|
+
# flags.sfdx-url-stdin.summary
|
|
28
|
+
|
|
29
|
+
Specify '-' as this flag's value to pipe the Salesforce DX authorization URL through standard input (stdin).
|
|
30
|
+
|
|
25
31
|
# examples
|
|
26
32
|
|
|
27
33
|
- Authorize an org using the SFDX authorization URL in the files/authFile.json file:
|
|
@@ -31,3 +37,7 @@ Path to a file that contains the Salesforce DX authorization URL.
|
|
|
31
37
|
- Similar to previous example, but set the org as your default and give it an alias MyDefaultOrg:
|
|
32
38
|
|
|
33
39
|
<%= config.bin %> <%= command.id %> --sfdx-url-file files/authFile.json --set-default --alias MyDefaultOrg
|
|
40
|
+
|
|
41
|
+
- Pipe the SFDX authorization URL from stdin by specifying the '-' value.
|
|
42
|
+
|
|
43
|
+
<%= "\n $ echo url | " + config.bin %> <%= command.id %> --sfdx-url-stdin -
|