@salesforce/plugin-auth 2.4.2 → 2.5.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/lib/authBaseCommand.d.ts +11 -0
- package/lib/authBaseCommand.js +64 -0
- package/lib/authBaseCommand.js.map +1 -0
- package/lib/commands/auth/accesstoken/store.d.ts +15 -3
- package/lib/commands/auth/accesstoken/store.js +39 -31
- package/lib/commands/auth/accesstoken/store.js.map +1 -1
- package/lib/commands/auth/device/login.d.ts +16 -4
- package/lib/commands/auth/device/login.js +48 -33
- package/lib/commands/auth/device/login.js.map +1 -1
- package/lib/commands/auth/jwt/grant.d.ts +18 -3
- package/lib/commands/auth/jwt/grant.js +54 -31
- package/lib/commands/auth/jwt/grant.js.map +1 -1
- package/lib/commands/auth/list.d.ts +14 -4
- package/lib/commands/auth/list.js +17 -14
- package/lib/commands/auth/list.js.map +1 -1
- package/lib/commands/auth/logout.d.ts +15 -6
- package/lib/commands/auth/logout.js +47 -26
- package/lib/commands/auth/logout.js.map +1 -1
- package/lib/commands/auth/sfdxurl/store.d.ts +11 -3
- package/lib/commands/auth/sfdxurl/store.js +37 -24
- package/lib/commands/auth/sfdxurl/store.js.map +1 -1
- package/lib/commands/auth/web/login.d.ts +18 -3
- package/lib/commands/auth/web/login.js +49 -31
- package/lib/commands/auth/web/login.js.map +1 -1
- package/messages/accesstoken.store.md +22 -0
- package/messages/device.login.md +28 -0
- package/messages/jwt.grant.md +29 -0
- package/messages/list.md +15 -0
- package/messages/logout.md +45 -0
- package/messages/messages.md +58 -0
- package/messages/sfdxurl.store.md +27 -0
- package/messages/web.login.md +31 -0
- package/oclif.manifest.json +371 -626
- package/package.json +16 -14
- package/lib/prompts.d.ts +0 -11
- package/lib/prompts.js +0 -65
- package/lib/prompts.js.map +0 -1
- package/messages/accesstoken.store.json +0 -9
- package/messages/device.login.json +0 -11
- package/messages/jwt.grant.json +0 -11
- package/messages/list.json +0 -4
- package/messages/logout.json +0 -9
- package/messages/messages.json +0 -37
- package/messages/sfdxurl.store.json +0 -8
- package/messages/web.login.json +0 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grant.js","sourceRoot":"","sources":["../../../../src/commands/auth/jwt/grant.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,
|
|
1
|
+
{"version":3,"file":"grant.js","sourceRoot":"","sources":["../../../../src/commands/auth/jwt/grant.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,iEAA8D;AAC9D,2CAAgG;AAChG,mDAAiD;AAEjD,8DAA2D;AAC3D,4CAAyC;AAEzC,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAC5C,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,CAAC,yBAAyB,EAAE,WAAW,CAAC,CAAC;AAC/E,MAAM,cAAc,GAAG,eAAQ,CAAC,YAAY,CAAC,yBAAyB,EAAE,UAAU,CAAC,CAAC;AAEpF,MAAqB,KAAM,SAAQ,iCAA2B;IAA9D;;QA+DU,WAAM,GAAG,aAAM,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IA6D/D,CAAC;IA3DQ,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC1C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,MAAM,GAAe,EAAE,CAAC;QAE5B,IAAI,MAAM,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YAAE,OAAO,EAAE,CAAC;QAEhE,IAAI;YACF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;YAC3C,MAAM,QAAQ,CAAC,6BAA6B,CAAC;gBAC3C,KAAK,EAAE,KAAK,CAAC,KAAe;gBAC5B,UAAU,EAAE,KAAK,CAAC,aAAa,CAAC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gBAAgB,EAAE,IAAI;QACtB,OAAO,EAAE,CAAC,UAAU,CAAC;KACtB,CAAC;IACF,QAAQ,EAAR,0BAAQ;CACT,CAAC"}
|
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
2
|
import { OrgAuthorization } from '@salesforce/core';
|
|
3
|
-
|
|
3
|
+
type AuthListResult = Omit<OrgAuthorization, 'aliases'> & {
|
|
4
|
+
alias: string;
|
|
5
|
+
};
|
|
6
|
+
export type AuthListResults = AuthListResult[];
|
|
7
|
+
export default class List extends SfCommand<AuthListResults> {
|
|
8
|
+
static readonly summary: string;
|
|
4
9
|
static readonly description: string;
|
|
10
|
+
static readonly examples: string[];
|
|
11
|
+
static readonly deprecateAliases = true;
|
|
5
12
|
static aliases: string[];
|
|
6
|
-
static readonly
|
|
7
|
-
|
|
13
|
+
static readonly flags: {
|
|
14
|
+
loglevel: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
15
|
+
};
|
|
16
|
+
run(): Promise<AuthListResults>;
|
|
8
17
|
}
|
|
18
|
+
export {};
|
|
@@ -6,26 +6,24 @@
|
|
|
6
6
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
const
|
|
9
|
+
const sf_plugins_core_1 = require("@salesforce/sf-plugins-core");
|
|
10
10
|
const core_1 = require("@salesforce/core");
|
|
11
11
|
core_1.Messages.importMessagesDirectory(__dirname);
|
|
12
12
|
const messages = core_1.Messages.loadMessages('@salesforce/plugin-auth', 'list');
|
|
13
|
-
class List extends
|
|
13
|
+
class List extends sf_plugins_core_1.SfCommand {
|
|
14
14
|
async run() {
|
|
15
|
+
await this.parse(List);
|
|
15
16
|
try {
|
|
16
17
|
const auths = await core_1.AuthInfo.listAllAuthorizations();
|
|
17
18
|
if (auths.length === 0) {
|
|
18
|
-
this.
|
|
19
|
+
this.log(messages.getMessage('noResultsFound'));
|
|
19
20
|
return [];
|
|
20
21
|
}
|
|
21
|
-
auths.map((auth) => {
|
|
22
|
+
const mappedAuths = auths.map((auth) => {
|
|
22
23
|
// core3 moved to aliases as a string[], revert to alias as a string
|
|
23
|
-
auth.alias = auth.aliases.join(',');
|
|
24
|
-
// to prevent 'undefined' entries in the table only delete auth.alias if it's json output
|
|
25
|
-
// matches the previous behavior where alias was only present when it was defined
|
|
26
|
-
if (auth.alias === '' && this.flags.json)
|
|
27
|
-
delete auth.alias;
|
|
24
|
+
auth.alias = auth.aliases ? auth.aliases.join(',') : '';
|
|
28
25
|
delete auth.aliases;
|
|
26
|
+
return auth;
|
|
29
27
|
});
|
|
30
28
|
const hasErrors = auths.filter((auth) => !!auth.error).length > 0;
|
|
31
29
|
let columns = {
|
|
@@ -38,18 +36,23 @@ class List extends command_1.SfdxCommand {
|
|
|
38
36
|
if (hasErrors) {
|
|
39
37
|
columns = { ...columns, ...{ error: { header: 'ERROR' } } };
|
|
40
38
|
}
|
|
41
|
-
this.
|
|
42
|
-
this.
|
|
43
|
-
return
|
|
39
|
+
this.styledHeader('authenticated orgs');
|
|
40
|
+
this.table(mappedAuths, columns);
|
|
41
|
+
return mappedAuths;
|
|
44
42
|
}
|
|
45
43
|
catch (err) {
|
|
46
|
-
this.
|
|
44
|
+
this.log(messages.getMessage('noResultsFound'));
|
|
47
45
|
return [];
|
|
48
46
|
}
|
|
49
47
|
}
|
|
50
48
|
}
|
|
51
49
|
exports.default = List;
|
|
50
|
+
List.summary = messages.getMessage('summary');
|
|
52
51
|
List.description = messages.getMessage('description');
|
|
52
|
+
List.examples = messages.getMessages('examples');
|
|
53
|
+
List.deprecateAliases = true;
|
|
53
54
|
List.aliases = ['force:auth:list'];
|
|
54
|
-
List.
|
|
55
|
+
List.flags = {
|
|
56
|
+
loglevel: sf_plugins_core_1.loglevel,
|
|
57
|
+
};
|
|
55
58
|
//# sourceMappingURL=list.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/auth/list.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/auth/list.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,iEAAkE;AAClE,2CAAwE;AAGxE,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAC5C,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,CAAC,yBAAyB,EAAE,MAAM,CAAC,CAAC;AAE1E,MAAqB,IAAK,SAAQ,2BAA0B;IAWnD,KAAK,CAAC,GAAG;QACd,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACvB,IAAI;YACF,MAAM,KAAK,GAAG,MAAM,eAAQ,CAAC,qBAAqB,EAAE,CAAC;YACrD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;gBACtB,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,CAAC;gBAChD,OAAO,EAAE,CAAC;aACX;YACD,MAAM,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAA0C,EAAE,EAAE;gBAC3E,oEAAoE;gBACpE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBAExD,OAAO,IAAI,CAAC,OAAO,CAAC;gBACpB,OAAO,IAAI,CAAC;YACd,CAAC,CAAC,CAAC;YACH,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAA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string[];
|
|
4
|
+
export default class Logout extends AuthBaseCommand<AuthLogoutResults> {
|
|
5
|
+
static readonly summary: string;
|
|
3
6
|
static readonly description: string;
|
|
4
7
|
static readonly examples: string[];
|
|
5
|
-
static readonly
|
|
8
|
+
static readonly deprecateAliases = true;
|
|
6
9
|
static aliases: string[];
|
|
7
|
-
static readonly
|
|
8
|
-
|
|
10
|
+
static readonly flags: {
|
|
11
|
+
'target-org': Interfaces.OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
12
|
+
all: Interfaces.BooleanFlag<boolean>;
|
|
13
|
+
'no-prompt': Interfaces.BooleanFlag<boolean>;
|
|
14
|
+
loglevel: Interfaces.OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
15
|
+
};
|
|
16
|
+
private flags;
|
|
17
|
+
run(): Promise<AuthLogoutResults>;
|
|
9
18
|
private shouldFindAllAuths;
|
|
10
|
-
private
|
|
19
|
+
private shouldRunLogoutCommand;
|
|
11
20
|
}
|
|
@@ -8,25 +8,24 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
const os = require("os");
|
|
10
10
|
const core_1 = require("@salesforce/core");
|
|
11
|
-
const
|
|
12
|
-
const
|
|
11
|
+
const sf_plugins_core_1 = require("@salesforce/sf-plugins-core");
|
|
12
|
+
const ts_types_1 = require("@salesforce/ts-types");
|
|
13
|
+
const authBaseCommand_1 = require("../../authBaseCommand");
|
|
13
14
|
core_1.Messages.importMessagesDirectory(__dirname);
|
|
14
15
|
const messages = core_1.Messages.loadMessages('@salesforce/plugin-auth', 'logout');
|
|
15
16
|
const commonMessages = core_1.Messages.loadMessages('@salesforce/plugin-auth', 'messages');
|
|
16
|
-
class Logout extends
|
|
17
|
+
class Logout extends authBaseCommand_1.AuthBaseCommand {
|
|
17
18
|
async run() {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const { flags } = await this.parse(Logout);
|
|
20
|
+
this.flags = flags;
|
|
21
|
+
this.configAggregator = await core_1.ConfigAggregator.create();
|
|
21
22
|
const remover = await core_1.AuthRemover.create();
|
|
22
|
-
const targetUsername = this.flags.targetusername
|
|
23
|
-
? this.flags.targetusername
|
|
24
|
-
: this.configAggregator.getInfo(core_1.OrgConfigProperties.TARGET_ORG).value;
|
|
25
23
|
let usernames;
|
|
26
24
|
try {
|
|
27
|
-
|
|
25
|
+
const targetUsername = this.flags['target-org'] ?? this.configAggregator.getInfo(core_1.OrgConfigProperties.TARGET_ORG).value;
|
|
26
|
+
usernames = (this.shouldFindAllAuths()
|
|
28
27
|
? Object.keys(remover.findAllAuths())
|
|
29
|
-
: [(await remover.findAuth(targetUsername)).username
|
|
28
|
+
: [(await remover.findAuth(targetUsername))?.username ?? targetUsername]).filter((username) => username);
|
|
30
29
|
}
|
|
31
30
|
catch (e) {
|
|
32
31
|
// keep the error name the same for SFDX
|
|
@@ -34,13 +33,13 @@ class Logout extends command_1.SfdxCommand {
|
|
|
34
33
|
err.name = 'NoOrgFound';
|
|
35
34
|
throw core_1.SfError.wrap(err);
|
|
36
35
|
}
|
|
37
|
-
if (await this.
|
|
36
|
+
if (await this.shouldRunLogoutCommand(usernames)) {
|
|
38
37
|
for (const username of usernames) {
|
|
39
38
|
// run sequentially to avoid configFile concurrency issues
|
|
40
39
|
// eslint-disable-next-line no-await-in-loop
|
|
41
40
|
await remover.removeAuth(username);
|
|
42
41
|
}
|
|
43
|
-
this.
|
|
42
|
+
this.logSuccess(messages.getMessage('logoutOrgCommandSuccess', [usernames.join(os.EOL)]));
|
|
44
43
|
return usernames;
|
|
45
44
|
}
|
|
46
45
|
else {
|
|
@@ -48,30 +47,52 @@ class Logout extends command_1.SfdxCommand {
|
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
shouldFindAllAuths() {
|
|
51
|
-
return !!this.flags.all || (!this.flags
|
|
50
|
+
return !!this.flags.all || (!this.flags['target-org'] && core_1.Global.getEnvironmentMode() === core_1.Mode.DEMO);
|
|
52
51
|
}
|
|
53
|
-
async
|
|
54
|
-
const orgsToDelete =
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
async shouldRunLogoutCommand(usernames) {
|
|
53
|
+
const orgsToDelete = usernames.filter(ts_types_1.isString);
|
|
54
|
+
if (orgsToDelete.length === 0) {
|
|
55
|
+
this.log(messages.getMessage('logoutOrgCommandNoOrgsFound'));
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
const message = messages.getMessage('logoutCommandYesNo', [
|
|
59
|
+
orgsToDelete.join(os.EOL),
|
|
60
|
+
this.config.bin,
|
|
61
|
+
this.config.bin,
|
|
62
|
+
this.config.bin,
|
|
63
|
+
]);
|
|
64
|
+
return this.shouldRunCommand(this.flags['no-prompt'], message, false);
|
|
57
65
|
}
|
|
58
66
|
}
|
|
59
67
|
exports.default = Logout;
|
|
68
|
+
Logout.summary = messages.getMessage('summary');
|
|
60
69
|
Logout.description = messages.getMessage('description');
|
|
61
|
-
Logout.examples = messages.
|
|
62
|
-
Logout.
|
|
70
|
+
Logout.examples = messages.getMessages('examples');
|
|
71
|
+
Logout.deprecateAliases = true;
|
|
63
72
|
Logout.aliases = ['force:auth:logout'];
|
|
64
|
-
Logout.
|
|
65
|
-
|
|
73
|
+
Logout.flags = {
|
|
74
|
+
// taking control over target-org vs using a org flag from sf-plugins-core to guarantee
|
|
75
|
+
// idempotency of the command
|
|
76
|
+
'target-org': sf_plugins_core_1.Flags.string({
|
|
77
|
+
summary: messages.getMessage('flags.target-org.summary'),
|
|
78
|
+
char: 'o',
|
|
79
|
+
aliases: ['targetusername', 'u'],
|
|
80
|
+
deprecateAliases: true,
|
|
81
|
+
}),
|
|
82
|
+
all: sf_plugins_core_1.Flags.boolean({
|
|
66
83
|
char: 'a',
|
|
67
|
-
|
|
68
|
-
|
|
84
|
+
summary: messages.getMessage('all'),
|
|
85
|
+
description: messages.getMessage('allLong'),
|
|
69
86
|
required: false,
|
|
87
|
+
exclusive: ['target-org'],
|
|
70
88
|
}),
|
|
71
|
-
|
|
89
|
+
'no-prompt': sf_plugins_core_1.Flags.boolean({
|
|
72
90
|
char: 'p',
|
|
73
|
-
|
|
91
|
+
summary: commonMessages.getMessage('noPrompt'),
|
|
74
92
|
required: false,
|
|
93
|
+
deprecateAliases: true,
|
|
94
|
+
aliases: ['noprompt'],
|
|
75
95
|
}),
|
|
96
|
+
loglevel: sf_plugins_core_1.loglevel,
|
|
76
97
|
};
|
|
77
98
|
//# sourceMappingURL=logout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/commands/auth/logout.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,yBAAyB;AACzB,
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/commands/auth/logout.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,yBAAyB;AACzB,2CAAuH;AACvH,iEAA8D;AAE9D,mDAAgD;AAChD,2DAAwD;AAExD,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAC5C,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,CAAC,yBAAyB,EAAE,QAAQ,CAAC,CAAC;AAC5E,MAAM,cAAc,GAAG,eAAQ,CAAC,YAAY,CAAC,yBAAyB,EAAE,UAAU,CAAC,CAAC;AAIpF,MAAqB,MAAO,SAAQ,iCAAkC;IAoC7D,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC3C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,gBAAgB,GAAG,MAAM,uBAAgB,CAAC,MAAM,EAAE,CAAC;QACxD,MAAM,OAAO,GAAG,MAAM,kBAAW,CAAC,MAAM,EAAE,CAAC;QAE3C,IAAI,SAA4B,CAAC;QACjC,IAAI;YACF,MAAM,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AAC,OAAO,CAAC;QACjB,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC;QACnC,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC;QAC3C,QAAQ,EAAE,KAAK;QACf,SAAS,EAAE,CAAC,YAAY,CAAC;KAC1B,CAAC;IACF,WAAW,EAAE,uBAAK,CAAC,OAAO,CAAC;QACzB,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,cAAc,CAAC,UAAU,CAAC,UAAU,CAAC;QAC9C,QAAQ,EAAE,KAAK;QACf,gBAAgB,EAAE,IAAI;QACtB,OAAO,EAAE,CAAC,UAAU,CAAC;KACtB,CAAC;IACF,QAAQ,EAAR,0BAAQ;CACT,CAAC"}
|
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import { FlagsConfig, SfdxCommand } from '@salesforce/command';
|
|
2
1
|
import { AuthFields } from '@salesforce/core';
|
|
3
|
-
|
|
2
|
+
import { AuthBaseCommand } from '../../../authBaseCommand';
|
|
3
|
+
export default class Store extends AuthBaseCommand<AuthFields> {
|
|
4
|
+
static readonly summary: string;
|
|
4
5
|
static readonly description: string;
|
|
5
6
|
static readonly examples: string[];
|
|
6
7
|
static aliases: string[];
|
|
7
|
-
static readonly
|
|
8
|
+
static readonly flags: {
|
|
9
|
+
'sfdx-url-file': import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
|
+
'set-default-dev-hub': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
'set-default': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
alias: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
13
|
+
'no-prompt': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
14
|
+
loglevel: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
15
|
+
};
|
|
8
16
|
run(): Promise<AuthFields>;
|
|
9
17
|
}
|
|
@@ -6,21 +6,21 @@
|
|
|
6
6
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
const os = require("os");
|
|
10
9
|
const promises_1 = require("fs/promises");
|
|
11
|
-
const
|
|
12
|
-
const command_1 = require("@salesforce/command");
|
|
10
|
+
const sf_plugins_core_1 = require("@salesforce/sf-plugins-core");
|
|
13
11
|
const core_1 = require("@salesforce/core");
|
|
14
|
-
const
|
|
12
|
+
const kit_1 = require("@salesforce/kit");
|
|
13
|
+
const authBaseCommand_1 = require("../../../authBaseCommand");
|
|
15
14
|
core_1.Messages.importMessagesDirectory(__dirname);
|
|
16
15
|
const messages = core_1.Messages.loadMessages('@salesforce/plugin-auth', 'sfdxurl.store');
|
|
17
16
|
const commonMessages = core_1.Messages.loadMessages('@salesforce/plugin-auth', 'messages');
|
|
18
17
|
const AUTH_URL_FORMAT = 'force://<clientId>:<clientSecret>:<refreshToken>@<instanceUrl>';
|
|
19
|
-
class Store extends
|
|
18
|
+
class Store extends authBaseCommand_1.AuthBaseCommand {
|
|
20
19
|
async run() {
|
|
21
|
-
|
|
20
|
+
const { flags } = await this.parse(Store);
|
|
21
|
+
if (await this.shouldExitCommand(flags['no-prompt']))
|
|
22
22
|
return {};
|
|
23
|
-
const authFile =
|
|
23
|
+
const authFile = flags['sfdx-url-file'];
|
|
24
24
|
const sfdxAuthUrl = authFile.endsWith('.json') ? await getUrlFromJson(authFile) : await (0, promises_1.readFile)(authFile, 'utf8');
|
|
25
25
|
if (!sfdxAuthUrl) {
|
|
26
26
|
throw new Error(`Error getting the auth URL from file ${authFile}. Please ensure it meets the description shown in the documentation for this command.`);
|
|
@@ -29,50 +29,63 @@ class Store extends command_1.SfdxCommand {
|
|
|
29
29
|
const authInfo = await core_1.AuthInfo.create({ oauth2Options });
|
|
30
30
|
await authInfo.save();
|
|
31
31
|
await authInfo.handleAliasAndDefaultSettings({
|
|
32
|
-
alias:
|
|
33
|
-
setDefault:
|
|
34
|
-
setDefaultDevHub:
|
|
32
|
+
alias: flags.alias,
|
|
33
|
+
setDefault: flags['set-default'],
|
|
34
|
+
setDefaultDevHub: flags['set-default-dev-hub'],
|
|
35
35
|
});
|
|
36
36
|
const result = authInfo.getFields(true);
|
|
37
37
|
// ensure the clientSecret field... even if it is empty
|
|
38
38
|
result.clientSecret = result.clientSecret ?? '';
|
|
39
39
|
await core_1.AuthInfo.identifyPossibleScratchOrgs(result, authInfo);
|
|
40
40
|
const successMsg = commonMessages.getMessage('authorizeCommandSuccess', [result.username, result.orgId]);
|
|
41
|
-
this.
|
|
41
|
+
this.logSuccess(successMsg);
|
|
42
42
|
return result;
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
exports.default = Store;
|
|
46
|
+
Store.summary = messages.getMessage('summary');
|
|
46
47
|
Store.description = messages.getMessage('description', [AUTH_URL_FORMAT]);
|
|
47
|
-
Store.examples = messages.
|
|
48
|
+
Store.examples = messages.getMessages('examples');
|
|
48
49
|
Store.aliases = ['force:auth:sfdxurl:store'];
|
|
49
|
-
Store.
|
|
50
|
-
|
|
50
|
+
Store.flags = {
|
|
51
|
+
'sfdx-url-file': sf_plugins_core_1.Flags.file({
|
|
51
52
|
char: 'f',
|
|
52
|
-
|
|
53
|
+
summary: messages.getMessage('file'),
|
|
53
54
|
required: true,
|
|
55
|
+
deprecateAliases: true,
|
|
56
|
+
aliases: ['sfdxurlfile'],
|
|
54
57
|
}),
|
|
55
|
-
|
|
58
|
+
'set-default-dev-hub': sf_plugins_core_1.Flags.boolean({
|
|
56
59
|
char: 'd',
|
|
57
|
-
|
|
60
|
+
summary: commonMessages.getMessage('setDefaultDevHub'),
|
|
61
|
+
deprecateAliases: true,
|
|
62
|
+
aliases: ['setdefaultdevhub'],
|
|
58
63
|
}),
|
|
59
|
-
|
|
64
|
+
'set-default': sf_plugins_core_1.Flags.boolean({
|
|
60
65
|
char: 's',
|
|
61
|
-
|
|
66
|
+
summary: commonMessages.getMessage('setDefaultUsername'),
|
|
67
|
+
deprecateAliases: true,
|
|
68
|
+
aliases: ['setdefaultusername'],
|
|
62
69
|
}),
|
|
63
|
-
|
|
70
|
+
alias: sf_plugins_core_1.Flags.string({
|
|
64
71
|
char: 'a',
|
|
65
|
-
|
|
72
|
+
summary: commonMessages.getMessage('setAlias'),
|
|
73
|
+
deprecateAliases: true,
|
|
74
|
+
aliases: ['setalias'],
|
|
66
75
|
}),
|
|
67
|
-
|
|
76
|
+
'no-prompt': sf_plugins_core_1.Flags.boolean({
|
|
68
77
|
char: 'p',
|
|
69
|
-
|
|
78
|
+
summary: commonMessages.getMessage('noPromptAuth'),
|
|
70
79
|
required: false,
|
|
71
80
|
hidden: true,
|
|
81
|
+
deprecateAliases: true,
|
|
82
|
+
aliases: ['noprompt'],
|
|
72
83
|
}),
|
|
84
|
+
loglevel: sf_plugins_core_1.loglevel,
|
|
73
85
|
};
|
|
74
86
|
const getUrlFromJson = async (authFile) => {
|
|
75
|
-
const
|
|
87
|
+
const jsonContents = await (0, promises_1.readFile)(authFile, 'utf8');
|
|
88
|
+
const authFileJson = (0, kit_1.parseJson)(jsonContents);
|
|
76
89
|
return authFileJson.result?.sfdxAuthUrl ?? authFileJson.sfdxAuthUrl;
|
|
77
90
|
};
|
|
78
91
|
//# sourceMappingURL=store.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../../../src/commands/auth/sfdxurl/store.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../../../src/commands/auth/sfdxurl/store.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,0CAAuC;AACvC,iEAA8D;AAC9D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AO,CAAC;QAC3B,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,cAAc,CAAC,UAAU,CAAC,oBAAoB,CAAC;QACxD,gBAAgB,EAAE,IAAI;QACtB,OAAO,EAAE,CAAC,oBAAoB,CAAC;KAChC,CAAC;IACF,KAAK,EAAE,uBAAK,CAAC,MAAM,CAAC;QAClB,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,cAAc,CAAC,UAAU,CAAC,UAAU,CAAC;QAC9C,gBAAgB,EAAE,IAAI;QACtB,OAAO,EAAE,CAAC,UAAU,CAAC;KACtB,CAAC;IACF,WAAW,EAAE,uBAAK,CAAC,OAAO,CAAC;QACzB,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,cAAc,CAAC,UAAU,CAAC,cAAc,CAAC;QAClD,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,IAAI;QACZ,gBAAgB,EAAE,IAAI;QACtB,OAAO,EAAE,CAAC,UAAU,CAAC;KACtB,CAAC;IACF,QAAQ,EAAR,0BAAQ;CACT,CAAC;AAsCJ,MAAM,cAAc,GAAG,KAAK,EAAE,QAAgB,EAAmB,EAAE;IACjE,MAAM,YAAY,GAAG,MAAM,IAAA,mBAAQ,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACtD,MAAM,YAAY,GAAG,IAAA,eAAS,EAAC,YAAY,CAAa,CAAC;IACzD,OAAO,YAAY,CAAC,MAAM,EAAE,WAAW,IAAI,YAAY,CAAC,WAAW,CAAC;AACtE,CAAC,CAAC"}
|
|
@@ -1,10 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
2
|
import { AuthFields } from '@salesforce/core';
|
|
3
|
-
|
|
3
|
+
import { Interfaces } from '@oclif/core';
|
|
4
|
+
import { AuthBaseCommand } from '../../../authBaseCommand';
|
|
5
|
+
export default class Login extends AuthBaseCommand<AuthFields> {
|
|
6
|
+
static readonly summary: string;
|
|
4
7
|
static readonly description: string;
|
|
5
8
|
static readonly examples: string[];
|
|
9
|
+
static readonly deprecateAliases = true;
|
|
6
10
|
static aliases: string[];
|
|
7
|
-
static readonly
|
|
11
|
+
static readonly flags: {
|
|
12
|
+
browser: Interfaces.OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
13
|
+
'client-id': Interfaces.OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
14
|
+
'instance-url': Interfaces.OptionFlag<import("url").URL | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
15
|
+
'set-default-dev-hub': Interfaces.BooleanFlag<boolean>;
|
|
16
|
+
'set-default': Interfaces.BooleanFlag<boolean>;
|
|
17
|
+
alias: Interfaces.OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
18
|
+
'disable-masking': Interfaces.BooleanFlag<boolean>;
|
|
19
|
+
'no-prompt': Interfaces.BooleanFlag<boolean>;
|
|
20
|
+
loglevel: Interfaces.OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
21
|
+
};
|
|
22
|
+
private flags;
|
|
8
23
|
run(): Promise<AuthFields>;
|
|
9
24
|
private executeLoginFlow;
|
|
10
25
|
}
|
|
@@ -6,42 +6,43 @@
|
|
|
6
6
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
const os = require("os");
|
|
10
9
|
const open = require("open");
|
|
11
|
-
const
|
|
10
|
+
const sf_plugins_core_1 = require("@salesforce/sf-plugins-core");
|
|
12
11
|
const core_1 = require("@salesforce/core");
|
|
13
12
|
const kit_1 = require("@salesforce/kit");
|
|
14
13
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
15
|
-
const
|
|
14
|
+
const authBaseCommand_1 = require("../../../authBaseCommand");
|
|
16
15
|
const common_1 = require("../../../common");
|
|
17
16
|
core_1.Messages.importMessagesDirectory(__dirname);
|
|
18
17
|
const messages = core_1.Messages.loadMessages('@salesforce/plugin-auth', 'web.login');
|
|
19
18
|
const commonMessages = core_1.Messages.loadMessages('@salesforce/plugin-auth', 'messages');
|
|
20
|
-
class Login extends
|
|
19
|
+
class Login extends authBaseCommand_1.AuthBaseCommand {
|
|
21
20
|
async run() {
|
|
21
|
+
const { flags } = await this.parse(Login);
|
|
22
|
+
this.flags = flags;
|
|
22
23
|
if (isSFDXContainerMode()) {
|
|
23
24
|
throw new core_1.SfError(messages.getMessage('deviceWarning'), 'DEVICE_WARNING');
|
|
24
25
|
}
|
|
25
|
-
if (await
|
|
26
|
+
if (await this.shouldExitCommand(flags['no-prompt']))
|
|
26
27
|
return {};
|
|
27
28
|
const oauthConfig = {
|
|
28
|
-
loginUrl: await common_1.Common.resolveLoginUrl((0, ts_types_1.get)(
|
|
29
|
-
clientId:
|
|
29
|
+
loginUrl: await common_1.Common.resolveLoginUrl((0, ts_types_1.get)(flags['instance-url'], 'href', null)),
|
|
30
|
+
clientId: flags.clientid,
|
|
30
31
|
};
|
|
31
|
-
if (
|
|
32
|
-
oauthConfig.clientSecret = await
|
|
32
|
+
if (flags.clientid) {
|
|
33
|
+
oauthConfig.clientSecret = await this.askForClientSecret(flags['disable-masking']);
|
|
33
34
|
}
|
|
34
35
|
try {
|
|
35
36
|
const authInfo = await this.executeLoginFlow(oauthConfig);
|
|
36
37
|
await authInfo.handleAliasAndDefaultSettings({
|
|
37
|
-
alias:
|
|
38
|
-
setDefault:
|
|
39
|
-
setDefaultDevHub:
|
|
38
|
+
alias: flags.alias,
|
|
39
|
+
setDefault: flags['set-default'],
|
|
40
|
+
setDefaultDevHub: flags['set-default-dev-hub'],
|
|
40
41
|
});
|
|
41
42
|
const fields = authInfo.getFields(true);
|
|
42
43
|
await core_1.AuthInfo.identifyPossibleScratchOrgs(fields, authInfo);
|
|
43
44
|
const successMsg = commonMessages.getMessage('authorizeCommandSuccess', [fields.username, fields.orgId]);
|
|
44
|
-
this.
|
|
45
|
+
this.logSuccess(successMsg);
|
|
45
46
|
return fields;
|
|
46
47
|
}
|
|
47
48
|
catch (err) {
|
|
@@ -66,45 +67,62 @@ class Login extends command_1.SfdxCommand {
|
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
69
|
exports.default = Login;
|
|
70
|
+
Login.summary = messages.getMessage('summary');
|
|
69
71
|
Login.description = messages.getMessage('description');
|
|
70
|
-
Login.examples = messages.
|
|
72
|
+
Login.examples = messages.getMessages('examples');
|
|
73
|
+
Login.deprecateAliases = true;
|
|
71
74
|
Login.aliases = ['force:auth:web:login'];
|
|
72
|
-
Login.
|
|
73
|
-
browser:
|
|
75
|
+
Login.flags = {
|
|
76
|
+
browser: sf_plugins_core_1.Flags.string({
|
|
74
77
|
char: 'b',
|
|
75
|
-
|
|
78
|
+
summary: messages.getMessage('browser'),
|
|
76
79
|
options: ['chrome', 'edge', 'firefox'], // These are ones supported by "open" package
|
|
77
80
|
}),
|
|
78
|
-
|
|
81
|
+
'client-id': sf_plugins_core_1.Flags.string({
|
|
79
82
|
char: 'i',
|
|
80
|
-
|
|
83
|
+
summary: commonMessages.getMessage('clientId'),
|
|
84
|
+
deprecateAliases: true,
|
|
85
|
+
aliases: ['clientid'],
|
|
81
86
|
}),
|
|
82
|
-
|
|
87
|
+
'instance-url': sf_plugins_core_1.Flags.url({
|
|
83
88
|
char: 'r',
|
|
84
|
-
|
|
89
|
+
summary: commonMessages.getMessage('instanceUrl'),
|
|
90
|
+
deprecateAliases: true,
|
|
91
|
+
aliases: ['instanceurl'],
|
|
85
92
|
}),
|
|
86
|
-
|
|
93
|
+
'set-default-dev-hub': sf_plugins_core_1.Flags.boolean({
|
|
87
94
|
char: 'd',
|
|
88
|
-
|
|
95
|
+
summary: commonMessages.getMessage('setDefaultDevHub'),
|
|
96
|
+
deprecateAliases: true,
|
|
97
|
+
aliases: ['setdefaultdevhubusername'],
|
|
89
98
|
}),
|
|
90
|
-
|
|
99
|
+
'set-default': sf_plugins_core_1.Flags.boolean({
|
|
91
100
|
char: 's',
|
|
92
|
-
|
|
101
|
+
summary: commonMessages.getMessage('setDefaultUsername'),
|
|
102
|
+
deprecateAliases: true,
|
|
103
|
+
aliases: ['setdefaultusername'],
|
|
93
104
|
}),
|
|
94
|
-
|
|
105
|
+
alias: sf_plugins_core_1.Flags.string({
|
|
95
106
|
char: 'a',
|
|
96
|
-
|
|
107
|
+
summary: commonMessages.getMessage('setAlias'),
|
|
108
|
+
deprecateAliases: true,
|
|
109
|
+
aliases: ['setalias'],
|
|
97
110
|
}),
|
|
98
|
-
|
|
99
|
-
|
|
111
|
+
'disable-masking': sf_plugins_core_1.Flags.boolean({
|
|
112
|
+
summary: commonMessages.getMessage('disableMasking'),
|
|
100
113
|
hidden: true,
|
|
114
|
+
deprecateAliases: true,
|
|
115
|
+
aliases: ['disablemasking'],
|
|
101
116
|
}),
|
|
102
|
-
|
|
117
|
+
'no-prompt': sf_plugins_core_1.Flags.boolean({
|
|
103
118
|
char: 'p',
|
|
104
|
-
|
|
119
|
+
summary: commonMessages.getMessage('noPromptAuth'),
|
|
105
120
|
required: false,
|
|
106
121
|
hidden: true,
|
|
122
|
+
deprecateAliases: true,
|
|
123
|
+
aliases: ['noprompt'],
|
|
107
124
|
}),
|
|
125
|
+
loglevel: sf_plugins_core_1.loglevel,
|
|
108
126
|
};
|
|
109
127
|
const isSFDXContainerMode = () => {
|
|
110
128
|
const env = new kit_1.Env();
|