opal-security 4.0.4 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -22,7 +22,7 @@ $ npm install -g opal-security
22
22
  $ opal COMMAND
23
23
  running command...
24
24
  $ opal (--version)
25
- opal-security/4.0.4 darwin-arm64 node-v18.20.4
25
+ opal-security/5.0.0 darwin-arm64 node-v22.21.1
26
26
  $ opal --help [COMMAND]
27
27
  USAGE
28
28
  $ opal COMMAND
@@ -36,6 +36,7 @@ USAGE
36
36
  * [`opal autocomplete [SHELL]`](#opal-autocomplete-shell)
37
37
  * [`opal aws identity`](#opal-aws-identity)
38
38
  * [`opal clear-auth-config`](#opal-clear-auth-config)
39
+ * [`opal curl-example`](#opal-curl-example)
39
40
  * [`opal groups get`](#opal-groups-get)
40
41
  * [`opal help [COMMANDS]`](#opal-help-commands)
41
42
  * [`opal iam-roles start`](#opal-iam-roles-start)
@@ -67,7 +68,7 @@ USAGE
67
68
  $ opal autocomplete [SHELL] [-r]
68
69
 
69
70
  ARGUMENTS
70
- SHELL shell type
71
+ [SHELL] shell type
71
72
 
72
73
  FLAGS
73
74
  -r, --refresh-cache Refresh cache (ignores displaying instructions)
@@ -105,7 +106,7 @@ EXAMPLES
105
106
  $ opal aws:identity
106
107
  ```
107
108
 
108
- _See code: [src/commands/aws/identity.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.4/src/commands/aws/identity.ts)_
109
+ _See code: [src/commands/aws/identity.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.0/src/commands/aws/identity.ts)_
109
110
 
110
111
  ## `opal clear-auth-config`
111
112
 
@@ -122,7 +123,24 @@ EXAMPLES
122
123
  $ opal clear-auth-config
123
124
  ```
124
125
 
125
- _See code: [src/commands/clear-auth-config.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.4/src/commands/clear-auth-config.ts)_
126
+ _See code: [src/commands/clear-auth-config.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.0/src/commands/clear-auth-config.ts)_
127
+
128
+ ## `opal curl-example`
129
+
130
+ Prints out an example cURL command containing the parameters the CLI uses to query the Opal server.
131
+
132
+ ```
133
+ USAGE
134
+ $ opal curl-example [-h]
135
+
136
+ FLAGS
137
+ -h, --help Show CLI help.
138
+
139
+ DESCRIPTION
140
+ Prints out an example cURL command containing the parameters the CLI uses to query the Opal server.
141
+ ```
142
+
143
+ _See code: [src/commands/curl-example.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.0/src/commands/curl-example.ts)_
126
144
 
127
145
  ## `opal groups get`
128
146
 
@@ -143,7 +161,7 @@ EXAMPLES
143
161
  $ opal groups:get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4
144
162
  ```
145
163
 
146
- _See code: [src/commands/groups/get.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.4/src/commands/groups/get.ts)_
164
+ _See code: [src/commands/groups/get.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.0/src/commands/groups/get.ts)_
147
165
 
148
166
  ## `opal help [COMMANDS]`
149
167
 
@@ -154,7 +172,7 @@ USAGE
154
172
  $ opal help [COMMANDS...] [-n]
155
173
 
156
174
  ARGUMENTS
157
- COMMANDS... Command to show help for.
175
+ [COMMANDS...] Command to show help for.
158
176
 
159
177
  FLAGS
160
178
  -n, --nested-commands Include all nested commands in the output.
@@ -171,15 +189,12 @@ Starts a session to assume an IAM role.
171
189
 
172
190
  ```
173
191
  USAGE
174
- $ opal iam-roles start [-h] [-i <value>] [-s <value>] [-r] [--profileName <value>]
192
+ $ opal iam-roles start [-h] [-i <value>] [--profileName <value>]
175
193
 
176
194
  FLAGS
177
195
  -h, --help Show CLI help.
178
196
  -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
179
197
  https://opal.dev/resources/[ID]
180
- -r, --refresh Starts a new session even if one already exists. Useful if a session is about to expire.
181
- -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
182
- web flow.
183
198
  --profileName=<value> Uses a custom AWS profile name for the IAM role. Default value is the role's name.
184
199
 
185
200
  DESCRIPTION
@@ -193,7 +208,7 @@ EXAMPLES
193
208
  $ opal iam-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --profileName "custom-profile"
194
209
  ```
195
210
 
196
- _See code: [src/commands/iam-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.4/src/commands/iam-roles/start.ts)_
211
+ _See code: [src/commands/iam-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.0/src/commands/iam-roles/start.ts)_
197
212
 
198
213
  ## `opal kube-roles start`
199
214
 
@@ -201,17 +216,13 @@ Starts a session to assume a Kubernetes cluster IAM role.
201
216
 
202
217
  ```
203
218
  USAGE
204
- $ opal kube-roles start [-h] [-i <value>] [-a <value>] [-s <value>] [-r]
219
+ $ opal kube-roles start [-h] [-i <value>] [-a <value>]
205
220
 
206
221
  FLAGS
207
222
  -a, --accessLevelRemoteId=<value> The remote ID of the access level with which to access the resource.
208
223
  -h, --help Show CLI help.
209
224
  -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
210
225
  https://opal.dev/resources/[ID]
211
- -r, --refresh Starts a new session even if one already exists. Useful if a session is about to
212
- expire.
213
- -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created
214
- via the web flow.
215
226
 
216
227
  DESCRIPTION
217
228
  Starts a session to assume a Kubernetes cluster IAM role.
@@ -224,7 +235,7 @@ EXAMPLES
224
235
  $ opal kube-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --accessLevelRemoteId "arn:aws:iam::712234975475:role/acme-eks-cluster-admin-role"
225
236
  ```
226
237
 
227
- _See code: [src/commands/kube-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.4/src/commands/kube-roles/start.ts)_
238
+ _See code: [src/commands/kube-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.0/src/commands/kube-roles/start.ts)_
228
239
 
229
240
  ## `opal login`
230
241
 
@@ -247,7 +258,7 @@ EXAMPLES
247
258
  $ opal login
248
259
  ```
249
260
 
250
- _See code: [src/commands/login.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.4/src/commands/login.ts)_
261
+ _See code: [src/commands/login.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.0/src/commands/login.ts)_
251
262
 
252
263
  ## `opal logout`
253
264
 
@@ -267,7 +278,7 @@ EXAMPLES
267
278
  $ opal logout
268
279
  ```
269
280
 
270
- _See code: [src/commands/logout.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.4/src/commands/logout.ts)_
281
+ _See code: [src/commands/logout.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.0/src/commands/logout.ts)_
271
282
 
272
283
  ## `opal postgres-instances start`
273
284
 
@@ -275,17 +286,13 @@ Starts a session to connect to a Postgres database.
275
286
 
276
287
  ```
277
288
  USAGE
278
- $ opal postgres-instances start [-h] [-i <value>] [-a <value>] [-s <value>] [-r] [--action open|psql|view]
289
+ $ opal postgres-instances start [-h] [-i <value>] [-a <value>] [--action open|psql|view]
279
290
 
280
291
  FLAGS
281
292
  -a, --accessLevelRemoteId=<value> The remote ID of the access level with which to access the resource.
282
293
  -h, --help Show CLI help.
283
294
  -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
284
295
  https://opal.dev/resources/[ID]
285
- -r, --refresh Starts a new session even if one already exists. Useful if a session is about to
286
- expire.
287
- -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created
288
- via the web flow.
289
296
  --action=<option> Method of connecting to the database.
290
297
  - open: Open external database app
291
298
  - psql: Start psql session in shell
@@ -305,7 +312,7 @@ EXAMPLES
305
312
  $ opal postgres-instances:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --accessLevelRemoteId fullaccess --action view
306
313
  ```
307
314
 
308
- _See code: [src/commands/postgres-instances/start.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.4/src/commands/postgres-instances/start.ts)_
315
+ _See code: [src/commands/postgres-instances/start.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.0/src/commands/postgres-instances/start.ts)_
309
316
 
310
317
  ## `opal request create`
311
318
 
@@ -331,7 +338,7 @@ DESCRIPTION
331
338
  Creates an Opal access request via an interactive form
332
339
  ```
333
340
 
334
- _See code: [src/commands/request/create.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.4/src/commands/request/create.ts)_
341
+ _See code: [src/commands/request/create.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.0/src/commands/request/create.ts)_
335
342
 
336
343
  ## `opal request get`
337
344
 
@@ -355,7 +362,7 @@ EXAMPLES
355
362
  $ opal request get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4 --verbose
356
363
  ```
357
364
 
358
- _See code: [src/commands/request/get.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.4/src/commands/request/get.ts)_
365
+ _See code: [src/commands/request/get.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.0/src/commands/request/get.ts)_
359
366
 
360
367
  ## `opal request list`
361
368
 
@@ -387,7 +394,7 @@ EXAMPLES
387
394
  $ opal request list --n 5 --pending --verbose
388
395
  ```
389
396
 
390
- _See code: [src/commands/request/list.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.4/src/commands/request/list.ts)_
397
+ _See code: [src/commands/request/list.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.0/src/commands/request/list.ts)_
391
398
 
392
399
  ## `opal request ls`
393
400
 
@@ -438,7 +445,7 @@ EXAMPLES
438
445
  $ opal resources:get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4
439
446
  ```
440
447
 
441
- _See code: [src/commands/resources/get.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.4/src/commands/resources/get.ts)_
448
+ _See code: [src/commands/resources/get.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.0/src/commands/resources/get.ts)_
442
449
 
443
450
  ## `opal set-auth-config`
444
451
 
@@ -468,7 +475,7 @@ EXAMPLES
468
475
  $ opal set-auth-config --organizationID=org-456 --clientID=abc123 --issuerUrl=https://auth.example.com
469
476
  ```
470
477
 
471
- _See code: [src/commands/set-auth-config.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.4/src/commands/set-auth-config.ts)_
478
+ _See code: [src/commands/set-auth-config.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.0/src/commands/set-auth-config.ts)_
472
479
 
473
480
  ## `opal set-custom-header`
474
481
 
@@ -489,7 +496,7 @@ EXAMPLES
489
496
  $ opal set-custom-header --header 'cf-access-token: $TOKEN'
490
497
  ```
491
498
 
492
- _See code: [src/commands/set-custom-header.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.4/src/commands/set-custom-header.ts)_
499
+ _See code: [src/commands/set-custom-header.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.0/src/commands/set-custom-header.ts)_
493
500
 
494
501
  ## `opal set-token`
495
502
 
@@ -509,7 +516,7 @@ EXAMPLES
509
516
  $ opal set-token
510
517
  ```
511
518
 
512
- _See code: [src/commands/set-token.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.4/src/commands/set-token.ts)_
519
+ _See code: [src/commands/set-token.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.0/src/commands/set-token.ts)_
513
520
 
514
521
  ## `opal set-url [URL]`
515
522
 
@@ -520,7 +527,7 @@ USAGE
520
527
  $ opal set-url [URL] [-h] [--allowSelfSignedCerts]
521
528
 
522
529
  ARGUMENTS
523
- URL URL of the Opal server to use. If unspecified, defaults to https://app.opal.dev
530
+ [URL] URL of the Opal server to use. If unspecified, defaults to https://app.opal.dev
524
531
 
525
532
  FLAGS
526
533
  -h, --help Show CLI help.
@@ -533,7 +540,7 @@ EXAMPLES
533
540
  $ opal set-url
534
541
  ```
535
542
 
536
- _See code: [src/commands/set-url.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.4/src/commands/set-url.ts)_
543
+ _See code: [src/commands/set-url.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.0/src/commands/set-url.ts)_
537
544
 
538
545
  ## `opal ssh copyFrom`
539
546
 
@@ -541,19 +548,16 @@ Use SCP to copy files from a compute instance.
541
548
 
542
549
  ```
543
550
  USAGE
544
- $ opal ssh copyFrom --src <value> [-h] [--dest <value>] [--user <value>] [-i <value>] [-s <value>]
551
+ $ opal ssh copyFrom --src <value> [-h] [--dest <value>] [--user <value>] [-i <value>]
545
552
 
546
553
  FLAGS
547
- -h, --help Show CLI help.
548
- -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
549
- https://opal.dev/resources/[ID]
550
- -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
551
- web flow.
552
- --dest=<value> [default: .] The directory you want your files to be copied to.
553
- --src=<value> (required) The directory or file you would like to copy over SCP. Note we only support one
554
- file or directory at a time.
555
- --user=<value> [default: ssm-user] The user you want to run SCP over. Keep in mind not all users will have
556
- access to each other's home directory.
554
+ -h, --help Show CLI help.
555
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g. https://opal.dev/resources/[ID]
556
+ --dest=<value> [default: .] The directory you want your files to be copied to.
557
+ --src=<value> (required) The directory or file you would like to copy over SCP. Note we only support one file or
558
+ directory at a time.
559
+ --user=<value> [default: ssm-user] The user you want to run SCP over. Keep in mind not all users will have access
560
+ to each other's home directory.
557
561
 
558
562
  DESCRIPTION
559
563
  Use SCP to copy files from a compute instance.
@@ -564,7 +568,7 @@ EXAMPLES
564
568
  $ opal ssh:copyFrom --src instance/dir --dest my/dir --id 51f7176b-0464-4a6f-8369-e951e187b398
565
569
  ```
566
570
 
567
- _See code: [src/commands/ssh/copyFrom.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.4/src/commands/ssh/copyFrom.ts)_
571
+ _See code: [src/commands/ssh/copyFrom.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.0/src/commands/ssh/copyFrom.ts)_
568
572
 
569
573
  ## `opal ssh copyTo`
570
574
 
@@ -572,19 +576,16 @@ Use SCP to copy files to a compute instance.
572
576
 
573
577
  ```
574
578
  USAGE
575
- $ opal ssh copyTo --src <value> [-h] [--dest <value>] [--user <value>] [-i <value>] [-s <value>]
579
+ $ opal ssh copyTo --src <value> [-h] [--dest <value>] [--user <value>] [-i <value>]
576
580
 
577
581
  FLAGS
578
- -h, --help Show CLI help.
579
- -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
580
- https://opal.dev/resources/[ID]
581
- -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
582
- web flow.
583
- --dest=<value> [default: .] The directory you want your files to be copied to.
584
- --src=<value> (required) The directory or file you would like to copy over SCP. Note we only support one
585
- file or directory at a time.
586
- --user=<value> [default: ssm-user] The user you want to run SCP over. Keep in mind not all users will have
587
- access to each other's home directory.
582
+ -h, --help Show CLI help.
583
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g. https://opal.dev/resources/[ID]
584
+ --dest=<value> [default: .] The directory you want your files to be copied to.
585
+ --src=<value> (required) The directory or file you would like to copy over SCP. Note we only support one file or
586
+ directory at a time.
587
+ --user=<value> [default: ssm-user] The user you want to run SCP over. Keep in mind not all users will have access
588
+ to each other's home directory.
588
589
 
589
590
  DESCRIPTION
590
591
  Use SCP to copy files to a compute instance.
@@ -595,7 +596,7 @@ EXAMPLES
595
596
  $ opal ssh:copyTo --src my/dir --dest instance/dir --id 51f7176b-0464-4a6f-8369-e951e187b398
596
597
  ```
597
598
 
598
- _See code: [src/commands/ssh/copyTo.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.4/src/commands/ssh/copyTo.ts)_
599
+ _See code: [src/commands/ssh/copyTo.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.0/src/commands/ssh/copyTo.ts)_
599
600
 
600
601
  ## `opal ssh start`
601
602
 
@@ -603,15 +604,11 @@ Starts an SSH session to access a compute instance.
603
604
 
604
605
  ```
605
606
  USAGE
606
- $ opal ssh start [-h] [-i <value>] [-s <value>] [-r]
607
+ $ opal ssh start [-h] [-i <value>]
607
608
 
608
609
  FLAGS
609
- -h, --help Show CLI help.
610
- -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
611
- https://opal.dev/resources/[ID]
612
- -r, --refresh Starts a new session even if one already exists. Useful if a session is about to expire.
613
- -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
614
- web flow.
610
+ -h, --help Show CLI help.
611
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g. https://opal.dev/resources/[ID]
615
612
 
616
613
  DESCRIPTION
617
614
  Starts an SSH session to access a compute instance.
@@ -622,7 +619,7 @@ EXAMPLES
622
619
  $ opal ssh:start --id 51f7176b-0464-4a6f-8369-e951e187b398
623
620
  ```
624
621
 
625
- _See code: [src/commands/ssh/start.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.4/src/commands/ssh/start.ts)_
622
+ _See code: [src/commands/ssh/start.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.0/src/commands/ssh/start.ts)_
626
623
 
627
624
  ## `opal version`
628
625
 
@@ -659,5 +656,5 @@ DESCRIPTION
659
656
  Describes current url set, organization name, and logged in user if applicable.
660
657
  ```
661
658
 
662
- _See code: [src/commands/whoami.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.4/src/commands/whoami.ts)_
659
+ _See code: [src/commands/whoami.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.0/src/commands/whoami.ts)_
663
660
  <!-- commandsstop -->
@@ -0,0 +1,8 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class CurlExample extends Command {
3
+ static description: string;
4
+ static flags: {
5
+ help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
6
+ };
7
+ run(): Promise<void>;
8
+ }
@@ -0,0 +1,35 @@
1
+ import { Command } from "@oclif/core";
2
+ import chalk from "chalk";
3
+ import { getOrCreateConfigData, urlKey } from "../lib/config.js";
4
+ import { SecretType, getOpalCredentials } from "../lib/credentials/index.js";
5
+ import { SHARED_FLAGS } from "../lib/flags.js";
6
+ class CurlExample extends Command {
7
+ async run() {
8
+ const opalCreds = await getOpalCredentials(this);
9
+ const secret = opalCreds === null || opalCreds === void 0 ? void 0 : opalCreds.secret;
10
+ const organizationID = opalCreds === null || opalCreds === void 0 ? void 0 : opalCreds.organizationID;
11
+ const configData = getOrCreateConfigData(this.config.configDir);
12
+ const url = configData[urlKey];
13
+ let authStr = "";
14
+ if (opalCreds.secretType === SecretType.ApiToken) {
15
+ authStr = `Authorization: Bearer ${secret}`;
16
+ }
17
+ else {
18
+ authStr = `Cookie: ${secret}`;
19
+ }
20
+ this.log(chalk.yellow(`WARN: This command will be removed in a future version of the Opal CLI. \n\
21
+ Opal's GraphQL API is not intended for developer use, please use our REST API instead`));
22
+ this.log(`
23
+ curl -v ${url}/query \\
24
+ --data-binary '{"query":"query ListSSHSessions {resources(input: {serviceType: SSH, onlyMine: true}) {... on ResourcesResult { resources { name } } } }"}' \\
25
+ --header "Content-Type: application/json" \\
26
+ --header "${authStr}" \\
27
+ --header "X-Opal-Organization-ID: ${organizationID}"
28
+ `);
29
+ }
30
+ }
31
+ CurlExample.description = "Prints out an example cURL command containing the parameters the CLI uses to query the Opal server.";
32
+ CurlExample.flags = {
33
+ help: SHARED_FLAGS.help,
34
+ };
35
+ export default CurlExample;
@@ -5,8 +5,6 @@ export default class StartIAMRoleSession extends Command {
5
5
  static flags: {
6
6
  help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
7
7
  id: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
8
- sessionId: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
9
- refresh: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
10
8
  profileName: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
11
9
  };
12
10
  run(): Promise<void>;
@@ -6,7 +6,7 @@ import { getAwsConfigUpdateCmd, getAwsEnvVarMessage } from "../../lib/aws.js";
6
6
  import { runCommandExec, setMostRecentCommand } from "../../lib/cmd.js";
7
7
  import { SHARED_FLAGS } from "../../lib/flags.js";
8
8
  import { DEFAULT_ACCESS_LEVEL, promptUserForResource, } from "../../lib/resources.js";
9
- import { getOrCreateSession, getSessionExpirationMessage, } from "../../lib/sessions.js";
9
+ import { createSession, getSessionExpirationMessage } from "../../lib/sessions.js";
10
10
  const IamSessionMetadataFragment = `
11
11
  ... on AwsIamFederatedRoleSession {
12
12
  awsAccessKeyId
@@ -52,22 +52,22 @@ class StartIAMRoleSession extends Command {
52
52
  if (flags.profileName && flags.profileName !== "") {
53
53
  roleName = flags.profileName;
54
54
  }
55
- const session = await getOrCreateSession(this, roleId, DEFAULT_ACCESS_LEVEL, sessionId, IamSessionMetadataFragment, flags.refresh);
55
+ const session = await createSession(this, roleId, DEFAULT_ACCESS_LEVEL, sessionId, IamSessionMetadataFragment);
56
56
  if (!session) {
57
57
  return;
58
58
  }
59
- const metadata = session.metadata;
59
+ const metadata = session.sessionMetadata;
60
60
  switch (metadata === null || metadata === void 0 ? void 0 : metadata.__typename) {
61
61
  case "AwsIamFederatedRoleSession": {
62
62
  const updateAwsConfigCommand = getAwsConfigUpdateCmd(roleName, metadata.awsAccessKeyId, metadata.awsSecretAccessKey, metadata.awsSessionToken);
63
63
  const startSessionCmd = `${updateAwsConfigCommand}`;
64
64
  const roleText = roleName ? `"${roleName}" role` : "role";
65
- const expirationMessage = getSessionExpirationMessage(session);
65
+ const expirationMessage = getSessionExpirationMessage(session.session);
66
66
  runCommandExec(startSessionCmd, `Now set to use ${roleText}. (session expires in ${expirationMessage})${getAwsEnvVarMessage()}`, `Failed to use ${roleText}.`);
67
67
  break;
68
68
  }
69
69
  default:
70
- return handleError(this, undefined, session);
70
+ return handleError(this, undefined);
71
71
  }
72
72
  }
73
73
  }
@@ -80,8 +80,6 @@ StartIAMRoleSession.examples = [
80
80
  StartIAMRoleSession.flags = {
81
81
  help: SHARED_FLAGS.help,
82
82
  id: SHARED_FLAGS.id,
83
- sessionId: SHARED_FLAGS.sessionId,
84
- refresh: SHARED_FLAGS.refresh,
85
83
  profileName: Flags.string({
86
84
  multiple: false,
87
85
  description: "Uses a custom AWS profile name for the IAM role. Default value is the role's name.",
@@ -6,8 +6,6 @@ export default class StartKubeIAMRoleSession extends Command {
6
6
  help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
7
7
  id: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
8
8
  accessLevelRemoteId: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
9
- sessionId: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
10
- refresh: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
11
9
  };
12
10
  run(): Promise<void>;
13
11
  }
@@ -4,7 +4,7 @@ import { getAwsConfigUpdateCmd, getAwsEnvVarMessage } from "../../lib/aws.js";
4
4
  import { runCommandExec, setMostRecentCommand } from "../../lib/cmd.js";
5
5
  import { SHARED_FLAGS } from "../../lib/flags.js";
6
6
  import { promptUserForAccessLevels, promptUserForResource, } from "../../lib/resources.js";
7
- import { getOrCreateSession, getSessionExpirationMessage, } from "../../lib/sessions.js";
7
+ import { createSession, getSessionExpirationMessage } from "../../lib/sessions.js";
8
8
  const EksSessionMetadataFragment = `
9
9
  ... on AwsIamFederatedEksSession {
10
10
  awsAccessKeyId
@@ -34,11 +34,11 @@ class StartKubeIAMRoleSession extends Command {
34
34
  if (!accessLevel) {
35
35
  return;
36
36
  }
37
- const session = await getOrCreateSession(this, clusterId, accessLevel, sessionId, EksSessionMetadataFragment, flags.refresh);
37
+ const session = await createSession(this, clusterId, accessLevel, sessionId, EksSessionMetadataFragment);
38
38
  if (!session) {
39
39
  return;
40
40
  }
41
- const metadata = session.metadata;
41
+ const metadata = session.sessionMetadata;
42
42
  switch (metadata === null || metadata === void 0 ? void 0 : metadata.__typename) {
43
43
  case "AwsIamFederatedEksSession": {
44
44
  const roleName = accessLevel.accessLevelName;
@@ -46,12 +46,12 @@ class StartKubeIAMRoleSession extends Command {
46
46
  const updateKubeConfigCmd = `aws eks update-kubeconfig --name ${metadata.clusterName} --region ${metadata.clusterRegion} --alias ${metadata.clusterName} --profile opal`;
47
47
  const startSessionCmd = `${updateAwsConfigCommand} && ${updateKubeConfigCmd}`;
48
48
  const roleText = roleName ? `"${roleName}" role` : "role";
49
- const expirationMessage = getSessionExpirationMessage(session);
49
+ const expirationMessage = getSessionExpirationMessage(session.session);
50
50
  runCommandExec(startSessionCmd, `Now set to use ${roleText} with updated Kube config pointing to "${metadata.clusterName}" cluster. (session expires in ${expirationMessage})${getAwsEnvVarMessage()}`, `Failed to assume ${roleText} and update Kube config.`);
51
51
  break;
52
52
  }
53
53
  default:
54
- return handleError(this, undefined, session);
54
+ return handleError(this, undefined);
55
55
  }
56
56
  }
57
57
  }
@@ -65,7 +65,5 @@ StartKubeIAMRoleSession.flags = {
65
65
  help: SHARED_FLAGS.help,
66
66
  id: SHARED_FLAGS.id,
67
67
  accessLevelRemoteId: SHARED_FLAGS.accessLevelRemoteId,
68
- sessionId: SHARED_FLAGS.sessionId,
69
- refresh: SHARED_FLAGS.refresh,
70
68
  };
71
69
  export default StartKubeIAMRoleSession;
@@ -19,7 +19,6 @@ const ISSUER_PROD = "https://auth.opal.dev";
19
19
  const ISSUER_DEV = "https://authdev.opal.dev";
20
20
  const CLIENT_ID_PROD = "42rm6E5v7o67LBpRfjdT9KhnjrQHr9UF";
21
21
  const CLIENT_ID_DEV = "XYV8qoAvZG7dHnhRp2g5XMJ1zX9fBP6s";
22
- const REDIRECT_URI = "http://127.0.0.1:8080/callback";
23
22
  const CLISignInMethodDocumentLegacy = `
24
23
  query CLISignInMethod($input: SignInMethodInput!) {
25
24
  signInMethod(input: $input) {
@@ -84,7 +83,7 @@ mutation CLITokenExchange($input: CLITokenExchangeInput!) {
84
83
  `;
85
84
  class Login extends Command {
86
85
  async run() {
87
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
86
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
88
87
  try {
89
88
  await initClient(this, false);
90
89
  const { flags } = await this.parse(Login);
@@ -94,7 +93,7 @@ class Login extends Command {
94
93
  let email = flags.email;
95
94
  let organizationId = existingCreds.organizationID;
96
95
  let organizationName;
97
- let clientIDCandidate = (_a = existingCreds.clientID) !== null && _a !== void 0 ? _a : configData.creds.clientIDCandidate; // configData.creds.clientIDCandidate is pre-4.0, load from here for backwards-compat
96
+ let clientIDCandidate = (_a = existingCreds.clientID) !== null && _a !== void 0 ? _a : (_b = configData === null || configData === void 0 ? void 0 : configData.creds) === null || _b === void 0 ? void 0 : _b.clientIDCandidate; // configData.creds.clientIDCandidate is pre-4.0, load from here for backwards-compat
98
97
  const useDeviceCodeFlow = flags["device-code"];
99
98
  // If user starts a new login, remove their existing auth cookie / API token
100
99
  await removeAuthSecret(this);
@@ -145,11 +144,11 @@ class Login extends Command {
145
144
  return handleError(this, "Could not connect to Opal. Did you set the right URL? (`opal set-url --help`)");
146
145
  }
147
146
  }
148
- const signInOrganizations = ((_c = (_b = signInOrganizationsResponse === null || signInOrganizationsResponse === void 0 ? void 0 : signInOrganizationsResponse.data) === null || _b === void 0 ? void 0 : _b.signInMethod) === null || _c === void 0 ? void 0 : _c.__typename) ===
147
+ const signInOrganizations = ((_d = (_c = signInOrganizationsResponse === null || signInOrganizationsResponse === void 0 ? void 0 : signInOrganizationsResponse.data) === null || _c === void 0 ? void 0 : _c.signInMethod) === null || _d === void 0 ? void 0 : _d.__typename) ===
149
148
  "SignInMethodResult"
150
149
  ? signInOrganizationsResponse.data.signInMethod.signInOrganizations
151
- : ((_e = (_d = signInOrganizationsLegacyResponse === null || signInOrganizationsLegacyResponse === void 0 ? void 0 : signInOrganizationsLegacyResponse.data) === null || _d === void 0 ? void 0 : _d.signInMethod) === null || _e === void 0 ? void 0 : _e.__typename) === "SignInMethodResult"
152
- ? (_f = signInOrganizationsLegacyResponse === null || signInOrganizationsLegacyResponse === void 0 ? void 0 : signInOrganizationsLegacyResponse.data.signInMethod) === null || _f === void 0 ? void 0 : _f.signInOrganizations
150
+ : ((_f = (_e = signInOrganizationsLegacyResponse === null || signInOrganizationsLegacyResponse === void 0 ? void 0 : signInOrganizationsLegacyResponse.data) === null || _e === void 0 ? void 0 : _e.signInMethod) === null || _f === void 0 ? void 0 : _f.__typename) === "SignInMethodResult"
151
+ ? (_g = signInOrganizationsLegacyResponse === null || signInOrganizationsLegacyResponse === void 0 ? void 0 : signInOrganizationsLegacyResponse.data.signInMethod) === null || _g === void 0 ? void 0 : _g.signInOrganizations
153
152
  : undefined;
154
153
  if (signInOrganizations && signInOrganizations.length > 0) {
155
154
  if (signInOrganizations.length === 1) {
@@ -192,7 +191,7 @@ class Login extends Command {
192
191
  input: { organizationId },
193
192
  },
194
193
  });
195
- const signInRespState = (_h = (_g = signInResp === null || signInResp === void 0 ? void 0 : signInResp.data) === null || _g === void 0 ? void 0 : _g.signIn) === null || _h === void 0 ? void 0 : _h.state;
194
+ const signInRespState = (_j = (_h = signInResp === null || signInResp === void 0 ? void 0 : signInResp.data) === null || _h === void 0 ? void 0 : _h.signIn) === null || _j === void 0 ? void 0 : _j.state;
196
195
  let server; // Authorization Server's Issuer Identifier
197
196
  let clientId; // Client identifier at the Authorization Server
198
197
  let isAuth0Issuer = true;
@@ -221,7 +220,7 @@ class Login extends Command {
221
220
  // This scope is evaluated in Auth0 "MFA Rule" Action to skip or enabled MFA
222
221
  let scope = "openid email profile";
223
222
  // This extra scope is only supported in Auth0, so if the user has a custom issuer, we omit it
224
- if (!((_k = (_j = signInResp === null || signInResp === void 0 ? void 0 : signInResp.data) === null || _j === void 0 ? void 0 : _j.signIn) === null || _k === void 0 ? void 0 : _k.forceExtraStep) && isAuth0Issuer) {
223
+ if (!((_l = (_k = signInResp === null || signInResp === void 0 ? void 0 : signInResp.data) === null || _k === void 0 ? void 0 : _k.signIn) === null || _l === void 0 ? void 0 : _l.forceExtraStep) && isAuth0Issuer) {
225
224
  scope += " mfa:skip";
226
225
  }
227
226
  let tokens;
@@ -251,7 +250,7 @@ Verify this code in your browser
251
250
  {
252
251
  type: "input",
253
252
  name: "continue",
254
- message: "Press Enter to open your browser and continue",
253
+ message: "Press Enter to open your browser and continue\n",
255
254
  },
256
255
  ]);
257
256
  this.log(`
@@ -271,12 +270,12 @@ If your browser doesn't automatically, go to:
271
270
  }
272
271
  }
273
272
  else {
274
- const serverPromise = startLocalServer();
273
+ const { port, urlPromise } = await startLocalServer();
275
274
  const code_verifier = client.randomPKCECodeVerifier();
276
275
  const code_challenge = await client.calculatePKCECodeChallenge(code_verifier);
277
276
  const clientState = client.randomState();
278
277
  const parameters = {
279
- redirect_uri: REDIRECT_URI,
278
+ redirect_uri: `http://127.0.0.1:${port}/callback`,
280
279
  scope,
281
280
  code_challenge,
282
281
  code_challenge_method: "S256",
@@ -300,18 +299,18 @@ To continue, please authorize this application in your browser.
300
299
  {
301
300
  type: "input",
302
301
  name: "continue",
303
- message: "Press Enter to open your browser and continue",
302
+ message: "Press Enter to open your browser and continue\n",
304
303
  },
305
304
  ]);
306
305
  this.log(`
307
- If your browser doesn't automatically, go to:
308
-
306
+ If your browser doesn't automatically, go to:
307
+
309
308
  ${redirectTo}
310
309
  `);
311
310
  ux.action.start("Waiting for authorization");
312
311
  try {
313
312
  await open(redirectTo.toString(), { wait: false });
314
- const url = await serverPromise;
313
+ const url = await urlPromise;
315
314
  tokens = await client.authorizationCodeGrant(config, new URL(url), {
316
315
  pkceCodeVerifier: code_verifier,
317
316
  expectedState: clientState,
@@ -348,7 +347,7 @@ ${redirectTo}
348
347
  variables: {},
349
348
  });
350
349
  if (authCheckErr ||
351
- !((_o = (_m = (_l = authCheckResp === null || authCheckResp === void 0 ? void 0 : authCheckResp.data) === null || _l === void 0 ? void 0 : _l.organizationSettings) === null || _m === void 0 ? void 0 : _m.settings) === null || _o === void 0 ? void 0 : _o.id)) {
350
+ !((_p = (_o = (_m = authCheckResp === null || authCheckResp === void 0 ? void 0 : authCheckResp.data) === null || _m === void 0 ? void 0 : _m.organizationSettings) === null || _o === void 0 ? void 0 : _o.settings) === null || _p === void 0 ? void 0 : _p.id)) {
352
351
  this.log("Error verifying log in. Authenticated commands may fail. Please double check your URL and use `opal logout; opal login` to try again.\n");
353
352
  await removeAuthSecret(this);
354
353
  process.exit(1);
@@ -6,8 +6,6 @@ export default class StartPostgresInstanceSession extends Command {
6
6
  help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
7
7
  id: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
8
8
  accessLevelRemoteId: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
9
- sessionId: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
10
- refresh: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
11
9
  action: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
12
10
  };
13
11
  run(): Promise<void>;