opal-security 3.1.1-beta.778ef29 → 3.1.1-beta.7e1cc21

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.1-beta.778ef29 linux-x64 node-v20.19.1
25
+ opal-security/3.1.1-beta.7e1cc21 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 resources get`](#opal-resources-get)
48
51
  * [`opal set-auth-provider`](#opal-set-auth-provider)
49
52
  * [`opal set-custom-header`](#opal-set-custom-header)
@@ -53,6 +56,7 @@ USAGE
53
56
  * [`opal ssh copyTo`](#opal-ssh-copyto)
54
57
  * [`opal ssh start`](#opal-ssh-start)
55
58
  * [`opal version`](#opal-version)
59
+ * [`opal whoami`](#opal-whoami)
56
60
 
57
61
  ## `opal autocomplete [SHELL]`
58
62
 
@@ -101,7 +105,7 @@ EXAMPLES
101
105
  $ opal aws:identity
102
106
  ```
103
107
 
104
- _See code: [src/commands/aws/identity.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/aws/identity.ts)_
108
+ _See code: [src/commands/aws/identity.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7e1cc21/src/commands/aws/identity.ts)_
105
109
 
106
110
  ## `opal clear-auth-provider`
107
111
 
@@ -121,7 +125,7 @@ EXAMPLES
121
125
  $ opal clear-auth-provider
122
126
  ```
123
127
 
124
- _See code: [src/commands/clear-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/clear-auth-provider.ts)_
128
+ _See code: [src/commands/clear-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7e1cc21/src/commands/clear-auth-provider.ts)_
125
129
 
126
130
  ## `opal curl-example`
127
131
 
@@ -138,7 +142,7 @@ DESCRIPTION
138
142
  Prints out an example cURL command containing the parameters the CLI uses to query the Opal server.
139
143
  ```
140
144
 
141
- _See code: [src/commands/curl-example.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/curl-example.ts)_
145
+ _See code: [src/commands/curl-example.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7e1cc21/src/commands/curl-example.ts)_
142
146
 
143
147
  ## `opal groups get`
144
148
 
@@ -150,7 +154,7 @@ USAGE
150
154
 
151
155
  FLAGS
152
156
  -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]
157
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g. https://opal.dev/resources/[ID]
154
158
 
155
159
  DESCRIPTION
156
160
  Get group info for a particular group.
@@ -159,7 +163,7 @@ EXAMPLES
159
163
  $ opal groups:get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4
160
164
  ```
161
165
 
162
- _See code: [src/commands/groups/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/groups/get.ts)_
166
+ _See code: [src/commands/groups/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7e1cc21/src/commands/groups/get.ts)_
163
167
 
164
168
  ## `opal help [COMMANDS]`
165
169
 
@@ -191,7 +195,7 @@ USAGE
191
195
 
192
196
  FLAGS
193
197
  -h, --help Show CLI help.
194
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g.
198
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
195
199
  https://opal.dev/resources/[ID]
196
200
  -r, --refresh Starts a new session even if one already exists. Useful if a session is about to expire.
197
201
  -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
@@ -209,7 +213,7 @@ EXAMPLES
209
213
  $ opal iam-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --profileName "custom-profile"
210
214
  ```
211
215
 
212
- _See code: [src/commands/iam-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/iam-roles/start.ts)_
216
+ _See code: [src/commands/iam-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7e1cc21/src/commands/iam-roles/start.ts)_
213
217
 
214
218
  ## `opal kube-roles start`
215
219
 
@@ -222,7 +226,7 @@ USAGE
222
226
  FLAGS
223
227
  -a, --accessLevelRemoteId=<value> The remote ID of the access level with which to access the resource.
224
228
  -h, --help Show CLI help.
225
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g.
229
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
226
230
  https://opal.dev/resources/[ID]
227
231
  -r, --refresh Starts a new session even if one already exists. Useful if a session is about to
228
232
  expire.
@@ -240,7 +244,7 @@ EXAMPLES
240
244
  $ opal kube-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --accessLevelRemoteId "arn:aws:iam::712234975475:role/acme-eks-cluster-admin-role"
241
245
  ```
242
246
 
243
- _See code: [src/commands/kube-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/kube-roles/start.ts)_
247
+ _See code: [src/commands/kube-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7e1cc21/src/commands/kube-roles/start.ts)_
244
248
 
245
249
  ## `opal login`
246
250
 
@@ -261,7 +265,7 @@ EXAMPLES
261
265
  $ opal login
262
266
  ```
263
267
 
264
- _See code: [src/commands/login.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/login.ts)_
268
+ _See code: [src/commands/login.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7e1cc21/src/commands/login.ts)_
265
269
 
266
270
  ## `opal logout`
267
271
 
@@ -281,7 +285,7 @@ EXAMPLES
281
285
  $ opal logout
