@rockcarver/frodo-cli 0.20.1-0 → 0.20.1

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 CHANGED
@@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.20.1] - 2023-01-20
11
+
12
+ ### Changed
13
+
14
+ - Updated to frodo-lib 0.18.1
15
+ - Include service account name in `frodo conn list -l` and `frodo conn describe <host>` output.
16
+ - Add missing service account name when running `frodo conn save <host>`.
17
+ - Add tenant name to beginning of output of all `frodo logs` sub-commands: `fetch`, `list`, `tail`.
18
+
19
+ ### Fixed
20
+
21
+ - \#176: frodo logs fetch end timestamp ignored
22
+
23
+ ## [0.20.1-1] - 2023-01-16
24
+
10
25
  ## [0.20.1-0] - 2023-01-15
11
26
 
12
27
  ### Fixed
@@ -107,7 +122,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
107
122
 
108
123
  - Updated list of contributors in package.json
109
124
 
110
- - Add linux arm64 binary builds
125
+ - \#166: Add linux arm64 binary builds
111
126
 
112
127
  ### Changed
113
128
 
@@ -116,6 +131,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
116
131
 
117
132
  ### Fixed
118
133
 
134
+ - \#164: Frodo now properly exports scripts with special chars in name
119
135
  - \#161: Frodo now properly adds connection profiles with log credentials
120
136
 
121
137
  ## [0.19.5-2] - 2023-01-13
@@ -960,7 +976,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
960
976
  - Fixed problem with adding connection profiles
961
977
  - Miscellaneous bug fixes
962
978
 
