opal-security 3.2.1 → 3.2.3

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.
Files changed (63) hide show
  1. package/README.md +28 -25
  2. package/lib/commands/login.js +18 -11
  3. package/lib/commands/request/create.d.ts +2 -0
  4. package/lib/commands/request/create.js +41 -20
  5. package/lib/commands/request/get.js +7 -58
  6. package/lib/commands/request/list.js +3 -60
  7. package/lib/graphql/gql.d.ts +35 -15
  8. package/lib/graphql/gql.js +9 -5
  9. package/lib/graphql/graphql.d.ts +1138 -383
  10. package/lib/graphql/graphql.js +1780 -1104
  11. package/lib/handler.d.ts +6 -6
  12. package/lib/handler.js +1 -1
  13. package/lib/labels.d.ts +3 -0
  14. package/lib/labels.js +40 -0
  15. package/lib/lib/apollo.d.ts +3 -3
  16. package/lib/lib/apollo.js +24 -47
  17. package/lib/lib/request/api/index.d.ts +6 -0
  18. package/lib/lib/request/api/index.js +20 -0
  19. package/lib/lib/request/api/mutations/create-request.d.ts +8 -0
  20. package/lib/lib/request/api/mutations/create-request.js +159 -0
  21. package/lib/lib/request/api/queries/apps.d.ts +4 -0
  22. package/lib/lib/request/api/queries/apps.js +73 -0
  23. package/lib/lib/request/api/queries/assets.d.ts +6 -0
  24. package/lib/lib/request/api/queries/assets.js +136 -0
  25. package/lib/lib/request/api/queries/request-defaults.d.ts +5 -0
  26. package/lib/lib/request/api/queries/request-defaults.js +52 -0
  27. package/lib/lib/request/api/queries/requests.d.ts +4 -0
  28. package/lib/lib/request/api/queries/requests.js +163 -0
  29. package/lib/lib/request/api/queries/roles.d.ts +5 -0
  30. package/lib/lib/request/api/queries/roles.js +239 -0
  31. package/lib/{utils → lib/request}/displays.d.ts +7 -5
  32. package/lib/{utils → lib/request}/displays.js +52 -30
  33. package/lib/lib/request/prompts/apps-prompt.d.ts +4 -0
  34. package/lib/lib/request/prompts/apps-prompt.js +35 -0
  35. package/lib/lib/request/prompts/asset-prompt.d.ts +5 -0
  36. package/lib/lib/request/prompts/asset-prompt.js +81 -0
  37. package/lib/lib/request/prompts/duration-prompt.d.ts +2 -0
  38. package/lib/lib/request/prompts/duration-prompt.js +125 -0
  39. package/lib/lib/request/prompts/index.d.ts +8 -0
  40. package/lib/lib/request/prompts/index.js +20 -0
  41. package/lib/lib/request/prompts/reason-prompt.d.ts +2 -0
  42. package/lib/lib/request/prompts/reason-prompt.js +20 -0
  43. package/lib/lib/request/prompts/role-prompt.d.ts +4 -0
  44. package/lib/lib/request/prompts/role-prompt.js +44 -0
  45. package/lib/lib/request/prompts/validate-prompt.d.ts +4 -0
  46. package/lib/lib/request/prompts/validate-prompt.js +29 -0
  47. package/lib/lib/request/request-utils.d.ts +14 -0
  48. package/lib/lib/request/request-utils.js +468 -0
  49. package/lib/lib/request/types.d.ts +55 -0
  50. package/lib/lib/request/types.js +15 -0
  51. package/lib/lib/resources.d.ts +1 -1
  52. package/lib/lib/sessions.d.ts +1 -1
  53. package/lib/lib/sessions.js +3 -2
  54. package/lib/lib/util.d.ts +1 -0
  55. package/lib/lib/util.js +16 -0
  56. package/lib/types.d.ts +19 -3
  57. package/lib/types.js +18 -2
  58. package/oclif.manifest.json +54 -38
  59. package/package.json +4 -3
  60. package/lib/lib/requests.d.ts +0 -54
  61. package/lib/lib/requests.js +0 -1160
  62. package/lib/utils/utils.d.ts +0 -1
  63. package/lib/utils/utils.js +0 -18
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.2.1 darwin-arm64 node-v18.20.4
25
+ opal-security/3.2.3 darwin-arm64 node-v18.20.4
26
26
  $ opal --help [COMMAND]
