@rockcarver/frodo-cli 2.0.0-4 → 2.0.0-5
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 +5 -1
- package/esm/app.js +2 -2
- package/esm/app.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/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/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,8 @@ 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-5] - 2023-06-21
|
|
11
|
+
|
|
10
12
|
## [2.0.0-4] - 2023-06-16
|
|
11
13
|
|
|
12
14
|
## [2.0.0-3] - 2023-06-15
|
|
@@ -1208,7 +1210,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
1208
1210
|
- Fixed problem with adding connection profiles
|
|
1209
1211
|
- Miscellaneous bug fixes
|
|
1210
1212
|
|
|
1211
|
-
[Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-
|
|
1213
|
+
[Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-5...HEAD
|
|
1214
|
+
|
|
1215
|
+
[2.0.0-5]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-4...v2.0.0-5
|
|
1212
1216
|
|
|
1213
1217
|
[2.0.0-4]: https://github.com/rockcarver/frodo-cli/compare/v2.0.0-3...v2.0.0-4
|
|
1214
1218
|
|
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;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,CAACG,UAAU,CAAClB,IAAI,CAAC,CAAC,CAAC;IAC1Be,OAAO,CAACG,UAAU,CAACjB,KAAK,CAAC,CAAC,CAAC;IAC3Bc,OAAO,CAACG,UAAU,CAAChB,GAAG,CAAC,CAAC,CAAC;IACzBa,OAAO,CAACG,UAAU,CAACf,GAAG,CAAC,CAAC,CAAC;IACzBY,OAAO,CAACG,UAAU,CAACd,GAAG,CAAC,CAAC,CAAC;IACzBW,OAAO,CAACG,UAAU,CAACb,IAAI,CAAC,CAAC,CAAC;IAC1BU,OAAO,CAACG,UAAU,CAACZ,OAAO,CAAC,CAAC,CAAC;IAC7BS,OAAO,CAACG,UAAU,CAACX,GAAG,CAAC,CAAC,CAAC;IACzBQ,OAAO,CAACG,UAAU,CAACV,KAAK,CAAC,CAAC,CAAC;IAC3BO,OAAO,CAACG,UAAU,CAACT,IAAI,CAAC,CAAC,CAAC;IAC1BM,OAAO,CAACG,UAAU,CAACR,MAAM,CAAC,CAAC,CAAC;IAC5BK,OAAO,CAACG,UAAU,CAACP,OAAO,CAAC,CAAC,CAAC;IAC7BI,OAAO,CAACG,UAAU,CAACN,KAAK,CAAC,CAAC,CAAC;IAC3B;IACA;;IAEAG,OAAO,CAACI,kBAAkB,CAAC,CAAC;IAC5BJ,OAAO,CAACK,uBAAuB,CAAC,CAAC;IACjCL,OAAO,CAACM,KAAK,CAAC,CAAC;EACjB,CAAC,CAAC,OAAOC,CAAC,EAAE;IACVT,YAAY,CAAE,oCAAmCS,CAAE,EAAC,EAAE,OAAO,CAAC;EAChE;AACF,CAAC,EAAE,CAAC"}
|
|
@@ -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,CACAU,SAAS,CAAC,IAAIV,MAAM,CAAC,SAAS,EAAE,wCAAwC,CAAC,CAAC,CAC1EU,SAAS,CACR,IAAIV,MAAM,CACR,qBAAqB,EACrB,2FACF,CACF,CAAC,CACAU,SAAS,CACR,IAAIV,MAAM,CACR,2BAA2B,EAC3B,2FACF,CACF,CAAC,CACAU,SAAS,CACR,IAAIV,MAAM,CAAC,cAAc,EAAE,+CAA+C,CAC5E,CAAC,CACAU,SAAS,CAAC,IAAIV,MAAM,CAAC,eAAe,EAAE,6BAA6B,CAAC,CAAC,CACrEU,SAAS,CACR,IAAIV,MAAM,CACR,oCAAoC,EACpC,iDACF,CACF,CAAC,CACAU,SAAS,CACR,IAAIV,MAAM,CACR,6CAA6C,EAC7C,iDACF,CACF,CAAC,CACAW,MAAM;AACL;AACA,OAAOC,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AAG,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,iBAAiB,EAAE,CAAC,OAAO,CAAC,CAAC;AAE9DS,OAAO,CACJC,KAAK,CAAC,KAAK,CAAC,CACZC,WAAW,CAAC,2BAA2B,CAAC,CACxCC,SAAS,CAAC,IAAIX,MAAM,CAAC,SAAS,EAAE,wCAAwC,CAAC,CAAC,CAC1EW,SAAS,CACR,IAAIX,MAAM,CACR,qBAAqB,EACrB,2FACF,CACF,CAAC,CACAW,SAAS,CACR,IAAIX,MAAM,CACR,2BAA2B,EAC3B,2FACF,CACF,CAAC,CACAW,SAAS,CACR,IAAIX,MAAM,CAAC,cAAc,EAAE,+CAA+C,CAC5E,CAAC,CACAW,SAAS,CAAC,IAAIX,MAAM,CAAC,eAAe,EAAE,6BAA6B,CAAC,CAAC,CACrEW,SAAS,CACR,IAAIX,MAAM,CACR,oCAAoC,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IAAI;UACF,MAAM2B,KAAK,GAAG,MAAM9D,cAAc,CAAC,CAAC;UACpCJ,KAAK,CAACuB,YAAY,CAAC2C,KAAK,CAACC,UAAoB,CAAC;UAC9CnE,KAAK,CAACyB,eAAe,CAACyC,KAAK,CAACE,cAAwB,CAAC;UACrDlE,YAAY,CACT,uBAAsBgE,KAAK,CAACC,UAAW,cAC1C,CAAC;QACH,CAAC,CAAC,OAAOV,KAAK,EAAE;UAAA,IAAAY,gBAAA,EAAAC,gBAAA,EAAAC,qBAAA;UACdrE,YAAY,EAAAmE,gBAAA,GAACZ,KAAK,CAACI,QAAQ,cAAAQ,gBAAA,uBAAdA,gBAAA,CAAgBP,IAAI,EAAE,OAAO,CAAC;UAC3C5D,YAAY,CACT,0CAAuC,CAAAoE,gBAAA,GAAEb,KAAK,CAACI,QAAQ,cAAAS,gBAAA,wBAAAC,qBAAA,GAAdD,gBAAA,CAAgBR,IAAI,cAAAS,qBAAA,uBAApBA,qBAAA,CAAsBR,OAAQ,EAAC,EACzE,OACF,CAAC;UACDC,OAAO,CAACC,QAAQ,GAAG,CAAC;QACtB;MACF;IACF;IACA;IACA;IACA,IAAI,MAAMlE,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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E,gBAAgB;UACvCC,UAAU,EAAE,aAAa;UACzBC,cAAc,EAAE,iBAAiB;UACjClB,IAAI,EAAE,UAAU;UAChBmB,SAAS,EAAE,WAAW;UACtBC,MAAM,EAAE,QAAQ;UAChBC,sBAAsB,EAAE,wBAAwB;UAChDC,MAAM,EAAE,QAAQ;UAChBC,IAAI,EAAE;QACR,CAAC;QACD,MAAMC,KAAK,GAAGxC,iBAAiB,CAACuB,IAAI,EAAEM,MAAM,CAAC;QAC7C5B,YAAY,CAAE,KAAIuC,KAAK,CAACC,QAAQ,CAAC,CAAE,EAAC,CAAC;QACrC,IAAI1C,KAAK,CAAC2C,cAAc,CAAC,CAAC,EAAE;UAC1BzC,YAAY,CAAE,kBAAiB,EAAE,MAAM,CAAC;UACxCA,YAAY,CAAE,GAAEF,KAAK,CAAC2C,cAAc,CAAC,CAAE,EAAC,CAAC;QAC3C;QACA,IAAI3C,KAAK,CAAC4C,cAAc,CAAC,CAAC,EAAE;UAC1B1C,YAAY,CAAE,iBAAgB,EAAE,MAAM,CAAC;UACvCA,YAAY,CAAE,GAAEF,KAAK,CAAC4C,cAAc,CAAC,CAAE,EAAC,CAAC;QAC3C;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,kBAAkB;AAE5D,MAAMC,kBAAkB,GAAG,OAAO;AAClC,MAAMC,iBAAiB,GAAG,IAAI;AAC9B,MAAMC,mBAAmB,GAAGF,kBAAkB;AAC9C,MAAMG,yBAAyB,GAAG,CAAC;AAEnC,MAAMC,OAAO,GAAG,IAAIb,YAAY,CAAC,iBAAiB,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AACtEa,OAAO,CACJC,WAAW,CACV;AACJ,wGACE,CAAC,CACAC,SAAS,CAACd,cAAc,CAAC,CACzBc,SAAS,CACR,IAAIb,MAAM,CACR,qBAAqB,EACrB;AACN;AACA;AACA;AACA,WACI,CAAC,CAACc,OAAO,CAAC,OAAO,EAAG,GAAEb,KAAK,CAACc,KAAK,CAACC,GAAG,CAACC,YAAY,CAAC,OAAO,CAAE,EAAC,C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ACW,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 }\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G,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"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FrodoCommand } from '../FrodoCommand';
|
|
2
|
+
import { Option } from 'commander';
|
|
3
|
+
import { frodo } from '@rockcarver/frodo-lib';
|
|
4
|
+
import { listLogApiKeys } from '../../ops/LogOps';
|
|
5
|
+
import { verboseMessage } from '../../utils/Console';
|
|
6
|
+
const program = new FrodoCommand('frodo log key list');
|
|
7
|
+
program.description('List log API keys.').addOption(new Option('-l, --long', 'Long with all fields.').default(false, 'false')).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
|
+
if (await frodo.login.getTokens(true)) {
|
|
12
|
+
verboseMessage(`Listing log API keys...`);
|
|
13
|
+
const outcome = await listLogApiKeys(options.long);
|
|
14
|
+
if (!outcome) process.exitCode = 1;
|
|
15
|
+
} else {
|
|
16
|
+
process.exitCode = 1;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
// end command logic inside action handler
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
program.parse();
|
|
23
|
+
//# sourceMappingURL=log-key-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-key-list.js","names":["FrodoCommand","Option","frodo","listLogApiKeys","verboseMessage","program","description","addOption","default","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","login","getTokens","outcome","long","process","exitCode","parse"],"sources":["cli/log/log-key-list.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { frodo } from '@rockcarver/frodo-lib';\nimport { listLogApiKeys } from '../../ops/LogOps';\nimport { verboseMessage } from '../../utils/Console';\n\nconst program = new FrodoCommand('frodo log key list');\n\nprogram\n .description('List log API keys.')\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, 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(true)) {\n verboseMessage(`Listing log API keys...`);\n const outcome = await listLogApiKeys(options.long);\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,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,KAAK,QAAQ,uBAAuB;AAC7C,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SAASC,cAAc,QAAQ,qBAAqB;AAEpD,MAAMC,OAAO,GAAG,IAAIL,YAAY,CAAC,oBAAoB,CAAC;AAEtDK,OAAO,CACJC,WAAW,CAAC,oBAAoB,CAAC,CACjCC,SAAS,CACR,IAAIN,MAAM,CAAC,YAAY,EAAE,uBAAuB,CAAC,CAACO,OAAO,CAAC,KAAK,EAAE,OAAO,CAC1E,CAAC,CACAC,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EACvDA,OAAO,CAACC,wBAAwB,CAC9BN,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,QAAQ,EACRC,OAAO,EACPC,OACF,CAAC;EACD,IAAI,MAAMb,KAAK,CAACe,KAAK,CAACC,SAAS,CAAC,IAAI,CAAC,EAAE;IACrCd,cAAc,CAAE,yBAAwB,CAAC;IACzC,MAAMe,OAAO,GAAG,MAAMhB,cAAc,CAACW,OAAO,CAACM,IAAI,CAAC;IAClD,IAAI,CAACD,OAAO,EAAEE,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC,CAAC,MAAM;IACLD,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEHjB,OAAO,CAACkB,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FrodoStubCommand } from '../FrodoCommand';
|
|
2
|
+
const program = new FrodoStubCommand('frodo log key');
|
|
3
|
+
program.description('Manage Identity Cloud log API keys.');
|
|
4
|
+
program.command('list', 'List log API keys.');
|
|
5
|
+
program.command('describe', 'Describe log API keys.');
|
|
6
|
+
program.command('delete', 'Delete log API keys.');
|
|
7
|
+
program.parse();
|
|
8
|
+
//# sourceMappingURL=log-key.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-key.js","names":["FrodoStubCommand","program","description","command","parse"],"sources":["cli/log/log-key.ts"],"sourcesContent":["import { FrodoStubCommand } from '../FrodoCommand';\n\nconst program = new FrodoStubCommand('frodo log key');\n\nprogram.description('Manage Identity Cloud log API keys.');\n\nprogram.command('list', 'List log API keys.');\n\nprogram.command('describe', 'Describe log API keys.');\n\nprogram.command('delete', 'Delete log API keys.');\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,iBAAiB;AAElD,MAAMC,OAAO,GAAG,IAAID,gBAAgB,CAAC,eAAe,CAAC;AAErDC,OAAO,CAACC,WAAW,CAAC,qCAAqC,CAAC;AAE1DD,OAAO,CAACE,OAAO,CAAC,MAAM,EAAE,oBAAoB,CAAC;AAE7CF,OAAO,CAACE,OAAO,CAAC,UAAU,EAAE,wBAAwB,CAAC;AAErDF,OAAO,CAACE,OAAO,CAAC,QAAQ,EAAE,sBAAsB,CAAC;AAEjDF,OAAO,CAACG,KAAK,CAAC,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { FrodoCommand } from '../FrodoCommand';
|
|
|
2
2
|
import { frodo, state } from '@rockcarver/frodo-lib';
|
|
3
3
|
import { printMessage, verboseMessage } from '../../utils/Console';
|
|
4
4
|
import { provisionCreds } from '../../ops/LogOps';
|
|
5
|
-
const program = new FrodoCommand('frodo
|
|
5
|
+
const program = new FrodoCommand('frodo log list', ['realm', 'type']);
|
|
6
6
|
program.description('List available ID Cloud log sources.').action(async (host, user, password, options, command) => {
|
|
7
7
|
command.handleDefaultArgsAndOpts(host, user, password, options, command);
|
|
8
8
|
let credsFromParameters = true;
|
|
@@ -46,4 +46,4 @@ program.description('List available ID Cloud log sources.').action(async (host,
|
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
program.parse();
|
|
49
|
-
//# sourceMappingURL=
|
|
49
|
+
//# sourceMappingURL=log-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-list.js","names":["FrodoCommand","frodo","state","printMessage","verboseMessage","provisionCreds","program","description","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","sources","cloud","log","getLogSources","length","saveConnectionProfile","forEach","source","parse"],"sources":["cli/log/log-list.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { frodo, state } from '@rockcarver/frodo-lib';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { provisionCreds } from '../../ops/LogOps';\n\nconst program = new FrodoCommand('frodo log 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 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\n const sources = await frodo.cloud.log.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 frodo.conn.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,SAASC,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,SAASC,YAAY,EAAEC,cAAc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WAAW,CAACZ,IAAI,CAACL,QAAQ,CAAC;MAClC;MACA,IAAI,MAAMV,KAAK,CAAC4B,KAAK,CAACC,SAAS,CAAC,IAAI,CAAC,EAAE;QACrC,MAAMC,KAAK,GAAG,MAAM1B,cAAc,CAAC,CAAC;QACpCH,KAAK,CAACoB,YAAY,CAACS,KAAK,CAACC,UAAoB,CAAC;QAC9C9B,KAAK,CAACqB,eAAe,CAACQ,KAAK,CAACE,cAAwB,CAAC;MACvD;IACF;IAEA,MAAMC,OAAO,GAAG,MAAMjC,KAAK,CAACkC,KAAK,CAACC,GAAG,CAACC,aAAa,CAAC,CAAC;IACrD,IAAIH,OAAO,CAACI,MAAM,KAAK,CAAC,EAAE;MACxBnC,YAAY,CACV,6DAA6D,EAC7D,OACF,CAAC;IACH,CAAC,MAAM;MACL,IAAIY,mBAAmB,EAAE,MAAMd,KAAK,CAACe,IAAI,CAACuB,qBAAqB,CAAC9B,IAAI,CAAC,CAAC,CAAC;MACvEN,YAAY,CAAE,oBAAmBa,IAAI,CAACG,MAAO,EAAC,CAAC;MAC/Ce,OAAO,CAACM,OAAO,CAAEC,MAAM,IAAK;QAC1BtC,YAAY,CAAE,GAAEsC,MAAO,EAAC,EAAE,MAAM,CAAC;MACnC,CAAC,CAAC;MACFtC,YAAY,CACV,0DAA0D,EAC1D,MACF,CAAC;MACDA,YAAY,CAAE,yCAAwCM,IAAK,EAAC,EAAE,MAAM,CAAC;IACvE;EACF;AACF,CAAC,CAAC;AAEJH,OAAO,CAACoC,KAAK,CAAC,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
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';
|
|
6
6
|
import { printMessage } from '../../utils/Console';
|
|
7
7
|
import { provisionCreds, tailLogs } from '../../ops/LogOps';
|
|
8
|
-
const program = new FrodoCommand('frodo
|
|
8
|
+
const program = new FrodoCommand('frodo log tail', ['realm', 'type']);
|
|
9
9
|
program.description('Tail Identity Cloud logs.').addOption(sourcesOptionM).addOption(new Option('-l, --level <level>', 'Set log level filter. You can specify the level as a number or a string. \
|
|
10
10
|
Following values are possible (values on the same line are equivalent): \
|
|
11
11
|
\n0, SEVERE, FATAL, or ERROR\n1, WARNING, WARN or CONFIG\
|
|
@@ -43,4 +43,4 @@ Following values are possible (values on the same line are equivalent): \
|
|
|
43
43
|
}
|
|
44
44
|
});
|
|
45
45
|
program.parse();
|
|
46
|
-
//# sourceMappingURL=
|
|
46
|
+
//# sourceMappingURL=log-tail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-tail.js","names":["FrodoCommand","sourcesOptionM","Option","frodo","state","config","printMessage","provisionCreds","tailLogs","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","opts","sources","level","saveConnectionProfile","transactionId","getNoiseFilters","defaults","parse"],"sources":["cli/log/log-tail.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 { provisionCreds, tailLogs } from '../../ops/LogOps';\n\nconst program = new FrodoCommand('frodo log 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', `${frodo.cloud.log.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 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 printMessage(\n `Tailing 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 await tailLogs(\n command.opts().sources,\n frodo.cloud.log.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,OAAO;AACtC,SAASC,MAAM,QAAQ,WAAW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BzC,KAAK,CAACU,KAAK,CAACC,GAAG,CAACC,YAAY,CAACO,OAAO,CAACqB,IAAI,CAAC,CAAC,CAACE,KAAK,CAAC,EAClDvB,OAAO,CAACqB,IAAI,CAAC,CAAC,CAACI,aAAa,EAC5B,IAAI,EACJ1C,MAAM,CAAC2C,eAAe,CAAC3B,OAAO,CAAC4B,QAAQ,CACzC,CAAC;EACH;AACF,CAAC,CAAC;AAEJxC,OAAO,CAACyC,KAAK,CAAC,CAAC"}
|
|
@@ -5,10 +5,13 @@ import { fileURLToPath } from 'url';
|
|
|
5
5
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
6
6
|
export const sourcesOptionM = new Option('-c, --sources <sources>', 'Comma separated list of log sources').makeOptionMandatory().default('am-everything,idm-everything', 'Log everything');
|
|
7
7
|
export default function setup() {
|
|
8
|
-
const program = new FrodoStubCommand('
|
|
8
|
+
const program = new FrodoStubCommand('log')
|
|
9
|
+
// for backwards compatibility
|
|
10
|
+
.alias('logs').summary('List/View Identity Cloud logs').description(`View Identity Cloud logs. If valid tenant admin credentials are specified, a log API key and secret are automatically created for that admin user.`).executableDir(__dirname);
|
|
9
11
|
program.command('list', 'List available ID Cloud log sources.');
|
|
10
12
|
program.command('tail', 'Tail Identity Cloud logs.');
|
|
11
13
|
program.command('fetch', 'Fetch Identity Cloud logs for a time window.');
|
|
14
|
+
program.command('key', 'Manage Identity Cloud log API keys.');
|
|
12
15
|
return program;
|
|
13
16
|
}
|
|
14
|
-
//# sourceMappingURL=
|
|
17
|
+
//# sourceMappingURL=log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.js","names":["FrodoStubCommand","Option","path","fileURLToPath","__dirname","dirname","import","meta","url","sourcesOptionM","makeOptionMandatory","default","setup","program","alias","summary","description","executableDir","command"],"sources":["cli/log/log.ts"],"sourcesContent":["import { FrodoStubCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nexport const sourcesOptionM = new Option(\n '-c, --sources <sources>',\n 'Comma separated list of log sources'\n)\n .makeOptionMandatory()\n .default('am-everything,idm-everything', 'Log everything');\n\nexport default function setup() {\n const program = new FrodoStubCommand('log')\n // for backwards compatibility\n .alias('logs')\n .summary('List/View Identity Cloud logs')\n .description(\n `View Identity Cloud logs. If valid tenant admin credentials are specified, a log API key and secret are automatically created for that admin user.`\n )\n .executableDir(__dirname);\n\n program.command('list', 'List available ID Cloud log sources.');\n\n program.command('tail', 'Tail Identity Cloud logs.');\n\n program.command('fetch', 'Fetch Identity Cloud logs for a time window.');\n\n program.command('key', 'Manage Identity Cloud log API keys.');\n\n return program;\n}\n"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,iBAAiB;AAClD,SAASC,MAAM,QAAQ,WAAW;AAClC,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,OAAO,MAAMC,cAAc,GAAG,IAAIR,MAAM,CACtC,yBAAyB,EACzB,qCACF,CAAC,CACES,mBAAmB,CAAC,CAAC,CACrBC,OAAO,CAAC,8BAA8B,EAAE,gBAAgB,CAAC;AAE5D,eAAe,SAASC,KAAKA,CAAA,EAAG;EAC9B,MAAMC,OAAO,GAAG,IAAIb,gBAAgB,CAAC,KAAK;EACxC;EAAA,CACCc,KAAK,CAAC,MAAM,CAAC,CACbC,OAAO,CAAC,+BAA+B,CAAC,CACxCC,WAAW,CACT,oJACH,CAAC,CACAC,aAAa,CAACb,SAAS,CAAC;EAE3BS,OAAO,CAACK,OAAO,CAAC,MAAM,EAAE,sCAAsC,CAAC;EAE/DL,OAAO,CAACK,OAAO,CAAC,MAAM,EAAE,2BAA2B,CAAC;EAEpDL,OAAO,CAACK,OAAO,CAAC,OAAO,EAAE,8CAA8C,CAAC;EAExEL,OAAO,CAACK,OAAO,CAAC,KAAK,EAAE,qCAAqC,CAAC;EAE7D,OAAOL,OAAO;AAChB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const amBaseUrl = 'https://openam-matrix.id.forgerock.io/am';
|
|
2
|
+
export const connId = 'matrix';
|
|
3
|
+
export const username = 'thomas.anderson@metacortex.com';
|
|
4
|
+
export const password = 'Blu3P!ll3d';
|
|
5
|
+
export const saId = 'b672336b-41ef-428d-ae4a-e0c082875377';
|
|
6
|
+
export const saJwkFile = './matrix-sa_privateKey.jwk';
|
|
7
|
+
//# sourceMappingURL=SampleData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SampleData.js","names":["amBaseUrl","connId","username","password","saId","saJwkFile"],"sources":["help/SampleData.ts"],"sourcesContent":["export const amBaseUrl = 'https://openam-matrix.id.forgerock.io/am';\nexport const connId = 'matrix';\nexport const username = 'thomas.anderson@metacortex.com';\nexport const password = 'Blu3P!ll3d';\nexport const saId = 'b672336b-41ef-428d-ae4a-e0c082875377';\nexport const saJwkFile = './matrix-sa_privateKey.jwk';\n"],"mappings":"AAAA,OAAO,MAAMA,SAAS,GAAG,0CAA0C;AACnE,OAAO,MAAMC,MAAM,GAAG,QAAQ;AAC9B,OAAO,MAAMC,QAAQ,GAAG,gCAAgC;AACxD,OAAO,MAAMC,QAAQ,GAAG,YAAY;AACpC,OAAO,MAAMC,IAAI,GAAG,sCAAsC;AAC1D,OAAO,MAAMC,SAAS,GAAG,4BAA4B"}
|
package/esm/ops/IdpOps.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { frodo } from '@rockcarver/frodo-lib';
|
|
2
2
|
import fs from 'fs';
|
|
3
|
-
import { createProgressBar, failSpinner, printMessage, showSpinner, stopProgressBar, succeedSpinner, updateProgressBar } from '../utils/Console';
|
|
3
|
+
import { createProgressBar, debugMessage, failSpinner, printMessage, showSpinner, stopProgressBar, succeedSpinner, updateProgressBar } from '../utils/Console';
|
|
4
4
|
import { getRealmString, getTypedFilename, saveJsonToFile } from '../utils/ExportImportUtils';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -56,6 +56,7 @@ export async function listSocialProviders() {
|
|
|
56
56
|
* @param {string} file optional export file name
|
|
57
57
|
*/
|
|
58
58
|
export async function exportSocialProviderToFile(providerId, file = '') {
|
|
59
|
+
debugMessage(`cli.IdpOps.exportSocialProviderToFile: start`);
|
|
59
60
|
let fileName = file;
|
|
60
61
|
if (!fileName) {
|
|
61
62
|
fileName = getTypedFilename(providerId, 'idp');
|
|
@@ -70,6 +71,7 @@ export async function exportSocialProviderToFile(providerId, file = '') {
|
|
|
70
71
|
stopProgressBar(`${err}`);
|
|
71
72
|
printMessage(`${err}`, 'error');
|
|
72
73
|
}
|
|
74
|
+
debugMessage(`cli.IdpOps.exportSocialProviderToFile: end`);
|
|
73
75
|
}
|
|
74
76
|
|
|
75
77
|
/**
|
|
@@ -89,16 +91,26 @@ export async function exportSocialProvidersToFile(file = '') {
|
|
|
89
91
|
* Export all providers to individual files
|
|
90
92
|
*/
|
|
91
93
|
export async function exportSocialProvidersToFiles() {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
94
|
+
debugMessage(`cli.IdpOps.exportSocialProvidersToFiles: start`);
|
|
95
|
+
try {
|
|
96
|
+
const allIdpsData = await frodo.oauth2oidc.external.getSocialIdentityProviders();
|
|
97
|
+
createProgressBar(allIdpsData.length, 'Exporting providers');
|
|
98
|
+
for (const idpData of allIdpsData) {
|
|
99
|
+
try {
|
|
100
|
+
const fileName = getTypedFilename(idpData._id, 'idp');
|
|
101
|
+
const fileData = await frodo.oauth2oidc.external.exportSocialProvider(idpData._id);
|
|
102
|
+
saveJsonToFile(fileData, fileName);
|
|
103
|
+
updateProgressBar(`Exported provider ${idpData._id}`);
|
|
104
|
+
} catch (error) {
|
|
105
|
+
printMessage(`Error exporting ${idpData._id}: ${error}`, 'error');
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
stopProgressBar(`${allIdpsData.length} providers exported.`);
|
|
109
|
+
} catch (error) {
|
|
110
|
+
stopProgressBar(`${error}`);
|
|
111
|
+
printMessage(`${error}`, 'error');
|
|
100
112
|
}
|
|
101
|
-
|
|
113
|
+
debugMessage(`cli.IdpOps.exportSocialProvidersToFiles: end`);
|
|
102
114
|
}
|
|
103
115
|
|
|
104
116
|
/**
|
package/esm/ops/IdpOps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdpOps.js","names":["frodo","fs","createProgressBar","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getRealmString","getTypedFilename","saveJsonToFile","getOneLineDescription","socialIdpObj","description","_id","_type","getTableHeaderMd","markdown","getTableRowMd","row","enabled","name","listSocialProviders","providers","oauth2oidc","external","getSocialIdentityProviders","sort","a","b","localeCompare","forEach","socialIdentityProvider","err","message","exportSocialProviderToFile","providerId","file","fileName","fileData","exportSocialProvider","exportSocialProvidersToFile","exportSocialProviders","exportSocialProvidersToFiles","allIdpsData","length","idpData","importSocialProviderFromFile","outcome","readFile","data","JSON","parse","importSocialProvider","error","_error$response","response","importFirstSocialProviderFromFile","importFirstSocialProvider","_error$response2","importSocialProvidersFromFile","importSocialProviders","_error$response3","importSocialProvidersFromFiles","names","readdirSync","jsonFiles","filter","toLowerCase","endsWith","total","readFileSync","count","Object","keys","idp"],"sources":["ops/IdpOps.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport fs from 'fs';\nimport type { SocialIdpSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport {\n createProgressBar,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport {\n getRealmString,\n getTypedFilename,\n saveJsonToFile,\n} from '../utils/ExportImportUtils';\n\n/**\n * Get a one-line description of the social idp object\n * @param {SocialIdpSkeleton} socialIdpObj social idp object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(socialIdpObj: SocialIdpSkeleton): string {\n const description = `[${socialIdpObj._id['brightCyan']}] ${socialIdpObj._type._id}`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Name/Id | Status | Type |\\n';\n markdown += '| ------- | ------ | ---- |';\n return markdown;\n}\n\n/**\n * Get a table-row of the social idp in markdown\n * @param {SocialIdpSkeleton} socialIdpObj social idp object to describe\n * @returns {string} a table-row of the social idp in markdown\n */\nexport function getTableRowMd(socialIdpObj: SocialIdpSkeleton): string {\n const row = `| ${socialIdpObj._id} | ${\n socialIdpObj.enabled === false\n ? ':o: `disabled`'\n : ':white_check_mark: `enabled`'\n } | ${socialIdpObj._type.name} |`;\n return row;\n}\n\n/**\n * List providers\n */\nexport async function listSocialProviders() {\n try {\n const providers =\n await frodo.oauth2oidc.external.getSocialIdentityProviders();\n providers.sort((a, b) => a._id.localeCompare(b._id));\n providers.forEach((socialIdentityProvider) => {\n printMessage(`${socialIdentityProvider._id}`, 'data');\n });\n } catch (err) {\n printMessage(`listSocialProviders ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n}\n\n/**\n * Export provider by id\n * @param {string} providerId provider id/name\n * @param {string} file optional export file name\n */\nexport async function exportSocialProviderToFile(\n providerId: string,\n file = ''\n) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(providerId, 'idp');\n }\n createProgressBar(1, `Exporting ${providerId}`);\n try {\n updateProgressBar(`Writing file ${fileName}`);\n const fileData = await frodo.oauth2oidc.external.exportSocialProvider(\n providerId\n );\n saveJsonToFile(fileData, fileName);\n stopProgressBar(\n `Exported ${providerId['brightCyan']} to ${fileName['brightCyan']}.`\n );\n } catch (err) {\n stopProgressBar(`${err}`);\n printMessage(`${err}`, 'error');\n }\n}\n\n/**\n * Export all providers\n * @param {string} file optional export file name\n */\nexport async function exportSocialProvidersToFile(file = '') {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`all${getRealmString()}Providers`, 'idp');\n }\n const fileData = await frodo.oauth2oidc.external.exportSocialProviders();\n saveJsonToFile(fileData, fileName);\n}\n\n/**\n * Export all providers to individual files\n */\nexport async function exportSocialProvidersToFiles() {\n const allIdpsData =\n await frodo.oauth2oidc.external.getSocialIdentityProviders();\n // printMessage(allIdpsData, 'data');\n createProgressBar(allIdpsData.length, 'Exporting providers');\n for (const idpData of allIdpsData) {\n updateProgressBar(`Writing provider ${idpData._id}`);\n const fileName = getTypedFilename(idpData._id, 'idp');\n const fileData = await frodo.oauth2oidc.external.exportSocialProvider(\n idpData._id\n );\n saveJsonToFile(fileData, fileName);\n }\n stopProgressBar(`${allIdpsData.length} providers exported.`);\n}\n\n/**\n * Import provider by id/name\n * @param {string} providerId provider id/name\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if provider was imported successfully, false otherwise\n */\nexport async function importSocialProviderFromFile(\n providerId: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing provider ${providerId} from ${file}...`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n outcome = await frodo.oauth2oidc.external.importSocialProvider(\n providerId,\n fileData\n );\n succeedSpinner(\n `Successfully imported provider ${providerId} from ${file}.`\n );\n } catch (error) {\n failSpinner(`Error importing provider ${providerId} from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import first provider from file\n * @param {String} file import file name\n * @returns {Promise<boolean>} true if first provider was imported successfully, false otherwise\n */\nexport async function importFirstSocialProviderFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing first provider from ${file}...`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n outcome = await frodo.oauth2oidc.external.importFirstSocialProvider(\n fileData\n );\n succeedSpinner(`Successfully imported first provider from ${file}.`);\n } catch (error) {\n failSpinner(`Error importing first provider from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import all providers from file\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if all providers were imported successfully, false otherwise\n */\nexport async function importSocialProvidersFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing providers from ${file}...`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n outcome = await frodo.oauth2oidc.external.importSocialProviders(fileData);\n succeedSpinner(`Successfully imported providers from ${file}.`);\n } catch (error) {\n failSpinner(`Error importing providers from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import providers from *.idp.json files in current working directory\n */\nexport async function importSocialProvidersFromFiles() {\n const names = fs.readdirSync('.');\n const jsonFiles = names.filter((name) =>\n name.toLowerCase().endsWith('.idp.json')\n );\n\n createProgressBar(jsonFiles.length, 'Importing providers...');\n let total = 0;\n for (const file of jsonFiles) {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n const count = Object.keys(fileData.idp).length;\n total += count;\n await frodo.oauth2oidc.external.importSocialProviders(fileData);\n updateProgressBar(`Imported ${count} provider(s) from ${file}`);\n }\n stopProgressBar(\n `Finished importing ${total} provider(s) from ${jsonFiles.length} file(s).`\n );\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,iBAAiB,EACjBC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,cAAc,EACdC,iBAAiB,QACZ,kBAAkB;AACzB,SACEC,cAAc,EACdC,gBAAgB,EAChBC,cAAc,QACT,4BAA4B;;AAEnC;AACA;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;IACd,MAAMzE,KAAK,CAACyB,UAAU,CAACC,QAAQ,CAACoC,qBAAqB,CAACtB,QAAQ,CAAC;IAC/DhC,iBAAiB,CAAE,YAAWiE,KAAM,qBAAoBnC,IAAK,EAAC,CAAC;EACjE;EACAhC,eAAe,CACZ,sBAAqBiE,KAAM,qBAAoBJ,SAAS,CAACrB,MAAO,WACnE,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"IdpOps.js","names":["frodo","fs","createProgressBar","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getRealmString","getTypedFilename","saveJsonToFile","getOneLineDescription","socialIdpObj","description","_id","_type","getTableHeaderMd","markdown","getTableRowMd","row","enabled","name","listSocialProviders","providers","oauth2oidc","external","getSocialIdentityProviders","sort","a","b","localeCompare","forEach","socialIdentityProvider","err","message","exportSocialProviderToFile","providerId","file","fileName","fileData","exportSocialProvider","exportSocialProvidersToFile","exportSocialProviders","exportSocialProvidersToFiles","allIdpsData","length","idpData","error","importSocialProviderFromFile","outcome","readFile","data","JSON","parse","importSocialProvider","_error$response","response","importFirstSocialProviderFromFile","importFirstSocialProvider","_error$response2","importSocialProvidersFromFile","importSocialProviders","_error$response3","importSocialProvidersFromFiles","names","readdirSync","jsonFiles","filter","toLowerCase","endsWith","total","readFileSync","count","Object","keys","idp"],"sources":["ops/IdpOps.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport fs from 'fs';\nimport type { SocialIdpSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport {\n createProgressBar,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport {\n getRealmString,\n getTypedFilename,\n saveJsonToFile,\n} from '../utils/ExportImportUtils';\n\n/**\n * Get a one-line description of the social idp object\n * @param {SocialIdpSkeleton} socialIdpObj social idp object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(socialIdpObj: SocialIdpSkeleton): string {\n const description = `[${socialIdpObj._id['brightCyan']}] ${socialIdpObj._type._id}`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Name/Id | Status | Type |\\n';\n markdown += '| ------- | ------ | ---- |';\n return markdown;\n}\n\n/**\n * Get a table-row of the social idp in markdown\n * @param {SocialIdpSkeleton} socialIdpObj social idp object to describe\n * @returns {string} a table-row of the social idp in markdown\n */\nexport function getTableRowMd(socialIdpObj: SocialIdpSkeleton): string {\n const row = `| ${socialIdpObj._id} | ${\n socialIdpObj.enabled === false\n ? ':o: `disabled`'\n : ':white_check_mark: `enabled`'\n } | ${socialIdpObj._type.name} |`;\n return row;\n}\n\n/**\n * List providers\n */\nexport async function listSocialProviders() {\n try {\n const providers =\n await frodo.oauth2oidc.external.getSocialIdentityProviders();\n providers.sort((a, b) => a._id.localeCompare(b._id));\n providers.forEach((socialIdentityProvider) => {\n printMessage(`${socialIdentityProvider._id}`, 'data');\n });\n } catch (err) {\n printMessage(`listSocialProviders ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n}\n\n/**\n * Export provider by id\n * @param {string} providerId provider id/name\n * @param {string} file optional export file name\n */\nexport async function exportSocialProviderToFile(\n providerId: string,\n file = ''\n) {\n debugMessage(`cli.IdpOps.exportSocialProviderToFile: start`);\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(providerId, 'idp');\n }\n createProgressBar(1, `Exporting ${providerId}`);\n try {\n updateProgressBar(`Writing file ${fileName}`);\n const fileData = await frodo.oauth2oidc.external.exportSocialProvider(\n providerId\n );\n saveJsonToFile(fileData, fileName);\n stopProgressBar(\n `Exported ${providerId['brightCyan']} to ${fileName['brightCyan']}.`\n );\n } catch (err) {\n stopProgressBar(`${err}`);\n printMessage(`${err}`, 'error');\n }\n debugMessage(`cli.IdpOps.exportSocialProviderToFile: end`);\n}\n\n/**\n * Export all providers\n * @param {string} file optional export file name\n */\nexport async function exportSocialProvidersToFile(file = '') {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`all${getRealmString()}Providers`, 'idp');\n }\n const fileData = await frodo.oauth2oidc.external.exportSocialProviders();\n saveJsonToFile(fileData, fileName);\n}\n\n/**\n * Export all providers to individual files\n */\nexport async function exportSocialProvidersToFiles() {\n debugMessage(`cli.IdpOps.exportSocialProvidersToFiles: start`);\n try {\n const allIdpsData =\n await frodo.oauth2oidc.external.getSocialIdentityProviders();\n createProgressBar(allIdpsData.length, 'Exporting providers');\n for (const idpData of allIdpsData) {\n try {\n const fileName = getTypedFilename(idpData._id, 'idp');\n const fileData = await frodo.oauth2oidc.external.exportSocialProvider(\n idpData._id\n );\n saveJsonToFile(fileData, fileName);\n updateProgressBar(`Exported provider ${idpData._id}`);\n } catch (error) {\n printMessage(`Error exporting ${idpData._id}: ${error}`, 'error');\n }\n }\n stopProgressBar(`${allIdpsData.length} providers exported.`);\n } catch (error) {\n stopProgressBar(`${error}`);\n printMessage(`${error}`, 'error');\n }\n debugMessage(`cli.IdpOps.exportSocialProvidersToFiles: end`);\n}\n\n/**\n * Import provider by id/name\n * @param {string} providerId provider id/name\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if provider was imported successfully, false otherwise\n */\nexport async function importSocialProviderFromFile(\n providerId: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing provider ${providerId} from ${file}...`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n outcome = await frodo.oauth2oidc.external.importSocialProvider(\n providerId,\n fileData\n );\n succeedSpinner(\n `Successfully imported provider ${providerId} from ${file}.`\n );\n } catch (error) {\n failSpinner(`Error importing provider ${providerId} from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import first provider from file\n * @param {String} file import file name\n * @returns {Promise<boolean>} true if first provider was imported successfully, false otherwise\n */\nexport async function importFirstSocialProviderFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing first provider from ${file}...`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n outcome = await frodo.oauth2oidc.external.importFirstSocialProvider(\n fileData\n );\n succeedSpinner(`Successfully imported first provider from ${file}.`);\n } catch (error) {\n failSpinner(`Error importing first provider from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import all providers from file\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if all providers were imported successfully, false otherwise\n */\nexport async function importSocialProvidersFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing providers from ${file}...`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n try {\n const fileData = JSON.parse(data);\n outcome = await frodo.oauth2oidc.external.importSocialProviders(fileData);\n succeedSpinner(`Successfully imported providers from ${file}.`);\n } catch (error) {\n failSpinner(`Error importing providers from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n });\n return outcome;\n}\n\n/**\n * Import providers from *.idp.json files in current working directory\n */\nexport async function importSocialProvidersFromFiles() {\n const names = fs.readdirSync('.');\n const jsonFiles = names.filter((name) =>\n name.toLowerCase().endsWith('.idp.json')\n );\n\n createProgressBar(jsonFiles.length, 'Importing providers...');\n let total = 0;\n for (const file of jsonFiles) {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n const count = Object.keys(fileData.idp).length;\n total += count;\n await frodo.oauth2oidc.external.importSocialProviders(fileData);\n updateProgressBar(`Imported ${count} provider(s) from ${file}`);\n }\n stopProgressBar(\n `Finished importing ${total} provider(s) from ${jsonFiles.length} file(s).`\n );\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,iBAAiB,EACjBC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WA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E,EAAE,CAACkE,WAAW,CAAC,GAAG,CAAC;EACjC,MAAMC,SAAS,GAAGF,KAAK,CAACG,MAAM,CAAE9C,IAAI,IAClCA,IAAI,CAAC+C,WAAW,CAAC,CAAC,CAACC,QAAQ,CAAC,WAAW,CACzC,CAAC;EAEDrE,iBAAiB,CAACkE,SAAS,CAACrB,MAAM,EAAE,wBAAwB,CAAC;EAC7D,IAAIyB,KAAK,GAAG,CAAC;EACb,KAAK,MAAMjC,IAAI,IAAI6B,SAAS,EAAE;IAC5B,MAAMf,IAAI,GAAGpD,EAAE,CAACwE,YAAY,CAAClC,IAAI,EAAE,MAAM,CAAC;IAC1C,MAAME,QAAQ,GAAGa,IAAI,CAACC,KAAK,CAACF,IAAI,CAAC;IACjC,MAAMqB,KAAK,GAAGC,MAAM,CAACC,IAAI,CAACnC,QAAQ,CAACoC,GAAG,CAAC,CAAC9B,MAAM;IAC9CyB,KAAK,IAAIE,KAAK;IACd,MAAM1E,KAAK,CAAC0B,UAAU,CAACC,QAAQ,CAACoC,qBAAqB,CAACtB,QAAQ,CAAC;IAC/DhC,iBAAiB,CAAE,YAAWiE,KAAM,qBAAoBnC,IAAK,EAAC,CAAC;EACjE;EACAhC,eAAe,CACZ,sBAAqBiE,KAAM,qBAAoBJ,SAAS,CAACrB,MAAO,WACnE,CAAC;AACH"}
|
package/esm/ops/LogOps.js
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
import { frodo, state } from '@rockcarver/frodo-lib';
|
|
2
|
-
import { printMessage, verboseMessage } from '../utils/Console';
|
|
3
|
-
export async function
|
|
2
|
+
import { createTable, debugMessage, failSpinner, printMessage, showSpinner, succeedSpinner, verboseMessage } from '../utils/Console';
|
|
3
|
+
export async function listLogApiKeys(long = false) {
|
|
4
|
+
let outcome = false;
|
|
4
5
|
try {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
const keys = await frodo.cloud.log.getLogApiKeys();
|
|
7
|
+
if (long) {
|
|
8
|
+
const table = createTable(['Key Id', 'Name', 'Created at']);
|
|
9
|
+
for (const key of keys) {
|
|
10
|
+
table.push([key.api_key_id, key.name, key.created_at]);
|
|
11
|
+
}
|
|
12
|
+
printMessage(table.toString(), 'data');
|
|
13
|
+
} else {
|
|
14
|
+
for (const key of keys) {
|
|
15
|
+
printMessage(`${key.api_key_id}`, 'data');
|
|
16
|
+
}
|
|
13
17
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
});
|
|
17
|
-
setTimeout(() => {
|
|
18
|
-
tailLogs(source, levels, txid, logsObject.pagedResultsCookie, nf);
|
|
19
|
-
}, 5000);
|
|
20
|
-
return null;
|
|
21
|
-
} catch (e) {
|
|
22
|
-
printMessage(`tail ERROR: tail data error - ${e}`, 'error');
|
|
23
|
-
return `tail ERROR: tail data error - ${e}`;
|
|
18
|
+
outcome = true;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
printMessage(`Error listing log API keys: ${error}`, 'error');
|
|
24
21
|
}
|
|
22
|
+
return outcome;
|
|
25
23
|
}
|
|
26
24
|
export async function provisionCreds() {
|
|
27
25
|
try {
|
|
@@ -35,11 +33,14 @@ export async function provisionCreds() {
|
|
|
35
33
|
}
|
|
36
34
|
}
|
|
37
35
|
try {
|
|
38
|
-
const resp = await frodo.cloud.log.
|
|
39
|
-
if (resp.name !== keyName) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
const resp = await frodo.cloud.log.createLogApiKey(keyName);
|
|
37
|
+
// if (resp.name !== keyName) {
|
|
38
|
+
// printMessage(
|
|
39
|
+
// `create keys ERROR: could not create log API key ${keyName} [new key name: ${resp.name}]`,
|
|
40
|
+
// 'error'
|
|
41
|
+
// );
|
|
42
|
+
// return null;
|
|
43
|
+
// }
|
|
43
44
|
verboseMessage(`Created a new log API key [${keyName}] in ${state.getHost()}`);
|
|
44
45
|
return resp;
|
|
45
46
|
} catch (error) {
|
|
@@ -54,6 +55,57 @@ export async function provisionCreds() {
|
|
|
54
55
|
return null;
|
|
55
56
|
}
|
|
56
57
|
}
|
|
58
|
+
export async function deleteLogApiKey(keyId) {
|
|
59
|
+
let outcome = false;
|
|
60
|
+
debugMessage(`cli.LogOps.deleteKey: start`);
|
|
61
|
+
showSpinner(`Deleting ${keyId}...`);
|
|
62
|
+
try {
|
|
63
|
+
await frodo.cloud.log.deleteLogApiKey(keyId);
|
|
64
|
+
succeedSpinner(`Deleted ${keyId}.`);
|
|
65
|
+
outcome = true;
|
|
66
|
+
} catch (error) {
|
|
67
|
+
failSpinner(`Error deleting ${keyId}: ${error.message}`);
|
|
68
|
+
}
|
|
69
|
+
debugMessage(`cli.LogOps.deleteKey: end [${outcome}]`);
|
|
70
|
+
return outcome;
|
|
71
|
+
}
|
|
72
|
+
export async function deleteLogApiKeys() {
|
|
73
|
+
let outcome = false;
|
|
74
|
+
debugMessage(`cli.LogOps.deleteKeys: start`);
|
|
75
|
+
showSpinner(`Deleting all keys...`);
|
|
76
|
+
try {
|
|
77
|
+
const response = await frodo.cloud.log.deleteLogApiKeys();
|
|
78
|
+
succeedSpinner(`Deleted ${response.length} keys.`);
|
|
79
|
+
outcome = true;
|
|
80
|
+
} catch (error) {
|
|
81
|
+
failSpinner(`Error deleting keys: ${error.message}`);
|
|
82
|
+
}
|
|
83
|
+
debugMessage(`cli.LogOps.deleteKeys: end [${outcome}]`);
|
|
84
|
+
return outcome;
|
|
85
|
+
}
|
|
86
|
+
export async function tailLogs(source, levels, txid, cookie, nf) {
|
|
87
|
+
try {
|
|
88
|
+
const logsObject = await frodo.cloud.log.tail(source, cookie);
|
|
89
|
+
let filteredLogs = [];
|
|
90
|
+
const noiseFilter = nf == null ? frodo.cloud.log.getDefaultNoiseFilter() : nf;
|
|
91
|
+
if (Array.isArray(logsObject.result)) {
|
|
92
|
+
filteredLogs = logsObject.result.filter(el => {
|
|
93
|
+
var _transactionId;
|
|
94
|
+
return !noiseFilter.includes(el.payload.logger) && !noiseFilter.includes(el.type) && (levels[0] === 'ALL' || levels.includes(frodo.cloud.log.resolvePayloadLevel(el))) && (typeof txid === 'undefined' || txid === null || ((_transactionId = el.payload.transactionId) === null || _transactionId === void 0 ? void 0 : _transactionId.includes(txid)));
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
filteredLogs.forEach(e => {
|
|
98
|
+
printMessage(JSON.stringify(e), 'data');
|
|
99
|
+
});
|
|
100
|
+
setTimeout(() => {
|
|
101
|
+
tailLogs(source, levels, txid, logsObject.pagedResultsCookie, nf);
|
|
102
|
+
}, 5000);
|
|
103
|
+
return null;
|
|
104
|
+
} catch (e) {
|
|
105
|
+
printMessage(`tail ERROR: tail data error - ${e}`, 'error');
|
|
106
|
+
return `tail ERROR: tail data error - ${e}`;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
57
109
|
export async function fetchLogs(source, startTs, endTs, levels, txid, ffString, cookie, nf) {
|
|
58
110
|
try {
|
|
59
111
|
const logsObject = await frodo.cloud.log.fetch(source, startTs, endTs, cookie);
|
package/esm/ops/LogOps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogOps.js","names":["frodo","state","printMessage","verboseMessage","tailLogs","source","levels","txid","cookie","nf","logsObject","cloud","log","tail","filteredLogs","noiseFilter","getDefaultNoiseFilter","Array","isArray","result","filter","el","_transactionId","includes","payload","logger","type","resolvePayloadLevel","transactionId","forEach","e","JSON","stringify","setTimeout","pagedResultsCookie","provisionCreds","keyName","getUsername","keys","getLogApiKeys","key","name","Date","toISOString","resp","createLogApiKeyAndSecret","getHost","error","fetchLogs","startTs","endTs","ffString","fetch","_transactionId2"],"sources":["ops/LogOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport type { LogEventPayloadSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport { printMessage, verboseMessage } from '../utils/Console';\n\nexport async function tailLogs(\n source: string,\n levels: string[],\n txid: string,\n cookie: string,\n nf: string[]\n) {\n try {\n const logsObject = await frodo.cloud.log.tail(source, cookie);\n let filteredLogs = [];\n const noiseFilter =\n nf == null ? frodo.cloud.log.getDefaultNoiseFilter() : nf;\n if (Array.isArray(logsObject.result)) {\n filteredLogs = logsObject.result.filter(\n (el) =>\n !noiseFilter.includes(\n (el.payload as LogEventPayloadSkeleton).logger\n ) &&\n !noiseFilter.includes(el.type) &&\n (levels[0] === 'ALL' ||\n levels.includes(frodo.cloud.log.resolvePayloadLevel(el))) &&\n (typeof txid === 'undefined' ||\n txid === null ||\n (el.payload as LogEventPayloadSkeleton).transactionId?.includes(\n txid\n ))\n );\n }\n\n filteredLogs.forEach((e) => {\n printMessage(JSON.stringify(e), 'data');\n });\n\n setTimeout(() => {\n tailLogs(source, levels, txid, logsObject.pagedResultsCookie, nf);\n }, 5000);\n return null;\n } catch (e) {\n printMessage(`tail ERROR: tail data error - ${e}`, 'error');\n return `tail ERROR: tail data error - ${e}`;\n }\n}\n\nexport async function provisionCreds() {\n try {\n let keyName = `frodo-${state.getUsername()}`;\n try {\n const keys = await frodo.cloud.log.getLogApiKeys();\n for (const key of keys) {\n if (key.name === keyName) {\n // append current timestamp to name if the named key already exists\n keyName = `${keyName}-${new Date().toISOString()}`;\n }\n }\n try {\n const resp = await frodo.cloud.log.createLogApiKeyAndSecret(keyName);\n if (resp.name !== keyName) {\n printMessage(\n `create keys ERROR: could not create log API key ${keyName}`,\n 'error'\n );\n return null;\n }\n verboseMessage(\n `Created a new log API key [${keyName}] in ${state.getHost()}`\n );\n return resp;\n } catch (error) {\n printMessage(\n `create keys ERROR: create keys call returned ${error}`,\n 'error'\n );\n return null;\n }\n } catch (error) {\n printMessage(`get keys ERROR: get keys call returned ${error}`, 'error');\n }\n } catch (e) {\n printMessage(`create keys ERROR: create keys data error - ${e}`, 'error');\n return null;\n }\n}\n\nexport async function fetchLogs(\n source: string,\n startTs: string,\n endTs: string,\n levels: string[],\n txid: string,\n ffString: string,\n cookie: string,\n nf: string[]\n) {\n try {\n const logsObject = await frodo.cloud.log.fetch(\n source,\n startTs,\n endTs,\n cookie\n );\n let filteredLogs = [];\n const noiseFilter =\n nf == null ? frodo.cloud.log.getDefaultNoiseFilter() : nf;\n if (Array.isArray(logsObject.result)) {\n filteredLogs = logsObject.result.filter(\n (el) =>\n !noiseFilter.includes(\n (el.payload as LogEventPayloadSkeleton).logger\n ) &&\n !noiseFilter.includes(el.type) &&\n (levels[0] === 'ALL' ||\n levels.includes(frodo.cloud.log.resolvePayloadLevel(el))) &&\n (typeof txid === 'undefined' ||\n txid === null ||\n (el.payload as LogEventPayloadSkeleton).transactionId?.includes(\n txid\n ))\n );\n }\n\n filteredLogs.forEach((e) => {\n const log = JSON.stringify(e, null, 2);\n if (ffString) {\n if (log.includes(ffString)) {\n printMessage(log, 'data');\n }\n } else {\n printMessage(log, 'data');\n }\n });\n if (logsObject.pagedResultsCookie != null) {\n await fetchLogs(\n source,\n startTs,\n endTs,\n levels,\n txid,\n ffString,\n logsObject.pagedResultsCookie,\n nf\n );\n }\n return null;\n } catch (e) {\n printMessage(`fetch ERROR: fetch data error - ${e}`, 'error');\n return `fetch ERROR: fetch data error - ${e}`;\n }\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAEpD,SAASC,YAAY,EAAEC,cAAc,QAAQ,kBAAkB;AAE/D,OAAO,eAAeC,QAAQA,CAC5BC,MAAc,EACdC,MAAgB,EAChBC,IAAY,EACZC,MAAc,EACdC,EAAY,EACZ;EACA,IAAI;IACF,MAAMC,UAAU,GAAG,MAAMV,KAAK,CAACW,KAAK,CAACC,GAAG,CAACC,IAAI,CAACR,MAAM,EAAEG,MAAM,CAAC;IAC7D,IAAIM,YAAY,GAAG,EAAE;IACrB,MAAMC,WAAW,GACfN,EAAE,IAAI,IAAI,GAAGT,KAAK,CAACW,KAAK,CAACC,GAAG,CAACI,qBAAqB,CAAC,CAAC,GAAGP,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AAC,CAAC;IACF,IAAIF,UAAU,CAACwB,kBAAkB,IAAI,IAAI,EAAE;MACzC,MAAMc,SAAS,CACb3C,MAAM,EACN4C,OAAO,EACPC,KAAK,EACL5C,MAAM,EACNC,IAAI,EACJ4C,QAAQ,EACRzC,UAAU,CAACwB,kBAAkB,EAC7BzB,EACF,CAAC;IACH;IACA,OAAO,IAAI;EACb,CAAC,CAAC,OAAOqB,CAAC,EAAE;IACV5B,YAAY,CAAE,mCAAkC4B,CAAE,EAAC,EAAE,OAAO,CAAC;IAC7D,OAAQ,mCAAkCA,CAAE,EAAC;EAC/C;AACF"}
|
|
1
|
+
{"version":3,"file":"LogOps.js","names":["frodo","state","createTable","debugMessage","failSpinner","printMessage","showSpinner","succeedSpinner","verboseMessage","listLogApiKeys","long","outcome","keys","cloud","log","getLogApiKeys","table","key","push","api_key_id","name","created_at","toString","error","provisionCreds","keyName","getUsername","Date","toISOString","resp","createLogApiKey","getHost","e","deleteLogApiKey","keyId","message","deleteLogApiKeys","response","length","tailLogs","source","levels","txid","cookie","nf","logsObject","tail","filteredLogs","noiseFilter","getDefaultNoiseFilter","Array","isArray","result","filter","el","_transactionId","includes","payload","logger","type","resolvePayloadLevel","transactionId","forEach","JSON","stringify","setTimeout","pagedResultsCookie","fetchLogs","startTs","endTs","ffString","fetch","_transactionId2"],"sources":["ops/LogOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport type { LogEventPayloadSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport {\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n succeedSpinner,\n verboseMessage,\n} from '../utils/Console';\n\nexport async function listLogApiKeys(long = false): Promise<boolean> {\n let outcome = false;\n try {\n const keys = await frodo.cloud.log.getLogApiKeys();\n if (long) {\n const table = createTable(['Key Id', 'Name', 'Created at']);\n for (const key of keys) {\n table.push([key.api_key_id, key.name, key.created_at]);\n }\n printMessage(table.toString(), 'data');\n } else {\n for (const key of keys) {\n printMessage(`${key.api_key_id}`, 'data');\n }\n }\n outcome = true;\n } catch (error) {\n printMessage(`Error listing log API keys: ${error}`, 'error');\n }\n return outcome;\n}\n\nexport async function provisionCreds() {\n try {\n let keyName = `frodo-${state.getUsername()}`;\n try {\n const keys = await frodo.cloud.log.getLogApiKeys();\n for (const key of keys) {\n if (key.name === keyName) {\n // append current timestamp to name if the named key already exists\n keyName = `${keyName}-${new Date().toISOString()}`;\n }\n }\n try {\n const resp = await frodo.cloud.log.createLogApiKey(keyName);\n // if (resp.name !== keyName) {\n // printMessage(\n // `create keys ERROR: could not create log API key ${keyName} [new key name: ${resp.name}]`,\n // 'error'\n // );\n // return null;\n // }\n verboseMessage(\n `Created a new log API key [${keyName}] in ${state.getHost()}`\n );\n return resp;\n } catch (error) {\n printMessage(\n `create keys ERROR: create keys call returned ${error}`,\n 'error'\n );\n return null;\n }\n } catch (error) {\n printMessage(`get keys ERROR: get keys call returned ${error}`, 'error');\n }\n } catch (e) {\n printMessage(`create keys ERROR: create keys data error - ${e}`, 'error');\n return null;\n }\n}\n\nexport async function deleteLogApiKey(keyId) {\n let outcome = false;\n debugMessage(`cli.LogOps.deleteKey: start`);\n showSpinner(`Deleting ${keyId}...`);\n try {\n await frodo.cloud.log.deleteLogApiKey(keyId);\n succeedSpinner(`Deleted ${keyId}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error deleting ${keyId}: ${error.message}`);\n }\n debugMessage(`cli.LogOps.deleteKey: end [${outcome}]`);\n return outcome;\n}\n\nexport async function deleteLogApiKeys() {\n let outcome = false;\n debugMessage(`cli.LogOps.deleteKeys: start`);\n showSpinner(`Deleting all keys...`);\n try {\n const response = await frodo.cloud.log.deleteLogApiKeys();\n succeedSpinner(`Deleted ${response.length} keys.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error deleting keys: ${error.message}`);\n }\n debugMessage(`cli.LogOps.deleteKeys: end [${outcome}]`);\n return outcome;\n}\n\nexport async function tailLogs(\n source: string,\n levels: string[],\n txid: string,\n cookie: string,\n nf: string[]\n) {\n try {\n const logsObject = await frodo.cloud.log.tail(source, cookie);\n let filteredLogs = [];\n const noiseFilter =\n nf == null ? frodo.cloud.log.getDefaultNoiseFilter() : nf;\n if (Array.isArray(logsObject.result)) {\n filteredLogs = logsObject.result.filter(\n (el) =>\n !noiseFilter.includes(\n (el.payload as LogEventPayloadSkeleton).logger\n ) &&\n !noiseFilter.includes(el.type) &&\n (levels[0] === 'ALL' ||\n levels.includes(frodo.cloud.log.resolvePayloadLevel(el))) &&\n (typeof txid === 'undefined' ||\n txid === null ||\n (el.payload as LogEventPayloadSkeleton).transactionId?.includes(\n txid\n ))\n );\n }\n\n filteredLogs.forEach((e) => {\n printMessage(JSON.stringify(e), 'data');\n });\n\n setTimeout(() => {\n tailLogs(source, levels, txid, logsObject.pagedResultsCookie, nf);\n }, 5000);\n return null;\n } catch (e) {\n printMessage(`tail ERROR: tail data error - ${e}`, 'error');\n return `tail ERROR: tail data error - ${e}`;\n }\n}\n\nexport async function fetchLogs(\n source: string,\n startTs: string,\n endTs: string,\n levels: string[],\n txid: string,\n ffString: string,\n cookie: string,\n nf: string[]\n) {\n try {\n const logsObject = await frodo.cloud.log.fetch(\n source,\n startTs,\n endTs,\n cookie\n );\n let filteredLogs = [];\n const noiseFilter =\n nf == null ? frodo.cloud.log.getDefaultNoiseFilter() : nf;\n if (Array.isArray(logsObject.result)) {\n filteredLogs = logsObject.result.filter(\n (el) =>\n !noiseFilter.includes(\n (el.payload as LogEventPayloadSkeleton).logger\n ) &&\n !noiseFilter.includes(el.type) &&\n (levels[0] === 'ALL' ||\n levels.includes(frodo.cloud.log.resolvePayloadLevel(el))) &&\n (typeof txid === 'undefined' ||\n txid === null ||\n (el.payload as LogEventPayloadSkeleton).transactionId?.includes(\n txid\n ))\n );\n }\n\n filteredLogs.forEach((e) => {\n const log = JSON.stringify(e, null, 2);\n if (ffString) {\n if (log.includes(ffString)) {\n printMessage(log, 'data');\n }\n } else {\n printMessage(log, 'data');\n }\n });\n if (logsObject.pagedResultsCookie != null) {\n await fetchLogs(\n source,\n startTs,\n endTs,\n levels,\n txid,\n ffString,\n logsObject.pagedResultsCookie,\n nf\n );\n }\n return null;\n } catch (e) {\n printMessage(`fetch ERROR: fetch data error - ${e}`, 'error');\n return `fetch ERROR: fetch data error - ${e}`;\n }\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAEpD,SACEC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,cAAc,EACdC,cAAc,QACT,kBAAkB;AAEzB,OAAO,eAAeC,cAAcA,CAACC,IAAI,GAAG,KAAK,EAAoB;EACnE,IAAIC,OAAO,GAAG,KAAK;EACnB,IAAI;IACF,MAAMC,IAAI,GAAG,MAAMZ,KAAK,CAACa,KAAK,CAACC,GAAG,CAACC,aAAa,CAAC,CAAC;IAClD,IAAIL,IAAI,EAAE;MACR,MAAMM,KAAK,GAAGd,WAAW,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;MAC3D,KAAK,MAAMe,GAAG,IAAIL,IAAI,EAAE;QACtBI,KAAK,CAACE,IAAI,CAAC,CAACD,GAAG,CAACE,UAAU,EAAEF,GAAG,CAACG,IAAI,EAAEH,GAAG,CAACI,UAAU,CAAC,CAAC;MACxD;MACAhB,YAAY,CAACW,KAAK,CAACM,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACxC,CAAC,MAAM;MACL,KAAK,MAAML,GAAG,IAAIL,IAAI,EAAE;QACtBP,YAAY,CAAE,GAAEY,GAAG,CAACE,UAAW,EAAC,EAAE,MAAM,CAAC;MAC3C;IACF;IACAR,OAAO,GAAG,IAAI;EAChB,CAAC,CAAC,OAAOY,KAAK,EAAE;IACdlB,YAAY,CAAE,+BAA8BkB,KAAM,EAAC,EAAE,OAAO,CAAC;EAC/D;EACA,OAAOZ,OAAO;AAChB;AAEA,OAAO,eA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AY,CAACS,GAAG,EAAE,MAAM,CAAC;MAC3B;IACF,CAAC,CAAC;IACF,IAAI+B,UAAU,CAACqB,kBAAkB,IAAI,IAAI,EAAE;MACzC,MAAMC,SAAS,CACb3B,MAAM,EACN4B,OAAO,EACPC,KAAK,EACL5B,MAAM,EACNC,IAAI,EACJ4B,QAAQ,EACRzB,UAAU,CAACqB,kBAAkB,EAC7BtB,EACF,CAAC;IACH;IACA,OAAO,IAAI;EACb,CAAC,CAAC,OAAOZ,CAAC,EAAE;IACV3B,YAAY,CAAE,mCAAkC2B,CAAE,EAAC,EAAE,OAAO,CAAC;IAC7D,OAAQ,mCAAkCA,CAAE,EAAC;EAC/C;AACF"}
|
package/esm/ops/RealmOps.js
CHANGED
|
@@ -7,7 +7,7 @@ import { createKeyValueTable, createTable, printMessage } from '../utils/Console
|
|
|
7
7
|
*/
|
|
8
8
|
export async function listRealms(long = false) {
|
|
9
9
|
try {
|
|
10
|
-
const realms = (await frodo.realm.getRealms()).
|
|
10
|
+
const realms = (await frodo.realm.getRealms()).result;
|
|
11
11
|
if (long) {
|
|
12
12
|
const table = createTable(['Name'['brightCyan'], 'Status'['brightCyan'], 'Custom Domains'['brightCyan'], 'Parent'['brightCyan']]);
|
|
13
13
|
realms.forEach(realmConfig => {
|
|
@@ -20,8 +20,10 @@ export async function listRealms(long = false) {
|
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
} catch (error) {
|
|
23
|
+
var _error$response;
|
|
24
|
+
printMessage(error, 'error');
|
|
23
25
|
printMessage(`Error listing realms: ${error.rmessage}`, 'error');
|
|
24
|
-
printMessage(error.response.data, 'error');
|
|
26
|
+
printMessage((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data, 'error');
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
|
|
@@ -61,7 +63,7 @@ export async function addCustomDomain(realm, domain) {
|
|
|
61
63
|
if (!exists) {
|
|
62
64
|
try {
|
|
63
65
|
realmConfig.aliases.push(domain.toLowerCase());
|
|
64
|
-
realmConfig =
|
|
66
|
+
realmConfig = await frodo.realm.putRealm(realmConfig._id, realmConfig);
|
|
65
67
|
const table = createKeyValueTable();
|
|
66
68
|
table.push(['Name'['brightCyan'], realmConfig.name]);
|
|
67
69
|
table.push(['Status'['brightCyan'], realmConfig.active ? 'active'['brightGreen'] : 'inactive'['brightRed']]);
|
|
@@ -90,7 +92,7 @@ export async function removeCustomDomain(realm, domain) {
|
|
|
90
92
|
if (aliases.length < realmConfig.aliases.length) {
|
|
91
93
|
try {
|
|
92
94
|
realmConfig.aliases = aliases;
|
|
93
|
-
realmConfig =
|
|
95
|
+
realmConfig = await frodo.realm.putRealm(realmConfig._id, realmConfig);
|
|
94
96
|
const table = createKeyValueTable();
|
|
95
97
|
table.push(['Name'['brightCyan'], realmConfig.name]);
|
|
96
98
|
table.push(['Status'['brightCyan'], realmConfig.active ? 'active'['brightGreen'] : 'inactive'['brightRed']]);
|
package/esm/ops/RealmOps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RealmOps.js","names":["frodo","createKeyValueTable","createTable","printMessage","listRealms","long","realms","realm","getRealms","
|
|
1
|
+
{"version":3,"file":"RealmOps.js","names":["frodo","createKeyValueTable","createTable","printMessage","listRealms","long","realms","realm","getRealms","result","table","forEach","realmConfig","push","name","active","aliases","join","parentPath","toString","error","_error$response","rmessage","response","data","describeRealm","getRealmByName","_id","addCustomDomain","domain","exists","alias","toLowerCase","putRealm","message","removeCustomDomain","filter","length"],"sources":["ops/RealmOps.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport {\n createKeyValueTable,\n createTable,\n printMessage,\n} from '../utils/Console';\n\n/**\n * List realms\n * @param {boolean} long Long list format with details\n */\nexport async function listRealms(long = false) {\n try {\n const realms = (await frodo.realm.getRealms()).result;\n if (long) {\n const table = createTable([\n 'Name'['brightCyan'],\n 'Status'['brightCyan'],\n 'Custom Domains'['brightCyan'],\n 'Parent'['brightCyan'],\n ]);\n realms.forEach((realmConfig) => {\n table.push([\n realmConfig.name,\n realmConfig.active\n ? 'active'['brightGreen']\n : 'inactive'['brightRed'],\n realmConfig.aliases.join('\\n'),\n realmConfig.parentPath,\n ]);\n });\n printMessage(table.toString());\n } else {\n realms.forEach((realmConfig) => {\n printMessage(realmConfig.name, 'info');\n });\n }\n } catch (error) {\n printMessage(error, 'error');\n printMessage(`Error listing realms: ${error.rmessage}`, 'error');\n printMessage(error.response?.data, 'error');\n }\n}\n\n/**\n * Describe realm\n * @param {String} realm realm name\n */\nexport async function describeRealm(realm: string) {\n try {\n const realmConfig = await frodo.realm.getRealmByName(realm);\n const table = createKeyValueTable();\n table.push(['Name'['brightCyan'], realmConfig.name]);\n table.push([\n 'Status'['brightCyan'],\n realmConfig.active ? 'active'['brightGreen'] : 'inactive'['brightRed'],\n ]);\n table.push([\n 'Custom Domains'['brightCyan'],\n realmConfig.aliases.join('\\n'),\n ]);\n table.push(['Parent'['brightCyan'], realmConfig.parentPath]);\n table.push(['Id'['brightCyan'], realmConfig._id]);\n printMessage(table.toString());\n } catch (error) {\n printMessage(`Realm ${realm} not found!`, 'error');\n }\n}\n\n/**\n * Add custom DNS domain name (realm DNS alias)\n * @param {String} realm realm name\n * @param {String} domain domain name\n */\nexport async function addCustomDomain(realm: string, domain: string) {\n try {\n let realmConfig = await frodo.realm.getRealmByName(realm);\n let exists = false;\n realmConfig.aliases.forEach((alias) => {\n if (domain.toLowerCase() === alias.toLowerCase()) {\n exists = true;\n }\n });\n if (!exists) {\n try {\n realmConfig.aliases.push(domain.toLowerCase());\n realmConfig = await frodo.realm.putRealm(realmConfig._id, realmConfig);\n const table = createKeyValueTable();\n table.push(['Name'['brightCyan'], realmConfig.name]);\n table.push([\n 'Status'['brightCyan'],\n realmConfig.active\n ? 'active'['brightGreen']\n : 'inactive'['brightRed'],\n ]);\n table.push([\n 'Custom Domains'['brightCyan'],\n realmConfig.aliases.join('\\n'),\n ]);\n table.push(['Parent'['brightCyan'], realmConfig.parentPath]);\n table.push(['Id'['brightCyan'], realmConfig._id]);\n printMessage(table.toString());\n } catch (error) {\n printMessage(`Error adding custom domain: ${error.message}`, 'error');\n }\n }\n } catch (error) {\n printMessage(`${error.message}`, 'error');\n }\n}\n\n/**\n * Remove custom DNS domain name (realm DNS alias)\n * @param {String} realm realm name\n * @param {String} domain domain name\n */\nexport async function removeCustomDomain(realm: string, domain: string) {\n try {\n let realmConfig = await frodo.realm.getRealmByName(realm);\n const aliases = realmConfig.aliases.filter(\n (alias) => domain.toLowerCase() !== alias.toLowerCase()\n );\n if (aliases.length < realmConfig.aliases.length) {\n try {\n realmConfig.aliases = aliases;\n realmConfig = await frodo.realm.putRealm(realmConfig._id, realmConfig);\n const table = createKeyValueTable();\n table.push(['Name'['brightCyan'], realmConfig.name]);\n table.push([\n 'Status'['brightCyan'],\n realmConfig.active\n ? 'active'['brightGreen']\n : 'inactive'['brightRed'],\n ]);\n table.push([\n 'Custom Domains'['brightCyan'],\n realmConfig.aliases.join('\\n'),\n ]);\n table.push(['Parent'['brightCyan'], realmConfig.parentPath]);\n table.push(['Id'['brightCyan'], realmConfig._id]);\n printMessage(table.toString());\n } catch (error) {\n printMessage(`Error removing custom domain: ${error.message}`, 'error');\n }\n }\n } catch (error) {\n printMessage(`${error.message}`, 'error');\n }\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,SACEC,mBAAmB,EACnBC,WAAW,EACXC,YAAY,QACP,kBAAkB;;AAEzB;AACA;AACA;AACA;AACA,OAAO,eAAeC,UAAUA,CAACC,IAAI,GAAG,KAAK,EAAE;EAC7C,IAAI;IACF,MAAMC,MAAM,GAAG,CAAC,MAAMN,KAAK,CAACO,KAAK,CAACC,SAAS,CAAC,CAAC,EAAEC,MAAM;IACrD,IAAIJ,IAAI,EAAE;MACR,MAAMK,KAAK,GAAGR,WAAW,CAAC,CACxB,MAAM,CAAC,YAAY,CAAC,EACpB,QAAQ,CAAC,YAAY,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GED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rockcarver/frodo-cli",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-5",
|
|
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": [
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
]
|
|
100
100
|
},
|
|
101
101
|
"dependencies": {
|
|
102
|
-
"@rockcarver/frodo-lib": "2.0.0-
|
|
102
|
+
"@rockcarver/frodo-lib": "2.0.0-6",
|
|
103
103
|
"chokidar": "^3.5.3",
|
|
104
104
|
"cli-progress": "^3.11.2",
|
|
105
105
|
"cli-table3": "^0.6.3",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logs-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/logging/logs-fetch.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { sourcesOptionM } from './logs';\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 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', `${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,QAAQ;AACvC,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,kBAAkB;AAE5D,MAAMC,kBAAkB,GAAG,OAAO;AAClC,MAAMC,iBAAiB,GAAG,IAAI;AAC9B,MAAMC,mBAAmB,GAAGF,kBAAkB;AAC9C,MAAMG,yBAAyB,GAAG,CAAC;AAEnC,MAAMC,OAAO,GAAG,IAAIb,YAAY,CAAC,kBAAkB,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AACvEa,OAAO,CACJC,WAAW,CACV;AACJ,wGACE,CAAC,CACAC,SAAS,CAACd,cAAc,CAAC,CACzBc,SAAS,CACR,IAAIb,MAAM,CACR,qBAAqB,EACrB;AACN;AACA;AACA;AACA,WACI,CAAC,CAACc,OAAO,CAAC,OAAO,EAAG,GAAEb,KAAK,CAACc,KAAK,CAACC,GAAG,CAACC,YAAY,CAAC,OAAO,CAAE,EAAC,CAC/D,CAAC,CACAJ,SAAS,CACR,IAAIb,MAAM,CAAC,6BAA6B,EAAE,yBAAyB,CACrE,CAAC,CACAa,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G,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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logs-list.js","names":["FrodoCommand","frodo","state","printMessage","verboseMessage","provisionCreds","program","description","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","sources","cloud","log","getLogSources","length","saveConnectionProfile","forEach","source","parse"],"sources":["cli/logging/logs-list.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { frodo, state } from '@rockcarver/frodo-lib';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { provisionCreds } from '../../ops/LogOps';\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 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\n const sources = await frodo.cloud.log.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 frodo.conn.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,SAASC,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SAASC,cAAc,QAAQ,kBAAkB;AAEjD,MAAMC,OAAO,GAAG,IAAIN,YAAY,CAAC,iBAAiB,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AACtEM,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;EAC9BX,cAAc,CAAC,2CAA2C,CAAC;EAC3D,MAAMY,IAAI,GAAG,MAAMf,KAAK,CAACe,IAAI,CAACC,oBAAoB,CAAC,CAAC;EACpD,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AK,CAACe,IAAI,CAACuB,qBAAqB,CAAC9B,IAAI,CAAC,CAAC,CAAC;MACvEN,YAAY,CAAE,oBAAmBa,IAAI,CAACG,MAAO,EAAC,CAAC;MAC/Ce,OAAO,CAACM,OAAO,CAAEC,MAAM,IAAK;QAC1BtC,YAAY,CAAE,GAAEsC,MAAO,EAAC,EAAE,MAAM,CAAC;MACnC,CAAC,CAAC;MACFtC,YAAY,CACV,0DAA0D,EAC1D,MACF,CAAC;MACDA,YAAY,CAAE,yCAAwCM,IAAK,EAAC,EAAE,MAAM,CAAC;IACvE;EACF;AACF,CAAC,CAAC;AAEJH,OAAO,CAACoC,KAAK,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logs-tail.js","names":["FrodoCommand","sourcesOptionM","Option","frodo","state","config","printMessage","provisionCreds","tailLogs","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","opts","sources","level","saveConnectionProfile","transactionId","getNoiseFilters","defaults","parse"],"sources":["cli/logging/logs-tail.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { sourcesOptionM } from './logs';\nimport { Option } from 'commander';\nimport { frodo, state } from '@rockcarver/frodo-lib';\nimport * as config from '../../utils/Config';\nimport { printMessage } from '../../utils/Console';\nimport { provisionCreds, tailLogs } from '../../ops/LogOps';\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', `${frodo.cloud.log.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 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 printMessage(\n `Tailing 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 await tailLogs(\n command.opts().sources,\n frodo.cloud.log.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,SAASC,KAAK,EAAEC,KAAK,QAAQ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ACC,YAAY,CAACO,OAAO,CAACqB,IAAI,CAAC,CAAC,CAACE,KAAK,CAAC,EAClDvB,OAAO,CAACqB,IAAI,CAAC,CAAC,CAACI,aAAa,EAC5B,IAAI,EACJ1C,MAAM,CAAC2C,eAAe,CAAC3B,OAAO,CAAC4B,QAAQ,CACzC,CAAC;EACH;AACF,CAAC,CAAC;AAEJxC,OAAO,CAACyC,KAAK,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logs.js","names":["FrodoStubCommand","Option","path","fileURLToPath","__dirname","dirname","import","meta","url","sourcesOptionM","makeOptionMandatory","default","setup","program","summary","description","executableDir","command"],"sources":["cli/logging/logs.ts"],"sourcesContent":["import { FrodoStubCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nexport const sourcesOptionM = new Option(\n '-c, --sources <sources>',\n 'Comma separated list of log sources'\n)\n .makeOptionMandatory()\n .default('am-everything,idm-everything', 'Log everything');\n\nexport default function setup() {\n const program = new FrodoStubCommand('logs')\n .summary('List/View Identity Cloud logs')\n .description(\n `View Identity Cloud logs. If valid tenant admin credentials are specified, a log API key and secret are automatically created for that admin user.`\n )\n .executableDir(__dirname);\n\n program.command('list', 'List available ID Cloud log sources.');\n\n program.command('tail', 'Tail Identity Cloud logs.');\n\n program.command('fetch', 'Fetch Identity Cloud logs for a time window.');\n\n return program;\n}\n"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,iBAAiB;AAClD,SAASC,MAAM,QAAQ,WAAW;AAClC,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,OAAO,MAAMC,cAAc,GAAG,IAAIR,MAAM,CACtC,yBAAyB,EACzB,qCACF,CAAC,CACES,mBAAmB,CAAC,CAAC,CACrBC,OAAO,CAAC,8BAA8B,EAAE,gBAAgB,CAAC;AAE5D,eAAe,SAASC,KAAKA,CAAA,EAAG;EAC9B,MAAMC,OAAO,GAAG,IAAIb,gBAAgB,CAAC,MAAM,CAAC,CACzCc,OAAO,CAAC,+BAA+B,CAAC,CACxCC,WAAW,CACT,oJACH,CAAC,CACAC,aAAa,CAACZ,SAAS,CAAC;EAE3BS,OAAO,CAACI,OAAO,CAAC,MAAM,EAAE,sCAAsC,CAAC;EAE/DJ,OAAO,CAACI,OAAO,CAAC,MAAM,EAAE,2BAA2B,CAAC;EAEpDJ,OAAO,CAACI,OAAO,CAAC,OAAO,EAAE,8CAA8C,CAAC;EAExE,OAAOJ,OAAO;AAChB"}
|