opal-security 3.1.1-beta.e966e75 → 3.1.1-beta.f1a5f49

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.e966e75 linux-x64 node-v20.19.1
25
+ opal-security/3.1.1-beta.f1a5f49 linux-x64 node-v20.19.2
26
26
  $ opal --help [COMMAND]
27
27
  USAGE
28
28
  $ opal COMMAND
@@ -53,6 +53,7 @@ USAGE
53
53
  * [`opal ssh copyTo`](#opal-ssh-copyto)
54
54
  * [`opal ssh start`](#opal-ssh-start)
55
55
  * [`opal version`](#opal-version)
56
+ * [`opal whoami`](#opal-whoami)
56
57
 
57
58
  ## `opal autocomplete [SHELL]`
58
59
 
@@ -101,7 +102,7 @@ EXAMPLES
101
102
  $ opal aws:identity
102
103
  ```
103
104
 
104
- _See code: [src/commands/aws/identity.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.e966e75/src/commands/aws/identity.ts)_
105
+ _See code: [src/commands/aws/identity.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.f1a5f49/src/commands/aws/identity.ts)_
105
106
 
106
107
  ## `opal clear-auth-provider`
107
108
 
@@ -121,7 +122,7 @@ EXAMPLES
121
122
  $ opal clear-auth-provider
122
123
  ```
123
124
 
124
- _See code: [src/commands/clear-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.e966e75/src/commands/clear-auth-provider.ts)_
125
+ _See code: [src/commands/clear-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.f1a5f49/src/commands/clear-auth-provider.ts)_
125
126
 
126
127
  ## `opal curl-example`
127
128
 
@@ -138,7 +139,7 @@ DESCRIPTION
138
139
  Prints out an example cURL command containing the parameters the CLI uses to query the Opal server.
139
140
  ```
140
141
 
141
- _See code: [src/commands/curl-example.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.e966e75/src/commands/curl-example.ts)_
142
+ _See code: [src/commands/curl-example.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.f1a5f49/src/commands/curl-example.ts)_
142
143
 
143
144
  ## `opal groups get`
144
145
 
@@ -150,7 +151,7 @@ USAGE
150
151
 
151
152
  FLAGS
152
153
  -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]
154
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g. https://opal.dev/resources/[ID]
154
155
 
155
156
  DESCRIPTION
156
157
  Get group info for a particular group.
@@ -159,7 +160,7 @@ EXAMPLES
159
160
  $ opal groups:get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4
160
161
  ```
161
162
 
162
- _See code: [src/commands/groups/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.e966e75/src/commands/groups/get.ts)_
163
+ _See code: [src/commands/groups/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.f1a5f49/src/commands/groups/get.ts)_
163
164
 
164
165
  ## `opal help [COMMANDS]`
165
166
 
@@ -191,7 +192,7 @@ USAGE
191
192
 
192
193
  FLAGS
193
194
  -h, --help Show CLI help.
194
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g.
195
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
195
196
  https://opal.dev/resources/[ID]
196
197
  -r, --refresh Starts a new session even if one already exists. Useful if a session is about to expire.
197
198
  -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
@@ -209,7 +210,7 @@ EXAMPLES
209
210
  $ opal iam-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --profileName "custom-profile"
210
211
  ```
211
212
 
212
- _See code: [src/commands/iam-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.e966e75/src/commands/iam-roles/start.ts)_
213
+ _See code: [src/commands/iam-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.f1a5f49/src/commands/iam-roles/start.ts)_
213
214
 
214
215
  ## `opal kube-roles start`
215
216
 
@@ -222,7 +223,7 @@ USAGE
222
223
  FLAGS
223
224
  -a, --accessLevelRemoteId=<value> The remote ID of the access level with which to access the resource.
224
225
  -h, --help Show CLI help.
225
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g.
226
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
226
227
  https://opal.dev/resources/[ID]
227
228
  -r, --refresh Starts a new session even if one already exists. Useful if a session is about to
228
229
  expire.
@@ -240,7 +241,7 @@ EXAMPLES
240
241
  $ opal kube-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --accessLevelRemoteId "arn:aws:iam::712234975475:role/acme-eks-cluster-admin-role"
241
242
  ```
242
243
 
243
- _See code: [src/commands/kube-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.e966e75/src/commands/kube-roles/start.ts)_
244
+ _See code: [src/commands/kube-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.f1a5f49/src/commands/kube-roles/start.ts)_
244
245
 
245
246
  ## `opal login`
246
247
 
@@ -261,7 +262,7 @@ EXAMPLES
261
262
  $ opal login
262
263
  ```
263
264
 
264
- _See code: [src/commands/login.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.e966e75/src/commands/login.ts)_
265
+ _See code: [src/commands/login.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.f1a5f49/src/commands/login.ts)_
265
266
 
266
267
  ## `opal logout`
267
268
 
@@ -281,7 +282,7 @@ EXAMPLES
281
282
  $ opal logout
282
283
  ```
283
284
 
284
- _See code: [src/commands/logout.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.e966e75/src/commands/logout.ts)_
285
+ _See code: [src/commands/logout.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.f1a5f49/src/commands/logout.ts)_
285
286
 
286
287
  ## `opal postgres-instances start`
287
288
 
@@ -294,7 +295,7 @@ USAGE
294
295
  FLAGS
295
296
  -a, --accessLevelRemoteId=<value> The remote ID of the access level with which to access the resource.
296
297
  -h, --help Show CLI help.
297
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g.
298
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
298
299
  https://opal.dev/resources/[ID]
299
300
  -r, --refresh Starts a new session even if one already exists. Useful if a session is about to
300
301
  expire.
@@ -318,7 +319,7 @@ EXAMPLES
318
319
  $ opal postgres-instances:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --accessLevelRemoteId fullaccess --action view
319
320
  ```
320
321
 
321
- _See code: [src/commands/postgres-instances/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.e966e75/src/commands/postgres-instances/start.ts)_
322
+ _See code: [src/commands/postgres-instances/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.f1a5f49/src/commands/postgres-instances/start.ts)_
322
323
 
323
324
  ## `opal resources get`
324
325
 
@@ -330,7 +331,7 @@ USAGE
330
331
 
331
332
  FLAGS
332
333
  -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]
334
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g. https://opal.dev/resources/[ID]
334
335
 
335
336
  DESCRIPTION
336
337
  Get resource info for a particular resource.
@@ -339,7 +340,7 @@ EXAMPLES
339
340
  $ opal resources:get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4
340
341
  ```
341
342
 
342
- _See code: [src/commands/resources/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.e966e75/src/commands/resources/get.ts)_
343
+ _See code: [src/commands/resources/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.f1a5f49/src/commands/resources/get.ts)_
343
344
 
344
345
  ## `opal set-auth-provider`
345
346
 
@@ -365,7 +366,7 @@ EXAMPLES
365
366
  $ opal set-auth-provider --clientID 1234asdf --issuerUrl https://auth.example.com
366
367
  ```
367
368
 
368
- _See code: [src/commands/set-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.e966e75/src/commands/set-auth-provider.ts)_
369
+ _See code: [src/commands/set-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.f1a5f49/src/commands/set-auth-provider.ts)_
369
370
 
370
371
  ## `opal set-custom-header`
371
372
 
@@ -386,7 +387,7 @@ EXAMPLES
386
387
  $ opal set-custom-header --header 'cf-access-token: $TOKEN'
387
388
  ```
388
389
 
389
- _See code: [src/commands/set-custom-header.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.e966e75/src/commands/set-custom-header.ts)_
390
+ _See code: [src/commands/set-custom-header.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.f1a5f49/src/commands/set-custom-header.ts)_
390
391
 
391
392
  ## `opal set-token`
392
393
 
@@ -406,7 +407,7 @@ EXAMPLES
406
407
  $ opal set-token
407
408
  ```
408
409
 
409
- _See code: [src/commands/set-token.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.e966e75/src/commands/set-token.ts)_
410
+ _See code: [src/commands/set-token.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.f1a5f49/src/commands/set-token.ts)_
410
411
 
411
412
  ## `opal set-url [URL]`
412
413
 
@@ -430,7 +431,7 @@ EXAMPLES
430
431
  $ opal set-url
431
432
  ```
432
433
 
433
- _See code: [src/commands/set-url.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.e966e75/src/commands/set-url.ts)_
434
+ _See code: [src/commands/set-url.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.f1a5f49/src/commands/set-url.ts)_
434
435
 
435
436
  ## `opal ssh copyFrom`
436
437
 
@@ -442,7 +443,7 @@ USAGE
442
443
 
443
444
  FLAGS
444
445
  -h, --help Show CLI help.
445
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g.
446
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
446
447
  https://opal.dev/resources/[ID]
447
448
  -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
448
449
  web flow.
@@ -461,7 +462,7 @@ EXAMPLES
461
462
  $ opal ssh:copyFrom --src instance/dir --dest my/dir --id 51f7176b-0464-4a6f-8369-e951e187b398
462
463
  ```
463
464
 
464
- _See code: [src/commands/ssh/copyFrom.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.e966e75/src/commands/ssh/copyFrom.ts)_
465
+ _See code: [src/commands/ssh/copyFrom.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.f1a5f49/src/commands/ssh/copyFrom.ts)_
465
466
 
466
467
  ## `opal ssh copyTo`
467
468
 
@@ -473,7 +474,7 @@ USAGE
473
474
 
474
475
  FLAGS
475
476
  -h, --help Show CLI help.
476
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g.
477
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
477
478
  https://opal.dev/resources/[ID]
478
479
  -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
479
480
  web flow.
@@ -492,7 +493,7 @@ EXAMPLES
492
493
  $ opal ssh:copyTo --src my/dir --dest instance/dir --id 51f7176b-0464-4a6f-8369-e951e187b398
493
494
  ```
494
495
 
495
- _See code: [src/commands/ssh/copyTo.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.e966e75/src/commands/ssh/copyTo.ts)_
496
+ _See code: [src/commands/ssh/copyTo.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.f1a5f49/src/commands/ssh/copyTo.ts)_
496
497
 
497
498
  ## `opal ssh start`
498
499
 
@@ -504,7 +505,7 @@ USAGE
504
505
 
505
506
  FLAGS
506
507
  -h, --help Show CLI help.
507
- -i, --id=<value> The Opal ID of the resource. You can find this from the URL, e.g.
508
+ -i, --id=<value> The Opal ID of the asset. You can find this from the URL, e.g.
508
509
  https://opal.dev/resources/[ID]
509
510
  -r, --refresh Starts a new session even if one already exists. Useful if a session is about to expire.
510
511
  -s, --sessionId=<value> The Opal ID of the session to connect to. Uses an existing session that was created via the
@@ -519,7 +520,7 @@ EXAMPLES
519
520
  $ opal ssh:start --id 51f7176b-0464-4a6f-8369-e951e187b398
520
521
  ```
521
522
 
522
- _See code: [src/commands/ssh/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.e966e75/src/commands/ssh/start.ts)_
523
+ _See code: [src/commands/ssh/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.f1a5f49/src/commands/ssh/start.ts)_
523
524
 
524
525
  ## `opal version`
525
526
 
@@ -540,4 +541,21 @@ FLAG DESCRIPTIONS
540
541
  ```
541
542
 
542
543
  _See code: [@oclif/plugin-version](https://github.com/oclif/plugin-version/blob/v2.2.27/src/commands/version.ts)_
544
+
545
+ ## `opal whoami`
546
+
547
+ Describes current url set, organization name, and logged in user if applicabled.
548
+
549
+ ```
550
+ USAGE
551
+ $ opal whoami [-h]
552
+
553
+ FLAGS
554
+ -h, --help Show CLI help.
555
+
556
+ DESCRIPTION
557
+ Describes current url set, organization name, and logged in user if applicabled.
558
+ ```
559
+
560
+ _See code: [src/commands/whoami.ts](https://github.com/opalsecurity/opal-cli/blob/v3.1.1-beta.f1a5f49/src/commands/whoami.ts)_
543
561
  <!-- 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)({
@@ -2,5 +2,11 @@ import { Command } from "@oclif/core";
2
2
  export default class RequestCreate extends Command {
3
3
  static hidden: boolean;
4
4
  static description: string;
5
+ static flags: {
6
+ help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
7
+ assets: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
8
+ reason: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
9
+ duration: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
10
+ };
5
11
  run(): Promise<void>;
6
12
  }
@@ -2,6 +2,7 @@
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 flags_1 = require("../../lib/flags");
5
6
  const requests_1 = require("../../lib/requests");
6
7
  const displays_1 = require("../../utils/displays");
7
8
  const utils_1 = require("../../utils/utils");
@@ -10,30 +11,72 @@ class RequestCreate extends core_1.Command {
10
11
  await (0, apollo_1.initClient)(this, true);
11
12
  const client = await (0, apollo_1.getClient)(this, true);
12
13
  (0, utils_1.restrictToDev)(); //TODO: Remove after development is complete
13
- const metadata = (0, requests_1.createEmptyRequestMetadata)();
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, metadata.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)(metadata.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
  }
25
33
  // Step 4: Set Request Defaults
26
34
  await (0, requests_1.setRequestDefaults)(this, client, metadata);
27
35
  // Step 4: Prompt for request reason
28
- const { reason } = await (0, requests_1.promptForReason)(metadata);
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
+ }
29
44
  // Step 5: Prompt for expiration
30
- const { expiration } = await (0, requests_1.promptForExpiration)(metadata);
45
+ if (flags.duration) {
46
+ (0, requests_1.bypassDuration)(this, flags.duration, metadata);
47
+ }
48
+ else {
49
+ await (0, requests_1.promptForExpiration)(metadata);
50
+ }
31
51
  // Step 6: Display final summary of request
32
- (0, displays_1.displayFinalRequestSummary)(this, metadata.requestMap, reason, expiration.label);
33
- // Step 7: Prompt for final submition
34
- 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);
35
61
  }
36
62
  }
37
63
  RequestCreate.hidden = true;
38
- RequestCreate.description = "Opens an Opal access request";
64
+ RequestCreate.description = "Creates an Opal access request via an interactive form";
65
+ RequestCreate.flags = {
66
+ help: flags_1.SHARED_FLAGS.help,
67
+ assets: core_1.Flags.string({
68
+ char: "a",
69
+ multiple: true,
70
+ 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`.\
71
+ \n If not provided, an interactive selection flow will be available to select assets to request.",
72
+ }),
73
+ reason: core_1.Flags.string({
74
+ char: "r",
75
+ description: "The reason for the request, contained in quotes. If not provided, you will be prompted.",
76
+ }),
77
+ duration: core_1.Flags.integer({
78
+ char: "d",
79
+ description: "The duration of access for the request in minutes. If not provided, you will be prompted.",
80
+ }),
81
+ };
39
82
  exports.default = RequestCreate;
@@ -5,6 +5,8 @@ export default class GetRequest extends Command {
5
5
  static flags: {
6
6
  help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
7
7
  id: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
8
+ verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
8
9
  };
10
+ static examples: string[];
9
11
  run(): Promise<void>;
10
12
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
+ const chalk_1 = require("chalk");
4
5
  const graphql_1 = require("../../graphql");
5
6
  const apollo_1 = require("../../lib/apollo");
6
7
  const cmd_1 = require("../../lib/cmd");
@@ -17,6 +18,7 @@ const GET_REQUEST = (0, graphql_1.graphql)(`
17
18
  ... on RequestResult {
18
19
  request {
19
20
  id
21
+ createdAt
20
22
  status
21
23
  requester {
22
24
  displayName
@@ -75,10 +77,17 @@ class GetRequest extends core_1.Command {
75
77
  fetchPolicy: "network-only", // to avoid caching
76
78
  });
77
79
  switch (resp.data.request.__typename) {
78
- case "RequestResult":
79
- (0, displays_1.displayRequestDetails)(this, resp);
80
- this.log(`\n💡Click to see request details on web: ${configData[config_1.urlKey]}/requests/sent/${flags.id}`);
80
+ case "RequestResult": {
81
+ if (flags.verbose) {
82
+ (0, apollo_1.printResponse)(this, resp);
83
+ }
84
+ else {
85
+ (0, displays_1.displayRequestDetails)(this, resp);
86
+ }
87
+ const url = `${configData[config_1.urlKey]}/requests/sent/${flags.id}`;
88
+ this.log(`\n💡Link to request details: ${chalk_1.default.underline(url)}`);
81
89
  return;
90
+ }
82
91
  case "RequestNotFoundError":
83
92
  this.log(`🚫 Request with id ${flags.id} was not found`);
84
93
  return;
@@ -92,5 +101,14 @@ GetRequest.description = "Lists access requests";
92
101
  GetRequest.flags = {
93
102
  help: flags_1.SHARED_FLAGS.help,
94
103
  id: flags_1.SHARED_FLAGS.id,
104
+ verbose: core_1.Flags.boolean({
105
+ char: "v",
106
+ description: "Enable verbose output, prints full response in JSON format. Defaults to false.",
107
+ default: false,
108
+ }),
95
109
  };
110
+ GetRequest.examples = [
111
+ "opal request get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4",
112
+ "opal request get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4 --verbose",
113
+ ];
96
114
  exports.default = GetRequest;
@@ -2,10 +2,12 @@ import { Command } from "@oclif/core";
2
2
  export default class ListRequests extends Command {
3
3
  static hidden: boolean;
4
4
  static description: string;
5
+ static examples: string[];
5
6
  static flags: {
6
7
  help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
7
- id: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
8
- pageSize: import("@oclif/core/lib/interfaces").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
8
+ n: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
9
+ pending: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
10
+ verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
9
11
  };
10
12
  run(): Promise<void>;
11
13
  }
@@ -4,8 +4,8 @@ const core_1 = require("@oclif/core");
4
4
  const graphql_1 = require("../../graphql");
5
5
  const apollo_1 = require("../../lib/apollo");
6
6
  const cmd_1 = require("../../lib/cmd");
7
- const config_1 = require("../../lib/config");
8
7
  const flags_1 = require("../../lib/flags");
8
+ const displays_1 = require("../../utils/displays");
9
9
  const utils_1 = require("../../utils/utils");
10
10
  // Add date filters, search query,
11
11
  const GET_REQUESTS = (0, graphql_1.graphql)(`
@@ -21,7 +21,7 @@ const GET_REQUESTS = (0, graphql_1.graphql)(`
21
21
  ... on RequestsResult {
22
22
  requestType
23
23
  requests {
24
- createdAt
24
+ durationInMinutes
25
25
  id
26
26
  requester {
27
27
  displayName
@@ -35,12 +35,20 @@ const GET_REQUESTS = (0, graphql_1.graphql)(`
35
35
  displayName
36
36
  id
37
37
  }
38
+ accessLevel {
39
+ accessLevelName
40
+ accessLevelRemoteId
41
+ }
38
42
  }
39
43
  requestedGroups {
40
44
  group {
41
45
  name
42
46
  id
43
47
  }
48
+ accessLevel {
49
+ accessLevelName
50
+ accessLevelRemoteId
51
+ }
44
52
  }
45
53
  status
46
54
  }
@@ -53,19 +61,15 @@ class ListRequests extends core_1.Command {
53
61
  async run() {
54
62
  (0, utils_1.restrictToDev)(); //TODO: Remove after development is complete
55
63
  (0, cmd_1.setMostRecentCommand)(this);
56
- const configData = (0, config_1.getOrCreateConfigData)(this.config.configDir);
57
64
  const client = await (0, apollo_1.getClient)(this, true);
58
65
  let pageSize = 10;
59
- const showPendingOnly = false;
66
+ let showPendingOnly = false;
60
67
  const { flags } = await this.parse(ListRequests);
61
- if (flags.pageSize) {
62
- if (flags.pageSize < 1) {
63
- this.error("pageSize must be greater than 0");
64
- }
65
- if (flags.pageSize > 100) {
66
- this.error("pageSize must be less than 100");
67
- }
68
- pageSize = flags.pageSize;
68
+ if (flags.n) {
69
+ pageSize = flags.n;
70
+ }
71
+ if (flags.showPendingOnly) {
72
+ showPendingOnly = flags.showPendingOnly;
69
73
  }
70
74
  const resp = await client.query({
71
75
  query: GET_REQUESTS,
@@ -76,20 +80,42 @@ class ListRequests extends core_1.Command {
76
80
  fetchPolicy: "network-only", // to avoid caching
77
81
  });
78
82
  //TODO: Make this pretty
79
- (0, apollo_1.printResponse)(this, resp);
83
+ if (flags.verbose) {
84
+ (0, apollo_1.printResponse)(this, resp);
85
+ }
86
+ else {
87
+ (0, displays_1.displayRequestListTable)(this, resp);
88
+ }
80
89
  }
81
90
  }
82
91
  ListRequests.hidden = true;
83
- ListRequests.description = "Lists your recent outgoing access requests.\
84
- \n--pageSize flag sets number of requests to be returned. Defaults to 10 requests.\
85
- \n--showPendingOnly flag will show only pending requests. Defaults to false.";
92
+ ListRequests.description = "Lists your n recent outgoing access requests";
93
+ ListRequests.examples = [
94
+ "opal request list --n 5",
95
+ "opal request list --n 5 --pending",
96
+ "opal request list --n 5 --verbose",
97
+ "opal request list --n 5 --pending --verbose",
98
+ ];
86
99
  // static aliases = ["request:ls"]; // uncomment when ready for release
87
100
  ListRequests.flags = {
88
101
  help: flags_1.SHARED_FLAGS.help,
89
- id: flags_1.SHARED_FLAGS.id,
90
- pageSize: core_1.Flags.integer({
102
+ n: core_1.Flags.integer({
103
+ char: "n",
91
104
  multiple: false,
92
- description: "Sets number of requests to be returned. Defaults to 10 requests.",
105
+ description: "Defines number of requests to be returned. 1 <= n <= 100.",
106
+ default: 10,
107
+ min: 1,
108
+ max: 100,
109
+ }),
110
+ pending: core_1.Flags.boolean({
111
+ char: "p",
112
+ description: "Show only pending requests. Defaults to false.",
113
+ default: false,
114
+ }),
115
+ verbose: core_1.Flags.boolean({
116
+ char: "v",
117
+ description: "Enable verbose output, prints full response in JSON format. Defaults to false.",
118
+ default: false,
93
119
  }),
94
120
  };
95
121
  exports.default = ListRequests;
@@ -0,0 +1,8 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class WhoAmI extends Command {
3
+ static description: string;
4
+ static flags: {
5
+ help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
6
+ };
7
+ run(): Promise<void>;
8
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const config_1 = require("../lib/config");
5
+ const credentials_1 = require("../lib/credentials");
6
+ const flags_1 = require("../lib/flags");
7
+ class WhoAmI extends core_1.Command {
8
+ async run() {
9
+ const opalCreds = await (0, credentials_1.getOpalCredentials)(this, false);
10
+ const organizationName = opalCreds === null || opalCreds === void 0 ? void 0 : opalCreds.organizationName;
11
+ const email = opalCreds === null || opalCreds === void 0 ? void 0 : opalCreds.email;
12
+ const configData = (0, config_1.getOrCreateConfigData)(this.config.configDir);
13
+ const url = configData[config_1.urlKey];
14
+ if (email) {
15
+ this.log(`User: ${email}`);
16
+ }
17
+ if (organizationName) {
18
+ if (organizationName === "unset-org-id") {
19
+ this.log("Authenticated with Opal API Token.");
20
+ }
21
+ else {
22
+ this.log(`Organization: ${organizationName}`);
23
+ }
24
+ }
25
+ if (url) {
26
+ this.log(`Server: ${url}`);
27
+ }
28
+ }
29
+ }
30
+ WhoAmI.description = "Describes current url set, organization name, and logged in user if applicabled.";
31
+ WhoAmI.flags = {
32
+ help: flags_1.SHARED_FLAGS.help,
33
+ };
34
+ exports.default = WhoAmI;