27
27
  USAGE
28
28
  $ opal COMMAND
@@ -106,7 +106,7 @@ EXAMPLES
106
106
  $ opal aws:identity
107
107
  ```
108
108
 
109
- _See code: [src/commands/aws/identity.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/aws/identity.ts)_
109
+ _See code: [src/commands/aws/identity.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.3/src/commands/aws/identity.ts)_
110
110
 
111
111
  ## `opal clear-auth-provider`
112
112
 
@@ -126,7 +126,7 @@ EXAMPLES
126
126
  $ opal clear-auth-provider
127
127
  ```
128
128
 
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)_
129
+ _See code: [src/commands/clear-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.3/src/commands/clear-auth-provider.ts)_
130
130
 
131
131
  ## `opal curl-example`
132
132
 
@@ -143,7 +143,7 @@ DESCRIPTION
143
143
  Prints out an example cURL command containing the parameters the CLI uses to query the Opal server.
144
144
  ```
145
145
 
146
- _See code: [src/commands/curl-example.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/curl-example.ts)_
146
+ _See code: [src/commands/curl-example.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.3/src/commands/curl-example.ts)_
147
147
 
148
148
  ## `opal groups get`
149
149
 
@@ -164,7 +164,7 @@ EXAMPLES
164
164
  $ opal groups:get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4
165
165
  ```
166
166
 
167
- _See code: [src/commands/groups/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/groups/get.ts)_
167
+ _See code: [src/commands/groups/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.3/src/commands/groups/get.ts)_
168
168
 
169
169
  ## `opal help [COMMANDS]`
170
170
 
@@ -214,7 +214,7 @@ EXAMPLES
214
214
  $ opal iam-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --profileName "custom-profile"
215
215
  ```
216
216
 
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)_
217
+ _See code: [src/commands/iam-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.3/src/commands/iam-roles/start.ts)_
218
218
 
219
219
  ## `opal kube-roles start`
220
220
 
@@ -245,7 +245,7 @@ EXAMPLES
245
245
  $ opal kube-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --accessLevelRemoteId "arn:aws:iam::712234975475:role/acme-eks-cluster-admin-role"
246
246
  ```
247
247
 
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)_
248
+ _See code: [src/commands/kube-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.3/src/commands/kube-roles/start.ts)_
249
249
 
250
250
  ## `opal login`
251
251
 
@@ -266,7 +266,7 @@ EXAMPLES
266
266
  $ opal login
267
267
  ```
268
268
 
269
- _See code: [src/commands/login.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/login.ts)_
269
+ _See code: [src/commands/login.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.3/src/commands/login.ts)_
270
270
 
271
271
  ## `opal logout`
272
272
 
@@ -286,7 +286,7 @@ EXAMPLES
286
286
  $ opal logout
287
287
  ```
288
288
 
289
- _See code: [src/commands/logout.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/logout.ts)_
289
+ _See code: [src/commands/logout.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.3/src/commands/logout.ts)_
290
290
 
291
291
  ## `opal postgres-instances start`
292
292
 
@@ -324,7 +324,7 @@ EXAMPLES
324
324
  $ opal postgres-instances:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --accessLevelRemoteId fullaccess --action view
325
325
  ```
326
326
 
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)_
327
+ _See code: [src/commands/postgres-instances/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.3/src/commands/postgres-instances/start.ts)_
328
328
 
329
329
  ## `opal request create`
330
330
 
@@ -332,26 +332,29 @@ Creates an Opal access request via an interactive form
332
332
 
333
333
  ```
334
334
  USAGE
335
- $ opal request create [-h] [-a <value>...] [-r <value>] [-d <value>]
335
+ $ opal request create [-h] [-a <value>...] [-r <value>] [-d <value>] [-t <value>] [-b <value>]
336
336
 
