opal-security 4.1.0 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md 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.1.0 darwin-arm64 node-v18.20.5
25
+ opal-security/5.0.1 darwin-arm64 node-v22.21.1
26
26
  $ opal --help [COMMAND]
27
27
  USAGE
28
28
  $ opal COMMAND
@@ -68,7 +68,7 @@ USAGE
68
68
  $ opal autocomplete [SHELL] [-r]
69
69
 
70
70
  ARGUMENTS
71
- SHELL shell type
71
+ [SHELL] shell type
72
72
 
73
73
  FLAGS
74
74
  -r, --refresh-cache Refresh cache (ignores displaying instructions)
@@ -106,7 +106,7 @@ EXAMPLES
106
106
  $ opal aws:identity
107
107
  ```
108
108
 
109
- _See code: [src/commands/aws/identity.ts](https://github.com/opalsecurity/opal-cli/blob/v4.1.0/src/commands/aws/identity.ts)_
109
+ _See code: [src/commands/aws/identity.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.1/src/commands/aws/identity.ts)_
110
110
 
111
111
  ## `opal clear-auth-config`
112
112
 
@@ -123,7 +123,7 @@ EXAMPLES
123
123
  $ opal clear-auth-config
124
124
  ```
125
125
 
126
- _See code: [src/commands/clear-auth-config.ts](https://github.com/opalsecurity/opal-cli/blob/v4.1.0/src/commands/clear-auth-config.ts)_
126
+ _See code: [src/commands/clear-auth-config.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.1/src/commands/clear-auth-config.ts)_
127
127
 
128
128
  ## `opal curl-example`
129
129
 
@@ -140,7 +140,7 @@ DESCRIPTION
140
140
  Prints out an example cURL command containing the parameters the CLI uses to query the Opal server.
141
141
  ```
142
142
 
143
- _See code: [src/commands/curl-example.ts](https://github.com/opalsecurity/opal-cli/blob/v4.1.0/src/commands/curl-example.ts)_
143
+ _See code: [src/commands/curl-example.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.1/src/commands/curl-example.ts)_
144
144
 
145
145
  ## `opal groups get`
146
146
 
@@ -161,7 +161,7 @@ EXAMPLES
161
161
  $ opal groups:get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4
162
162
  ```
163
163
 
164
- _See code: [src/commands/groups/get.ts](https://github.com/opalsecurity/opal-cli/blob/v4.1.0/src/commands/groups/get.ts)_
164
+ _See code: [src/commands/groups/get.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.1/src/commands/groups/get.ts)_
165
165
 
166
166
  ## `opal help [COMMANDS]`
167
167
 
@@ -172,7 +172,7 @@ USAGE
172
172
  $ opal help [COMMANDS...] [-n]
173
173
 
174
174
  ARGUMENTS
175
- COMMANDS... Command to show help for.
175
+ [COMMANDS...] Command to show help for.
176
176
 
177
177
  FLAGS
178
178
  -n, --nested-commands Include all nested commands in the output.
@@ -189,15 +189,12 @@ Starts a session to assume an IAM role.
189
189
 
190
190
  ```
191
191
  USAGE
192
- $ opal iam-roles start [-h] [-i <value>] [-s <value>] [-r] [--profileName <value>]
192
+ $ opal iam-roles start [-h] [-i <value>] [--profileName <value>]
193
193
 
194
194
  FLAGS
195
195
  -h, --help Show CLI help.
196
196
  -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
197
197
  https://opal.dev/resources/[ID]
198
- -r, --refresh Starts a new session even if one already exists. Useful if a session is about to expire.
199
- -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
200
- web flow.
201
198
  --profileName=<value> Uses a custom AWS profile name for the IAM role. Default value is the role's name.
202
199
 
203
200
  DESCRIPTION
@@ -211,7 +208,7 @@ EXAMPLES
211
208
  $ opal iam-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --profileName "custom-profile"
212
209
  ```
213
210
 
214
- _See code: [src/commands/iam-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v4.1.0/src/commands/iam-roles/start.ts)_
211
+ _See code: [src/commands/iam-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.1/src/commands/iam-roles/start.ts)_
215
212
 
216
213
  ## `opal kube-roles start`
217
214
 
@@ -219,17 +216,13 @@ Starts a session to assume a Kubernetes cluster IAM role.
219
216
 
220
217
  ```
221
218
  USAGE
222
- $ opal kube-roles start [-h] [-i <value>] [-a <value>] [-s <value>] [-r]
219
+ $ opal kube-roles start [-h] [-i <value>] [-a <value>]
223
220
 
224
221
  FLAGS
225
222
  -a, --accessLevelRemoteId=<value> The remote ID of the access level with which to access the resource.
226
223
  -h, --help Show CLI help.
227
224
  -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
228
225
  https://opal.dev/resources/[ID]
229
- -r, --refresh Starts a new session even if one already exists. Useful if a session is about to
230
- expire.
231
- -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created
232
- via the web flow.
233
226
 
234
227
  DESCRIPTION
235
228
  Starts a session to assume a Kubernetes cluster IAM role.
@@ -242,7 +235,7 @@ EXAMPLES
242
235
  $ opal kube-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --accessLevelRemoteId "arn:aws:iam::712234975475:role/acme-eks-cluster-admin-role"
243
236
  ```
244
237
 
245
- _See code: [src/commands/kube-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v4.1.0/src/commands/kube-roles/start.ts)_
238
+ _See code: [src/commands/kube-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.1/src/commands/kube-roles/start.ts)_
246
239
 
247
240
  ## `opal login`
248
241
 
@@ -265,7 +258,7 @@ EXAMPLES
265
258
  $ opal login
266
259
  ```
267
260
 
268
- _See code: [src/commands/login.ts](https://github.com/opalsecurity/opal-cli/blob/v4.1.0/src/commands/login.ts)_
261
+ _See code: [src/commands/login.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.1/src/commands/login.ts)_
269
262
 
270
263
  ## `opal logout`
271
264
 
@@ -285,7 +278,7 @@ EXAMPLES
285
278
  $ opal logout
286
279
  ```
287
280
 
288
- _See code: [src/commands/logout.ts](https://github.com/opalsecurity/opal-cli/blob/v4.1.0/src/commands/logout.ts)_
281
+ _See code: [src/commands/logout.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.1/src/commands/logout.ts)_
289
282
 
290
283
  ## `opal postgres-instances start`
291
284
 
@@ -293,17 +286,13 @@ Starts a session to connect to a Postgres database.
293
286
 
294
287
  ```
295
288
  USAGE
296
- $ 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]
297
290
 
298
291
  FLAGS
299
292
  -a, --accessLevelRemoteId=<value> The remote ID of the access level with which to access the resource.
300
293
  -h, --help Show CLI help.
301
294
  -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
302
295
  https://opal.dev/resources/[ID]
303
- -r, --refresh Starts a new session even if one already exists. Useful if a session is about to
304
- expire.
305
- -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created
306
- via the web flow.
307
296
  --action=<option> Method of connecting to the database.
308
297
  - open: Open external database app
309
298
  - psql: Start psql session in shell
@@ -323,7 +312,7 @@ EXAMPLES
323
312
  $ opal postgres-instances:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --accessLevelRemoteId fullaccess --action view
324
313
  ```
325
314
 
326
- _See code: [src/commands/postgres-instances/start.ts](https://github.com/opalsecurity/opal-cli/blob/v4.1.0/src/commands/postgres-instances/start.ts)_
315
+ _See code: [src/commands/postgres-instances/start.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.1/src/commands/postgres-instances/start.ts)_
327
316
 
328
317
  ## `opal request create`
329
318
 
@@ -349,7 +338,7 @@ DESCRIPTION
349
338
  Creates an Opal access request via an interactive form
350
339
  ```
351
340
 
352
- _See code: [src/commands/request/create.ts](https://github.com/opalsecurity/opal-cli/blob/v4.1.0/src/commands/request/create.ts)_
341
+ _See code: [src/commands/request/create.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.1/src/commands/request/create.ts)_
353
342
 
354
343
  ## `opal request get`
355
344
 
@@ -373,7 +362,7 @@ EXAMPLES
373
362
  $ opal request get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4 --verbose
374
363
  ```
375
364
 
376
- _See code: [src/commands/request/get.ts](https://github.com/opalsecurity/opal-cli/blob/v4.1.0/src/commands/request/get.ts)_
365
+ _See code: [src/commands/request/get.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.1/src/commands/request/get.ts)_
377
366
 
378
367
  ## `opal request list`
379
368
 
@@ -405,7 +394,7 @@ EXAMPLES
405
394
  $ opal request list --n 5 --pending --verbose
406
395
  ```
407
396
 
408
- _See code: [src/commands/request/list.ts](https://github.com/opalsecurity/opal-cli/blob/v4.1.0/src/commands/request/list.ts)_
397
+ _See code: [src/commands/request/list.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.1/src/commands/request/list.ts)_
409
398
 
410
399
  ## `opal request ls`
411
400
 
@@ -456,7 +445,7 @@ EXAMPLES
456
445
  $ opal resources:get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4
457
446
  ```
458
447
 
459
- _See code: [src/commands/resources/get.ts](https://github.com/opalsecurity/opal-cli/blob/v4.1.0/src/commands/resources/get.ts)_
448
+ _See code: [src/commands/resources/get.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.1/src/commands/resources/get.ts)_
460
449
 
461
450
  ## `opal set-auth-config`
462
451
 
@@ -486,7 +475,7 @@ EXAMPLES
486
475
  $ opal set-auth-config --organizationID=org-456 --clientID=abc123 --issuerUrl=https://auth.example.com
487
476
  ```
488
477
 
489
- _See code: [src/commands/set-auth-config.ts](https://github.com/opalsecurity/opal-cli/blob/v4.1.0/src/commands/set-auth-config.ts)_
478
+ _See code: [src/commands/set-auth-config.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.1/src/commands/set-auth-config.ts)_
490
479
 
491
480
  ## `opal set-custom-header`
492
481
 
@@ -507,7 +496,7 @@ EXAMPLES
507
496
  $ opal set-custom-header --header 'cf-access-token: $TOKEN'
508
497
  ```
509
498
 
510
- _See code: [src/commands/set-custom-header.ts](https://github.com/opalsecurity/opal-cli/blob/v4.1.0/src/commands/set-custom-header.ts)_
499
+ _See code: [src/commands/set-custom-header.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.1/src/commands/set-custom-header.ts)_
511
500
 
512
501
  ## `opal set-token`
513
502
 
@@ -527,7 +516,7 @@ EXAMPLES
527
516
  $ opal set-token
528
517
  ```
529
518
 
530
- _See code: [src/commands/set-token.ts](https://github.com/opalsecurity/opal-cli/blob/v4.1.0/src/commands/set-token.ts)_
519
+ _See code: [src/commands/set-token.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.1/src/commands/set-token.ts)_
531
520
 
532
521
  ## `opal set-url [URL]`
533
522
 
@@ -538,7 +527,7 @@ USAGE
538
527
  $ opal set-url [URL] [-h] [--allowSelfSignedCerts]
539
528
 
540
529
  ARGUMENTS
541
- 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
542
531
 
543
532
  FLAGS
544
533
  -h, --help Show CLI help.
@@ -551,7 +540,7 @@ EXAMPLES
551
540
  $ opal set-url
552
541
  ```
553
542
 
554
- _See code: [src/commands/set-url.ts](https://github.com/opalsecurity/opal-cli/blob/v4.1.0/src/commands/set-url.ts)_
543
+ _See code: [src/commands/set-url.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.1/src/commands/set-url.ts)_
555
544
 
556
545
  ## `opal ssh copyFrom`
557
546
 
@@ -559,19 +548,16 @@ Use SCP to copy files from a compute instance.
559
548
 
560
549
  ```
561
550
  USAGE
562
- $ 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>]
563
552
 
564
553
  FLAGS
565
- -h, --help Show CLI help.
566
- -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
567
- https://opal.dev/resources/[ID]
568
- -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
569
- web flow.
570
- --dest=<value> [default: .] The directory you want your files to be copied to.
571
- --src=<value> (required) The directory or file you would like to copy over SCP. Note we only support one
572
- file or directory at a time.
573
- --user=<value> [default: ssm-user] The user you want to run SCP over. Keep in mind not all users will have
574
- 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.
575
561
 
576
562
  DESCRIPTION
577
563
  Use SCP to copy files from a compute instance.
@@ -582,7 +568,7 @@ EXAMPLES
582
568
  $ opal ssh:copyFrom --src instance/dir --dest my/dir --id 51f7176b-0464-4a6f-8369-e951e187b398
583
569
  ```
584
570
 
585
- _See code: [src/commands/ssh/copyFrom.ts](https://github.com/opalsecurity/opal-cli/blob/v4.1.0/src/commands/ssh/copyFrom.ts)_
571
+ _See code: [src/commands/ssh/copyFrom.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.1/src/commands/ssh/copyFrom.ts)_
586
572
 
587
573
  ## `opal ssh copyTo`
588
574
 
@@ -590,19 +576,16 @@ Use SCP to copy files to a compute instance.
590
576
 
591
577
  ```
592
578
  USAGE
593
- $ 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>]
594
580
 
595
581
  FLAGS
596
- -h, --help Show CLI help.
597
- -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
598
- https://opal.dev/resources/[ID]
599
- -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
600
- web flow.
601
- --dest=<value> [default: .] The directory you want your files to be copied to.
602
- --src=<value> (required) The directory or file you would like to copy over SCP. Note we only support one
603
- file or directory at a time.
604
- --user=<value> [default: ssm-user] The user you want to run SCP over. Keep in mind not all users will have
605
- 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.
606
589
 
607
590
  DESCRIPTION
608
591
  Use SCP to copy files to a compute instance.
@@ -613,7 +596,7 @@ EXAMPLES
613
596
  $ opal ssh:copyTo --src my/dir --dest instance/dir --id 51f7176b-0464-4a6f-8369-e951e187b398
614
597
  ```
615
598
 
616
- _See code: [src/commands/ssh/copyTo.ts](https://github.com/opalsecurity/opal-cli/blob/v4.1.0/src/commands/ssh/copyTo.ts)_
599
+ _See code: [src/commands/ssh/copyTo.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.1/src/commands/ssh/copyTo.ts)_
617
600
 
618
601
  ## `opal ssh start`
619
602
 
@@ -621,15 +604,11 @@ Starts an SSH session to access a compute instance.
621
604
 
622
605
  ```
623
606
  USAGE
624
- $ opal ssh start [-h] [-i <value>] [-s <value>] [-r]
607
+ $ opal ssh start [-h] [-i <value>]
625
608
 
626
609
  FLAGS
627
- -h, --help Show CLI help.
628
- -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
629
- https://opal.dev/resources/[ID]
630
- -r, --refresh Starts a new session even if one already exists. Useful if a session is about to expire.
631
- -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
632
- 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]
633
612
 
634
613
  DESCRIPTION
635
614
  Starts an SSH session to access a compute instance.
@@ -640,7 +619,7 @@ EXAMPLES
640
619
  $ opal ssh:start --id 51f7176b-0464-4a6f-8369-e951e187b398
641
620
  ```
642
621
 
643
- _See code: [src/commands/ssh/start.ts](https://github.com/opalsecurity/opal-cli/blob/v4.1.0/src/commands/ssh/start.ts)_
622
+ _See code: [src/commands/ssh/start.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.1/src/commands/ssh/start.ts)_
644
623
 
645
624
  ## `opal version`
646
625
 
@@ -677,5 +656,5 @@ DESCRIPTION
677
656
  Describes current url set, organization name, and logged in user if applicable.
678
657
  ```
679
658
 
680
- _See code: [src/commands/whoami.ts](https://github.com/opalsecurity/opal-cli/blob/v4.1.0/src/commands/whoami.ts)_
659
+ _See code: [src/commands/whoami.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.1/src/commands/whoami.ts)_
681
660
  <!-- commandsstop -->
@@ -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;
@@ -11,6 +11,7 @@ if (!globalThis.crypto) {
11
11
  import chalk from "chalk";
12
12
  import { runMutation, runQueryDeprecated } from "../handler.js";
13
13
  import { cookieStr, handleError, initClient } from "../lib/apollo.js";
14
+ import { clearPendingCommandAfterAuth, pendingCommandAfterAuth, } from "../lib/cmd.js";
14
15
  import { getOrCreateConfigData, isProduction, urlKey } from "../lib/config.js";
15
16
  import { SecretType, getOpalCredentials, removeAuthSecret, setOpalCredentials, } from "../lib/credentials/index.js";
16
17
  import { SHARED_FLAGS } from "../lib/flags.js";
@@ -83,7 +84,7 @@ mutation CLITokenExchange($input: CLITokenExchangeInput!) {
83
84
  `;
84
85
  class Login extends Command {
85
86
  async run() {
86
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
87
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
87
88
  try {
88
89
  await initClient(this, false);
89
90
  const { flags } = await this.parse(Login);
@@ -93,7 +94,7 @@ class Login extends Command {
93
94
  let email = flags.email;
94
95
  let organizationId = existingCreds.organizationID;
95
96
  let organizationName;
96
- 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
97
+ 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
97
98
  const useDeviceCodeFlow = flags["device-code"];
98
99
  // If user starts a new login, remove their existing auth cookie / API token
99
100
  await removeAuthSecret(this);
@@ -144,11 +145,11 @@ class Login extends Command {
144
145
  return handleError(this, "Could not connect to Opal. Did you set the right URL? (`opal set-url --help`)");
145
146
  }
146
147
  }
147
- 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) ===
148
+ 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) ===
148
149
  "SignInMethodResult"
149
150
  ? signInOrganizationsResponse.data.signInMethod.signInOrganizations
150
- : ((_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"
151
- ? (_f = signInOrganizationsLegacyResponse === null || signInOrganizationsLegacyResponse === void 0 ? void 0 : signInOrganizationsLegacyResponse.data.signInMethod) === null || _f === void 0 ? void 0 : _f.signInOrganizations
151
+ : ((_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"
152
+ ? (_g = signInOrganizationsLegacyResponse === null || signInOrganizationsLegacyResponse === void 0 ? void 0 : signInOrganizationsLegacyResponse.data.signInMethod) === null || _g === void 0 ? void 0 : _g.signInOrganizations
152
153
  : undefined;
153
154
  if (signInOrganizations && signInOrganizations.length > 0) {
154
155
  if (signInOrganizations.length === 1) {
@@ -191,7 +192,7 @@ class Login extends Command {
191
192
  input: { organizationId },
192
193
  },
193
194
  });
194
- 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;
195
+ 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;
195
196
  let server; // Authorization Server's Issuer Identifier
196
197
  let clientId; // Client identifier at the Authorization Server
197
198
  let isAuth0Issuer = true;
@@ -220,7 +221,7 @@ class Login extends Command {
220
221
  // This scope is evaluated in Auth0 "MFA Rule" Action to skip or enabled MFA
221
222
  let scope = "openid email profile";
222
223
  // This extra scope is only supported in Auth0, so if the user has a custom issuer, we omit it
223
- 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) {
224
+ 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) {
224
225
  scope += " mfa:skip";
225
226
  }
226
227
  let tokens;
@@ -347,12 +348,21 @@ ${redirectTo}
347
348
  variables: {},
348
349
  });
349
350
  if (authCheckErr ||
350
- !((_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)) {
351
+ !((_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)) {
351
352
  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");
352
353
  await removeAuthSecret(this);
353
354
  process.exit(1);
354
355
  }
355
356
  this.log("\nšŸŽ‰ You have successfully authenticated with Opal! You can now run authenticated commands.\n");
357
+ // If authentication was triggered by another command, re-run that command
358
+ if (pendingCommandAfterAuth) {
359
+ const { commandId, args } = pendingCommandAfterAuth;
360
+ clearPendingCommandAfterAuth();
361
+ this.log(`Resuming command: ${commandId}\n`);
362
+ // Re-run the original command
363
+ const { run } = await import("@oclif/core");
364
+ await run([commandId, ...args], this.config);
365
+ }
356
366
  process.exit(0);
357
367
  }
358
368
  catch (error) {
@@ -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>;
@@ -4,7 +4,7 @@ import { handleError } from "../../lib/apollo.js";
4
4
  import { runCommandExec, setMostRecentCommand, startInteractiveShell, } 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 } from "../../lib/sessions.js";
7
+ import { createSession } from "../../lib/sessions.js";
8
8
  import { displayContent } from "../../lib/util.js";
9
9
  const RdsSessionMetadataFragment = `
10
10
  ... on AwsIamFederatedRdsSession {
@@ -53,11 +53,11 @@ class StartPostgresInstanceSession extends Command {
53
53
  if (!accessLevel) {
54
54
  return;
55
55
  }
56
- const session = await getOrCreateSession(this, instanceId, accessLevel, sessionId, RdsSessionMetadataFragment, flags.refresh);
56
+ const session = await createSession(this, instanceId, accessLevel, sessionId, RdsSessionMetadataFragment);
57
57
  if (!session) {
58
58
  return;
59
59
  }
60
- const metadata = session.metadata;
60
+ const metadata = session.sessionMetadata;
61
61
  switch (metadata === null || metadata === void 0 ? void 0 : metadata.__typename) {
62
62
  case "AwsIamFederatedRdsSession": {
63
63
  // Don't inform the user about RDS session expiration time, since RDS works differently.
@@ -105,7 +105,7 @@ class StartPostgresInstanceSession extends Command {
105
105
  break;
106
106
  }
107
107
  default:
108
- return handleError(this, undefined, session);
108
+ return handleError(this, undefined);
109
109
  }
110
110
  }
111
111
  }
@@ -120,8 +120,6 @@ StartPostgresInstanceSession.flags = {
120
120
  help: SHARED_FLAGS.help,
121
121
  id: SHARED_FLAGS.id,
122
122
  accessLevelRemoteId: SHARED_FLAGS.accessLevelRemoteId,
123
- sessionId: SHARED_FLAGS.sessionId,
124
- refresh: SHARED_FLAGS.refresh,
125
123
  action: Flags.string({
126
124
  multiple: false,
127
125
  description: `Method of connecting to the database.\n${methodChoices.map((c) => `- ${c.value}: ${c.name}`).join("\n")}`,
@@ -8,7 +8,6 @@ export default class StartSCPSession extends Command {
8
8
  dest: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
9
9
  user: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
10
10
  id: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
11
- sessionId: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
12
11
  };
13
12
  run(): Promise<void>;
14
13
  }
@@ -3,7 +3,7 @@ import { handleError } from "../../lib/apollo.js";
3
3
  import { runCommandSpawn, setMostRecentCommand } from "../../lib/cmd.js";
4
4
  import { SHARED_FLAGS } from "../../lib/flags.js";
5
5
  import { DEFAULT_ACCESS_LEVEL } from "../../lib/resources.js";
6
- import { getOrCreateSession } from "../../lib/sessions.js";
6
+ import { createSession } from "../../lib/sessions.js";
7
7
  import { assertSessionManagerPluginExists, selectComputeInstance, } from "../../lib/ssh.js";
8
8
  import { Ec2SessionMetadataFragment } from "./start.js";
9
9
  class StartSCPSession extends Command {
@@ -25,11 +25,11 @@ class StartSCPSession extends Command {
25
25
  instanceId = selectedInstance.id;
26
26
  instanceName = selectedInstance.name;
27
27
  }
28
- const session = await getOrCreateSession(this, instanceId, DEFAULT_ACCESS_LEVEL, sessionId, Ec2SessionMetadataFragment);
28
+ const session = await createSession(this, instanceId, DEFAULT_ACCESS_LEVEL, sessionId, Ec2SessionMetadataFragment);
29
29
  if (!session) {
30
30
  return;
31
31
  }
32
- const metadata = session.metadata;
32
+ const metadata = session.sessionMetadata;
33
33
  switch (metadata === null || metadata === void 0 ? void 0 : metadata.__typename) {
34
34
  case "AwsIamFederatedSSMSession": {
35
35
  const envVars = {
@@ -44,7 +44,7 @@ class StartSCPSession extends Command {
44
44
  break;
45
45
  }
46
46
  default:
47
- return handleError(this, undefined, session);
47
+ return handleError(this, undefined);
48
48
  }
49
49
  }
50
50
  }
@@ -73,6 +73,5 @@ StartSCPSession.flags = {
73
73
  description: "The user you want to run SCP over. Keep in mind not all users will have access to each other's home directory.",
74
74
  }),
75
75
  id: SHARED_FLAGS.id,
76
- sessionId: SHARED_FLAGS.sessionId,
77
76
  };
78
77
  export default StartSCPSession;