opal-security 3.1.0 → 3.1.1-beta.01fe2fd

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.0 linux-x64 node-v20.19.0
25
+ opal-security/3.1.1-beta.01fe2fd linux-x64 node-v20.19.2
26
26
  $ opal --help [COMMAND]
27
27
  USAGE
28
28
  $ opal COMMAND
@@ -44,6 +44,9 @@ 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)
47
50
  * [`opal request ls`](#opal-request-ls)
48
51
  * [`opal resources get`](#opal-resources-get)
49
52
  * [`opal set-auth-provider`](#opal-set-auth-provider)
@@ -54,6 +57,7 @@ USAGE
54
57
  * [`opal ssh copyTo`](#opal-ssh-copyto)
55
58
  * [`opal ssh start`](#opal-ssh-start)
56
59
  * [`opal version`](#opal-version)
60
+ * [`opal whoami`](#opal-whoami)
57
61
 
58
62
  ## `opal autocomplete [SHELL]`
59
63
 
@@ -102,7 +106,7 @@ EXAMPLES
102
106
  $ opal aws:identity
103
107
  ```
104
108
 
105
- _See code: [src/commands/aws/identity.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.0/src/commands/aws/identity.ts)_
109
+ _See code: [src/commands/aws/identity.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.01fe2fd/src/commands/aws/identity.ts)_
106
110
 
107
111
  ## `opal clear-auth-provider`
108
112
 
@@ -122,7 +126,7 @@ EXAMPLES
122
126
  $ opal clear-auth-provider
123
127
  ```
124
128
 
125
- _See code: [src/commands/clear-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.0/src/commands/clear-auth-provider.ts)_
129
+ _See code: [src/commands/clear-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.01fe2fd/src/commands/clear-auth-provider.ts)_
126
130
 
127
131
  ## `opal curl-example`
128
132
 
@@ -139,7 +143,7 @@ DESCRIPTION
139
143
  Prints out an example cURL command containing the parameters the CLI uses to query the Opal server.
140
144
  ```
141
145
 
142
- _See code: [src/commands/curl-example.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.0/src/commands/curl-example.ts)_
146
+ _See code: [src/commands/curl-example.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.01fe2fd/src/commands/curl-example.ts)_
143
147
 
144
148
  ## `opal groups get`
145
149
 
@@ -151,7 +155,7 @@ USAGE
151
155
 
152
156
  FLAGS
153
157
  -h, --help Show CLI help.
154
- -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]
155
159
 
156
160
  DESCRIPTION
157
161
  Get group info for a particular group.
@@ -160,7 +164,7 @@ EXAMPLES
160
164
  $ opal groups:get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4
161
165
  ```
162
166
 
163
- _See code: [src/commands/groups/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.0/src/commands/groups/get.ts)_
167
+ _See code: [src/commands/groups/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.01fe2fd/src/commands/groups/get.ts)_
164
168
 
165
169
  ## `opal help [COMMANDS]`
166
170
 
@@ -192,7 +196,7 @@ USAGE
192
196
 
193
197
  FLAGS
194
198
  -h, --help Show CLI help.
195
- -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.
196
200
  https://opal.dev/resources/[ID]
197
201
  -r, --refresh Starts a new session even if one already exists. Useful if a session is about to expire.
198
202
  -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
@@ -210,7 +214,7 @@ EXAMPLES
210
214
  $ opal iam-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --profileName "custom-profile"
211
215
  ```
212
216
 
213
- _See code: [src/commands/iam-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.0/src/commands/iam-roles/start.ts)_
217
+ _See code: [src/commands/iam-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.01fe2fd/src/commands/iam-roles/start.ts)_
214
218
 
215
219
  ## `opal kube-roles start`
216
220
 
@@ -223,7 +227,7 @@ USAGE
223
227
  FLAGS
224
228
  -a, --accessLevelRemoteId=<value> The remote ID of the access level with which to access the resource.
225
229
  -h, --help Show CLI help.
226
- -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.
227
231
  https://opal.dev/resources/[ID]
228
232
  -r, --refresh Starts a new session even if one already exists. Useful if a session is about to
229
233
  expire.
@@ -241,7 +245,7 @@ EXAMPLES
241
245
  $ opal kube-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --accessLevelRemoteId "arn:aws:iam::712234975475:role/acme-eks-cluster-admin-role"
242
246
  ```
243
247
 
244
- _See code: [src/commands/kube-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.0/src/commands/kube-roles/start.ts)_
248
+ _See code: [src/commands/kube-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.01fe2fd/src/commands/kube-roles/start.ts)_
245
249
 
246
250
  ## `opal login`
247
251
 
@@ -262,7 +266,7 @@ EXAMPLES
262
266
  $ opal login
263
267
  ```
264
268
 
265
- _See code: [src/commands/login.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.0/src/commands/login.ts)_
269
+ _See code: [src/commands/login.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.01fe2fd/src/commands/login.ts)_
266
270
 
267
271
  ## `opal logout`
268
272
 
@@ -282,7 +286,7 @@ EXAMPLES
282
286
  $ opal logout
283
287
  ```
284
288
 
285
- _See code: [src/commands/logout.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.0/src/commands/logout.ts)_
289
+ _See code: [src/commands/logout.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.01fe2fd/src/commands/logout.ts)_
286
290
 
287
291
  ## `opal postgres-instances start`
288
292
 
@@ -295,7 +299,7 @@ USAGE
295
299
  FLAGS
296
300
  -a, --accessLevelRemoteId=<value> The remote ID of the access level with which to access the resource.
297
301
  -h, --help Show CLI help.
298
- -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.
299
303
  https://opal.dev/resources/[ID]
300
304
  -r, --refresh Starts a new session even if one already exists. Useful if a session is about to
301
305
  expire.
@@ -319,21 +323,114 @@ EXAMPLES
319
323
  $ opal postgres-instances:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --accessLevelRemoteId fullaccess --action view
320
324
  ```
321
325
 
322
- _See code: [src/commands/postgres-instances/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.0/src/commands/postgres-instances/start.ts)_
326
+ _See code: [src/commands/postgres-instances/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.01fe2fd/src/commands/postgres-instances/start.ts)_
323
327
 
324
- ## `opal request ls`
328
+ ## `opal request create`
329
+
330
+ Creates an Opal access request via an interactive form
331
+
332
+ ```
333
+ USAGE
334
+ $ opal request create [-h] [-a <value>...] [-r <value>] [-d <value>]
335
+
336
+ FLAGS
337
+ -a, --assets=<value>... The ids of the assets (resource, group) to request access to. Append a role ID using a colon
338
+ if needed, e.g. `--assets 123:456`.
339
+ If not provided, an interactive selection flow will be available to select assets to request.
340
+ -d, --duration=<value> The duration of access for the request in minutes. If not provided, you will be prompted.
341
+ -h, --help Show CLI help.
342
+ -r, --reason=<value> The reason for the request, contained in quotes. If not provided, you will be prompted.
343
+
344
+ DESCRIPTION
345
+ Creates an Opal access request via an interactive form
346
+ ```
347
+
348
+ _See code: [src/commands/request/create.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.01fe2fd/src/commands/request/create.ts)_
349
+
350
+ ## `opal request get`
325
351
 
326
352
  Lists access requests
327
353
 
328
354
  ```
329
355
  USAGE
330
- $ opal request ls
356
+ $ opal request get [-h] [-i <value>] [-v]
357
+
358
+ FLAGS
359
+ -h, --help Show CLI help.
360
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g. https://opal.dev/resources/[ID]
361
+ -v, --verbose Enable verbose output, prints full response in JSON format. Defaults to false.
331
362
 
332
363
  DESCRIPTION
333
364
  Lists access requests
334
365
 
366
+ EXAMPLES
367
+ $ opal request get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4
368
+
369
+ $ opal request get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4 --verbose
370
+ ```
371
+
372
+ _See code: [src/commands/request/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.01fe2fd/src/commands/request/get.ts)_
373
+
374
+ ## `opal request list`
375
+
376
+ Lists your n recent outgoing access requests
377
+
378
+ ```
379
+ USAGE
380
+ $ opal request list [-h] [-n <value>] [-p] [-v]
381
+
382
+ FLAGS
383
+ -h, --help Show CLI help.
384
+ -n, --n=<value> [default: 10] Defines number of requests to be returned. 1 <= n <= 100.
385
+ -p, --pending Show only pending requests. Defaults to false.
386
+ -v, --verbose Enable verbose output, prints full response in JSON format. Defaults to false.
387
+
388
+ DESCRIPTION
389
+ Lists your n recent outgoing access requests
390
+
391
+ ALIASES
392
+ $ opal request ls
393
+
394
+ EXAMPLES
395
+ $ opal request list --n 5
396
+
397
+ $ opal request list --n 5 --pending
398
+
399
+ $ opal request list --n 5 --verbose
400
+
401
+ $ opal request list --n 5 --pending --verbose
402
+ ```
403
+
404
+ _See code: [src/commands/request/list.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.01fe2fd/src/commands/request/list.ts)_
405
+
406
+ ## `opal request ls`
407
+
408
+ Lists your n recent outgoing access requests
409
+
410
+ ```
411
+ USAGE
412
+ $ opal request ls [-h] [-n <value>] [-p] [-v]
413
+
414
+ FLAGS
415
+ -h, --help Show CLI help.
416
+ -n, --n=<value> [default: 10] Defines number of requests to be returned. 1 <= n <= 100.
417
+ -p, --pending Show only pending requests. Defaults to false.
418
+ -v, --verbose Enable verbose output, prints full response in JSON format. Defaults to false.
419
+
420
+ DESCRIPTION
421
+ Lists your n recent outgoing access requests
422
+
335
423
  ALIASES
336
424
  $ opal request ls
425
+
426
+ EXAMPLES
427
+ $ opal request list --n 5
428
+
429
+ $ opal request list --n 5 --pending
430
+
431
+ $ opal request list --n 5 --verbose
432
+
433
+ $ opal request list --n 5 --pending --verbose
337
434
  ```
338
435
 
339
436
  ## `opal resources get`
@@ -346,7 +443,7 @@ USAGE
346
443
 
347
444
  FLAGS
348
445
  -h, --help Show CLI help.
349
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g. https://opal.dev/resources/[ID]
446
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g. https://opal.dev/resources/[ID]
350
447
 
351
448
  DESCRIPTION
352
449
  Get resource info for a particular resource.
@@ -355,7 +452,7 @@ EXAMPLES
355
452
  $ opal resources:get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4
356
453
  ```
357
454
 
358
- _See code: [src/commands/resources/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.0/src/commands/resources/get.ts)_
455
+ _See code: [src/commands/resources/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.01fe2fd/src/commands/resources/get.ts)_
359
456
 
360
457
  ## `opal set-auth-provider`
361
458
 
@@ -381,7 +478,7 @@ EXAMPLES
381
478
  $ opal set-auth-provider --clientID 1234asdf --issuerUrl https://auth.example.com
382
479
  ```
383
480
 
384
- _See code: [src/commands/set-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.0/src/commands/set-auth-provider.ts)_
481
+ _See code: [src/commands/set-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.01fe2fd/src/commands/set-auth-provider.ts)_
385
482
 
386
483
  ## `opal set-custom-header`
387
484
 
@@ -402,7 +499,7 @@ EXAMPLES
402
499
  $ opal set-custom-header --header 'cf-access-token: $TOKEN'
403
500
  ```
404
501
 
405
- _See code: [src/commands/set-custom-header.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.0/src/commands/set-custom-header.ts)_
502
+ _See code: [src/commands/set-custom-header.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.01fe2fd/src/commands/set-custom-header.ts)_
406
503
 
407
504
  ## `opal set-token`
408
505
 
@@ -422,7 +519,7 @@ EXAMPLES
422
519
  $ opal set-token
423
520
  ```
424
521
 
425
- _See code: [src/commands/set-token.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.0/src/commands/set-token.ts)_
522
+ _See code: [src/commands/set-token.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.01fe2fd/src/commands/set-token.ts)_
426
523
 
427
524
  ## `opal set-url [URL]`
428
525
 
@@ -446,7 +543,7 @@ EXAMPLES
446
543
  $ opal set-url
447
544
  ```
448
545
 
449
- _See code: [src/commands/set-url.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.0/src/commands/set-url.ts)_
546
+ _See code: [src/commands/set-url.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.01fe2fd/src/commands/set-url.ts)_
450
547
 
451
548
  ## `opal ssh copyFrom`
452
549
 
@@ -458,7 +555,7 @@ USAGE
458
555
 
459
556
  FLAGS
460
557
  -h, --help Show CLI help.
461
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g.
558
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
462
559
  https://opal.dev/resources/[ID]
463
560
  -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
464
561
  web flow.
@@ -477,7 +574,7 @@ EXAMPLES
477
574
  $ opal ssh:copyFrom --src instance/dir --dest my/dir --id 51f7176b-0464-4a6f-8369-e951e187b398
478
575
  ```
479
576
 
480
- _See code: [src/commands/ssh/copyFrom.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.0/src/commands/ssh/copyFrom.ts)_
577
+ _See code: [src/commands/ssh/copyFrom.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.01fe2fd/src/commands/ssh/copyFrom.ts)_
481
578
 
482
579
  ## `opal ssh copyTo`
483
580
 
@@ -489,7 +586,7 @@ USAGE
489
586
 
490
587
  FLAGS
491
588
  -h, --help Show CLI help.
492
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g.
589
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
493
590
  https://opal.dev/resources/[ID]
494
591
  -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
495
592
  web flow.
@@ -508,7 +605,7 @@ EXAMPLES
508
605
  $ opal ssh:copyTo --src my/dir --dest instance/dir --id 51f7176b-0464-4a6f-8369-e951e187b398
509
606
  ```
510
607
 
511
- _See code: [src/commands/ssh/copyTo.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.0/src/commands/ssh/copyTo.ts)_
608
+ _See code: [src/commands/ssh/copyTo.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.01fe2fd/src/commands/ssh/copyTo.ts)_
512
609
 
513
610
  ## `opal ssh start`
514
611
 
@@ -520,7 +617,7 @@ USAGE
520
617
 
521
618
  FLAGS
522
619
  -h, --help Show CLI help.
523
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g.
620
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
524
621
  https://opal.dev/resources/[ID]
525
622
  -r, --refresh Starts a new session even if one already exists. Useful if a session is about to expire.
526
623
  -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
@@ -535,7 +632,7 @@ EXAMPLES
535
632
  $ opal ssh:start --id 51f7176b-0464-4a6f-8369-e951e187b398
536
633
  ```
537
634
 
538
- _See code: [src/commands/ssh/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.0/src/commands/ssh/start.ts)_
635
+ _See code: [src/commands/ssh/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.01fe2fd/src/commands/ssh/start.ts)_
539
636
 
540
637
  ## `opal version`
541
638
 
@@ -556,4 +653,21 @@ FLAG DESCRIPTIONS
556
653
  ```
557
654
 
558
655
  _See code: [@oclif/plugin-version](https://github.com/oclif/plugin-version/blob/v2.2.27/src/commands/version.ts)_
656
+
657
+ ## `opal whoami`
658
+
659
+ Describes current url set, organization name, and logged in user if applicable.
660
+
661
+ ```
662
+ USAGE
663
+ $ opal whoami [-h]
664
+
665
+ FLAGS
666
+ -h, --help Show CLI help.
667
+
668
+ DESCRIPTION
669
+ Describes current url set, organization name, and logged in user if applicable.
670
+ ```
671
+
672
+ _See code: [src/commands/whoami.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.01fe2fd/src/commands/whoami.ts)_
559
673
  <!-- commandsstop -->
@@ -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) {
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 &&
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 ID 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. 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
  }
@@ -1,13 +1,111 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
- const utils_1 = require("../../utils/utils");
5
- class RequestGet extends core_1.Command {
4
+ const chalk_1 = require("chalk");
5
+ const graphql_1 = require("../../graphql");
6
+ const apollo_1 = require("../../lib/apollo");
7
+ const cmd_1 = require("../../lib/cmd");
8
+ const config_1 = require("../../lib/config");
9
+ const flags_1 = require("../../lib/flags");
10
+ const displays_1 = require("../../utils/displays");
11
+ const GET_REQUEST = (0, graphql_1.graphql)(`
12
+ query GetRequest(
13
+ $id: RequestId!
14
+ ) {
15
+ request(input: {id: $id}) {
16
+ __typename
17
+ ... on RequestResult {
18
+ request {
19
+ id
20
+ createdAt
21
+ status
22
+ requester {
23
+ displayName
24
+ }
25
+ targetUser {
26
+ displayName
27
+ }
28
+ requestedResources {
29
+ resource {
30
+ displayName
31
+ id
32
+ }
33
+ accessLevel {
34
+ accessLevelName
35
+ accessLevelRemoteId
36
+ }
37
+ }
38
+ durationInMinutes
39
+ requestedGroups {
40
+ group {
41
+ id
42
+ name
43
+ }
44
+ accessLevel {
45
+ accessLevelName
46
+ accessLevelRemoteId
47
+ }
48
+ }
49
+ reason
50
+ }
51
+ }
52
+ ... on RequestNotFoundError {
53
+ message
54
+ }
55
+ }
56
+ }
57
+ `);
58
+ class GetRequest extends core_1.Command {
6
59
  async run() {
7
- (0, utils_1.restrictToDev)(); //TODO: Remove after development is complete
8
- this.log("Running the get command");
60
+ (0, cmd_1.setMostRecentCommand)(this);
61
+ const configData = (0, config_1.getOrCreateConfigData)(this.config.configDir);
62
+ const client = await (0, apollo_1.getClient)(this, true);
63
+ // Verify id tag was provided
64
+ const { flags } = await this.parse(GetRequest);
65
+ if (!flags.id) {
66
+ this.log("Error: Please provide a request ID using the --id flag.");
67
+ this.log("ex. opal request get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4");
68
+ return;
69
+ }
70
+ const resp = await client.query({
71
+ query: GET_REQUEST,
72
+ variables: {
73
+ id: flags.id,
74
+ },
75
+ fetchPolicy: "network-only", // to avoid caching
76
+ });
77
+ switch (resp.data.request.__typename) {
78
+ case "RequestResult": {
79
+ if (flags.verbose) {
80
+ (0, apollo_1.printResponse)(this, resp);
81
+ }
82
+ else {
83
+ (0, displays_1.displayRequestDetails)(this, resp);
84
+ }
85
+ const url = `${configData[config_1.urlKey]}/requests/sent/${flags.id}`;
86
+ this.log(`\n💡Link to request details: ${chalk_1.default.underline(url)}`);
87
+ return;
88
+ }
89
+ case "RequestNotFoundError":
90
+ this.log(`🚫 Request with id ${flags.id} was not found`);
91
+ return;
92
+ default:
93
+ this.log("🚫 Error retrieving request data");
94
+ }
9
95
  }
10
96
  }
11
- RequestGet.hidden = true;
12
- RequestGet.description = "Lists access requests";
13
- exports.default = RequestGet;
97
+ GetRequest.description = "Lists access requests";
98
+ GetRequest.flags = {
99
+ help: flags_1.SHARED_FLAGS.help,
100
+ id: flags_1.SHARED_FLAGS.id,
101
+ verbose: core_1.Flags.boolean({
102
+ char: "v",
103
+ description: "Enable verbose output, prints full response in JSON format. Defaults to false.",
104
+ default: false,
105
+ }),
106
+ };
107
+ GetRequest.examples = [
108
+ "opal request get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4",
109
+ "opal request get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4 --verbose",
110
+ ];
111
+ exports.default = GetRequest;