337
337
  FLAGS
338
338
  -a, --assets=<value>... The ids of the assets (resource, group) to request access to. Append a role name using a
339
339
  colon if needed, e.g. `--assets 123:456`.
340
340
  If not provided, an interactive selection flow will be available to select assets to request.
341
+ -b, --bundle=<value> A bundle ID to create a new request based on the assets in the bundle.
341
342
  -d, --duration=<value> The duration of access for the request in minutes. Pass in a 0 value for permanent access. If
342
343
  not provided, you will be prompted.
343
344
  -h, --help Show CLI help.
344
345
  -r, --reason=<value> The reason for the request, contained in quotes. If not provided, you will be prompted.
346
+ -t, --template=<value> A request ID of a previously finished request (cancelled/denied/approved) to create a new
347
+ request based on the completed request.
345
348
 
346
349
  DESCRIPTION
347
350
  Creates an Opal access request via an interactive form
348
351
  ```
349
352
 
350
- _See code: [src/commands/request/create.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/request/create.ts)_
353
+ _See code: [src/commands/request/create.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.3/src/commands/request/create.ts)_
351
354
 
352
355
  ## `opal request get`
353
356
 
354
- Lists access requests
357
+ Fetch details of an access request by request ID
355
358
 
356
359
  ```
357
360
  USAGE
@@ -363,7 +366,7 @@ FLAGS
363
366
  -v, --verbose Enable verbose output, prints full response in JSON format. Defaults to false.
364
367
 
365
368
  DESCRIPTION
366
- Lists access requests
369
+ Fetch details of an access request by request ID
367
370
 
368
371
  EXAMPLES
369
372
  $ opal request get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4
@@ -371,7 +374,7 @@ EXAMPLES
371
374
  $ opal request get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4 --verbose
372
375
  ```
373
376
 
374
- _See code: [src/commands/request/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/request/get.ts)_
377
+ _See code: [src/commands/request/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.3/src/commands/request/get.ts)_
375
378
 
376
379
  ## `opal request list`
377
380
 
@@ -403,7 +406,7 @@ EXAMPLES
403
406
  $ opal request list --n 5 --pending --verbose
404
407
  ```
405
408
 
406
- _See code: [src/commands/request/list.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/request/list.ts)_
409
+ _See code: [src/commands/request/list.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.3/src/commands/request/list.ts)_
407
410
 
408
411
  ## `opal request ls`
409
412
 
@@ -454,7 +457,7 @@ EXAMPLES
454
457
  $ opal resources:get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4
455
458
  ```
456
459
 
457
- _See code: [src/commands/resources/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/resources/get.ts)_
460
+ _See code: [src/commands/resources/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.3/src/commands/resources/get.ts)_
458
461
 
459
462
  ## `opal set-auth-provider`
460
463
 
@@ -480,7 +483,7 @@ EXAMPLES
480
483
  $ opal set-auth-provider --clientID 1234asdf --issuerUrl https://auth.example.com
481
484
  ```
482
485
 
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)_
486
+ _See code: [src/commands/set-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.3/src/commands/set-auth-provider.ts)_
484
487
 
485
488
  ## `opal set-custom-header`
486
489
 
@@ -501,7 +504,7 @@ EXAMPLES
501
504
  $ opal set-custom-header --header 'cf-access-token: $TOKEN'
502
505
  ```
503
506
 
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)_
507
+ _See code: [src/commands/set-custom-header.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.3/src/commands/set-custom-header.ts)_
505
508
 
506
509
  ## `opal set-token`
507
510
 
@@ -521,7 +524,7 @@ EXAMPLES
521
524
  $ opal set-token
522
525
  ```
523
526
 
524
- _See code: [src/commands/set-token.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/set-token.ts)_
527
+ _See code: [src/commands/set-token.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.3/src/commands/set-token.ts)_
525
528
 
526
529
  ## `opal set-url [URL]`
527
530
 
