@codiac.io/codiac-cli 1.3.121 → 1.3.123

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.
Files changed (87) hide show
  1. package/README.md +1 -1
  2. package/dist/apis/codiac-api/i-client.d.ts +12 -0
  3. package/dist/apis/codiac-api-nats/gen/client.d.ts +5 -0
  4. package/dist/apis/codiac-api-nats/gen/client.js +22 -8
  5. package/dist/apis/codiac-api-nats/gen/client.js.map +1 -1
  6. package/dist/apis/codiac-api-nats/gen/config.d.ts +2 -1
  7. package/dist/apis/codiac-api-nats/gen/config.js +3 -2
  8. package/dist/apis/codiac-api-nats/gen/config.js.map +1 -1
  9. package/dist/apis/codiac-relay/gen/contracts/types.gen.d.ts +10 -3
  10. package/dist/apis/codiac-relay/gen/contracts/types.gen.js.map +1 -1
  11. package/dist/apis/codiac-relay-nats/common/creds.d.ts +8 -0
  12. package/dist/apis/codiac-relay-nats/common/creds.js +19 -0
  13. package/dist/apis/codiac-relay-nats/common/creds.js.map +1 -0
  14. package/dist/apis/codiac-relay-nats/common/token-utils.d.ts +11 -0
  15. package/dist/apis/codiac-relay-nats/common/token-utils.js +84 -0
  16. package/dist/apis/codiac-relay-nats/common/token-utils.js.map +1 -0
  17. package/dist/apis/codiac-relay-nats/common/token.d.ts +4 -0
  18. package/dist/apis/codiac-relay-nats/common/token.js +16 -0
  19. package/dist/apis/codiac-relay-nats/common/token.js.map +1 -0
  20. package/dist/apis/codiac-relay-nats/common/types.d.ts +8 -0
  21. package/dist/apis/codiac-relay-nats/common/types.js +3 -0
  22. package/dist/apis/codiac-relay-nats/common/types.js.map +1 -0
  23. package/dist/apis/codiac-relay-nats/common/utils.d.ts +56 -0
  24. package/dist/apis/codiac-relay-nats/common/utils.js +323 -0
  25. package/dist/apis/codiac-relay-nats/common/utils.js.map +1 -0
  26. package/dist/apis/codiac-relay-nats/gen/client.d.ts +995 -0
  27. package/dist/apis/codiac-relay-nats/gen/client.js +5750 -0
  28. package/dist/apis/codiac-relay-nats/gen/client.js.map +1 -0
  29. package/dist/apis/codiac-relay-nats/gen/config.d.ts +19 -0
  30. package/dist/apis/codiac-relay-nats/gen/config.js +19 -0
  31. package/dist/apis/codiac-relay-nats/gen/config.js.map +1 -0
  32. package/dist/apis/codiac-relay-nats/gen/contracts/index.d.ts +1 -0
  33. package/dist/apis/codiac-relay-nats/gen/contracts/index.js +6 -0
  34. package/dist/apis/codiac-relay-nats/gen/contracts/index.js.map +1 -0
  35. package/dist/apis/codiac-relay-nats/gen/contracts/transformers.gen.d.ts +315 -0
  36. package/dist/apis/codiac-relay-nats/gen/contracts/transformers.gen.js +3656 -0
  37. package/dist/apis/codiac-relay-nats/gen/contracts/transformers.gen.js.map +1 -0
  38. package/dist/apis/codiac-relay-nats/gen/contracts/types.gen.d.ts +16515 -0
  39. package/dist/apis/codiac-relay-nats/gen/contracts/types.gen.js +408 -0
  40. package/dist/apis/codiac-relay-nats/gen/contracts/types.gen.js.map +1 -0
  41. package/dist/apis/codiac-relay-nats/gen/contracts.ng.d.ts +4517 -0
  42. package/dist/apis/codiac-relay-nats/gen/contracts.ng.js +573 -0
  43. package/dist/apis/codiac-relay-nats/gen/contracts.ng.js.map +1 -0
  44. package/dist/apis/codiac-relay-nats/index.d.ts +3 -0
  45. package/dist/apis/codiac-relay-nats/index.js +7 -0
  46. package/dist/apis/codiac-relay-nats/index.js.map +1 -0
  47. package/dist/bootstrapper-for-api-clients.d.ts +6 -0
  48. package/dist/bootstrapper-for-api-clients.js +110 -0
  49. package/dist/bootstrapper-for-api-clients.js.map +1 -0
  50. package/dist/bootstrapper-for-enterprise-commands.js +2 -59
  51. package/dist/bootstrapper-for-enterprise-commands.js.map +1 -1
  52. package/dist/command-base-enterprise.js +17 -4
  53. package/dist/command-base-enterprise.js.map +1 -1
  54. package/dist/command-base-exec-tenant.js +11 -4
  55. package/dist/command-base-exec-tenant.js.map +1 -1
  56. package/dist/commands/asset/view.js +1 -1
  57. package/dist/commands/asset/view.js.map +1 -1
  58. package/dist/commands/cluster/connect.js +1 -1
  59. package/dist/commands/cluster/connect.js.map +1 -1
  60. package/dist/commands/csp/login.d.ts +25 -6
  61. package/dist/commands/csp/login.js +186 -142
  62. package/dist/commands/csp/login.js.map +1 -1
  63. package/dist/commands/csp/logout.d.ts +5 -3
  64. package/dist/commands/csp/logout.js +27 -16
  65. package/dist/commands/csp/logout.js.map +1 -1
  66. package/dist/commands/noc/cluster/forget.js +3 -3
  67. package/dist/commands/noc/cluster/forget.js.map +1 -1
  68. package/dist/ops/k8s/k8s-utils.d.ts +2 -1
  69. package/dist/ops/k8s/k8s-utils.js +4 -3
  70. package/dist/ops/k8s/k8s-utils.js.map +1 -1
  71. package/dist/ops/k8s/kube-config-utils.d.ts +2 -1
  72. package/dist/ops/k8s/kube-config-utils.js +1 -1
  73. package/dist/ops/k8s/kube-config-utils.js.map +1 -1
  74. package/dist/read-stdin.js +7 -6
  75. package/dist/read-stdin.js.map +1 -1
  76. package/dist/relay/relay-container.js +1 -1
  77. package/dist/sdk/i-login-configurator.d.ts +2 -1
  78. package/dist/sdk-adapters/azure/az-interactive-login-configurator.d.ts +2 -2
  79. package/dist/sdk-adapters/azure/az-interactive-login-configurator.js +2 -2
  80. package/dist/sdk-adapters/azure/az-interactive-login-configurator.js.map +1 -1
  81. package/dist/sdk-adapters/docker-hub/docker-hub-resource-configurator.js +1 -0
  82. package/dist/sdk-adapters/docker-hub/docker-hub-resource-configurator.js.map +1 -1
  83. package/dist/uilogic/cloud-provider-contextualizer.d.ts +5 -1
  84. package/dist/uilogic/cloud-provider-contextualizer.js +48 -7
  85. package/dist/uilogic/cloud-provider-contextualizer.js.map +1 -1
  86. package/oclif.manifest.json +60 -11
  87. package/package.json +2 -2
