opal-security 3.0.1-beta.4262451 → 3.0.1-beta.cbf0332

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/3.0.1-beta.4262451 linux-x64 node-v20.19.0
25
+ opal-security/3.0.1-beta.cbf0332 linux-x64 node-v20.19.0
26
26
  $ opal --help [COMMAND]
27
27
  USAGE
28
28
  $ opal COMMAND
@@ -34,23 +34,24 @@ USAGE
34
34
 
35
35
  <!-- commands -->
36
36
  * [`opal autocomplete [SHELL]`](#opal-autocomplete-shell)
37
- * [`opal aws:identity`](#opal-awsidentity)
37
+ * [`opal aws identity`](#opal-aws-identity)
38
38
  * [`opal clear-auth-provider`](#opal-clear-auth-provider)
39
39
  * [`opal curl-example`](#opal-curl-example)
40
40
  * [`opal help [COMMANDS]`](#opal-help-commands)
41
- * [`opal iam-roles:start`](#opal-iam-rolesstart)
42
- * [`opal kube-roles:start`](#opal-kube-rolesstart)
41
+ * [`opal iam-roles start`](#opal-iam-roles-start)
42
+ * [`opal kube-roles start`](#opal-kube-roles-start)
43
43
  * [`opal login`](#opal-login)
44
44
  * [`opal logout`](#opal-logout)
45
- * [`opal postgres-instances:start`](#opal-postgres-instancesstart)
46
- * [`opal resources:get`](#opal-resourcesget)
45
+ * [`opal postgres-instances start`](#opal-postgres-instances-start)
46
+ * [`opal request ls`](#opal-request-ls)
47
+ * [`opal resources get`](#opal-resources-get)
47
48
  * [`opal set-auth-provider`](#opal-set-auth-provider)
48
49
  * [`opal set-custom-header`](#opal-set-custom-header)
49
50
  * [`opal set-token`](#opal-set-token)
50
51
  * [`opal set-url [URL]`](#opal-set-url-url)
51
- * [`opal ssh:copyFrom`](#opal-sshcopyfrom)
52
- * [`opal ssh:copyTo`](#opal-sshcopyto)
53
- * [`opal ssh:start`](#opal-sshstart)
52
+ * [`opal ssh copyFrom`](#opal-ssh-copyfrom)
53
+ * [`opal ssh copyTo`](#opal-ssh-copyto)
54
+ * [`opal ssh start`](#opal-ssh-start)
54
55
  * [`opal version`](#opal-version)
55
56
 
56
57
  ## `opal autocomplete [SHELL]`
@@ -82,13 +83,13 @@ EXAMPLES
82
83
 
83
84
  _See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v1.4.6/src/commands/autocomplete/index.ts)_
84
85
 
85
- ## `opal aws:identity`
86
+ ## `opal aws identity`
86
87
 
87
88
  Gets the current caller identity for the "opal" AWS profile.
88
89
 
89
90
  ```
90
91
  USAGE
91
- $ opal aws:identity [-h]
92
+ $ opal aws identity [-h]
92
93
 
93
94
  FLAGS
94
95
  -h, --help Show CLI help.
@@ -100,7 +101,7 @@ EXAMPLES
100
101
  $ opal aws:identity
101
102
  ```
102
103
 
103
- _See code: [src/commands/aws/identity.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.4262451/src/commands/aws/identity.ts)_
104
+ _See code: [src/commands/aws/identity.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.cbf0332/src/commands/aws/identity.ts)_
104
105
 
105
106
  ## `opal clear-auth-provider`
106
107
 
@@ -120,7 +121,7 @@ EXAMPLES
120
121
  $ opal clear-auth-provider
121
122
  ```
122
123
 
123
- _See code: [src/commands/clear-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.4262451/src/commands/clear-auth-provider.ts)_
124
+ _See code: [src/commands/clear-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.cbf0332/src/commands/clear-auth-provider.ts)_
124
125
 
125
126
  ## `opal curl-example`
126
127
 
@@ -137,7 +138,7 @@ DESCRIPTION
137
138
  Prints out an example cURL command containing the parameters the CLI uses to query the Opal server.
138
139
  ```
139
140
 
140
- _See code: [src/commands/curl-example.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.4262451/src/commands/curl-example.ts)_
141
+ _See code: [src/commands/curl-example.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.cbf0332/src/commands/curl-example.ts)_
141
142
 
142
143
  ## `opal help [COMMANDS]`
143
144
 
@@ -159,13 +160,13 @@ DESCRIPTION
159
160
 
160
161
  _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.2.20/src/commands/help.ts)_
161
162
 
162
- ## `opal iam-roles:start`
163
+ ## `opal iam-roles start`
163
164
 
164
165
  Starts a session to assume an IAM role.
165
166
 
166
167
  ```
167
168
  USAGE
168
- $ opal iam-roles:start [-h] [-i <value>] [-s <value>] [-r] [--profileName <value>]
169
+ $ opal iam-roles start [-h] [-i <value>] [-s <value>] [-r] [--profileName <value>]
169
170
 
170
171
  FLAGS
171
172
  -h, --help Show CLI help.
@@ -187,15 +188,15 @@ EXAMPLES
187
188
  $ opal iam-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --profileName "custom-profile"
188
189
  ```
189
190
 
190
- _See code: [src/commands/iam-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.4262451/src/commands/iam-roles/start.ts)_
191
+ _See code: [src/commands/iam-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.cbf0332/src/commands/iam-roles/start.ts)_
191
192
 
192
- ## `opal kube-roles:start`
193
+ ## `opal kube-roles start`
193
194
 
194
195
  Starts a session to assume a Kubernetes cluster IAM role.
195
196
 
196
197
  ```
197
198
  USAGE
198
- $ opal kube-roles:start [-h] [-i <value>] [-a <value>] [-s <value>] [-r]
199
+ $ opal kube-roles start [-h] [-i <value>] [-a <value>] [-s <value>] [-r]
199
200
 
200
201
  FLAGS
201
202
  -a, --accessLevelRemoteId=<value> The remote ID of the access level with which to access the resource.
@@ -218,7 +219,7 @@ EXAMPLES
218
219
  $ opal kube-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --accessLevelRemoteId "arn:aws:iam::712234975475:role/acme-eks-cluster-admin-role"
219
220
  ```
220
221
 
221
- _See code: [src/commands/kube-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.4262451/src/commands/kube-roles/start.ts)_
222
+ _See code: [src/commands/kube-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.cbf0332/src/commands/kube-roles/start.ts)_
222
223
 
223
224
  ## `opal login`
224
225
 
@@ -239,7 +240,7 @@ EXAMPLES
239
240
  $ opal login
240
241
  ```
241
242
 
242
- _See code: [src/commands/login.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.4262451/src/commands/login.ts)_
243
+ _See code: [src/commands/login.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.cbf0332/src/commands/login.ts)_
243
244
 
244
245
  ## `opal logout`
245
246
 
@@ -259,15 +260,15 @@ EXAMPLES
259
260
  $ opal logout
260
261
  ```
261
262
 
262
- _See code: [src/commands/logout.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.4262451/src/commands/logout.ts)_
263
+ _See code: [src/commands/logout.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.cbf0332/src/commands/logout.ts)_
263
264
 
264
- ## `opal postgres-instances:start`
265
+ ## `opal postgres-instances start`
265
266
 
266
267
  Starts a session to connect to a Postgres database.
267
268
 
268
269
  ```
269
270
  USAGE
270
- $ opal postgres-instances:start [-h] [-i <value>] [-a <value>] [-s <value>] [-r] [--action psql|view]
271
+ $ opal postgres-instances start [-h] [-i <value>] [-a <value>] [-s <value>] [-r] [--action psql|view]
271
272
 
272
273
  FLAGS
273
274
  -a, --accessLevelRemoteId=<value> The remote ID of the access level with which to access the resource.
@@ -296,15 +297,30 @@ EXAMPLES
296
297
  $ opal postgres-instances:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --accessLevelRemoteId fullaccess --action view
297
298
  ```
298
299
 
299
- _See code: [src/commands/postgres-instances/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.4262451/src/commands/postgres-instances/start.ts)_
300
+ _See code: [src/commands/postgres-instances/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.cbf0332/src/commands/postgres-instances/start.ts)_
300
301
 
301
- ## `opal resources:get`
302
+ ## `opal request ls`
303
+
304
+ Lists access requests
305
+
306
+ ```
307
+ USAGE
308
+ $ opal request ls
309
+
310
+ DESCRIPTION
311
+ Lists access requests
312
+
313
+ ALIASES
314
+ $ opal request ls
315
+ ```
316
+
317
+ ## `opal resources get`
302
318
 
303
319
  Get resource info for a particular resource.
304
320
 
305
321
  ```
306
322
  USAGE
307
- $ opal resources:get [-h] [-i <value>]
323
+ $ opal resources get [-h] [-i <value>]
308
324
 
309
325
  FLAGS
310
326
  -h, --help Show CLI help.
@@ -317,7 +333,7 @@ EXAMPLES
317
333
  $ opal resources:get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4
318
334
  ```
319
335
 
320
- _See code: [src/commands/resources/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.4262451/src/commands/resources/get.ts)_
336
+ _See code: [src/commands/resources/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.cbf0332/src/commands/resources/get.ts)_
321
337
 
322
338
  ## `opal set-auth-provider`
323
339
 
@@ -343,7 +359,7 @@ EXAMPLES
343
359
  $ opal set-auth-provider --clientID 1234asdf --issuerUrl https://auth.example.com
344
360
  ```
345
361
 
346
- _See code: [src/commands/set-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.4262451/src/commands/set-auth-provider.ts)_
362
+ _See code: [src/commands/set-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.cbf0332/src/commands/set-auth-provider.ts)_
347
363
 
348
364
  ## `opal set-custom-header`
349
365
 
@@ -364,7 +380,7 @@ EXAMPLES
364
380
  $ opal set-custom-header --header 'cf-access-token: $TOKEN'
365
381
  ```
366
382
 
367
- _See code: [src/commands/set-custom-header.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.4262451/src/commands/set-custom-header.ts)_
383
+ _See code: [src/commands/set-custom-header.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.cbf0332/src/commands/set-custom-header.ts)_
368
384
 
369
385
  ## `opal set-token`
370
386
 
@@ -384,7 +400,7 @@ EXAMPLES
384
400
  $ opal set-token
385
401
  ```
386
402
 
387
- _See code: [src/commands/set-token.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.4262451/src/commands/set-token.ts)_
403
+ _See code: [src/commands/set-token.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.cbf0332/src/commands/set-token.ts)_
388
404
 
389
405
  ## `opal set-url [URL]`
390
406
 
@@ -408,15 +424,15 @@ EXAMPLES
408
424
  $ opal set-url
409
425
  ```
410
426
 
411
- _See code: [src/commands/set-url.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.4262451/src/commands/set-url.ts)_
427
+ _See code: [src/commands/set-url.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.cbf0332/src/commands/set-url.ts)_
412
428
 
413
- ## `opal ssh:copyFrom`
429
+ ## `opal ssh copyFrom`
414
430
 
415
431
  Use SCP to copy files from a compute instance.
416
432
 
417
433
  ```
418
434
  USAGE
419
- $ opal ssh:copyFrom --src <value> [-h] [--dest <value>] [--user <value>] [-i <value>] [-s <value>]
435
+ $ opal ssh copyFrom --src <value> [-h] [--dest <value>] [--user <value>] [-i <value>] [-s <value>]
420
436
 
421
437
  FLAGS
422
438
  -h, --help Show CLI help.
@@ -439,15 +455,15 @@ EXAMPLES
439
455
  $ opal ssh:copyFrom --src instance/dir --dest my/dir --id 51f7176b-0464-4a6f-8369-e951e187b398
440
456
  ```
441
457
 
442
- _See code: [src/commands/ssh/copyFrom.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.4262451/src/commands/ssh/copyFrom.ts)_
458
+ _See code: [src/commands/ssh/copyFrom.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.cbf0332/src/commands/ssh/copyFrom.ts)_
443
459
 
444
- ## `opal ssh:copyTo`
460
+ ## `opal ssh copyTo`
445
461
 
446
462
  Use SCP to copy files to a compute instance.
447
463
 
448
464
  ```
449
465
  USAGE
450
- $ opal ssh:copyTo --src <value> [-h] [--dest <value>] [--user <value>] [-i <value>] [-s <value>]
466
+ $ opal ssh copyTo --src <value> [-h] [--dest <value>] [--user <value>] [-i <value>] [-s <value>]
451
467
 
452
468
  FLAGS
453
469
  -h, --help Show CLI help.
@@ -470,15 +486,15 @@ EXAMPLES
470
486
  $ opal ssh:copyTo --src my/dir --dest instance/dir --id 51f7176b-0464-4a6f-8369-e951e187b398
471
487
  ```
472
488
 
473
- _See code: [src/commands/ssh/copyTo.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.4262451/src/commands/ssh/copyTo.ts)_
489
+ _See code: [src/commands/ssh/copyTo.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.cbf0332/src/commands/ssh/copyTo.ts)_
474
490
 
475
- ## `opal ssh:start`
491
+ ## `opal ssh start`
476
492
 
477
493
  Starts an SSH session to access a compute instance.
478
494
 
479
495
  ```
480
496
  USAGE
481
- $ opal ssh:start [-h] [-i <value>] [-s <value>] [-r]
497
+ $ opal ssh start [-h] [-i <value>] [-s <value>] [-r]
482
498
 
483
499
  FLAGS
484
500
  -h, --help Show CLI help.
@@ -497,7 +513,7 @@ EXAMPLES
497
513
  $ opal ssh:start --id 51f7176b-0464-4a6f-8369-e951e187b398
498
514
  ```
499
515
 
500
- _See code: [src/commands/ssh/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.4262451/src/commands/ssh/start.ts)_
516
+ _See code: [src/commands/ssh/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.0.1-beta.cbf0332/src/commands/ssh/start.ts)_
501
517
 
502
518
  ## `opal version`
503
519
 
@@ -517,5 +533,5 @@ FLAG DESCRIPTIONS
517
533
  Additionally shows the architecture, node version, operating system, and versions of plugins that the CLI is using.
518
534
  ```
519
535
 
520
- _See code: [@oclif/plugin-version](https://github.com/oclif/plugin-version/blob/v2.0.12/src/commands/version.ts)_
536
+ _See code: [@oclif/plugin-version](https://github.com/oclif/plugin-version/blob/v2.2.27/src/commands/version.ts)_
521
537
  <!-- commandsstop -->
package/bin/run CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const engineMajorVersion = parseInt(process.version.slice(1).split('.'));
3
+ const engineMajorVersion = Number.parseInt(process.version.slice(1).split('.'));
4
4
  if (engineMajorVersion < 18) {
5
5
  console.log("Opal CLI requires Node v18.0.0 or later to run.")
6
6
  process.exit(1)
@@ -0,0 +1,6 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class RequestCreate extends Command {
3
+ static hidden: boolean;
4
+ static description: string;
5
+ run(): Promise<void>;
6
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const requests_1 = require("../../lib/requests");
5
+ const displays_1 = require("../../utils/displays");
6
+ const utils_1 = require("../../utils/utils");
7
+ class RequestCreate extends core_1.Command {
8
+ async run() {
9
+ (0, utils_1.restrictToDev)(); //TODO: Remove after development is complete
10
+ const requestMap = new Map();
11
+ (0, displays_1.headerMessage)();
12
+ let shouldProceed = false;
13
+ while (!shouldProceed) {
14
+ // Step 1: Select first round of assets from an app
15
+ await (0, requests_1.selectRequestableItems)(requestMap);
16
+ // Step 2: Display the selected items in a tree format
17
+ (0, displays_1.headerMessage)();
18
+ console.log((0, displays_1.treeifyRequestMap)(requestMap), "\n");
19
+ // Step 3: Prompt to add more items, repeat 1-3 if needed
20
+ shouldProceed = await (0, requests_1.doneSelectingAssets)();
21
+ }
22
+ // Step 4: Prompt for reason
23
+ const { reason } = await (0, requests_1.promptForReason)();
24
+ // Step 5: Prompt for expiration
25
+ const { expiration } = await (0, requests_1.promptForExpiration)();
26
+ // Step 6: Display final summary of request
27
+ (0, displays_1.displayFinalRequestSummary)(requestMap, reason, expiration);
28
+ // Step 7: Prompt for final submition
29
+ await (0, requests_1.submitFinalRequest)();
30
+ }
31
+ }
32
+ RequestCreate.hidden = true;
33
+ RequestCreate.description = "Opens an Opal access request";
34
+ exports.default = RequestCreate;
@@ -0,0 +1,6 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class RequestGet extends Command {
3
+ static hidden: boolean;
4
+ static description: string;
5
+ run(): Promise<void>;
6
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const utils_1 = require("../../utils/utils");
5
+ class RequestGet extends core_1.Command {
6
+ async run() {
7
+ (0, utils_1.restrictToDev)(); //TODO: Remove after development is complete
8
+ this.log("Running the get command");
9
+ }
10
+ }
11
+ RequestGet.hidden = true;
12
+ RequestGet.description = "Lists access requests";
13
+ exports.default = RequestGet;
@@ -0,0 +1,7 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class RequestList extends Command {
3
+ static hidden: boolean;
4
+ static description: string;
5
+ static aliases: string[];
6
+ run(): Promise<void>;
7
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const utils_1 = require("../../utils/utils");
5
+ class RequestList extends core_1.Command {
6
+ async run() {
7
+ (0, utils_1.restrictToDev)(); //TODO: Remove after development is complete
8
+ this.log("Running the list command");
9
+ }
10
+ }
11
+ RequestList.hidden = true;
12
+ RequestList.description = "Lists access requests";
13
+ RequestList.aliases = ["request:ls"];
14
+ exports.default = RequestList;
@@ -0,0 +1,19 @@
1
+ export interface AppNode {
2
+ appName: string;
3
+ assets: Map<string, AssetNode>;
4
+ }
5
+ export interface AssetNode {
6
+ assetName: string;
7
+ roles?: Map<string, RoleNode>;
8
+ }
9
+ export interface RoleNode {
10
+ roleName: string;
11
+ }
12
+ export type RequestMap = Map<string, AppNode>;
13
+ export declare function selectRequestableItems(requestMap: RequestMap): Promise<void>;
14
+ export declare function chooseAssets(app: string, requestMap: RequestMap): Promise<void>;
15
+ export declare function chooseRoles(app: string, asset: string, requestMap: RequestMap): Promise<void>;
16
+ export declare function doneSelectingAssets(): Promise<boolean>;
17
+ export declare function promptForReason(): Promise<any>;
18
+ export declare function promptForExpiration(): Promise<any>;
19
+ export declare function submitFinalRequest(): Promise<void>;
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.selectRequestableItems = selectRequestableItems;
4
+ exports.chooseAssets = chooseAssets;
5
+ exports.chooseRoles = chooseRoles;
6
+ exports.doneSelectingAssets = doneSelectingAssets;
7
+ exports.promptForReason = promptForReason;
8
+ exports.promptForExpiration = promptForExpiration;
9
+ exports.submitFinalRequest = submitFinalRequest;
10
+ const inquirer = require("inquirer");
11
+ async function selectRequestableItems(requestMap) {
12
+ const { app } = await inquirer.prompt({
13
+ name: "app",
14
+ type: "list",
15
+ message: "Select App:",
16
+ choices: ["Github", "Google Groups", "MongoDB", "Primary AD Server"],
17
+ });
18
+ // Set the app in the requestMap and call choose assets step
19
+ if (!requestMap.has(app)) {
20
+ requestMap.set(app, {
21
+ appName: app,
22
+ assets: new Map(),
23
+ });
24
+ }
25
+ await chooseAssets(app, requestMap);
26
+ }
27
+ async function chooseAssets(app, requestMap) {
28
+ const { assets } = await inquirer.prompt({
29
+ name: "assets",
30
+ type: "checkbox",
31
+ message: "Select one or more items:",
32
+ choices: ["Asset 1", "Asset 2", "Asset 3", "Asset 4"],
33
+ });
34
+ const entry = requestMap.get(app);
35
+ for (const asset of assets) {
36
+ if (entry === undefined) {
37
+ throw new Error(`App ${app} not found in requestMap`);
38
+ }
39
+ if (!entry.assets.has(asset)) {
40
+ entry.assets.set(asset, {
41
+ assetName: asset,
42
+ roles: new Map(),
43
+ });
44
+ }
45
+ await chooseRoles(app, asset, requestMap);
46
+ }
47
+ }
48
+ async function chooseRoles(app, asset, requestMap) {
49
+ var _a;
50
+ const { roles } = await inquirer.prompt({
51
+ name: "roles",
52
+ type: "checkbox",
53
+ message: `Select one or more roles for ${asset}:`,
54
+ choices: ["push", "pull", "triage", "admin"],
55
+ });
56
+ const entry = requestMap.get(app);
57
+ const assetEntry = entry === null || entry === void 0 ? void 0 : entry.assets.get(asset);
58
+ if (entry === undefined || assetEntry === undefined) {
59
+ throw new Error(`App ${app} or Asset ${asset} not found in requestMap`);
60
+ }
61
+ for (const role of roles) {
62
+ (_a = assetEntry.roles) === null || _a === void 0 ? void 0 : _a.set(role, {
63
+ roleName: role,
64
+ });
65
+ }
66
+ }
67
+ async function doneSelectingAssets() {
68
+ const submitMessage = "✅ Yes, proceed with request";
69
+ const addMoreMessage = "❌ No, add more items";
70
+ const { submitOrAdd } = await inquirer.prompt([
71
+ {
72
+ name: "submitOrAdd",
73
+ message: "Is this all you want to request?",
74
+ type: "list",
75
+ choices: [submitMessage, addMoreMessage],
76
+ },
77
+ ]);
78
+ return submitOrAdd === submitMessage;
79
+ }
80
+ async function promptForReason() {
81
+ return await inquirer.prompt([
82
+ {
83
+ name: "reason",
84
+ message: "I need access to this because...",
85
+ type: "input",
86
+ },
87
+ ]);
88
+ }
89
+ async function promptForExpiration() {
90
+ return await inquirer.prompt([
91
+ {
92
+ name: "expiration",
93
+ message: "When should access expire?",
94
+ type: "list",
95
+ choices: ["1 hour", "1 day", "7 days", "30 days", "1 year", "Indefinite"],
96
+ },
97
+ ]);
98
+ }
99
+ async function submitFinalRequest() {
100
+ const submitMessage = "✅ Yes, submit request";
101
+ const cancelMessage = "❌ No, cancel request";
102
+ const { submit } = await inquirer.prompt([
103
+ {
104
+ name: "submit",
105
+ message: "Submit request?",
106
+ type: "list",
107
+ choices: [submitMessage, cancelMessage],
108
+ },
109
+ ]);
110
+ if (submit === submitMessage) {
111
+ const requestLink = "https://dev.opal.dev/requests/sent/05ca5d5f-ea60-4cdb-84e1-7e3c575b2b72"; //TODO: Replace with actual request link
112
+ console.log("\n🎉 Your Access Request has been submitted! Request ID: 1234");
113
+ console.log(`🔍 View request status here: ${requestLink}`);
114
+ }
115
+ else {
116
+ console.log("🚫 Access Request has been cancelled.");
117
+ }
118
+ }
@@ -0,0 +1,4 @@
1
+ import type { RequestMap } from "../lib/requests";
2
+ export declare function headerMessage(): void;
3
+ export declare function treeifyRequestMap(requestMap: RequestMap): string;
4
+ export declare function displayFinalRequestSummary(requestMap: RequestMap, reason: string, expiration: string): void;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.headerMessage = headerMessage;
4
+ exports.treeifyRequestMap = treeifyRequestMap;
5
+ exports.displayFinalRequestSummary = displayFinalRequestSummary;
6
+ const treeify = require("object-treeify");
7
+ const Table = require("cli-table3");
8
+ const tableStyle = {
9
+ top: "═",
10
+ "top-mid": "╤",
11
+ "top-left": "╔",
12
+ "top-right": "╗",
13
+ bottom: "═",
14
+ "bottom-mid": "╧",
15
+ "bottom-left": "╚",
16
+ "bottom-right": "╝",
17
+ left: "║",
18
+ "left-mid": "╟",
19
+ mid: "─",
20
+ "mid-mid": "┼",
21
+ right: "║",
22
+ "right-mid": "╢",
23
+ middle: "│",
24
+ };
25
+ function headerMessage() {
26
+ console.clear();
27
+ console.log("============================================================");
28
+ console.log("Opal Access Request ✏️");
29
+ console.log("Press Ctrl+C to cancel at any time.\n");
30
+ }
31
+ function treeifyRequestMap(requestMap) {
32
+ const requestTree = {};
33
+ for (const [appName, appNode] of requestMap.entries()) {
34
+ const appKey = `🔧${appName}`;
35
+ requestTree[appKey] = {};
36
+ for (const [assetName, assetNode] of appNode.assets.entries()) {
37
+ const assetKey = `📦${assetName}`;
38
+ if (assetNode.roles !== undefined) {
39
+ requestTree[appKey][assetKey] = {};
40
+ for (const [roleName, _] of assetNode.roles.entries()) {
41
+ requestTree[appKey][assetKey][roleName] = null;
42
+ }
43
+ }
44
+ else {
45
+ requestTree[appKey][assetKey] = null;
46
+ }
47
+ }
48
+ }
49
+ return String(treeify(requestTree));
50
+ }
51
+ function displayFinalRequestSummary(requestMap, reason, expiration) {
52
+ headerMessage();
53
+ console.log("Final Summary of Request\n");
54
+ const requestedAssets = treeifyRequestMap(requestMap);
55
+ const table = new Table({
56
+ chars: tableStyle,
57
+ });
58
+ table.push(["Requested Assets", requestedAssets], ["Reason", reason], ["Expiration", expiration]);
59
+ console.log(table.toString());
60
+ }
@@ -0,0 +1 @@
1
+ export declare function restrictToDev(): void;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.restrictToDev = restrictToDev;
4
+ /*
5
+ Use restrictToDev function in the run functions of commands still in development-
6
+
7
+ static hidden = true; # Use this in tandem with restrictToDev function to hide from help menu.
8
+ async run() {
9
+ restrictToDev();
10
+ ...
11
+ }
12
+ */
13
+ function restrictToDev() {
14
+ if (process.env.NODE_ENV !== "development") {
15
+ console.error("Command still under development. Please look out for product announcements for official release.");
16
+ process.exit(1);
17
+ }
18
+ }
@@ -554,6 +554,74 @@
554
554
  "start.js"
555
555
  ]
556
556
  },
557
+ "request:create": {
558
+ "aliases": [],
559
+ "args": {},
560
+ "description": "Opens an Opal access request",
561
+ "flags": {},
562
+ "hasDynamicHelp": false,
563
+ "hidden": true,
564
+ "hiddenAliases": [],
565
+ "id": "request:create",
566
+ "pluginAlias": "opal-security",
567
+ "pluginName": "opal-security",
568
+ "pluginType": "core",
569
+ "strict": true,
570
+ "enableJsonFlag": false,
571
+ "isESM": false,
572
+ "relativePath": [
573
+ "lib",
574
+ "commands",
575
+ "request",
576
+ "create.js"
577
+ ]
578
+ },
579
+ "request:get": {
580
+ "aliases": [],
581
+ "args": {},
582
+ "description": "Lists access requests",
583
+ "flags": {},
584
+ "hasDynamicHelp": false,
585
+ "hidden": true,
586
+ "hiddenAliases": [],
587
+ "id": "request:get",
588
+ "pluginAlias": "opal-security",
589
+ "pluginName": "opal-security",
590
+ "pluginType": "core",
591
+ "strict": true,
592
+ "enableJsonFlag": false,
593
+ "isESM": false,
594
+ "relativePath": [
595
+ "lib",
596
+ "commands",
597
+ "request",
598
+ "get.js"
599
+ ]
600
+ },
601
+ "request:list": {
602
+ "aliases": [
603
+ "request:ls"
604
+ ],
605
+ "args": {},
606
+ "description": "Lists access requests",
607
+ "flags": {},
608
+ "hasDynamicHelp": false,
609
+ "hidden": true,
610
+ "hiddenAliases": [],
611
+ "id": "request:list",
612
+ "pluginAlias": "opal-security",
613
+ "pluginName": "opal-security",
614
+ "pluginType": "core",
615
+ "strict": true,
616
+ "enableJsonFlag": false,
617
+ "isESM": false,
618
+ "relativePath": [
619
+ "lib",
620
+ "commands",
621
+ "request",
622
+ "list.js"
623
+ ]
624
+ },
557
625
  "resources:get": {
558
626
  "aliases": [],
559
627
  "args": {},
@@ -801,5 +869,5 @@
801
869
  ]
802
870
  }
803
871
  },
804
- "version": "3.0.1-beta.4262451"
872
+ "version": "3.0.1-beta.cbf0332"
805
873
  }
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": "3.0.1-beta.4262451",
4
+ "version": "3.0.1-beta.cbf0332",
5
5
  "author": "Stephen Cobbe",
6
6
  "bin": {
7
7
  "opal": "./bin/run"
@@ -15,6 +15,7 @@
15
15
  "@oclif/plugin-version": "^2.0.12",
16
16
  "argon2": "^0.40.1",
17
17
  "chalk": "^2.4.2",
18
+ "cli-table3": "^0.6.5",
18
19
  "graphql": "^15.5.0",
19
20
  "inquirer": "^8.2.6",
20
21
  "inquirer-autocomplete-prompt": "^2.0.1",
@@ -74,7 +75,8 @@
74
75
  ],
75
76
  "macos": {
76
77
  "identifier": "dev.opal.cli"
77
- }
78
+ },
79
+ "topicSeparator": " "
78
80
  },
79
81
  "repository": {
80
82
  "type": "git",