opal-security 5.0.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/5.0.0 darwin-arm64 node-v22.21.1
25
+ opal-security/5.0.1 darwin-arm64 node-v22.21.1
26
26
  $ opal --help [COMMAND]
27
27
  USAGE
28
28
  $ opal COMMAND
@@ -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/v5.0.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/v5.0.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/v5.0.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/v5.0.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
 
@@ -208,7 +208,7 @@ EXAMPLES
208
208
  $ opal iam-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --profileName "custom-profile"
209
209
  ```
210
210
 
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)_
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)_
212
212
 
213
213
  ## `opal kube-roles start`
214
214
 
@@ -235,7 +235,7 @@ EXAMPLES
235
235
  $ opal kube-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --accessLevelRemoteId "arn:aws:iam::712234975475:role/acme-eks-cluster-admin-role"
236
236
  ```
237
237
 
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)_
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)_
239
239
 
240
240
  ## `opal login`
241
241
 
@@ -258,7 +258,7 @@ EXAMPLES
258
258
  $ opal login
259
259
  ```
260
260
 
261
- _See code: [src/commands/login.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.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)_
262
262
 
263
263
  ## `opal logout`
264
264
 
@@ -278,7 +278,7 @@ EXAMPLES
278
278
  $ opal logout
279
279
  ```
280
280
 
281
- _See code: [src/commands/logout.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.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)_
282
282
 
283
283
  ## `opal postgres-instances start`
284
284
 
@@ -312,7 +312,7 @@ EXAMPLES
312
312
  $ opal postgres-instances:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --accessLevelRemoteId fullaccess --action view
313
313
  ```
314
314
 
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)_
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)_
316
316
 
317
317
  ## `opal request create`
318
318
 
@@ -338,7 +338,7 @@ DESCRIPTION
338
338
  Creates an Opal access request via an interactive form
339
339
  ```
340
340
 
341
- _See code: [src/commands/request/create.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.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)_
342
342
 
343
343
  ## `opal request get`
344
344
 
@@ -362,7 +362,7 @@ EXAMPLES
362
362
  $ opal request get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4 --verbose
363
363
  ```
364
364
 
365
- _See code: [src/commands/request/get.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.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)_
366
366
 
367
367
  ## `opal request list`
368
368
 
@@ -394,7 +394,7 @@ EXAMPLES
394
394
  $ opal request list --n 5 --pending --verbose
395
395
  ```
396
396
 
397
- _See code: [src/commands/request/list.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.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)_
398
398
 
399
399
  ## `opal request ls`
400
400
 
@@ -445,7 +445,7 @@ EXAMPLES
445
445
  $ opal resources:get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4
446
446
  ```
447
447
 
448
- _See code: [src/commands/resources/get.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.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)_
449
449
 
450
450
  ## `opal set-auth-config`
451
451
 
@@ -475,7 +475,7 @@ EXAMPLES
475
475
  $ opal set-auth-config --organizationID=org-456 --clientID=abc123 --issuerUrl=https://auth.example.com
476
476
  ```
477
477
 
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)_
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)_
479
479
 
480
480
  ## `opal set-custom-header`
481
481
 
@@ -496,7 +496,7 @@ EXAMPLES
496
496
  $ opal set-custom-header --header 'cf-access-token: $TOKEN'
497
497
  ```
498
498
 
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)_
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)_
500
500
 
501
501
  ## `opal set-token`
502
502
 
@@ -516,7 +516,7 @@ EXAMPLES
516
516
  $ opal set-token
517
517
  ```
518
518
 
519
- _See code: [src/commands/set-token.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.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)_
520
520
 
521
521
  ## `opal set-url [URL]`
522
522
 
@@ -540,7 +540,7 @@ EXAMPLES
540
540
  $ opal set-url
541
541
  ```
542
542
 
543
- _See code: [src/commands/set-url.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.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)_
544
544
 
545
545
  ## `opal ssh copyFrom`
546
546
 
@@ -568,7 +568,7 @@ EXAMPLES
568
568
  $ opal ssh:copyFrom --src instance/dir --dest my/dir --id 51f7176b-0464-4a6f-8369-e951e187b398
569
569
  ```
570
570
 
571
- _See code: [src/commands/ssh/copyFrom.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.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)_
572
572
 
573
573
  ## `opal ssh copyTo`
574
574
 