@@ -1,157 +1,197 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CLIENT_CREDENTIALS = void 0;
3
4
  const tslib_1 = require("tslib");
4
5
  const _ = require("lodash");
5
6
  const core_1 = require("@oclif/core");
6
- const ops_1 = require("../../ops");
7
7
  const contracts_1 = require("../../apis/codiac-relay/contracts");
8
- const command_base_enterprise_1 = require("../../command-base-enterprise");
9
- const cloud_provider_contextualizer_1 = require("../../uilogic/cloud-provider-contextualizer");
10
- const read_stdin_1 = require("../../read-stdin");
11
8
  const type_safety_utils_1 = require("../../uilogic/type-safety-utils");
12
- class CspLogin extends command_base_enterprise_1.CommandBaseEnterprise {
13
- get uiCloudProvider() {
14
- if (this.__uiCloudProvider_backing === undefined) {
15
- this.__uiCloudProvider_backing = this.ioc.get(cloud_provider_contextualizer_1.CloudProviderContextualizer);
16
- }
17
- return this.__uiCloudProvider_backing;
9
+ const command_base_exec_tenant_1 = require("../../command-base-exec-tenant");
10
+ const config_ui_utils_1 = require("../../uilogic/config-ui-utils");
11
+ /** wtf: This because we cant use `CredentialType.client_credentials`.
12
+ *
13
+ * Using the enum `CredentialType.client_credentials` fails with:
14
+ *
15
+ * *"Cannot read properties of undefined (reading 'client_credentials')"*
16
+ */
17
+ exports.CLIENT_CREDENTIALS = "client_credentials";
18
+ class CspLogin extends command_base_exec_tenant_1.CommandBaseExecTenant {
19
+ // static readonly USERNAME_PLACEHOLDER = "<CspTenantClientId>";
20
+ // protected bootstrap(): void {
21
+ // super.bootstrap();
22
+ // CloudProviderContextualizer.bootstrap(this.ioc);
23
+ // }
24
+ captureArgs() {
25
+ var _a, _b, _c;
26
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
27
+ const { args, flags } = yield this.parse(CspLogin);
28
+ let partial = {};
29
+ if (args.provider) {
30
+ partial.providerCode = type_safety_utils_1.TypeSafetyUtils.toEnum(contracts_1.CloudProviderEnum, args.provider);
31
+ if (partial.providerCode == undefined)
32
+ throw new Error("Unrecognized cloud provider.");
33
+ }
34
+ // TODO: We should build this with better decoupled principles
35
+ // (eg: delegate to a ui provider instead of if-aws),
36
+ // but not worth it until there's more than just this one single outlier.
37
+ if (partial.providerCode == contracts_1.CloudProviderEnum.aws && flags['aws-session-token']) {
38
+ partial.proprietaryInput = { sessionToken: flags['aws-session-token'] };
39
+ }
40
+ if (flags.subscriptionId)
41
+ partial.providerSubscription = flags.subscriptionId.trim();
42
+ if (flags.tenantId)
43
+ partial.providerTenant = flags.tenantId.trim();
44
+ if (flags.user) {
45
+ partial.username = flags.user;
46
+ }
47
+ if (flags.clientSecret) {
48
+ partial.credsType = exports.CLIENT_CREDENTIALS;
49
+ // partial.username = partial.username ?? CspLogin.USERNAME_PLACEHOLDER; // <-- this is not a magic string, just a placeholder.
50
+ if (flags.silent == true) {
51
+ // silent mode, with piped input
52
+ partial.secret = (_a = this.pipedInput) === null || _a === void 0 ? void 0 : _a.trim(); // (await readStdin())?.trim();
53
+ this.logger.debug("Secret captured from stdin stream in command [csp login].");
54
+ if (_.isEmpty(partial.secret)) {
55
+ throw new Error("Missing client secret. In silent mode, clientSecret must be passed in via stdin (ie: piped input).");
56
+ }
57
+ }
58
+ }
59
+ // ---------------------------------------------------------------
60
+ // TODO: move everything from here down into the base class
61
+ // ---------------------------------------------------------------
62
+ const interactionMode = (this.pipedInput) ? config_ui_utils_1.InteractionModes.silent : (_c = (_b = undefined !== null && undefined !== void 0 ? undefined : (flags.echo ? config_ui_utils_1.InteractionModes.echo : undefined)) !== null && _b !== void 0 ? _b : (flags["to-script"] ? config_ui_utils_1.InteractionModes.toscript : undefined)) !== null && _c !== void 0 ? _c : (flags.silent ? config_ui_utils_1.InteractionModes.silent : undefined);
63
+ const takeDefaults = flags['take-defaults'];
64
+ return [partial, interactionMode, takeDefaults];
65
+ });
18
66
  }
19
- bootstrap() {
20
- super.bootstrap();
21
- cloud_provider_contextualizer_1.CloudProviderContextualizer.bootstrap(this.ioc);
67
+ buildCandidate_silently(partial, rootMap) {
68
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
69
+ if (partial.providerCode == undefined) {
70
+ throw new Error(`You must specify a cloud provider.`);
71
+ }
72
+ if (_.isEmpty(partial.secret)) {
73
+ throw new Error(`No clientSecret/password provided (clientSecret/password can be provided interatively or via the stdin process stream).`);
74
+ }
75
+ const cspTenant = yield this.cspContextualizer.ensureCspTenantContext(this._codiacApi, partial.providerCode, partial.providerSubscription, partial.providerTenant, true);
76
+ partial.providerSubscription = cspTenant.subscriptionId;
77
+ partial.providerTenant = cspTenant.tenantId;
78
+ let candidate;
79
+ if (partial.proprietaryInput) {
80
+ candidate = this.cspContextualizer.assembleLoginRequest(this.ioc, partial.providerCode, partial.username, partial.secret, cspTenant.subscriptionId, partial.proprietaryInput);
81
+ }
82
+ else {
83
+ candidate = {
84
+ providerCode: partial.providerCode,
85
+ username: partial.username,
86
+ secret: partial.secret,
87
+ providerSubscription: partial.providerSubscription,
88
+ };
89
+ if (partial.credsType)
90
+ candidate.credsType = partial.credsType;
91
+ if (partial.providerTenant)
92
+ candidate.providerTenant = partial.providerTenant;
93
+ }
94
+ return candidate;
95
+ });
22
96
  }
