opal-security 3.1.3 → 3.2.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/3.1.3 linux-x64 node-v20.19.0
25
+ opal-security/3.2.1 darwin-arm64 node-v18.20.4
26
26
  $ opal --help [COMMAND]
27
27
  USAGE
28
28
  $ opal COMMAND
@@ -44,6 +44,10 @@ USAGE
44
44
  * [`opal login`](#opal-login)
45
45
  * [`opal logout`](#opal-logout)
46
46
  * [`opal postgres-instances start`](#opal-postgres-instances-start)
47
+ * [`opal request create`](#opal-request-create)
48
+ * [`opal request get`](#opal-request-get)
49
+ * [`opal request list`](#opal-request-list)
50
+ * [`opal request ls`](#opal-request-ls)
47
51
  * [`opal resources get`](#opal-resources-get)
48
52
  * [`opal set-auth-provider`](#opal-set-auth-provider)
49
53
  * [`opal set-custom-header`](#opal-set-custom-header)
@@ -53,6 +57,7 @@ USAGE
53
57
  * [`opal ssh copyTo`](#opal-ssh-copyto)
54
58
  * [`opal ssh start`](#opal-ssh-start)
55
59
  * [`opal version`](#opal-version)
60
+ * [`opal whoami`](#opal-whoami)
56
61
 
57
62
  ## `opal autocomplete [SHELL]`
58
63
 
@@ -101,7 +106,7 @@ EXAMPLES
101
106
  $ opal aws:identity
102
107
  ```
103
108
 
104
- _See code: [src/commands/aws/identity.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.3/src/commands/aws/identity.ts)_
109
+ _See code: [src/commands/aws/identity.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/aws/identity.ts)_
105
110
 
106
111
  ## `opal clear-auth-provider`
107
112
 
@@ -121,7 +126,7 @@ EXAMPLES
121
126
  $ opal clear-auth-provider
122
127
  ```
123
128
 
124
- _See code: [src/commands/clear-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.3/src/commands/clear-auth-provider.ts)_
129
+ _See code: [src/commands/clear-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/clear-auth-provider.ts)_
125
130
 
126
131
  ## `opal curl-example`
127
132
 
@@ -138,7 +143,7 @@ DESCRIPTION
138
143
  Prints out an example cURL command containing the parameters the CLI uses to query the Opal server.
139
144
  ```
140
145
 
141
- _See code: [src/commands/curl-example.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.3/src/commands/curl-example.ts)_
146
+ _See code: [src/commands/curl-example.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/curl-example.ts)_
142
147
 
143
148
  ## `opal groups get`
144
149
 
@@ -150,7 +155,7 @@ USAGE
150
155
 
151
156
  FLAGS
152
157
  -h, --help Show CLI help.
153
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g. https://opal.dev/resources/[ID]
158
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g. https://opal.dev/resources/[ID]
154
159
 
155
160
  DESCRIPTION
156
161
  Get group info for a particular group.
@@ -159,7 +164,7 @@ EXAMPLES
159
164
  $ opal groups:get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4
160
165
  ```
161
166
 
162
- _See code: [src/commands/groups/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.3/src/commands/groups/get.ts)_
167
+ _See code: [src/commands/groups/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/groups/get.ts)_
163
168
 
164
169
  ## `opal help [COMMANDS]`
165
170
 
@@ -191,7 +196,7 @@ USAGE
191
196
 
192
197
  FLAGS
193
198
  -h, --help Show CLI help.
194
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g.
199
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
195
200
  https://opal.dev/resources/[ID]
196
201
  -r, --refresh Starts a new session even if one already exists. Useful if a session is about to expire.
197
202
  -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
@@ -209,7 +214,7 @@ EXAMPLES
209
214
  $ opal iam-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --profileName "custom-profile"
210
215
  ```
211
216
 
212
- _See code: [src/commands/iam-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.3/src/commands/iam-roles/start.ts)_
217
+ _See code: [src/commands/iam-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/iam-roles/start.ts)_
213
218
 
214
219
  ## `opal kube-roles start`
215
220
 
@@ -222,7 +227,7 @@ USAGE
222
227
  FLAGS
223
228
  -a, --accessLevelRemoteId=<value> The remote ID of the access level with which to access the resource.
224
229
  -h, --help Show CLI help.
225
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g.
230
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
226
231
  https://opal.dev/resources/[ID]
227
232
  -r, --refresh Starts a new session even if one already exists. Useful if a session is about to
228
233
  expire.
@@ -240,7 +245,7 @@ EXAMPLES
240
245
  $ opal kube-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --accessLevelRemoteId "arn:aws:iam::712234975475:role/acme-eks-cluster-admin-role"
241
246
  ```
242
247
 
243
- _See code: [src/commands/kube-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.3/src/commands/kube-roles/start.ts)_
248
+ _See code: [src/commands/kube-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/kube-roles/start.ts)_
244
249
 
245
250
  ## `opal login`
246
251
 
@@ -261,7 +266,7 @@ EXAMPLES
261
266
  $ opal login
262
267
  ```
263
268
 
264
- _See code: [src/commands/login.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.3/src/commands/login.ts)_
269
+ _See code: [src/commands/login.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/login.ts)_
265
270
 
266
271
  ## `opal logout`
267
272
 
@@ -281,7 +286,7 @@ EXAMPLES
281
286
  $ opal logout
282
287
  ```
283
288
 
284
- _See code: [src/commands/logout.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.3/src/commands/logout.ts)_
289
+ _See code: [src/commands/logout.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/logout.ts)_
285
290
 
286
291
  ## `opal postgres-instances start`
287
292
 
@@ -289,21 +294,22 @@ Starts a session to connect to a Postgres database.
289
294
 
290
295
  ```
291
296
  USAGE
292
- $ opal postgres-instances start [-h] [-i <value>] [-a <value>] [-s <value>] [-r] [--action psql|view]
297
+ $ opal postgres-instances start [-h] [-i <value>] [-a <value>] [-s <value>] [-r] [--action open|psql|view]
293
298
 
294
299
  FLAGS
295
300
  -a, --accessLevelRemoteId=<value> The remote ID of the access level with which to access the resource.
296
301
  -h, --help Show CLI help.
297
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g.
302
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
298
303
  https://opal.dev/resources/[ID]
299
304
  -r, --refresh Starts a new session even if one already exists. Useful if a session is about to
300
305
  expire.
301
306
  -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created
302
307
  via the web flow.
303
308
  --action=<option> Method of connecting to the database.
309
+ - open: Open external database app
304
310
  - psql: Start psql session in shell
305
311
  - view: View connection configuration details
306
- <options: psql|view>
312
+ <options: open|psql|view>
307
313
 
308
314
  DESCRIPTION
309
315
  Starts a session to connect to a Postgres database.
@@ -318,7 +324,116 @@ EXAMPLES
318
324
  $ opal postgres-instances:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --accessLevelRemoteId fullaccess --action view
319
325
  ```
320
326
 
321
- _See code: [src/commands/postgres-instances/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.3/src/commands/postgres-instances/start.ts)_
327
+ _See code: [src/commands/postgres-instances/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/postgres-instances/start.ts)_
328
+
329
+ ## `opal request create`
330
+
331
+ Creates an Opal access request via an interactive form
332
+
333
+ ```
334
+ USAGE
335
+ $ opal request create [-h] [-a <value>...] [-r <value>] [-d <value>]
336
+
337
+ FLAGS
338
+ -a, --assets=<value>... The ids of the assets (resource, group) to request access to. Append a role name using a
339
+ colon if needed, e.g. `--assets 123:456`.
340
+ If not provided, an interactive selection flow will be available to select assets to request.
341
+ -d, --duration=<value> The duration of access for the request in minutes. Pass in a 0 value for permanent access. If
342
+ not provided, you will be prompted.
343
+ -h, --help Show CLI help.
344
+ -r, --reason=<value> The reason for the request, contained in quotes. If not provided, you will be prompted.
345
+
346
+ DESCRIPTION
347
+ Creates an Opal access request via an interactive form
348
+ ```
349
+
350
+ _See code: [src/commands/request/create.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/request/create.ts)_
351
+
352
+ ## `opal request get`
353
+
354
+ Lists access requests
355
+
356
+ ```
357
+ USAGE
358
+ $ opal request get [-h] [-i <value>] [-v]
359
+
360
+ FLAGS
361
+ -h, --help Show CLI help.
362
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g. https://opal.dev/resources/[ID]
363
+ -v, --verbose Enable verbose output, prints full response in JSON format. Defaults to false.
364
+
365
+ DESCRIPTION
366
+ Lists access requests
367
+
368
+ EXAMPLES
369
+ $ opal request get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4
370
+
371
+ $ opal request get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4 --verbose
372
+ ```
373
+
374
+ _See code: [src/commands/request/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/request/get.ts)_
375
+
376
+ ## `opal request list`
377
+
378
+ Lists your n recent outgoing access requests
379
+
380
+ ```
381
+ USAGE
382
+ $ opal request list [-h] [-n <value>] [-p] [-v]
383
+
384
+ FLAGS
385
+ -h, --help Show CLI help.
386
+ -n, --n=<value> [default: 10] Defines number of requests to be returned. 1 <= n <= 100.
387
+ -p, --pending Show only pending requests. Defaults to false.
388
+ -v, --verbose Enable verbose output, prints full response in JSON format. Defaults to false.
389
+
390
+ DESCRIPTION
391
+ Lists your n recent outgoing access requests
392
+
393
+ ALIASES
394
+ $ opal request ls
395
+
396
+ EXAMPLES
397
+ $ opal request list --n 5
398
+
399
+ $ opal request list --n 5 --pending
400
+
401
+ $ opal request list --n 5 --verbose
402
+
403
+ $ opal request list --n 5 --pending --verbose
404
+ ```
405
+
406
+ _See code: [src/commands/request/list.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/request/list.ts)_
407
+
408
+ ## `opal request ls`
409
+
410
+ Lists your n recent outgoing access requests
411
+
412
+ ```
413
+ USAGE
414
+ $ opal request ls [-h] [-n <value>] [-p] [-v]
415
+
416
+ FLAGS
417
+ -h, --help Show CLI help.
418
+ -n, --n=<value> [default: 10] Defines number of requests to be returned. 1 <= n <= 100.
419
+ -p, --pending Show only pending requests. Defaults to false.
420
+ -v, --verbose Enable verbose output, prints full response in JSON format. Defaults to false.
421
+
422
+ DESCRIPTION
423
+ Lists your n recent outgoing access requests
424
+
425
+ ALIASES
426
+ $ opal request ls
427
+
428
+ EXAMPLES
429
+ $ opal request list --n 5
430
+
431
+ $ opal request list --n 5 --pending
432
+
433
+ $ opal request list --n 5 --verbose
434
+
435
+ $ opal request list --n 5 --pending --verbose
436
+ ```
322
437
 
323
438
  ## `opal resources get`
324
439
 
@@ -330,7 +445,7 @@ USAGE
330
445
 
331
446
  FLAGS
332
447
  -h, --help Show CLI help.
333
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g. https://opal.dev/resources/[ID]
448
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g. https://opal.dev/resources/[ID]
334
449
 
335
450
  DESCRIPTION
336
451
  Get resource info for a particular resource.
@@ -339,7 +454,7 @@ EXAMPLES
339
454
  $ opal resources:get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4
340
455
  ```
341
456
 
342
- _See code: [src/commands/resources/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.3/src/commands/resources/get.ts)_
457
+ _See code: [src/commands/resources/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/resources/get.ts)_
343
458
 
344
459
  ## `opal set-auth-provider`
345
460
 
@@ -365,7 +480,7 @@ EXAMPLES
365
480
  $ opal set-auth-provider --clientID 1234asdf --issuerUrl https://auth.example.com
366
481
  ```
367
482
 
368
- _See code: [src/commands/set-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.3/src/commands/set-auth-provider.ts)_
483
+ _See code: [src/commands/set-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/set-auth-provider.ts)_
369
484
 
370
485
  ## `opal set-custom-header`
371
486
 
@@ -386,7 +501,7 @@ EXAMPLES
386
501
  $ opal set-custom-header --header 'cf-access-token: $TOKEN'
387
502
  ```
388
503
 
389
- _See code: [src/commands/set-custom-header.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.3/src/commands/set-custom-header.ts)_
504
+ _See code: [src/commands/set-custom-header.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/set-custom-header.ts)_
390
505
 
391
506
  ## `opal set-token`
392
507
 
@@ -406,7 +521,7 @@ EXAMPLES
406
521
  $ opal set-token
407
522
  ```
408
523
 
409
- _See code: [src/commands/set-token.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.3/src/commands/set-token.ts)_
524
+ _See code: [src/commands/set-token.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/set-token.ts)_
410
525
 
411
526
  ## `opal set-url [URL]`
412
527
 
@@ -430,7 +545,7 @@ EXAMPLES
430
545
  $ opal set-url
431
546
  ```
432
547
 
433
- _See code: [src/commands/set-url.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.3/src/commands/set-url.ts)_
548
+ _See code: [src/commands/set-url.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/set-url.ts)_
434
549
 
435
550
  ## `opal ssh copyFrom`
436
551
 
@@ -442,7 +557,7 @@ USAGE
442
557
 
443
558
  FLAGS
444
559
  -h, --help Show CLI help.
445
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g.
560
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
446
561
  https://opal.dev/resources/[ID]
447
562
  -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
448
563
  web flow.
@@ -461,7 +576,7 @@ EXAMPLES
461
576
  $ opal ssh:copyFrom --src instance/dir --dest my/dir --id 51f7176b-0464-4a6f-8369-e951e187b398
462
577
  ```
463
578
 
464
- _See code: [src/commands/ssh/copyFrom.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.3/src/commands/ssh/copyFrom.ts)_
579
+ _See code: [src/commands/ssh/copyFrom.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/ssh/copyFrom.ts)_
465
580
 
466
581
  ## `opal ssh copyTo`
467
582
 
@@ -473,7 +588,7 @@ USAGE
473
588
 
474
589
  FLAGS
475
590
  -h, --help Show CLI help.
476
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g.
591
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
477
592
  https://opal.dev/resources/[ID]
478
593
  -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
479
594
  web flow.
@@ -492,7 +607,7 @@ EXAMPLES
492
607
  $ opal ssh:copyTo --src my/dir --dest instance/dir --id 51f7176b-0464-4a6f-8369-e951e187b398
493
608
  ```
494
609
 
495
- _See code: [src/commands/ssh/copyTo.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.3/src/commands/ssh/copyTo.ts)_
610
+ _See code: [src/commands/ssh/copyTo.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/ssh/copyTo.ts)_
496
611
 
497
612
  ## `opal ssh start`
498
613
 
@@ -504,7 +619,7 @@ USAGE
504
619
 
505
620
  FLAGS
506
621
  -h, --help Show CLI help.
507
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g.
622
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
508
623
  https://opal.dev/resources/[ID]
509
624
  -r, --refresh Starts a new session even if one already exists. Useful if a session is about to expire.
510
625
  -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
@@ -519,7 +634,7 @@ EXAMPLES
519
634
  $ opal ssh:start --id 51f7176b-0464-4a6f-8369-e951e187b398
520
635
  ```
521
636
 
522
- _See code: [src/commands/ssh/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.3/src/commands/ssh/start.ts)_
637
+ _See code: [src/commands/ssh/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/ssh/start.ts)_
523
638
 
524
639
  ## `opal version`
525
640
 
@@ -540,4 +655,21 @@ FLAG DESCRIPTIONS
540
655
  ```
541
656
 
542
657
  _See code: [@oclif/plugin-version](https://github.com/oclif/plugin-version/blob/v2.2.27/src/commands/version.ts)_
658
+
659
+ ## `opal whoami`
660
+
661
+ Describes current url set, organization name, and logged in user if applicable.
662
+
663
+ ```
664
+ USAGE
665
+ $ opal whoami [-h]
666
+
667
+ FLAGS
668
+ -h, --help Show CLI help.
669
+
670
+ DESCRIPTION
671
+ Describes current url set, organization name, and logged in user if applicable.
672
+ ```
673
+
674
+ _See code: [src/commands/whoami.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/whoami.ts)_
543
675
  <!-- commandsstop -->
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
- const parseAndCheckHttpResponse_1 = require("@apollo/client/link/http/parseAndCheckHttpResponse");
5
4
  const graphql_1 = require("../../graphql");
6
5
  const apollo_1 = require("../../lib/apollo");
7
6
  const cmd_1 = require("../../lib/cmd");
@@ -64,7 +63,7 @@ class GetGroup extends core_1.Command {
64
63
  (0, apollo_1.printResponse)(this, resp);
65
64
  }
66
65
  catch (error) {
67
- return (0, parseAndCheckHttpResponse_1.handleError)(this, error);
66
+ return (0, apollo_1.handleError)(this, error);
68
67
  }
69
68
  }
70
69
  }
@@ -88,12 +88,14 @@ class Login extends core_1.Command {
88
88
  const configData = (0, config_1.getOrCreateConfigData)(configDir);
89
89
  let email = flags.email;
90
90
  let organizationId;
91
+ let organizationName;
91
92
  let clientIDCandidate;
92
93
  const existingCreds = await (0, credentials_1.getOpalCredentials)(this, false);
93
94
  // Only use the previous email + organizationID if email isn't explicitly specified.
94
95
  if (!email) {
95
96
  email = existingCreds.email;
96
97
  organizationId = existingCreds.organizationID;
98
+ organizationName = existingCreds.organizationName;
97
99
  clientIDCandidate = existingCreds.clientIDCandidate;
98
100
  }
99
101
  await (0, credentials_1.removeOpalCredentials)(this);
@@ -149,6 +151,7 @@ class Login extends core_1.Command {
149
151
  if (signInOrganizations && signInOrganizations.length > 0) {
150
152
  if (signInOrganizations.length === 1) {
151
153
  organizationId = signInOrganizations[0].organizationId;
154
+ organizationName = signInOrganizations[0].organizationName;
152
155
  clientIDCandidate = signInOrganizations[0].cliClientId;
153
156
  }
154
157
  else {
@@ -164,6 +167,7 @@ class Login extends core_1.Command {
164
167
  },
165
168
  ]);
166
169
  organizationId = responses.signInOrganization.organizationId;
170
+ organizationName = responses.signInOrganization.organizationName;
167
171
  clientIDCandidate = responses.signInOrganization.cliClientId;
168
172
  }
169
173
  }
@@ -238,10 +242,10 @@ class Login extends core_1.Command {
238
242
  if (tokenExchangeError) {
239
243
  this.log("WARN: Failed to exchange access token for session in Opal. Falling back to using access token for authenticating requests\n");
240
244
  // TODO: consider adding a warn line recommending upgrading Opal to version XYZ, once accompanying PR is pushed to prod
241
- await (0, credentials_1.setOpalCredentials)(this, email, organizationId !== null && organizationId !== void 0 ? organizationId : "", clientIDCandidate, (tokenSet === null || tokenSet === void 0 ? void 0 : tokenSet.access_token) || "", credentials_1.SecretType.ApiToken);
245
+ await (0, credentials_1.setOpalCredentials)(this, email, organizationId !== null && organizationId !== void 0 ? organizationId : "", clientIDCandidate, (tokenSet === null || tokenSet === void 0 ? void 0 : tokenSet.access_token) || "", credentials_1.SecretType.ApiToken, organizationName);
242
246
  }
243
247
  else {
244
- await (0, credentials_1.setOpalCredentials)(this, email, organizationId !== null && organizationId !== void 0 ? organizationId : "", clientIDCandidate, apollo_1.cookieStr, credentials_1.SecretType.Cookie);
248
+ await (0, credentials_1.setOpalCredentials)(this, email, organizationId !== null && organizationId !== void 0 ? organizationId : "", clientIDCandidate, apollo_1.cookieStr, credentials_1.SecretType.Cookie, organizationName);
245
249
  }
246
250
  // "Representative" authenticated call to check the log-in worked as expected.
247
251
  const { resp: authCheckResp, error: authCheckErr } = await (0, handler_1.runQueryDeprecated)({
@@ -1,6 +1,11 @@
1
1
  import { Command } from "@oclif/core";
2
2
  export default class RequestCreate extends Command {
3
- static hidden: boolean;
4
3
  static description: string;
4
+ static flags: {
5
+ help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
6
+ assets: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
7
+ reason: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
8
+ duration: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
9
+ };
5
10
  run(): Promise<void>;
6
11
  }
@@ -2,36 +2,80 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
4
  const apollo_1 = require("../../lib/apollo");
5
+ const cmd_1 = require("../../lib/cmd");
6
+ const flags_1 = require("../../lib/flags");
5
7
  const requests_1 = require("../../lib/requests");
6
8
  const displays_1 = require("../../utils/displays");
7
- const utils_1 = require("../../utils/utils");
8
9
  class RequestCreate extends core_1.Command {
9
10
  async run() {
11
+ (0, cmd_1.setMostRecentCommand)(this);
10
12
  await (0, apollo_1.initClient)(this, true);
11
13
  const client = await (0, apollo_1.getClient)(this, true);
12
- (0, utils_1.restrictToDev)(); //TODO: Remove after development is complete
13
- const requestMap = new Map();
14
- (0, displays_1.headerMessage)(this);
15
- let shouldProceed = false;
16
- while (!shouldProceed) {
17
- // Step 1: Select first round of assets from an app
18
- await (0, requests_1.selectRequestableItems)(this, client, requestMap);
19
- // Step 2: Display the selected items in a tree format
14
+ const { flags } = await this.parse(RequestCreate);
15
+ const metadata = (0, requests_1.initEmptyRequestMetadata)();
16
+ if (flags.assets) {
17
+ // if IDs are provided, bypass the interactive selection process
18
+ await (0, requests_1.bypassRequestSelection)(this, client, flags.assets, metadata);
19
+ }
20
+ else {
20
21
  (0, displays_1.headerMessage)(this);
21
- this.log((0, displays_1.treeifyRequestMap)(requestMap), "\n");
22
- // Step 3: Prompt to add more items, repeat 1-3 if needed
23
- shouldProceed = await (0, requests_1.doneSelectingAssets)();
22
+ let shouldProceed = false;
23
+ while (!shouldProceed) {
24
+ // Step 1: Select first round of assets from an app
25
+ await (0, requests_1.selectRequestableItems)(this, client, metadata.requestMap);
26
+ // Step 2: Display the selected items in a tree format
27
+ (0, displays_1.headerMessage)(this);
28
+ (0, displays_1.treeifyRequestMap)(this, metadata.requestMap);
29
+ // Step 3: Prompt to add more items, repeat 1-3 if needed
30
+ shouldProceed = await (0, requests_1.doneSelectingAssets)();
31
+ }
24
32
  }
33
+ // Step 4: Set Request Defaults
34
+ await (0, requests_1.setRequestDefaults)(this, client, metadata);
25
35
  // Step 4: Prompt for request reason
26
- const { reason } = await (0, requests_1.promptForReason)();
36
+ if (flags.reason) {
37
+ metadata.reason = flags.reason;
38
+ }
39
+ else if (!(metadata.requestDefaults.reasonOptional &&
40
+ flags.assets &&
41
+ flags.duration)) {
42
+ await (0, requests_1.promptForReason)(metadata);
43
+ }
27
44
  // Step 5: Prompt for expiration
28
- const { expiration } = await (0, requests_1.promptForExpiration)();
45
+ if (flags.duration !== undefined) {
46
+ (0, requests_1.bypassDuration)(this, flags.duration, metadata);
47
+ }
48
+ else {
49
+ await (0, requests_1.promptForExpiration)(metadata);
50
+ }
29
51
  // Step 6: Display final summary of request
30
- (0, displays_1.displayFinalRequestSummary)(this, requestMap, reason, expiration);
31
- // Step 7: Prompt for final submition
32
- await (0, requests_1.submitFinalRequest)(this);
52
+ let canSubmit = true;
53
+ if (!(flags.assets &&
54
+ flags.duration !== undefined &&
55
+ (metadata.requestDefaults.reasonOptional || flags.reason))) {
56
+ canSubmit = await (0, requests_1.promptRequestSubmission)(this, metadata);
57
+ }
58
+ // Step 7: Prompt for final submission
59
+ if (canSubmit)
60
+ await (0, requests_1.submitFinalRequest)(this, client, metadata);
33
61
  }
34
62
  }
35
- RequestCreate.hidden = true;
36
- RequestCreate.description = "Opens an Opal access request";
63
+ RequestCreate.description = "Creates an Opal access request via an interactive form";
64
+ RequestCreate.flags = {
65
+ help: flags_1.SHARED_FLAGS.help,
66
+ assets: core_1.Flags.string({
67
+ char: "a",
68
+ multiple: true,
69
+ description: "The ids of the assets (resource, group) to request access to. Append a role name using a colon if needed, e.g. `--assets 123:456`.\
70
+ \n If not provided, an interactive selection flow will be available to select assets to request.",
71
+ }),
72
+ reason: core_1.Flags.string({
73
+ char: "r",
74
+ description: "The reason for the request, contained in quotes. If not provided, you will be prompted.",
75
+ }),
76
+ duration: core_1.Flags.integer({
77
+ char: "d",
78
+ description: "The duration of access for the request in minutes. Pass in a 0 value for permanent access. If not provided, you will be prompted.",
79
+ }),
80
+ };
37
81
  exports.default = RequestCreate;
@@ -1,6 +1,11 @@
1
1
  import { Command } from "@oclif/core";
2
- export default class RequestGet extends Command {
3
- static hidden: boolean;
2
+ export default class GetRequest extends Command {
4
3
  static description: string;
4
+ static flags: {
5
+ help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
6
+ id: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
7
+ verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
8
+ };
9
+ static examples: string[];
5
10
  run(): Promise<void>;
6
11
  }