@rockcarver/frodo-cli 2.0.0-4 → 2.0.0-6
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 +39 -1
- package/esm/app.js +2 -2
- package/esm/app.js.map +1 -1
- package/esm/cli/admin/admin-federation-export.js +42 -0
- package/esm/cli/admin/admin-federation-export.js.map +1 -0
- package/esm/cli/admin/admin-federation-import.js +46 -0
- package/esm/cli/admin/admin-federation-import.js.map +1 -0
- package/esm/cli/admin/admin-federation-list.js +26 -0
- package/esm/cli/admin/admin-federation-list.js.map +1 -0
- package/esm/cli/admin/admin-federation.js +13 -0
- package/esm/cli/admin/admin-federation.js.map +1 -0
- package/esm/cli/admin/admin.js +1 -0
- package/esm/cli/admin/admin.js.map +1 -1
- package/esm/cli/conn/conn-save.js +6 -3
- package/esm/cli/conn/conn-save.js.map +1 -1
- package/esm/cli/info/info.js +2 -3
- package/esm/cli/info/info.js.map +1 -1
- package/esm/cli/{logging/logs-fetch.js → log/log-fetch.js} +3 -3
- package/esm/cli/log/log-fetch.js.map +1 -0
- package/esm/cli/log/log-key-delete.js +32 -0
- package/esm/cli/log/log-key-delete.js.map +1 -0
- package/esm/cli/log/log-key-describe.js +19 -0
- package/esm/cli/log/log-key-describe.js.map +1 -0
- package/esm/cli/log/log-key-list.js +23 -0
- package/esm/cli/log/log-key-list.js.map +1 -0
- package/esm/cli/log/log-key.js +8 -0
- package/esm/cli/log/log-key.js.map +1 -0
- package/esm/cli/{logging/logs-list.js → log/log-list.js} +2 -2
- package/esm/cli/log/log-list.js.map +1 -0
- package/esm/cli/{logging/logs-tail.js → log/log-tail.js} +3 -3
- package/esm/cli/log/log-tail.js.map +1 -0
- package/esm/cli/{logging/logs.js → log/log.js} +5 -2
- package/esm/cli/log/log.js.map +1 -0
- package/esm/help/SampleData.js +7 -0
- package/esm/help/SampleData.js.map +1 -0
- package/esm/ops/AdminFederationOps.js +208 -0
- package/esm/ops/AdminFederationOps.js.map +1 -0
- package/esm/ops/IdpOps.js +22 -10
- package/esm/ops/IdpOps.js.map +1 -1
- package/esm/ops/LogOps.js +77 -25
- package/esm/ops/LogOps.js.map +1 -1
- package/esm/ops/OAuth2ClientOps.js +1 -1
- package/esm/ops/OAuth2ClientOps.js.map +1 -1
- package/esm/ops/RealmOps.js +6 -4
- package/esm/ops/RealmOps.js.map +1 -1
- package/package.json +2 -2
- package/esm/cli/logging/logs-fetch.js.map +0 -1
- package/esm/cli/logging/logs-list.js.map +0 -1
- package/esm/cli/logging/logs-tail.js.map +0 -1
- package/esm/cli/logging/logs.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,40 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [2.0.0-6] - 2023-06-22
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- \#251: Support for Identity Cloud admin federation configuration:
|
|
15
|
+
|
|
16
|
+
- `frodo admin federation` Manage admin federation configuration.
|
|
17
|
+
- `export` Export admin federation providers.
|
|
18
|
+
- `import` Import admin federation providers.
|
|
19
|
+
- `list` List admin federation providers.
|
|
20
|
+
|
|
21
|
+
Examples:
|
|
22
|
+
|
|
23
|
+
- List all configured admin federation providers:<br>
|
|
24
|
+
`frodo admin federation list <myTenant>`
|
|
25
|
+
|
|
26
|
+
`frodo admin federation list <myTenant> <username> <password>`
|
|
27
|
+
- Export all admin federation providers to a single file:<br>
|
|
28
|
+
`frodo admin federation export -a <myTenant>`
|
|
29
|
+
|
|
30
|
+
`frodo admin federation export -a <myTenant> <username> <password>`
|
|
31
|
+
- Import all admin federation providers from a single file:<br>
|
|
32
|
+
`frodo admin federation import -a -f allProviders.admin.federation.json <myTenant>`
|
|
33
|
+
|
|
34
|
+
`frodo admin federation import -a -f allProviders.admin.federation.json <myTenant> <username> <password>`<br>
|
|
35
|
+
|
|
36
|
+
**_Note_**: Only tenant admins can perform admin federation operations, service accounts do not have the required privileges. Therefore, the connection profile used must contain username and password or they must be provided through command arguments.
|
|
37
|
+
|
|
38
|
+
### Changed
|
|
39
|
+
|
|
40
|
+
- Update to frodo-lib 2.0.0-8
|
|
41
|
+
|
|
42
|
+
## [2.0.0-5] - 2023-06-21
|
|
43
|
+
|
|
10
44
|
## [2.0.0-4] - 2023-06-16
|
|
11
45
|
|
|
12
46
|
## [2.0.0-3] - 2023-06-15
|
|
@@ -1208,7 +1242,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
1208
1242
|
- Fixed problem with adding connection profiles
|
|
1209
1243
|
- Miscellaneous bug fixes
|
|
1210
1244
|
|
|
1211
|
-
[Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-
|
|
1245
|
+
[Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-6...HEAD
|
|
1246
|
+
|
|
1247
|
+
[2.0.0-6]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-5...v2.0.0-6
|
|
1248
|
+
|
|
1249
|
+
[2.0.0-5]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-4...v2.0.0-5
|
|
1212
1250
|
|
|
1213
1251
|
[2.0.0-4]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-3...v2.0.0-4
|
|
1214
1252
|
|
package/esm/app.js
CHANGED
|
@@ -13,7 +13,7 @@ import idm from './cli/idm/idm';
|
|
|
13
13
|
import idp from './cli/idp/idp';
|
|
14
14
|
import info from './cli/info/info';
|
|
15
15
|
import journey from './cli/journey/journey';
|
|
16
|
-
import
|
|
16
|
+
import log from './cli/log/log';
|
|
17
17
|
import realm from './cli/realm/realm';
|
|
18
18
|
import saml from './cli/saml/saml';
|
|
19
19
|
import script from './cli/script/script';
|
|
@@ -39,7 +39,7 @@ import { getVersions } from './utils/Version';
|
|
|
39
39
|
program.addCommand(idp());
|
|
40
40
|
program.addCommand(info());
|
|
41
41
|
program.addCommand(journey());
|
|
42
|
-
program.addCommand(
|
|
42
|
+
program.addCommand(log());
|
|
43
43
|
program.addCommand(realm());
|
|
44
44
|
program.addCommand(saml());
|
|
45
45
|
program.addCommand(script());
|
package/esm/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","names":["frodo","Command","admin","agent","authz","app","conn","email","esv","idm","idp","info","journey","
|
|
1
|
+
{"version":3,"file":"app.js","names":["frodo","Command","admin","agent","authz","app","conn","email","esv","idm","idp","info","journey","log","realm","saml","script","service","theme","printMessage","getVersions","program","version","initConnectionProfiles","addCommand","showHelpAfterError","enablePositionalOptions","parse","e"],"sources":["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 authz from './cli/authz/authz';\nimport app from './cli/app/app';\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 realm from './cli/realm/realm';\nimport saml from './cli/saml/saml';\nimport script from './cli/script/script';\nimport service from './cli/service/service';\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\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 frodo.conn.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(realm());\n program.addCommand(saml());\n program.addCommand(script());\n program.addCommand(service());\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 printMessage(`ERROR: exception running frodo - ${e}`, '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,KAAK,MAAM,mBAAmB;AACrC,OAAOC,GAAG,MAAM,eAAe;AAC/B,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,IAAI,MAAM,iBAAiB;AAClC,OAAOC,MAAM,MAAM,qBAAqB;AACxC,OAAOC,OAAO,MAAM,uBAAuB;AAC3C;AACA;AACA,OAAOC,KAAK,MAAM,mBAAmB;AACrC,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,WAAW,QAAQ,iBAAiB;AAE7C,CAAC,YAAY;EACX,IAAI;IACF,MAAMC,OAAO,GAAG,IAAIpB,OAAO,CAAC,OAAO,CAAC,CAACqB,OAAO,CAC1C,MAAMF,WAAW,CAAC,KAAK,CAAC,EACxB,eACF,CAAC;IAEDD,YAAY,CAAC,MAAMC,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC;IAEpD,MAAMpB,KAAK,CAACM,IAAI,CAACiB,sBAAsB,CAAC,CAAC;IAEzCF,OAAO,CAACG,UAAU,CAACtB,KAAK,CAAC,CAAC,CA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/frodo-lib';
|
|
2
|
+
import { FrodoCommand } from '../FrodoCommand';
|
|
3
|
+
import { Option } from 'commander';
|
|
4
|
+
import { printMessage, verboseMessage } from '../../utils/Console';
|
|
5
|
+
import { exportAdminFederationProviderToFile, exportAdminFederationProvidersToFile, exportAdminFederationProvidersToFiles } from '../../ops/AdminFederationOps';
|
|
6
|
+
const program = new FrodoCommand('frodo admin federation export', ['realm']);
|
|
7
|
+
program.description('Export admin federation providers.').addOption(new Option('-i, --idp-id <idp-id>', 'Id/name of a provider. If specified, -a and -A are ignored.')).addOption(new Option('-f, --file [file]', 'Name of the file to write the exported provider(s) to. Ignored with -A.')).addOption(new Option('-a, --all', 'Export all the providers to a single file. Ignored with -t and -i.')).addOption(new Option('-A, --all-separate', 'Export all the providers as separate files <provider name>.admin.federation.json. Ignored with -t, -i, and -a.')).action(
|
|
8
|
+
// implement command logic inside action handler
|
|
9
|
+
async (host, user, password, options, command) => {
|
|
10
|
+
command.handleDefaultArgsAndOpts(host, user, password, options, command);
|
|
11
|
+
if (await frodo.login.getTokens(true)) {
|
|
12
|
+
// export by id/name
|
|
13
|
+
if (options.idpId) {
|
|
14
|
+
verboseMessage(`Exporting provider "${options.idpId}...`);
|
|
15
|
+
const outcome = await exportAdminFederationProviderToFile(options.idpId, options.file);
|
|
16
|
+
if (!outcome) process.exitCode = 1;
|
|
17
|
+
}
|
|
18
|
+
// --all -a
|
|
19
|
+
else if (options.all) {
|
|
20
|
+
verboseMessage('Exporting all providers to a single file...');
|
|
21
|
+
const outcome = await exportAdminFederationProvidersToFile(options.file);
|
|
22
|
+
if (!outcome) process.exitCode = 1;
|
|
23
|
+
}
|
|
24
|
+
// --all-separate -A
|
|
25
|
+
else if (options.allSeparate) {
|
|
26
|
+
verboseMessage('Exporting all providers to separate files...');
|
|
27
|
+
const outcome = await exportAdminFederationProvidersToFiles();
|
|
28
|
+
if (!outcome) process.exitCode = 1;
|
|
29
|
+
}
|
|
30
|
+
// unrecognized combination of options or no options
|
|
31
|
+
else {
|
|
32
|
+
printMessage('Unrecognized combination of options or no options...', 'error');
|
|
33
|
+
program.help();
|
|
34
|
+
process.exitCode = 1;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// end command logic inside action handler
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
program.parse();
|
|
42
|
+
//# sourceMappingURL=admin-federation-export.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-federation-export.js","names":["frodo","FrodoCommand","Option","printMessage","verboseMessage","exportAdminFederationProviderToFile","exportAdminFederationProvidersToFile","exportAdminFederationProvidersToFiles","program","description","addOption","action","host","user","password","options","command","handleDefaultArgsAndOpts","login","getTokens","idpId","outcome","file","process","exitCode","all","allSeparate","help","parse"],"sources":["cli/admin/admin-federation-export.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport {\n exportAdminFederationProviderToFile,\n exportAdminFederationProvidersToFile,\n exportAdminFederationProvidersToFiles,\n} from '../../ops/AdminFederationOps';\n\nconst program = new FrodoCommand('frodo admin federation export', ['realm']);\n\nprogram\n .description('Export admin federation providers.')\n .addOption(\n new Option(\n '-i, --idp-id <idp-id>',\n 'Id/name of a provider. If specified, -a and -A are ignored.'\n )\n )\n .addOption(\n new Option(\n '-f, --file [file]',\n 'Name of the file to write the exported provider(s) to. Ignored with -A.'\n )\n )\n .addOption(\n new Option(\n '-a, --all',\n 'Export all the providers to a single file. Ignored with -t and -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Export all the providers as separate files <provider name>.admin.federation.json. Ignored with -t, -i, and -a.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(host, user, password, options, command);\n if (await frodo.login.getTokens(true)) {\n // export by id/name\n if (options.idpId) {\n verboseMessage(`Exporting provider \"${options.idpId}...`);\n const outcome = await exportAdminFederationProviderToFile(\n options.idpId,\n options.file\n );\n if (!outcome) process.exitCode = 1;\n }\n // --all -a\n else if (options.all) {\n verboseMessage('Exporting all providers to a single file...');\n const outcome = await exportAdminFederationProvidersToFile(\n options.file\n );\n if (!outcome) process.exitCode = 1;\n }\n // --all-separate -A\n else if (options.allSeparate) {\n verboseMessage('Exporting all providers to separate files...');\n const outcome = await exportAdminFederationProvidersToFiles();\n if (!outcome) process.exitCode = 1;\n }\n // unrecognized combination of options or no options\n else {\n printMessage(\n 'Unrecognized combination of options or no options...',\n 'error'\n );\n program.help();\n process.exitCode = 1;\n }\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SACEC,mCAAmC,EACnCC,oCAAoC,EACpCC,qCAAqC,QAChC,8BAA8B;AAErC,MAAMC,OAAO,GAAG,IAAIP,YAAY,CAAC,+BAA+B,EAAE,CAAC,OAAO,CAAC,CAAC;AAE5EO,OAAO,CACJC,WAAW,CAAC,oCAAoC,CAAC,CACjDC,SAAS,CACR,IAAIR,MAAM,CACR,uBAAuB,EACvB,6DACF,CACF,CAAC,CACAQ,SAAS,CACR,IAAIR,MAAM,CACR,mBAAmB,EACnB,yEACF,CACF,CAAC,CACAQ,SAAS,CACR,IAAIR,MAAM,CACR,WAAW,EACX,oEACF,CACF,CAAC,CACAQ,SAAS,CACR,IAAIR,MAAM,CACR,oBAAoB,EACpB,gHACF,CACF,CAAC,CACAS,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EAChDA,OAAO,CAACC,wBAAwB,CAACL,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,CAAC;EACxE,IAAI,MAAMhB,KAAK,CAACkB,KAAK,CAACC,SAAS,CAAC,IAAI,CAAC,EAAE;IACrC;IACA,IAAIJ,OAAO,CAACK,KAAK,EAAE;MACjBhB,cAAc,CAAE,uBAAsBW,OAAO,CAACK,KAAM,KAAI,CAAC;MACzD,MAAMC,OAAO,GAAG,MAAMhB,mCAAmC,CACvDU,OAAO,CAACK,KAAK,EACbL,OAAO,CAACO,IACV,CAAC;MACD,IAAI,CAACD,OAAO,EAAEE,OAAO,CAACC,QAAQ,GAAG,CAAC;IACpC;IACA;IAAA,KACK,IAAIT,OAAO,CAACU,GAAG,EAAE;MACpBrB,cAAc,CAAC,6CAA6C,CAAC;MAC7D,MAAMiB,OAAO,GAAG,MAAMf,oCAAoC,CACxDS,OAAO,CAACO,IACV,CAAC;MACD,IAAI,CAACD,OAAO,EAAEE,OAAO,CAACC,QAAQ,GAAG,CAAC;IACpC;IACA;IAAA,KACK,IAAIT,OAAO,CAACW,WAAW,EAAE;MAC5BtB,cAAc,CAAC,8CAA8C,CAAC;MAC9D,MAAMiB,OAAO,GAAG,MAAMd,qCAAqC,CAAC,CAAC;MAC7D,IAAI,CAACc,OAAO,EAAEE,OAAO,CAACC,QAAQ,GAAG,CAAC;IACpC;IACA;IAAA,KACK;MACHrB,YAAY,CACV,sDAAsD,EACtD,OACF,CAAC;MACDK,OAAO,CAACmB,IAAI,CAAC,CAAC;MACdJ,OAAO,CAACC,QAAQ,GAAG,CAAC;IACtB;EACF;AACF;AACA;AACF,CAAC;;AAEHhB,OAAO,CAACoB,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { frodo } from '@rockcarver/frodo-lib';
|
|
2
|
+
import { FrodoCommand } from '../FrodoCommand';
|
|
3
|
+
import { Option } from 'commander';
|
|
4
|
+
import { printMessage, verboseMessage } from '../../utils/Console';
|
|
5
|
+
import { importAdminFederationProviderFromFile, importAdminFederationProvidersFromFile, importAdminFederationProvidersFromFiles, importFirstAdminFederationProviderFromFile } from '../../ops/AdminFederationOps';
|
|
6
|
+
const program = new FrodoCommand('frodo admin federation import', ['realm']);
|
|
7
|
+
program.description('Import admin federation providers.').addOption(new Option('-i, --idp-id <id>', 'Provider id. If specified, -a and -A are ignored.')).addOption(new Option('-f, --file <file>', 'Name of the file to import the provider(s) from.')).addOption(new Option('-a, --all', 'Import all the providers from single file. Ignored with -t or -i.')).addOption(new Option('-A, --all-separate', 'Import all the providers from separate files (*.admin.federation.json) in the current directory. Ignored with -t or -i or -a.')).action(
|
|
8
|
+
// implement command logic inside action handler
|
|
9
|
+
async (host, user, password, options, command) => {
|
|
10
|
+
command.handleDefaultArgsAndOpts(host, user, password, options, command);
|
|
11
|
+
// import by id
|
|
12
|
+
if (options.file && options.idpId && (await frodo.login.getTokens(true))) {
|
|
13
|
+
verboseMessage(`Importing provider "${options.idpId}"...`);
|
|
14
|
+
const outcome = await importAdminFederationProviderFromFile(options.idpId, options.file);
|
|
15
|
+
if (!outcome) process.exitCode = 1;
|
|
16
|
+
}
|
|
17
|
+
// --all -a
|
|
18
|
+
else if (options.all && options.file && (await frodo.login.getTokens(true))) {
|
|
19
|
+
verboseMessage(`Importing all providers from a single file (${options.file})...`);
|
|
20
|
+
const outcome = await importAdminFederationProvidersFromFile(options.file);
|
|
21
|
+
if (!outcome) process.exitCode = 1;
|
|
22
|
+
}
|
|
23
|
+
// --all-separate -A
|
|
24
|
+
else if (options.allSeparate && !options.file && (await frodo.login.getTokens(true))) {
|
|
25
|
+
verboseMessage('Importing all providers from separate files in current directory...');
|
|
26
|
+
const outcome = await importAdminFederationProvidersFromFiles();
|
|
27
|
+
if (!outcome) process.exitCode = 1;
|
|
28
|
+
}
|
|
29
|
+
// import first provider from file
|
|
30
|
+
else if (options.file && (await frodo.login.getTokens(true))) {
|
|
31
|
+
verboseMessage(`Importing first provider from file "${options.file}"...`);
|
|
32
|
+
const outcome = await importFirstAdminFederationProviderFromFile(options.file);
|
|
33
|
+
if (!outcome) process.exitCode = 1;
|
|
34
|
+
}
|
|
35
|
+
// unrecognized combination of options or no options
|
|
36
|
+
else {
|
|
37
|
+
printMessage('Unrecognized combination of options or no options...');
|
|
38
|
+
program.help();
|
|
39
|
+
process.exitCode = 1;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// end command logic inside action handler
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
program.parse();
|
|
46
|
+
//# sourceMappingURL=admin-federation-import.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-federation-import.js","names":["frodo","FrodoCommand","Option","printMessage","verboseMessage","importAdminFederationProviderFromFile","importAdminFederationProvidersFromFile","importAdminFederationProvidersFromFiles","importFirstAdminFederationProviderFromFile","program","description","addOption","action","host","user","password","options","command","handleDefaultArgsAndOpts","file","idpId","login","getTokens","outcome","process","exitCode","all","allSeparate","help","parse"],"sources":["cli/admin/admin-federation-import.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport {\n importAdminFederationProviderFromFile,\n importAdminFederationProvidersFromFile,\n importAdminFederationProvidersFromFiles,\n importFirstAdminFederationProviderFromFile,\n} from '../../ops/AdminFederationOps';\n\nconst program = new FrodoCommand('frodo admin federation import', ['realm']);\n\nprogram\n .description('Import admin federation providers.')\n .addOption(\n new Option(\n '-i, --idp-id <id>',\n 'Provider id. If specified, -a and -A are ignored.'\n )\n )\n .addOption(\n new Option(\n '-f, --file <file>',\n 'Name of the file to import the provider(s) from.'\n )\n )\n .addOption(\n new Option(\n '-a, --all',\n 'Import all the providers from single file. Ignored with -t or -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Import all the providers from separate files (*.admin.federation.json) in the current directory. Ignored with -t or -i or -a.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(host, user, password, options, command);\n // import by id\n if (\n options.file &&\n options.idpId &&\n (await frodo.login.getTokens(true))\n ) {\n verboseMessage(`Importing provider \"${options.idpId}\"...`);\n const outcome = await importAdminFederationProviderFromFile(\n options.idpId,\n options.file\n );\n if (!outcome) process.exitCode = 1;\n }\n // --all -a\n else if (\n options.all &&\n options.file &&\n (await frodo.login.getTokens(true))\n ) {\n verboseMessage(\n `Importing all providers from a single file (${options.file})...`\n );\n const outcome = await importAdminFederationProvidersFromFile(\n options.file\n );\n if (!outcome) process.exitCode = 1;\n }\n // --all-separate -A\n else if (\n options.allSeparate &&\n !options.file &&\n (await frodo.login.getTokens(true))\n ) {\n verboseMessage(\n 'Importing all providers from separate files in current directory...'\n );\n const outcome = await importAdminFederationProvidersFromFiles();\n if (!outcome) process.exitCode = 1;\n }\n // import first provider from file\n else if (options.file && (await frodo.login.getTokens(true))) {\n verboseMessage(\n `Importing first provider from file \"${options.file}\"...`\n );\n const outcome = await importFirstAdminFederationProviderFromFile(\n options.file\n );\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,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SACEC,qCAAqC,EACrCC,sCAAsC,EACtCC,uCAAuC,EACvCC,0CAA0C,QACrC,8BAA8B;AAErC,MAAMC,OAAO,GAAG,IAAIR,YAAY,CAAC,+BAA+B,EAAE,CAAC,OAAO,CAAC,CAAC;AAE5EQ,OAAO,CACJC,WAAW,CAAC,oCAAoC,CAAC,CACjDC,SAAS,CACR,IAAIT,MAAM,CACR,mBAAmB,EACnB,mDACF,CACF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EACnC;IACAlB,cAAc,CACZ,qEACF,CAAC;IACD,MAAMmB,OAAO,GAAG,MAAMhB,uCAAuC,CAAC,CAAC;IAC/D,IAAI,CAACgB,OAAO,EAAEC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC;EACA;EAAA,KACK,IAAIT,OAAO,CAACG,IAAI,KAAK,MAAMnB,KAAK,CAACqB,KAAK,CAACC,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE;IAC5DlB,cAAc,CACX,uCAAsCY,OAAO,CAACG,IAAK,MACtD,CAAC;IACD,MAAMI,OAAO,GAAG,MAAMf,0CAA0C,CAC9DQ,OAAO,CAACG,IACV,CAAC;IACD,IAAI,CAACI,OAAO,EAAEC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC;EACA;EAAA,KACK;IACHtB,YAAY,CAAC,sDAAsD,CAAC;IACpEM,OAAO,CAACmB,IAAI,CAAC,CAAC;IACdJ,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEHhB,OAAO,CAACoB,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { frodo } from '@rockcarver/frodo-lib';
|
|
2
|
+
import { FrodoCommand } from '../FrodoCommand';
|
|
3
|
+
import { verboseMessage } from '../../utils/Console';
|
|
4
|
+
import { listAdminFederationProviders } from '../../ops/AdminFederationOps';
|
|
5
|
+
const program = new FrodoCommand('frodo admin federation list', ['realm']);
|
|
6
|
+
program.description('List admin federation providers.')
|
|
7
|
+
// .addOption(
|
|
8
|
+
// new Option('-l, --long', 'Long with all fields.').default(false, 'false')
|
|
9
|
+
// )
|
|
10
|
+
.action(
|
|
11
|
+
// implement command logic inside action handler
|
|
12
|
+
async (host, user, password, options, command) => {
|
|
13
|
+
command.handleDefaultArgsAndOpts(host, user, password, options, command);
|
|
14
|
+
if (await frodo.login.getTokens(true)) {
|
|
15
|
+
verboseMessage(`Listing admin federation providers...`);
|
|
16
|
+
const outcome = await listAdminFederationProviders();
|
|
17
|
+
if (!outcome) process.exitCode = 1;
|
|
18
|
+
} else {
|
|
19
|
+
process.exitCode = 1;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
// end command logic inside action handler
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
program.parse();
|
|
26
|
+
//# sourceMappingURL=admin-federation-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-federation-list.js","names":["frodo","FrodoCommand","verboseMessage","listAdminFederationProviders","program","description","action","host","user","password","options","command","handleDefaultArgsAndOpts","login","getTokens","outcome","process","exitCode","parse"],"sources":["cli/admin/admin-federation-list.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport { FrodoCommand } from '../FrodoCommand';\nimport { verboseMessage } from '../../utils/Console';\nimport { listAdminFederationProviders } from '../../ops/AdminFederationOps';\n\nconst program = new FrodoCommand('frodo admin federation list', ['realm']);\n\nprogram\n .description('List admin federation providers.')\n // .addOption(\n // new Option('-l, --long', 'Long with all fields.').default(false, 'false')\n // )\n .action(\n // implement command logic inside action handler\n async (host, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(host, user, password, options, command);\n if (await frodo.login.getTokens(true)) {\n verboseMessage(`Listing admin federation providers...`);\n const outcome = await listAdminFederationProviders();\n if (!outcome) process.exitCode = 1;\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,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,cAAc,QAAQ,qBAAqB;AACpD,SAASC,4BAA4B,QAAQ,8BAA8B;AAE3E,MAAMC,OAAO,GAAG,IAAIH,YAAY,CAAC,6BAA6B,EAAE,CAAC,OAAO,CAAC,CAAC;AAE1EG,OAAO,CACJC,WAAW,CAAC,kCAAkC;AAC/C;AACA;AACA;AAAA,CACCC,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EAChDA,OAAO,CAACC,wBAAwB,CAACL,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,CAAC;EACxE,IAAI,MAAMX,KAAK,CAACa,KAAK,CAACC,SAAS,CAAC,IAAI,CAAC,EAAE;IACrCZ,cAAc,CAAE,uCAAsC,CAAC;IACvD,MAAMa,OAAO,GAAG,MAAMZ,4BAA4B,CAAC,CAAC;IACpD,IAAI,CAACY,OAAO,EAAEC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC,CAAC,MAAM;IACLD,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEHb,OAAO,CAACc,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FrodoStubCommand } from '../FrodoCommand';
|
|
2
|
+
const program = new FrodoStubCommand('frodo admin federation');
|
|
3
|
+
program.description('Manages admin federation configuration.');
|
|
4
|
+
|
|
5
|
+
// program.command('delete', 'Delete admin federation provider.');
|
|
6
|
+
|
|
7
|
+
// program.command('describe', 'Describe admin federation provider.');
|
|
8
|
+
|
|
9
|
+
program.command('export', 'Export admin federation providers.');
|
|
10
|
+
program.command('import', 'Import admin federation providers.');
|
|
11
|
+
program.command('list', 'List admin federation providers.');
|
|
12
|
+
program.parse();
|
|
13
|
+
//# sourceMappingURL=admin-federation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-federation.js","names":["FrodoStubCommand","program","description","command","parse"],"sources":["cli/admin/admin-federation.ts"],"sourcesContent":["import { FrodoStubCommand } from '../FrodoCommand';\n\nconst program = new FrodoStubCommand('frodo admin federation');\n\nprogram.description('Manages admin federation configuration.');\n\n// program.command('delete', 'Delete admin federation provider.');\n\n// program.command('describe', 'Describe admin federation provider.');\n\nprogram.command('export', 'Export admin federation providers.');\n\nprogram.command('import', 'Import admin federation providers.');\n\nprogram.command('list', 'List admin federation providers.');\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,iBAAiB;AAElD,MAAMC,OAAO,GAAG,IAAID,gBAAgB,CAAC,wBAAwB,CAAC;AAE9DC,OAAO,CAACC,WAAW,CAAC,yCAAyC,CAAC;;AAE9D;;AAEA;;AAEAD,OAAO,CAACE,OAAO,CAAC,QAAQ,EAAE,oCAAoC,CAAC;AAE/DF,OAAO,CAACE,OAAO,CAAC,QAAQ,EAAE,oCAAoC,CAAC;AAE/DF,OAAO,CAACE,OAAO,CAAC,MAAM,EAAE,kCAAkC,CAAC;AAE3DF,OAAO,CAACG,KAAK,CAAC,CAAC"}
|
package/esm/cli/admin/admin.js
CHANGED
|
@@ -4,6 +4,7 @@ import { fileURLToPath } from 'url';
|
|
|
4
4
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
5
5
|
export default function setup() {
|
|
6
6
|
const program = new FrodoStubCommand('admin').description('Platform admin tasks.').executableDir(__dirname);
|
|
7
|
+
program.command('federation', 'Manage admin federation configuration.');
|
|
7
8
|
program.command('create-oauth2-client-with-admin-privileges', 'Create an oauth2 client with admin privileges.');
|
|
8
9
|
program.command('get-access-token', 'Get an access token using client credentials grant type.');
|
|
9
10
|
program.command('list-oauth2-clients-with-admin-privileges', 'List oauth2 clients with admin privileges.');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin.js","names":["FrodoStubCommand","path","fileURLToPath","__dirname","dirname","import","meta","url","setup","program","description","executableDir","command"],"sources":["cli/admin/admin.ts"],"sourcesContent":["import { FrodoStubCommand } from '../FrodoCommand';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nexport default function setup() {\n const program = new FrodoStubCommand('admin')\n .description('Platform admin tasks.')\n .executableDir(__dirname);\n\n program.command(\n 'create-oauth2-client-with-admin-privileges',\n 'Create an oauth2 client with admin privileges.'\n );\n\n program.command(\n 'get-access-token',\n 'Get an access token using client credentials grant type.'\n );\n\n program.command(\n 'list-oauth2-clients-with-admin-privileges',\n 'List oauth2 clients with admin privileges.'\n );\n\n program.command(\n 'grant-oauth2-client-admin-privileges',\n 'Grant an oauth2 client admin privileges.'\n );\n\n program.command(\n 'revoke-oauth2-client-admin-privileges',\n 'Revoke admin privileges from an oauth2 client.'\n );\n\n program.command(\n 'list-oauth2-clients-with-custom-privileges',\n 'List oauth2 clients with custom privileges.'\n );\n\n program.command(\n 'list-static-user-mappings',\n 'List all subjects of static user mappings that are not oauth2 clients.'\n );\n\n program.command(\n 'remove-static-user-mapping',\n \"Remove a subject's static user mapping.\"\n );\n\n program.command(\n 'add-autoid-static-user-mapping',\n 'Add AutoId static user mapping to enable dashboards and other AutoId-based functionality.'\n );\n\n program.command(\n 'hide-generic-extension-attributes',\n 'Hide generic extension attributes.'\n );\n\n program.command(\n 'show-generic-extension-attributes',\n 'Show generic extension attributes.'\n );\n\n program.command('repair-org-model', 'Repair org model.');\n\n return program;\n}\n"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,iBAAiB;AAClD,OAAOC,IAAI,MAAM,MAAM;AACvB,SAASC,aAAa,QAAQ,KAAK;AAEnC,MAAMC,SAAS,GAAGF,IAAI,CAACG,OAAO,CAACF,aAAa,CAACG,MAAM,CAACC,IAAI,CAACC,GAAG,CAAC,CAAC;AAE9D,eAAe,SAASC,KAAKA,CAAA,EAAG;EAC9B,MAAMC,OAAO,GAAG,IAAIT,gBAAgB,CAAC,OAAO,CAAC,CAC1CU,WAAW,CAAC,uBAAuB,CAAC,CACpCC,aAAa,CAACR,SAAS,CAAC;EAE3BM,OAAO,CAACG,OAAO,CACb,4CAA4C,EAC5C,gDACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,kBAAkB,EAClB,0DACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,2CAA2C,EAC3C,4CACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,sCAAsC,EACtC,0CACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,uCAAuC,EACvC,gDACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,4CAA4C,EAC5C,6CACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,2BAA2B,EAC3B,wEACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,4BAA4B,EAC5B,yCACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,gCAAgC,EAChC,2FACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,mCAAmC,EACnC,oCACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,mCAAmC,EACnC,oCACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CAAC,kBAAkB,EAAE,mBAAmB,CAAC;EAExD,OAAOH,OAAO;AAChB"}
|
|
1
|
+
{"version":3,"file":"admin.js","names":["FrodoStubCommand","path","fileURLToPath","__dirname","dirname","import","meta","url","setup","program","description","executableDir","command"],"sources":["cli/admin/admin.ts"],"sourcesContent":["import { FrodoStubCommand } from '../FrodoCommand';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nexport default function setup() {\n const program = new FrodoStubCommand('admin')\n .description('Platform admin tasks.')\n .executableDir(__dirname);\n\n program.command('federation', 'Manage admin federation configuration.');\n\n program.command(\n 'create-oauth2-client-with-admin-privileges',\n 'Create an oauth2 client with admin privileges.'\n );\n\n program.command(\n 'get-access-token',\n 'Get an access token using client credentials grant type.'\n );\n\n program.command(\n 'list-oauth2-clients-with-admin-privileges',\n 'List oauth2 clients with admin privileges.'\n );\n\n program.command(\n 'grant-oauth2-client-admin-privileges',\n 'Grant an oauth2 client admin privileges.'\n );\n\n program.command(\n 'revoke-oauth2-client-admin-privileges',\n 'Revoke admin privileges from an oauth2 client.'\n );\n\n program.command(\n 'list-oauth2-clients-with-custom-privileges',\n 'List oauth2 clients with custom privileges.'\n );\n\n program.command(\n 'list-static-user-mappings',\n 'List all subjects of static user mappings that are not oauth2 clients.'\n );\n\n program.command(\n 'remove-static-user-mapping',\n \"Remove a subject's static user mapping.\"\n );\n\n program.command(\n 'add-autoid-static-user-mapping',\n 'Add AutoId static user mapping to enable dashboards and other AutoId-based functionality.'\n );\n\n program.command(\n 'hide-generic-extension-attributes',\n 'Hide generic extension attributes.'\n );\n\n program.command(\n 'show-generic-extension-attributes',\n 'Show generic extension attributes.'\n );\n\n program.command('repair-org-model', 'Repair org model.');\n\n return program;\n}\n"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,iBAAiB;AAClD,OAAOC,IAAI,MAAM,MAAM;AACvB,SAASC,aAAa,QAAQ,KAAK;AAEnC,MAAMC,SAAS,GAAGF,IAAI,CAACG,OAAO,CAACF,aAAa,CAACG,MAAM,CAACC,IAAI,CAACC,GAAG,CAAC,CAAC;AAE9D,eAAe,SAASC,KAAKA,CAAA,EAAG;EAC9B,MAAMC,OAAO,GAAG,IAAIT,gBAAgB,CAAC,OAAO,CAAC,CAC1CU,WAAW,CAAC,uBAAuB,CAAC,CACpCC,aAAa,CAACR,SAAS,CAAC;EAE3BM,OAAO,CAACG,OAAO,CAAC,YAAY,EAAE,wCAAwC,CAAC;EAEvEH,OAAO,CAACG,OAAO,CACb,4CAA4C,EAC5C,gDACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,kBAAkB,EAClB,0DACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,2CAA2C,EAC3C,4CACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,sCAAsC,EACtC,0CACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,uCAAuC,EACvC,gDACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,4CAA4C,EAC5C,6CACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,2BAA2B,EAC3B,wEACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,4BAA4B,EAC5B,yCACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,gCAAgC,EAChC,2FACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,mCAAmC,EACnC,oCACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,mCAAmC,EACnC,oCACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CAAC,kBAAkB,EAAE,mBAAmB,CAAC;EAExD,OAAOH,OAAO;AAChB"}
|
|
@@ -4,8 +4,9 @@ import { frodo, state } from '@rockcarver/frodo-lib';
|
|
|
4
4
|
import { verboseMessage, printMessage } from '../../utils/Console';
|
|
5
5
|
import { addExistingServiceAccount } from '../../ops/ConnectionProfileOps.js';
|
|
6
6
|
import { provisionCreds } from '../../ops/LogOps';
|
|
7
|
+
import * as s from '../../help/SampleData';
|
|
7
8
|
const program = new FrodoCommand('frodo conn save', ['realm']);
|
|
8
|
-
program.alias('add').description('Save connection profiles.').addOption(new Option('--
|
|
9
|
+
program.alias('add').description('Save connection profiles.').addOption(new Option('--no-sa', 'Do not create and add service account.')).addOption(new Option('--log-api-key [key]', 'Log API key. If specified, must also include --log-api-secret. Ignored with --no-log-api.')).addOption(new Option('--log-api-secret [secret]', 'Log API secret. If specified, must also include --log-api-key. Ignored with --no-log-api.')).addOption(new Option('--no-log-api', 'Do not create and add log API key and secret.')).addOption(new Option('--no-validate', 'Do not validate connection.')).addOption(new Option('--authentication-service [service]', 'Name of the authentication service/tree to use.')).addOption(new Option('--authentication-header-overrides [headers]', 'Map of headers: {"host":"am.example.com:8081"}.')).addHelpText('after', `Usage Examples:\n` + ` Create a connection profile with a new log API key and secret and a new service account:\n` + ` $ frodo conn save ${s.amBaseUrl} ${s.username} '${s.password}'\n`['brightCyan'] + ` Save an existing service account to an existing or new connection profile:\n` + ` $ frodo conn save --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}'\n`['brightCyan'] + ` Save an existing service account to an existing connection profile (partial host URL only updates an existing profile):\n` + ` $ frodo conn save --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}'\n`['brightCyan']).action(
|
|
9
10
|
// implement command logic inside action handler
|
|
10
11
|
async (host, user, password, options, command) => {
|
|
11
12
|
command.handleDefaultArgsAndOpts(host, user, password, options, command);
|
|
@@ -17,7 +18,9 @@ async (host, user, password, options, command) => {
|
|
|
17
18
|
if (options.authenticationHeaderOverrides) {
|
|
18
19
|
state.setAuthenticationHeaderOverrides(JSON.parse(options.authenticationHeaderOverrides));
|
|
19
20
|
}
|
|
20
|
-
const
|
|
21
|
+
const needSa = options.sa && !state.getServiceAccountId() && !state.getServiceAccountJwk();
|
|
22
|
+
const needLogApiKey = options.logApi && !state.getLogApiKey() && !state.getLogApiSecret() && needSa;
|
|
23
|
+
const forceLoginAsUser = needSa || needLogApiKey;
|
|
21
24
|
if (options.validate && (await frodo.login.getTokens(forceLoginAsUser)) || !options.validate) {
|
|
22
25
|
verboseMessage(`Saving connection profile for tenant ${state.getHost()}...`);
|
|
23
26
|
// if cloud deployment add service account
|
|
@@ -50,7 +53,7 @@ async (host, user, password, options, command) => {
|
|
|
50
53
|
// if cloud deployment add log api key and secret
|
|
51
54
|
verboseMessage(options);
|
|
52
55
|
verboseMessage(state);
|
|
53
|
-
if (options.validate && state.getDeploymentType() === frodo.helper.constants.CLOUD_DEPLOYMENT_TYPE_KEY &&
|
|
56
|
+
if (options.validate && state.getDeploymentType() === frodo.helper.constants.CLOUD_DEPLOYMENT_TYPE_KEY && needLogApiKey) {
|
|
54
57
|
// validate and add existing log api key and secret
|
|
55
58
|
if (options.logApiKey && options.logApiSecret) {
|
|
56
59
|
verboseMessage(`Validating and adding log api key and secret...`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conn-save.js","names":["FrodoCommand","Option","frodo","state","verboseMessage","printMessage","addExistingServiceAccount","provisionCreds","program","alias","description","addOption","action","host","user","password","options","command","handleDefaultArgsAndOpts","setLogApiKey","logApiKey","setLogApiSecret","logApiSecret","authenticationService","setAuthenticationService","authenticationHeaderOverrides","setAuthenticationHeaderOverrides","JSON","parse","forceLoginAsUser","sa","getLogApiKey","getLogApiSecret","validate","login","getTokens","getHost","getDeploymentType","helper","constants","CLOUD_DEPLOYMENT_TYPE_KEY","cloud","serviceAccount","isServiceAccountsFeatureAvailable","saId","saJwkFile","getServiceAccountId","conn","addNewServiceAccount","name","_id","error","_error$response","_error$response2","_error$response2$data","response","data","message","process","exitCode","logApi","creds","api_key_id","api_key_secret","_error$response3","_error$response4","_error$response4$data","saveConnectionProfile"],"sources":["cli/conn/conn-save.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { frodo, state } from '@rockcarver/frodo-lib';\nimport { verboseMessage, printMessage } from '../../utils/Console';\nimport { addExistingServiceAccount } from '../../ops/ConnectionProfileOps.js';\nimport { provisionCreds } from '../../ops/LogOps';\n\nconst program = new FrodoCommand('frodo conn save', ['realm']);\n\nprogram\n .alias('add')\n .description('Save connection profiles.')\n .addOption(\n new Option(\n '--sa-id <uuid>',\n \"Service account's uuid. If specified, must also include --sa-jwk-file. Ignored with --no-sa.\"\n )\n )\n .addOption(\n new Option(\n '--sa-jwk-file <file>',\n \"File containing the service account's java web key (jwk). Jwk must contain private key! If specified, must also include --sa-id. Ignored with --no-sa.\"\n )\n )\n .addOption(new Option('--no-sa', 'Do not create and add service account.'))\n .addOption(\n new Option(\n '--log-api-key [key]',\n 'Log API key. If specified, must also include --log-api-secret. Ignored with --no-log-api.'\n )\n )\n .addOption(\n new Option(\n '--log-api-secret [secret]',\n 'Log API secret. If specified, must also include --log-api-key. Ignored with --no-log-api.'\n )\n )\n .addOption(\n new Option('--no-log-api', 'Do not create and add log API key and secret.')\n )\n .addOption(new Option('--no-validate', 'Do not validate connection.'))\n .addOption(\n new Option(\n '--authentication-service [service]',\n 'Name of the authentication service/tree to use.'\n )\n )\n .addOption(\n new Option(\n '--authentication-header-overrides [headers]',\n 'Map of headers: {\"host\":\"am.example.com:8081\"}.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(host, user, password, options, command);\n state.setLogApiKey(options.logApiKey);\n state.setLogApiSecret(options.logApiSecret);\n if (options.authenticationService) {\n state.setAuthenticationService(options.authenticationService);\n }\n if (options.authenticationHeaderOverrides) {\n state.setAuthenticationHeaderOverrides(\n JSON.parse(options.authenticationHeaderOverrides)\n );\n }\n const forceLoginAsUser =\n !options.sa ||\n (state.getLogApiKey() && state.getLogApiSecret() ? false : true);\n if (\n (options.validate && (await frodo.login.getTokens(forceLoginAsUser))) ||\n !options.validate\n ) {\n verboseMessage(\n `Saving connection profile for tenant ${state.getHost()}...`\n );\n // if cloud deployment add service account\n if (\n options.validate &&\n state.getDeploymentType() ===\n frodo.helper.constants.CLOUD_DEPLOYMENT_TYPE_KEY &&\n options.sa &&\n (await frodo.cloud.serviceAccount.isServiceAccountsFeatureAvailable())\n ) {\n // validate and add existing service account\n if (options.saId && options.saJwkFile) {\n verboseMessage(`Validating and adding service account...`);\n if (\n await addExistingServiceAccount(\n options.saId,\n options.saJwkFile,\n options.validate\n )\n ) {\n printMessage(\n `Validated and added service account with id ${options.saId} to profile.`\n );\n }\n }\n // add new service account if none already exists in the profile\n else if (!state.getServiceAccountId()) {\n try {\n verboseMessage(`Creating service account...`);\n const sa = await frodo.conn.addNewServiceAccount();\n printMessage(\n `Created and added service account ${sa.name} with id ${sa._id} to profile.`\n );\n } catch (error) {\n printMessage(error.response?.data, 'error');\n printMessage(\n `Error creating service account: ${error.response?.data?.message}`,\n 'error'\n );\n process.exitCode = 1;\n }\n }\n }\n // add existing service account without validation\n else if (\n !options.validate &&\n options.saId &&\n options.saJwkFile &&\n options.sa\n ) {\n addExistingServiceAccount(\n options.saId,\n options.saJwkFile,\n options.validate\n );\n }\n // if cloud deployment add log api key and secret\n verboseMessage(options);\n verboseMessage(state);\n if (\n options.validate &&\n state.getDeploymentType() ===\n frodo.helper.constants.CLOUD_DEPLOYMENT_TYPE_KEY &&\n options.logApi\n ) {\n // validate and add existing log api key and secret\n if (options.logApiKey && options.logApiSecret) {\n verboseMessage(`Validating and adding log api key and secret...`);\n if (\n await addExistingServiceAccount(\n options.logApiKey,\n options.logApiSecret,\n options.validate\n )\n ) {\n printMessage(\n `Added log API key ${options.logApiKey} to profile.`\n );\n }\n }\n // add new log api key and secret if none already exists in the profile\n else if (!state.getLogApiKey()) {\n try {\n const creds = await provisionCreds();\n state.setLogApiKey(creds.api_key_id as string);\n state.setLogApiSecret(creds.api_key_secret as string);\n printMessage(\n `Created log API key ${creds.api_key_id} and secret.`\n );\n } catch (error) {\n printMessage(error.response?.data, 'error');\n printMessage(\n `Error creating log API key and secret: ${error.response?.data?.message}`,\n 'error'\n );\n process.exitCode = 1;\n }\n }\n }\n // add existing log api key and secret without validation\n // storing log API key and secret in the connection profile is happening default, therefore no code required here\n if (await frodo.conn.saveConnectionProfile(host)) {\n printMessage(`Saved connection profile ${state.getHost()}`);\n } else {\n process.exitCode = 1;\n }\n } else {\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,SAASC,cAAc,EAAEC,YAAY,QAAQ,qBAAqB;AAClE,SAASC,yBAAyB,QAAQ,mCAAmC;AAC7E,SAASC,cAAc,QAAQ,kBAAkB;AAEjD,MAAMC,OAAO,GAAG,IAAIR,YAAY,CAAC,iBAAiB,EAAE,CAAC,OAAO,CAAC,CAAC;AAE9DQ,OAAO,CACJC,KAAK,CAAC,KAAK,CAAC,CACZC,WAAW,CAAC,2BAA2B,CAAC,CACxCC,SAAS,CACR,IAAIV,MAAM,CACR,gBAAgB,EAChB,8FACF,CACF,CAAC,CACAU,SAAS,CACR,IAAIV,MAAM,CACR,sBAAsB,EACtB,wJACF,CACF,CAAC,C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CAACE,cAAwB,CAAC;UACrD1D,YAAY,CACT,uBAAsBwD,KAAK,CAACC,UAAW,cAC1C,CAAC;QACH,CAAC,CAAC,OAAOX,KAAK,EAAE;UAAA,IAAAa,gBAAA,EAAAC,gBAAA,EAAAC,qBAAA;UACd7D,YAAY,EAAA2D,gBAAA,GAACb,KAAK,CAACI,QAAQ,cAAAS,gBAAA,uBAAdA,gBAAA,CAAgBR,IAAI,EAAE,OAAO,CAAC;UAC3CnD,YAAY,CACT,0CAAuC,CAAA4D,gBAAA,GAAEd,KAAK,CAACI,QAAQ,cAAAU,gBAAA,wBAAAC,qBAAA,GAAdD,gBAAA,CAAgBT,IAAI,cAAAU,qBAAA,uBAApBA,qBAAA,CAAsBT,OAAQ,EAAC,EACzE,OACF,CAAC;UACDC,OAAO,CAACC,QAAQ,GAAG,CAAC;QACtB;MACF;IACF;IACA;IACA;IACA,IAAI,MAAMzD,KAAK,CAAC6C,IAAI,CAACoB,qBAAqB,CAACtD,IAAI,CAAC,EAAE;MAChDR,YAAY,CAAE,4BAA2BF,KAAK,CAACiC,OAAO,CAAC,CAAE,EAAC,CAAC;IAC7D,CAAC,MAAM;MACLsB,OAAO,CAACC,QAAQ,GAAG,CAAC;IACtB;EACF,CAAC,MAAM;IACLD,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEHnD,OAAO,CAACoB,KAAK,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"conn-save.js","names":["FrodoCommand","Option","frodo","state","verboseMessage","printMessage","addExistingServiceAccount","provisionCreds","s","program","alias","description","addOption","addHelpText","amBaseUrl","username","password","saId","saJwkFile","connId","action","host","user","options","command","handleDefaultArgsAndOpts","setLogApiKey","logApiKey","setLogApiSecret","logApiSecret","authenticationService","setAuthenticationService","authenticationHeaderOverrides","setAuthenticationHeaderOverrides","JSON","parse","needSa","sa","getServiceAccountId","getServiceAccountJwk","needLogApiKey","logApi","getLogApiKey","getLogApiSecret","forceLoginAsUser","validate","login","getTokens","getHost","getDeploymentType","helper","constants","CLOUD_DEPLOYMENT_TYPE_KEY","cloud","serviceAccount","isServiceAccountsFeatureAvailable","conn","addNewServiceAccount","name","_id","error","_error$response","_error$response2","_error$response2$data","response","data","message","process","exitCode","creds","api_key_id","api_key_secret","_error$response3","_error$response4","_error$response4$data","saveConnectionProfile"],"sources":["cli/conn/conn-save.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { frodo, state } from '@rockcarver/frodo-lib';\nimport { verboseMessage, printMessage } from '../../utils/Console';\nimport { addExistingServiceAccount } from '../../ops/ConnectionProfileOps.js';\nimport { provisionCreds } from '../../ops/LogOps';\nimport * as s from '../../help/SampleData';\n\nconst program = new FrodoCommand('frodo conn save', ['realm']);\n\nprogram\n .alias('add')\n .description('Save connection profiles.')\n .addOption(new Option('--no-sa', 'Do not create and add service account.'))\n .addOption(\n new Option(\n '--log-api-key [key]',\n 'Log API key. If specified, must also include --log-api-secret. Ignored with --no-log-api.'\n )\n )\n .addOption(\n new Option(\n '--log-api-secret [secret]',\n 'Log API secret. If specified, must also include --log-api-key. Ignored with --no-log-api.'\n )\n )\n .addOption(\n new Option('--no-log-api', 'Do not create and add log API key and secret.')\n )\n .addOption(new Option('--no-validate', 'Do not validate connection.'))\n .addOption(\n new Option(\n '--authentication-service [service]',\n 'Name of the authentication service/tree to use.'\n )\n )\n .addOption(\n new Option(\n '--authentication-header-overrides [headers]',\n 'Map of headers: {\"host\":\"am.example.com:8081\"}.'\n )\n )\n .addHelpText(\n 'after',\n `Usage Examples:\\n` +\n ` Create a connection profile with a new log API key and secret and a new service account:\\n` +\n ` $ frodo conn save ${s.amBaseUrl} ${s.username} '${s.password}'\\n`[\n 'brightCyan'\n ] +\n ` Save an existing service account to an existing or new connection profile:\\n` +\n ` $ frodo conn save --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.amBaseUrl}'\\n`[\n 'brightCyan'\n ] +\n ` Save an existing service account to an existing connection profile (partial host URL only updates an existing profile):\\n` +\n ` $ frodo conn save --sa-id ${s.saId} --sa-jwk-file ${s.saJwkFile} ${s.connId}'\\n`[\n 'brightCyan'\n ]\n )\n .action(\n // implement command logic inside action handler\n async (host, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(host, user, password, options, command);\n state.setLogApiKey(options.logApiKey);\n state.setLogApiSecret(options.logApiSecret);\n if (options.authenticationService) {\n state.setAuthenticationService(options.authenticationService);\n }\n if (options.authenticationHeaderOverrides) {\n state.setAuthenticationHeaderOverrides(\n JSON.parse(options.authenticationHeaderOverrides)\n );\n }\n const needSa =\n options.sa &&\n !state.getServiceAccountId() &&\n !state.getServiceAccountJwk();\n const needLogApiKey =\n options.logApi &&\n !state.getLogApiKey() &&\n !state.getLogApiSecret() &&\n needSa;\n const forceLoginAsUser = needSa || needLogApiKey;\n if (\n (options.validate && (await frodo.login.getTokens(forceLoginAsUser))) ||\n !options.validate\n ) {\n verboseMessage(\n `Saving connection profile for tenant ${state.getHost()}...`\n );\n // if cloud deployment add service account\n if (\n options.validate &&\n state.getDeploymentType() ===\n frodo.helper.constants.CLOUD_DEPLOYMENT_TYPE_KEY &&\n options.sa &&\n (await frodo.cloud.serviceAccount.isServiceAccountsFeatureAvailable())\n ) {\n // validate and add existing service account\n if (options.saId && options.saJwkFile) {\n verboseMessage(`Validating and adding service account...`);\n if (\n await addExistingServiceAccount(\n options.saId,\n options.saJwkFile,\n options.validate\n )\n ) {\n printMessage(\n `Validated and added service account with id ${options.saId} to profile.`\n );\n }\n }\n // add new service account if none already exists in the profile\n else if (!state.getServiceAccountId()) {\n try {\n verboseMessage(`Creating service account...`);\n const sa = await frodo.conn.addNewServiceAccount();\n printMessage(\n `Created and added service account ${sa.name} with id ${sa._id} to profile.`\n );\n } catch (error) {\n printMessage(error.response?.data, 'error');\n printMessage(\n `Error creating service account: ${error.response?.data?.message}`,\n 'error'\n );\n process.exitCode = 1;\n }\n }\n }\n // add existing service account without validation\n else if (\n !options.validate &&\n options.saId &&\n options.saJwkFile &&\n options.sa\n ) {\n addExistingServiceAccount(\n options.saId,\n options.saJwkFile,\n options.validate\n );\n }\n // if cloud deployment add log api key and secret\n verboseMessage(options);\n verboseMessage(state);\n if (\n options.validate &&\n state.getDeploymentType() ===\n frodo.helper.constants.CLOUD_DEPLOYMENT_TYPE_KEY &&\n needLogApiKey\n ) {\n // validate and add existing log api key and secret\n if (options.logApiKey && options.logApiSecret) {\n verboseMessage(`Validating and adding log api key and secret...`);\n if (\n await addExistingServiceAccount(\n options.logApiKey,\n options.logApiSecret,\n options.validate\n )\n ) {\n printMessage(\n `Added log API key ${options.logApiKey} to profile.`\n );\n }\n }\n // add new log api key and secret if none already exists in the profile\n else if (!state.getLogApiKey()) {\n try {\n const creds = await provisionCreds();\n state.setLogApiKey(creds.api_key_id as string);\n state.setLogApiSecret(creds.api_key_secret as string);\n printMessage(\n `Created log API key ${creds.api_key_id} and secret.`\n );\n } catch (error) {\n printMessage(error.response?.data, 'error');\n printMessage(\n `Error creating log API key and secret: ${error.response?.data?.message}`,\n 'error'\n );\n process.exitCode = 1;\n }\n }\n }\n // add existing log api key and secret without validation\n // storing log API key and secret in the connection profile is happening default, therefore no code required here\n if (await frodo.conn.saveConnectionProfile(host)) {\n printMessage(`Saved connection profile ${state.getHost()}`);\n } else {\n process.exitCode = 1;\n }\n } else {\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,SAASC,cAAc,EAAEC,YAAY,QAAQ,qBAAqB;AAClE,SAASC,yBAAyB,QAAQ,mCAAmC;AAC7E,SAASC,cAAc,QAAQ,kBAAkB;AACjD,OAAO,KAAKC,CAAC,MAAM,uBAAuB;AAE1C,MAAMC,OAAO,GAAG,IAAIT,YAAY,CAAC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E,KAAK,CAACsD,IAAI,CAACmB,qBAAqB,CAACtD,IAAI,CAAC,EAAE;MAChDhB,YAAY,CAAE,4BAA2BF,KAAK,CAAC6C,OAAO,CAAC,CAAE,EAAC,CAAC;IAC7D,CAAC,MAAM;MACLmB,OAAO,CAACC,QAAQ,GAAG,CAAC;IACtB;EACF,CAAC,MAAM;IACLD,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEH3D,OAAO,CAAC0B,KAAK,CAAC,CAAC"}
|
package/esm/cli/info/info.js
CHANGED
|
@@ -2,9 +2,10 @@ import { FrodoCommand } from '../FrodoCommand';
|
|
|
2
2
|
import { Option } from 'commander';
|
|
3
3
|
import { frodo, state } from '@rockcarver/frodo-lib';
|
|
4
4
|
import { createObjectTable, printMessage, verboseMessage } from '../../utils/Console';
|
|
5
|
+
import * as s from '../../help/SampleData';
|
|
5
6
|
export default function setup() {
|
|
6
7
|
const program = new FrodoCommand('info', ['realm']);
|
|
7
|
-
program.description('Print versions and tokens.').addOption(new Option('--json', 'Output in JSON format.')).addOption(new Option('-s, --scriptFriendly', 'Send output of operation to STDOUT in a script-friendly format (JSON) which can be piped to other commands. User messages/warnings are output to STDERR, and are not piped. For example, to only get bearer token: \n<<< frodo info my-tenant -s 2>/dev/null | jq -r .bearerToken >>>').default(false, 'Output as plain text').hideHelp()).action(async (host, user, password, options, command) => {
|
|
8
|
+
program.description('Print versions and tokens.').addOption(new Option('--json', 'Output in JSON format.')).addOption(new Option('-s, --scriptFriendly', 'Send output of operation to STDOUT in a script-friendly format (JSON) which can be piped to other commands. User messages/warnings are output to STDERR, and are not piped. For example, to only get bearer token: \n<<< frodo info my-tenant -s 2>/dev/null | jq -r .bearerToken >>>').default(false, 'Output as plain text').hideHelp()).addHelpText('after', `Usage Examples:\n` + ` Show human-readable output and login using AM base URL, username, and password (note the quotes around password to allow special characters):\n` + ` $ frodo info ${s.amBaseUrl} ${s.username} '${s.password}'\n`['brightCyan'] + ` Show human-readable output and login using a connection profile (identified by the full AM base URL):\n` + ` $ frodo info ${s.amBaseUrl}'\n`['brightCyan'] + ` Show human-readable output and login using a connection profile (identified by a unique substring of the AM base URL):\n` + ` $ frodo info ${s.connId}'\n`['brightCyan'] + ` Show JSON output and login using the AM base URL's unique substring to identify the connection profile:\n` + ` $ frodo info --json ${s.connId}'\n`['brightCyan']).action(async (host, user, password, options, command) => {
|
|
8
9
|
command.handleDefaultArgsAndOpts(host, user, password, options, command);
|
|
9
10
|
if (await frodo.login.getTokens()) {
|
|
10
11
|
const info = await frodo.info.getInfo();
|
|
@@ -40,10 +41,8 @@ export default function setup() {
|
|
|
40
41
|
}
|
|
41
42
|
} else {
|
|
42
43
|
process.exitCode = 1;
|
|
43
|
-
program.help();
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
|
-
program.showHelpAfterError();
|
|
47
46
|
return program;
|
|
48
47
|
}
|
|
49
48
|
//# sourceMappingURL=info.js.map
|
package/esm/cli/info/info.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"info.js","names":["FrodoCommand","Option","frodo","state","createObjectTable","printMessage","verboseMessage","setup","program","description","addOption","default","hideHelp","
|
|
1
|
+
{"version":3,"file":"info.js","names":["FrodoCommand","Option","frodo","state","createObjectTable","printMessage","verboseMessage","s","setup","program","description","addOption","default","hideHelp","addHelpText","amBaseUrl","username","password","connId","action","host","user","options","command","handleDefaultArgsAndOpts","login","getTokens","info","getInfo","scriptFriendly","json","sessionToken","bearerToken","labels","amVersion","authenticatedSubject","config_promotion_done","cookieName","deploymentType","immutable","locked","placeholder_management","region","tier","table","toString","getCookieValue","getBearerToken","JSON","stringify","process","exitCode"],"sources":["cli/info/info.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { frodo, state } from '@rockcarver/frodo-lib';\nimport {\n createObjectTable,\n printMessage,\n verboseMessage,\n} from '../../utils/Console';\nimport * as s from '../../help/SampleData';\n\nexport default function setup() {\n const program = new FrodoCommand('info', ['realm']);\n program\n .description('Print versions and tokens.')\n .addOption(new Option('--json', 'Output in JSON format.'))\n .addOption(\n new Option(\n '-s, --scriptFriendly',\n 'Send output of operation to STDOUT in a script-friendly format (JSON) which can be piped to other commands. User messages/warnings are output to STDERR, and are not piped. For example, to only get bearer token: \\n<<< frodo info my-tenant -s 2>/dev/null | jq -r .bearerToken >>>'\n )\n .default(false, 'Output as plain text')\n .hideHelp()\n )\n .addHelpText(\n 'after',\n `Usage Examples:\\n` +\n ` Show human-readable output and login using AM base URL, username, and password (note the quotes around password to allow special characters):\\n` +\n ` $ frodo info ${s.amBaseUrl} ${s.username} '${s.password}'\\n`[\n 'brightCyan'\n ] +\n ` Show human-readable output and login using a connection profile (identified by the full AM base URL):\\n` +\n ` $ frodo info ${s.amBaseUrl}'\\n`['brightCyan'] +\n ` Show human-readable output and login using a connection profile (identified by a unique substring of the AM base URL):\\n` +\n ` $ frodo info ${s.connId}'\\n`['brightCyan'] +\n ` Show JSON output and login using the AM base URL's unique substring to identify the connection profile:\\n` +\n ` $ frodo info --json ${s.connId}'\\n`['brightCyan']\n )\n .action(async (host, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(host, user, password, options, command);\n if (await frodo.login.getTokens()) {\n const info = await frodo.info.getInfo();\n if (!options.scriptFriendly && !options.json) {\n verboseMessage('Printing info, versions, and tokens...');\n delete info.sessionToken;\n delete info.bearerToken;\n const labels = {\n amVersion: 'AM Version',\n authenticatedSubject: 'Subject (Type)',\n config_promotion_done: 'Promotion Done',\n cookieName: 'Cookie Name',\n deploymentType: 'Deployment Type',\n host: 'Host URL',\n immutable: 'Immutable',\n locked: 'Locked',\n placeholder_management: 'Placeholder Management',\n region: 'Region',\n tier: 'Tier',\n };\n const table = createObjectTable(info, labels);\n printMessage(`\\n${table.toString()}`);\n if (state.getCookieValue()) {\n printMessage(`\\nSession token:`, 'info');\n printMessage(`${state.getCookieValue()}`);\n }\n if (state.getBearerToken()) {\n printMessage(`\\nBearer token:`, 'info');\n printMessage(`${state.getBearerToken()}`);\n }\n } else {\n printMessage(JSON.stringify(info, null, 2), 'data');\n }\n } else {\n process.exitCode = 1;\n }\n });\n return program;\n}\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,SACEC,iBAAiB,EACjBC,YAAY,EACZC,cAAc,QACT,qBAAqB;AAC5B,OAAO,KAAKC,CAAC,MAAM,uBAAuB;AAE1C,eAAe,SAASC,KAAKA,CAAA,EAAG;EAC9B,MAAMC,OAAO,GAAG,IAAIT,YAAY,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,CAAC;EACnDS,OAAO,CACJC,WAAW,CAAC,4BAA4B,CAAC,CACzCC,SAAS,CAAC,IAAIV,MAAM,CAAC,QAAQ,EAAE,wBAAwB,CAAC,CAAC,CACzDU,SAAS,CACR,IAAIV,MAAM,CACR,sBAAsB,EACtB,uRACF,CAAC,CACEW,OAAO,CAAC,KAAK,EAAE,sBAAsB,CAAC,CACtCC,QAAQ,CAAC,CACd,CAAC,CACAC,WAAW,CACV,OAAO,EACN,mBAAkB,GAChB,mJAAkJ,GAClJ,kBAAiBP,CAAC,CAACQ,SAAU,IAAGR,CAAC,CAACS,QAAS,KAAIT,CAAC,CAACU,QAAS,KAAI,CAC7D,YAAY,CACb,GACA,2GAA0G,GAC1G,kBAAiBV,CAAC,CAACQ,SAAU,KAAI,CAAC,YAAY,CAAC,GAC/C,4HAA2H,GAC3H,kBAAiBR,CAAC,CAACW,MAAO,KAAI,CAAC,YAAY,CAAC,GAC5C,6GAA4G,GAC5G,yBAAwBX,CAAC,CAACW,MAAO,KAAI,CAAC,YAAY,CACvD,CAAC,CACAC,MAAM,CAAC,OAAOC,IAAI,EAAEC,IAAI,EAAEJ,QAAQ,EAAEK,OAAO,EAAEC,OAAO,KAAK;IACxDA,OAAO,C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C;MACF,CAAC,MAAM;QACL1C,YAAY,CAAC2C,IAAI,CAACC,SAAS,CAACtB,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC;MACrD;IACF,CAAC,MAAM;MACLuB,OAAO,CAACC,QAAQ,GAAG,CAAC;IACtB;EACF,CAAC,CAAC;EACJ,OAAO1C,OAAO;AAChB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FrodoCommand } from '../FrodoCommand';
|
|
2
|
-
import { sourcesOptionM } from './
|
|
2
|
+
import { sourcesOptionM } from './log';
|
|
3
3
|
import { Option } from 'commander';
|
|
4
4
|
import { frodo, state } from '@rockcarver/frodo-lib';
|
|
5
5
|
import * as config from '../../utils/Config';
|
|
@@ -9,7 +9,7 @@ const SECONDS_IN_30_DAYS = 2592000;
|
|
|
9
9
|
const SECONDS_IN_1_HOUR = 3600;
|
|
10
10
|
const LOG_TIME_WINDOW_MAX = SECONDS_IN_30_DAYS;
|
|
11
11
|
const LOG_TIME_WINDOW_INCREMENT = 1;
|
|
12
|
-
const program = new FrodoCommand('frodo
|
|
12
|
+
const program = new FrodoCommand('frodo log fetch', ['realm', 'type']);
|
|
13
13
|
program.description('Fetch Identity Cloud logs between a specified begin and end time period.\
|
|
14
14
|
WARNING: depending on filters and time period specified, this could take substantial time to complete.').addOption(sourcesOptionM).addOption(new Option('-l, --level <level>', 'Set log level filter. You can specify the level as a number or a string. \
|
|
15
15
|
Following values are possible (values on the same line are equivalent): \
|
|
@@ -88,4 +88,4 @@ Cannot be more than 30 days in the past. If not specified, logs from one hour ag
|
|
|
88
88
|
}
|
|
89
89
|
});
|
|
90
90
|
program.parse();
|
|
91
|
-
//# sourceMappingURL=
|
|
91
|
+
//# sourceMappingURL=log-fetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-fetch.js","names":["FrodoCommand","sourcesOptionM","Option","frodo","state","config","printMessage","fetchLogs","provisionCreds","SECONDS_IN_30_DAYS","SECONDS_IN_1_HOUR","LOG_TIME_WINDOW_MAX","LOG_TIME_WINDOW_INCREMENT","program","description","addOption","default","cloud","log","resolveLevel","FRODO_LOG_NOISEFILTER_FILENAME","action","host","user","password","options","command","handleDefaultArgsAndOpts","credsFromParameters","conn","getConnectionProfile","setHost","tenant","logApiKey","logApiSecret","setLogApiKey","setLogApiSecret","username","getUsername","getPassword","setUsername","setPassword","login","getTokens","creds","api_key_id","api_key_secret","now","Date","nowString","toISOString","beginTimestamp","tempStartDate","setTime","tempEndDate","endTimestamp","beginTs","parse","endTs","intermediateEndTs","opts","sources","level","saveConnectionProfile","timeIncrement","transactionId","searchString","getNoiseFilters","defaults"],"sources":["cli/log/log-fetch.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { sourcesOptionM } from './log';\nimport { Option } from 'commander';\nimport { frodo, state } from '@rockcarver/frodo-lib';\nimport * as config from '../../utils/Config';\nimport { printMessage } from '../../utils/Console';\nimport { fetchLogs, provisionCreds } from '../../ops/LogOps';\n\nconst SECONDS_IN_30_DAYS = 2592000;\nconst SECONDS_IN_1_HOUR = 3600;\nconst LOG_TIME_WINDOW_MAX = SECONDS_IN_30_DAYS;\nconst LOG_TIME_WINDOW_INCREMENT = 1;\n\nconst program = new FrodoCommand('frodo log fetch', ['realm', 'type']);\nprogram\n .description(\n 'Fetch Identity Cloud logs between a specified begin and end time period.\\\n WARNING: depending on filters and time period specified, this could take substantial time to complete.'\n )\n .addOption(sourcesOptionM)\n .addOption(\n new Option(\n '-l, --level <level>',\n 'Set log level filter. You can specify the level as a number or a string. \\\nFollowing values are possible (values on the same line are equivalent): \\\n\\n0, SEVERE, FATAL, or ERROR\\n1, WARNING, WARN or CONFIG\\\n\\n2, INFO or INFORMATION\\n3, DEBUG, FINE, FINER or FINEST\\\n\\n4 or ALL'\n ).default('ERROR', `${frodo.cloud.log.resolveLevel('ERROR')}`)\n )\n .addOption(\n new Option('-t, --transaction-id <txid>', 'Filter by transactionId')\n )\n .addOption(\n new Option(\n '-b, --begin-timestamp <beginTs>',\n 'Begin timestamp for period (in ISO8601, example: \"2022-10-13T19:06:28Z\", or \"2022-09.30\". \\\nCannot be more than 30 days in the past. If not specified, logs from one hour ago are fetched \\\n(-e is ignored)'\n )\n )\n .addOption(\n new Option(\n '-e, --end-timestamp <endTs>',\n 'End timestamp for period. Default: \"now\"'\n )\n )\n .addOption(\n new Option(\n '-s, --search-string <ss>',\n 'Filter by a specific string (ANDed with transactionID filter)'\n )\n )\n .addOption(\n new Option('-d, --defaults', 'Use default logging noise filters').default(\n false,\n `Use custom logging noise filters defined in $HOME/${config.FRODO_LOG_NOISEFILTER_FILENAME}`\n )\n )\n .action(async (host, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(host, user, password, options, command);\n let credsFromParameters = true;\n const conn = await frodo.conn.getConnectionProfile();\n if (conn) {\n state.setHost(conn.tenant);\n if (conn.logApiKey != null && conn.logApiSecret != null) {\n credsFromParameters = false;\n state.setLogApiKey(conn.logApiKey);\n state.setLogApiSecret(conn.logApiSecret);\n } else {\n if (conn.username == null && conn.password == null) {\n if (!state.getUsername() && !state.getPassword()) {\n credsFromParameters = false;\n printMessage(\n 'User credentials not specified as parameters and no saved API key and secret found!',\n 'warn'\n );\n return;\n }\n } else {\n state.setUsername(conn.username);\n state.setPassword(conn.password);\n }\n if (await frodo.login.getTokens(true)) {\n const creds = await provisionCreds();\n state.setLogApiKey(creds.api_key_id as string);\n state.setLogApiSecret(creds.api_key_secret as string);\n }\n }\n const now = Date.now() / 1000;\n const nowString = new Date(now * 1000).toISOString();\n if (\n typeof options.beginTimestamp === 'undefined' ||\n !options.beginTimestamp\n ) {\n // no beginTimestamp value specified, default is 1 hour ago\n const tempStartDate = new Date();\n tempStartDate.setTime((now - SECONDS_IN_1_HOUR) * 1000);\n options.beginTimestamp = tempStartDate.toISOString();\n // also override endTimestamp to now\n const tempEndDate = new Date();\n tempEndDate.setTime(now * 1000);\n options.endTimestamp = tempEndDate;\n printMessage(\n 'No timestamps specified, defaulting to logs from 1 hour ago',\n 'info'\n );\n }\n if (\n typeof options.endTimestamp === 'undefined' ||\n !options.endTimestamp\n ) {\n // no endTimestamp value specified, default is now\n options.endTimestamp = nowString;\n printMessage(\n 'No end timestamp specified, defaulting end timestamp to \"now\"',\n 'info'\n );\n }\n let beginTs = Date.parse(options.beginTimestamp) / 1000;\n const endTs = Date.parse(options.endTimestamp) / 1000;\n if (endTs < beginTs) {\n printMessage(\n 'End timestamp can not be before begin timestamp',\n 'error'\n );\n return;\n }\n if (now - beginTs > LOG_TIME_WINDOW_MAX) {\n printMessage(\n 'Begin timestamp can not be more than 30 days in the past',\n 'error'\n );\n return;\n }\n let intermediateEndTs = 0;\n printMessage(\n `Fetching ID Cloud logs from the following sources: ${\n command.opts().sources\n } and levels [${frodo.cloud.log.resolveLevel(\n command.opts().level\n )}] of ${conn.tenant}...`\n );\n if (credsFromParameters) await frodo.conn.saveConnectionProfile(host); // save new values if they were specified on CLI\n\n let timeIncrement = LOG_TIME_WINDOW_INCREMENT;\n if (endTs - beginTs > 30) {\n timeIncrement = timeIncrement * 30;\n }\n do {\n intermediateEndTs = beginTs + timeIncrement;\n await fetchLogs(\n command.opts().sources,\n new Date(beginTs * 1000).toISOString(),\n new Date(intermediateEndTs * 1000).toISOString(),\n frodo.cloud.log.resolveLevel(command.opts().level),\n command.opts().transactionId,\n command.opts().searchString,\n null,\n config.getNoiseFilters(options.defaults)\n );\n beginTs = intermediateEndTs;\n } while (intermediateEndTs < endTs);\n }\n });\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,cAAc,QAAQ,OAAO;AACtC,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,OAAO,KAAKC,MAAM,MAAM,oBAAoB;AAC5C,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,SAAS,EAAEC,cAAc,QAAQ,kB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CAAE,QAAOjC,IAAI,CAACG,MAAO,KACvB,CAAC;IACD,IAAIJ,mBAAmB,EAAE,MAAMzB,KAAK,CAAC0B,IAAI,CAACkC,qBAAqB,CAACzC,IAAI,CAAC,CAAC,CAAC;;IAEvE,IAAI0C,aAAa,GAAGpD,yBAAyB;IAC7C,IAAI8C,KAAK,GAAGF,OAAO,GAAG,EAAE,EAAE;MACxBQ,aAAa,GAAGA,aAAa,GAAG,EAAE;IACpC;IACA,GAAG;MACDL,iBAAiB,GAAGH,OAAO,GAAGQ,aAAa;MAC3C,MAAMzD,SAAS,CACbmB,OAAO,CAACkC,IAAI,CAAC,CAAC,CAACC,OAAO,EACtB,IAAIb,IAAI,CAACQ,OAAO,GAAG,IAAI,CAAC,CAACN,WAAW,CAAC,CAAC,EACtC,IAAIF,IAAI,CAACW,iBAAiB,GAAG,IAAI,CAAC,CAACT,WAAW,CAAC,CAAC,EAChD/C,KAAK,CAACc,KAAK,CAACC,GAAG,CAACC,YAAY,CAACO,OAAO,CAACkC,IAAI,CAAC,CAAC,CAACE,KAAK,CAAC,EAClDpC,OAAO,CAACkC,IAAI,CAAC,CAAC,CAACK,aAAa,EAC5BvC,OAAO,CAACkC,IAAI,CAAC,CAAC,CAACM,YAAY,EAC3B,IAAI,EACJ7D,MAAM,CAAC8D,eAAe,CAAC1C,OAAO,CAAC2C,QAAQ,CACzC,CAAC;MACDZ,OAAO,GAAGG,iBAAiB;IAC7B,CAAC,QAAQA,iBAAiB,GAAGD,KAAK;EACpC;AACF,CAAC,CAAC;AAEJ7C,OAAO,CAAC4C,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { FrodoCommand } from '../FrodoCommand';
|
|
2
|
+
import { Option } from 'commander';
|
|
3
|
+
import { frodo } from '@rockcarver/frodo-lib';
|
|
4
|
+
import { printMessage, verboseMessage } from '../../utils/Console';
|
|
5
|
+
import { deleteLogApiKey, deleteLogApiKeys } from '../../ops/LogOps';
|
|
6
|
+
const program = new FrodoCommand('frodo log key delete');
|
|
7
|
+
program.description('Delete log API keys.').addOption(new Option('-i, --key-id <key-id>', 'Key id. Regex if specified with -a.')).addOption(new Option('-a, --all', 'Delete all keys. Optionally specify regex filter -i.')).action(
|
|
8
|
+
// implement command logic inside action handler
|
|
9
|
+
async (host, realm, user, password, options, command) => {
|
|
10
|
+
command.handleDefaultArgsAndOpts(host, realm, user, password, options, command);
|
|
11
|
+
// delete by id
|
|
12
|
+
if (options.keyId && (await frodo.login.getTokens(true))) {
|
|
13
|
+
verboseMessage(`Deleting key ${options.keyId}`);
|
|
14
|
+
deleteLogApiKey(options.keyId);
|
|
15
|
+
}
|
|
16
|
+
// --all -a
|
|
17
|
+
else if (options.all && (await frodo.login.getTokens(true))) {
|
|
18
|
+
verboseMessage('Deleting keys...');
|
|
19
|
+
deleteLogApiKeys();
|
|
20
|
+
}
|
|
21
|
+
// unrecognized combination of options or no options
|
|
22
|
+
else {
|
|
23
|
+
printMessage('Unrecognized combination of options or no options...', 'error');
|
|
24
|
+
program.help();
|
|
25
|
+
process.exitCode = 1;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// end command logic inside action handler
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
program.parse();
|
|
32
|
+
//# sourceMappingURL=log-key-delete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-key-delete.js","names":["FrodoCommand","Option","frodo","printMessage","verboseMessage","deleteLogApiKey","deleteLogApiKeys","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","keyId","login","getTokens","all","help","process","exitCode","parse"],"sources":["cli/log/log-key-delete.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { frodo } from '@rockcarver/frodo-lib';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { deleteLogApiKey, deleteLogApiKeys } from '../../ops/LogOps';\n\nconst program = new FrodoCommand('frodo log key delete');\n\nprogram\n .description('Delete log API keys.')\n .addOption(\n new Option('-i, --key-id <key-id>', 'Key id. Regex if specified with -a.')\n )\n .addOption(\n new Option(\n '-a, --all',\n 'Delete all keys. Optionally specify regex filter -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.keyId && (await frodo.login.getTokens(true))) {\n verboseMessage(`Deleting key ${options.keyId}`);\n deleteLogApiKey(options.keyId);\n }\n // --all -a\n else if (options.all && (await frodo.login.getTokens(true))) {\n verboseMessage('Deleting keys...');\n deleteLogApiKeys();\n }\n // unrecognized combination of options or no options\n else {\n printMessage(\n 'Unrecognized combination of options or no options...',\n 'error'\n );\n program.help();\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,KAAK,QAAQ,uBAAuB;AAC7C,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SAASC,eAAe,EAAEC,gBAAgB,QAAQ,kBAAkB;AAEpE,MAAMC,OAAO,GAAG,IAAIP,YAAY,CAAC,sBAAsB,CAAC;AAExDO,OAAO,CACJC,WAAW,CAAC,sBAAsB,CAAC,CACnCC,SAAS,CACR,IAAIR,MAAM,CAAC,uBAAuB,EAAE,qCAAqC,CAC3E,CAAC,CACAQ,SAAS,CACR,IAAIR,MAAM,CACR,WAAW,EACX,sDACF,CACF,CAAC,CACAS,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,MAAMhB,KAAK,CAACiB,KAAK,CAACC,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE;IACxDhB,cAAc,CAAE,gBAAeW,OAAO,CAACG,KAAM,EAAC,CAAC;IAC/Cb,eAAe,CAACU,OAAO,CAACG,KAAK,CAAC;EAChC;EACA;EAAA,KACK,IAAIH,OAAO,CAACM,GAAG,KAAK,MAAMnB,KAAK,CAACiB,KAAK,CAACC,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE;IAC3DhB,cAAc,CAAC,kBAAkB,CAAC;IAClCE,gBAAgB,CAAC,CAAC;EACpB;EACA;EAAA,KACK;IACHH,YAAY,CACV,sDAAsD,EACtD,OACF,CAAC;IACDI,OAAO,CAACe,IAAI,CAAC,CAAC;IACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEHjB,OAAO,CAACkB,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FrodoCommand } from '../FrodoCommand';
|
|
2
|
+
import { Option } from 'commander';
|
|
3
|
+
import { frodo } from '@rockcarver/frodo-lib';
|
|
4
|
+
const program = new FrodoCommand('frodo log key describe');
|
|
5
|
+
program.description('Describe log API keys.').addOption(new Option('-i, --key-id <key-id>', 'Key id. If specified, -a and -A are ignored.')).action(
|
|
6
|
+
// implement command logic inside action handler
|
|
7
|
+
async (host, realm, user, password, options, command) => {
|
|
8
|
+
command.handleDefaultArgsAndOpts(host, realm, user, password, options, command);
|
|
9
|
+
if (await frodo.login.getTokens()) {
|
|
10
|
+
// code goes here
|
|
11
|
+
} else {
|
|
12
|
+
process.exitCode = 1;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
// end command logic inside action handler
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
program.parse();
|
|
19
|
+
//# sourceMappingURL=log-key-describe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-key-describe.js","names":["FrodoCommand","Option","frodo","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","login","getTokens","process","exitCode","parse"],"sources":["cli/log/log-key-describe.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { frodo } from '@rockcarver/frodo-lib';\n\nconst program = new FrodoCommand('frodo log key describe');\n\nprogram\n .description('Describe log API keys.')\n .addOption(\n new Option(\n '-i, --key-id <key-id>',\n 'Key id. If specified, -a and -A are ignored.'\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 frodo.login.getTokens()) {\n // code goes here\n } else {\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,KAAK,QAAQ,uBAAuB;AAE7C,MAAMC,OAAO,GAAG,IAAIH,YAAY,CAAC,wBAAwB,CAAC;AAE1DG,OAAO,CACJC,WAAW,CAAC,wBAAwB,CAAC,CACrCC,SAAS,CACR,IAAIJ,MAAM,CACR,uBAAuB,EACvB,8CACF,CACF,CAAC,CACAK,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,MAAMV,KAAK,CAACY,KAAK,CAACC,SAAS,CAAC,CAAC,EAAE;IACjC;EAAA,CACD,MAAM;IACLC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEHd,OAAO,CAACe,KAAK,CAAC,CAAC"}
|