@salesforce/plugin-auth 2.8.26 → 3.0.1
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 +67 -67
- package/lib/authBaseCommand.d.ts +0 -2
- package/lib/authBaseCommand.js +9 -25
- package/lib/authBaseCommand.js.map +1 -1
- package/lib/commands/org/list/auth.d.ts +1 -1
- package/lib/commands/org/list/auth.js +16 -17
- package/lib/commands/org/list/auth.js.map +1 -1
- package/lib/commands/org/login/access-token.d.ts +5 -5
- package/lib/commands/org/login/access-token.js +62 -62
- package/lib/commands/org/login/access-token.js.map +1 -1
- package/lib/commands/org/login/device.d.ts +10 -10
- package/lib/commands/org/login/device.js +59 -60
- package/lib/commands/org/login/device.js.map +1 -1
- package/lib/commands/org/login/jwt.d.ts +8 -8
- package/lib/commands/org/login/jwt.js +78 -81
- package/lib/commands/org/login/jwt.js.map +1 -1
- package/lib/commands/org/login/sfdx-url.d.ts +7 -7
- package/lib/commands/org/login/sfdx-url.js +59 -58
- package/lib/commands/org/login/sfdx-url.js.map +1 -1
- package/lib/commands/org/login/web.d.ts +7 -7
- package/lib/commands/org/login/web.js +81 -81
- package/lib/commands/org/login/web.js.map +1 -1
- package/lib/commands/org/logout.d.ts +3 -3
- package/lib/commands/org/logout.js +48 -49
- package/lib/commands/org/logout.js.map +1 -1
- package/lib/common.js +13 -15
- package/lib/common.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -2
- package/lib/index.js.map +1 -1
- package/messages/accesstoken.store.md +5 -0
- package/messages/messages.md +0 -5
- package/oclif.lock +7839 -0
- package/oclif.manifest.json +665 -329
- package/package.json +32 -50
|
@@ -1,31 +1,91 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/*
|
|
3
2
|
* Copyright (c) 2021, salesforce.com, inc.
|
|
4
3
|
* All rights reserved.
|
|
5
4
|
* Licensed under the BSD 3-Clause license.
|
|
6
5
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
6
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
7
|
+
import { dirname } from 'node:path';
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
9
|
+
import open, { apps } from 'open';
|
|
10
|
+
import { Flags, loglevel } from '@salesforce/sf-plugins-core';
|
|
11
|
+
import { AuthInfo, Logger, Messages, SfError, WebOAuthServer } from '@salesforce/core';
|
|
12
|
+
import { Env } from '@salesforce/kit';
|
|
13
|
+
import { AuthBaseCommand } from '../../../authBaseCommand.js';
|
|
14
|
+
import { Common } from '../../../common.js';
|
|
15
|
+
Messages.importMessagesDirectory(dirname(fileURLToPath(import.meta.url)));
|
|
16
|
+
const messages = Messages.loadMessages('@salesforce/plugin-auth', 'web.login');
|
|
17
|
+
const commonMessages = Messages.loadMessages('@salesforce/plugin-auth', 'messages');
|
|
18
|
+
export default class LoginWeb extends AuthBaseCommand {
|
|
19
|
+
static summary = messages.getMessage('summary');
|
|
20
|
+
static description = messages.getMessage('description');
|
|
21
|
+
static examples = messages.getMessages('examples');
|
|
22
|
+
static deprecateAliases = true;
|
|
23
|
+
static aliases = ['force:auth:web:login', 'auth:web:login'];
|
|
24
|
+
static flags = {
|
|
25
|
+
browser: Flags.string({
|
|
26
|
+
char: 'b',
|
|
27
|
+
summary: messages.getMessage('flags.browser.summary'),
|
|
28
|
+
description: messages.getMessage('flags.browser.description'),
|
|
29
|
+
options: ['chrome', 'edge', 'firefox'], // These are ones supported by "open" package
|
|
30
|
+
}),
|
|
31
|
+
'client-id': Flags.string({
|
|
32
|
+
char: 'i',
|
|
33
|
+
summary: commonMessages.getMessage('flags.client-id.summary'),
|
|
34
|
+
deprecateAliases: true,
|
|
35
|
+
aliases: ['clientid'],
|
|
36
|
+
}),
|
|
37
|
+
'instance-url': Flags.url({
|
|
38
|
+
char: 'r',
|
|
39
|
+
summary: commonMessages.getMessage('flags.instance-url.summary'),
|
|
40
|
+
description: commonMessages.getMessage('flags.instance-url.description'),
|
|
41
|
+
deprecateAliases: true,
|
|
42
|
+
aliases: ['instanceurl', 'l'],
|
|
43
|
+
}),
|
|
44
|
+
'set-default-dev-hub': Flags.boolean({
|
|
45
|
+
char: 'd',
|
|
46
|
+
summary: commonMessages.getMessage('flags.set-default-dev-hub.summary'),
|
|
47
|
+
deprecateAliases: true,
|
|
48
|
+
aliases: ['setdefaultdevhubusername', 'setdefaultdevhub', 'v'],
|
|
49
|
+
}),
|
|
50
|
+
'set-default': Flags.boolean({
|
|
51
|
+
char: 's',
|
|
52
|
+
summary: commonMessages.getMessage('flags.set-default.summary'),
|
|
53
|
+
deprecateAliases: true,
|
|
54
|
+
aliases: ['setdefaultusername'],
|
|
55
|
+
}),
|
|
56
|
+
alias: Flags.string({
|
|
57
|
+
char: 'a',
|
|
58
|
+
summary: commonMessages.getMessage('flags.alias.summary'),
|
|
59
|
+
deprecateAliases: true,
|
|
60
|
+
aliases: ['setalias'],
|
|
61
|
+
}),
|
|
62
|
+
'disable-masking': Flags.boolean({
|
|
63
|
+
summary: commonMessages.getMessage('flags.disable-masking.summary'),
|
|
64
|
+
hidden: true,
|
|
65
|
+
deprecateAliases: true,
|
|
66
|
+
aliases: ['disablemasking'],
|
|
67
|
+
}),
|
|
68
|
+
'no-prompt': Flags.boolean({
|
|
69
|
+
char: 'p',
|
|
70
|
+
summary: commonMessages.getMessage('flags.no-prompt.summary'),
|
|
71
|
+
required: false,
|
|
72
|
+
hidden: true,
|
|
73
|
+
deprecateAliases: true,
|
|
74
|
+
aliases: ['noprompt'],
|
|
75
|
+
}),
|
|
76
|
+
loglevel,
|
|
77
|
+
};
|
|
78
|
+
flags;
|
|
19
79
|
async run() {
|
|
20
80
|
const { flags } = await this.parse(LoginWeb);
|
|
21
81
|
this.flags = flags;
|
|
22
82
|
if (isSFDXContainerMode()) {
|
|
23
|
-
throw new
|
|
83
|
+
throw new SfError(messages.getMessage('deviceWarning'), 'DEVICE_WARNING');
|
|
24
84
|
}
|
|
25
85
|
if (await this.shouldExitCommand(flags['no-prompt']))
|
|
26
86
|
return {};
|
|
27
87
|
const oauthConfig = {
|
|
28
|
-
loginUrl: await
|
|
88
|
+
loginUrl: await Common.resolveLoginUrl(flags['instance-url']?.href),
|
|
29
89
|
clientId: flags['client-id'],
|
|
30
90
|
};
|
|
31
91
|
if (flags['client-id']) {
|
|
@@ -39,16 +99,16 @@ class LoginWeb extends authBaseCommand_1.AuthBaseCommand {
|
|
|
39
99
|
setDefaultDevHub: flags['set-default-dev-hub'],
|
|
40
100
|
});
|
|
41
101
|
const fields = authInfo.getFields(true);
|
|
42
|
-
await
|
|
102
|
+
await AuthInfo.identifyPossibleScratchOrgs(fields, authInfo);
|
|
43
103
|
const successMsg = commonMessages.getMessage('authorizeCommandSuccess', [fields.username, fields.orgId]);
|
|
44
104
|
this.logSuccess(successMsg);
|
|
45
105
|
return fields;
|
|
46
106
|
}
|
|
47
107
|
catch (err) {
|
|
48
108
|
const error = err;
|
|
49
|
-
|
|
109
|
+
Logger.childFromRoot('auth').debug(error);
|
|
50
110
|
if (error.name === 'AuthCodeExchangeError') {
|
|
51
|
-
throw new
|
|
111
|
+
throw new SfError(messages.getMessage('invalidClientId', [error.message]));
|
|
52
112
|
}
|
|
53
113
|
throw error;
|
|
54
114
|
}
|
|
@@ -56,76 +116,16 @@ class LoginWeb extends authBaseCommand_1.AuthBaseCommand {
|
|
|
56
116
|
// leave it because it's stubbed in the test
|
|
57
117
|
// eslint-disable-next-line class-methods-use-this
|
|
58
118
|
async executeLoginFlow(oauthConfig) {
|
|
59
|
-
const oauthServer = await
|
|
119
|
+
const oauthServer = await WebOAuthServer.create({ oauthConfig });
|
|
60
120
|
await oauthServer.start();
|
|
61
|
-
const app = this.flags.browser && this.flags.browser in
|
|
62
|
-
const openOptions = app ? { app: { name:
|
|
121
|
+
const app = this.flags.browser && this.flags.browser in apps ? this.flags.browser : undefined;
|
|
122
|
+
const openOptions = app ? { app: { name: apps[app] }, wait: false } : { wait: false };
|
|
63
123
|
await open(oauthServer.getAuthorizationUrl(), openOptions);
|
|
64
124
|
return oauthServer.authorizeAndSave();
|
|
65
125
|
}
|
|
66
126
|
}
|
|
67
|
-
LoginWeb.summary = messages.getMessage('summary');
|
|
68
|
-
LoginWeb.description = messages.getMessage('description');
|
|
69
|
-
LoginWeb.examples = messages.getMessages('examples');
|
|
70
|
-
LoginWeb.deprecateAliases = true;
|
|
71
|
-
LoginWeb.aliases = ['force:auth:web:login', 'auth:web:login'];
|
|
72
|
-
LoginWeb.flags = {
|
|
73
|
-
browser: sf_plugins_core_1.Flags.string({
|
|
74
|
-
char: 'b',
|
|
75
|
-
summary: messages.getMessage('flags.browser.summary'),
|
|
76
|
-
description: messages.getMessage('flags.browser.description'),
|
|
77
|
-
options: ['chrome', 'edge', 'firefox'], // These are ones supported by "open" package
|
|
78
|
-
}),
|
|
79
|
-
'client-id': sf_plugins_core_1.Flags.string({
|
|
80
|
-
char: 'i',
|
|
81
|
-
summary: commonMessages.getMessage('flags.client-id.summary'),
|
|
82
|
-
deprecateAliases: true,
|
|
83
|
-
aliases: ['clientid'],
|
|
84
|
-
}),
|
|
85
|
-
'instance-url': sf_plugins_core_1.Flags.url({
|
|
86
|
-
char: 'r',
|
|
87
|
-
summary: commonMessages.getMessage('flags.instance-url.summary'),
|
|
88
|
-
description: commonMessages.getMessage('flags.instance-url.description'),
|
|
89
|
-
deprecateAliases: true,
|
|
90
|
-
aliases: ['instanceurl', 'l'],
|
|
91
|
-
}),
|
|
92
|
-
'set-default-dev-hub': sf_plugins_core_1.Flags.boolean({
|
|
93
|
-
char: 'd',
|
|
94
|
-
summary: commonMessages.getMessage('flags.set-default-dev-hub.summary'),
|
|
95
|
-
deprecateAliases: true,
|
|
96
|
-
aliases: ['setdefaultdevhubusername', 'setdefaultdevhub', 'v'],
|
|
97
|
-
}),
|
|
98
|
-
'set-default': sf_plugins_core_1.Flags.boolean({
|
|
99
|
-
char: 's',
|
|
100
|
-
summary: commonMessages.getMessage('flags.set-default.summary'),
|
|
101
|
-
deprecateAliases: true,
|
|
102
|
-
aliases: ['setdefaultusername'],
|
|
103
|
-
}),
|
|
104
|
-
alias: sf_plugins_core_1.Flags.string({
|
|
105
|
-
char: 'a',
|
|
106
|
-
summary: commonMessages.getMessage('flags.alias.summary'),
|
|
107
|
-
deprecateAliases: true,
|
|
108
|
-
aliases: ['setalias'],
|
|
109
|
-
}),
|
|
110
|
-
'disable-masking': sf_plugins_core_1.Flags.boolean({
|
|
111
|
-
summary: commonMessages.getMessage('flags.disable-masking.summary'),
|
|
112
|
-
hidden: true,
|
|
113
|
-
deprecateAliases: true,
|
|
114
|
-
aliases: ['disablemasking'],
|
|
115
|
-
}),
|
|
116
|
-
'no-prompt': sf_plugins_core_1.Flags.boolean({
|
|
117
|
-
char: 'p',
|
|
118
|
-
summary: commonMessages.getMessage('flags.no-prompt.summary'),
|
|
119
|
-
required: false,
|
|
120
|
-
hidden: true,
|
|
121
|
-
deprecateAliases: true,
|
|
122
|
-
aliases: ['noprompt'],
|
|
123
|
-
}),
|
|
124
|
-
loglevel: sf_plugins_core_1.loglevel,
|
|
125
|
-
};
|
|
126
|
-
exports.default = LoginWeb;
|
|
127
127
|
const isSFDXContainerMode = () => {
|
|
128
|
-
const env = new
|
|
128
|
+
const env = new Env();
|
|
129
129
|
return env.getBoolean('SFDX_CONTAINER_MODE');
|
|
130
130
|
};
|
|
131
131
|
//# sourceMappingURL=web.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../../../src/commands/org/login/web.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../../../src/commands/org/login/web.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM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AAI,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC,CAAE,IAAI,CAAC,KAAK,CAAC,OAAmB,CAAC,CAAC,CAAC,SAAS,CAAC;QAC3G,MAAM,WAAW,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QACtF,MAAM,IAAI,CAAC,WAAW,CAAC,mBAAmB,EAAE,EAAE,WAAW,CAAC,CAAC;QAC3D,OAAO,WAAW,CAAC,gBAAgB,EAAE,CAAC;IACxC,CAAC;;AAGH,MAAM,mBAAmB,GAAG,GAAY,EAAE;IACxC,MAAM,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;IACtB,OAAO,GAAG,CAAC,UAAU,CAAC,qBAAqB,CAAC,CAAC;AAC/C,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Interfaces } from '@oclif/core';
|
|
2
|
-
import { AuthBaseCommand } from '../../authBaseCommand';
|
|
2
|
+
import { AuthBaseCommand } from '../../authBaseCommand.js';
|
|
3
3
|
export type AuthLogoutResults = string[];
|
|
4
4
|
export default class Logout extends AuthBaseCommand<AuthLogoutResults> {
|
|
5
5
|
static readonly summary: string;
|
|
@@ -8,10 +8,10 @@ export default class Logout extends AuthBaseCommand<AuthLogoutResults> {
|
|
|
8
8
|
static readonly deprecateAliases = true;
|
|
9
9
|
static aliases: string[];
|
|
10
10
|
static readonly flags: {
|
|
11
|
-
'target-org': Interfaces.OptionFlag<string | undefined,
|
|
11
|
+
'target-org': Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
12
12
|
all: Interfaces.BooleanFlag<boolean>;
|
|
13
13
|
'no-prompt': Interfaces.BooleanFlag<boolean>;
|
|
14
|
-
loglevel: Interfaces.OptionFlag<string | undefined,
|
|
14
|
+
loglevel: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
15
15
|
};
|
|
16
16
|
private flags;
|
|
17
17
|
private static buildChoices;
|
|
@@ -1,21 +1,50 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/*
|
|
3
2
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
4
3
|
* All rights reserved.
|
|
5
4
|
* Licensed under the BSD 3-Clause license.
|
|
6
5
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
6
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const messages =
|
|
17
|
-
const commonMessages =
|
|
18
|
-
class Logout extends
|
|
7
|
+
import { dirname } from 'node:path';
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
9
|
+
import os from 'node:os';
|
|
10
|
+
import { AuthInfo, AuthRemover, ConfigAggregator, Global, Messages, Mode, OrgConfigProperties, } from '@salesforce/core';
|
|
11
|
+
import { Flags, loglevel, Separator } from '@salesforce/sf-plugins-core';
|
|
12
|
+
import chalk from 'chalk';
|
|
13
|
+
import { AuthBaseCommand } from '../../authBaseCommand.js';
|
|
14
|
+
Messages.importMessagesDirectory(dirname(fileURLToPath(import.meta.url)));
|
|
15
|
+
const messages = Messages.loadMessages('@salesforce/plugin-auth', 'logout');
|
|
16
|
+
const commonMessages = Messages.loadMessages('@salesforce/plugin-auth', 'messages');
|
|
17
|
+
export default class Logout extends AuthBaseCommand {
|
|
18
|
+
static summary = messages.getMessage('summary');
|
|
19
|
+
static description = messages.getMessage('description');
|
|
20
|
+
static examples = messages.getMessages('examples');
|
|
21
|
+
static deprecateAliases = true;
|
|
22
|
+
static aliases = ['force:auth:logout', 'auth:logout'];
|
|
23
|
+
static flags = {
|
|
24
|
+
'target-org': Flags.string({
|
|
25
|
+
summary: messages.getMessage('flags.target-org.summary'),
|
|
26
|
+
char: 'o',
|
|
27
|
+
aliases: ['targetusername', 'u'],
|
|
28
|
+
deprecateAliases: true,
|
|
29
|
+
}),
|
|
30
|
+
all: Flags.boolean({
|
|
31
|
+
char: 'a',
|
|
32
|
+
summary: messages.getMessage('flags.all.summary'),
|
|
33
|
+
description: messages.getMessage('flags.all.description'),
|
|
34
|
+
required: false,
|
|
35
|
+
default: false,
|
|
36
|
+
exclusive: ['target-org'],
|
|
37
|
+
}),
|
|
38
|
+
'no-prompt': Flags.boolean({
|
|
39
|
+
char: 'p',
|
|
40
|
+
summary: commonMessages.getMessage('flags.no-prompt.summary'),
|
|
41
|
+
required: false,
|
|
42
|
+
deprecateAliases: true,
|
|
43
|
+
aliases: ['noprompt'],
|
|
44
|
+
}),
|
|
45
|
+
loglevel,
|
|
46
|
+
};
|
|
47
|
+
flags;
|
|
19
48
|
static buildChoices(orgAuths, all) {
|
|
20
49
|
const maxUsernameLength = Math.max('Username'.length, ...orgAuths.map((orgAuth) => orgAuth.username.length));
|
|
21
50
|
const maxAliasLength = Math.max('Aliases'.length, ...orgAuths.map((orgAuth) => (orgAuth.aliases ? orgAuth.aliases.join(',') : '').length));
|
|
@@ -46,15 +75,15 @@ class Logout extends authBaseCommand_1.AuthBaseCommand {
|
|
|
46
75
|
const aliasHeader = `${'Aliases'.padEnd(maxAliasLength, ' ')}`;
|
|
47
76
|
const configHeader = `${'Configs'.padEnd(maxConfigLength, ' ')}`;
|
|
48
77
|
const typeHeader = `${'Type'.padEnd(maxTypeLength, ' ')}`;
|
|
49
|
-
return [new
|
|
78
|
+
return [new Separator(` ${userHeader} | ${typeHeader} | ${aliasHeader} | ${configHeader}`), ...choices];
|
|
50
79
|
}
|
|
51
80
|
async run() {
|
|
52
81
|
const { flags } = await this.parse(Logout);
|
|
53
82
|
this.flags = flags;
|
|
54
|
-
this.configAggregator = await
|
|
55
|
-
const remover = await
|
|
83
|
+
this.configAggregator = await ConfigAggregator.create();
|
|
84
|
+
const remover = await AuthRemover.create();
|
|
56
85
|
let orgAuths = [];
|
|
57
|
-
const targetUsername = this.flags['target-org'] ?? this.configAggregator.getInfo(
|
|
86
|
+
const targetUsername = this.flags['target-org'] ?? this.configAggregator.getInfo(OrgConfigProperties.TARGET_ORG).value;
|
|
58
87
|
// if no-prompt, there must be a resolved target-org or --all
|
|
59
88
|
if (flags['no-prompt'] && !targetUsername && !flags.all) {
|
|
60
89
|
throw messages.createError('noOrgSpecifiedWithNoPrompt');
|
|
@@ -63,10 +92,10 @@ class Logout extends authBaseCommand_1.AuthBaseCommand {
|
|
|
63
92
|
throw messages.createError('noOrgSpecifiedWithJson');
|
|
64
93
|
}
|
|
65
94
|
if (this.shouldFindAllAuths(targetUsername)) {
|
|
66
|
-
orgAuths = await
|
|
95
|
+
orgAuths = await AuthInfo.listAllAuthorizations();
|
|
67
96
|
}
|
|
68
97
|
else if (targetUsername) {
|
|
69
|
-
orgAuths = await
|
|
98
|
+
orgAuths = await AuthInfo.listAllAuthorizations((orgAuth) => orgAuth.username === targetUsername || !!orgAuth.aliases?.includes(targetUsername));
|
|
70
99
|
}
|
|
71
100
|
else {
|
|
72
101
|
// just for clarity
|
|
@@ -101,7 +130,7 @@ class Logout extends authBaseCommand_1.AuthBaseCommand {
|
|
|
101
130
|
if (targetUsername && !this.flags.all) {
|
|
102
131
|
return false;
|
|
103
132
|
}
|
|
104
|
-
return this.flags.all ||
|
|
133
|
+
return this.flags.all || Global.getEnvironmentMode() === Mode.DEMO || !this.flags['no-prompt'];
|
|
105
134
|
}
|
|
106
135
|
async promptForOrgsToRemove(orgAuths, all) {
|
|
107
136
|
if (this.flags['no-prompt'] || this.jsonEnabled()) {
|
|
@@ -155,34 +184,4 @@ class Logout extends authBaseCommand_1.AuthBaseCommand {
|
|
|
155
184
|
};
|
|
156
185
|
}
|
|
157
186
|
}
|
|
158
|
-
Logout.summary = messages.getMessage('summary');
|
|
159
|
-
Logout.description = messages.getMessage('description');
|
|
160
|
-
Logout.examples = messages.getMessages('examples');
|
|
161
|
-
Logout.deprecateAliases = true;
|
|
162
|
-
Logout.aliases = ['force:auth:logout', 'auth:logout'];
|
|
163
|
-
Logout.flags = {
|
|
164
|
-
'target-org': sf_plugins_core_1.Flags.string({
|
|
165
|
-
summary: messages.getMessage('flags.target-org.summary'),
|
|
166
|
-
char: 'o',
|
|
167
|
-
aliases: ['targetusername', 'u'],
|
|
168
|
-
deprecateAliases: true,
|
|
169
|
-
}),
|
|
170
|
-
all: sf_plugins_core_1.Flags.boolean({
|
|
171
|
-
char: 'a',
|
|
172
|
-
summary: messages.getMessage('flags.all.summary'),
|
|
173
|
-
description: messages.getMessage('flags.all.description'),
|
|
174
|
-
required: false,
|
|
175
|
-
default: false,
|
|
176
|
-
exclusive: ['target-org'],
|
|
177
|
-
}),
|
|
178
|
-
'no-prompt': sf_plugins_core_1.Flags.boolean({
|
|
179
|
-
char: 'p',
|
|
180
|
-
summary: commonMessages.getMessage('flags.no-prompt.summary'),
|
|
181
|
-
required: false,
|
|
182
|
-
deprecateAliases: true,
|
|
183
|
-
aliases: ['noprompt'],
|
|
184
|
-
}),
|
|
185
|
-
loglevel: sf_plugins_core_1.loglevel,
|
|
186
|
-
};
|
|
187
|
-
exports.default = Logout;
|
|
188
187
|
//# sourceMappingURL=logout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/commands/org/logout.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/commands/org/logout.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EACL,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,MAAM,EACN,QAAQ,EACR,IAAI,EAEJ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,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;oBACpE,IAAI,cAAc,EAAE;wBAClB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;qBAC3C;oBACD,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;oBACtD,IAAI,KAAK,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,EAAE;wBACpC,OAAO,QAAQ,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;qBAClD;yBAAM;wBACL,OAAO,QAAQ,CAAC,UAAU,CAAC,gBAAgB,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;qBAC3F;gBACH,CAAC;gBACD,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,KAAK;aACf;SACF,EACD,KAAM,CACP,CAAC;QACF,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;YACxB,SAAS;SACV,CAAC;IACJ,CAAC"}
|
package/lib/common.js
CHANGED
|
@@ -1,43 +1,41 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Common = void 0;
|
|
4
1
|
/*
|
|
5
2
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
6
3
|
* All rights reserved.
|
|
7
4
|
* Licensed under the BSD 3-Clause license.
|
|
8
5
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
9
6
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
import { dirname } from 'node:path';
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
9
|
+
import { Logger, SfdcUrl, SfProject, Messages, SfError } from '@salesforce/core';
|
|
10
|
+
import { getString, isObject } from '@salesforce/ts-types';
|
|
11
|
+
Messages.importMessagesDirectory(dirname(fileURLToPath(import.meta.url)));
|
|
12
|
+
const messages = Messages.loadMessages('@salesforce/plugin-auth', 'messages');
|
|
13
|
+
export class Common {
|
|
15
14
|
static async resolveLoginUrl(instanceUrl) {
|
|
16
|
-
const logger = await
|
|
15
|
+
const logger = await Logger.child('Common', { tag: 'resolveLoginUrl' });
|
|
17
16
|
if (instanceUrl) {
|
|
18
17
|
throwIfLightning(instanceUrl);
|
|
19
18
|
return instanceUrl;
|
|
20
19
|
}
|
|
21
20
|
let loginUrl;
|
|
22
21
|
try {
|
|
23
|
-
const project = await
|
|
22
|
+
const project = await SfProject.resolve();
|
|
24
23
|
const projectJson = await project.resolveProjectConfig();
|
|
25
|
-
loginUrl =
|
|
24
|
+
loginUrl = getString(projectJson, 'sfdcLoginUrl', SfdcUrl.PRODUCTION);
|
|
26
25
|
}
|
|
27
26
|
catch (err) {
|
|
28
|
-
const message = (
|
|
27
|
+
const message = (isObject(err) ? Reflect.get(err, 'message') ?? err : err);
|
|
29
28
|
logger.debug(`error occurred while trying to determine loginUrl: ${message}`);
|
|
30
|
-
loginUrl =
|
|
29
|
+
loginUrl = SfdcUrl.PRODUCTION;
|
|
31
30
|
}
|
|
32
31
|
throwIfLightning(loginUrl);
|
|
33
32
|
logger.debug(`loginUrl: ${loginUrl}`);
|
|
34
33
|
return loginUrl;
|
|
35
34
|
}
|
|
36
35
|
}
|
|
37
|
-
exports.Common = Common;
|
|
38
36
|
const throwIfLightning = (urlString) => {
|
|
39
37
|
if (urlString?.match(/\.lightning\..*force\.com/)) {
|
|
40
|
-
throw new
|
|
38
|
+
throw new SfError(messages.getMessage('lightningInstanceUrl'), 'LightningDomain', [
|
|
41
39
|
messages.getMessage('flags.instance-url.description'),
|
|
42
40
|
]);
|
|
43
41
|
}
|
package/lib/common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAE3D,QAAQ,CAAC,uBAAuB,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC1E,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,yBAAyB,EAAE,UAAU,CAAC,CAAC;AAE9E,MAAM,OAAO,MAAM;IACV,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,WAAoB;QACtD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,GAAG,EAAE,iBAAiB,EAAE,CAAC,CAAC;QACxE,IAAI,WAAW,EAAE;YACf,gBAAgB,CAAC,WAAW,CAAC,CAAC;YAC9B,OAAO,WAAW,CAAC;SACpB;QACD,IAAI,QAAgB,CAAC;QACrB,IAAI;YACF,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,OAAO,EAAE,CAAC;YAC1C,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,oBAAoB,EAAE,CAAC;YACzD,QAAQ,GAAG,SAAS,CAAC,WAAW,EAAE,cAAc,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;SACvE;QAAC,OAAO,GAAG,EAAE;YACZ,MAAM,OAAO,GAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,SAAS,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAW,CAAC;YAC7F,MAAM,CAAC,KAAK,CAAC,sDAAsD,OAAO,EAAE,CAAC,CAAC;YAC9E,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;SAC/B;QACD,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAE3B,MAAM,CAAC,KAAK,CAAC,aAAa,QAAQ,EAAE,CAAC,CAAC;QACtC,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAED,MAAM,gBAAgB,GAAG,CAAC,SAAkB,EAAQ,EAAE;IACpD,IAAI,SAAS,EAAE,KAAK,CAAC,2BAA2B,CAAC,EAAE;QACjD,MAAM,IAAI,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,sBAAsB,CAAC,EAAE,iBAAiB,EAAE;YAChF,QAAQ,CAAC,UAAU,CAAC,gCAAgC,CAAC;SACtD,CAAC,CAAC;KACJ;AACH,CAAC,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
declare const _default: {};
|
|
2
|
-
export
|
|
2
|
+
export default _default;
|
package/lib/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/*
|
|
3
2
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
4
3
|
* All rights reserved.
|
|
5
4
|
* Licensed under the BSD 3-Clause license.
|
|
6
5
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
6
|
*/
|
|
8
|
-
|
|
7
|
+
export default {};
|
|
9
8
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAe,EAAE,CAAC"}
|
|
@@ -22,3 +22,8 @@ To use the command in a CI/CD script, set the SFDX_ACCESS_TOKEN environment vari
|
|
|
22
22
|
|
|
23
23
|
The access token isn't in the correct format.
|
|
24
24
|
It should follow this pattern: %s.
|
|
25
|
+
|
|
26
|
+
# overwriteAccessTokenAuthUserFile
|
|
27
|
+
|
|
28
|
+
A file already exists for user "%s", which is associated with the access token you provided.
|
|
29
|
+
Are you sure you want to overwrite the existing file?
|
package/messages/messages.md
CHANGED
|
@@ -59,8 +59,3 @@ Access token of user to use for authentication
|
|
|
59
59
|
# noPrompt
|
|
60
60
|
|
|
61
61
|
do not prompt for confirmation
|
|
62
|
-
|
|
63
|
-
# overwriteAccessTokenAuthUserFile
|
|
64
|
-
|
|
65
|
-
A file already exists for user "%s", which is associated with the access token you provided.
|
|
66
|
-
Are you sure you want to overwrite the existing file?
|