23
- run() {
97
+ buildCandidate_interactively(partial, takeDefaults, rootMap) {
24
98
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
25
- return new Promise((resolve, reject) => tslib_1.__awaiter(this, void 0, void 0, function* () {
26
- var _a;
99
+ // Select the CSP
100
+ if (partial.providerCode == undefined) {
101
+ // Select interactively
102
+ let allPvds = Object.values(contracts_1.CloudProviderEnum); //this.cspUiFactory.getAllClusterProviders(this.ioc); // TODO: this call is currently limited to cluster providers - we need the comprehensive list of CSPs in use.
103
+ _.remove(allPvds, x => x == contracts_1.CloudProviderEnum.other);
104
+ _.remove(allPvds, x => x == contracts_1.CloudProviderEnum.localMachine);
105
+ partial.providerCode = yield this.cspContextualizer.promptForCloudProvider(allPvds, undefined);
106
+ }
107
+ // prompt for password/secret if needed
108
+ if (partial.credsType == exports.CLIENT_CREDENTIALS) {
109
+ // Client Credentials auth flow (aka: service principal creds)
110
+ while (partial.secret == undefined || _.isEmpty(partial.secret)) {
111
+ partial.secret = yield this._ui.promptPassword("clientSecret", "Client Secret: ");
112
+ if (_.isEmpty(partial.secret)) {
113
+ this._ui.userMessage(`No client secret provided (client secret can be provided interactively or via the stdin process stream).`);
114
+ }
115
+ }
116
+ }
117
+ // Csp Tenant
118
+ const cspTenant = yield this.cspContextualizer.ensureCspTenantContext(this._codiacApi, partial.providerCode, partial.providerSubscription, partial.providerTenant, false);
119
+ partial.providerSubscription = cspTenant.subscriptionId;
120
+ partial.providerTenant = cspTenant.tenantId;
121
+ // ULTIMATE CANDIDATE
122
+ let candidate = {
123
+ providerCode: partial.providerCode,
124
+ credsType: partial.credsType,
125
+ username: partial.username,
126
+ secret: partial.secret,
127
+ providerSubscription: partial.providerSubscription,
128
+ providerTenant: partial.providerTenant
129
+ };
130
+ return candidate;
131
+ });
132
+ }
133
+ buildCommandString(candidate, cmd) {
134
+ cmd.push(candidate.providerCode);
135
+ cmd.push("--silent");
136
+ if (candidate.username)
137
+ cmd.push(...["--user", candidate.username]);
138
+ if (candidate.credsType == exports.CLIENT_CREDENTIALS)
139
+ cmd.push("--clientSecret");
140
+ if (candidate.providerSubscription)
141
+ cmd.push(...["--subscriptionId", candidate.providerSubscription]);
142
+ if (candidate.providerTenant)
143
+ cmd.push(...["--tenantId", candidate.providerTenant]);
144
+ if (candidate.proprietaryInput) {
145
+ // Aws
146
+ if (candidate.proprietaryInput.sessionToken) {
147
+ cmd.push(...["--aws-session-token", candidate.proprietaryInput.sessionToken]);
148
+ }
149
+ }
150
+ // This command must run in silent mode,
151
+ // and even if they provided a password inline,
152
+ // we should only recommend piping the secret in.
153
+ cmd.unshift("echo", "$MY_SECRET", "|");
154
+ return cmd;
155
+ }
156
+ executeTask(candidate) {
157
+ var _a, _b, _c, _d;
158
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
159
+ if (candidate.credsType == exports.CLIENT_CREDENTIALS) {
160
+ // ------------------------------------------------------------
161
+ // Client Credentials auth flow (aka: service principal creds)
162
+ // ------------------------------------------------------------
27
163
  try {
28
- this.bootstrap();
29
- const { args, flags } = yield this.parse(CspLogin);
30
- (_a = this._relayContainer) === null || _a === void 0 ? void 0 : _a.ready$.subscribe(() => tslib_1.__awaiter(this, void 0, void 0, function* () {
31
- var _b, _c, _d;
32
- try {
33
- if (flags.silent === true)
34
- this.__ui = new ops_1.ThrowingUserInputProvider(this.logger);
35
- this._userCntx = yield this.establishTenantContext(this._userCntx);
36
- // Select the CSP
37
- let provider;
38
- if (args.provider) {
39
- provider = type_safety_utils_1.TypeSafetyUtils.toEnum(contracts_1.CloudProviderEnum, args.provider);
40
- if (provider == undefined)
41
- throw new Error("Unrecognized cloud provider.");
42
- }
43
- else if (flags.silent === true) {
44
- throw new Error(`You must specify a cloud provider.`);
45
- }
46
- else {
47
- // Select interactively
48
- let allPvds = Object.values(contracts_1.CloudProviderEnum); //this.cspUiFactory.getAllClusterProviders(this.ioc); // TODO: this call is currently limited to cluster providers - we need the comprehensive list of CSPs in use.
49
- _.remove(allPvds, x => x == contracts_1.CloudProviderEnum.other);
50
- _.remove(allPvds, x => x == contracts_1.CloudProviderEnum.localMachine);
51
- provider = yield this.uiCloudProvider.promptForCloudProvider(allPvds, undefined);
52
- }
53
- let proprietaryInput;
54
- // TODO: We should build this with better decoupled principles (eg: delegate to a ui provider instead of if-aws), but not worth it until there's more than just this one single outlier.
55
- if (provider == contracts_1.CloudProviderEnum.aws && flags['aws-session-token'])
56
- proprietaryInput = { sessionToken: flags['aws-session-token'] };
57
- if (flags.clientSecret) {
58
- // Client Credentials auth flow (aka: service principal creds)
59
- let clientSecret;
60
- if (flags.silent == true) {
61
- // silent mode, with piped input
62
- clientSecret = yield (0, read_stdin_1.default)();
63
- if (_.isEmpty(clientSecret)) {
64
- throw new Error("Missing client secret. In silent mode, clientSecret must be passed in via stdin (ie: piped input).");
65
- }
66
- }
67
- else {
68
- // Interactive mode
69
- clientSecret = yield this._ui.promptPassword("clientSecret", "Client Secret: ");
70
- }
71
- if (_.isEmpty(clientSecret)) {
72
- throw new Error(`No client secret provided (client secret can be provided interatively or via the stdin process stream).`);
73
- }
74
- const cspTenant = yield this.cspContextualizer.ensureCspTenantContext(this._codiacApi, provider, flags.subscriptionId, flags.tenantId, flags.silent);
75
- // BUILD REQUEST
76
- let req = {
77
- providerCode: provider,
78
- credsType: 'client_credentials',
79
- username: (_b = flags.user) !== null && _b !== void 0 ? _b : "<CspTenantClientId>",
80
- secret: clientSecret,
81
- providerSubscription: cspTenant.subscriptionId,
82
- providerTenant: cspTenant.tenantId
83
- };
84
- let result = yield this.genRelayClient.Call.csp_login(req);
85
- if (result.success) {
86
- this._ui.userMessage(`${this._styler.colorGood("Success!")} Authenticated this Codiac instance as a trusted client with ${this._styler.hilite(provider)} for [${this._userCntx.currentTenantCode}: ${this._userCntx.userName}].`);
87
- this.logger.debug(`Authenticated this Codiac instance as a trusted client with ${this._styler.hilite(provider)} for [${this._userCntx.currentTenantCode}: ${this._userCntx.userName}].`);
88
- }
89
- else {
90
- this._ui.userMessage(`Authentication failed (${result.message})`);
91
- }
92
- }
93
- else if (Boolean(flags.silent) === true) {
94
- const cspTenant = yield this.cspContextualizer.ensureCspTenantContext(this._codiacApi, provider, flags.subscriptionId, flags.tenantId, flags.silent);
95
- // Silent login - good luck... (if user or password are empty, the api will pick up the stored creds for this csp)
96
- let loginReq;
97
- if (proprietaryInput) {
98
- loginReq = this.uiCloudProvider.assembleLoginRequest(this.ioc, provider, flags.user, flags.password, cspTenant.subscriptionId, proprietaryInput);
99
- }
100
- else {
101
- loginReq = {
102
- providerCode: provider,
103
- username: flags.user,
104
- secret: flags.password,
105
- providerSubscription: cspTenant.subscriptionId,
106
- providerTenant: cspTenant.tenantId
107
- };
108
- }
109
- const loginResult = yield this.genRelayClient.Call.csp_login(loginReq); // TODO: Consider passing in flags.subscriptionId
110
- if (loginResult.success) {
111
- this._ui.userMessage(`${this._styler.colorGood("Success!")} Authenticated with ${this._styler.hilite(provider)} for [${this._userCntx.currentTenantCode}: ${this._userCntx.userName}].`);
112
- this.logger.debug(`Authenticated with ${this._styler.hilite(provider)} for [${this._userCntx.currentTenantCode}: ${this._userCntx.userName}].`);
113
- }
114
- else {
115
- this._ui.userMessage(`Authentication failed (${loginResult.message})`);
116
- }
117
- }
118
- else {
119
- // interactive auth flow
120
- try {
121
- const cspTenant = yield this.uiCloudProvider.ensureCspTenantContext(this._codiacApi, provider, flags.subscriptionId, flags.tenantId, flags.silent);
122
- let cspUser = yield this.uiCloudProvider.promptForCloudProviderCreds(this.ioc, provider, Boolean(flags.silent), flags.user, flags.password, cspTenant, proprietaryInput);
123
- let subx = "";
124
- if (cspUser.subscriptionId) {
125
- subx = ((cspUser.provider == contracts_1.CloudProviderEnum.aws) ? "acct" : "subx").concat(": ", cspUser.subscriptionId);
126
- subx = "(".concat(subx, ")");
127
- }
128
- this._ui.userMessage(this._styler.colorGood("Success!").concat(" Authenticated with ", provider, " as ", this._styler.hilite(cspUser.username), subx));
129
- }
130
- catch (err) {
131
- this._ui.userMessage(`${this._styler.colorCritical("FAILED")} ${(_c = err.name) !== null && _c !== void 0 ? _c : ""} ${(_d = err.message) !== null && _d !== void 0 ? _d : ""}`);
132
- }
133
- }
134
- resolve();
135
- }
136
- catch (err) {
137
- // this.logger.error(err);
138
- // this._ui.userMessage(`${this._styler.colorCritical("ERROR")} ${err.name ?? ""} ${err.message ?? ""}`);
139
- this.handleError(err);
140
- resolve();
141
- }
142
- finally {
143
- yield this.closeConnections();
144
- }
145
- }));
164
+ let result = yield this.genRelayClient.Call.csp_login(candidate);
165
+ if (result.success) {
166
+ this._ui.userMessage(`${this._styler.colorGood("Success!")} Authenticated this Codiac instance as a trusted client with ${this._styler.hilite(candidate.providerCode)} for [${this._userCntx.currentTenantCode}: ${this._userCntx.userName}].`);
167
+ this.logger.debug(`Authenticated this Codiac instance as a trusted client with ${this._styler.hilite(candidate.providerCode)} for [${this._userCntx.currentTenantCode}: ${this._userCntx.userName}].`);
168
+ }
169
+ else {
170
+ this._ui.userMessage(`${this._styler.colorCritical("Authentication FAILED")} (${result.message})`);
171
+ }
146
172
  }
147
173
  catch (err) {
148
- this.handleError(err);
149
- reject(err);
174
+ this._ui.userMessage(`${this._styler.colorCritical("Error")} ${(_a = err.name) !== null && _a !== void 0 ? _a : ""} ${(_b = err.message) !== null && _b !== void 0 ? _b : ""}`);
150
175
  }
151
- finally {
152
- yield this.closeConnections();
176
+ }
177
+ else {
178
+ // ------------------------------------------------------------
179
+ // User Interactive auth flow (aka: PKCE with regular user creds)
180
+ // ------------------------------------------------------------
181
+ try {
182
+ let cspUser = yield this.cspContextualizer.promptForCloudProviderCreds(this.ioc, candidate.providerCode, false, candidate.username, candidate.secret, { subscriptionId: candidate.providerSubscription, tenantId: candidate.providerTenant }, candidate.proprietaryInput);
183
+ let subx = "";
184
+ if (cspUser.subscriptionId) {
185
+ subx = ((cspUser.provider == contracts_1.CloudProviderEnum.aws) ? "acct" : "subx").concat(": ", cspUser.subscriptionId);
186
+ subx = "(".concat(subx, ")");
187
+ }
188
+ this._ui.userMessage(this._styler.colorGood("Success!").concat(" Authenticated with ", candidate.providerCode, " as ", this._styler.hilite(cspUser.username), subx));
189
+ }
190
+ catch (err) {
191
+ this._ui.userMessage(`${this._styler.colorCritical("FAILED")} ${(_c = err.name) !== null && _c !== void 0 ? _c : ""} ${(_d = err.message) !== null && _d !== void 0 ? _d : ""}`);
153
192
  }
154
- }));
193
+ }
194
+ return;
155
195
  });