282
286
  ```
283
287
 
284
- _See code: [src/commands/logout.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/logout.ts)_
288
+ _See code: [src/commands/logout.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7e1cc21/src/commands/logout.ts)_
285
289
 
286
290
  ## `opal postgres-instances start`
287
291
 
@@ -294,7 +298,7 @@ USAGE
294
298
  FLAGS
295
299
  -a, --accessLevelRemoteId=<value> The remote ID of the access level with which to access the resource.
296
300
  -h, --help Show CLI help.
297
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g.
301
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
298
302
  https://opal.dev/resources/[ID]
299
303
  -r, --refresh Starts a new session even if one already exists. Useful if a session is about to
300
304
  expire.
@@ -318,7 +322,82 @@ EXAMPLES
318
322
  $ opal postgres-instances:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --accessLevelRemoteId fullaccess --action view
319
323
  ```
320
324
 
321
- _See code: [src/commands/postgres-instances/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/postgres-instances/start.ts)_
325
+ _See code: [src/commands/postgres-instances/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7e1cc21/src/commands/postgres-instances/start.ts)_
326
+
327
+ ## `opal request create`
328
+
329
+ Creates an Opal access request via an interactive form
330
+
331
+ ```
332
+ USAGE
333
+ $ opal request create [-h] [-a <value>...] [-r <value>] [-d <value>]
334
+
335
+ FLAGS
336
+ -a, --assets=<value>... The ids of the assets (resource, group) to request access to. Append a role ID using a colon
337
+ if needed, e.g. `--assets 123:456`.
338
+ If not provided, an interactive selection flow will be available to select assets to request.
339
+ -d, --duration=<value> The duration of access for the request in minutes. If not provided, you will be prompted.
340
+ -h, --help Show CLI help.
341
+ -r, --reason=<value> The reason for the request, contained in quotes. If not provided, you will be prompted.
342
+
343
+ DESCRIPTION
344
+ Creates an Opal access request via an interactive form
345
+ ```
346
+
347
+ _See code: [src/commands/request/create.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7e1cc21/src/commands/request/create.ts)_
348
+
349
+ ## `opal request get`
350
+
351
+ Lists access requests
352
+
353
+ ```
354
+ USAGE
355
+ $ opal request get [-h] [-i <value>] [-v]
356
+
357
+ FLAGS
358
+ -h, --help Show CLI help.
359
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g. https://opal.dev/resources/[ID]
360
+ -v, --verbose Enable verbose output, prints full response in JSON format. Defaults to false.
361
+
362
+ DESCRIPTION
363
+ Lists access requests
364
+
365
+ EXAMPLES
366
+ $ opal request get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4
367
+
368
+ $ opal request get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4 --verbose
369
+ ```
370
+
371
+ _See code: [src/commands/request/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7e1cc21/src/commands/request/get.ts)_
372
+
373
+ ## `opal request list`
374
+
375
+ Lists your n recent outgoing access requests
376
+
377
+ ```
378
+ USAGE
379
+ $ opal request list [-h] [-n <value>] [-p] [-v]
380
+
381
+ FLAGS
382
+ -h, --help Show CLI help.
383
+ -n, --n=<value> [default: 10] Defines number of requests to be returned. 1 <= n <= 100.
384
+ -p, --pending Show only pending requests. Defaults to false.
385
+ -v, --verbose Enable verbose output, prints full response in JSON format. Defaults to false.
386
+
387
+ DESCRIPTION
388
+ Lists your n recent outgoing access requests
389
+
390
+ EXAMPLES
391
+ $ opal request list --n 5
392
+
393
+ $ opal request list --n 5 --pending
394
+
395
+ $ opal request list --n 5 --verbose
396
+
397
+ $ opal request list --n 5 --pending --verbose
398
+ ```
399
+
400
+ _See code: [src/commands/request/list.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7e1cc21/src/commands/request/list.ts)_
322
401
 
323
402
  ## `opal resources get`
324
403
 
@@ -330,7 +409,7 @@ USAGE
330
409
 
331
410
  FLAGS
332
411
  -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]
412
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g. https://opal.dev/resources/[ID]
334
413
 
335
414
  DESCRIPTION
336
415
  Get resource info for a particular resource.
@@ -339,7 +418,7 @@ EXAMPLES
339
418
  $ opal resources:get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4
340
419
  ```
341
420
 
342
- _See code: [src/commands/resources/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/resources/get.ts)_
421
+ _See code: [src/commands/resources/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7e1cc21/src/commands/resources/get.ts)_
343
422
 
344
423
  ## `opal set-auth-provider`
345
424
 
@@ -365,7 +444,7 @@ EXAMPLES
365
444
  $ opal set-auth-provider --clientID 1234asdf --issuerUrl https://auth.example.com
366
445
  ```
367
446
 
368
- _See code: [src/commands/set-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/set-auth-provider.ts)_
447
+ _See code: [src/commands/set-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7e1cc21/src/commands/set-auth-provider.ts)_
369
448
 
