@rockcarver/frodo-cli 2.0.0-28 → 2.0.0-29
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/CHANGELOG.md +22 -1
- package/esm/app.js +4 -0
- package/esm/app.js.map +1 -1
- package/esm/cli/FrodoCommand.js +10 -4
- package/esm/cli/FrodoCommand.js.map +1 -1
- package/esm/cli/admin/admin-get-access-token.js +1 -1
- package/esm/cli/admin/admin-get-access-token.js.map +1 -1
- package/esm/cli/admin/admin-grant-oauth2-client-admin-privileges.js +1 -1
- package/esm/cli/admin/admin-grant-oauth2-client-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-list-oauth2-clients-with-admin-privileges.js +1 -1
- package/esm/cli/admin/admin-list-oauth2-clients-with-admin-privileges.js.map +1 -1
- package/esm/cli/admin/admin-list-oauth2-clients-with-custom-privileges.js +1 -1
- package/esm/cli/admin/admin-list-oauth2-clients-with-custom-privileges.js.map +1 -1
- package/esm/cli/admin/admin-list-static-user-mappings.js +1 -1
- package/esm/cli/admin/admin-list-static-user-mappings.js.map +1 -1
- package/esm/cli/authz/authz-policy-delete.js +2 -2
- package/esm/cli/authz/authz-policy-delete.js.map +1 -1
- package/esm/cli/authz/authz-set-delete.js +2 -2
- package/esm/cli/authz/authz-set-delete.js.map +1 -1
- package/esm/cli/authz/authz-type-delete.js +3 -3
- package/esm/cli/authz/authz-type-delete.js.map +1 -1
- package/esm/cli/esv/esv-variable-delete.js +2 -2
- package/esm/cli/esv/esv-variable-delete.js.map +1 -1
- package/esm/cli/journey/journey-describe.js +1 -0
- package/esm/cli/journey/journey-describe.js.map +1 -1
- package/esm/cli/journey/journey-export.js +11 -1
- package/esm/cli/journey/journey-export.js.map +1 -1
- package/esm/ops/CirclesOfTrustOps.js +1 -1
- package/esm/ops/CirclesOfTrustOps.js.map +1 -1
- package/esm/ops/OAuth2ClientOps.js.map +1 -1
- package/esm/ops/PolicyOps.js +5 -15
- package/esm/ops/PolicyOps.js.map +1 -1
- package/esm/ops/PolicySetOps.js +11 -10
- package/esm/ops/PolicySetOps.js.map +1 -1
- package/esm/ops/RealmOps.js +3 -3
- package/esm/ops/RealmOps.js.map +1 -1
- package/esm/ops/ResourceTypeOps.js +11 -25
- package/esm/ops/ResourceTypeOps.js.map +1 -1
- package/esm/ops/Saml2Ops.js +2 -2
- package/esm/ops/Saml2Ops.js.map +1 -1
- package/esm/ops/SecretsOps.js +4 -4
- package/esm/ops/SecretsOps.js.map +1 -1
- package/esm/ops/VariablesOps.js +6 -4
- package/esm/ops/VariablesOps.js.map +1 -1
- package/global-jest-setup.js +4 -0
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- rockcarver/frodo-lib#53: Frodo Library now uses a file-based secure token cache to persist session and access tokens for re-use. The cached tokens are protected by the credential that was used to obtain them. Session tokens are encrypted using the hashed password as the master key, access tokens are encrypted using the hashed JWK private key as the master key. Therefore only users and processes with the correct credentials can access the tokens in the cache.
|
|
13
|
+
|
|
14
|
+
- The new default behavior is for Frodo CLI to use the new token cache for all applicable commands.
|
|
15
|
+
- A new global option `--no-cache` has been added to all commands to allow disabling the cache for indiviual invocations.
|
|
16
|
+
- A new environment variable `FRODO_NO_CACHE` is available to globally turn off token caching.
|
|
17
|
+
- A new environment variable `FRODO_TOKEN_CACHE_PATH` is available to instruct Frodo Library to use a non-default token cache file.
|
|
18
|
+
|
|
19
|
+
- rockcarver/frodo-lib#340: Frodo Library now autotomatically refreshes expired session and access tokens.
|
|
20
|
+
|
|
21
|
+
- The new default behavior is for Frodo CLI to automatically refresh tokens. This will only ever be noticeable during long-running operations like `frodo journey prune` or `frodo esv apply` that can take longer than 15 mins to complete.
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
25
|
+
- \#316: Frodo Library now properly exports scripts referenced by the `Device Match` node if the `Use Custom Matching Script` option is selected.
|
|
26
|
+
|
|
27
|
+
## [2.0.0-28] - 2023-10-25
|
|
28
|
+
|
|
10
29
|
## [2.0.0-27] - 2023-10-22
|
|
11
30
|
|
|
12
31
|
## [2.0.0-26] - 2023-10-19
|
|
@@ -1369,7 +1388,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
1369
1388
|
- Fixed problem with adding connection profiles
|
|
1370
1389
|
- Miscellaneous bug fixes
|
|
1371
1390
|
|
|
1372
|
-
[Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-
|
|
1391
|
+
[Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-28...HEAD
|
|
1392
|
+
|
|
1393
|
+
[2.0.0-28]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-27...v2.0.0-28
|
|
1373
1394
|
|
|
1374
1395
|
[2.0.0-27]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-26...v2.0.0-27
|
|
1375
1396
|
|
package/esm/app.js
CHANGED
|
@@ -28,11 +28,15 @@ import { getVersions } from './utils/Version';
|
|
|
28
28
|
const {
|
|
29
29
|
initConnectionProfiles
|
|
30
30
|
} = frodo.conn;
|
|
31
|
+
const {
|
|
32
|
+
initTokenCache
|
|
33
|
+
} = frodo.cache;
|
|
31
34
|
(async () => {
|
|
32
35
|
try {
|
|
33
36
|
const program = new Command('frodo').version(await getVersions(false), '-v, --version');
|
|
34
37
|
printMessage(await getVersions(true), 'text', false);
|
|
35
38
|
await initConnectionProfiles();
|
|
39
|
+
await initTokenCache();
|
|
36
40
|
program.addCommand(admin());
|
|
37
41
|
program.addCommand(agent());
|
|
38
42
|
program.addCommand(authz());
|
package/esm/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","names":["frodo","Command","admin","agent","app","authz","conn","email","esv","idm","idp","info","journey","log","oauth","realm","saml","script","service","shell","theme","printMessage","getVersions","initConnectionProfiles","program","version","addCommand","showHelpAfterError","enablePositionalOptions","parse","e","process","exitCode","stack"],"sources":["../src/app.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport { Command } from 'commander';\n\n// commands\nimport admin from './cli/admin/admin';\nimport agent from './cli/agent/agent';\nimport app from './cli/app/app';\nimport authz from './cli/authz/authz';\nimport conn from './cli/conn/conn';\nimport email from './cli/email/email';\nimport esv from './cli/esv/esv';\nimport idm from './cli/idm/idm';\nimport idp from './cli/idp/idp';\nimport info from './cli/info/info';\nimport journey from './cli/journey/journey';\nimport log from './cli/log/log';\nimport oauth from './cli/oauth/oauth';\nimport realm from './cli/realm/realm';\nimport saml from './cli/saml/saml';\nimport script from './cli/script/script';\nimport service from './cli/service/service';\nimport shell from './cli/shell/shell';\n// enable sample command template.\n// import something from './cli/_template/something';\nimport theme from './cli/theme/theme';\nimport { printMessage } from './utils/Console';\nimport { getVersions } from './utils/Version';\n\nconst { initConnectionProfiles } = frodo.conn;\n\n(async () => {\n try {\n const program = new Command('frodo').version(\n await getVersions(false),\n '-v, --version'\n );\n\n printMessage(await getVersions(true), 'text', false);\n\n await initConnectionProfiles();\n\n program.addCommand(admin());\n program.addCommand(agent());\n program.addCommand(authz());\n program.addCommand(app());\n program.addCommand(conn());\n program.addCommand(email());\n program.addCommand(esv());\n program.addCommand(idm());\n program.addCommand(idp());\n program.addCommand(info());\n program.addCommand(journey());\n program.addCommand(log());\n program.addCommand(oauth());\n program.addCommand(realm());\n program.addCommand(saml());\n program.addCommand(script());\n program.addCommand(service());\n program.addCommand(shell());\n program.addCommand(theme());\n // enable sample command template.\n // program.addCommand(something());\n\n program.showHelpAfterError();\n program.enablePositionalOptions();\n program.parse();\n } catch (e) {\n process.exitCode = 1;\n printMessage(`ERROR: exception running frodo - ${e}`, 'error');\n printMessage(e.stack, 'error');\n }\n})();\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,SAASC,OAAO,QAAQ,WAAW;;AAEnC;AACA,OAAOC,KAAK,MAAM,mBAAmB;AACrC,OAAOC,KAAK,MAAM,mBAAmB;AACrC,OAAOC,GAAG,MAAM,eAAe;AAC/B,OAAOC,KAAK,MAAM,mBAAmB;AACrC,OAAOC,IAAI,MAAM,iBAAiB;AAClC,OAAOC,KAAK,MAAM,mBAAmB;AACrC,OAAOC,GAAG,MAAM,eAAe;AAC/B,OAAOC,GAAG,MAAM,eAAe;AAC/B,OAAOC,GAAG,MAAM,eAAe;AAC/B,OAAOC,IAAI,MAAM,iBAAiB;AAClC,OAAOC,OAAO,MAAM,uBAAuB;AAC3C,OAAOC,GAAG,MAAM,eAAe;AAC/B,OAAOC,KAAK,MAAM,mBAAmB;AACrC,OAAOC,KAAK,MAAM,mBAAmB;AACrC,OAAOC,IAAI,MAAM,iBAAiB;AAClC,OAAOC,MAAM,MAAM,qBAAqB;AACxC,OAAOC,OAAO,MAAM,uBAAuB;AAC3C,OAAOC,KAAK,MAAM,mBAAmB;AACrC;AACA;AACA,OAAOC,KAAK,MAAM,mBAAmB;AACrC,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,WAAW,QAAQ,iBAAiB;AAE7C,MAAM;EAAEC;AAAuB,CAAC,GAAGvB,KAAK,CAACM,IAAI;
|
|
1
|
+
{"version":3,"file":"app.js","names":["frodo","Command","admin","agent","app","authz","conn","email","esv","idm","idp","info","journey","log","oauth","realm","saml","script","service","shell","theme","printMessage","getVersions","initConnectionProfiles","initTokenCache","cache","program","version","addCommand","showHelpAfterError","enablePositionalOptions","parse","e","process","exitCode","stack"],"sources":["../src/app.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport { Command } from 'commander';\n\n// commands\nimport admin from './cli/admin/admin';\nimport agent from './cli/agent/agent';\nimport app from './cli/app/app';\nimport authz from './cli/authz/authz';\nimport conn from './cli/conn/conn';\nimport email from './cli/email/email';\nimport esv from './cli/esv/esv';\nimport idm from './cli/idm/idm';\nimport idp from './cli/idp/idp';\nimport info from './cli/info/info';\nimport journey from './cli/journey/journey';\nimport log from './cli/log/log';\nimport oauth from './cli/oauth/oauth';\nimport realm from './cli/realm/realm';\nimport saml from './cli/saml/saml';\nimport script from './cli/script/script';\nimport service from './cli/service/service';\nimport shell from './cli/shell/shell';\n// enable sample command template.\n// import something from './cli/_template/something';\nimport theme from './cli/theme/theme';\nimport { printMessage } from './utils/Console';\nimport { getVersions } from './utils/Version';\n\nconst { initConnectionProfiles } = frodo.conn;\nconst { initTokenCache } = frodo.cache;\n\n(async () => {\n try {\n const program = new Command('frodo').version(\n await getVersions(false),\n '-v, --version'\n );\n\n printMessage(await getVersions(true), 'text', false);\n\n await initConnectionProfiles();\n await initTokenCache();\n\n program.addCommand(admin());\n program.addCommand(agent());\n program.addCommand(authz());\n program.addCommand(app());\n program.addCommand(conn());\n program.addCommand(email());\n program.addCommand(esv());\n program.addCommand(idm());\n program.addCommand(idp());\n program.addCommand(info());\n program.addCommand(journey());\n program.addCommand(log());\n program.addCommand(oauth());\n program.addCommand(realm());\n program.addCommand(saml());\n program.addCommand(script());\n program.addCommand(service());\n program.addCommand(shell());\n program.addCommand(theme());\n // enable sample command template.\n // program.addCommand(something());\n\n program.showHelpAfterError();\n program.enablePositionalOptions();\n program.parse();\n } catch (e) {\n process.exitCode = 1;\n printMessage(`ERROR: exception running frodo - ${e}`, 'error');\n printMessage(e.stack, 'error');\n }\n})();\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,SAASC,OAAO,QAAQ,WAAW;;AAEnC;AACA,OAAOC,KAAK,MAAM,mBAAmB;AACrC,OAAOC,KAAK,MAAM,mBAAmB;AACrC,OAAOC,GAAG,MAAM,eAAe;AAC/B,OAAOC,KAAK,MAAM,mBAAmB;AACrC,OAAOC,IAAI,MAAM,iBAAiB;AAClC,OAAOC,KAAK,MAAM,mBAAmB;AACrC,OAAOC,GAAG,MAAM,eAAe;AA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odo, state } from '@rockcarver/frodo-lib';
|
|
2
2
|
import { Argument, Command, Option } from 'commander';
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import * as globalConfig from '../storage/StaticStorage';
|
|
@@ -23,8 +23,10 @@ const insecureOption = new Option('-k, --insecure', 'Allow insecure connections
|
|
|
23
23
|
const verboseOption = new Option('--verbose', 'Verbose output during command execution. If specified, may or may not produce additional output.');
|
|
24
24
|
const debugOption = new Option('--debug', 'Debug output during command execution. If specified, may or may not produce additional output helpful for troubleshooting.');
|
|
25
25
|
const curlirizeOption = new Option('--curlirize', 'Output all network calls in curl format.');
|
|
26
|
+
const noCacheOption = new Option('--no-cache', 'Disable token cache for this operation.');
|
|
27
|
+
const flushCacheOption = new Option('--flush-cache', 'Flush token cache.');
|
|
26
28
|
const defaultArgs = [hostArgument, realmArgument, usernameArgument, passwordArgument];
|
|
27
|
-
const defaultOpts = [serviceAccountIdOption, serviceAccountJwkFileOption, deploymentOption, directoryOption, insecureOption, verboseOption, debugOption, curlirizeOption];
|
|
29
|
+
const defaultOpts = [serviceAccountIdOption, serviceAccountJwkFileOption, deploymentOption, directoryOption, insecureOption, verboseOption, debugOption, curlirizeOption, noCacheOption, flushCacheOption];
|
|
28
30
|
const stateMap = {
|
|
29
31
|
[hostArgument.name()]: host => state.setHost(host),
|
|
30
32
|
[realmArgument.name()]: realm => state.setRealm(realm),
|
|
@@ -45,7 +47,11 @@ const stateMap = {
|
|
|
45
47
|
[insecureOption.attributeName()]: insecure => state.setAllowInsecureConnection(insecure),
|
|
46
48
|
[verboseOption.attributeName()]: verbose => state.setVerbose(verbose),
|
|
47
49
|
[debugOption.attributeName()]: debug => state.setDebug(debug),
|
|
48
|
-
[curlirizeOption.attributeName()]: curlirize => state.setCurlirize(curlirize)
|
|
50
|
+
[curlirizeOption.attributeName()]: curlirize => state.setCurlirize(curlirize),
|
|
51
|
+
[noCacheOption.attributeName()]: cache => state.setUseTokenCache(cache),
|
|
52
|
+
[flushCacheOption.attributeName()]: flush => {
|
|
53
|
+
if (flush) frodo.cache.flush();
|
|
54
|
+
}
|
|
49
55
|
};
|
|
50
56
|
|
|
51
57
|
/**
|
|
@@ -113,7 +119,7 @@ export class FrodoCommand extends FrodoStubCommand {
|
|
|
113
119
|
}
|
|
114
120
|
|
|
115
121
|
// additional help
|
|
116
|
-
this.addHelpText('after', `\nEvironment Variables:\n` + ` FRODO_HOST: Access Management base URL. Overrides 'host' argument.\n` + ` FRODO_REALM: Realm. Overrides 'realm' argument.\n` + ` FRODO_USERNAME: Username. Overrides 'username' argument.\n` + ` FRODO_PASSWORD: Password. Overrides 'password' argument.\n` + ` FRODO_SA_ID: Service account uuid. Overrides '--sa-id' option.\n` + ` FRODO_SA_JWK: Service account JWK. Overrides '--sa-jwk-file' option but takes the actual JWK as a value, not a file name.\n` + ('frodo conn save' === this.name() ? ` FRODO_LOG_KEY: Log API key. Overrides '--log-api-key' option.\n` + ` FRODO_LOG_SECRET: Log API secret. Overrides '--log-api-secret' option.\n` : ``) + (this.name().startsWith('frodo log') ? ` FRODO_LOG_KEY: Log API key. Overrides 'username' argument.\n` + ` FRODO_LOG_SECRET: Log API secret. Overrides 'password' argument.\n` : ``) + ` FRODO_CONNECTION_PROFILES_PATH: Use this connection profiles file instead of '~/.frodo/Connections.json'.\n` + ` FRODO_AUTHENTICATION_SERVICE: Name of a login journey to use.\n` + ` FRODO_DEBUG: Set to any value to enable debug output. Same as '--debug'.\n` + ` FRODO_MASTER_KEY_PATH: Use this master key file instead of '~/.frodo/masterkey.key' file.\n` + ` FRODO_MASTER_KEY: Use this master key instead of '~/.frodo/masterkey.key'
|
|
122
|
+
this.addHelpText('after', `\nEvironment Variables:\n` + ` FRODO_HOST: Access Management base URL. Overrides 'host' argument.\n` + ` FRODO_REALM: Realm. Overrides 'realm' argument.\n` + ` FRODO_USERNAME: Username. Overrides 'username' argument.\n` + ` FRODO_PASSWORD: Password. Overrides 'password' argument.\n` + ` FRODO_SA_ID: Service account uuid. Overrides '--sa-id' option.\n` + ` FRODO_SA_JWK: Service account JWK. Overrides '--sa-jwk-file' option but takes the actual JWK as a value, not a file name.\n` + ` FRODO_NO_CACHE: Disable token cache. Same as '--no-cache' option.\n` + ` FRODO_TOKEN_CACHE_PATH: Use this token cache file instead of '~/.frodo/TokenCache.json'.\n` + ('frodo conn save' === this.name() ? ` FRODO_LOG_KEY: Log API key. Overrides '--log-api-key' option.\n` + ` FRODO_LOG_SECRET: Log API secret. Overrides '--log-api-secret' option.\n` : ``) + (this.name().startsWith('frodo log') ? ` FRODO_LOG_KEY: Log API key. Overrides 'username' argument.\n` + ` FRODO_LOG_SECRET: Log API secret. Overrides 'password' argument.\n` : ``) + ` FRODO_CONNECTION_PROFILES_PATH: Use this connection profiles file instead of '~/.frodo/Connections.json'.\n` + ` FRODO_AUTHENTICATION_SERVICE: Name of a login journey to use.\n` + ` FRODO_DEBUG: Set to any value to enable debug output. Same as '--debug'.\n` + ` FRODO_MASTER_KEY_PATH: Use this master key file instead of '~/.frodo/masterkey.key' file.\n` + ` FRODO_MASTER_KEY: Use this master key instead of what's in '~/.frodo/masterkey.key'. Takes precedence over FRODO_MASTER_KEY_PATH.\n`);
|
|
117
123
|
}
|
|
118
124
|
|
|
119
125
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FrodoCommand.js","names":["state","Argument","Command","Option","fs","globalConfig","createProgressIndicator","curlirizeMessage","debugMessage","printMessage","stopProgressIndicator","updateProgressIndicator","verboseMessage","hostArgument","realmArgument","default","process","env","FRODO_REALM","DEFAULT_REALM_KEY","usernameArgument","passwordArgument","serviceAccountIdOption","serviceAccountJwkFileOption","deploymentOption","choices","DEPLOYMENT_TYPES","directoryOption","undefined","insecureOption","verboseOption","debugOption","curlirizeOption","defaultArgs","defaultOpts","stateMap","name","host","setHost","realm","setRealm","username","setUsername","password","setPassword","attributeName","saId","setServiceAccountId","file","data","readFileSync","jwk","JSON","parse","toString","setServiceAccountJwk","error","message","type","setDeploymentType","directory","setDirectory","insecure","setAllowInsecureConnection","verbose","setVerbose","debug","setDebug","curlirize","setCurlirize","FrodoStubCommand","constructor","listenerCount","on","_error$config","_error$config2","_error$response","config","method","url","response","stack","exitCode","helpOption","showHelpAfterError","configureHelp","sortSubcommands","sortOptions","setPrintHandler","setVerboseHandler","setDebugHandler","setCurlirizeHandler","setCreateProgressHandler","setUpdateProgressHandler","setStopProgressHandler","FrodoCommand","omits","arg","includes","addArgument","opt","addOption","addHelpText","startsWith","handleDefaultArgsAndOpts","args","command","pop","options","i","v","entries","_args","length","Object","keys","handler","k"],"sources":["../../src/cli/FrodoCommand.ts"],"sourcesContent":["import { state } from '@rockcarver/frodo-lib';\nimport { Argument, Command, Option } from 'commander';\nimport fs from 'fs';\n\nimport * as globalConfig from '../storage/StaticStorage';\nimport {\n createProgressIndicator,\n curlirizeMessage,\n debugMessage,\n printMessage,\n stopProgressIndicator,\n updateProgressIndicator,\n verboseMessage,\n} from '../utils/Console.js';\n\nconst hostArgument = new Argument(\n '[host]',\n 'Access Management base URL, e.g.: https://cdk.iam.example.com/am. To use a connection profile, just specify a unique substring.'\n);\n\nconst realmArgument = new Argument(\n '[realm]',\n \"Realm. Specify realm as '/' for the root realm or 'realm' or '/parent/child' otherwise.\"\n).default(\n // must check for FRODO_REALM env variable here because otherwise cli will overwrite realm with default value\n process.env.FRODO_REALM || globalConfig.DEFAULT_REALM_KEY,\n '\"alpha\" for Identity Cloud tenants, \"/\" otherwise.'\n);\n\nconst usernameArgument = new Argument(\n '[username]',\n 'Username to login with. Must be an admin user with appropriate rights to manage authentication journeys/trees.'\n);\n\nconst passwordArgument = new Argument('[password]', 'Password.');\n\nconst serviceAccountIdOption = new Option(\n '--sa-id <sa-id>',\n 'Service account id.'\n);\n\nconst serviceAccountJwkFileOption = new Option(\n '--sa-jwk-file <file>',\n 'File containing the JSON Web Key (JWK) associated with the the service account.'\n);\n\nconst deploymentOption = new Option(\n '-m, --type <type>',\n 'Override auto-detected deployment type. Valid values for type: \\n\\\nclassic: A classic Access Management-only deployment with custom layout and configuration. \\n\\\ncloud: A ForgeRock Identity Cloud environment. \\n\\\nforgeops: A ForgeOps CDK or CDM deployment. \\n\\\nThe detected or provided deployment type controls certain behavior like obtaining an Identity \\\nManagement admin token or not and whether to export/import referenced email templates or how \\\nto walk through the tenant admin login flow of Identity Cloud and handle MFA'\n).choices(globalConfig.DEPLOYMENT_TYPES);\n\nconst directoryOption = new Option(\n '-D, --directory <directory>',\n 'Set the working directory.'\n).default(undefined, 'undefined');\n\nconst insecureOption = new Option(\n '-k, --insecure',\n 'Allow insecure connections when using SSL/TLS. Has no effect when using a network proxy for https (HTTPS_PROXY=http://<host>:<port>), in that case the proxy must provide this capability.'\n).default(false, \"Don't allow insecure connections\");\n\nconst verboseOption = new Option(\n '--verbose',\n 'Verbose output during command execution. If specified, may or may not produce additional output.'\n);\n\nconst debugOption = new Option(\n '--debug',\n 'Debug output during command execution. If specified, may or may not produce additional output helpful for troubleshooting.'\n);\n\nconst curlirizeOption = new Option(\n '--curlirize',\n 'Output all network calls in curl format.'\n);\n\nconst defaultArgs = [\n hostArgument,\n realmArgument,\n usernameArgument,\n passwordArgument,\n];\n\nconst defaultOpts = [\n serviceAccountIdOption,\n serviceAccountJwkFileOption,\n deploymentOption,\n directoryOption,\n insecureOption,\n verboseOption,\n debugOption,\n curlirizeOption,\n];\n\nconst stateMap = {\n [hostArgument.name()]: (host: string) => state.setHost(host),\n [realmArgument.name()]: (realm: string) => state.setRealm(realm),\n [usernameArgument.name()]: (username: string) => state.setUsername(username),\n [passwordArgument.name()]: (password: string) => state.setPassword(password),\n [serviceAccountIdOption.attributeName()]: (saId: string) =>\n state.setServiceAccountId(saId),\n [serviceAccountJwkFileOption.attributeName()]: (file: string) => {\n try {\n const data = fs.readFileSync(file);\n const jwk = JSON.parse(data.toString());\n state.setServiceAccountJwk(jwk);\n } catch (error) {\n printMessage(\n `Error parsing JWK from file ${file}: ${error.message}`,\n 'error'\n );\n }\n },\n [deploymentOption.attributeName()]: (type: string) =>\n state.setDeploymentType(type),\n [directoryOption.attributeName()]: (directory: string) =>\n state.setDirectory(directory),\n [insecureOption.attributeName()]: (insecure: boolean) =>\n state.setAllowInsecureConnection(insecure),\n [verboseOption.attributeName()]: (verbose: boolean) =>\n state.setVerbose(verbose),\n [debugOption.attributeName()]: (debug: boolean) => state.setDebug(debug),\n [curlirizeOption.attributeName()]: (curlirize: boolean) =>\n state.setCurlirize(curlirize),\n};\n\n/**\n * Command with default options\n */\nexport class FrodoStubCommand extends Command {\n /**\n * Creates a new FrodoCommand instance\n * @param name Name of the command\n * @param omits Array of default argument names and default option names that should not be added to this command\n */\n constructor(name: string) {\n super(name);\n\n if (!process.listenerCount('unhandledRejection')) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n process.on('unhandledRejection', (error: any) => {\n printMessage(\n `${error.config?.method ? error.config.method + ' ' : ''}${\n error.config?.url ? error.config.url : ''\n }`,\n 'error'\n );\n printMessage(error.response?.data, 'error');\n printMessage(error.stack, 'error');\n printMessage(\n `Please report this unhandled error here: https://github.com/rockcarver/frodo-cli/issues`,\n 'error'\n );\n process.exitCode = 1;\n });\n }\n\n // other default settings\n this.helpOption('-h, --help', 'Help');\n this.showHelpAfterError();\n this.configureHelp({\n sortSubcommands: true,\n sortOptions: true,\n });\n\n // register default handlers\n state.setPrintHandler(printMessage);\n state.setVerboseHandler(verboseMessage);\n state.setDebugHandler(debugMessage);\n state.setCurlirizeHandler(curlirizeMessage);\n state.setCreateProgressHandler(createProgressIndicator);\n state.setUpdateProgressHandler(updateProgressIndicator);\n state.setStopProgressHandler(stopProgressIndicator);\n }\n}\n\n/**\n * Command with default options\n */\nexport class FrodoCommand extends FrodoStubCommand {\n /**\n * Creates a new FrodoCommand instance\n * @param name Name of the command\n * @param omits Array of default argument names and default option names that should not be added to this command\n */\n constructor(name: string, omits: string[] = []) {\n super(name);\n\n // register default arguments\n for (const arg of defaultArgs) {\n if (!omits.includes(arg.name())) this.addArgument(arg);\n }\n\n // register default options\n for (const opt of defaultOpts) {\n if (!omits.includes(opt.name())) this.addOption(opt);\n }\n\n // additional help\n this.addHelpText(\n 'after',\n `\\nEvironment Variables:\\n` +\n ` FRODO_HOST: Access Management base URL. Overrides 'host' argument.\\n` +\n ` FRODO_REALM: Realm. Overrides 'realm' argument.\\n` +\n ` FRODO_USERNAME: Username. Overrides 'username' argument.\\n` +\n ` FRODO_PASSWORD: Password. Overrides 'password' argument.\\n` +\n ` FRODO_SA_ID: Service account uuid. Overrides '--sa-id' option.\\n` +\n ` FRODO_SA_JWK: Service account JWK. Overrides '--sa-jwk-file' option but takes the actual JWK as a value, not a file name.\\n` +\n ('frodo conn save' === this.name()\n ? ` FRODO_LOG_KEY: Log API key. Overrides '--log-api-key' option.\\n` +\n ` FRODO_LOG_SECRET: Log API secret. Overrides '--log-api-secret' option.\\n`\n : ``) +\n (this.name().startsWith('frodo log')\n ? ` FRODO_LOG_KEY: Log API key. Overrides 'username' argument.\\n` +\n ` FRODO_LOG_SECRET: Log API secret. Overrides 'password' argument.\\n`\n : ``) +\n ` FRODO_CONNECTION_PROFILES_PATH: Use this connection profiles file instead of '~/.frodo/Connections.json'.\\n` +\n ` FRODO_AUTHENTICATION_SERVICE: Name of a login journey to use.\\n` +\n ` FRODO_DEBUG: Set to any value to enable debug output. Same as '--debug'.\\n` +\n ` FRODO_MASTER_KEY_PATH: Use this master key file instead of '~/.frodo/masterkey.key' file.\\n` +\n ` FRODO_MASTER_KEY: Use this master key instead of '~/.frodo/masterkey.key' file. Takes precedence over FRODO_MASTER_KEY_PATH.\\n`\n );\n }\n\n /**\n *\n * @param args\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n handleDefaultArgsAndOpts(...args: any) {\n const command = args.pop();\n const options = args.pop();\n\n // handle arguments first\n for (const [i, v] of command.args.entries()) {\n if (!command._args[i]) {\n printMessage(\n `${command.args.length} arguments supplied but command only supports ${command._args.length}.`,\n 'warn'\n );\n break;\n }\n const arg = command._args[i].name();\n // handle only default arguments\n if (Object.keys(stateMap).includes(arg)) {\n debugMessage(\n `FrodoCommand.handleDefaultArgsAndOpts: Handling default argument '${arg}'.`\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const handler: any = stateMap[arg];\n handler(v);\n } else {\n debugMessage(\n `FrodoCommand.handleDefaultArgsAndOpts: Ignoring non-default argument '${arg}'.`\n );\n }\n }\n\n // handle options\n for (const [k, v] of Object.entries(options)) {\n // handle only default options\n if (Object.keys(stateMap).includes(k)) {\n debugMessage(\n `FrodoCommand.handleDefaultArgsAndOpts: Handling default option '${k}'.`\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const handler: any = stateMap[k];\n handler(v);\n } else {\n debugMessage(\n `FrodoCommand.handleDefaultArgsAndOpts: Ignoring non-default option '${k}'.`\n );\n }\n }\n }\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,SAASC,QAAQ,EAAEC,OAAO,EAAEC,MAAM,QAAQ,WAAW;AACrD,OAAOC,EAAE,MAAM,IAAI;AAEnB,OAAO,KAAKC,YAAY,MAAM,0BAA0B;AACxD,SACEC,uBAAuB,EACvBC,gBAAgB,EAChBC,YAAY,EACZC,YAAY,EACZC,qBAAqB,EACrBC,uBAAuB,EACvBC,cAAc,QACT,qBAAqB;AAE5B,MAAMC,YAAY,GAAG,IAAIZ,QAAQ,CAC/B,QAAQ,EACR,iIACF,CAAC;AAED,MAAMa,aAAa,GAAG,IAAIb,QAAQ,CAChC,SAAS,EACT,yFACF,CAAC,CAACc,OAAO;AACP;AACAC,OAAO,CAACC,GAAG,CAACC,WAAW,IAAIb,YAAY,CAACc,iBAAiB,EACzD,oDACF,CAAC;AAED,MAAMC,gBAAgB,GAAG,IAAInB,QAAQ,CACnC,YAAY,EACZ,gHACF,CAAC;AAED,MAAMoB,gBAAgB,GAAG,IAAIpB,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAC;AAEhE,MAAMqB,sBAAsB,GA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Q,CAACmB,CAAC,CAAC,EAAE;QACrC7G,YAAY,CACT,mEAAkE6G,CAAE,IACvE,CAAC;QACD;QACA,MAAMD,OAAY,GAAGjF,QAAQ,CAACkF,CAAC,CAAC;QAChCD,OAAO,CAACN,CAAC,CAAC;MACZ,CAAC,MAAM;QACLtG,YAAY,CACT,uEAAsE6G,CAAE,IAC3E,CAAC;MACH;IACF;EACF;AACF"}
|
|
1
|
+
{"version":3,"file":"FrodoCommand.js","names":["frodo","state","Argument","Command","Option","fs","globalConfig","createProgressIndicator","curlirizeMessage","debugMessage","printMessage","stopProgressIndicator","updateProgressIndicator","verboseMessage","hostArgument","realmArgument","default","process","env","FRODO_REALM","DEFAULT_REALM_KEY","usernameArgument","passwordArgument","serviceAccountIdOption","serviceAccountJwkFileOption","deploymentOption","choices","DEPLOYMENT_TYPES","directoryOption","undefined","insecureOption","verboseOption","debugOption","curlirizeOption","noCacheOption","flushCacheOption","defaultArgs","defaultOpts","stateMap","name","host","setHost","realm","setRealm","username","setUsername","password","setPassword","attributeName","saId","setServiceAccountId","file","data","readFileSync","jwk","JSON","parse","toString","setServiceAccountJwk","error","message","type","setDeploymentType","directory","setDirectory","insecure","setAllowInsecureConnection","verbose","setVerbose","debug","setDebug","curlirize","setCurlirize","cache","setUseTokenCache","flush","FrodoStubCommand","constructor","listenerCount","on","_error$config","_error$config2","_error$response","config","method","url","response","stack","exitCode","helpOption","showHelpAfterError","configureHelp","sortSubcommands","sortOptions","setPrintHandler","setVerboseHandler","setDebugHandler","setCurlirizeHandler","setCreateProgressHandler","setUpdateProgressHandler","setStopProgressHandler","FrodoCommand","omits","arg","includes","addArgument","opt","addOption","addHelpText","startsWith","handleDefaultArgsAndOpts","args","command","pop","options","i","v","entries","_args","length","Object","keys","handler","k"],"sources":["../../src/cli/FrodoCommand.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { Argument, Command, Option } from 'commander';\nimport fs from 'fs';\n\nimport * as globalConfig from '../storage/StaticStorage';\nimport {\n createProgressIndicator,\n curlirizeMessage,\n debugMessage,\n printMessage,\n stopProgressIndicator,\n updateProgressIndicator,\n verboseMessage,\n} from '../utils/Console.js';\n\nconst hostArgument = new Argument(\n '[host]',\n 'Access Management base URL, e.g.: https://cdk.iam.example.com/am. To use a connection profile, just specify a unique substring.'\n);\n\nconst realmArgument = new Argument(\n '[realm]',\n \"Realm. Specify realm as '/' for the root realm or 'realm' or '/parent/child' otherwise.\"\n).default(\n // must check for FRODO_REALM env variable here because otherwise cli will overwrite realm with default value\n process.env.FRODO_REALM || globalConfig.DEFAULT_REALM_KEY,\n '\"alpha\" for Identity Cloud tenants, \"/\" otherwise.'\n);\n\nconst usernameArgument = new Argument(\n '[username]',\n 'Username to login with. Must be an admin user with appropriate rights to manage authentication journeys/trees.'\n);\n\nconst passwordArgument = new Argument('[password]', 'Password.');\n\nconst serviceAccountIdOption = new Option(\n '--sa-id <sa-id>',\n 'Service account id.'\n);\n\nconst serviceAccountJwkFileOption = new Option(\n '--sa-jwk-file <file>',\n 'File containing the JSON Web Key (JWK) associated with the the service account.'\n);\n\nconst deploymentOption = new Option(\n '-m, --type <type>',\n 'Override auto-detected deployment type. Valid values for type: \\n\\\nclassic: A classic Access Management-only deployment with custom layout and configuration. \\n\\\ncloud: A ForgeRock Identity Cloud environment. \\n\\\nforgeops: A ForgeOps CDK or CDM deployment. \\n\\\nThe detected or provided deployment type controls certain behavior like obtaining an Identity \\\nManagement admin token or not and whether to export/import referenced email templates or how \\\nto walk through the tenant admin login flow of Identity Cloud and handle MFA'\n).choices(globalConfig.DEPLOYMENT_TYPES);\n\nconst directoryOption = new Option(\n '-D, --directory <directory>',\n 'Set the working directory.'\n).default(undefined, 'undefined');\n\nconst insecureOption = new Option(\n '-k, --insecure',\n 'Allow insecure connections when using SSL/TLS. Has no effect when using a network proxy for https (HTTPS_PROXY=http://<host>:<port>), in that case the proxy must provide this capability.'\n).default(false, \"Don't allow insecure connections\");\n\nconst verboseOption = new Option(\n '--verbose',\n 'Verbose output during command execution. If specified, may or may not produce additional output.'\n);\n\nconst debugOption = new Option(\n '--debug',\n 'Debug output during command execution. If specified, may or may not produce additional output helpful for troubleshooting.'\n);\n\nconst curlirizeOption = new Option(\n '--curlirize',\n 'Output all network calls in curl format.'\n);\n\nconst noCacheOption = new Option(\n '--no-cache',\n 'Disable token cache for this operation.'\n);\n\nconst flushCacheOption = new Option('--flush-cache', 'Flush token cache.');\n\nconst defaultArgs = [\n hostArgument,\n realmArgument,\n usernameArgument,\n passwordArgument,\n];\n\nconst defaultOpts = [\n serviceAccountIdOption,\n serviceAccountJwkFileOption,\n deploymentOption,\n directoryOption,\n insecureOption,\n verboseOption,\n debugOption,\n curlirizeOption,\n noCacheOption,\n flushCacheOption,\n];\n\nconst stateMap = {\n [hostArgument.name()]: (host: string) => state.setHost(host),\n [realmArgument.name()]: (realm: string) => state.setRealm(realm),\n [usernameArgument.name()]: (username: string) => state.setUsername(username),\n [passwordArgument.name()]: (password: string) => state.setPassword(password),\n [serviceAccountIdOption.attributeName()]: (saId: string) =>\n state.setServiceAccountId(saId),\n [serviceAccountJwkFileOption.attributeName()]: (file: string) => {\n try {\n const data = fs.readFileSync(file);\n const jwk = JSON.parse(data.toString());\n state.setServiceAccountJwk(jwk);\n } catch (error) {\n printMessage(\n `Error parsing JWK from file ${file}: ${error.message}`,\n 'error'\n );\n }\n },\n [deploymentOption.attributeName()]: (type: string) =>\n state.setDeploymentType(type),\n [directoryOption.attributeName()]: (directory: string) =>\n state.setDirectory(directory),\n [insecureOption.attributeName()]: (insecure: boolean) =>\n state.setAllowInsecureConnection(insecure),\n [verboseOption.attributeName()]: (verbose: boolean) =>\n state.setVerbose(verbose),\n [debugOption.attributeName()]: (debug: boolean) => state.setDebug(debug),\n [curlirizeOption.attributeName()]: (curlirize: boolean) =>\n state.setCurlirize(curlirize),\n [noCacheOption.attributeName()]: (cache: boolean) =>\n state.setUseTokenCache(cache),\n [flushCacheOption.attributeName()]: (flush: boolean) => {\n if (flush) frodo.cache.flush();\n },\n};\n\n/**\n * Command with default options\n */\nexport class FrodoStubCommand extends Command {\n /**\n * Creates a new FrodoCommand instance\n * @param name Name of the command\n * @param omits Array of default argument names and default option names that should not be added to this command\n */\n constructor(name: string) {\n super(name);\n\n if (!process.listenerCount('unhandledRejection')) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n process.on('unhandledRejection', (error: any) => {\n printMessage(\n `${error.config?.method ? error.config.method + ' ' : ''}${\n error.config?.url ? error.config.url : ''\n }`,\n 'error'\n );\n printMessage(error.response?.data, 'error');\n printMessage(error.stack, 'error');\n printMessage(\n `Please report this unhandled error here: https://github.com/rockcarver/frodo-cli/issues`,\n 'error'\n );\n process.exitCode = 1;\n });\n }\n\n // other default settings\n this.helpOption('-h, --help', 'Help');\n this.showHelpAfterError();\n this.configureHelp({\n sortSubcommands: true,\n sortOptions: true,\n });\n\n // register default handlers\n state.setPrintHandler(printMessage);\n state.setVerboseHandler(verboseMessage);\n state.setDebugHandler(debugMessage);\n state.setCurlirizeHandler(curlirizeMessage);\n state.setCreateProgressHandler(createProgressIndicator);\n state.setUpdateProgressHandler(updateProgressIndicator);\n state.setStopProgressHandler(stopProgressIndicator);\n }\n}\n\n/**\n * Command with default options\n */\nexport class FrodoCommand extends FrodoStubCommand {\n /**\n * Creates a new FrodoCommand instance\n * @param name Name of the command\n * @param omits Array of default argument names and default option names that should not be added to this command\n */\n constructor(name: string, omits: string[] = []) {\n super(name);\n\n // register default arguments\n for (const arg of defaultArgs) {\n if (!omits.includes(arg.name())) this.addArgument(arg);\n }\n\n // register default options\n for (const opt of defaultOpts) {\n if (!omits.includes(opt.name())) this.addOption(opt);\n }\n\n // additional help\n this.addHelpText(\n 'after',\n `\\nEvironment Variables:\\n` +\n ` FRODO_HOST: Access Management base URL. Overrides 'host' argument.\\n` +\n ` FRODO_REALM: Realm. Overrides 'realm' argument.\\n` +\n ` FRODO_USERNAME: Username. Overrides 'username' argument.\\n` +\n ` FRODO_PASSWORD: Password. Overrides 'password' argument.\\n` +\n ` FRODO_SA_ID: Service account uuid. Overrides '--sa-id' option.\\n` +\n ` FRODO_SA_JWK: Service account JWK. Overrides '--sa-jwk-file' option but takes the actual JWK as a value, not a file name.\\n` +\n ` FRODO_NO_CACHE: Disable token cache. Same as '--no-cache' option.\\n` +\n ` FRODO_TOKEN_CACHE_PATH: Use this token cache file instead of '~/.frodo/TokenCache.json'.\\n` +\n ('frodo conn save' === this.name()\n ? ` FRODO_LOG_KEY: Log API key. Overrides '--log-api-key' option.\\n` +\n ` FRODO_LOG_SECRET: Log API secret. Overrides '--log-api-secret' option.\\n`\n : ``) +\n (this.name().startsWith('frodo log')\n ? ` FRODO_LOG_KEY: Log API key. Overrides 'username' argument.\\n` +\n ` FRODO_LOG_SECRET: Log API secret. Overrides 'password' argument.\\n`\n : ``) +\n ` FRODO_CONNECTION_PROFILES_PATH: Use this connection profiles file instead of '~/.frodo/Connections.json'.\\n` +\n ` FRODO_AUTHENTICATION_SERVICE: Name of a login journey to use.\\n` +\n ` FRODO_DEBUG: Set to any value to enable debug output. Same as '--debug'.\\n` +\n ` FRODO_MASTER_KEY_PATH: Use this master key file instead of '~/.frodo/masterkey.key' file.\\n` +\n ` FRODO_MASTER_KEY: Use this master key instead of what's in '~/.frodo/masterkey.key'. Takes precedence over FRODO_MASTER_KEY_PATH.\\n`\n );\n }\n\n /**\n *\n * @param args\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n handleDefaultArgsAndOpts(...args: any) {\n const command = args.pop();\n const options = args.pop();\n\n // handle arguments first\n for (const [i, v] of command.args.entries()) {\n if (!command._args[i]) {\n printMessage(\n `${command.args.length} arguments supplied but command only supports ${command._args.length}.`,\n 'warn'\n );\n break;\n }\n const arg = command._args[i].name();\n // handle only default arguments\n if (Object.keys(stateMap).includes(arg)) {\n debugMessage(\n `FrodoCommand.handleDefaultArgsAndOpts: Handling default argument '${arg}'.`\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const handler: any = stateMap[arg];\n handler(v);\n } else {\n debugMessage(\n `FrodoCommand.handleDefaultArgsAndOpts: Ignoring non-default argument '${arg}'.`\n );\n }\n }\n\n // handle options\n for (const [k, v] of Object.entries(options)) {\n // handle only default options\n if (Object.keys(stateMap).includes(k)) {\n debugMessage(\n `FrodoCommand.handleDefaultArgsAndOpts: Handling default option '${k}'.`\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const handler: any = stateMap[k];\n handler(v);\n } else {\n debugMessage(\n `FrodoCommand.handleDefaultArgsAndOpts: Ignoring non-default option '${k}'.`\n );\n }\n }\n }\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,SAASC,QAAQ,EAAEC,OAAO,EAAEC,MAAM,QAAQ,WAAW;AACrD,OAAOC,EAAE,MAAM,IAAI;AAEnB,OAAO,KAAKC,YAAY,MAAM,0BAA0B;AACxD,SACEC,uBAAuB,EACvBC,gBAAgB,EAChBC,YAAY,EACZC,YAAY,EACZC,qBAAqB,EACrBC,uBAAuB,EACvBC,cAAc,QACT,qBAAqB;AAE5B,MAAMC,YAAY,GAAG,IAAIZ,QAAQ,CAC/B,QAAQ,EACR,iIACF,CAAC;AAED,MAAMa,aAAa,GAAG,IAAIb,QAAQ,CAChC,SAAS,EACT,yFACF,CAAC,CAACc,OAAO;AACP;AACAC,OAAO,CAACC,GAAG,CAACC,WAAW,IAAIb,YAAY,CAACc,iBAAiB,EACzD,oDACF,CAAC;AAED,MAAMC,gBAAgB,GAAG,IAAInB,QAAQ,CACnC,YAAY,EACZ,gHACF,CAAC;AAED,MAAMoB,gBAAgB,GAAG,IAAIpB,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAC;AAEhE,MAAMqB,sBAAsB,GAAG,IAAInB,MAAM,CACvC,iBAAiB,EACjB,qBACF,CAAC;AAED,MAAMoB,2BAA2B,GAAG,IAAIpB,MAAM,CAC5C,sBAAsB,EACtB,iFACF,CAAC;AAED,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AAY,GAAGpF,QAAQ,CAACiE,GAAG,CAAC;QAClCmB,OAAO,CAACN,CAAC,CAAC;MACZ,CAAC,MAAM;QACL3G,YAAY,CACT,yEAAwE8F,GAAI,IAC/E,CAAC;MACH;IACF;;IAEA;IACA,KAAK,MAAM,CAACoB,CAAC,EAAEP,CAAC,CAAC,IAAII,MAAM,CAACH,OAAO,CAACH,OAAO,CAAC,EAAE;MAC5C;MACA,IAAIM,MAAM,CAACC,IAAI,CAACnF,QAAQ,CAAC,CAACkE,QAAQ,CAACmB,CAAC,CAAC,EAAE;QACrClH,YAAY,CACT,mEAAkEkH,CAAE,IACvE,CAAC;QACD;QACA,MAAMD,OAAY,GAAGpF,QAAQ,CAACqF,CAAC,CAAC;QAChCD,OAAO,CAACN,CAAC,CAAC;MACZ,CAAC,MAAM;QACL3G,YAAY,CACT,uEAAsEkH,CAAE,IAC3E,CAAC;MACH;IACF;EACF;AACF"}
|
|
@@ -15,7 +15,7 @@ async (host, realm, user, password, options, command) => {
|
|
|
15
15
|
command.handleDefaultArgsAndOpts(host, realm, user, password, options, command);
|
|
16
16
|
if (await getTokens()) {
|
|
17
17
|
printMessage(`Getting an access token using client "${options.clientId}"...`);
|
|
18
|
-
const response =
|
|
18
|
+
const response = await clientCredentialsGrant(state.getHost(), options.clientId, options.clientSecret, options.scope);
|
|
19
19
|
printMessage(`Token: ${response.access_token}`);
|
|
20
20
|
} else {
|
|
21
21
|
process.exitCode = 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-get-access-token.js","names":["frodo","state","Option","printMessage","FrodoCommand","getTokens","login","clientCredentialsGrant","oauth2oidc","endpoint","program","description","addOption","makeOptionMandatory","default","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","clientId","response","getHost","clientSecret","scope","
|
|
1
|
+
{"version":3,"file":"admin-get-access-token.js","names":["frodo","state","Option","printMessage","FrodoCommand","getTokens","login","clientCredentialsGrant","oauth2oidc","endpoint","program","description","addOption","makeOptionMandatory","default","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","clientId","response","getHost","clientSecret","scope","access_token","process","exitCode","parse"],"sources":["../../../src/cli/admin/admin-get-access-token.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport { printMessage } from '../../utils/Console.js';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\nconst { clientCredentialsGrant } = frodo.oauth2oidc.endpoint;\n\nconst program = new FrodoCommand('frodo admin get-access-token');\n\nprogram\n .description('Get an access token using client credentials grant type.')\n .addOption(\n new Option('-i, --client-id [id]', 'Client id.').makeOptionMandatory()\n )\n .addOption(\n new Option(\n '-s, --client-secret [secret]',\n 'Client secret.'\n ).makeOptionMandatory()\n )\n .addOption(\n new Option('--scope [scope]', 'Request the following scope(s).').default(\n 'fr:idm:*',\n 'fr:idm:*'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n if (await getTokens()) {\n printMessage(\n `Getting an access token using client \"${options.clientId}\"...`\n );\n const response = await clientCredentialsGrant(\n state.getHost(),\n options.clientId,\n options.clientSecret,\n options.scope\n );\n printMessage(`Token: ${response.access_token}`);\n } else {\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,SAASC,MAAM,QAAQ,WAAW;AAElC,SAASC,YAAY,QAAQ,wBAAwB;AACrD,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAM;EAAEC;AAAU,CAAC,GAAGL,KAAK,CAACM,KAAK;AACjC,MAAM;EAAEC;AAAuB,CAAC,GAAGP,KAAK,CAACQ,UAAU,CAACC,QAAQ;AAE5D,MAAMC,OAAO,GAAG,IAAIN,YAAY,CAAC,8BAA8B,CAAC;AAEhEM,OAAO,CACJC,WAAW,CAAC,0DAA0D,CAAC,CACvEC,SAAS,CACR,IAAIV,MAAM,CAAC,sBAAsB,EAAE,YAAY,CAAC,CAACW,mBAAmB,CAAC,CACvE,CAAC,CACAD,SAAS,CACR,IAAIV,MAAM,CACR,8BAA8B,EAC9B,gBACF,CAAC,CAACW,mBAAmB,CAAC,CACxB,CAAC,CACAD,SAAS,CACR,IAAIV,MAAM,CAAC,iBAAiB,EAAE,iCAAiC,CAAC,CAACY,OAAO,CACtE,UAAU,EACV,UACF,CACF,CAAC,CACAC,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EACvDA,OAAO,CAACC,wBAAwB,CAC9BN,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,QAAQ,EACRC,OAAO,EACPC,OACF,CAAC;EACD,IAAI,MAAMhB,SAAS,CAAC,CAAC,EAAE;IACrBF,YAAY,CACT,yCAAwCiB,OAAO,CAACG,QAAS,MAC5D,CAAC;IACD,MAAMC,QAAQ,GAAG,MAAMjB,sBAAsB,CAC3CN,KAAK,CAACwB,OAAO,CAAC,CAAC,EACfL,OAAO,CAACG,QAAQ,EAChBH,OAAO,CAACM,YAAY,EACpBN,OAAO,CAACO,KACV,CAAC;IACDxB,YAAY,CAAE,UAASqB,QAAQ,CAACI,YAAa,EAAC,CAAC;EACjD,CAAC,MAAM;IACLC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEHpB,OAAO,CAACqB,KAAK,CAAC,CAAC"}
|
|
@@ -14,7 +14,7 @@ program.description('Grant an oauth2 client admin privileges.').addOption(new Op
|
|
|
14
14
|
async (host, realm, user, password, options, command) => {
|
|
15
15
|
command.handleDefaultArgsAndOpts(host, realm, user, password, options, command);
|
|
16
16
|
if (await getTokens()) {
|
|
17
|
-
printMessage(`Granting oauth2 client "${options.target}" in realm "${state.getRealm()}" admin privileges...`);
|
|
17
|
+
printMessage(`Granting oauth2 client "${options.clientId || options.target}" in realm "${state.getRealm()}" admin privileges...`);
|
|
18
18
|
await grantOAuth2ClientAdminPrivileges(options.clientId || options.target);
|
|
19
19
|
printMessage('Done.');
|
|
20
20
|
} else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-grant-oauth2-client-admin-privileges.js","names":["frodo","state","Option","printMessage","FrodoCommand","getTokens","login","grantOAuth2ClientAdminPrivileges","admin","program","description","addOption","hideHelp","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","
|
|
1
|
+
{"version":3,"file":"admin-grant-oauth2-client-admin-privileges.js","names":["frodo","state","Option","printMessage","FrodoCommand","getTokens","login","grantOAuth2ClientAdminPrivileges","admin","program","description","addOption","hideHelp","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","clientId","target","getRealm","process","exitCode","parse"],"sources":["../../../src/cli/admin/admin-grant-oauth2-client-admin-privileges.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport { printMessage } from '../../utils/Console.js';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\nconst { grantOAuth2ClientAdminPrivileges } = frodo.admin;\n\nconst program = new FrodoCommand(\n 'frodo admin grant-oauth2-client-admin-privileges'\n);\n\nprogram\n .description('Grant an oauth2 client admin privileges.')\n .addOption(new Option('-i, --client-id <id>', 'OAuth2 client id.'))\n .addOption(\n new Option(\n '-t, --target <target name or id>',\n 'Name of the oauth2 client.'\n ).hideHelp()\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n if (await getTokens()) {\n printMessage(\n `Granting oauth2 client \"${\n options.clientId || options.target\n }\" in realm \"${state.getRealm()}\" admin privileges...`\n );\n await grantOAuth2ClientAdminPrivileges(\n options.clientId || options.target\n );\n printMessage('Done.');\n } else {\n process.exit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@ async (host, realm, user, password, options, command) => {
|
|
|
17
17
|
const adminClients = await listOAuth2AdminClients();
|
|
18
18
|
adminClients.sort((a, b) => a.localeCompare(b));
|
|
19
19
|
adminClients.forEach(item => {
|
|
20
|
-
printMessage(`${item}
|
|
20
|
+
printMessage(`${item}`, 'data');
|
|
21
21
|
});
|
|
22
22
|
} else {
|
|
23
23
|
process.exitCode = 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-list-oauth2-clients-with-admin-privileges.js","names":["frodo","state","printMessage","FrodoCommand","getTokens","login","listOAuth2AdminClients","admin","program","description","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","getRealm","adminClients","sort","a","b","localeCompare","forEach","item","process","exitCode","parse"],"sources":["../../../src/cli/admin/admin-list-oauth2-clients-with-admin-privileges.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\n\nimport { printMessage } from '../../utils/Console.js';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\nconst { listOAuth2AdminClients } = frodo.admin;\n\nconst program = new FrodoCommand(\n 'frodo admin list-oauth2-clients-with-admin-privileges'\n);\n\nprogram.description('List oauth2 clients with admin privileges.').action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n if (await getTokens()) {\n printMessage(\n `Listing oauth2 clients with admin privileges in realm \"${state.getRealm()}\"...`\n );\n const adminClients = await listOAuth2AdminClients();\n adminClients.sort((a, b) => a.localeCompare(b));\n adminClients.forEach((item) => {\n printMessage(`${item}
|
|
1
|
+
{"version":3,"file":"admin-list-oauth2-clients-with-admin-privileges.js","names":["frodo","state","printMessage","FrodoCommand","getTokens","login","listOAuth2AdminClients","admin","program","description","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","getRealm","adminClients","sort","a","b","localeCompare","forEach","item","process","exitCode","parse"],"sources":["../../../src/cli/admin/admin-list-oauth2-clients-with-admin-privileges.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\n\nimport { printMessage } from '../../utils/Console.js';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\nconst { listOAuth2AdminClients } = frodo.admin;\n\nconst program = new FrodoCommand(\n 'frodo admin list-oauth2-clients-with-admin-privileges'\n);\n\nprogram.description('List oauth2 clients with admin privileges.').action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n if (await getTokens()) {\n printMessage(\n `Listing oauth2 clients with admin privileges in realm \"${state.getRealm()}\"...`\n );\n const adminClients = await listOAuth2AdminClients();\n adminClients.sort((a, b) => a.localeCompare(b));\n adminClients.forEach((item) => {\n printMessage(`${item}`, 'data');\n });\n } else {\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n);\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAEpD,SAASC,YAAY,QAAQ,wBAAwB;AACrD,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAM;EAAEC;AAAU,CAAC,GAAGJ,KAAK,CAACK,KAAK;AACjC,MAAM;EAAEC;AAAuB,CAAC,GAAGN,KAAK,CAACO,KAAK;AAE9C,MAAMC,OAAO,GAAG,IAAIL,YAAY,CAC9B,uDACF,CAAC;AAEDK,OAAO,CAACC,WAAW,CAAC,4CAA4C,CAAC,CAACC,MAAM;AACtE;AACA,OAAOC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EACvDA,OAAO,CAACC,wBAAwB,CAC9BN,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,QAAQ,EACRC,OAAO,EACPC,OACF,CAAC;EACD,IAAI,MAAMZ,SAAS,CAAC,CAAC,EAAE;IACrBF,YAAY,CACT,0DAAyDD,KAAK,CAACiB,QAAQ,CAAC,CAAE,MAC7E,CAAC;IACD,MAAMC,YAAY,GAAG,MAAMb,sBAAsB,CAAC,CAAC;IACnDa,YAAY,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACE,aAAa,CAACD,CAAC,CAAC,CAAC;IAC/CH,YAAY,CAACK,OAAO,CAAEC,IAAI,IAAK;MAC7BvB,YAAY,CAAE,GAAEuB,IAAK,EAAC,EAAE,MAAM,CAAC;IACjC,CAAC,CAAC;EACJ,CAAC,MAAM;IACLC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEDnB,OAAO,CAACoB,KAAK,CAAC,CAAC"}
|
|
@@ -17,7 +17,7 @@ async (host, realm, user, password, options, command) => {
|
|
|
17
17
|
const adminClients = await listOAuth2CustomClients();
|
|
18
18
|
adminClients.sort((a, b) => a.localeCompare(b));
|
|
19
19
|
adminClients.forEach(item => {
|
|
20
|
-
printMessage(`${item}
|
|
20
|
+
printMessage(`${item}`, 'data');
|
|
21
21
|
});
|
|
22
22
|
} else {
|
|
23
23
|
process.exitCode = 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-list-oauth2-clients-with-custom-privileges.js","names":["frodo","state","printMessage","FrodoCommand","getTokens","login","listOAuth2CustomClients","admin","program","description","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","getRealm","adminClients","sort","a","b","localeCompare","forEach","item","process","exitCode","parse"],"sources":["../../../src/cli/admin/admin-list-oauth2-clients-with-custom-privileges.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\n\nimport { printMessage } from '../../utils/Console.js';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\nconst { listOAuth2CustomClients } = frodo.admin;\n\nconst program = new FrodoCommand(\n 'frodo admin list-oauth2-clients-with-custom-privileges'\n);\n\nprogram.description('List oauth2 clients with custom privileges.').action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n if (await getTokens()) {\n printMessage(\n `Listing oauth2 clients with custom privileges in realm \"${state.getRealm()}\"...`\n );\n const adminClients = await listOAuth2CustomClients();\n adminClients.sort((a, b) => a.localeCompare(b));\n adminClients.forEach((item) => {\n printMessage(`${item}
|
|
1
|
+
{"version":3,"file":"admin-list-oauth2-clients-with-custom-privileges.js","names":["frodo","state","printMessage","FrodoCommand","getTokens","login","listOAuth2CustomClients","admin","program","description","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","getRealm","adminClients","sort","a","b","localeCompare","forEach","item","process","exitCode","parse"],"sources":["../../../src/cli/admin/admin-list-oauth2-clients-with-custom-privileges.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\n\nimport { printMessage } from '../../utils/Console.js';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\nconst { listOAuth2CustomClients } = frodo.admin;\n\nconst program = new FrodoCommand(\n 'frodo admin list-oauth2-clients-with-custom-privileges'\n);\n\nprogram.description('List oauth2 clients with custom privileges.').action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n if (await getTokens()) {\n printMessage(\n `Listing oauth2 clients with custom privileges in realm \"${state.getRealm()}\"...`\n );\n const adminClients = await listOAuth2CustomClients();\n adminClients.sort((a, b) => a.localeCompare(b));\n adminClients.forEach((item) => {\n printMessage(`${item}`, 'data');\n });\n } else {\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n);\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAEpD,SAASC,YAAY,QAAQ,wBAAwB;AACrD,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAM;EAAEC;AAAU,CAAC,GAAGJ,KAAK,CAACK,KAAK;AACjC,MAAM;EAAEC;AAAwB,CAAC,GAAGN,KAAK,CAACO,KAAK;AAE/C,MAAMC,OAAO,GAAG,IAAIL,YAAY,CAC9B,wDACF,CAAC;AAEDK,OAAO,CAACC,WAAW,CAAC,6CAA6C,CAAC,CAACC,MAAM;AACvE;AACA,OAAOC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EACvDA,OAAO,CAACC,wBAAwB,CAC9BN,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,QAAQ,EACRC,OAAO,EACPC,OACF,CAAC;EACD,IAAI,MAAMZ,SAAS,CAAC,CAAC,EAAE;IACrBF,YAAY,CACT,2DAA0DD,KAAK,CAACiB,QAAQ,CAAC,CAAE,MAC9E,CAAC;IACD,MAAMC,YAAY,GAAG,MAAMb,uBAAuB,CAAC,CAAC;IACpDa,YAAY,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACE,aAAa,CAACD,CAAC,CAAC,CAAC;IAC/CH,YAAY,CAACK,OAAO,CAAEC,IAAI,IAAK;MAC7BvB,YAAY,CAAE,GAAEuB,IAAK,EAAC,EAAE,MAAM,CAAC;IACjC,CAAC,CAAC;EACJ,CAAC,MAAM;IACLC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEDnB,OAAO,CAACoB,KAAK,CAAC,CAAC"}
|
|
@@ -18,7 +18,7 @@ async (host, realm, user, password, options, command) => {
|
|
|
18
18
|
const subjects = await listNonOAuth2AdminStaticUserMappings(options.showProtected);
|
|
19
19
|
subjects.sort((a, b) => a.localeCompare(b));
|
|
20
20
|
subjects.forEach(item => {
|
|
21
|
-
printMessage(`${item}
|
|
21
|
+
printMessage(`${item}`, 'data');
|
|
22
22
|
});
|
|
23
23
|
} else {
|
|
24
24
|
process.exitCode = 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-list-static-user-mappings.js","names":["frodo","Option","printMessage","FrodoCommand","getTokens","login","listNonOAuth2AdminStaticUserMappings","admin","program","description","addOption","default","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","subjects","showProtected","sort","a","b","localeCompare","forEach","item","process","exitCode","parse"],"sources":["../../../src/cli/admin/admin-list-static-user-mappings.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport { printMessage } from '../../utils/Console.js';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\nconst { listNonOAuth2AdminStaticUserMappings } = frodo.admin;\n\nconst program = new FrodoCommand('frodo admin list-static-user-mappings');\n\nprogram\n .description(\n 'List all subjects of static user mappings that are not oauth2 clients.'\n )\n .addOption(\n new Option('--show-protected', 'Show protected (system) subjects.').default(\n false,\n 'false'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n if (await getTokens()) {\n printMessage(\n 'Listing all non-oauth2 client subjects of static user mappings...'\n );\n const subjects = await listNonOAuth2AdminStaticUserMappings(\n options.showProtected\n );\n subjects.sort((a, b) => a.localeCompare(b));\n subjects.forEach((item) => {\n printMessage(`${item}
|
|
1
|
+
{"version":3,"file":"admin-list-static-user-mappings.js","names":["frodo","Option","printMessage","FrodoCommand","getTokens","login","listNonOAuth2AdminStaticUserMappings","admin","program","description","addOption","default","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","subjects","showProtected","sort","a","b","localeCompare","forEach","item","process","exitCode","parse"],"sources":["../../../src/cli/admin/admin-list-static-user-mappings.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport { printMessage } from '../../utils/Console.js';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\nconst { listNonOAuth2AdminStaticUserMappings } = frodo.admin;\n\nconst program = new FrodoCommand('frodo admin list-static-user-mappings');\n\nprogram\n .description(\n 'List all subjects of static user mappings that are not oauth2 clients.'\n )\n .addOption(\n new Option('--show-protected', 'Show protected (system) subjects.').default(\n false,\n 'false'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n if (await getTokens()) {\n printMessage(\n 'Listing all non-oauth2 client subjects of static user mappings...'\n );\n const subjects = await listNonOAuth2AdminStaticUserMappings(\n options.showProtected\n );\n subjects.sort((a, b) => a.localeCompare(b));\n subjects.forEach((item) => {\n printMessage(`${item}`, 'data');\n });\n } else {\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,SAASC,MAAM,QAAQ,WAAW;AAElC,SAASC,YAAY,QAAQ,wBAAwB;AACrD,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAM;EAAEC;AAAU,CAAC,GAAGJ,KAAK,CAACK,KAAK;AACjC,MAAM;EAAEC;AAAqC,CAAC,GAAGN,KAAK,CAACO,KAAK;AAE5D,MAAMC,OAAO,GAAG,IAAIL,YAAY,CAAC,uCAAuC,CAAC;AAEzEK,OAAO,CACJC,WAAW,CACV,wEACF,CAAC,CACAC,SAAS,CACR,IAAIT,MAAM,CAAC,kBAAkB,EAAE,mCAAmC,CAAC,CAACU,OAAO,CACzE,KAAK,EACL,OACF,CACF,CAAC,CACAC,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EACvDA,OAAO,CAACC,wBAAwB,CAC9BN,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,QAAQ,EACRC,OAAO,EACPC,OACF,CAAC;EACD,IAAI,MAAMd,SAAS,CAAC,CAAC,EAAE;IACrBF,YAAY,CACV,mEACF,CAAC;IACD,MAAMkB,QAAQ,GAAG,MAAMd,oCAAoC,CACzDW,OAAO,CAACI,aACV,CAAC;IACDD,QAAQ,CAACE,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACE,aAAa,CAACD,CAAC,CAAC,CAAC;IAC3CJ,QAAQ,CAACM,OAAO,CAAEC,IAAI,IAAK;MACzBzB,YAAY,CAAE,GAAEyB,IAAK,EAAC,EAAE,MAAM,CAAC;IACjC,CAAC,CAAC;EACJ,CAAC,MAAM;IACLC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEHrB,OAAO,CAACsB,KAAK,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { frodo } from '@rockcarver/frodo-lib';
|
|
2
2
|
import { Option } from 'commander';
|
|
3
|
-
import { deletePolicies, deletePoliciesByPolicySet,
|
|
3
|
+
import { deletePolicies, deletePoliciesByPolicySet, deletePolicyById } from '../../ops/PolicyOps';
|
|
4
4
|
import { printMessage, verboseMessage } from '../../utils/Console.js';
|
|
5
5
|
import { FrodoCommand } from '../FrodoCommand';
|
|
6
6
|
const {
|
|
@@ -14,7 +14,7 @@ async (host, realm, user, password, options, command) => {
|
|
|
14
14
|
// delete by id
|
|
15
15
|
if (options.policyId && (await getTokens())) {
|
|
16
16
|
verboseMessage('Deleting authorization policy...');
|
|
17
|
-
const outcome = await
|
|
17
|
+
const outcome = await deletePolicyById(options.policyId);
|
|
18
18
|
if (!outcome) process.exitCode = 1;
|
|
19
19
|
}
|
|
20
20
|
// --all -a by policy set
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authz-policy-delete.js","names":["frodo","Option","deletePolicies","deletePoliciesByPolicySet","
|
|
1
|
+
{"version":3,"file":"authz-policy-delete.js","names":["frodo","Option","deletePolicies","deletePoliciesByPolicySet","deletePolicyById","printMessage","verboseMessage","FrodoCommand","getTokens","login","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","policyId","outcome","process","exitCode","setId","all","help","parse"],"sources":["../../../src/cli/authz/authz-policy-delete.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport {\n deletePolicies,\n deletePoliciesByPolicySet,\n deletePolicyById,\n} from '../../ops/PolicyOps';\nimport { printMessage, verboseMessage } from '../../utils/Console.js';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\n\nconst program = new FrodoCommand('frodo authz policy delete');\n\nprogram\n .description('Delete authorization policies.')\n .addOption(\n new Option(\n '-i, --policy-id <policy-id>',\n 'Policy id/name. If specified, -a is ignored.'\n )\n )\n .addOption(\n new Option('-a, --all', 'Delete all policies in a realm. Ignored with -i.')\n )\n .addOption(\n new Option('--set-id <set-id>', 'Policy set id/name. Ignored with -i.')\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n // delete by id\n if (options.policyId && (await getTokens())) {\n verboseMessage('Deleting authorization policy...');\n const outcome = await deletePolicyById(options.policyId);\n if (!outcome) process.exitCode = 1;\n }\n // --all -a by policy set\n else if (options.setId && options.all && (await getTokens())) {\n verboseMessage(\n `Deleting all authorization policies in policy set ${options.setId}...`\n );\n const outcome = await deletePoliciesByPolicySet(options.setId);\n if (!outcome) process.exitCode = 1;\n }\n // --all -a\n else if (options.all && (await getTokens())) {\n verboseMessage('Deleting all authorization policies...');\n const outcome = await deletePolicies();\n if (!outcome) process.exitCode = 1;\n }\n // unrecognized combination of options or no options\n else {\n printMessage('Unrecognized combination of options or no options...');\n program.help();\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,SAASC,MAAM,QAAQ,WAAW;AAElC,SACEC,cAAc,EACdC,yBAAyB,EACzBC,gBAAgB,QACX,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GAAG,CAAC;EACpC;EACA;EAAA,KACK,IAAIN,OAAO,CAACQ,GAAG,KAAK,MAAMlB,SAAS,CAAC,CAAC,CAAC,EAAE;IAC3CF,cAAc,CAAC,wCAAwC,CAAC;IACxD,MAAMgB,OAAO,GAAG,MAAMpB,cAAc,CAAC,CAAC;IACtC,IAAI,CAACoB,OAAO,EAAEC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC;EACA;EAAA,KACK;IACHnB,YAAY,CAAC,sDAAsD,CAAC;IACpEK,OAAO,CAACiB,IAAI,CAAC,CAAC;IACdJ,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEHd,OAAO,CAACkB,KAAK,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { frodo } from '@rockcarver/frodo-lib';
|
|
2
2
|
import { Option } from 'commander';
|
|
3
|
-
import {
|
|
3
|
+
import { deletePolicySetById, deletePolicySets } from '../../ops/PolicySetOps';
|
|
4
4
|
import { printMessage, verboseMessage } from '../../utils/Console.js';
|
|
5
5
|
import { FrodoCommand } from '../FrodoCommand';
|
|
6
6
|
const {
|
|
@@ -14,7 +14,7 @@ async (host, realm, user, password, options, command) => {
|
|
|
14
14
|
// delete by id
|
|
15
15
|
if (options.setId && (await getTokens())) {
|
|
16
16
|
verboseMessage('Deleting authorization policy set...');
|
|
17
|
-
const outcome =
|
|
17
|
+
const outcome = deletePolicySetById(options.setId);
|
|
18
18
|
if (!outcome) process.exitCode = 1;
|
|
19
19
|
}
|
|
20
20
|
// --all -a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authz-set-delete.js","names":["frodo","Option","
|
|
1
|
+
{"version":3,"file":"authz-set-delete.js","names":["frodo","Option","deletePolicySetById","deletePolicySets","printMessage","verboseMessage","FrodoCommand","getTokens","login","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","setId","outcome","process","exitCode","all","help","parse"],"sources":["../../../src/cli/authz/authz-set-delete.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport { deletePolicySetById, deletePolicySets } from '../../ops/PolicySetOps';\nimport { printMessage, verboseMessage } from '../../utils/Console.js';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\n\nconst program = new FrodoCommand('frodo authz set delete');\n\nprogram\n .description('Delete authorization policy sets.')\n .addOption(new Option('-i, --set-id <set-id>', 'Policy set id/name.'))\n .addOption(\n new Option(\n '-a, --all',\n 'Delete all policy sets in a realm. Ignored with -i.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n // delete by id\n if (options.setId && (await getTokens())) {\n verboseMessage('Deleting authorization policy set...');\n const outcome = deletePolicySetById(options.setId);\n if (!outcome) process.exitCode = 1;\n }\n // --all -a\n else if (options.all && (await getTokens())) {\n verboseMessage('Deleting all authorization policy sets...');\n const outcome = deletePolicySets();\n if (!outcome) process.exitCode = 1;\n }\n // unrecognized combination of options or no options\n else {\n printMessage('Unrecognized combination of options or no options...');\n program.help();\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,SAASC,MAAM,QAAQ,WAAW;AAElC,SAASC,mBAAmB,EAAEC,gBAAgB,QAAQ,wBAAwB;AAC9E,SAASC,YAAY,EAAEC,cAAc,QAAQ,wBAAwB;AACrE,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAM;EAAEC;AAAU,CAAC,GAAGP,KAAK,CAACQ,KAAK;AAEjC,MAAMC,OAAO,GAAG,IAAIH,YAAY,CAAC,wBAAwB,CAAC;AAE1DG,OAAO,CACJC,WAAW,CAAC,mCAAmC,CAAC,CAChDC,SAAS,CAAC,IAAIV,MAAM,CAAC,uBAAuB,EAAE,qBAAqB,CAAC,CAAC,CACrEU,SAAS,CACR,IAAIV,MAAM,CACR,WAAW,EACX,qDACF,CACF,CAAC,CACAW,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EACvDA,OAAO,CAACC,wBAAwB,CAC9BN,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,QAAQ,EACRC,OAAO,EACPC,OACF,CAAC;EACD;EACA,IAAID,OAAO,CAACG,KAAK,KAAK,MAAMb,SAAS,CAAC,CAAC,CAAC,EAAE;IACxCF,cAAc,CAAC,sCAAsC,CAAC;IACtD,MAAMgB,OAAO,GAAGnB,mBAAmB,CAACe,OAAO,CAACG,KAAK,CAAC;IAClD,IAAI,CAACC,OAAO,EAAEC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC;EACA;EAAA,KACK,IAAIN,OAAO,CAACO,GAAG,KAAK,MAAMjB,SAAS,CAAC,CAAC,CAAC,EAAE;IAC3CF,cAAc,CAAC,2CAA2C,CAAC;IAC3D,MAAMgB,OAAO,GAAGlB,gBAAgB,CAAC,CAAC;IAClC,IAAI,CAACkB,OAAO,EAAEC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC;EACA;EAAA,KACK;IACHnB,YAAY,CAAC,sDAAsD,CAAC;IACpEK,OAAO,CAACgB,IAAI,CAAC,CAAC;IACdH,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEHd,OAAO,CAACiB,KAAK,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { frodo } from '@rockcarver/frodo-lib';
|
|
2
2
|
import { Option } from 'commander';
|
|
3
|
-
import {
|
|
3
|
+
import { deleteResourceTypeById, deleteResourceTypes, deleteResourceTypeUsingName } from '../../ops/ResourceTypeOps';
|
|
4
4
|
import { printMessage, verboseMessage } from '../../utils/Console.js';
|
|
5
5
|
import { FrodoCommand } from '../FrodoCommand';
|
|
6
6
|
const {
|
|
@@ -14,13 +14,13 @@ async (host, realm, user, password, options, command) => {
|
|
|
14
14
|
// delete by uuid
|
|
15
15
|
if (options.typeId && (await getTokens())) {
|
|
16
16
|
verboseMessage('Deleting authorization resource type...');
|
|
17
|
-
const outcome =
|
|
17
|
+
const outcome = deleteResourceTypeById(options.typeId);
|
|
18
18
|
if (!outcome) process.exitCode = 1;
|
|
19
19
|
}
|
|
20
20
|
// delete by name
|
|
21
21
|
else if (options.typeName && (await getTokens())) {
|
|
22
22
|
verboseMessage('Deleting authorization resource type...');
|
|
23
|
-
const outcome =
|
|
23
|
+
const outcome = deleteResourceTypeUsingName(options.typeName);
|
|
24
24
|
if (!outcome) process.exitCode = 1;
|
|
25
25
|
}
|
|
26
26
|
// --all -a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authz-type-delete.js","names":["frodo","Option","
|
|
1
|
+
{"version":3,"file":"authz-type-delete.js","names":["frodo","Option","deleteResourceTypeById","deleteResourceTypes","deleteResourceTypeUsingName","printMessage","verboseMessage","FrodoCommand","getTokens","login","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","typeId","outcome","process","exitCode","typeName","all","help","parse"],"sources":["../../../src/cli/authz/authz-type-delete.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport {\n deleteResourceTypeById,\n deleteResourceTypes,\n deleteResourceTypeUsingName,\n} from '../../ops/ResourceTypeOps';\nimport { printMessage, verboseMessage } from '../../utils/Console.js';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\n\nconst program = new FrodoCommand('frodo authz type delete');\n\nprogram\n .description('Delete authorization resource types.')\n .addOption(\n new Option(\n '-i, --type-id <type-id>',\n 'Variable id. If specified, -a is ignored.'\n )\n )\n .addOption(\n new Option(\n '-n, --type-name <type-name>',\n 'Resource type name. If specified, -a is ignored.'\n )\n )\n .addOption(\n new Option(\n '-a, --all',\n 'Delete all resource types in a realm. Ignored with -i and -n.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n // delete by uuid\n if (options.typeId && (await getTokens())) {\n verboseMessage('Deleting authorization resource type...');\n const outcome = deleteResourceTypeById(options.typeId);\n if (!outcome) process.exitCode = 1;\n }\n // delete by name\n else if (options.typeName && (await getTokens())) {\n verboseMessage('Deleting authorization resource type...');\n const outcome = deleteResourceTypeUsingName(options.typeName);\n if (!outcome) process.exitCode = 1;\n }\n // --all -a\n else if (options.all && (await getTokens())) {\n verboseMessage('Deleting all authorization resource types...');\n const outcome = deleteResourceTypes();\n if (!outcome) process.exitCode = 1;\n }\n // unrecognized combination of options or no options\n else {\n printMessage('Unrecognized combination of options or no options...');\n program.help();\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,SAASC,MAAM,QAAQ,WAAW;AAElC,SACEC,sBAAsB,EACtBC,mBAAmB,EACnBC,2BAA2B,QACtB,2BAA2B;AAClC,SAASC,YAAY,EAAEC,cAAc,QAAQ,wBAAwB;AACrE,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAM;EAAEC;AAAU,CAAC,GAAGR,KAAK,CAACS,KAAK;AAEjC,MAAMC,OAAO,GAAG,IAAIH,YAAY,CAAC,yBAAyB,CAAC;AAE3DG,OAAO,CACJC,WAAW,CAAC,sCAAsC,CAAC,CACnDC,SAAS,CACR,IAAIX,MAAM,CACR,yBAAyB,EACzB,2CACF,CACF,CAAC,CACAW,SAAS,CACR,IAAIX,MAAM,CACR,6BAA6B,EAC7B,kDACF,CACF,CAAC,CACAW,SAAS,CACR,IAAIX,MAAM,CACR,WAAW,EACX,+DACF,CACF,CAAC,CACAY,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,KA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
+
import { deleteVariableById, deleteVariables } from '../../ops/VariablesOps';
|
|
4
4
|
import { printMessage, verboseMessage } from '../../utils/Console.js';
|
|
5
5
|
import { FrodoCommand } from '../FrodoCommand';
|
|
6
6
|
const {
|
|
@@ -14,7 +14,7 @@ async (host, realm, user, password, options, command) => {
|
|
|
14
14
|
// delete by id
|
|
15
15
|
if (options.variableId && (await getTokens())) {
|
|
16
16
|
verboseMessage('Deleting variable...');
|
|
17
|
-
|
|
17
|
+
deleteVariableById(options.variableId);
|
|
18
18
|
}
|
|
19
19
|
// --all -a
|
|
20
20
|
else if (options.all && (await getTokens())) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"esv-variable-delete.js","names":["frodo","Option","
|
|
1
|
+
{"version":3,"file":"esv-variable-delete.js","names":["frodo","Option","deleteVariableById","deleteVariables","printMessage","verboseMessage","FrodoCommand","getTokens","login","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","variableId","all","help","process","exitCode","parse"],"sources":["../../../src/cli/esv/esv-variable-delete.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport { deleteVariableById, deleteVariables } from '../../ops/VariablesOps';\nimport { printMessage, verboseMessage } from '../../utils/Console.js';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\n\nconst program = new FrodoCommand('frodo cmd sub2 delete');\n\nprogram\n .description('Delete variables.')\n .addOption(\n new Option(\n '-i, --variable-id <variable-id>',\n 'Variable id. If specified, -a is ignored.'\n )\n )\n .addOption(\n new Option('-a, --all', 'Delete all variable in a realm. Ignored with -i.')\n )\n .addOption(\n new Option(\n '--no-deep',\n 'No deep delete. This leaves orphaned configuration artifacts behind.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n // delete by id\n if (options.variableId && (await getTokens())) {\n verboseMessage('Deleting variable...');\n deleteVariableById(options.variableId);\n }\n // --all -a\n else if (options.all && (await getTokens())) {\n verboseMessage('Deleting all variables...');\n deleteVariables();\n }\n // unrecognized combination of options or no options\n else {\n printMessage('Unrecognized combination of options or no options...');\n program.help();\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,SAASC,MAAM,QAAQ,WAAW;AAElC,SAASC,kBAAkB,EAAEC,eAAe,QAAQ,wBAAwB;AAC5E,SAASC,YAAY,EAAEC,cAAc,QAAQ,wBAAwB;AACrE,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAM;EAAEC;AAAU,CAAC,GAAGP,KAAK,CAACQ,KAAK;AAEjC,MAAMC,OAAO,GAAG,IAAIH,YAAY,CAAC,uBAAuB,CAAC;AAEzDG,OAAO,CACJC,WAAW,CAAC,mBAAmB,CAAC,CAChCC,SAAS,CACR,IAAIV,MAAM,CACR,iCAAiC,EACjC,2CACF,CACF,CAAC,CACAU,SAAS,CACR,IAAIV,MAAM,CAAC,WAAW,EAAE,kDAAkD,CAC5E,CAAC,CACAU,SAAS,CACR,IAAIV,MAAM,CACR,WAAW,EACX,sEACF,CACF,CAAC,CACAW,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EACvDA,OAAO,CAACC,wBAAwB,CAC9BN,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,QAAQ,EACRC,OAAO,EACPC,OACF,CAAC;EACD;EACA,IAAID,OAAO,CAACG,UAAU,KAAK,MAAMb,SAAS,CAAC,CAAC,CAAC,EAAE;IAC7CF,cAAc,CAAC,sBAAsB,CAAC;IACtCH,kBAAkB,CAACe,OAAO,CAACG,UAAU,CAAC;EACxC;EACA;EAAA,KACK,IAAIH,OAAO,CAACI,GAAG,KAAK,MAAMd,SAAS,CAAC,CAAC,CAAC,EAAE;IAC3CF,cAAc,CAAC,2BAA2B,CAAC;IAC3CF,eAAe,CAAC,CAAC;EACnB;EACA;EAAA,KACK;IACHC,YAAY,CAAC,sDAAsD,CAAC;IACpEK,OAAO,CAACa,IAAI,CAAC,CAAC;IACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEHf,OAAO,CAACgB,KAAK,CAAC,CAAC"}
|
|
@@ -18,6 +18,7 @@ program.description('If -h is supplied, describe the journey/tree indicated by -
|
|
|
18
18
|
// implement command logic inside action handler
|
|
19
19
|
async (host, realm, user, password, options, command) => {
|
|
20
20
|
command.handleDefaultArgsAndOpts(host, realm, user, password, options, command);
|
|
21
|
+
host = host ? host : state.getHost();
|
|
21
22
|
if (options.outputFile) state.setOutputFile(options.outputFile);
|
|
22
23
|
// TODO: review checks for arguments
|
|
23
24
|
if (typeof host === 'undefined' || typeof options.file !== 'undefined') {
|