@@ -596,7 +596,7 @@ EXAMPLES
596
596
  $ opal ssh:copyTo --src my/dir --dest instance/dir --id 51f7176b-0464-4a6f-8369-e951e187b398
597
597
  ```
598
598
 
599
- _See code: [src/commands/ssh/copyTo.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.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)_
600
600
 
601
601
  ## `opal ssh start`
602
602
 
@@ -619,7 +619,7 @@ EXAMPLES
619
619
  $ opal ssh:start --id 51f7176b-0464-4a6f-8369-e951e187b398
620
620
  ```
621
621
 
622
- _See code: [src/commands/ssh/start.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.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)_
623
623
 
624
624
  ## `opal version`
625
625
 
@@ -656,5 +656,5 @@ DESCRIPTION
656
656
  Describes current url set, organization name, and logged in user if applicable.
657
657
  ```
658
658
 
659
- _See code: [src/commands/whoami.ts](https://github.com/opalsecurity/opal-cli/blob/v5.0.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)_
660
660
  <!-- commandsstop -->
@@ -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";
@@ -353,6 +354,15 @@ ${redirectTo}
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) {
@@ -8,6 +8,7 @@ import { major } from "semver";
8
8
  import { invariant } from "@apollo/client/utilities/invariant";
9
9
  import { from } from "rxjs";
10
10
  import Login, { CLIAuthSessionCheckName, CLISignInMethodName, CLITokenExchangeName, } from "../commands/login.js";
11
+ import { setPendingCommandAfterAuth } from "./cmd.js";
11
12
  import { allowSelfSignedCertsKey, customHttpHeaderKey, getOrCreateConfigData, urlKey, } from "./config.js";
12
13
  import { SecretType, getOpalCredentials } from "./credentials/index.js";
13
14
  import http from "node:http";
@@ -168,6 +169,10 @@ export const initClient = async (command, fetchAccessToken = true) => {
168
169
  const errorMessage = error.message;
169
170
  if (errorMessage.includes("invalid authentication")) {
170
171
  command.log("Your session is invalid or expired. Authenticating now...\n");
172
+ // Store the current command for re-execution after auth
173
+ if (command.id) {
174
+ setPendingCommandAfterAuth(command.id, command.argv);
175
+ }
171
176
  const loginCommand = new Login([], command.config);
172
177
  return from(loginCommand.run()).pipe(mergeMap(() => forward(operation)));
173
178
  }
@@ -3,7 +3,13 @@ import type { Command } from "@oclif/core";
3
3
  import moment from "moment";
4
4
  export declare let mostRecentCommand: Command | null;
5
5
  export declare let mostRecentCommandTime: moment.Moment | null;
6
+ export declare let pendingCommandAfterAuth: {
7
+ commandId: string;
8
+ args: string[];
9
+ } | null;
6
10
  export declare const setMostRecentCommand: (cmd: Command) => void;
11
+ export declare const setPendingCommandAfterAuth: (commandId: string, args: string[]) => void;
12
+ export declare const clearPendingCommandAfterAuth: () => void;
7
13
  export declare const startInteractiveShell: (runCmd: string, shellName?: string) => void;
8
14
  export declare const runCommandExec: (runCmd: string, successMessage: string, errorMessage: string, envVars?: NodeJS.ProcessEnv) => void;
9
15
  export declare const runCommandExecWithCallback: (cmd: string, callback?: (error: ExecException | null, stdout: string, stderr: string) => void) => Promise<unknown>;
package/build/lib/cmd.js CHANGED
@@ -7,10 +7,21 @@ const __filename = fileURLToPath(import.meta.url);
7
7
  const __dirname = path.dirname(__filename);
8
8
  export let mostRecentCommand = null;
9
9
  export let mostRecentCommandTime = null;
10
+ // Store command info for re-execution after auth
11
+ export let pendingCommandAfterAuth = null;
10
12
  export const setMostRecentCommand = (cmd) => {
11
13
  mostRecentCommand = cmd;
12
14
  mostRecentCommandTime = moment(new Date());
13
15
  };
16
+ export const setPendingCommandAfterAuth = (commandId, args) => {
17
+ pendingCommandAfterAuth = {
18
+ commandId,
19
+ args,
20
+ };
21
+ };
22
+ export const clearPendingCommandAfterAuth = () => {
23
+ pendingCommandAfterAuth = null;
24
+ };
14
25
  export const startInteractiveShell = (runCmd, shellName) => {
15
26
  const shell = spawn(`${runCmd}`, [], {
16
27
  env: Object.assign(Object.assign({}, process.env), { SCRIPT_PATH: __dirname }),
@@ -383,12 +383,14 @@
383
383
  "identity.js"
384
384
  ]
385
385
  },
386
- "groups:get": {
386
+ "iam-roles:start": {
387
387
  "aliases": [],
388
388
  "args": {},
389
- "description": "Get group info for a particular group.",
389
+ "description": "Starts a session to assume an IAM role.",
390
390
  "examples": [
391
- "opal groups:get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4"
391
+ "opal iam-roles:start",
392
+ "opal iam-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398",
393
+ "opal iam-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --profileName \"custom-profile\""
392
394
  ],
393
395
  "flags": {
394
396
  "help": {
@@ -405,11 +407,18 @@
405
407
  "hasDynamicHelp": false,
406
408
  "multiple": false,
407
409
  "type": "option"
410
+ },
411
+ "profileName": {
412
+ "description": "Uses a custom AWS profile name for the IAM role. Default value is the role's name.",
413
+ "name": "profileName",
414
+ "hasDynamicHelp": false,
415
+ "multiple": false,
416
+ "type": "option"
408
417
  }
409
418
  },
410
419
  "hasDynamicHelp": false,
411
420
  "hiddenAliases": [],
412
- "id": "groups:get",
421
+ "id": "iam-roles:start",
413
422
  "pluginAlias": "opal-security",
414
423
  "pluginName": "opal-security",
415
424
  "pluginType": "core",
@@ -419,18 +428,16 @@
419
428
  "relativePath": [
420
429
  "build",
421
430
  "commands",
422
- "groups",
423
- "get.js"
431
+ "iam-roles",
432
+ "start.js"
424
433
  ]
425
434
  },
426
- "iam-roles:start": {
435
+ "groups:get": {
427
436
  "aliases": [],
428
437
  "args": {},
429
- "description": "Starts a session to assume an IAM role.",
438
+ "description": "Get group info for a particular group.",
430
439
  "examples": [
431
- "opal iam-roles:start",
432
- "opal iam-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398",
433
- "opal iam-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --profileName \"custom-profile\""
440
+ "opal groups:get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4"
434
441
  ],
435
442
  "flags": {
436
443
  "help": {
@@ -447,18 +454,11 @@
447
454
  "hasDynamicHelp": false,
448
455
  "multiple": false,
449
456
  "type": "option"
450
- },
451
- "profileName": {
452
- "description": "Uses a custom AWS profile name for the IAM role. Default value is the role's name.",
453
- "name": "profileName",
454
- "hasDynamicHelp": false,
455
- "multiple": false,
456
- "type": "option"
457
457
  }
458
458
  },
459
459
  "hasDynamicHelp": false,
460
460
  "hiddenAliases": [],
461
- "id": "iam-roles:start",
461
+ "id": "groups:get",
462
462
  "pluginAlias": "opal-security",
463
463
  "pluginName": "opal-security",
464
464
  "pluginType": "core",
@@ -468,8 +468,8 @@
468
468
  "relativePath": [
469
469
  "build",
470
470
  "commands",
471
- "iam-roles",
472
- "start.js"
471
+ "groups",
472
+ "get.js"
473
473
  ]
474
474
  },
475
475
  "kube-roles:start": {
@@ -978,5 +978,5 @@
978
978
  ]
979
979
  }
980
980
  },
981
- "version": "5.0.0"
981
+ "version": "5.0.1"
982
982
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "opal-security",
3
3
  "description": "Opal allows you to centrally manage access to all of your sensitive systems.",
4
- "version": "5.0.0",
4
+ "version": "5.0.1",
5
5
  "type": "module",
6
6
  "author": "Opal Security",
7
7
  "bin": {
@@ -32,7 +32,7 @@
32
32
  "sanitize-html": "^2.17.0",
33
33
  "semver": "^7.5.4",
34
34
  "tslib": "^2.8.1",
35
- "validator": "^13.15.20"
35
+ "validator": "^13.15.26"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@biomejs/biome": "1.9.4",
@@ -72,9 +72,7 @@
72
72
  "/scripts"
73
73
  ],
74
74
  "homepage": "https://github.com/opalsecurity/opal-cli/",
75
- "keywords": [
76
- "oclif"
77
- ],
75
+ "keywords": ["oclif"],
78
76
  "license": "MIT",
79
77
  "main": "build/index.js",
80
78
  "oclif": {