@@ -545,7 +548,7 @@ EXAMPLES
545
548
  $ opal set-url
546
549
  ```
547
550
 
548
- _See code: [src/commands/set-url.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/set-url.ts)_
551
+ _See code: [src/commands/set-url.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.3/src/commands/set-url.ts)_
549
552
 
550
553
  ## `opal ssh copyFrom`
551
554
 
@@ -576,7 +579,7 @@ EXAMPLES
576
579
  $ opal ssh:copyFrom --src instance/dir --dest my/dir --id 51f7176b-0464-4a6f-8369-e951e187b398
577
580
  ```
578
581
 
579
- _See code: [src/commands/ssh/copyFrom.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/ssh/copyFrom.ts)_
582
+ _See code: [src/commands/ssh/copyFrom.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.3/src/commands/ssh/copyFrom.ts)_
580
583
 
581
584
  ## `opal ssh copyTo`
582
585
 
@@ -607,7 +610,7 @@ EXAMPLES
607
610
  $ opal ssh:copyTo --src my/dir --dest instance/dir --id 51f7176b-0464-4a6f-8369-e951e187b398
608
611
  ```
609
612
 
610
- _See code: [src/commands/ssh/copyTo.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/ssh/copyTo.ts)_
613
+ _See code: [src/commands/ssh/copyTo.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.3/src/commands/ssh/copyTo.ts)_
611
614
 
612
615
  ## `opal ssh start`
613
616
 
@@ -634,7 +637,7 @@ EXAMPLES
634
637
  $ opal ssh:start --id 51f7176b-0464-4a6f-8369-e951e187b398
635
638
  ```
636
639
 
637
- _See code: [src/commands/ssh/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/ssh/start.ts)_
640
+ _See code: [src/commands/ssh/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.3/src/commands/ssh/start.ts)_
638
641
 
639
642
  ## `opal version`
640
643
 
@@ -671,5 +674,5 @@ DESCRIPTION
671
674
  Describes current url set, organization name, and logged in user if applicable.
672
675
  ```
673
676
 
674
- _See code: [src/commands/whoami.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.1/src/commands/whoami.ts)_
677
+ _See code: [src/commands/whoami.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.3/src/commands/whoami.ts)_
675
678
  <!-- commandsstop -->
@@ -4,6 +4,7 @@ exports.CLITokenExchangeName = exports.CLIAuthSessionCheckDocument = exports.CLI
4
4
  const core_1 = require("@oclif/core");
5
5
  const open = require("open");
6
6
  const openid_client_1 = require("openid-client");
7
+ const client_1 = require("@apollo/client");
7
8
  const inquirer = require("inquirer");
8
9
  const handler_1 = require("../handler");
9
10
  const apollo_1 = require("../lib/apollo");
@@ -80,7 +81,7 @@ mutation CLITokenExchange($input: CLITokenExchangeInput!) {
80
81
  `;