370
449
  ## `opal set-custom-header`
371
450
 
@@ -386,7 +465,7 @@ EXAMPLES
386
465
  $ opal set-custom-header --header 'cf-access-token: $TOKEN'
387
466
  ```
388
467
 
389
- _See code: [src/commands/set-custom-header.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/set-custom-header.ts)_
468
+ _See code: [src/commands/set-custom-header.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7e1cc21/src/commands/set-custom-header.ts)_
390
469
 
391
470
  ## `opal set-token`
392
471
 
@@ -406,7 +485,7 @@ EXAMPLES
406
485
  $ opal set-token
407
486
  ```
408
487
 
409
- _See code: [src/commands/set-token.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/set-token.ts)_
488
+ _See code: [src/commands/set-token.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7e1cc21/src/commands/set-token.ts)_
410
489
 
411
490
  ## `opal set-url [URL]`
412
491
 
@@ -430,7 +509,7 @@ EXAMPLES
430
509
  $ opal set-url
431
510
  ```
432
511
 
433
- _See code: [src/commands/set-url.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/set-url.ts)_
512
+ _See code: [src/commands/set-url.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7e1cc21/src/commands/set-url.ts)_
434
513
 
435
514
  ## `opal ssh copyFrom`
436
515
 
@@ -442,7 +521,7 @@ USAGE
442
521
 
443
522
  FLAGS
444
523
  -h, --help Show CLI help.
445
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g.
524
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
446
525
  https://opal.dev/resources/[ID]
447
526
  -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
448
527
  web flow.
@@ -461,7 +540,7 @@ EXAMPLES
461
540
  $ opal ssh:copyFrom --src instance/dir --dest my/dir --id 51f7176b-0464-4a6f-8369-e951e187b398
462
541
  ```
463
542
 
464
- _See code: [src/commands/ssh/copyFrom.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/ssh/copyFrom.ts)_
543
+ _See code: [src/commands/ssh/copyFrom.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7e1cc21/src/commands/ssh/copyFrom.ts)_
465
544
 
466
545
  ## `opal ssh copyTo`
467
546
 
@@ -473,7 +552,7 @@ USAGE
473
552
 
474
553
  FLAGS
475
554
  -h, --help Show CLI help.
476
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g.
555
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
477
556
  https://opal.dev/resources/[ID]
478
557
  -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
479
558
  web flow.
@@ -492,7 +571,7 @@ EXAMPLES
492
571
  $ opal ssh:copyTo --src my/dir --dest instance/dir --id 51f7176b-0464-4a6f-8369-e951e187b398
493
572
  ```
494
573
 
495
- _See code: [src/commands/ssh/copyTo.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/ssh/copyTo.ts)_
574
+ _See code: [src/commands/ssh/copyTo.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7e1cc21/src/commands/ssh/copyTo.ts)_
496
575
 
497
576
  ## `opal ssh start`
498
577
 
@@ -504,7 +583,7 @@ USAGE
504
583
 
505
584
  FLAGS
506
585
  -h, --help Show CLI help.
507
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g.
586
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
508
587
  https://opal.dev/resources/[ID]
509
588
  -r, --refresh Starts a new session even if one already exists. Useful if a session is about to expire.
510
589
  -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
@@ -519,7 +598,7 @@ EXAMPLES
519
598
  $ opal ssh:start --id 51f7176b-0464-4a6f-8369-e951e187b398
520
599
  ```
521
600
 
522
- _See code: [src/commands/ssh/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.778ef29/src/commands/ssh/start.ts)_
601
+ _See code: [src/commands/ssh/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7e1cc21/src/commands/ssh/start.ts)_
523
602
 
524
603
  ## `opal version`
525
604
 
@@ -540,4 +619,21 @@ FLAG DESCRIPTIONS
540
619
  ```
541
620
 
542
621
  _See code: [@oclif/plugin-version](https://github.com/oclif/plugin-version/blob/v2.2.27/src/commands/version.ts)_
622
+
623
+ ## `opal whoami`
624
+
625
+ Describes current url set, organization name, and logged in user if applicabled.
626
+
627
+ ```
628
+ USAGE
629
+ $ opal whoami [-h]
630
+
631
+ FLAGS
632
+ -h, --help Show CLI help.
633
+
634
+ DESCRIPTION
635
+ Describes current url set, organization name, and logged in user if applicabled.
636
+ ```
637
+
638
+ _See code: [src/commands/whoami.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.7e1cc21/src/commands/whoami.ts)_
543
639
  <!-- 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;
@@ -1,6 +1,12 @@
1
1
  import { Command } from "@oclif/core";
2
- export default class RequestList extends Command {
3
- static hidden: boolean;
2
+ export default class ListRequests extends Command {
4
3
  static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
7
+ n: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
8
+ pending: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
9
+ verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
10
+ };
5
11
  run(): Promise<void>;
6
12
  }