963
- [Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v0.20.1-0...HEAD
979
+ [Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v0.20.1...HEAD
980
+
981
+ [0.20.1]: https://github.com/rockcarver/frodo-cli/compare/v0.20.1-1...v0.20.1
982
+
983
+ [0.20.1-1]: https://github.com/rockcarver/frodo-cli/compare/v0.20.1-0...v0.20.1-1
964
984
 
965
985
  [0.20.1-0]: https://github.com/rockcarver/frodo-cli/compare/v0.20.0...v0.20.1-0
966
986
 
@@ -10,7 +10,7 @@ process.env.FRODO_REALM || globalConfig.DEFAULT_REALM_KEY, '"alpha" for Identity
10
10
  const usernameArgument = new Argument('[username]', 'Username to login with. Must be an admin user with appropriate rights to manage authentication journeys/trees.');
11
11
  const passwordArgument = new Argument('[password]', 'Password.');
12
12
  const serviceAccountIdOption = new Option('--sa-id <sa-id>', 'Service account id.');
13
- const serviceAccountJwkFileOption = new Option('--sa-jwk-file <file>', 'File containing the java web key (jwk) associated with the the service account.');
13
+ const serviceAccountJwkFileOption = new Option('--sa-jwk-file <file>', 'File containing the JSON Web Key (JWK) associated with the the service account.');
14
14
  const deploymentOption = new Option('-m, --type <type>', 'Override auto-detected deployment type. Valid values for type: \n\
15
15
  classic: A classic Access Management-only deployment with custom layout and configuration. \n\
16
16
  cloud: A ForgeRock Identity Cloud environment. \n\
@@ -111,6 +111,10 @@ export class FrodoCommand extends FrodoStubCommand {
111
111
 
112
112
  // handle arguments first
113
113
  for (const [i, v] of command.args.entries()) {
114
+ if (!command._args[i]) {
115
+ printMessage(`${command.args.length} arguments supplied but command only supports ${command._args.length}.`, 'warn');
116
+ break;
117
+ }
114
118
  const arg = command._args[i].name();
115
119
  // handle only default arguments
116
120
  if (Object.keys(stateMap).includes(arg)) {
@@ -1 +1 @@
1
- {"version":3,"file":"FrodoCommand.js","names":["Argument","Command","Option","globalConfig","state","fs","printMessage","createProgressIndicator","updateProgressIndicator","stopProgressIndicator","verboseMessage","debugMessage","curlirizeMessage","hostArgument","realmArgument","default","process","env","FRODO_REALM","DEFAULT_REALM_KEY","usernameArgument","passwordArgument","serviceAccountIdOption","serviceAccountJwkFileOption","deploymentOption","choices","DEPLOYMENT_TYPES","insecureOption","verboseOption","debugOption","curlirizeOption","defaultArgs","defaultOpts","stateMap","name","setHost","setRealm","setUsername","setPassword","attributeName","setServiceAccountId","file","data","readFileSync","jwk","JSON","parse","toString","setServiceAccountJwk","error","message","setDeploymentType","setAllowInsecureConnection","setVerbose","setDebug","setCurlirize","FrodoStubCommand","constructor","helpOption","showHelpAfterError","configureHelp","sortSubcommands","sortOptions","setPrintHandler","setVerboseHandler","setDebugHandler","setCurlirizeHandler","setCreateProgressHandler","setUpdateProgressHandler","setStopProgressHandler","FrodoCommand","omits","arg","includes","addArgument","opt","addOption","handleDefaultArgsAndOpts","args","command","pop","options","i","v","entries","_args","Object","keys","handler","k"],"sources":["cli/FrodoCommand.ts"],"sourcesContent":["import { Argument, Command, Option } from 'commander';\nimport * as globalConfig from '../storage/StaticStorage';\nimport { state } from '@rockcarver/frodo-lib';\nimport fs from 'fs';\nimport {\n printMessage,\n createProgressIndicator,\n updateProgressIndicator,\n stopProgressIndicator,\n verboseMessage,\n debugMessage,\n curlirizeMessage,\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 java 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 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 insecureOption,\n verboseOption,\n debugOption,\n curlirizeOption,\n];\n\nconst stateMap = {\n [hostArgument.name()]: state.setHost,\n [realmArgument.name()]: state.setRealm,\n [usernameArgument.name()]: state.setUsername,\n [passwordArgument.name()]: state.setPassword,\n [serviceAccountIdOption.attributeName()]: state.setServiceAccountId,\n [serviceAccountJwkFileOption.attributeName()]: (file) => {\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()]: state.setDeploymentType,\n [insecureOption.attributeName()]: state.setAllowInsecureConnection,\n [verboseOption.attributeName()]: state.setVerbose,\n [debugOption.attributeName()]: state.setDebug,\n [curlirizeOption.attributeName()]: state.setCurlirize,\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 // 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\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 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,QAAQ,EAAEC,OAAO,EAAEC,MAAM,QAAQ,WAAW;AACrD,OAAO,KAAKC,YAAY,MAAM,0BAA0B;AACxD,SAASC,KAAK,QAAQ,uBAAuB;AAC7C,OAAOC,EAAE,MAAM,IAAI;AACnB,SACEC,YAAY,EACZC,uBAAuB,EACvBC,uBAAuB,EACvBC,qBAAqB,EACrBC,cAAc,EACdC,YAAY,EACZC,gBAAgB,QACX,qBAAqB;AAE5B,MAAMC,YAAY,GAAG,IAAIb,QAAQ,CAC/B,QAAQ,EACR,iIAAiI,CAClI;AAED,MAAMc,aAAa,GAAG,IAAId,QAAQ,CAChC,SAAS,EACT,yFAAyF,CAC1F,CAACe,OAAO;AACP;AACAC,OAAO,CAACC,GAAG,CAACC,WAAW,IAAIf,YAAY,CAACgB,iBAAiB,EACzD,oDAAoD,CACrD;AAED,MAAMC,gBAAgB,GAAG,IAAIpB,QAAQ,CACnC,YAAY,EACZ,gHAAgH,CACjH;AAED,MAAMqB,gBAAgB,GAAG,IAAIrB,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAC;AAEhE,MAAMsB,sBAAsB,GAAG,IAAIpB,MAAM,CACvC,iBAAiB,EACjB,qBAAqB,CACtB;AAED,MAAMqB,2BAA2B,GAAG,IAAIrB,MAAM,CAC5C,sBAAsB,EACtB,iFAAiF,CAClF;AAED,MAAMsB,gBAAgB,GAAG,IAAItB,MAAM,CACjC,mBAAmB,EACnB;AACF;AACA;AACA;AACA;AACA;AACA,6EAA6E,CAC5E,CAACuB,OAAO,CAACtB,YAAY,CAACuB,gBAAgB,CAAC;AAExC,MAAMC,cAAc,GAAG,IA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M,CAACC,IAAI,CAACtD,QAAQ,CAAC,CAACwC,QAAQ,CAACgB,CAAC,CAAC,EAAE;QACrC9E,YAAY,CACT,mEAAkE8E,CAAE,IAAG,CACzE;QACD;QACA,MAAMD,OAAY,GAAGvD,QAAQ,CAACwD,CAAC,CAAC;QAChCD,OAAO,CAACL,CAAC,CAAC;MACZ,CAAC,MAAM;QACLxE,YAAY,CACT,uEAAsE8E,CAAE,IAAG,CAC7E;MACH;IACF;EACF;AACF"}
1
+ {"version":3,"file":"FrodoCommand.js","names":["Argument","Command","Option","globalConfig","state","fs","printMessage","createProgressIndicator","updateProgressIndicator","stopProgressIndicator","verboseMessage","debugMessage","curlirizeMessage","hostArgument","realmArgument","default","process","env","FRODO_REALM","DEFAULT_REALM_KEY","usernameArgument","passwordArgument","serviceAccountIdOption","serviceAccountJwkFileOption","deploymentOption","choices","DEPLOYMENT_TYPES","insecureOption","verboseOption","debugOption","curlirizeOption","defaultArgs","defaultOpts","stateMap","name","setHost","setRealm","setUsername","setPassword","attributeName","setServiceAccountId","file","data","readFileSync","jwk","JSON","parse","toString","setServiceAccountJwk","error","message","setDeploymentType","setAllowInsecureConnection","setVerbose","setDebug","setCurlirize","FrodoStubCommand","constructor","helpOption","showHelpAfterError","configureHelp","sortSubcommands","sortOptions","setPrintHandler","setVerboseHandler","setDebugHandler","setCurlirizeHandler","setCreateProgressHandler","setUpdateProgressHandler","setStopProgressHandler","FrodoCommand","omits","arg","includes","addArgument","opt","addOption","handleDefaultArgsAndOpts","args","command","pop","options","i","v","entries","_args","length","Object","keys","handler","k"],"sources":["cli/FrodoCommand.ts"],"sourcesContent":["import { Argument, Command, Option } from 'commander';\nimport * as globalConfig from '../storage/StaticStorage';\nimport { state } from '@rockcarver/frodo-lib';\nimport fs from 'fs';\nimport {\n printMessage,\n createProgressIndicator,\n updateProgressIndicator,\n stopProgressIndicator,\n verboseMessage,\n debugMessage,\n curlirizeMessage,\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 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 insecureOption,\n verboseOption,\n debugOption,\n curlirizeOption,\n];\n\nconst stateMap = {\n [hostArgument.name()]: state.setHost,\n [realmArgument.name()]: state.setRealm,\n [usernameArgument.name()]: state.setUsername,\n [passwordArgument.name()]: state.setPassword,\n [serviceAccountIdOption.attributeName()]: state.setServiceAccountId,\n [serviceAccountJwkFileOption.attributeName()]: (file) => {\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()]: state.setDeploymentType,\n [insecureOption.attributeName()]: state.setAllowInsecureConnection,\n [verboseOption.attributeName()]: state.setVerbose,\n [debugOption.attributeName()]: state.setDebug,\n [curlirizeOption.attributeName()]: state.setCurlirize,\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 // 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\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,QAAQ,EAAEC,OAAO,EAAEC,MAAM,QAAQ,WAAW;AACrD,OAAO,KAAKC,YAAY,MAAM,0BAA0B;AACxD,SAASC,KAAK,QAAQ,uBAAuB;AAC7C,OAAOC,EAAE,MAAM,IAAI;AACnB,SACEC,YAAY,EACZC,uBAAuB,EACvBC,uBAAuB,EACvBC,qBAAqB,EACrBC,cAAc,EACdC,YAAY,EACZC,gBAAgB,QACX,qBAAqB;AAE5B,MAAMC,YAAY,GAAG,IAAIb,QAAQ,CAC/B,QAAQ,EACR,i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MC,OAAO,GAAGH,IAAI,CAACE,GAAG,EAAE;;IAE1B;IACA,KAAK,MAAM,CAACE,CAAC,EAAEC,CAAC,CAAC,IAAIJ,OAAO,CAACD,IAAI,CAACM,OAAO,EAAE,EAAE;MAC3C,IAAI,CAACL,OAAO,CAACM,KAAK,CAACH,CAAC,CAAC,EAAE;QACrB5E,YAAY,CACT,GAAEyE,OAAO,CAACD,IAAI,CAACQ,MAAO,iDAAgDP,OAAO,CAACM,KAAK,CAACC,MAAO,GAAE,EAC9F,MAAM,CACP;QACD;MACF;MACA,MAAMd,GAAG,GAAGO,OAAO,CAACM,KAAK,CAACH,CAAC,CAAC,CAAChD,IAAI,EAAE;MACnC;MACA,IAAIqD,MAAM,CAACC,IAAI,CAACvD,QAAQ,CAAC,CAACwC,QAAQ,CAACD,GAAG,CAAC,EAAE;QACvC7D,YAAY,CACT,qEAAoE6D,GAAI,IAAG,CAC7E;QACD;QACA,MAAMiB,OAAY,GAAGxD,QAAQ,CAACuC,GAAG,CAAC;QAClCiB,OAAO,CAACN,CAAC,CAAC;MACZ,CAAC,MAAM;QACLxE,YAAY,CACT,yEAAwE6D,GAAI,IAAG,CACjF;MACH;IACF;;IAEA;IACA,KAAK,MAAM,CAACkB,CAAC,EAAEP,CAAC,CAAC,IAAII,MAAM,CAACH,OAAO,CAACH,OAAO,CAAC,EAAE;MAC5C;MACA,IAAIM,MAAM,CAACC,IAAI,CAACvD,QAAQ,CAAC,CAACwC,QAAQ,CAACiB,CAAC,CAAC,EAAE;QACrC/E,YAAY,CACT,mEAAkE+E,CAAE,IAAG,CACzE;QACD;QACA,MAAMD,OAAY,GAAGxD,QAAQ,CAACyD,CAAC,CAAC;QAChCD,OAAO,CAACN,CAAC,CAAC;MACZ,CAAC,MAAM;QACLxE,YAAY,CACT,uEAAsE+E,CAAE,IAAG,CAC7E;MACH;IACF;EACF;AACF"}
@@ -32,64 +32,66 @@ Cannot be more than 30 days in the past. If not specified, logs from one hour ag
32
32
  command.handleDefaultArgsAndOpts(host, user, password, options, command);
33
33
  let credsFromParameters = true;
34
34
  const conn = await getConnectionProfile();
35
- state.setHost(conn.tenant);
36
- if (conn.logApiKey != null && conn.logApiSecret != null) {
37
- credsFromParameters = false;
38
- state.setLogApiKey(conn.logApiKey);
39
- state.setLogApiSecret(conn.logApiSecret);
40
- } else {
41
- if (conn.username == null && conn.password == null) {
42
- if (!state.getUsername() && !state.getPassword()) {
43
- credsFromParameters = false;
44
- printMessage('User credentials not specified as parameters and no saved API key and secret found!', 'warn');
45
- return;
46
- }
35
+ if (conn) {
36
+ state.setHost(conn.tenant);
37
+ if (conn.logApiKey != null && conn.logApiSecret != null) {
38
+ credsFromParameters = false;
39
+ state.setLogApiKey(conn.logApiKey);
40
+ state.setLogApiSecret(conn.logApiSecret);
47
41
  } else {
48
- state.setUsername(conn.username);
49
- state.setPassword(conn.password);
42
+ if (conn.username == null && conn.password == null) {
43
+ if (!state.getUsername() && !state.getPassword()) {
44
+ credsFromParameters = false;
45
+ printMessage('User credentials not specified as parameters and no saved API key and secret found!', 'warn');
46
+ return;
47
+ }
48
+ } else {
49
+ state.setUsername(conn.username);
50
+ state.setPassword(conn.password);
51
+ }
52
+ if (await getTokens()) {
53
+ const creds = await provisionCreds();
54
+ state.setLogApiKey(creds.api_key_id);
55
+ state.setLogApiSecret(creds.api_key_secret);
56
+ }
50
57
  }
51
- if (await getTokens()) {
52
- const creds = await provisionCreds();
53
- state.setLogApiKey(creds.api_key_id);
54
- state.setLogApiSecret(creds.api_key_secret);
58
+ const now = Date.now() / 1000;
59
+ const nowString = new Date(now * 1000).toISOString();
60
+ if (typeof options.beginTimestamp === 'undefined' || !options.beginTimestamp) {
61
+ // no beginTimestamp value specified, default is 1 hour ago
62
+ const tempStartDate = new Date();
63
+ tempStartDate.setTime((now - SECONDS_IN_1_HOUR) * 1000);
64
+ options.beginTimestamp = tempStartDate.toISOString();
65
+ // also override endTimestamp to now
66
+ const tempEndDate = new Date();
67
+ tempEndDate.setTime(now * 1000);
68
+ options.endTimestamp = tempEndDate;
69
+ printMessage('No timestamps specified, defaulting to logs from 1 hour ago', 'info');
55
70
  }
56
- }
57
- const now = Date.now() / 1000;
58
- const nowString = new Date(now * 1000).toISOString();
59
- if (typeof options.beginTimestamp === 'undefined' || !options.beginTimestamp) {
60
- // no beginTimestamp value specified, default is 1 hour ago
61
- const tempStartDate = new Date();
62
- tempStartDate.setTime((now - SECONDS_IN_1_HOUR) * 1000);
63
- options.beginTimestamp = tempStartDate.toISOString();
64
- // also override endTimestamp to now
65
- const tempEndDate = new Date();
66
- tempEndDate.setTime(now * 1000);
67
- options.endTimestamp = tempEndDate;
68
- printMessage('No timestamps specified, defaulting to logs from 1 hour ago', 'info');
69
- }
70
- if (typeof options.endTimestamp === 'undefined' || !options.endTimestamp) {
71
- // no endTimestamp value specified, default is now
72
- options.endTimestamp = nowString;
73
- printMessage('No end timestamp specified, defaulting end timestamp to "now"', 'info');
74
- }
75
- let beginTs = Date.parse(options.beginTimestamp) / 1000;
76
- if (Date.parse(options.endTimestamp) / 1000 < beginTs) {
77
- printMessage('End timestamp can not be before begin timestamp', 'error');
78
- return;
79
- }
80
- if (now - beginTs > LOG_TIME_WINDOW_MAX) {
81
- printMessage('Begin timestamp can not be more than 30 days in the past', 'error');
82
- return;
83
- }
84
- let intermediateEndTs = 0;
85
- printMessage(`Fetching ID Cloud logs from the following sources: ${command.opts().sources} and levels [${resolveLevel(command.opts().level)}]...`);
86
- if (credsFromParameters) await saveConnectionProfile(host); // save new values if they were specified on CLI
71
+ if (typeof options.endTimestamp === 'undefined' || !options.endTimestamp) {
72
+ // no endTimestamp value specified, default is now
73
+ options.endTimestamp = nowString;
74
+ printMessage('No end timestamp specified, defaulting end timestamp to "now"', 'info');
75
+ }
76
+ let beginTs = Date.parse(options.beginTimestamp) / 1000;
77
+ if (Date.parse(options.endTimestamp) / 1000 < beginTs) {
78
+ printMessage('End timestamp can not be before begin timestamp', 'error');
79
+ return;
80
+ }
81
+ if (now - beginTs > LOG_TIME_WINDOW_MAX) {
82
+ printMessage('Begin timestamp can not be more than 30 days in the past', 'error');
83
+ return;
84
+ }
85
+ let intermediateEndTs = 0;
86
+ printMessage(`Fetching ID Cloud logs from the following sources: ${command.opts().sources} and levels [${resolveLevel(command.opts().level)}] of ${conn.tenant}...`);
87
+ if (credsFromParameters) await saveConnectionProfile(host); // save new values if they were specified on CLI
87
88
 
88
- do {
89
- intermediateEndTs = beginTs + LOG_TIME_WINDOW_INCREMENT;
90
- await fetchLogs(command.opts().sources, new Date(beginTs * 1000).toISOString(), new Date(intermediateEndTs * 1000).toISOString(), resolveLevel(command.opts().level), command.opts().transactionId, command.opts().searchString, null, config.getNoiseFilters(options.defaults));
91
- beginTs = intermediateEndTs;
92
- } while (intermediateEndTs < Date.parse(options.endTimestamp) / 1000);
89
+ do {
90
+ intermediateEndTs = beginTs + LOG_TIME_WINDOW_INCREMENT;
91
+ await fetchLogs(command.opts().sources, new Date(beginTs * 1000).toISOString(), new Date(intermediateEndTs * 1000).toISOString(), resolveLevel(command.opts().level), command.opts().transactionId, command.opts().searchString, null, config.getNoiseFilters(options.defaults));
92
+ beginTs = intermediateEndTs;
93
+ } while (intermediateEndTs < Date.parse(options.endTimestamp) / 1000);
94
+ }
93
95
  });
94
96
  program.parse();
95
97
  //# sourceMappingURL=logs-fetch.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"logs-fetch.js","names":["FrodoCommand","sourcesOptionM","Option","Authenticate","ConnectionProfile","Log","state","config","printMessage","provisionCreds","fetchLogs","resolveLevel","getConnectionProfile","saveConnectionProfile","getTokens","SECONDS_IN_30_DAYS","SECONDS_IN_1_HOUR","LOG_TIME_WINDOW_MAX","LOG_TIME_WINDOW_INCREMENT","program","description","addOption","default","FRODO_LOG_NOISEFILTER_FILENAME","action","host","user","password","options","command","handleDefaultArgsAndOpts","credsFromParameters","conn","setHost","tenant","logApiKey","logApiSecret","setLogApiKey","setLogApiSecret","username","getUsername","getPassword","setUsername","setPassword","creds","api_key_id","api_key_secret","now","Date","nowString","toISOString","beginTimestamp","tempStartDate","setTime","tempEndDate","endTimestamp","beginTs","parse","intermediateEndTs","opts","sources","level","transactionId","searchString","getNoiseFilters","defaults"],"sources":["cli/logging/logs-fetch.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { sourcesOptionM } from './logs';\nimport { Option } from 'commander';\nimport {\n Authenticate,\n ConnectionProfile,\n Log,\n state,\n} from '@rockcarver/frodo-lib';\nimport * as config from '../../utils/Config';\nimport { printMessage } from '../../utils/Console';\n\nconst { provisionCreds, fetchLogs, resolveLevel } = Log;\nconst { getConnectionProfile, saveConnectionProfile } = ConnectionProfile;\nconst { getTokens } = Authenticate;\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 logs 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', `${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 getConnectionProfile();\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 getTokens()) {\n const creds = await provisionCreds();\n state.setLogApiKey(creds.api_key_id);\n state.setLogApiSecret(creds.api_key_secret);\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 (typeof options.endTimestamp === 'undefined' || !options.endTimestamp) {\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 if (Date.parse(options.endTimestamp) / 1000 < beginTs) {\n printMessage('End timestamp can not be before begin timestamp', 'error');\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 [${resolveLevel(command.opts().level)}]...`\n );\n if (credsFromParameters) await saveConnectionProfile(host); // save new values if they were specified on CLI\n\n do {\n intermediateEndTs = beginTs + LOG_TIME_WINDOW_INCREMENT;\n await fetchLogs(\n command.opts().sources,\n new Date(beginTs * 1000).toISOString(),\n new Date(intermediateEndTs * 1000).toISOString(),\n 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 < Date.parse(options.endTimestamp) / 1000);\n });\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,cAAc,QAAQ,QAAQ;AACvC,SAASC,MAAM,QAAQ,WAAW;AAClC,SACEC,YAAY,EACZC,iBAAiB,EACjBC,GAAG,EACHC,KAAK,QACA,uBAAuB;AAC9B,OAAO,KAAKC,MAAM,MAAM,oBAAoB;AAC5C,SAASC,YAAY,QAAQ,qBAAqB;AAElD,MAAM;EAAEC,cAAc;EAAEC,SAAS;EAAEC;AAAa,CAAC,GAAGN,GAAG;AACvD,MAAM;EAAEO,oBAAoB;EAAEC;AAAsB,CAAC,GAAGT,iBAAiB;AACzE,MAAM;EAAEU;AAAU,CAAC,GAAGX,YAAY;AAElC,MAAMY,kBAAkB,GAAG,OAAO;AAClC,MAAMC,iBAAiB,GAAG,IAAI;AAC9B,MAAMC,mBAAmB,GAAGF,kBAAkB;AAC9C,MAAMG,yBAAyB,GAAG,CAAC;AAEnC,MAAMC,OAAO,GAAG,IAAInB,YAAY,CAAC,kBAAkB,EAAE,CAAC,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AACG,aAAa,EAC5BjC,OAAO,CAAC8B,IAAI,EAAE,CAACI,YAAY,EAC3B,IAAI,EACJxD,MAAM,CAACyD,eAAe,CAACpC,OAAO,CAACqC,QAAQ,CAAC,CACzC;IACDT,OAAO,GAAGE,iBAAiB;EAC7B,CAAC,QAAQA,iBAAiB,GAAGV,IAAI,CAACS,KAAK,CAAC7B,OAAO,CAAC2B,YAAY,CAAC,GAAG,IAAI;AACtE,CAAC,CAAC;AAEJpC,OAAO,CAACsC,KAAK,EAAE"}
1
+ {"version":3,"file":"logs-fetch.js","names":["FrodoCommand","sourcesOptionM","Option","Authenticate","ConnectionProfile","Log","state","config","printMessage","provisionCreds","fetchLogs","resolveLevel","getConnectionProfile","saveConnectionProfile","getTokens","SECONDS_IN_30_DAYS","SECONDS_IN_1_HOUR","LOG_TIME_WINDOW_MAX","LOG_TIME_WINDOW_INCREMENT","program","description","addOption","default","FRODO_LOG_NOISEFILTER_FILENAME","action","host","user","password","options","command","handleDefaultArgsAndOpts","credsFromParameters","conn","setHost","tenant","logApiKey","logApiSecret","setLogApiKey","setLogApiSecret","username","getUsername","getPassword","setUsername","setPassword","creds","api_key_id","api_key_secret","now","Date","nowString","toISOString","beginTimestamp","tempStartDate","setTime","tempEndDate","endTimestamp","beginTs","parse","intermediateEndTs","opts","sources","level","transactionId","searchString","getNoiseFilters","defaults"],"sources":["cli/logging/logs-fetch.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { sourcesOptionM } from './logs';\nimport { Option } from 'commander';\nimport {\n Authenticate,\n ConnectionProfile,\n Log,\n state,\n} from '@rockcarver/frodo-lib';\nimport * as config from '../../utils/Config';\nimport { printMessage } from '../../utils/Console';\n\nconst { provisionCreds, fetchLogs, resolveLevel } = Log;\nconst { getConnectionProfile, saveConnectionProfile } = ConnectionProfile;\nconst { getTokens } = Authenticate;\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 logs 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', `${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 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 getTokens()) {\n const creds = await provisionCreds();\n state.setLogApiKey(creds.api_key_id);\n state.setLogApiSecret(creds.api_key_secret);\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 if (Date.parse(options.endTimestamp) / 1000 < 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 [${resolveLevel(command.opts().level)}] of ${\n conn.tenant\n }...`\n );\n if (credsFromParameters) await saveConnectionProfile(host); // save new values if they were specified on CLI\n\n do {\n intermediateEndTs = beginTs + LOG_TIME_WINDOW_INCREMENT;\n await fetchLogs(\n command.opts().sources,\n new Date(beginTs * 1000).toISOString(),\n new Date(intermediateEndTs * 1000).toISOString(),\n 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 < Date.parse(options.endTimestamp) / 1000);\n }\n });\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,cAAc,QAAQ,QAAQ;AACvC,SAASC,MAAM,QAAQ,WAAW;AAClC,SACEC,YAAY,EACZC,iBAAiB,EACjBC,GAAG,EACHC,KAAK,QACA,uBAAuB;AAC9B,OAAO,KAAKC,MAAM,MAAM,oBAAoB;AAC5C,SAASC,YAAY,QAAQ,qBAAqB;AAElD,MAAM;EAAEC,cAAc;EAAEC,SAAS;EAAEC;AAAa,CAAC,GAAGN,GAAG;AACvD,MAAM;EAAEO,oBAAoB;EAAEC;AAAsB,CAAC,GAAGT,iBAAiB;AACzE,MAAM;EAAEU;AAAU,CAAC,GAAGX,YAAY;AAElC,MAAMY,kBAAkB,GAAG,OAAO;AAClC,MAAMC,iBAAiB,GAAG,IAAI;AAC9B,MAAMC,mBAAmB,GAAGF,kBAAkB;AAC9C,MAAMG,yBAAyB,GAAG,CAAC;AAEnC,MAAMC,OAAO,GAAG,IAAInB,YAAY,CAAC,kBAAkB,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AACvEmB,OAAO,CACJC,WAAW,CACV;AACJ,wGAAwG,CACrG,CACAC,SAAS,CAACpB,cAAc,CAAC,CACzBoB,SAAS,CACR,IAAInB,MAAM,CACR,qBAAqB,EACrB;AACN;AACA;AACA;AACA,WAAW,CACN,CAACoB,OAAO,CAAC,OAAO,EAAG,GAAEX,YAAY,CAAC,OAAO,CAAE,EAAC,CAAC,CAC/C,CACAU,SAAS,CACR,IAAInB,MAAM,CAAC,6BAA6B,EAAE,yBAAyB,CAAC,CACrE,CACAmB,SAAS,CACR,IAAInB,MAAM,CACR,iCAAiC,EACjC;AACN;AACA,gBAAgB,CACX,CACF,CACAmB,SAAS,CACR,IAAInB,MAAM,CACR,6BAA6B,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;MACrDhD,YAAY,CACV,iDAAiD,EACjD,OAAO,CACR;MACD;IACF;IACA,IAAIuC,GAAG,GAAGS,OAAO,GAAGvC,mBAAmB,EAAE;MACvCT,YAAY,CACV,0DAA0D,EAC1D,OAAO,CACR;MACD;IACF;IACA,IAAIkD,iBAAiB,GAAG,CAAC;IACzBlD,YAAY,CACT,sDACCqB,OAAO,CAAC8B,IAAI,EAAE,CAACC,OAChB,gBAAejD,YAAY,CAACkB,OAAO,CAAC8B,IAAI,EAAE,CAACE,KAAK,CAAE,QACjD7B,IAAI,CAACE,MACN,KAAI,CACN;IACD,IAAIH,mBAAmB,EAAE,MAAMlB,qBAAqB,CAACY,IAAI,CAAC,CAAC,CAAC;;IAE5D,GAAG;MACDiC,iBAAiB,GAAGF,OAAO,GAAGtC,yBAAyB;MACvD,MAAMR,SAAS,CACbmB,OAAO,CAAC8B,IAAI,EAAE,CAACC,OAAO,EACtB,IAAIZ,IAAI,CAACQ,OAAO,GAAG,IAAI,CAAC,CAACN,WAAW,EAAE,EACtC,IAAIF,IAAI,CAACU,iBAAiB,GAAG,IAAI,CAAC,CAACR,WAAW,EAAE,EAChDvC,YAAY,CAACkB,OAAO,CAAC8B,IAAI,EAAE,CAACE,KAAK,CAAC,EAClChC,OAAO,CAAC8B,IAAI,EAAE,CAACG,aAAa,EAC5BjC,OAAO,CAAC8B,IAAI,EAAE,CAACI,YAAY,EAC3B,IAAI,EACJxD,MAAM,CAACyD,eAAe,CAACpC,OAAO,CAACqC,QAAQ,CAAC,CACzC;MACDT,OAAO,GAAGE,iBAAiB;IAC7B,CAAC,QAAQA,iBAAiB,GAAGV,IAAI,CAACS,KAAK,CAAC7B,OAAO,CAAC2B,YAAY,CAAC,GAAG,IAAI;EACtE;AACF,CAAC,CAAC;AAEJpC,OAAO,CAACsC,KAAK,EAAE"}
@@ -18,39 +18,42 @@ program.description('List available ID Cloud log sources.').action(async (host,
18
18
  let credsFromParameters = true;
19
19
  verboseMessage('Listing available ID Cloud log sources...');
20
20
  const conn = await getConnectionProfile();
21
- state.setHost(conn.tenant);
22
- if (conn.logApiKey != null && conn.logApiSecret != null) {
23
- credsFromParameters = false;
24
- state.setLogApiKey(conn.logApiKey);
25
- state.setLogApiSecret(conn.logApiSecret);
26
- } else {
27
- if (conn.username == null && conn.password == null) {
28
- if (!state.getUsername() && !state.getPassword()) {
29
- credsFromParameters = false;
30
- printMessage('User credentials not specified as parameters and no saved API key and secret found!', 'warn');
31
- return;
32
- }
21
+ if (conn) {
22
+ state.setHost(conn.tenant);
23
+ if (conn.logApiKey != null && conn.logApiSecret != null) {
24
+ credsFromParameters = false;
25
+ state.setLogApiKey(conn.logApiKey);
26
+ state.setLogApiSecret(conn.logApiSecret);
33
27
  } else {
34
- state.setUsername(conn.username);
35
- state.setPassword(conn.password);
28
+ if (conn.username == null && conn.password == null) {
29
+ if (!state.getUsername() && !state.getPassword()) {
30
+ credsFromParameters = false;
31
+ printMessage('User credentials not specified as parameters and no saved API key and secret found!', 'warn');
32
+ return;
33
+ }
34
+ } else {
35
+ state.setUsername(conn.username);
36
+ state.setPassword(conn.password);
37
+ }
38
+ if (await getTokens()) {
39
+ const creds = await provisionCreds();
40
+ state.setLogApiKey(creds.api_key_id);
41
+ state.setLogApiSecret(creds.api_key_secret);
42
+ }
36
43
  }
37
- if (await getTokens()) {
38
- const creds = await provisionCreds();
39
- state.setLogApiKey(creds.api_key_id);
40
- state.setLogApiSecret(creds.api_key_secret);
44
+ const sources = await getLogSources();
45
+ if (sources.length === 0) {
46
+ printMessage("Can't get sources, possible cause - wrong API key or secret", 'error');
47
+ } else {
48
+ if (credsFromParameters) await saveConnectionProfile(host); // save new values if they were specified on CLI
49
+ printMessage(`Log sources from ${conn.tenant}`);
50
+ sources.forEach(source => {
51
+ printMessage(`${source}`, 'data');
52
+ });
53
+ printMessage('Use any combination of comma separated sources, example:', 'info');
54
+ printMessage(`$ frodo logs tail -c am-core,idm-core ${host}`, 'text');
41
55
  }
42
56
  }
43
- const sources = await getLogSources();
44
- if (sources.length === 0) {
45
- printMessage("Can't get sources, possible cause - wrong API key or secret", 'error');
46
- } else {
47
- if (credsFromParameters) await saveConnectionProfile(host); // save new values if they were specified on CLI
48
- sources.forEach(source => {
49
- printMessage(`${source}`, 'data');
50
- });
51
- printMessage('Use any combination of comma separated sources:', 'info');
52
- printMessage(`$ frodo logs tail -c am-core,idm-core ${host}`, 'text');
53
- }
54
57
  });
55
58
  program.parse();
56
59
  //# sourceMappingURL=logs-list.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"logs-list.js","names":["FrodoCommand","Authenticate","ConnectionProfile","Log","state","printMessage","verboseMessage","provisionCreds","getLogSources","getConnectionProfile","saveConnectionProfile","getTokens","program","description","action","host","user","password","options","command","handleDefaultArgsAndOpts","credsFromParameters","conn","setHost","tenant","logApiKey","logApiSecret","setLogApiKey","setLogApiSecret","username","getUsername","getPassword","setUsername","setPassword","creds","api_key_id","api_key_secret","sources","length","forEach","source","parse"],"sources":["cli/logging/logs-list.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport {\n Authenticate,\n ConnectionProfile,\n Log,\n state,\n} from '@rockcarver/frodo-lib';\nimport { printMessage, verboseMessage } from '../../utils/Console';\n\nconst { provisionCreds, getLogSources } = Log;\nconst { getConnectionProfile, saveConnectionProfile } = ConnectionProfile;\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo logs list', ['realm', 'type']);\nprogram\n .description('List available ID Cloud log sources.')\n .action(async (host, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(host, user, password, options, command);\n let credsFromParameters = true;\n verboseMessage('Listing available ID Cloud log sources...');\n const conn = await getConnectionProfile();\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 getTokens()) {\n const creds = await provisionCreds();\n state.setLogApiKey(creds.api_key_id);\n state.setLogApiSecret(creds.api_key_secret);\n }\n }\n\n const sources = await getLogSources();\n if (sources.length === 0) {\n printMessage(\n \"Can't get sources, possible cause - wrong API key or secret\",\n 'error'\n );\n } else {\n if (credsFromParameters) await saveConnectionProfile(host); // save new values if they were specified on CLI\n sources.forEach((source) => {\n printMessage(`${source}`, 'data');\n });\n printMessage('Use any combination of comma separated sources:', 'info');\n printMessage(`$ frodo logs tail -c am-core,idm-core ${host}`, 'text');\n }\n });\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SACEC,YAAY,EACZC,iBAAiB,EACjBC,GAAG,EACHC,KAAK,QACA,uBAAuB;AAC9B,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAElE,MAAM;EAAEC,cAAc;EAAEC;AAAc,CAAC,GAAGL,GAAG;AAC7C,MAAM;EAAEM,oBAAoB;EAAEC;AAAsB,CAAC,GAAGR,iBAAiB;AACzE,MAAM;EAAES;AAAU,CAAC,GAAGV,YAAY;AAElC,MAAMW,OAAO,GAAG,IAAIZ,YAAY,CAAC,iBAAiB,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AACtEY,OAAO,CACJC,WAAW,CAAC,sCAAsC,CAAC,CACnDC,MAAM,CAAC,OAAOC,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EACxDA,OAAO,CAACC,wBAAwB,CAACL,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,CAAC;EACxE,IAAIE,mBAAmB,GAAG,IAAI;EAC9Bf,cAAc,CAAC,2CAA2C,CAAC;EAC3D,MAAMgB,IAAI,GAAG,MAAMb,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AAE,GAAEmC,MAAO,EAAC,EAAE,MAAM,CAAC;IACnC,CAAC,CAAC;IACFnC,YAAY,CAAC,iDAAiD,EAAE,MAAM,CAAC;IACvEA,YAAY,CAAE,yCAAwCU,IAAK,EAAC,EAAE,MAAM,CAAC;EACvE;AACF,CAAC,CAAC;AAEJH,OAAO,CAAC6B,KAAK,EAAE"}
1
+ {"version":3,"file":"logs-list.js","names":["FrodoCommand","Authenticate","ConnectionProfile","Log","state","printMessage","verboseMessage","provisionCreds","getLogSources","getConnectionProfile","saveConnectionProfile","getTokens","program","description","action","host","user","password","options","command","handleDefaultArgsAndOpts","credsFromParameters","conn","setHost","tenant","logApiKey","logApiSecret","setLogApiKey","setLogApiSecret","username","getUsername","getPassword","setUsername","setPassword","creds","api_key_id","api_key_secret","sources","length","forEach","source","parse"],"sources":["cli/logging/logs-list.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport {\n Authenticate,\n ConnectionProfile,\n Log,\n state,\n} from '@rockcarver/frodo-lib';\nimport { printMessage, verboseMessage } from '../../utils/Console';\n\nconst { provisionCreds, getLogSources } = Log;\nconst { getConnectionProfile, saveConnectionProfile } = ConnectionProfile;\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo logs list', ['realm', 'type']);\nprogram\n .description('List available ID Cloud log sources.')\n .action(async (host, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(host, user, password, options, command);\n let credsFromParameters = true;\n verboseMessage('Listing available ID Cloud log sources...');\n const conn = await 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 getTokens()) {\n const creds = await provisionCreds();\n state.setLogApiKey(creds.api_key_id);\n state.setLogApiSecret(creds.api_key_secret);\n }\n }\n\n const sources = await getLogSources();\n if (sources.length === 0) {\n printMessage(\n \"Can't get sources, possible cause - wrong API key or secret\",\n 'error'\n );\n } else {\n if (credsFromParameters) await saveConnectionProfile(host); // save new values if they were specified on CLI\n printMessage(`Log sources from ${conn.tenant}`);\n sources.forEach((source) => {\n printMessage(`${source}`, 'data');\n });\n printMessage(\n 'Use any combination of comma separated sources, example:',\n 'info'\n );\n printMessage(`$ frodo logs tail -c am-core,idm-core ${host}`, 'text');\n }\n }\n });\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SACEC,YAAY,EACZC,iBAAiB,EACjBC,GAAG,EACHC,KAAK,QACA,uBAAuB;AAC9B,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAElE,MAAM;EAAEC,cAAc;EAAEC;AAAc,CAAC,GAAGL,GAAG;AAC7C,MAAM;EAAEM,oBAAoB;EAAEC;AAAsB,CAAC,GAAGR,iBAAiB;AACzE,MAAM;EAAES;AAAU,CAAC,GAAGV,YAAY;AAElC,MAAMW,OAAO,GAAG,IAAIZ,YAAY,CAAC,iBAAiB,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AACtEY,OAAO,CACJC,WAAW,CAAC,sCAAsC,CAAC,CACnDC,MAAM,CAAC,OAAOC,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EACxDA,OAAO,CAACC,wBAAwB,CAACL,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,CAAC;EACxE,IAAIE,mBAAmB,GAAG,IAAI;EAC9Bf,cAAc,CAAC,2CAA2C,CAAC;EAC3D,MAAMgB,IAAI,GAAG,MAAMb,oBAAoB,EAAE;EACzC,IAAIa,IAAI,EAAE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CAACE,OAAO,CAAEC,MAAM,IAAK;QAC1BnC,YAAY,CAAE,GAAEmC,MAAO,EAAC,EAAE,MAAM,CAAC;MACnC,CAAC,CAAC;MACFnC,YAAY,CACV,0DAA0D,EAC1D,MAAM,CACP;MACDA,YAAY,CAAE,yCAAwCU,IAAK,EAAC,EAAE,MAAM,CAAC;IACvE;EACF;AACF,CAAC,CAAC;AAEJH,OAAO,CAAC6B,KAAK,EAAE"}
@@ -25,31 +25,33 @@ Following values are possible (values on the same line are equivalent): \
25
25
  command.handleDefaultArgsAndOpts(host, user, password, options, command);
26
26
  let credsFromParameters = true;
27
27
  const conn = await getConnectionProfile();
28
- state.setHost(conn.tenant);
29
- if (conn.logApiKey != null && conn.logApiSecret != null) {
30
- credsFromParameters = false;
31
- state.setLogApiKey(conn.logApiKey);
32
- state.setLogApiSecret(conn.logApiSecret);
33
- } else {
34
- if (conn.username == null && conn.password == null) {
35
- if (!state.getUsername() && !state.getPassword()) {
36
- credsFromParameters = false;
37
- printMessage('User credentials not specified as parameters and no saved API key and secret found!', 'warn');
38
- return;
39
- }
28
+ if (conn) {
29
+ state.setHost(conn.tenant);
30
+ if (conn.logApiKey != null && conn.logApiSecret != null) {
31
+ credsFromParameters = false;
32
+ state.setLogApiKey(conn.logApiKey);
33
+ state.setLogApiSecret(conn.logApiSecret);
40
34
  } else {
41
- state.setUsername(conn.username);
42
- state.setPassword(conn.password);
43
- }
44
- if (await getTokens()) {
45
- const creds = await provisionCreds();
46
- state.setLogApiKey(creds.api_key_id);
47
- state.setLogApiSecret(creds.api_key_secret);
35
+ if (conn.username == null && conn.password == null) {
36
+ if (!state.getUsername() && !state.getPassword()) {
37
+ credsFromParameters = false;
38
+ printMessage('User credentials not specified as parameters and no saved API key and secret found!', 'warn');
39
+ return;
40
+ }
41
+ } else {
42
+ state.setUsername(conn.username);
43
+ state.setPassword(conn.password);
44
+ }
45
+ if (await getTokens()) {
46
+ const creds = await provisionCreds();
47
+ state.setLogApiKey(creds.api_key_id);
48
+ state.setLogApiSecret(creds.api_key_secret);
49
+ }
48
50
  }
51
+ printMessage(`Tailing ID Cloud logs from the following sources: ${command.opts().sources} and levels [${resolveLevel(command.opts().level)}] of ${conn.tenant}...`);
52
+ if (credsFromParameters) await saveConnectionProfile(host); // save new values if they were specified on CLI
53
+ await tailLogs(command.opts().sources, resolveLevel(command.opts().level), command.opts().transactionId, null, config.getNoiseFilters(options.defaults));
49
54
  }
50
- printMessage(`Tailing ID Cloud logs from the following sources: ${command.opts().sources} and levels [${resolveLevel(command.opts().level)}]...`);
51
- if (credsFromParameters) await saveConnectionProfile(host); // save new values if they were specified on CLI
52
- await tailLogs(command.opts().sources, resolveLevel(command.opts().level), command.opts().transactionId, null, config.getNoiseFilters(options.defaults));
53
55
  });
54
56
  program.parse();
55
57
  //# sourceMappingURL=logs-tail.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"logs-tail.js","names":["FrodoCommand","sourcesOptionM","Option","Authenticate","ConnectionProfile","Log","state","config","printMessage","provisionCreds","tailLogs","resolveLevel","getConnectionProfile","saveConnectionProfile","getTokens","program","description","addOption","default","FRODO_LOG_NOISEFILTER_FILENAME","action","host","user","password","options","command","handleDefaultArgsAndOpts","credsFromParameters","conn","setHost","tenant","logApiKey","logApiSecret","setLogApiKey","setLogApiSecret","username","getUsername","getPassword","setUsername","setPassword","creds","api_key_id","api_key_secret","opts","sources","level","transactionId","getNoiseFilters","defaults","parse"],"sources":["cli/logging/logs-tail.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { sourcesOptionM } from './logs';\nimport { Option } from 'commander';\nimport {\n Authenticate,\n ConnectionProfile,\n Log,\n state,\n} from '@rockcarver/frodo-lib';\nimport * as config from '../../utils/Config';\nimport { printMessage } from '../../utils/Console';\n\nconst { provisionCreds, tailLogs, resolveLevel } = Log;\nconst { getConnectionProfile, saveConnectionProfile } = ConnectionProfile;\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo logs tail', ['realm', 'type']);\nprogram\n .description('Tail Identity Cloud logs.')\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', `${resolveLevel('ERROR')}`)\n )\n .addOption(\n new Option('-t, --transaction-id <txid>', 'Filter by transactionId')\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 getConnectionProfile();\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 getTokens()) {\n const creds = await provisionCreds();\n state.setLogApiKey(creds.api_key_id);\n state.setLogApiSecret(creds.api_key_secret);\n }\n }\n printMessage(\n `Tailing ID Cloud logs from the following sources: ${\n command.opts().sources\n } and levels [${resolveLevel(command.opts().level)}]...`\n );\n if (credsFromParameters) await saveConnectionProfile(host); // save new values if they were specified on CLI\n await tailLogs(\n command.opts().sources,\n resolveLevel(command.opts().level),\n command.opts().transactionId,\n null,\n config.getNoiseFilters(options.defaults)\n );\n });\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,c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K,CAAC,EAClCpB,OAAO,CAACkB,IAAI,EAAE,CAACG,aAAa,EAC5B,IAAI,EACJvC,MAAM,CAACwC,eAAe,CAACvB,OAAO,CAACwB,QAAQ,CAAC,CACzC;AACH,CAAC,CAAC;AAEJjC,OAAO,CAACkC,KAAK,EAAE"}
1
+ {"version":3,"file":"logs-tail.js","names":["FrodoCommand","sourcesOptionM","Option","Authenticate","ConnectionProfile","Log","state","config","printMessage","provisionCreds","tailLogs","resolveLevel","getConnectionProfile","saveConnectionProfile","getTokens","program","description","addOption","default","FRODO_LOG_NOISEFILTER_FILENAME","action","host","user","password","options","command","handleDefaultArgsAndOpts","credsFromParameters","conn","setHost","tenant","logApiKey","logApiSecret","setLogApiKey","setLogApiSecret","username","getUsername","getPassword","setUsername","setPassword","creds","api_key_id","api_key_secret","opts","sources","level","transactionId","getNoiseFilters","defaults","parse"],"sources":["cli/logging/logs-tail.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { sourcesOptionM } from './logs';\nimport { Option } from 'commander';\nimport {\n Authenticate,\n ConnectionProfile,\n Log,\n state,\n} from '@rockcarver/frodo-lib';\nimport * as config from '../../utils/Config';\nimport { printMessage } from '../../utils/Console';\n\nconst { provisionCreds, tailLogs, resolveLevel } = Log;\nconst { getConnectionProfile, saveConnectionProfile } = ConnectionProfile;\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo logs tail', ['realm', 'type']);\nprogram\n .description('Tail Identity Cloud logs.')\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', `${resolveLevel('ERROR')}`)\n )\n .addOption(\n new Option('-t, --transaction-id <txid>', 'Filter by transactionId')\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 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 getTokens()) {\n const creds = await provisionCreds();\n state.setLogApiKey(creds.api_key_id);\n state.setLogApiSecret(creds.api_key_secret);\n }\n }\n printMessage(\n `Tailing ID Cloud logs from the following sources: ${\n command.opts().sources\n } and levels [${resolveLevel(command.opts().level)}] of ${\n conn.tenant\n }...`\n );\n if (credsFromParameters) await saveConnectionProfile(host); // save new values if they were specified on CLI\n await tailLogs(\n command.opts().sources,\n resolveLevel(command.opts().level),\n command.opts().transactionId,\n null,\n config.getNoiseFilters(options.defaults)\n );\n }\n });\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,cAAc,QAAQ,QAAQ;AACvC,SAASC,MAAM,QAAQ,WAAW;AAClC,SACEC,YAAY,EACZC,iBAAiB,EACjBC,GAAG,EACHC,KAAK,QACA,uBAAuB;AAC9B,OAAO,KAAKC,MAAM,MAAM,oBAAoB;AAC5C,SAASC,YAAY,QAAQ,qBAAqB;AAElD,MAAM;EAAEC,cAAc;EAAEC,QAAQ;EAAEC;AAAa,CAAC,GAAGN,GAAG;AACtD,MAAM;EAAEO,oBAAoB;EAAEC;AAAsB,CAAC,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"0.20.1-0",
3
+ "version": "0.20.1",
4
4
  "type": "module",
5
5
  "description": "A command line interface to manage ForgeRock Identity Cloud tenants, ForgeOps deployments, and classic deployments.",
6
6
  "keywords": [
@@ -104,7 +104,7 @@
104
104
  ]
105
105
  },
106
106
  "dependencies": {
107
- "@rockcarver/frodo-lib": "0.18.0",
107
+ "@rockcarver/frodo-lib": "0.18.1",
108
108
  "cli-progress": "^3.11.2",
109
109
  "cli-table3": "^0.6.3",
110
110
  "colors": "^1.4.0",