opal-security 3.2.4 → 4.0.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 (149) hide show
  1. package/README.md +46 -61
  2. package/bin/dev +5 -5
  3. package/bin/run +2 -4
  4. package/build/commands/aws/identity.js +16 -0
  5. package/build/commands/clear-auth-config.d.ts +6 -0
  6. package/build/commands/clear-auth-config.js +22 -0
  7. package/{lib → build}/commands/groups/get.js +14 -16
  8. package/{lib → build}/commands/iam-roles/start.js +28 -30
  9. package/build/commands/kube-roles/start.js +71 -0
  10. package/{lib → build}/commands/login.d.ts +1 -0
  11. package/build/commands/login.js +379 -0
  12. package/build/commands/logout.js +22 -0
  13. package/{lib → build}/commands/postgres-instances/start.js +25 -27
  14. package/{lib → build}/commands/request/create.js +34 -36
  15. package/{lib → build}/commands/request/get.js +22 -24
  16. package/{lib → build}/commands/request/list.js +17 -19
  17. package/{lib → build}/commands/resources/get.js +15 -18
  18. package/build/commands/set-auth-config.d.ts +11 -0
  19. package/build/commands/set-auth-config.js +59 -0
  20. package/build/commands/set-custom-header.js +35 -0
  21. package/{lib → build}/commands/set-token.js +15 -17
  22. package/{lib → build}/commands/set-url.js +26 -28
  23. package/{lib → build}/commands/ssh/copyFrom.js +22 -24
  24. package/{lib → build}/commands/ssh/copyTo.js +22 -24
  25. package/{lib → build}/commands/ssh/start.js +30 -33
  26. package/build/commands/whoami.js +27 -0
  27. package/{lib → build}/graphql/fragment-masking.d.ts +1 -1
  28. package/{lib → build}/graphql/fragment-masking.js +3 -8
  29. package/{lib → build}/graphql/gql.d.ts +1 -1
  30. package/{lib → build}/graphql/gql.js +2 -5
  31. package/{lib → build}/graphql/graphql.js +256 -261
  32. package/build/graphql/index.d.ts +2 -0
  33. package/build/graphql/index.js +2 -0
  34. package/{lib → build}/handler.d.ts +1 -1
  35. package/build/handler.js +36 -0
  36. package/build/index.js +1 -0
  37. package/{lib → build}/labels.d.ts +1 -1
  38. package/build/labels.js +37 -0
  39. package/{lib → build}/lib/apollo.d.ts +2 -2
  40. package/{lib → build}/lib/apollo.js +62 -69
  41. package/build/lib/auth-success-template.d.ts +3 -0
  42. package/build/lib/auth-success-template.js +149 -0
  43. package/{lib → build}/lib/aws.js +2 -7
  44. package/{lib → build}/lib/cmd.d.ts +4 -4
  45. package/{lib → build}/lib/cmd.js +16 -20
  46. package/build/lib/config.js +46 -0
  47. package/{lib → build}/lib/credentials/index.d.ts +3 -2
  48. package/build/lib/credentials/index.js +85 -0
  49. package/{lib → build}/lib/credentials/keychain.js +4 -10
  50. package/{lib → build}/lib/credentials/localEncryption.js +12 -17
  51. package/{lib → build}/lib/flags.js +7 -10
  52. package/build/lib/local-auth-server.d.ts +5 -0
  53. package/build/lib/local-auth-server.js +69 -0
  54. package/build/lib/request/api/index.d.ts +6 -0
  55. package/build/lib/request/api/index.js +8 -0
  56. package/{lib → build}/lib/request/api/mutations/create-request.d.ts +2 -2
  57. package/{lib → build}/lib/request/api/mutations/create-request.js +3 -6
  58. package/{lib → build}/lib/request/api/queries/apps.d.ts +1 -1
  59. package/{lib → build}/lib/request/api/queries/apps.js +3 -6
  60. package/{lib → build}/lib/request/api/queries/assets.d.ts +2 -2
  61. package/{lib → build}/lib/request/api/queries/assets.js +7 -11
  62. package/{lib → build}/lib/request/api/queries/request-defaults.d.ts +2 -2
  63. package/{lib → build}/lib/request/api/queries/request-defaults.js +3 -6
  64. package/{lib → build}/lib/request/api/queries/requests.d.ts +3 -3
  65. package/{lib → build}/lib/request/api/queries/requests.js +10 -16
  66. package/{lib → build}/lib/request/api/queries/roles.d.ts +1 -1
  67. package/{lib → build}/lib/request/api/queries/roles.js +14 -18
  68. package/{lib → build}/lib/request/displays.d.ts +2 -2
  69. package/{lib → build}/lib/request/displays.js +27 -37
  70. package/{lib → build}/lib/request/prompts/apps-prompt.d.ts +1 -1
  71. package/build/lib/request/prompts/apps-prompt.js +33 -0
  72. package/{lib → build}/lib/request/prompts/asset-prompt.d.ts +1 -1
  73. package/build/lib/request/prompts/asset-prompt.js +61 -0
  74. package/{lib → build}/lib/request/prompts/duration-prompt.d.ts +1 -1
  75. package/{lib → build}/lib/request/prompts/duration-prompt.js +6 -10
  76. package/build/lib/request/prompts/index.d.ts +7 -0
  77. package/build/lib/request/prompts/index.js +8 -0
  78. package/{lib → build}/lib/request/prompts/reason-prompt.d.ts +1 -1
  79. package/{lib → build}/lib/request/prompts/reason-prompt.js +3 -6
  80. package/{lib → build}/lib/request/prompts/role-prompt.d.ts +1 -1
  81. package/{lib → build}/lib/request/prompts/role-prompt.js +9 -11
  82. package/{lib → build}/lib/request/prompts/validate-prompt.d.ts +1 -1
  83. package/{lib → build}/lib/request/prompts/validate-prompt.js +9 -13
  84. package/{lib → build}/lib/request/request-utils.d.ts +2 -2
  85. package/{lib → build}/lib/request/request-utils.js +50 -62
  86. package/{lib → build}/lib/request/types.d.ts +1 -1
  87. package/build/lib/request/types.js +12 -0
  88. package/{lib → build}/lib/resources.d.ts +1 -1
  89. package/{lib → build}/lib/resources.js +18 -23
  90. package/{lib → build}/lib/sessions.d.ts +1 -1
  91. package/{lib → build}/lib/sessions.js +57 -32
  92. package/{lib → build}/lib/ssh.d.ts +1 -1
  93. package/{lib → build}/lib/ssh.js +6 -11
  94. package/{lib → build}/lib/util.js +7 -14
  95. package/{lib → build}/types.js +98 -101
  96. package/oclif.manifest.json +115 -136
  97. package/package.json +24 -14
  98. package/lib/commands/aws/identity.js +0 -18
  99. package/lib/commands/clear-auth-provider.d.ts +0 -9
  100. package/lib/commands/clear-auth-provider.js +0 -28
  101. package/lib/commands/curl-example.d.ts +0 -8
  102. package/lib/commands/curl-example.js +0 -34
  103. package/lib/commands/kube-roles/start.js +0 -73
  104. package/lib/commands/login.js +0 -286
  105. package/lib/commands/logout.js +0 -23
  106. package/lib/commands/set-auth-provider.d.ts +0 -11
  107. package/lib/commands/set-auth-provider.js +0 -44
  108. package/lib/commands/set-custom-header.js +0 -37
  109. package/lib/commands/whoami.js +0 -34
  110. package/lib/graphql/index.d.ts +0 -2
  111. package/lib/graphql/index.js +0 -5
  112. package/lib/handler.js +0 -41
  113. package/lib/index.js +0 -5
  114. package/lib/labels.js +0 -40
  115. package/lib/lib/config.js +0 -54
  116. package/lib/lib/credentials/index.js +0 -67
  117. package/lib/lib/request/api/index.d.ts +0 -6
  118. package/lib/lib/request/api/index.js +0 -20
  119. package/lib/lib/request/prompts/apps-prompt.js +0 -35
  120. package/lib/lib/request/prompts/asset-prompt.js +0 -65
  121. package/lib/lib/request/prompts/index.d.ts +0 -7
  122. package/lib/lib/request/prompts/index.js +0 -19
  123. package/lib/lib/request/types.js +0 -15
  124. /package/{lib → build}/commands/aws/identity.d.ts +0 -0
  125. /package/{lib → build}/commands/groups/get.d.ts +0 -0
  126. /package/{lib → build}/commands/iam-roles/start.d.ts +0 -0
  127. /package/{lib → build}/commands/kube-roles/start.d.ts +0 -0
  128. /package/{lib → build}/commands/logout.d.ts +0 -0
  129. /package/{lib → build}/commands/postgres-instances/start.d.ts +0 -0
  130. /package/{lib → build}/commands/request/create.d.ts +0 -0
  131. /package/{lib → build}/commands/request/get.d.ts +0 -0
  132. /package/{lib → build}/commands/request/list.d.ts +0 -0
  133. /package/{lib → build}/commands/resources/get.d.ts +0 -0
  134. /package/{lib → build}/commands/set-custom-header.d.ts +0 -0
  135. /package/{lib → build}/commands/set-token.d.ts +0 -0
  136. /package/{lib → build}/commands/set-url.d.ts +0 -0
  137. /package/{lib → build}/commands/ssh/copyFrom.d.ts +0 -0
  138. /package/{lib → build}/commands/ssh/copyTo.d.ts +0 -0
  139. /package/{lib → build}/commands/ssh/start.d.ts +0 -0
  140. /package/{lib → build}/commands/whoami.d.ts +0 -0
  141. /package/{lib → build}/graphql/graphql.d.ts +0 -0
  142. /package/{lib → build}/index.d.ts +0 -0
  143. /package/{lib → build}/lib/aws.d.ts +0 -0
  144. /package/{lib → build}/lib/config.d.ts +0 -0
  145. /package/{lib → build}/lib/credentials/keychain.d.ts +0 -0
  146. /package/{lib → build}/lib/credentials/localEncryption.d.ts +0 -0
  147. /package/{lib → build}/lib/flags.d.ts +0 -0
  148. /package/{lib → build}/lib/util.d.ts +0 -0
  149. /package/{lib → build}/types.d.ts +0 -0
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.4 darwin-arm64 node-v18.20.4
25
+ opal-security/4.0.3 darwin-arm64 node-v24.5.0
26
26
  $ opal --help [COMMAND]