81
82
  class Login extends core_1.Command {
82
83
  async run() {
83
- var _a, _b, _c, _d, _e, _f, _g;
84
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
84
85
  try {
85
86
  await (0, apollo_1.initClient)(this, false);
86
87
  const { flags } = await this.parse(Login);
@@ -123,9 +124,8 @@ class Login extends core_1.Command {
123
124
  query: CLISignInMethodDocument,
124
125
  variables: { input: { email } },
125
126
  });
126
- if (error === null || error === void 0 ? void 0 : error.networkError) {
127
- if ("statusCode" in error.networkError &&
128
- error.networkError.statusCode === 422) {
127
+ if (error) {
128
+ if (client_1.ServerError.is(error) && error.statusCode === 422) {
129
129
  const { resp, error: legacyError } = await (0, handler_1.runQueryDeprecated)({
130
130
  command: this,
131
131
  query: CLISignInMethodDocumentLegacy,
@@ -142,11 +142,11 @@ class Login extends core_1.Command {
142
142
  return (0, apollo_1.handleError)(this, "Could not connect to Opal. Did you set the right URL? (`opal set-url --help`)");
143
143
  }
144
144
  }
145
- const signInOrganizations = ((_a = signInOrganizationsResponse === null || signInOrganizationsResponse === void 0 ? void 0 : signInOrganizationsResponse.data.signInMethod) === null || _a === void 0 ? void 0 : _a.__typename) ===
145
+ const signInOrganizations = ((_b = (_a = signInOrganizationsResponse === null || signInOrganizationsResponse === void 0 ? void 0 : signInOrganizationsResponse.data) === null || _a === void 0 ? void 0 : _a.signInMethod) === null || _b === void 0 ? void 0 : _b.__typename) ===
146
146
  "SignInMethodResult"
147
147
  ? signInOrganizationsResponse.data.signInMethod.signInOrganizations
148
- : ((_b = signInOrganizationsLegacyResponse === null || signInOrganizationsLegacyResponse === void 0 ? void 0 : signInOrganizationsLegacyResponse.data.signInMethod) === null || _b === void 0 ? void 0 : _b.__typename) === "SignInMethodResult"
149
- ? (_c = signInOrganizationsLegacyResponse === null || signInOrganizationsLegacyResponse === void 0 ? void 0 : signInOrganizationsLegacyResponse.data.signInMethod) === null || _c === void 0 ? void 0 : _c.signInOrganizations
148
+ : ((_d = (_c = signInOrganizationsLegacyResponse === null || signInOrganizationsLegacyResponse === void 0 ? void 0 : signInOrganizationsLegacyResponse.data) === null || _c === void 0 ? void 0 : _c.signInMethod) === null || _d === void 0 ? void 0 : _d.__typename) === "SignInMethodResult"
149
+ ? (_e = signInOrganizationsLegacyResponse === null || signInOrganizationsLegacyResponse === void 0 ? void 0 : signInOrganizationsLegacyResponse.data.signInMethod) === null || _e === void 0 ? void 0 : _e.signInOrganizations
150
150
  : undefined;
151
151
  if (signInOrganizations && signInOrganizations.length > 0) {
152
152
  if (signInOrganizations.length === 1) {
@@ -161,7 +161,7 @@ class Login extends core_1.Command {
161
161
  message: "Select an organization:",
162
162
  type: "list",
163
163
  choices: signInOrganizations.map((signInOrganization) => ({
164
- name: signInOrganization.organizationName,
164
+ name: signInOrganization === null || signInOrganization === void 0 ? void 0 : signInOrganization.organizationName,
165
165
  value: signInOrganization,
166
166
  })),
167
167
  },
@@ -183,7 +183,7 @@ class Login extends core_1.Command {
183
183
  input: { organizationId },
184
184
  },
185
185
  });
186
- const state = (_d = signInResp === null || signInResp === void 0 ? void 0 : signInResp.data.signIn) === null || _d === void 0 ? void 0 : _d.state;
186
+ const state = (_g = (_f = signInResp === null || signInResp === void 0 ? void 0 : signInResp.data) === null || _f === void 0 ? void 0 : _f.signIn) === null || _g === void 0 ? void 0 : _g.state;
187
187
  let issuer;
188
188
  // issuerURL may come from configData if set by set-airgap-auth
189
189
  if (configData.issuerURL) {
@@ -218,12 +218,19 @@ class Login extends core_1.Command {
218
218
  token_endpoint_auth_method: "none",
219
219
  application_type: "native",
220
220
  });
221
+ // Add the mfa:skip scope to the scopes according to appropriate org settings
222
+ // This scope is evaluated in Auth0 "MFA Rule" Action to skip or enabled MFA
223
+ let scopes = "openid email profile";
224
+ if (!((_j = (_h = signInResp === null || signInResp === void 0 ? void 0 : signInResp.data) === null || _h === void 0 ? void 0 : _h.signIn) === null || _j === void 0 ? void 0 : _j.forceExtraStep)) {
225
+ scopes += " mfa:skip";
226
+ }
221
227
  const handle = await client.deviceAuthorization({
222
228
  audience: "https://opal.dev",
223
- scope: "openid email profile",
229
+ scope: scopes,
224
230
  });
225
231
  this.log("\nYou are being redirected to your browser to authenticate.\n");
226
232
  this.log(` User Code: ${handle.user_code}\n`);
233
+ this.log("If your browser doesn't open, go to:", handle.verification_uri_complete, "\n");
227
234
  // Wait before opening the browser window to ensure the user has time to
228
235
  // see the User Code.
229
236
  await (0, util_1.sleep)(1000);
@@ -254,7 +261,7 @@ class Login extends core_1.Command {
254
261
  variables: {},
255
262
  });
256
263
  if (authCheckErr ||
257
- !((_g = (_f = (_e = authCheckResp === null || authCheckResp === void 0 ? void 0 : authCheckResp.data) === null || _e === void 0 ? void 0 : _e.organizationSettings) === null || _f === void 0 ? void 0 : _f.settings) === null || _g === void 0 ? void 0 : _g.id)) {
264
+ !((_m = (_l = (_k = authCheckResp === null || authCheckResp === void 0 ? void 0 : authCheckResp.data) === null || _k === void 0 ? void 0 : _k.organizationSettings) === null || _l === void 0 ? void 0 : _l.settings) === null || _m === void 0 ? void 0 : _m.id)) {
258
265
  this.log("Error verifying log in. Authenticated commands may fail. Please double check your URL and use `opal logout; opal login` to try again.\n");
259
266
  await (0, credentials_1.removeOpalCredentials)(this);
260
267
  process.exit(1);
@@ -6,6 +6,8 @@ export default class RequestCreate extends Command {
6
6
  assets: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
7
7
  reason: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
8
8
  duration: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
9
+ template: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
10
+ bundle: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
9
11
  };
10
12
  run(): Promise<void>;
11
13
  }
@@ -4,60 +4,73 @@ const core_1 = require("@oclif/core");
4
4
  const apollo_1 = require("../../lib/apollo");
5
5
  const cmd_1 = require("../../lib/cmd");
6
6
  const flags_1 = require("../../lib/flags");
7
- const requests_1 = require("../../lib/requests");
8
- const displays_1 = require("../../utils/displays");
7
+ const displays_1 = require("../../lib/request/displays");
8
+ const prompts_1 = require("../../lib/request/prompts");
9
+ const request_utils_1 = require("../../lib/request/request-utils");
9
10
  class RequestCreate extends core_1.Command {
10
11
  async run() {
12
+ var _a;
11
13
  (0, cmd_1.setMostRecentCommand)(this);
12
14
  await (0, apollo_1.initClient)(this, true);
13
15
  const client = await (0, apollo_1.getClient)(this, true);
14
16
  const { flags } = await this.parse(RequestCreate);
15
- const metadata = (0, requests_1.initEmptyRequestMetadata)();
17
+ const metadata = (0, request_utils_1.initEmptyRequestMetadata)();
18
+ if (flags.template) {
19
+ await (0, request_utils_1.duplicateRequestTemplate)(this, client, flags.template, metadata);
20
+ }
21
+ if (flags.bundle) {
22
+ await (0, request_utils_1.copyBundleAssets)(this, client, flags.bundle, metadata.requestMap);
23
+ }
16
24
  if (flags.assets) {
17
25
  // if IDs are provided, bypass the interactive selection process
18
- await (0, requests_1.bypassRequestSelection)(this, client, flags.assets, metadata);
26
+ await (0, request_utils_1.bypassRequestSelection)(this, client, flags.assets, metadata);
19
27
  }
20
- else {
28
+ else if (!flags.template && !flags.bundle) {
21
29
  (0, displays_1.headerMessage)(this);
22
30
  let shouldProceed = false;
23
31
  while (!shouldProceed) {
24
32
  // Step 1: Select first round of assets from an app
25
- await (0, requests_1.selectRequestableItems)(this, client, metadata.requestMap);
33
+ await (0, prompts_1.selectRequestableItems)(this, client, metadata.requestMap);
26
34
  // Step 2: Display the selected items in a tree format
27
35
  (0, displays_1.headerMessage)(this);
28
36
  (0, displays_1.treeifyRequestMap)(this, metadata.requestMap);
29
37
  // Step 3: Prompt to add more items, repeat 1-3 if needed
30
- shouldProceed = await (0, requests_1.doneSelectingAssets)();
38
+ shouldProceed = await (0, prompts_1.doneSelectingAssets)();
31
39
  }
32
40
  }
33
41
  // Step 4: Set Request Defaults
34
- await (0, requests_1.setRequestDefaults)(this, client, metadata);
35
- // Step 4: Prompt for request reason
42
+ await (0, request_utils_1.setRequestDefaults)(this, client, metadata);
43
+ // Step 5: Prompt for request reason
36
44
  if (flags.reason) {
37
45
  metadata.reason = flags.reason;
38
46
  }
39
47
  else if (!(metadata.requestDefaults.reasonOptional &&
40
48
  flags.assets &&
41
- flags.duration)) {
42
- await (0, requests_1.promptForReason)(metadata);
49
+ flags.duration) &&
50
+ !flags.template) {
51
+ await (0, prompts_1.promptForReason)(metadata);
43
52
  }
44
- // Step 5: Prompt for expiration
53
+ // Step 6: Prompt for expiration
45
54
  if (flags.duration !== undefined) {
46
- (0, requests_1.bypassDuration)(this, flags.duration, metadata);
55
+ (0, request_utils_1.bypassDuration)(this, flags.duration, metadata);
56
+ }
57
+ else if (!flags.template) {
58
+ await (0, prompts_1.promptForDuration)(metadata);
47
59
  }
48
60
  else {
49
- await (0, requests_1.promptForExpiration)(metadata);
61
+ (0, request_utils_1.bypassDuration)(this, (_a = metadata.durationInMinutes) !== null && _a !== void 0 ? _a : 0, metadata);
50
62
  }
51
- // Step 6: Display final summary of request
63
+ // Step 7: Display final summary of request
52
64
  let canSubmit = true;
53
- if (!(flags.assets &&
65
+ if (!((flags.assets || flags.bundle) &&
54
66
  flags.duration !== undefined &&
55
- (metadata.requestDefaults.reasonOptional || flags.reason))) {
56
- canSubmit = await (0, requests_1.promptRequestSubmission)(this, metadata);
67
+ (metadata.requestDefaults.reasonOptional || flags.reason)) &&
68
+ !flags.template) {
69
+ canSubmit = await (0, prompts_1.promptRequestSubmission)(this, metadata);
57
70
  }
58
- // Step 7: Prompt for final submission
71
+ // Step 8: Prompt for final submission
59
72
  if (canSubmit)
60
- await (0, requests_1.submitFinalRequest)(this, client, metadata);
73
+ await (0, request_utils_1.submitFinalRequest)(this, client, metadata);
61
74
  }
62
75
  }
63
76
  RequestCreate.description = "Creates an Opal access request via an interactive form";
@@ -77,5 +90,13 @@ RequestCreate.flags = {
77
90
  char: "d",
78
91
  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
92
  }),
93
+ template: core_1.Flags.string({
94
+ char: "t",
95
+ description: "A request ID of a previously finished request (cancelled/denied/approved) to create a new request based on the completed request.",
96
+ }),
97
+ bundle: core_1.Flags.string({
98
+ char: "b",
99
+ description: "A bundle ID to create a new request based on the assets in the bundle.",
100
+ }),
80
101
  };
81
102
  exports.default = RequestCreate;
@@ -2,61 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
4
  const chalk_1 = require("chalk");
5
- const graphql_1 = require("../../graphql");
6
5
  const apollo_1 = require("../../lib/apollo");
7
6
  const cmd_1 = require("../../lib/cmd");
8
7
  const config_1 = require("../../lib/config");
9
8
  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
- `);
9
+ const api_1 = require("../../lib/request/api");
10
+ const displays_1 = require("../../lib/request/displays");
58
11
  class GetRequest extends core_1.Command {
59
12
  async run() {
13
+ var _a;
60
14
  (0, cmd_1.setMostRecentCommand)(this);
61
15
  const configData = (0, config_1.getOrCreateConfigData)(this.config.configDir);
62
16
  const client = await (0, apollo_1.getClient)(this, true);
@@ -67,14 +21,8 @@ class GetRequest extends core_1.Command {
67
21
  this.log("ex. opal request get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4");
68
22
  return;
69
23
  }
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) {
24
+ const resp = await (0, api_1.queryRequest)(client, flags.id);
25
+ switch ((_a = resp.data) === null || _a === void 0 ? void 0 : _a.request.__typename) {
78
26
  case "RequestResult": {
79
27
  if (flags.verbose) {
80
28
  (0, apollo_1.printResponse)(this, resp);
@@ -84,6 +32,7 @@ class GetRequest extends core_1.Command {
84
32
  }
85
33
  const url = `${configData[config_1.urlKey]}/requests/sent/${flags.id}`;
86
34
  this.log(`\n💡Link to request details: ${chalk_1.default.underline(url)}`);
35
+ (0, displays_1.displayRequestAgain)(this, flags.id);
87
36
  return;
88
37
  }
89
38
  case "RequestNotFoundError":
@@ -94,7 +43,7 @@ class GetRequest extends core_1.Command {
94
43
  }
95
44
  }
96
45
  }
97
- GetRequest.description = "Lists access requests";
46
+ GetRequest.description = "Fetch details of an access request by request ID";
98
47
  GetRequest.flags = {
99
48
  help: flags_1.SHARED_FLAGS.help,
100
49
  id: flags_1.SHARED_FLAGS.id,
@@ -1,61 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
- const graphql_1 = require("../../graphql");
5
4
  const apollo_1 = require("../../lib/apollo");
6
5
  const cmd_1 = require("../../lib/cmd");
7
6
  const flags_1 = require("../../lib/flags");
8
- const displays_1 = require("../../utils/displays");
9
- // Add date filters, search query,
10
- const GET_REQUESTS = (0, graphql_1.graphql)(`
11
- query GetRequests($pageSize: Int, $showPendingOnly: Boolean!) {
12
- requests(input: {
13
- requestType: OUTGOING
14
- maxNumEntries: $pageSize
15
- filters: {
16
- showPendingOnly: $showPendingOnly
17
- }
18
- }) {
19
- __typename
20
- ... on RequestsResult {
21
- requestType
22
- requests {
23
- durationInMinutes
24
- id
25
- requester {
26
- displayName
27
- }
28
- targetUser {
29
- displayName
30
- }
31
- reason
32
- requestedResources {
33
- resource {
34
- displayName
35
- id
36
- }
37
- accessLevel {
38
- accessLevelName
39
- accessLevelRemoteId
40
- }
41
- }
42
- requestedGroups {
43
- group {
44
- name
45
- id
46
- }
47
- accessLevel {
48
- accessLevelName
49
- accessLevelRemoteId
50
- }
51
- }
52
- status
53
- }
54
-
55
- }
56
-
57
- }
58
- }`);
7
+ const api_1 = require("../../lib/request/api");
8
+ const displays_1 = require("../../lib/request/displays");
59
9
  class ListRequests extends core_1.Command {
60
10
  async run() {
61
11
  (0, cmd_1.setMostRecentCommand)(this);
@@ -69,14 +19,7 @@ class ListRequests extends core_1.Command {
69
19
  if (flags.showPendingOnly) {
70
20
  showPendingOnly = flags.showPendingOnly;
71
21
  }
72
- const resp = await client.query({
73
- query: GET_REQUESTS,
74
- variables: {
75
- pageSize: pageSize,
76
- showPendingOnly: showPendingOnly,
77
- },
78
- fetchPolicy: "network-only", // to avoid caching
79
- });
22
+ const resp = await (0, api_1.queryRequests)(client, pageSize, showPendingOnly);
80
23
  //TODO: Make this pretty
81
24
  if (flags.verbose) {
82
25
  (0, apollo_1.printResponse)(this, resp);