156
196
  }
157
197
  }
@@ -171,12 +211,16 @@ CspLogin.examples = [
171
211
  // static dependsOn = ["provider"]; // this isnt the whole of the requirements
172
212
  CspLogin.flags = {
173
213
  user: core_1.Flags.string({ char: 'u', description: 'The username at the given cloud provider.' /*, exclusive: ["clientSecret"] */ }),
174
- password: core_1.Flags.string({ char: 'p', description: '(must be provided via stdin) The password at the given cloud provider.', exclusive: ["clientSecret"] }),
214
+ password: core_1.Flags.string({ char: 'p', description: '(must be provided via stdin using --silent) The password at the given cloud provider.', exclusive: ["clientSecret"] }),
175
215
  "aws-session-token": core_1.Flags.string({ required: false, exclusive: ["clientSecret"], description: "(for AWS only) The session token parameter for use when authenticating with a short-term AWS access key credentials." }),
176
- clientSecret: core_1.Flags.boolean({ exclusive: ["password"], description: '(must be provided interactively or via stdin) Invokes the OAuth Client Credentials Flow. Used to authenticate when no user is present, such as an internal service or in a devops pipeline. Note: This is a secret that must be created when Codiac gets registered as a trusted application in your cloud service provider subscription (eg: in azure, this is an app registration in Azure AD).' }),
216
+ clientSecret: core_1.Flags.boolean({ exclusive: ["password"], description: '(must be provided interactively or via stdin using --silent) Invokes the OAuth Client Credentials Flow. Used to authenticate when no user is present, such as an internal service or in a devops pipeline. Note: This is a secret that must be created when Codiac gets registered as a trusted application in your cloud service provider subscription (eg: in azure, this is an app registration in Azure AD).' }),
177
217
  subscriptionId: core_1.Flags.string({ char: 's', description: '(in silent mode, either this or tenantId is required if you have more than one tenant profile on a given cloud provider) The Id of the cloud provider subscription under which to authenticate.' }),
178
218
  tenantId: core_1.Flags.string({ char: 't', description: '(in silent mode, either this or subscriptionId is required if you have more than one tenant profile on a given cloud provider) The Id of the cloud provider tenant under which to authenticate.' }),
179
- silent: core_1.Flags.boolean({ char: 'y', required: false, description: `(Optional: defaults to false) Suppresses any user-interaction.` })
219
+ // TODO: Move these into the base class
220
+ silent: core_1.Flags.boolean({ exclusive: ["echo", "to-script"], description: 'Non-Interactive mode; executes without any user interaction and fails on any missing or invalid arguments.' }),
221
+ echo: core_1.Flags.boolean({ exclusive: ["to-script", "silent"], description: 'Echo interaction mode; renders the equivalent non-interactive cli command for future use before final execution.' }),
222
+ "to-script": core_1.Flags.boolean({ exclusive: ["echo", "silent"], description: 'Toscript interaction mode; renders the equivalent non-interactive cli command WITHOUT any execution.' }),
223
+ "take-defaults": core_1.Flags.boolean({ exclusive: ["silent"], description: "Setting this to true prevents prompting for confirmation on parameters that were passed in or were automatically set to default values (Irrelevant in --silent mode). This behavior does NOT apply to scenarios that the command needs to override invalid user input; such cases will always prompt for confirmation. eg: when no argument was provided for file or type, and only one exists, the system will render the autoselected file unless this flag is set." })
180
224
  };
181
225
  CspLogin.args = {
182
226
  provider: core_1.Args.string({ required: false, options: Object.keys(contracts_1.CloudProviderEnum), description: 'Code indicating the Cloud Service Provider (CSP) being authenticated with.' })
@@ -1 +1 @@
1
- {"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/commands/csp/login.ts"],"names":[],"mappings":";;;AAAA,4BAA4B;AAC5B,sCAAyC;AACzC,mCAAsD;AACtD,iEAAkG;AAClG,2EAAqE;AACrE,+FAAyF;AACzF,iDAAyC;AAEzC,uEAAkE;AAGlE,MAAqB,QAAS,SAAQ,+CAAqB;IAgCzD,IAAY,eAAe;QACzB,IAAI,IAAI,CAAC,yBAAyB,KAAK,SAAS,EAAE;YAChD,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,2DAA2B,CAAC,CAAC;SAC5E;QACD,OAAO,IAAI,CAAC,yBAAyB,CAAC;IACxC,CAAC;IAIS,SAAS;QACjB,KAAK,CAAC,SAAS,EAAE,CAAC;QAClB,2DAA2B,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClD,CAAC;IAGY,GAAG;;YACd,OAAO,IAAI,OAAO,CAAO,CAAO,OAAO,EAAE,MAAM,EAAE,EAAE;;gBACjD,IAAI;oBACF,IAAI,CAAC,SAAS,EAAE,CAAC;oBACjB,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;oBACnD,MAAA,IAAI,CAAC,eAAe,0CAAE,MAAM,CACzB,SAAS,CAAC,GAAS,EAAE;;wBAEpB,IAAI;4BACF,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI;gCAAE,IAAI,CAAC,IAAI,GAAG,IAAI,+BAAyB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;4BAClF,IAAI,CAAC,SAAS,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,SAAS,CAAC,CA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WAAW,EAAE,YAAK,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,WAAW,EAAE,sGAAsG,EAAE,CAAC;IAClL,eAAe,EAAE,YAAK,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,ycAAyc,EAAE,CAAC;CAClhB,CAAA;AAEM,aAAI,GAAG;IACZ,QAAQ,EAAE,WAAI,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,6BAAiB,CAAC,EAAE,WAAW,EAAE,4EAA4E,EAAE,CAAC;CAC/K,CAAA"}
@@ -1,15 +1,17 @@
1
+ import { CloudProviderEnum } from '../../apis/codiac-relay/contracts';
1
2
  import { CommandBaseEnterprise } from '../../command-base-enterprise';
2
3
  export default class CspLogout extends CommandBaseEnterprise {
3
4
  static description: string;
4
5
  static examples: string[];
5
6
  static flags: {
7
+ subscriptionId: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
+ tenantId: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
6
9
  silent: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
7
10
  };
11
+ private static _allPvds;
12
+ static get allPvds(): CloudProviderEnum[];
8
13
  static args: {
9
14
  provider: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
10
15
  };
11
- private get uiCloudProvider();
12
- private __uiCloudProvider_backing;
13
- protected bootstrap(): void;
14
16
  run(): Promise<void>;
15
17
  }
@@ -1,26 +1,25 @@
1
1
  "use strict";
2
+ var _a;
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  const tslib_1 = require("tslib");
4
5
  const core_1 = require("@oclif/core");
5
6
  const contracts_1 = require("../../apis/codiac-relay/contracts");
6
7
  const command_base_enterprise_1 = require("../../command-base-enterprise");
7
- const cloud_provider_contextualizer_1 = require("../../uilogic/cloud-provider-contextualizer");
8
+ const _ = require("lodash");
8
9
  const type_safety_utils_1 = require("../../uilogic/type-safety-utils");
9
10
  class CspLogout extends command_base_enterprise_1.CommandBaseEnterprise {
10
- get uiCloudProvider() {
11
- if (this.__uiCloudProvider_backing === undefined) {
12
- this.__uiCloudProvider_backing = this.ioc.get(cloud_provider_contextualizer_1.CloudProviderContextualizer);
11
+ static get allPvds() {
12
+ if (this._allPvds == undefined) {
13
+ this._allPvds = Object.values(contracts_1.CloudProviderEnum); //this.cspUiFactory.getAllClusterProviders(this.ioc); // TODO: this call is currently limited to cluster providers - we need the comprehensive list of CSPs in use.
14
+ _.remove(this._allPvds, x => x == contracts_1.CloudProviderEnum.other);
15
+ _.remove(this._allPvds, x => x == contracts_1.CloudProviderEnum.localMachine);
13
16
  }
14
- return this.__uiCloudProvider_backing;
15
- }
16
- bootstrap() {
17
- super.bootstrap();
18
- cloud_provider_contextualizer_1.CloudProviderContextualizer.bootstrap(this.ioc);
17
+ return this._allPvds;
19
18
  }
20
19
  run() {
21
20
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
22
21
  return new Promise((resolve, reject) => tslib_1.__awaiter(this, void 0, void 0, function* () {
23
- var _a, _b, _c, _d;
22
+ var _b, _c, _d, _e, _f;
24
23
  try {
25
24
  this.bootstrap();
26
25
  const { args, flags } = yield this.parse(CspLogout);
@@ -39,22 +38,31 @@ class CspLogout extends command_base_enterprise_1.CommandBaseEnterprise {
39
38
  }
40
39
  else {
41
40
  // Select interactively
42
- let allPvds = this.cspUiFactory.getAllClusterProviders(this.ioc);
43
- provider = yield this.uiCloudProvider.promptForCloudProvider(allPvds, undefined);
41
+ // let allPvds = this.cspUiFactory.getAllClusterProviders(this.ioc); // we dont want just cluster providers here
42
+ provider = yield this.cspContextualizer.promptForCloudProvider(CspLogout.allPvds, undefined);
43
+ }
44
+ let cspAcct = { subscriptionId: flags.subscriptionId, tenantId: flags.tenantId };
45
+ const cspTenant = yield this.cspContextualizer.ensureCspTenant(provider, this._codiacApi, cspAcct, false);
46
+ if (cspTenant) {
47
+ cspAcct.tenantId = cspTenant.cspTenantId;
48
+ // remove an invalid user-provided subscriptionId
49
+ if (cspAcct.subscriptionId && !((_b = cspTenant.subscriptionIds) === null || _b === void 0 ? void 0 : _b.includes(cspAcct.subscriptionId))) {
50
+ delete cspAcct.subscriptionId;
51
+ }
44
52
  }
45
53
  // interactive sign-out flow
46
54
  try {
47
- let username = yield this.uiCloudProvider.promptToLogout(this.ioc, provider, suppressConfirmations);
55
+ let username = yield this.cspContextualizer.promptToLogout(this.ioc, provider, cspAcct, suppressConfirmations);
48
56
  this._ui.userMessage(`${this._styler.colorGood("Success!")} Signed out from ${this._styler.hilite(provider)}.`);
49
57
  }
50
58
  catch (err) {
51
- this._ui.userMessage(`${this._styler.colorCritical("FAILED")} ${(_a = err.name) !== null && _a !== void 0 ? _a : ""} ${(_b = err.message) !== null && _b !== void 0 ? _b : ""}`);
59
+ this._ui.userMessage(`${this._styler.colorCritical("FAILED")} ${(_c = err.name) !== null && _c !== void 0 ? _c : ""} ${(_d = err.message) !== null && _d !== void 0 ? _d : ""}`);
52
60
  }
53
61
  resolve();
54
62
  }
55
63
  catch (err) {
56
64
  this.logger.error(err);
57
- this._ui.userMessage(`${this._styler.colorCritical("ERROR")} ${(_c = err.name) !== null && _c !== void 0 ? _c : ""} ${(_d = err.message) !== null && _d !== void 0 ? _d : ""}`);
65
+ this._ui.userMessage(`${this._styler.colorCritical("ERROR")} ${(_e = err.name) !== null && _e !== void 0 ? _e : ""} ${(_f = err.message) !== null && _f !== void 0 ? _f : ""}`);
58
66
  resolve();
59
67
  }
60
68
  finally {
@@ -65,6 +73,7 @@ class CspLogout extends command_base_enterprise_1.CommandBaseEnterprise {
65
73
  }
66
74
  }
67
75
  exports.default = CspLogout;
76
+ _a = CspLogout;
68
77
  CspLogout.description = 'Closes session with the given Cloud Service Provider (CSP), eg: aws, azure, docker. Use this command to clear the local cache for your security account at that provider.';
69
78
  CspLogout.examples = [
70
79
  'cod csp logout',
@@ -73,9 +82,11 @@ CspLogout.examples = [
73
82
  ];
74
83
  // static dependsOn = ["provider"]; // this isnt the whole of the requirements
75
84
  CspLogout.flags = {
85
+ subscriptionId: core_1.Flags.string({ char: 's', description: '(in silent mode, either this or tenantId is required if you have more than one tenant profile on a given cloud provider) The Id of the cloud provider subscription under which to logout.' }),
86
+ tenantId: core_1.Flags.string({ char: 't', description: '(in silent mode, either this or subscriptionId is required if you have more than one tenant profile on a given cloud provider) The Id of the cloud provider tenant under which to logout.' }),
76
87
  silent: core_1.Flags.boolean({ char: 'y', required: false, description: `(Optional: defaults to false) Suppresses any user-interaction.` })
77
88
  };
78
89
  CspLogout.args = {
79
- provider: core_1.Args.string({ required: false, options: Object.keys(contracts_1.CloudProviderEnum), char: 'p', description: 'Code indicating the Cloud Service Provider (CSP) being authenticated with.' })
90
+ provider: core_1.Args.string({ required: false, options: _a.allPvds, char: 'p', description: 'Code indicating the Cloud Service Provider (CSP) being authenticated with.' })
80
91
  };
81
92
  //# sourceMappingURL=logout.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/commands/csp/logout.ts"],"names":[],"mappings":";;;AAAA,sCAAyC;AACzC,iEAAqE;AACrE,2EAAqE;AACrE,+FAAyF;AAGzF,uEAAkE;AAElE,MAAqB,SAAU,SAAQ,+CAAqB;IAoB1D,IAAY,eAAe;QACzB,IAAI,IAAI,CAAC,yBAAyB,KAAK,SAAS,EAAE;YAChD,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,2DAA2B,CAAC,CAAC;SAC5E;QACD,OAAO,IAAI,CAAC,yBAAyB,CAAC;IACxC,CAAC;IAIS,SAAS;QACjB,KAAK,CAAC,SAAS,EAAE,CAAC;QAClB,2DAA2B,CAAC,SAAS,CAAC,IAAI,CAA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EAAE,YAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE,gEAAgE,EAAE,CAAC;CACrI,CAAA;AAYM,cAAI,GAAG;IACZ,QAAQ,EAAE,WAAI,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,EAAI,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,4EAA4E,EAAE,CAAC;CACxK,CAAA"}
@@ -106,7 +106,7 @@ class NocClusterForget extends command_base_exec_tenant_1.CommandBaseExecTenant
106
106
  // this.logger.trace("rootmap", rootMap);
107
107
  // Get the list of clusters
108
108
  let cluster;
109
- let readResult = yield this._codiacApi.ClusterDef.tryReadMany({ all: true }, { projection: { pathsIncluded: ["id", "name", "provider", "thisMachine", "locationName", "instance", "modified", "modifiedBy"], pathsExcluded: [] } });
109
+ let readResult = yield this._codiacApi.ClusterDef.tryReadMany({ all: true }, { projection: { pathsIncluded: ["id", "name", "provider", "thisMachine", "locationName", "instance", "modified", "modifiedBy", "isCaptured"], pathsExcluded: [] } });
110
110
  let clusterDefs = (_b = readResult.output) !== null && _b !== void 0 ? _b : [];
111
111
  clusterDefs = _.orderBy(clusterDefs, c => c.name);
112
112
  if (provider) {
@@ -117,10 +117,10 @@ class NocClusterForget extends command_base_exec_tenant_1.CommandBaseExecTenant
117
117
  }
118
118
  else {
119
119
  if (running !== true) {
120
- clusterDefs = clusterDefs.filter(c => c.instance == undefined);
120
+ clusterDefs = clusterDefs.filter(c => c.instance == undefined || type_safety_utils_1.TypeSafetyUtils.toBoolean(c.isCaptured == true));
121
121
  }
122
122
  if (readResult.error == undefined && clusterDefs.length === 0) {
123
- this._ui.userMessage("No clusters exist without instances");
123
+ this._ui.userMessage("No clusters exist that are either captured or without instances");
124
124
  }
125
125
  else if (silent === true) {
126
126
  cluster = clusterDefs.find(c => c.name === name && c.provider === provider);