27
27
  USAGE
28
28
  $ opal COMMAND
@@ -35,8 +35,7 @@ USAGE
35
35
  <!-- commands -->
36
36
  * [`opal autocomplete [SHELL]`](#opal-autocomplete-shell)
37
37
  * [`opal aws identity`](#opal-aws-identity)
38
- * [`opal clear-auth-provider`](#opal-clear-auth-provider)
39
- * [`opal curl-example`](#opal-curl-example)
38
+ * [`opal clear-auth-config`](#opal-clear-auth-config)
40
39
  * [`opal groups get`](#opal-groups-get)
41
40
  * [`opal help [COMMANDS]`](#opal-help-commands)
42
41
  * [`opal iam-roles start`](#opal-iam-roles-start)
@@ -49,7 +48,7 @@ USAGE
49
48
  * [`opal request list`](#opal-request-list)
50
49
  * [`opal request ls`](#opal-request-ls)
51
50
  * [`opal resources get`](#opal-resources-get)
52
- * [`opal set-auth-provider`](#opal-set-auth-provider)
51
+ * [`opal set-auth-config`](#opal-set-auth-config)
53
52
  * [`opal set-custom-header`](#opal-set-custom-header)
54
53
  * [`opal set-token`](#opal-set-token)
55
54
  * [`opal set-url [URL]`](#opal-set-url-url)
@@ -106,44 +105,24 @@ EXAMPLES
106
105
  $ opal aws:identity
107
106
  ```
108
107
 
109
- _See code: [src/commands/aws/identity.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.4/src/commands/aws/identity.ts)_
108
+ _See code: [src/commands/aws/identity.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.3/src/commands/aws/identity.ts)_
110
109
 
111
- ## `opal clear-auth-provider`
110
+ ## `opal clear-auth-config`
112
111
 
113
- Clears the custom Issuer URL and Client ID set by set-airgap-auth, returning to the default.
112
+ Clear all authentication configuration values
114
113
 
115
114
  ```
116
115
  USAGE
117
- $ opal clear-auth-provider [-h]
118
-
119
- FLAGS
120
- -h, --help Show CLI help.
116
+ $ opal clear-auth-config
121
117
 
122
118
  DESCRIPTION
123
- Clears the custom Issuer URL and Client ID set by set-airgap-auth, returning to the default.
119
+ Clear all authentication configuration values
124
120
 
125
121
  EXAMPLES
126
- $ opal clear-auth-provider
127
- ```
128
-
129
- _See code: [src/commands/clear-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.4/src/commands/clear-auth-provider.ts)_
130
-
131
- ## `opal curl-example`
132
-
133
- Prints out an example cURL command containing the parameters the CLI uses to query the Opal server.
134
-
135
- ```
136
- USAGE
137
- $ opal curl-example [-h]
138
-
139
- FLAGS
140
- -h, --help Show CLI help.
141
-
142
- DESCRIPTION
143
- Prints out an example cURL command containing the parameters the CLI uses to query the Opal server.
122
+ $ opal clear-auth-config
144
123
  ```
145
124
 
146
- _See code: [src/commands/curl-example.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.4/src/commands/curl-example.ts)_
125
+ _See code: [src/commands/clear-auth-config.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.3/src/commands/clear-auth-config.ts)_
147
126
 
148
127
  ## `opal groups get`
149
128
 
@@ -164,7 +143,7 @@ EXAMPLES
164
143
  $ opal groups:get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4
165
144
  ```
166
145
 
167
- _See code: [src/commands/groups/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.4/src/commands/groups/get.ts)_
146
+ _See code: [src/commands/groups/get.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.3/src/commands/groups/get.ts)_
168
147
 
169
148
  ## `opal help [COMMANDS]`
170
149
 
@@ -214,7 +193,7 @@ EXAMPLES
214
193
  $ opal iam-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --profileName "custom-profile"
215
194
  ```
216
195
 
217
- _See code: [src/commands/iam-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.4/src/commands/iam-roles/start.ts)_
196
+ _See code: [src/commands/iam-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.3/src/commands/iam-roles/start.ts)_
218
197
 
219
198
  ## `opal kube-roles start`
220
199
 
@@ -245,7 +224,7 @@ EXAMPLES
245
224
  $ opal kube-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --accessLevelRemoteId "arn:aws:iam::712234975475:role/acme-eks-cluster-admin-role"
246
225
  ```
247
226
 
248
- _See code: [src/commands/kube-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.4/src/commands/kube-roles/start.ts)_
227
+ _See code: [src/commands/kube-roles/start.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.3/src/commands/kube-roles/start.ts)_
249
228
 
250
229
  ## `opal login`
251
230
 
@@ -253,9 +232,11 @@ Authenticates you with the Opal server.
253
232
 
254
233
  ```
255
234
  USAGE
256
- $ opal login [-h] [--email <value>]
235
+ $ opal login [-h] [--email <value>] [-d]
257
236
 
258
237
  FLAGS
238
+ -d, --device-code Enables the Device Code flow instead of the Authorization Code flow when logging in.
239
+ Use the Device Code flow if your environment can't open a browser or listen on a local port.
259
240
  -h, --help Show CLI help.
260
241
  --email=<value> Email address to login with.
261
242
 
@@ -266,7 +247,7 @@ EXAMPLES
266
247
  $ opal login
267
248
  ```
268
249
 
269
- _See code: [src/commands/login.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.4/src/commands/login.ts)_
250
+ _See code: [src/commands/login.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.3/src/commands/login.ts)_
270
251
 
271
252
  ## `opal logout`
272
253
 
@@ -286,7 +267,7 @@ EXAMPLES
286
267
  $ opal logout
287
268
  ```
288
269
 
289
- _See code: [src/commands/logout.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.4/src/commands/logout.ts)_
270
+ _See code: [src/commands/logout.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.3/src/commands/logout.ts)_
290
271
 
291
272
  ## `opal postgres-instances start`
292
273
 
@@ -324,7 +305,7 @@ EXAMPLES
324
305
  $ opal postgres-instances:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --accessLevelRemoteId fullaccess --action view
325
306
  ```
326
307
 
327
- _See code: [src/commands/postgres-instances/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.4/src/commands/postgres-instances/start.ts)_
308
+ _See code: [src/commands/postgres-instances/start.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.3/src/commands/postgres-instances/start.ts)_
328
309
 
329
310
  ## `opal request create`
330
311
 
@@ -350,7 +331,7 @@ DESCRIPTION
350
331
  Creates an Opal access request via an interactive form
351
332
  ```
352
333
 
353
- _See code: [src/commands/request/create.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.4/src/commands/request/create.ts)_
334
+ _See code: [src/commands/request/create.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.3/src/commands/request/create.ts)_
354
335
 
355
336
  ## `opal request get`
356
337
 
@@ -374,7 +355,7 @@ EXAMPLES
374
355
  $ opal request get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4 --verbose
375
356
  ```
376
357
 
377
- _See code: [src/commands/request/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.4/src/commands/request/get.ts)_
358
+ _See code: [src/commands/request/get.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.3/src/commands/request/get.ts)_
378
359
 
379
360
  ## `opal request list`
380
361
 
@@ -406,7 +387,7 @@ EXAMPLES
406
387
  $ opal request list --n 5 --pending --verbose
407
388
  ```
408
389
 
409
- _See code: [src/commands/request/list.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.4/src/commands/request/list.ts)_
390
+ _See code: [src/commands/request/list.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.3/src/commands/request/list.ts)_
410
391
 
411
392
  ## `opal request ls`
412
393
 
@@ -457,33 +438,37 @@ EXAMPLES
457
438
  $ opal resources:get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4
458
439
  ```
459
440
 
460
- _See code: [src/commands/resources/get.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.4/src/commands/resources/get.ts)_
441
+ _See code: [src/commands/resources/get.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.3/src/commands/resources/get.ts)_
461
442
 
462
- ## `opal set-auth-provider`
443
+ ## `opal set-auth-config`
463
444
 
464
- Sets the Issuer URL and Client ID of the Auth Provider that the CLI will authenticate with.
445
+ Set authentication configuration values
465
446
 
466
447
  ```
467
448
  USAGE
468
- $ opal set-auth-provider --clientID <value> --issuerUrl <value> [-h]
449
+ $ opal set-auth-config [--organizationID <value>] [--clientID <value>] [--issuerUrl <value>]
469
450
 
470
451
  FLAGS
471
- -h, --help Show CLI help.
472
- --clientID=<value> (required) Client ID of your Auth Provider
473
- --issuerUrl=<value> (required) Issuer URL of your Auth Provider
452
+ --clientID=<value> OIDC client ID for authentication
453
+ --issuerUrl=<value> OIDC issuer URL for authentication
454
+ --organizationID=<value> Organization ID for authentication
474
455
 
475
456
  DESCRIPTION
476
- Sets the Issuer URL and Client ID of the Auth Provider that the CLI will authenticate with.
477
- Only use this if you are running a self-hosted, air-gapped instance of Opal that uses a custom Auth Provider.
457
+ Set authentication configuration values
478
458
 
479
- Note - you will need an OIDC provider that supports the device_code grant.
459
+ EXAMPLES
460
+ $ opal set-auth-config --clientID=abc123
480
461
 
462
+ $ opal set-auth-config --organizationID=org-456
481
463
 
482
- EXAMPLES
483
- $ opal set-auth-provider --clientID 1234asdf --issuerUrl https://auth.example.com
464
+ $ opal set-auth-config --issuerUrl=https://auth.example.com
465
+
466
+ $ opal set-auth-config --clientID=abc123 --issuerUrl=https://auth.example.com
467
+
468
+ $ opal set-auth-config --organizationID=org-456 --clientID=abc123 --issuerUrl=https://auth.example.com
484
469
  ```
485
470
 
486
- _See code: [src/commands/set-auth-provider.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.4/src/commands/set-auth-provider.ts)_
471
+ _See code: [src/commands/set-auth-config.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.3/src/commands/set-auth-config.ts)_
487
472
 
488
473
  ## `opal set-custom-header`
489
474
 
@@ -504,7 +489,7 @@ EXAMPLES
504
489
  $ opal set-custom-header --header 'cf-access-token: $TOKEN'
505
490
  ```
506
491
 
507
- _See code: [src/commands/set-custom-header.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.4/src/commands/set-custom-header.ts)_
492
+ _See code: [src/commands/set-custom-header.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.3/src/commands/set-custom-header.ts)_
508
493
 
509
494
  ## `opal set-token`
510
495
 
@@ -524,7 +509,7 @@ EXAMPLES
524
509
  $ opal set-token
525
510
  ```
526
511
 
527
- _See code: [src/commands/set-token.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.4/src/commands/set-token.ts)_
512
+ _See code: [src/commands/set-token.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.3/src/commands/set-token.ts)_
528
513
 
529
514
  ## `opal set-url [URL]`
530
515
 
@@ -548,7 +533,7 @@ EXAMPLES
548
533
  $ opal set-url
549
534
  ```
550
535
 
551
- _See code: [src/commands/set-url.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.4/src/commands/set-url.ts)_
536
+ _See code: [src/commands/set-url.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.3/src/commands/set-url.ts)_
552
537
 
553
538
  ## `opal ssh copyFrom`
554
539
 
@@ -579,7 +564,7 @@ EXAMPLES
579
564
  $ opal ssh:copyFrom --src instance/dir --dest my/dir --id 51f7176b-0464-4a6f-8369-e951e187b398
580
565
  ```
581
566
 
582
- _See code: [src/commands/ssh/copyFrom.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.4/src/commands/ssh/copyFrom.ts)_
567
+ _See code: [src/commands/ssh/copyFrom.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.3/src/commands/ssh/copyFrom.ts)_
583
568
 
584
569
  ## `opal ssh copyTo`
585
570
 
@@ -610,7 +595,7 @@ EXAMPLES
610
595
  $ opal ssh:copyTo --src my/dir --dest instance/dir --id 51f7176b-0464-4a6f-8369-e951e187b398
611
596
  ```
612
597
 
613
- _See code: [src/commands/ssh/copyTo.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.4/src/commands/ssh/copyTo.ts)_
598
+ _See code: [src/commands/ssh/copyTo.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.3/src/commands/ssh/copyTo.ts)_
614
599
 
615
600
  ## `opal ssh start`
616
601
 
@@ -637,7 +622,7 @@ EXAMPLES
637
622
  $ opal ssh:start --id 51f7176b-0464-4a6f-8369-e951e187b398
638
623
  ```
639
624
 
640
- _See code: [src/commands/ssh/start.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.4/src/commands/ssh/start.ts)_
625
+ _See code: [src/commands/ssh/start.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.3/src/commands/ssh/start.ts)_
641
626
 
642
627
  ## `opal version`
643
628
 
@@ -674,5 +659,5 @@ DESCRIPTION
674
659
  Describes current url set, organization name, and logged in user if applicable.
675
660
  ```
676
661
 
677
- _See code: [src/commands/whoami.ts](https://github.com/opalsecurity/opal-cli/blob/v3.2.4/src/commands/whoami.ts)_
662
+ _See code: [src/commands/whoami.ts](https://github.com/opalsecurity/opal-cli/blob/v4.0.3/src/commands/whoami.ts)_
678
663
  <!-- commandsstop -->
package/bin/dev CHANGED
@@ -1,6 +1,6 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env -S npx tsx
2
+
3
+ import {execute} from '@oclif/core'
4
+
5
+ await execute({development: true, dir: import.meta.url})
2
6
 
3
- require("@oclif/core")
4
- .execute({ development: true, dir: __dirname })
5
- .then(require("@oclif/core/flush"))
6
- .catch(require("@oclif/core/handle"));
package/bin/run CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import {execute} from "@oclif/core";
2
3
 
3
4
  const engineMajorVersion = Number.parseInt(process.version.slice(1).split('.'));
4
5
  if (engineMajorVersion < 18) {
@@ -6,7 +7,4 @@ if (engineMajorVersion < 18) {
6
7
  process.exit(1)
7
8
  }
8
9
 
9
- require("@oclif/core")
10
- .execute({ development: false, dir: __dirname })
11
- .then(require("@oclif/core/flush"))
12
- .catch(require("@oclif/core/handle"));
10
+ await execute({development: false, dir: import.meta.url})
@@ -0,0 +1,16 @@
1
+ import { Command } from "@oclif/core";
2
+ import { runCommandExec, setMostRecentCommand } from "../../lib/cmd.js";
3
+ import { SHARED_FLAGS } from "../../lib/flags.js";
4
+ class Identity extends Command {
5
+ async run() {
6
+ setMostRecentCommand(this);
7
+ const currentCallerIdentityCmd = "aws sts get-caller-identity --profile opal";
8
+ runCommandExec(currentCallerIdentityCmd, 'This is the current caller identity for the "opal" AWS profile.', 'Failed to get the current caller identity for the "opal" AWS profile.');
9
+ }
10
+ }
11
+ Identity.description = 'Gets the current caller identity for the "opal" AWS profile.';
12
+ Identity.examples = ["opal aws:identity"];
13
+ Identity.flags = {
14
+ help: SHARED_FLAGS.help,
15
+ };
16
+ export default Identity;
@@ -0,0 +1,6 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class ClearConfig extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ run(): Promise<void>;
6
+ }
@@ -0,0 +1,22 @@
1
+ import { Command } from "@oclif/core";
2
+ import { getOrCreateConfigData, writeConfigData } from "../lib/config.js";
3
+ import { removeOpalCredentials } from "../lib/credentials/index.js";
4
+ class ClearConfig extends Command {
5
+ async run() {
6
+ try {
7
+ const configData = getOrCreateConfigData(this.config.configDir);
8
+ await removeOpalCredentials(this);
9
+ // biome-ignore lint/performance/noDelete: view performance of this and modify if needed
10
+ delete configData.issuerURL;
11
+ configData.creds = {};
12
+ writeConfigData(this.config.configDir, configData);
13
+ this.log("Authentication configuration cleared");
14
+ }
15
+ catch (error) {
16
+ this.error(String(error));
17
+ }
18
+ }
19
+ }
20
+ ClearConfig.description = "Clear all authentication configuration values";
21
+ ClearConfig.examples = ["$ opal clear-auth-config"];
22
+ export default ClearConfig;
@@ -1,11 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const core_1 = require("@oclif/core");
4
- const graphql_1 = require("../../graphql");
5
- const apollo_1 = require("../../lib/apollo");
6
- const cmd_1 = require("../../lib/cmd");
7
- const flags_1 = require("../../lib/flags");
8
- const GET_GROUP_QUERY = (0, graphql_1.graphql)(`
1
+ import { Command } from "@oclif/core";
2
+ import { graphql } from "../../graphql/index.js";
3
+ import { getClient, handleError, printResponse } from "../../lib/apollo.js";
4
+ import { setMostRecentCommand } from "../../lib/cmd.js";
5
+ import { SHARED_FLAGS } from "../../lib/flags.js";
6
+ const GET_GROUP_QUERY = graphql(`
9
7
  query GetGroup($id: GroupId!) {
10
8
  group(input: { id: $id }) {
11
9
  __typename
@@ -43,9 +41,9 @@ query GetGroup($id: GroupId!) {
43
41
  }
44
42
  }
45
43
  }`);
46
- class GetGroup extends core_1.Command {
44
+ class GetGroup extends Command {
47
45
  async run() {
48
- (0, cmd_1.setMostRecentCommand)(this);
46
+ setMostRecentCommand(this);
49
47
  const { flags } = await this.parse(GetGroup);
50
48
  if (!flags.id) {
51
49
  this.log("Error: Please provide a group ID using the --id flag.");
@@ -53,17 +51,17 @@ class GetGroup extends core_1.Command {
53
51
  return;
54
52
  }
55
53
  try {
56
- const client = await (0, apollo_1.getClient)(this);
54
+ const client = await getClient(this);
57
55
  const resp = await client.query({
58
56
  query: GET_GROUP_QUERY,
59
57
  variables: {
60
58
  id: flags.id,
61
59
  },
62
60
  });
63
- (0, apollo_1.printResponse)(this, resp);
61
+ printResponse(this, resp);
64
62
  }
65
63
  catch (error) {
66
- return (0, apollo_1.handleError)(this, error);
64
+ return handleError(this, error);
67
65
  }
68
66
  }
69
67
  }
@@ -72,7 +70,7 @@ GetGroup.examples = [
72
70
  "opal groups:get --id 54052a3e-5375-4392-aeaf-0c6c44c131d4",
73
71
  ];
74
72
  GetGroup.flags = {
75
- help: flags_1.SHARED_FLAGS.help,
76
- id: flags_1.SHARED_FLAGS.id,
73
+ help: SHARED_FLAGS.help,
74
+ id: SHARED_FLAGS.id,
77
75
  };
78
- exports.default = GetGroup;
76
+ export default GetGroup;
@@ -1,14 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const core_1 = require("@oclif/core");
4
- const get_1 = require("../../commands/resources/get");
5
- const handler_1 = require("../../handler");
6
- const apollo_1 = require("../../lib/apollo");
7
- const aws_1 = require("../../lib/aws");
8
- const cmd_1 = require("../../lib/cmd");
9
- const flags_1 = require("../../lib/flags");
10
- const resources_1 = require("../../lib/resources");
11
- const sessions_1 = require("../../lib/sessions");
1
+ import { Command, Flags } from "@oclif/core";
2
+ import { GetResourceDocument } from "../../commands/resources/get.js";
3
+ import { runQueryDeprecated } from "../../handler.js";
4
+ import { handleError } from "../../lib/apollo.js";
5
+ import { getAwsConfigUpdateCmd, getAwsEnvVarMessage } from "../../lib/aws.js";
6
+ import { runCommandExec, setMostRecentCommand } from "../../lib/cmd.js";
7
+ import { SHARED_FLAGS } from "../../lib/flags.js";
8
+ import { DEFAULT_ACCESS_LEVEL, promptUserForResource, } from "../../lib/resources.js";
9
+ import { getOrCreateSession, getSessionExpirationMessage, } from "../../lib/sessions.js";
12
10
  const IamSessionMetadataFragment = `
13
11
  ... on AwsIamFederatedRoleSession {
14
12
  awsAccessKeyId
@@ -17,18 +15,18 @@ const IamSessionMetadataFragment = `
17
15
  awsLoginUrl
18
16
  federatedArn
19
17
  }`;
20
- class StartIAMRoleSession extends core_1.Command {
18
+ class StartIAMRoleSession extends Command {
21
19
  async run() {
22
- (0, cmd_1.setMostRecentCommand)(this);
20
+ setMostRecentCommand(this);
23
21
  const { flags } = await this.parse(StartIAMRoleSession);
24
22
  if (flags.sessionId && flags.refresh) {
25
- return (0, apollo_1.handleError)(this, "Cannot use both --sessionId and --refresh");
23
+ return handleError(this, "Cannot use both --sessionId and --refresh");
26
24
  }
27
25
  let roleId = flags.id;
28
26
  let roleName = null;
29
27
  const sessionId = flags.sessionId;
30
28
  if (!roleId) {
31
- const selectedRole = await (0, resources_1.promptUserForResource)(this, "AWS_IAM_ROLE", "Select an IAM role to assume");
29
+ const selectedRole = await promptUserForResource(this, "AWS_IAM_ROLE", "Select an IAM role to assume");
32
30
  if (!selectedRole) {
33
31
  return;
34
32
  }
@@ -36,40 +34,40 @@ class StartIAMRoleSession extends core_1.Command {
36
34
  roleName = selectedRole.name;
37
35
  }
38
36
  else {
39
- const { resp, error } = await (0, handler_1.runQueryDeprecated)({
37
+ const { resp, error } = await runQueryDeprecated({
40
38
  command: this,
41
- query: get_1.GetResourceDocument,
39
+ query: GetResourceDocument,
42
40
  variables: {
43
41
  id: roleId,
44
42
  },
45
43
  });
46
44
  if (error) {
47
- return (0, apollo_1.handleError)(this, error, resp);
45
+ return handleError(this, error, resp);
48
46
  }
49
47
  if (!(resp === null || resp === void 0 ? void 0 : resp.data.resource.resource)) {
50
- return (0, apollo_1.handleError)(this, `Resource not found for ID: ${roleId}`);
48
+ return handleError(this, `Resource not found for ID: ${roleId}`);
51
49
  }
52
50
  roleName = (resp === null || resp === void 0 ? void 0 : resp.data.resource.resource.name) || "iam-role";
53
51
  }
54
52
  if (flags.profileName && flags.profileName !== "") {
55
53
  roleName = flags.profileName;
56
54
  }
57
- const session = await (0, sessions_1.getOrCreateSession)(this, roleId, resources_1.DEFAULT_ACCESS_LEVEL, sessionId, IamSessionMetadataFragment, flags.refresh);
55
+ const session = await getOrCreateSession(this, roleId, DEFAULT_ACCESS_LEVEL, sessionId, IamSessionMetadataFragment, flags.refresh);
58
56
  if (!session) {
59
57
  return;
60
58
  }
61
59
  const metadata = session.metadata;
62
60
  switch (metadata === null || metadata === void 0 ? void 0 : metadata.__typename) {
63
61
  case "AwsIamFederatedRoleSession": {
64
- const updateAwsConfigCommand = (0, aws_1.getAwsConfigUpdateCmd)(roleName, metadata.awsAccessKeyId, metadata.awsSecretAccessKey, metadata.awsSessionToken);
62
+ const updateAwsConfigCommand = getAwsConfigUpdateCmd(roleName, metadata.awsAccessKeyId, metadata.awsSecretAccessKey, metadata.awsSessionToken);
65
63
  const startSessionCmd = `${updateAwsConfigCommand}`;
66
64
  const roleText = roleName ? `"${roleName}" role` : "role";
67
- const expirationMessage = (0, sessions_1.getSessionExpirationMessage)(session);
68
- (0, cmd_1.runCommandExec)(startSessionCmd, `Now set to use ${roleText}. (session expires in ${expirationMessage})${(0, aws_1.getAwsEnvVarMessage)()}`, `Failed to use ${roleText}.`);
65
+ const expirationMessage = getSessionExpirationMessage(session);
66
+ runCommandExec(startSessionCmd, `Now set to use ${roleText}. (session expires in ${expirationMessage})${getAwsEnvVarMessage()}`, `Failed to use ${roleText}.`);
69
67
  break;
70
68
  }
71
69
  default:
72
- return (0, apollo_1.handleError)(this, undefined, session);
70
+ return handleError(this, undefined, session);
73
71
  }
74
72
  }
75
73
  }
@@ -80,13 +78,13 @@ StartIAMRoleSession.examples = [
80
78
  'opal iam-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --profileName "custom-profile"',
81
79
  ];
82
80
  StartIAMRoleSession.flags = {
83
- help: flags_1.SHARED_FLAGS.help,
84
- id: flags_1.SHARED_FLAGS.id,
85
- sessionId: flags_1.SHARED_FLAGS.sessionId,
86
- refresh: flags_1.SHARED_FLAGS.refresh,
87
- profileName: core_1.Flags.string({
81
+ help: SHARED_FLAGS.help,
82
+ id: SHARED_FLAGS.id,
83
+ sessionId: SHARED_FLAGS.sessionId,
84
+ refresh: SHARED_FLAGS.refresh,
85
+ profileName: Flags.string({
88
86
  multiple: false,
89
87
  description: "Uses a custom AWS profile name for the IAM role. Default value is the role's name.",
90
88
  }),
91
89
  };
92
- exports.default = StartIAMRoleSession;
90
+ export default StartIAMRoleSession;
@@ -0,0 +1,71 @@
1
+ import { Command } from "@oclif/core";
2
+ import { handleError } from "../../lib/apollo.js";
3
+ import { getAwsConfigUpdateCmd, getAwsEnvVarMessage } from "../../lib/aws.js";
4
+ import { runCommandExec, setMostRecentCommand } from "../../lib/cmd.js";
5
+ import { SHARED_FLAGS } from "../../lib/flags.js";
6
+ import { promptUserForAccessLevels, promptUserForResource, } from "../../lib/resources.js";
7
+ import { getOrCreateSession, getSessionExpirationMessage, } from "../../lib/sessions.js";
8
+ const EksSessionMetadataFragment = `
9
+ ... on AwsIamFederatedEksSession {
10
+ awsAccessKeyId
11
+ awsSecretAccessKey
12
+ awsSessionToken
13
+ clusterName
14
+ clusterRegion
15
+ }`;
16
+ class StartKubeIAMRoleSession extends Command {
17
+ async run() {
18
+ setMostRecentCommand(this);
19
+ const { flags } = await this.parse(StartKubeIAMRoleSession);
20
+ if (flags.sessionId && flags.refresh) {
21
+ return handleError(this, "Cannot use both --sessionId and --refresh");
22
+ }
23
+ let clusterId = flags.id;
24
+ const sessionId = flags.sessionId;
25
+ if (!clusterId) {
26
+ const selectedCluster = await promptUserForResource(this, "AWS_EKS_CLUSTER", "Select an EKS Kubernetes cluster to connect to");
27
+ if (!selectedCluster) {
28
+ return;
29
+ }
30
+ clusterId = selectedCluster.id;
31
+ }
32
+ // Fetch all access levels for resource
33
+ const accessLevel = await promptUserForAccessLevels(this, clusterId, "Kubernetes cluster", flags.accessLevelRemoteId);
34
+ if (!accessLevel) {
35
+ return;
36
+ }
37
+ const session = await getOrCreateSession(this, clusterId, accessLevel, sessionId, EksSessionMetadataFragment, flags.refresh);
38
+ if (!session) {
39
+ return;
40
+ }
41
+ const metadata = session.metadata;
42
+ switch (metadata === null || metadata === void 0 ? void 0 : metadata.__typename) {
43
+ case "AwsIamFederatedEksSession": {
44
+ const roleName = accessLevel.accessLevelName;
45
+ const updateAwsConfigCommand = getAwsConfigUpdateCmd(roleName, metadata.awsAccessKeyId, metadata.awsSecretAccessKey, metadata.awsSessionToken);
46
+ const updateKubeConfigCmd = `aws eks update-kubeconfig --name ${metadata.clusterName} --region ${metadata.clusterRegion} --alias ${metadata.clusterName} --profile opal`;
47
+ const startSessionCmd = `${updateAwsConfigCommand} && ${updateKubeConfigCmd}`;
48
+ const roleText = roleName ? `"${roleName}" role` : "role";
49
+ const expirationMessage = getSessionExpirationMessage(session);
50
+ runCommandExec(startSessionCmd, `Now set to use ${roleText} with updated Kube config pointing to "${metadata.clusterName}" cluster. (session expires in ${expirationMessage})${getAwsEnvVarMessage()}`, `Failed to assume ${roleText} and update Kube config.`);
51
+ break;
52
+ }
53
+ default:
54
+ return handleError(this, undefined, session);
55
+ }
56
+ }
57
+ }
58
+ StartKubeIAMRoleSession.description = "Starts a session to assume a Kubernetes cluster IAM role.";
59
+ StartKubeIAMRoleSession.examples = [
60
+ "opal kube-roles:start",
61
+ "opal kube-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398",
62
+ 'opal kube-roles:start --id 51f7176b-0464-4a6f-8369-e951e187b398 --accessLevelRemoteId "arn:aws:iam::712234975475:role/acme-eks-cluster-admin-role"',
63
+ ];
64
+ StartKubeIAMRoleSession.flags = {
65
+ help: SHARED_FLAGS.help,
66
+ id: SHARED_FLAGS.id,
67
+ accessLevelRemoteId: SHARED_FLAGS.accessLevelRemoteId,
68
+ sessionId: SHARED_FLAGS.sessionId,
69
+ refresh: SHARED_FLAGS.refresh,
70
+ };
71
+ export default StartKubeIAMRoleSession;
@@ -9,6 +9,7 @@ export default class Login extends Command {
9
9
  static flags: {
10
10
  help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
11
11
  email: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
12
+ "device-code": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
12
13
  };
13
14
  static args: {};
14
15
  run(): Promise<void>;