@rockcarver/frodo-cli 0.18.2-13 → 0.18.2-14
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 +1 -1
- package/esm/app.js.map +1 -1
- package/esm/cli/conn/conn-save.js +78 -0
- package/esm/cli/conn/conn-save.js.map +1 -0
- package/esm/cli/conn/conn.js +1 -1
- package/esm/cli/conn/conn.js.map +1 -1
- package/esm/cli/info/info.js +35 -17
- package/esm/cli/info/info.js.map +1 -1
- package/esm/cli/logging/logs-fetch.js +4 -4
- package/esm/cli/logging/logs-fetch.js.map +1 -1
- package/esm/cli/logging/logs-list.js +4 -4
- package/esm/cli/logging/logs-list.js.map +1 -1
- package/esm/cli/logging/logs-tail.js +4 -4
- package/esm/cli/logging/logs-tail.js.map +1 -1
- package/esm/cli/service/service-delete.js +4 -3
- package/esm/cli/service/service-delete.js.map +1 -1
- package/esm/cli/service/service-export.js +6 -4
- package/esm/cli/service/service-export.js.map +1 -1
- package/esm/cli/service/service-import.js +6 -5
- package/esm/cli/service/service-import.js.map +1 -1
- package/esm/cli/service/service-list.js +2 -2
- package/esm/cli/service/service-list.js.map +1 -1
- package/esm/ops/ConnectionProfileOps.js +30 -0
- package/esm/ops/ConnectionProfileOps.js.map +1 -0
- package/esm/ops/ServiceOps.js +20 -20
- package/esm/ops/ServiceOps.js.map +1 -1
- package/package.json +2 -2
- package/esm/cli/conn/conn-add.js +0 -40
- package/esm/cli/conn/conn-add.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
|
+
## [0.18.2-14] - 2022-12-10
|
|
11
|
+
|
|
10
12
|
## [0.18.2-13] - 2022-12-01
|
|
11
13
|
|
|
12
14
|
## [0.18.2-12] - 2022-11-29
|
|
@@ -740,7 +742,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
740
742
|
- Fixed problem with adding connection profiles
|
|
741
743
|
- Miscellaneous bug fixes
|
|
742
744
|
|
|
743
|
-
[Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v0.18.2-
|
|
745
|
+
[Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v0.18.2-14...HEAD
|
|
746
|
+
|
|
747
|
+
[0.18.2-14]: https://github.com/rockcarver/frodo-cli/compare/v0.18.2-13...v0.18.2-14
|
|
744
748
|
|
|
745
749
|
[0.18.2-13]: https://github.com/rockcarver/frodo-cli/compare/v0.18.2-12...v0.18.2-13
|
|
746
750
|
|
package/esm/app.js
CHANGED
|
@@ -28,7 +28,7 @@ const {
|
|
|
28
28
|
try {
|
|
29
29
|
const program = new Command('frodo').version(await getVersions(false), '-v, --version');
|
|
30
30
|
printMessage(await getVersions(true), 'text', false);
|
|
31
|
-
initConnectionProfiles();
|
|
31
|
+
await initConnectionProfiles();
|
|
32
32
|
program.addCommand(admin());
|
|
33
33
|
program.addCommand(agent());
|
|
34
34
|
program.addCommand(app());
|
package/esm/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","names":["ConnectionProfile","Command","admin","agent","app","conn","email","esv","idm","idp","info","journey","logging","realm","saml","script","service","theme","printMessage","getVersions","initConnectionProfiles","program","version","addCommand","showHelpAfterError","enablePositionalOptions","parse","e"],"sources":["app.ts"],"sourcesContent":["#!/usr/bin/env -S node --no-warnings --enable-source-maps --experimental-specifier-resolution=node\n\nimport { ConnectionProfile } from '@rockcarver/frodo-lib';\nimport { Command } from 'commander';\n\n// commands\nimport admin from './cli/admin/admin';\nimport agent from './cli/agent/agent';\nimport app from './cli/app/app';\nimport 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 logging from './cli/logging/logs';\nimport realm from './cli/realm/realm';\nimport saml from './cli/saml/saml';\nimport script from './cli/script/script';\nimport service from './cli/service/service';\nimport theme from './cli/theme/theme';\nimport { printMessage } from './utils/Console';\nimport { getVersions } from './utils/Version';\n\nconst { initConnectionProfiles } = ConnectionProfile;\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 initConnectionProfiles();\n\n program.addCommand(admin());\n program.addCommand(agent());\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(logging());\n program.addCommand(realm());\n program.addCommand(saml());\n program.addCommand(script());\n program.addCommand(service());\n program.addCommand(theme());\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;AAEA,SAASA,iBAAiB,QAAQ,uBAAuB;AACzD,SAASC,OAAO,QAAQ,WAAW;;AAEnC;AACA,OAAOC,KAAK,MAAM,mBAAmB;AACrC,OAAOC,KAAK,MAAM,mBAAmB;AACrC,OAAOC,GAAG,MAAM,eAAe;AAC/B,OAAOC,IAAI,MAAM,iBAAiB;AAClC,OAAOC,KAAK,MAAM,mBAAmB;AACrC,OAAOC,GAAG,MAAM,eAAe;AAC/B,OAAOC,GAAG,MAAM,eAAe;AAC/B,OAAOC,GAAG,MAAM,eAAe;AAC/B,OAAOC,IAAI,MAAM,iBAAiB;AAClC,OAAOC,OAAO,MAAM,uBAAuB;AAC3C,OAAOC,OAAO,MAAM,oBAAoB;AACxC,OAAOC,KAAK,MAAM,mBAAmB;AACrC,OAAOC,IAAI,MAAM,iBAAiB;AAClC,OAAOC,MAAM,MAAM,qBAAqB;AACxC,OAAOC,OAAO,MAAM,uBAAuB;AAC3C,OAAOC,KAAK,MAAM,mBAAmB;AACrC,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,WAAW,QAAQ,iBAAiB;AAE7C,MAAM;EAAEC;AAAuB,CAAC,GAAGpB,iBAAiB;AAEpD,CAAC,YAAY;EACX,IAAI;IACF,MAAMqB,OAAO,GAAG,IAAIpB,OAAO,CAAC,OAAO,CAAC,CAACqB,OAAO,CAC1C,MAAMH,WAAW,CAAC,KAAK,CAAC,EACxB,eAAe,CAChB;IAEDD,YAAY,CAAC,MAAMC,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"app.js","names":["ConnectionProfile","Command","admin","agent","app","conn","email","esv","idm","idp","info","journey","logging","realm","saml","script","service","theme","printMessage","getVersions","initConnectionProfiles","program","version","addCommand","showHelpAfterError","enablePositionalOptions","parse","e"],"sources":["app.ts"],"sourcesContent":["#!/usr/bin/env -S node --no-warnings --enable-source-maps --experimental-specifier-resolution=node\n\nimport { ConnectionProfile } from '@rockcarver/frodo-lib';\nimport { Command } from 'commander';\n\n// commands\nimport admin from './cli/admin/admin';\nimport agent from './cli/agent/agent';\nimport app from './cli/app/app';\nimport 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 logging from './cli/logging/logs';\nimport realm from './cli/realm/realm';\nimport saml from './cli/saml/saml';\nimport script from './cli/script/script';\nimport service from './cli/service/service';\nimport theme from './cli/theme/theme';\nimport { printMessage } from './utils/Console';\nimport { getVersions } from './utils/Version';\n\nconst { initConnectionProfiles } = ConnectionProfile;\n\n(async () => {\n try {\n const program = new Command('frodo').version(\n await getVersions(false),\n '-v, --version'\n );\n\n printMessage(await getVersions(true), 'text', false);\n\n await initConnectionProfiles();\n\n program.addCommand(admin());\n program.addCommand(agent());\n program.addCommand(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(logging());\n program.addCommand(realm());\n program.addCommand(saml());\n program.addCommand(script());\n program.addCommand(service());\n program.addCommand(theme());\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;AAEA,SAASA,iBAAiB,QAAQ,uBAAuB;AACzD,SAASC,OAAO,QAAQ,WAAW;;AAEnC;AACA,OAAOC,KAAK,MAAM,mBAAmB;AACrC,OAAOC,KAAK,MAAM,mBAAmB;AACrC,OAAOC,GAAG,MAAM,eAAe;AAC/B,OAAOC,IAAI,MAAM,iBAAiB;AAClC,OAAOC,KAAK,MAAM,mBAAmB;AACrC,OAAOC,GAAG,MAAM,eAAe;AAC/B,OAAOC,GAAG,MAAM,eAAe;AAC/B,OAAOC,GAAG,MAAM,eAAe;AAC/B,OAAOC,IAAI,MAAM,iBAAiB;AAClC,OAAOC,OAAO,MAAM,uBAAuB;AAC3C,OAAOC,OAAO,MAAM,oBAAoB;AACxC,OAAOC,KAAK,MAAM,mBAAmB;AACrC,OAAOC,IAAI,MAAM,iBAAiB;AAClC,OAAOC,MAAM,MAAM,qBAAqB;AACxC,OAAOC,OAAO,MAAM,uBAAuB;AAC3C,OAAOC,KAAK,MAAM,mBAAmB;AACrC,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,WAAW,QAAQ,iBAAiB;AAE7C,MAAM;EAAEC;AAAuB,CAAC,GAAGpB,iBAAiB;AAEpD,CAAC,YAAY;EACX,IAAI;IACF,MAAMqB,OAAO,GAAG,IAAIpB,OAAO,CAAC,OAAO,CAAC,CAACqB,OAAO,CAC1C,MAAMH,WAAW,CAAC,KAAK,CAAC,EACxB,eAAe,CAChB;IAEDD,YAAY,CAAC,MAAMC,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC;IAEpD,MAAMC,sBAAsB,EAAE;IAE9BC,OAAO,CAACE,UAAU,CAACrB,KAAK,EAAE,CAAC;IAC3BmB,OAAO,CAACE,UAAU,CAACpB,KAAK,EAAE,CAAC;IAC3BkB,OAAO,CAACE,UAAU,CAACnB,GAAG,EAAE,CAAC;IACzBiB,OAAO,CAACE,UAAU,CAAClB,IAAI,EAAE,CAAC;IAC1BgB,OAAO,CAACE,UAAU,CAACjB,KAAK,EAAE,CAAC;IAC3Be,OAAO,CAACE,UAAU,CAAChB,GAAG,EAAE,CAAC;IACzBc,OAAO,CAACE,UAAU,CAACf,GAAG,EAAE,CAAC;IACzBa,OAAO,CAACE,UAAU,CAACd,GAAG,EAAE,CAAC;IACzBY,OAAO,CAACE,UAAU,CAACb,IAAI,EAAE,CAAC;IAC1BW,OAAO,CAACE,UAAU,CAACZ,OAAO,EAAE,CAAC;IAC7BU,OAAO,CAACE,UAAU,CAACX,OAAO,EAAE,CAAC;IAC7BS,OAAO,CAACE,UAAU,CAACV,KAAK,EAAE,CAAC;IAC3BQ,OAAO,CAACE,UAAU,CAACT,IAAI,EAAE,CAAC;IAC1BO,OAAO,CAACE,UAAU,CAACR,MAAM,EAAE,CAAC;IAC5BM,OAAO,CAACE,UAAU,CAACP,OAAO,EAAE,CAAC;IAC7BK,OAAO,CAACE,UAAU,CAACN,KAAK,EAAE,CAAC;IAE3BI,OAAO,CAACG,kBAAkB,EAAE;IAC5BH,OAAO,CAACI,uBAAuB,EAAE;IACjCJ,OAAO,CAACK,KAAK,EAAE;EACjB,CAAC,CAAC,OAAOC,CAAC,EAAE;IACVT,YAAY,CAAE,oCAAmCS,CAAE,EAAC,EAAE,OAAO,CAAC;EAChE;AACF,CAAC,GAAG"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Command, Option } from 'commander';
|
|
2
|
+
import { Authenticate, ConnectionProfile, ServiceAccount, state, constants } from '@rockcarver/frodo-lib';
|
|
3
|
+
import * as common from '../cmd_common.js';
|
|
4
|
+
import { verboseMessage, printMessage } from '../../utils/Console';
|
|
5
|
+
import { addExistingServiceAccount } from '../../ops/ConnectionProfileOps.js';
|
|
6
|
+
const {
|
|
7
|
+
getTokens
|
|
8
|
+
} = Authenticate;
|
|
9
|
+
const {
|
|
10
|
+
saveConnectionProfile,
|
|
11
|
+
addNewServiceAccount
|
|
12
|
+
} = ConnectionProfile;
|
|
13
|
+
const {
|
|
14
|
+
isServiceAccountsFeatureAvailable
|
|
15
|
+
} = ServiceAccount;
|
|
16
|
+
const program = new Command('frodo conn save');
|
|
17
|
+
program.alias('add').description('Save connection profiles.').helpOption('-h, --help', 'Help').showHelpAfterError().addArgument(common.hostArgumentM).addArgument(common.userArgument).addArgument(common.passwordArgument).addArgument(common.apiKeyArgument).addArgument(common.apiSecretArgument).addOption(common.deploymentOption).addOption(common.insecureOption).addOption(common.verboseOption).addOption(common.debugOption).addOption(common.curlirizeOption).addOption(new Option('--sa-id <uuid>', "Service account's uuid. If specified, must also include --sa-jwk-file. Ignored with --no-sa.")).addOption(new Option('--sa-jwk-file <file>', "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.")).addOption(new Option('--no-sa', 'Do not add service account.')).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"}.')).action(
|
|
18
|
+
// implement command logic inside action handler
|
|
19
|
+
async (host, user, password, key, secret, options) => {
|
|
20
|
+
state.default.session.setTenant(host);
|
|
21
|
+
state.default.session.setUsername(user);
|
|
22
|
+
state.default.session.setPassword(password);
|
|
23
|
+
state.default.session.setLogApiKey(key);
|
|
24
|
+
state.default.session.setLogApiSecret(secret);
|
|
25
|
+
state.default.session.setDeploymentType(options.type);
|
|
26
|
+
state.default.session.setAllowInsecureConnection(options.insecure);
|
|
27
|
+
state.default.session.setVerbose(options.verbose);
|
|
28
|
+
state.default.session.setDebug(options.debug);
|
|
29
|
+
state.default.session.setCurlirize(options.curlirize);
|
|
30
|
+
if (options.authenticationService) {
|
|
31
|
+
state.default.session.setAuthenticationService(options.authenticationService);
|
|
32
|
+
}
|
|
33
|
+
if (options.authenticationHeaderOverrides) {
|
|
34
|
+
state.default.session.setAuthenticationHeaderOverrides(JSON.parse(options.authenticationHeaderOverrides));
|
|
35
|
+
}
|
|
36
|
+
if (options.validate && (await getTokens()) || !options.validate) {
|
|
37
|
+
verboseMessage(`Saving connection profile for tenant ${state.default.session.getTenant()}...`);
|
|
38
|
+
// if cloud deployment add service account
|
|
39
|
+
if (options.validate && state.default.session.getDeploymentType() === constants.CLOUD_DEPLOYMENT_TYPE_KEY && options.sa && (await isServiceAccountsFeatureAvailable())) {
|
|
40
|
+
// validate and add existing service account
|
|
41
|
+
if (options.saId && options.saJwkFile) {
|
|
42
|
+
verboseMessage(`Validating and adding service account...`);
|
|
43
|
+
if (await addExistingServiceAccount(options.saId, options.saJwkFile, options.validate)) {
|
|
44
|
+
printMessage(`Validated and added service account with id ${options.saId} to profile.`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// add new service account if none already exists in the profile
|
|
48
|
+
else if (!state.default.session.getServiceAccountId()) {
|
|
49
|
+
try {
|
|
50
|
+
verboseMessage(`Creating service account...`);
|
|
51
|
+
const sa = await addNewServiceAccount();
|
|
52
|
+
printMessage(`Created and added service account ${sa.name} with id ${sa._id} to profile.`);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
var _error$response, _error$response2, _error$response2$data;
|
|
55
|
+
printMessage((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data, 'error');
|
|
56
|
+
printMessage(`Error creating service account: ${(_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : (_error$response2$data = _error$response2.data) === null || _error$response2$data === void 0 ? void 0 : _error$response2$data.message}`, 'error');
|
|
57
|
+
process.exitCode = 1;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// add existing service account without validation
|
|
62
|
+
else if (!options.validate && options.saId && options.saJwkFile && options.sa) {
|
|
63
|
+
addExistingServiceAccount(options.saId, options.saJwkFile, options.validate);
|
|
64
|
+
}
|
|
65
|
+
if (await saveConnectionProfile(host)) {
|
|
66
|
+
printMessage(`Saved connection profile ${state.default.session.getTenant()}`);
|
|
67
|
+
} else {
|
|
68
|
+
process.exitCode = 1;
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
process.exitCode = 1;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// end command logic inside action handler
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
program.parse();
|
|
78
|
+
//# sourceMappingURL=conn-save.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conn-save.js","names":["Command","Option","Authenticate","ConnectionProfile","ServiceAccount","state","constants","common","verboseMessage","printMessage","addExistingServiceAccount","getTokens","saveConnectionProfile","addNewServiceAccount","isServiceAccountsFeatureAvailable","program","alias","description","helpOption","showHelpAfterError","addArgument","hostArgumentM","userArgument","passwordArgument","apiKeyArgument","apiSecretArgument","addOption","deploymentOption","insecureOption","verboseOption","debugOption","curlirizeOption","action","host","user","password","key","secret","options","default","session","setTenant","setUsername","setPassword","setLogApiKey","setLogApiSecret","setDeploymentType","type","setAllowInsecureConnection","insecure","setVerbose","verbose","setDebug","debug","setCurlirize","curlirize","authenticationService","setAuthenticationService","authenticationHeaderOverrides","setAuthenticationHeaderOverrides","JSON","parse","validate","getTenant","getDeploymentType","CLOUD_DEPLOYMENT_TYPE_KEY","sa","saId","saJwkFile","getServiceAccountId","name","_id","error","response","data","message","process","exitCode"],"sources":["cli/conn/conn-save.ts"],"sourcesContent":["import { Command, Option } from 'commander';\nimport {\n Authenticate,\n ConnectionProfile,\n ServiceAccount,\n state,\n constants,\n} from '@rockcarver/frodo-lib';\nimport * as common from '../cmd_common.js';\nimport { verboseMessage, printMessage } from '../../utils/Console';\nimport { addExistingServiceAccount } from '../../ops/ConnectionProfileOps.js';\n\nconst { getTokens } = Authenticate;\nconst { saveConnectionProfile, addNewServiceAccount } = ConnectionProfile;\nconst { isServiceAccountsFeatureAvailable } = ServiceAccount;\n\nconst program = new Command('frodo conn save');\n\nprogram\n .alias('add')\n .description('Save connection profiles.')\n .helpOption('-h, --help', 'Help')\n .showHelpAfterError()\n .addArgument(common.hostArgumentM)\n .addArgument(common.userArgument)\n .addArgument(common.passwordArgument)\n .addArgument(common.apiKeyArgument)\n .addArgument(common.apiSecretArgument)\n .addOption(common.deploymentOption)\n .addOption(common.insecureOption)\n .addOption(common.verboseOption)\n .addOption(common.debugOption)\n .addOption(common.curlirizeOption)\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 add service account.'))\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, key, secret, options) => {\n state.default.session.setTenant(host);\n state.default.session.setUsername(user);\n state.default.session.setPassword(password);\n state.default.session.setLogApiKey(key);\n state.default.session.setLogApiSecret(secret);\n state.default.session.setDeploymentType(options.type);\n state.default.session.setAllowInsecureConnection(options.insecure);\n state.default.session.setVerbose(options.verbose);\n state.default.session.setDebug(options.debug);\n state.default.session.setCurlirize(options.curlirize);\n if (options.authenticationService) {\n state.default.session.setAuthenticationService(\n options.authenticationService\n );\n }\n if (options.authenticationHeaderOverrides) {\n state.default.session.setAuthenticationHeaderOverrides(\n JSON.parse(options.authenticationHeaderOverrides)\n );\n }\n if ((options.validate && (await getTokens())) || !options.validate) {\n verboseMessage(\n `Saving connection profile for tenant ${state.default.session.getTenant()}...`\n );\n // if cloud deployment add service account\n if (\n options.validate &&\n state.default.session.getDeploymentType() ===\n constants.CLOUD_DEPLOYMENT_TYPE_KEY &&\n options.sa &&\n (await 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.default.session.getServiceAccountId()) {\n try {\n verboseMessage(`Creating service account...`);\n const sa = await 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 (await saveConnectionProfile(host)) {\n printMessage(\n `Saved connection profile ${state.default.session.getTenant()}`\n );\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,OAAO,EAAEC,MAAM,QAAQ,WAAW;AAC3C,SACEC,YAAY,EACZC,iBAAiB,EACjBC,cAAc,EACdC,KAAK,EACLC,SAAS,QACJ,uBAAuB;AAC9B,OAAO,KAAKC,MAAM,MAAM,kBAAkB;AAC1C,SAASC,cAAc,EAAEC,YAAY,QAAQ,qBAAqB;AAClE,SAASC,yBAAyB,QAAQ,mCAAmC;AAE7E,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,GAAG,CAAC;QACtB;MACF;IACF;IACA;IAAA,KACK,IACH,CAACvC,OAAO,CAACwB,QAAQ,IACjBxB,OAAO,CAAC6B,IAAI,IACZ7B,OAAO,CAAC8B,SAAS,IACjB9B,OAAO,CAAC4B,EAAE,EACV;MACAxD,yBAAyB,CACvB4B,OAAO,CAAC6B,IAAI,EACZ7B,OAAO,CAAC8B,SAAS,EACjB9B,OAAO,CAACwB,QAAQ,CACjB;IACH;IACA,IAAI,MAAMlD,qBAAqB,CAACqB,IAAI,CAAC,EAAE;MACrCxB,YAAY,CACT,4BAA2BJ,KAAK,CAACkC,OAAO,CAACC,OAAO,CAACuB,SAAS,EAAG,EAAC,CAChE;IACH,CAAC,MAAM;MACLa,OAAO,CAACC,QAAQ,GAAG,CAAC;IACtB;EACF,CAAC,MAAM;IACLD,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AAAA,CACD;;AAEH9D,OAAO,CAAC8C,KAAK,EAAE"}
|
package/esm/cli/conn/conn.js
CHANGED
|
@@ -6,7 +6,7 @@ export default function setup() {
|
|
|
6
6
|
const program = new Command('conn').alias('connection')
|
|
7
7
|
// for backwards compatibility
|
|
8
8
|
.alias('connections').helpOption('-h, --help', 'Help').description('Manage connection profiles.').executableDir(__dirname);
|
|
9
|
-
program.command('
|
|
9
|
+
program.command('save', 'Save connection profiles.').alias('add').showHelpAfterError();
|
|
10
10
|
program.command('delete', 'Delete connection profiles.').showHelpAfterError();
|
|
11
11
|
program.command('describe', 'Describe connection profiles.').showHelpAfterError();
|
|
12
12
|
program.command('list', 'List connection profiles.').showHelpAfterError();
|
package/esm/cli/conn/conn.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conn.js","names":["Command","path","fileURLToPath","__dirname","dirname","import","meta","url","setup","program","alias","helpOption","description","executableDir","command","showHelpAfterError"],"sources":["cli/conn/conn.ts"],"sourcesContent":["import { Command } from 'commander';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nexport default function setup() {\n const program = new Command('conn')\n .alias('connection')\n // for backwards compatibility\n .alias('connections')\n .helpOption('-h, --help', 'Help')\n .description('Manage connection profiles.')\n .executableDir(__dirname);\n\n program.command('
|
|
1
|
+
{"version":3,"file":"conn.js","names":["Command","path","fileURLToPath","__dirname","dirname","import","meta","url","setup","program","alias","helpOption","description","executableDir","command","showHelpAfterError"],"sources":["cli/conn/conn.ts"],"sourcesContent":["import { Command } from 'commander';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nexport default function setup() {\n const program = new Command('conn')\n .alias('connection')\n // for backwards compatibility\n .alias('connections')\n .helpOption('-h, --help', 'Help')\n .description('Manage connection profiles.')\n .executableDir(__dirname);\n\n program\n .command('save', 'Save connection profiles.')\n .alias('add')\n .showHelpAfterError();\n\n program.command('delete', 'Delete connection profiles.').showHelpAfterError();\n\n program\n .command('describe', 'Describe connection profiles.')\n .showHelpAfterError();\n\n program.command('list', 'List connection profiles.').showHelpAfterError();\n\n program.showHelpAfterError();\n return program;\n}\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,WAAW;AACnC,OAAOC,IAAI,MAAM,MAAM;AACvB,SAASC,aAAa,QAAQ,KAAK;AAEnC,MAAMC,SAAS,GAAGF,IAAI,CAACG,OAAO,CAACF,aAAa,CAACG,MAAM,CAACC,IAAI,CAACC,GAAG,CAAC,CAAC;AAE9D,eAAe,SAASC,KAAK,GAAG;EAC9B,MAAMC,OAAO,GAAG,IAAIT,OAAO,CAAC,MAAM,CAAC,CAChCU,KAAK,CAAC,YAAY;EACnB;EAAA,CACCA,KAAK,CAAC,aAAa,CAAC,CACpBC,UAAU,CAAC,YAAY,EAAE,MAAM,CAAC,CAChCC,WAAW,CAAC,6BAA6B,CAAC,CAC1CC,aAAa,CAACV,SAAS,CAAC;EAE3BM,OAAO,CACJK,OAAO,CAAC,MAAM,EAAE,2BAA2B,CAAC,CAC5CJ,KAAK,CAAC,KAAK,CAAC,CACZK,kBAAkB,EAAE;EAEvBN,OAAO,CAACK,OAAO,CAAC,QAAQ,EAAE,6BAA6B,CAAC,CAACC,kBAAkB,EAAE;EAE7EN,OAAO,CACJK,OAAO,CAAC,UAAU,EAAE,+BAA+B,CAAC,CACpDC,kBAAkB,EAAE;EAEvBN,OAAO,CAACK,OAAO,CAAC,MAAM,EAAE,2BAA2B,CAAC,CAACC,kBAAkB,EAAE;EAEzEN,OAAO,CAACM,kBAAkB,EAAE;EAC5B,OAAON,OAAO;AAChB"}
|
package/esm/cli/info/info.js
CHANGED
|
@@ -5,36 +5,54 @@ import { printMessage, verboseMessage } from '../../utils/Console';
|
|
|
5
5
|
const {
|
|
6
6
|
getTokens
|
|
7
7
|
} = Authenticate;
|
|
8
|
+
const {
|
|
9
|
+
getCookieName,
|
|
10
|
+
getCookieValue,
|
|
11
|
+
getBearerToken,
|
|
12
|
+
setTenant,
|
|
13
|
+
setUsername,
|
|
14
|
+
setPassword,
|
|
15
|
+
setDeploymentType,
|
|
16
|
+
setAllowInsecureConnection,
|
|
17
|
+
setVerbose,
|
|
18
|
+
setDebug,
|
|
19
|
+
setCurlirize,
|
|
20
|
+
setItem
|
|
21
|
+
} = state.default.session;
|
|
8
22
|
export default function setup() {
|
|
9
23
|
const info = new Command('info');
|
|
10
24
|
info.addArgument(common.hostArgumentM).addArgument(common.userArgument).addArgument(common.passwordArgument).helpOption('-h, --help', 'Help').addOption(common.deploymentOption).addOption(common.insecureOption).addOption(common.verboseOption).addOption(common.debugOption).addOption(common.curlirizeOption).addOption(common.scriptFriendlyOption).description('Print versions and tokens.').action(async (host, user, password, options) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
25
|
+
setTenant(host);
|
|
26
|
+
setUsername(user);
|
|
27
|
+
setPassword(password);
|
|
28
|
+
setDeploymentType(options.type);
|
|
29
|
+
setAllowInsecureConnection(options.insecure);
|
|
30
|
+
setVerbose(options.verbose);
|
|
31
|
+
setDebug(options.debug);
|
|
32
|
+
setCurlirize(options.curlirize);
|
|
33
|
+
setItem('scriptFriendly', options.scriptFriendly);
|
|
20
34
|
if (!options.scriptFriendly) {
|
|
21
35
|
verboseMessage('Printing versions and tokens...');
|
|
22
36
|
if (await getTokens()) {
|
|
23
|
-
printMessage(`Cookie name: ${
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
37
|
+
printMessage(`Cookie name: ${getCookieName()}`);
|
|
38
|
+
if (getCookieValue()) {
|
|
39
|
+
printMessage(`Session token: ${getCookieValue()}`);
|
|
40
|
+
}
|
|
41
|
+
if (getBearerToken()) {
|
|
42
|
+
printMessage(`Bearer token: ${getBearerToken()}`);
|
|
27
43
|
}
|
|
28
44
|
} else {
|
|
29
45
|
process.exitCode = 1;
|
|
30
46
|
}
|
|
31
47
|
} else if (await getTokens()) {
|
|
32
48
|
const output = {
|
|
33
|
-
cookieName:
|
|
34
|
-
sessionToken: state.default.session.getCookieValue()
|
|
49
|
+
cookieName: getCookieName()
|
|
35
50
|
};
|
|
36
|
-
if (
|
|
37
|
-
output['
|
|
51
|
+
if (getCookieValue()) {
|
|
52
|
+
output['sessionToken'] = getCookieValue();
|
|
53
|
+
}
|
|
54
|
+
if (getBearerToken()) {
|
|
55
|
+
output['bearerToken'] = getBearerToken();
|
|
38
56
|
}
|
|
39
57
|
printMessage(JSON.stringify(output, null, 2), 'data');
|
|
40
58
|
} else {
|
package/esm/cli/info/info.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"info.js","names":["Command","Authenticate","state","common","printMessage","verboseMessage","getTokens","
|
|
1
|
+
{"version":3,"file":"info.js","names":["Command","Authenticate","state","common","printMessage","verboseMessage","getTokens","getCookieName","getCookieValue","getBearerToken","setTenant","setUsername","setPassword","setDeploymentType","setAllowInsecureConnection","setVerbose","setDebug","setCurlirize","setItem","default","session","setup","info","addArgument","hostArgumentM","userArgument","passwordArgument","helpOption","addOption","deploymentOption","insecureOption","verboseOption","debugOption","curlirizeOption","scriptFriendlyOption","description","action","host","user","password","options","type","insecure","verbose","debug","curlirize","scriptFriendly","process","exitCode","output","cookieName","JSON","stringify","showHelpAfterError"],"sources":["cli/info/info.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { Authenticate, state } from '@rockcarver/frodo-lib';\nimport * as common from '../cmd_common';\nimport { printMessage, verboseMessage } from '../../utils/Console';\n\nconst { getTokens } = Authenticate;\nconst {\n getCookieName,\n getCookieValue,\n getBearerToken,\n setTenant,\n setUsername,\n setPassword,\n setDeploymentType,\n setAllowInsecureConnection,\n setVerbose,\n setDebug,\n setCurlirize,\n setItem,\n} = state.default.session;\n\nexport default function setup() {\n const info = new Command('info');\n info\n .addArgument(common.hostArgumentM)\n .addArgument(common.userArgument)\n .addArgument(common.passwordArgument)\n .helpOption('-h, --help', 'Help')\n .addOption(common.deploymentOption)\n .addOption(common.insecureOption)\n .addOption(common.verboseOption)\n .addOption(common.debugOption)\n .addOption(common.curlirizeOption)\n .addOption(common.scriptFriendlyOption)\n .description('Print versions and tokens.')\n .action(async (host, user, password, options) => {\n setTenant(host);\n setUsername(user);\n setPassword(password);\n setDeploymentType(options.type);\n setAllowInsecureConnection(options.insecure);\n setVerbose(options.verbose);\n setDebug(options.debug);\n setCurlirize(options.curlirize);\n setItem('scriptFriendly', options.scriptFriendly);\n if (!options.scriptFriendly) {\n verboseMessage('Printing versions and tokens...');\n if (await getTokens()) {\n printMessage(`Cookie name: ${getCookieName()}`);\n if (getCookieValue()) {\n printMessage(`Session token: ${getCookieValue()}`);\n }\n if (getBearerToken()) {\n printMessage(`Bearer token: ${getBearerToken()}`);\n }\n } else {\n process.exitCode = 1;\n }\n } else if (await getTokens()) {\n const output = {\n cookieName: getCookieName(),\n };\n if (getCookieValue()) {\n output['sessionToken'] = getCookieValue();\n }\n if (getBearerToken()) {\n output['bearerToken'] = getBearerToken();\n }\n printMessage(JSON.stringify(output, null, 2), 'data');\n } else {\n process.exitCode = 1;\n }\n });\n info.showHelpAfterError();\n return info;\n}\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,WAAW;AACnC,SAASC,YAAY,EAAEC,KAAK,QAAQ,uBAAuB;AAC3D,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAElE,MAAM;EAAEC;AAAU,CAAC,GAAGL,YAAY;AAClC,MAAM;EACJM,aAAa;EACbC,cAAc;EACdC,cAAc;EACdC,SAAS;EACTC,WAAW;EACXC,WAAW;EACXC,iBAAiB;EACjBC,0BAA0B;EAC1BC,UAAU;EACVC,QAAQ;EACRC,YAAY;EACZC;AACF,CAAC,GAAGhB,KAAK,CAACiB,OAAO,CAACC,OAAO;AAEzB,eAAe,SAASC,KAAK,GAAG;EAC9B,MAAMC,IAAI,GAAG,IAAItB,OAAO,CAAC,MAAM,CAAC;EAChCsB,IAAI,CACDC,WAAW,CAACpB,MAAM,CAACqB,aAAa,CAAC,CACjCD,WAAW,CAACpB,MAAM,CAACsB,YAAY,CAAC,CAChCF,WAAW,CAACpB,MAAM,CAACuB,gBAAgB,CAAC,CACpCC,UAAU,CAAC,YAAY,EAAE,MAAM,CAAC,CAChCC,SAAS,CAACzB,MAAM,CAAC0B,gBAAgB,CAAC,CAClCD,SAAS,CAACzB,MAAM,CAAC2B,cAAc,CAAC,CAChCF,SAAS,CAACzB,MAAM,CAAC4B,aAAa,CAAC,CAC/BH,SAAS,CAACzB,MAAM,CAAC6B,WAAW,CAAC,CAC7BJ,SAAS,CAACzB,MAAM,CAAC8B,eAAe,CAAC,CACjCL,SAAS,CAACzB,MAAM,CAAC+B,oBAAoB,CAAC,CACtCC,WAAW,CAAC,4BAA4B,CAAC,CACzCC,MAAM,CAAC,OAAOC,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEC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D,CAAC,MAAM;MACLF,OAAO,CAACC,QAAQ,GAAG,CAAC;IACtB;EACF,CAAC,CAAC;EACJ1B,IAAI,CAAC+B,kBAAkB,EAAE;EACzB,OAAO/B,IAAI;AACb"}
|
|
@@ -38,10 +38,10 @@ Cannot be more than 30 days in the past. If not specified, logs from one hour ag
|
|
|
38
38
|
state.default.session.setCurlirize(options.curlirize);
|
|
39
39
|
const conn = await getConnectionProfile();
|
|
40
40
|
state.default.session.setTenant(conn.tenant);
|
|
41
|
-
if (conn.
|
|
41
|
+
if (conn.logApiKey != null && conn.logApiSecret != null) {
|
|
42
42
|
credsFromParameters = false;
|
|
43
|
-
state.default.session.setLogApiKey(conn.
|
|
44
|
-
state.default.session.setLogApiSecret(conn.
|
|
43
|
+
state.default.session.setLogApiKey(conn.logApiKey);
|
|
44
|
+
state.default.session.setLogApiSecret(conn.logApiSecret);
|
|
45
45
|
} else {
|
|
46
46
|
if (conn.username == null && conn.password == null) {
|
|
47
47
|
if (!state.default.session.getUsername() && !state.default.session.getPassword()) {
|
|
@@ -87,7 +87,7 @@ Cannot be more than 30 days in the past. If not specified, logs from one hour ag
|
|
|
87
87
|
}
|
|
88
88
|
let intermediateEndTs = 0;
|
|
89
89
|
printMessage(`Fetching ID Cloud logs from the following sources: ${command.opts().sources} and levels [${resolveLevel(command.opts().level)}]...`);
|
|
90
|
-
if (credsFromParameters) await saveConnectionProfile(); // save new values if they were specified on CLI
|
|
90
|
+
if (credsFromParameters) await saveConnectionProfile(host); // save new values if they were specified on CLI
|
|
91
91
|
|
|
92
92
|
do {
|
|
93
93
|
intermediateEndTs = beginTs + LOG_TIME_WINDOW_INCREMENT;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logs-fetch.js","names":["Command","Option","Authenticate","ConnectionProfile","Log","state","common","config","printMessage","provisionCreds","fetchLogs","resolveLevel","getConnectionProfile","saveConnectionProfile","getTokens","SECONDS_IN_30_DAYS","SECONDS_IN_1_HOUR","LOG_TIME_WINDOW_MAX","LOG_TIME_WINDOW_INCREMENT","program","description","helpOption","showHelpAfterError","addArgument","hostArgumentM","userArgument","passwordArgument","addOption","insecureOption","verboseOption","debugOption","curlirizeOption","sourcesOptionM","default","FRODO_LOG_NOISEFILTER_FILENAME","action","host","user","password","options","command","credsFromParameters","session","setTenant","setUsername","setPassword","setAllowInsecureConnection","insecure","setVerbose","verbose","setDebug","debug","setCurlirize","curlirize","conn","tenant","key","secret","setLogApiKey","setLogApiSecret","username","getUsername","getPassword","creds","api_key_id","api_key_secret","now","Date","beginTimestamp","tempStartDate","setTime","toISOString","tempEndDate","endTimestamp","beginTs","parse","intermediateEndTs","opts","sources","level","transactionId","searchString","getNoiseFilters","defaults"],"sources":["cli/logging/logs-fetch.ts"],"sourcesContent":["import { Command, Option } from 'commander';\nimport {\n Authenticate,\n ConnectionProfile,\n Log,\n state,\n} from '@rockcarver/frodo-lib';\nimport * as common from '../cmd_common';\nimport * as config from '../../utils/Config';\nimport { printMessage } from '../../utils/Console';\n\nconst { provisionCreds, fetchLogs, resolveLevel } = Log;\nconst { getConnectionProfile, saveConnectionProfile } = ConnectionProfile;\nconst { getTokens } = Authenticate;\n\nconst SECONDS_IN_30_DAYS = 2592000;\nconst SECONDS_IN_1_HOUR = 3600;\nconst LOG_TIME_WINDOW_MAX = SECONDS_IN_30_DAYS;\nconst LOG_TIME_WINDOW_INCREMENT = SECONDS_IN_1_HOUR;\n\nconst program = new Command('frodo logs fetch');\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 .helpOption('-h, --help', 'Help')\n .showHelpAfterError()\n .addArgument(common.hostArgumentM)\n .addArgument(common.userArgument)\n .addArgument(common.passwordArgument)\n .addOption(common.insecureOption)\n .addOption(common.verboseOption)\n .addOption(common.debugOption)\n .addOption(common.curlirizeOption)\n .addOption(common.sourcesOptionM)\n .addOption(\n new Option(\n '-l, --level <level>',\n 'Set log level filter. You can specify the level as a number or a string. \\\nFollowing values are possible (values on the same line are equivalent): \\\n\\n0, SEVERE, FATAL, or ERROR\\n1, WARNING, WARN or CONFIG\\\n\\n2, INFO or INFORMATION\\n3, DEBUG, FINE, FINER or FINEST\\\n\\n4 or ALL'\n ).default('ERROR', `${resolveLevel('ERROR')}`)\n )\n .addOption(\n new Option('-t, --transaction-id <txid>', 'Filter by transactionId')\n )\n .addOption(\n new Option(\n '-b, --begin-timestamp <beginTs>',\n 'Begin timestamp for period (in ISO8601, example: \"2022-10-13T19:06:28Z\", or \"2022-09.30\". \\\nCannot be more than 30 days in the past. If not specified, logs from one hour ago are fetched \\\n(-e is ignored)'\n )\n )\n .addOption(\n new Option(\n '-e, --end-timestamp <endTs>',\n 'End timestamp for period. Default: \"now\"'\n )\n )\n .addOption(\n new Option(\n '-s, --search-string <ss>',\n 'Filter by a specific string (ANDed with transactionID filter)'\n )\n )\n .addOption(\n new Option('-d, --defaults', 'Use default logging noise filters').default(\n false,\n `Use custom logging noise filters defined in $HOME/${config.FRODO_LOG_NOISEFILTER_FILENAME}`\n )\n )\n .action(async (host, user, password, options, command) => {\n let credsFromParameters = true;\n state.default.session.setTenant(host);\n state.default.session.setUsername(user);\n state.default.session.setPassword(password);\n state.default.session.setAllowInsecureConnection(options.insecure);\n state.default.session.setVerbose(options.verbose);\n state.default.session.setDebug(options.debug);\n state.default.session.setCurlirize(options.curlirize);\n const conn = await getConnectionProfile();\n state.default.session.setTenant(conn.tenant);\n if (conn.key != null && conn.secret != null) {\n credsFromParameters = false;\n state.default.session.setLogApiKey(conn.key);\n state.default.session.setLogApiSecret(conn.secret);\n } else {\n if (conn.username == null && conn.password == null) {\n if (\n !state.default.session.getUsername() &&\n !state.default.session.getPassword()\n ) {\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.default.session.setUsername(conn.username);\n state.default.session.setPassword(conn.password);\n }\n if (await getTokens()) {\n const creds = await provisionCreds();\n state.default.session.setLogApiKey(creds.api_key_id);\n state.default.session.setLogApiSecret(creds.api_key_secret);\n }\n }\n const now = Date.now() / 1000;\n if (\n typeof options.beginTimestamp === 'undefined' ||\n !options.beginTimestamp\n ) {\n // no beginTimestamp value specified, default is 1 hour ago\n const tempStartDate = new Date();\n tempStartDate.setTime((now - SECONDS_IN_1_HOUR) * 1000);\n options.beginTimestamp = tempStartDate.toISOString();\n // also override endTimestamp to now\n const tempEndDate = new Date();\n tempEndDate.setTime(now * 1000);\n options.endTimestamp = tempEndDate;\n printMessage(\n 'No timestamps specified, defaulting to logs from 1 hour ago',\n 'info'\n );\n }\n if (typeof options.endTimestamp === 'undefined' || !options.endTimestamp) {\n // no endTimestamp value specified, default is now\n options.endTimestamp = now * 1000;\n printMessage(\n 'No end timestamp specified, defaulting end timestamp to \"now\"',\n 'info'\n );\n }\n let beginTs = Date.parse(options.beginTimestamp) / 1000;\n if (Date.parse(options.endTimestamp) / 1000 < beginTs) {\n printMessage('End timestamp can not be before begin timestamp', 'error');\n return;\n }\n if (now - beginTs > LOG_TIME_WINDOW_MAX) {\n printMessage(\n 'Begin timestamp can not be more than 30 days in the past',\n 'error'\n );\n return;\n }\n let intermediateEndTs = 0;\n printMessage(\n `Fetching ID Cloud logs from the following sources: ${\n command.opts().sources\n } and levels [${resolveLevel(command.opts().level)}]...`\n );\n if (credsFromParameters) await saveConnectionProfile(); // save new values if they were specified on CLI\n\n do {\n intermediateEndTs = beginTs + LOG_TIME_WINDOW_INCREMENT;\n await fetchLogs(\n command.opts().sources,\n new Date(beginTs * 1000).toISOString(),\n new Date(intermediateEndTs * 1000).toISOString(),\n resolveLevel(command.opts().level),\n command.opts().transactionId,\n command.opts().searchString,\n null,\n config.getNoiseFilters(options.defaults)\n );\n beginTs = intermediateEndTs;\n } while (intermediateEndTs < Date.parse(options.endTimestamp) / 1000);\n });\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,OAAO,EAAEC,MAAM,QAAQ,WAAW;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OAAO,GAAGxD,yBAAyB;IACvD,MAAMR,SAAS,CACb8B,OAAO,CAACqC,IAAI,EAAE,CAACC,OAAO,EACtB,IAAIX,IAAI,CAACO,OAAO,GAAG,IAAI,CAAC,CAACH,WAAW,EAAE,EACtC,IAAIJ,IAAI,CAACS,iBAAiB,GAAG,IAAI,CAAC,CAACL,WAAW,EAAE,EAChD5D,YAAY,CAAC6B,OAAO,CAACqC,IAAI,EAAE,CAACE,KAAK,CAAC,EAClCvC,OAAO,CAACqC,IAAI,EAAE,CAACG,aAAa,EAC5BxC,OAAO,CAACqC,IAAI,EAAE,CAACI,YAAY,EAC3B,IAAI,EACJ1E,MAAM,CAAC2E,eAAe,CAAC3C,OAAO,CAAC4C,QAAQ,CAAC,CACzC;IACDT,OAAO,GAAGE,iBAAiB;EAC7B,CAAC,QAAQA,iBAAiB,GAAGT,IAAI,CAACQ,KAAK,CAACpC,OAAO,CAACkC,YAAY,CAAC,GAAG,IAAI;AACtE,CAAC,CAAC;AAEJtD,OAAO,CAACwD,KAAK,EAAE"}
|
|
1
|
+
{"version":3,"file":"logs-fetch.js","names":["Command","Option","Authenticate","ConnectionProfile","Log","state","common","config","printMessage","provisionCreds","fetchLogs","resolveLevel","getConnectionProfile","saveConnectionProfile","getTokens","SECONDS_IN_30_DAYS","SECONDS_IN_1_HOUR","LOG_TIME_WINDOW_MAX","LOG_TIME_WINDOW_INCREMENT","program","description","helpOption","showHelpAfterError","addArgument","hostArgumentM","userArgument","passwordArgument","addOption","insecureOption","verboseOption","debugOption","curlirizeOption","sourcesOptionM","default","FRODO_LOG_NOISEFILTER_FILENAME","action","host","user","password","options","command","credsFromParameters","session","setTenant","setUsername","setPassword","setAllowInsecureConnection","insecure","setVerbose","verbose","setDebug","debug","setCurlirize","curlirize","conn","tenant","logApiKey","logApiSecret","setLogApiKey","setLogApiSecret","username","getUsername","getPassword","creds","api_key_id","api_key_secret","now","Date","beginTimestamp","tempStartDate","setTime","toISOString","tempEndDate","endTimestamp","beginTs","parse","intermediateEndTs","opts","sources","level","transactionId","searchString","getNoiseFilters","defaults"],"sources":["cli/logging/logs-fetch.ts"],"sourcesContent":["import { Command, Option } from 'commander';\nimport {\n Authenticate,\n ConnectionProfile,\n Log,\n state,\n} from '@rockcarver/frodo-lib';\nimport * as common from '../cmd_common';\nimport * as config from '../../utils/Config';\nimport { printMessage } from '../../utils/Console';\n\nconst { provisionCreds, fetchLogs, resolveLevel } = Log;\nconst { getConnectionProfile, saveConnectionProfile } = ConnectionProfile;\nconst { getTokens } = Authenticate;\n\nconst SECONDS_IN_30_DAYS = 2592000;\nconst SECONDS_IN_1_HOUR = 3600;\nconst LOG_TIME_WINDOW_MAX = SECONDS_IN_30_DAYS;\nconst LOG_TIME_WINDOW_INCREMENT = SECONDS_IN_1_HOUR;\n\nconst program = new Command('frodo logs fetch');\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 .helpOption('-h, --help', 'Help')\n .showHelpAfterError()\n .addArgument(common.hostArgumentM)\n .addArgument(common.userArgument)\n .addArgument(common.passwordArgument)\n .addOption(common.insecureOption)\n .addOption(common.verboseOption)\n .addOption(common.debugOption)\n .addOption(common.curlirizeOption)\n .addOption(common.sourcesOptionM)\n .addOption(\n new Option(\n '-l, --level <level>',\n 'Set log level filter. You can specify the level as a number or a string. \\\nFollowing values are possible (values on the same line are equivalent): \\\n\\n0, SEVERE, FATAL, or ERROR\\n1, WARNING, WARN or CONFIG\\\n\\n2, INFO or INFORMATION\\n3, DEBUG, FINE, FINER or FINEST\\\n\\n4 or ALL'\n ).default('ERROR', `${resolveLevel('ERROR')}`)\n )\n .addOption(\n new Option('-t, --transaction-id <txid>', 'Filter by transactionId')\n )\n .addOption(\n new Option(\n '-b, --begin-timestamp <beginTs>',\n 'Begin timestamp for period (in ISO8601, example: \"2022-10-13T19:06:28Z\", or \"2022-09.30\". \\\nCannot be more than 30 days in the past. If not specified, logs from one hour ago are fetched \\\n(-e is ignored)'\n )\n )\n .addOption(\n new Option(\n '-e, --end-timestamp <endTs>',\n 'End timestamp for period. Default: \"now\"'\n )\n )\n .addOption(\n new Option(\n '-s, --search-string <ss>',\n 'Filter by a specific string (ANDed with transactionID filter)'\n )\n )\n .addOption(\n new Option('-d, --defaults', 'Use default logging noise filters').default(\n false,\n `Use custom logging noise filters defined in $HOME/${config.FRODO_LOG_NOISEFILTER_FILENAME}`\n )\n )\n .action(async (host, user, password, options, command) => {\n let credsFromParameters = true;\n state.default.session.setTenant(host);\n state.default.session.setUsername(user);\n state.default.session.setPassword(password);\n state.default.session.setAllowInsecureConnection(options.insecure);\n state.default.session.setVerbose(options.verbose);\n state.default.session.setDebug(options.debug);\n state.default.session.setCurlirize(options.curlirize);\n const conn = await getConnectionProfile();\n state.default.session.setTenant(conn.tenant);\n if (conn.logApiKey != null && conn.logApiSecret != null) {\n credsFromParameters = false;\n state.default.session.setLogApiKey(conn.logApiKey);\n state.default.session.setLogApiSecret(conn.logApiSecret);\n } else {\n if (conn.username == null && conn.password == null) {\n if (\n !state.default.session.getUsername() &&\n !state.default.session.getPassword()\n ) {\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.default.session.setUsername(conn.username);\n state.default.session.setPassword(conn.password);\n }\n if (await getTokens()) {\n const creds = await provisionCreds();\n state.default.session.setLogApiKey(creds.api_key_id);\n state.default.session.setLogApiSecret(creds.api_key_secret);\n }\n }\n const now = Date.now() / 1000;\n if (\n typeof options.beginTimestamp === 'undefined' ||\n !options.beginTimestamp\n ) {\n // no beginTimestamp value specified, default is 1 hour ago\n const tempStartDate = new Date();\n tempStartDate.setTime((now - SECONDS_IN_1_HOUR) * 1000);\n options.beginTimestamp = tempStartDate.toISOString();\n // also override endTimestamp to now\n const tempEndDate = new Date();\n tempEndDate.setTime(now * 1000);\n options.endTimestamp = tempEndDate;\n printMessage(\n 'No timestamps specified, defaulting to logs from 1 hour ago',\n 'info'\n );\n }\n if (typeof options.endTimestamp === 'undefined' || !options.endTimestamp) {\n // no endTimestamp value specified, default is now\n options.endTimestamp = now * 1000;\n printMessage(\n 'No end timestamp specified, defaulting end timestamp to \"now\"',\n 'info'\n );\n }\n let beginTs = Date.parse(options.beginTimestamp) / 1000;\n if (Date.parse(options.endTimestamp) / 1000 < beginTs) {\n printMessage('End timestamp can not be before begin timestamp', 'error');\n return;\n }\n if (now - beginTs > LOG_TIME_WINDOW_MAX) {\n printMessage(\n 'Begin timestamp can not be more than 30 days in the past',\n 'error'\n );\n return;\n }\n let intermediateEndTs = 0;\n printMessage(\n `Fetching ID Cloud logs from the following sources: ${\n command.opts().sources\n } and levels [${resolveLevel(command.opts().level)}]...`\n );\n if (credsFromParameters) await saveConnectionProfile(host); // save new values if they were specified on CLI\n\n do {\n intermediateEndTs = beginTs + LOG_TIME_WINDOW_INCREMENT;\n await fetchLogs(\n command.opts().sources,\n new Date(beginTs * 1000).toISOString(),\n new Date(intermediateEndTs * 1000).toISOString(),\n resolveLevel(command.opts().level),\n command.opts().transactionId,\n command.opts().searchString,\n null,\n config.getNoiseFilters(options.defaults)\n );\n beginTs = intermediateEndTs;\n } while (intermediateEndTs < Date.parse(options.endTimestamp) / 1000);\n });\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,OAAO,EAAEC,MAAM,QAAQ,WAAW;AAC3C,SACEC,YAAY,EACZC,iBAAiB,EACjBC,GAAG,EACHC,KAAK,QACA,uBAAuB;AAC9B,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,MAAM,MAAM,oBAAoB;AAC5C,SAASC,YAAY,QAAQ,qBAAqB;AAElD,MAAM;EAAEC,cAAc;EAAEC,SAAS;EAAEC;AAAa,CAAC,GAAGP,GAAG;AACvD,MAAM;EAAEQ,oBAAoB;EAAEC;AAAsB,CAAC,GAAGV,iBAAiB;AACzE,MAAM;EAAEW;AAAU,CAAC,GAAGZ,YAAY;A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ACqC,IAAI,EAAE,CAACI,YAAY,EAC3B,IAAI,EACJ1E,MAAM,CAAC2E,eAAe,CAAC3C,OAAO,CAAC4C,QAAQ,CAAC,CACzC;IACDT,OAAO,GAAGE,iBAAiB;EAC7B,CAAC,QAAQA,iBAAiB,GAAGT,IAAI,CAACQ,KAAK,CAACpC,OAAO,CAACkC,YAAY,CAAC,GAAG,IAAI;AACtE,CAAC,CAAC;AAEJtD,OAAO,CAACwD,KAAK,EAAE"}
|
|
@@ -26,10 +26,10 @@ program.description('List available ID Cloud log sources.').helpOption('-h, --he
|
|
|
26
26
|
printMessage('Listing available ID Cloud log sources...');
|
|
27
27
|
const conn = await getConnectionProfile();
|
|
28
28
|
state.default.session.setTenant(conn.tenant);
|
|
29
|
-
if (conn.
|
|
29
|
+
if (conn.logApiKey != null && conn.logApiSecret != null) {
|
|
30
30
|
credsFromParameters = false;
|
|
31
|
-
state.default.session.setLogApiKey(conn.
|
|
32
|
-
state.default.session.setLogApiSecret(conn.
|
|
31
|
+
state.default.session.setLogApiKey(conn.logApiKey);
|
|
32
|
+
state.default.session.setLogApiSecret(conn.logApiSecret);
|
|
33
33
|
} else {
|
|
34
34
|
if (conn.username == null && conn.password == null) {
|
|
35
35
|
if (!state.default.session.getUsername() && !state.default.session.getPassword()) {
|
|
@@ -51,7 +51,7 @@ program.description('List available ID Cloud log sources.').helpOption('-h, --he
|
|
|
51
51
|
if (sources.length === 0) {
|
|
52
52
|
printMessage("Can't get sources, possible cause - wrong API key or secret", 'error');
|
|
53
53
|
} else {
|
|
54
|
-
if (credsFromParameters) await saveConnectionProfile(); // save new values if they were specified on CLI
|
|
54
|
+
if (credsFromParameters) await saveConnectionProfile(host); // save new values if they were specified on CLI
|
|
55
55
|
printMessage('Available log sources:');
|
|
56
56
|
sources.forEach(source => {
|
|
57
57
|
printMessage(`${source}`, 'info');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logs-list.js","names":["Authenticate","ConnectionProfile","Log","state","Command","printMessage","common","provisionCreds","getLogSources","getConnectionProfile","saveConnectionProfile","getTokens","program","description","helpOption","showHelpAfterError","addArgument","hostArgumentM","userArgument","passwordArgument","addOption","insecureOption","verboseOption","debugOption","curlirizeOption","action","host","user","password","options","credsFromParameters","default","session","setTenant","setUsername","setPassword","setAllowInsecureConnection","insecure","setVerbose","verbose","setDebug","debug","setCurlirize","curlirize","conn","tenant","
|
|
1
|
+
{"version":3,"file":"logs-list.js","names":["Authenticate","ConnectionProfile","Log","state","Command","printMessage","common","provisionCreds","getLogSources","getConnectionProfile","saveConnectionProfile","getTokens","program","description","helpOption","showHelpAfterError","addArgument","hostArgumentM","userArgument","passwordArgument","addOption","insecureOption","verboseOption","debugOption","curlirizeOption","action","host","user","password","options","credsFromParameters","default","session","setTenant","setUsername","setPassword","setAllowInsecureConnection","insecure","setVerbose","verbose","setDebug","debug","setCurlirize","curlirize","conn","tenant","logApiKey","logApiSecret","setLogApiKey","setLogApiSecret","username","getUsername","getPassword","creds","api_key_id","api_key_secret","sources","length","forEach","source","parse"],"sources":["cli/logging/logs-list.ts"],"sourcesContent":["import {\n Authenticate,\n ConnectionProfile,\n Log,\n state,\n} from '@rockcarver/frodo-lib';\nimport { Command } from 'commander';\nimport { printMessage } from '../../utils/Console';\nimport * as common from '../cmd_common';\n\nconst { provisionCreds, getLogSources } = Log;\nconst { getConnectionProfile, saveConnectionProfile } = ConnectionProfile;\nconst { getTokens } = Authenticate;\n\nconst program = new Command('frodo logs list');\nprogram\n .description('List available ID Cloud log sources.')\n .helpOption('-h, --help', 'Help')\n .showHelpAfterError()\n .addArgument(common.hostArgumentM)\n .addArgument(common.userArgument)\n .addArgument(common.passwordArgument)\n .addOption(common.insecureOption)\n .addOption(common.verboseOption)\n .addOption(common.debugOption)\n .addOption(common.curlirizeOption)\n .action(async (host, user, password, options) => {\n let credsFromParameters = true;\n state.default.session.setTenant(host);\n state.default.session.setUsername(user);\n state.default.session.setPassword(password);\n state.default.session.setAllowInsecureConnection(options.insecure);\n state.default.session.setVerbose(options.verbose);\n state.default.session.setDebug(options.debug);\n state.default.session.setCurlirize(options.curlirize);\n printMessage('Listing available ID Cloud log sources...');\n const conn = await getConnectionProfile();\n state.default.session.setTenant(conn.tenant);\n if (conn.logApiKey != null && conn.logApiSecret != null) {\n credsFromParameters = false;\n state.default.session.setLogApiKey(conn.logApiKey);\n state.default.session.setLogApiSecret(conn.logApiSecret);\n } else {\n if (conn.username == null && conn.password == null) {\n if (\n !state.default.session.getUsername() &&\n !state.default.session.getPassword()\n ) {\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.default.session.setUsername(conn.username);\n state.default.session.setPassword(conn.password);\n }\n if (await getTokens()) {\n const creds = await provisionCreds();\n state.default.session.setLogApiKey(creds.api_key_id);\n state.default.session.setLogApiSecret(creds.api_key_secret);\n }\n }\n\n const sources = await getLogSources();\n if (sources.length === 0) {\n printMessage(\n \"Can't get sources, possible cause - wrong API key or secret\",\n 'error'\n );\n } else {\n if (credsFromParameters) await saveConnectionProfile(host); // save new values if they were specified on CLI\n printMessage('Available log sources:');\n sources.forEach((source) => {\n printMessage(`${source}`, 'info');\n });\n printMessage('You can use any combination of comma separated sources.');\n printMessage('For example:');\n printMessage(`$ frodo logs tail -c am-core,idm-core ${host}`, 'info');\n }\n });\n\nprogram.parse();\n"],"mappings":"AAAA,SACEA,YAAY,EACZC,iBAAiB,EACjBC,GAAG,EACHC,KAAK,QACA,uBAAuB;AAC9B,SAASC,OAAO,QAAQ,WAAW;AACnC,SAASC,YAAY,QAAQ,qBAAqB;AAClD,OAAO,KAAKC,MAAM,MAAM,eAAe;AAEvC,MAAM;EAAEC,cAAc;EAAEC;AAAc,CAAC,GAAGN,GAAG;AAC7C,MAAM;EAAEO,oBAAoB;EAAEC;AAAsB,CAAC,GAAGT,iBAAiB;AACzE,MAAM;EAAEU;AAAU,CAAC,GAAGX,YAAY;AAElC,MAAMY,OAAO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,EAAE;IACxBpD,YAAY,CACV,6DAA6D,EAC7D,OAAO,CACR;EACH,CAAC,MAAM;IACL,IAAIyB,mBAAmB,EAAE,MAAMpB,qBAAqB,CAACgB,IAAI,CAAC,CAAC,CAAC;IAC5DrB,YAAY,CAAC,wBAAwB,CAAC;IACtCmD,OAAO,CAACE,OAAO,CAAEC,MAAM,IAAK;MAC1BtD,YAAY,CAAE,GAAEsD,MAAO,EAAC,EAAE,MAAM,CAAC;IACnC,CAAC,CAAC;IACFtD,YAAY,CAAC,yDAAyD,CAAC;IACvEA,YAAY,CAAC,cAAc,CAAC;IAC5BA,YAAY,CAAE,yCAAwCqB,IAAK,EAAC,EAAE,MAAM,CAAC;EACvE;AACF,CAAC,CAAC;AAEJd,OAAO,CAACgD,KAAK,EAAE"}
|
|
@@ -31,10 +31,10 @@ Following values are possible (values on the same line are equivalent): \
|
|
|
31
31
|
state.default.session.setCurlirize(options.curlirize);
|
|
32
32
|
const conn = await getConnectionProfile();
|
|
33
33
|
state.default.session.setTenant(conn.tenant);
|
|
34
|
-
if (conn.
|
|
34
|
+
if (conn.logApiKey != null && conn.logApiSecret != null) {
|
|
35
35
|
credsFromParameters = false;
|
|
36
|
-
state.default.session.setLogApiKey(conn.
|
|
37
|
-
state.default.session.setLogApiSecret(conn.
|
|
36
|
+
state.default.session.setLogApiKey(conn.logApiKey);
|
|
37
|
+
state.default.session.setLogApiSecret(conn.logApiSecret);
|
|
38
38
|
} else {
|
|
39
39
|
if (conn.username == null && conn.password == null) {
|
|
40
40
|
if (!state.default.session.getUsername() && !state.default.session.getPassword()) {
|
|
@@ -53,7 +53,7 @@ Following values are possible (values on the same line are equivalent): \
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
printMessage(`Tailing ID Cloud logs from the following sources: ${command.opts().sources} and levels [${resolveLevel(command.opts().level)}]...`);
|
|
56
|
-
if (credsFromParameters) await saveConnectionProfile(); // save new values if they were specified on CLI
|
|
56
|
+
if (credsFromParameters) await saveConnectionProfile(host); // save new values if they were specified on CLI
|
|
57
57
|
await tailLogs(command.opts().sources, resolveLevel(command.opts().level), command.opts().transactionId, null, config.getNoiseFilters(options.defaults));
|
|
58
58
|
});
|
|
59
59
|
program.parse();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logs-tail.js","names":["Command","Option","Authenticate","ConnectionProfile","Log","state","common","config","printMessage","provisionCreds","tailLogs","resolveLevel","getConnectionProfile","saveConnectionProfile","getTokens","program","description","helpOption","showHelpAfterError","addArgument","hostArgumentM","userArgument","passwordArgument","addOption","insecureOption","verboseOption","debugOption","curlirizeOption","sourcesOptionM","default","FRODO_LOG_NOISEFILTER_FILENAME","action","host","user","password","options","command","credsFromParameters","session","setTenant","setUsername","setPassword","setAllowInsecureConnection","insecure","setVerbose","verbose","setDebug","debug","setCurlirize","curlirize","conn","tenant","
|
|
1
|
+
{"version":3,"file":"logs-tail.js","names":["Command","Option","Authenticate","ConnectionProfile","Log","state","common","config","printMessage","provisionCreds","tailLogs","resolveLevel","getConnectionProfile","saveConnectionProfile","getTokens","program","description","helpOption","showHelpAfterError","addArgument","hostArgumentM","userArgument","passwordArgument","addOption","insecureOption","verboseOption","debugOption","curlirizeOption","sourcesOptionM","default","FRODO_LOG_NOISEFILTER_FILENAME","action","host","user","password","options","command","credsFromParameters","session","setTenant","setUsername","setPassword","setAllowInsecureConnection","insecure","setVerbose","verbose","setDebug","debug","setCurlirize","curlirize","conn","tenant","logApiKey","logApiSecret","setLogApiKey","setLogApiSecret","username","getUsername","getPassword","creds","api_key_id","api_key_secret","opts","sources","level","transactionId","getNoiseFilters","defaults","parse"],"sources":["cli/logging/logs-tail.ts"],"sourcesContent":["import { Command, Option } from 'commander';\nimport {\n Authenticate,\n ConnectionProfile,\n Log,\n state,\n} from '@rockcarver/frodo-lib';\nimport * as common from '../cmd_common';\nimport * as config from '../../utils/Config';\nimport { printMessage } from '../../utils/Console';\n\nconst { provisionCreds, tailLogs, resolveLevel } = Log;\nconst { getConnectionProfile, saveConnectionProfile } = ConnectionProfile;\nconst { getTokens } = Authenticate;\n\nconst program = new Command('frodo logs tail');\nprogram\n .description('Tail Identity Cloud logs.')\n .helpOption('-h, --help', 'Help')\n .showHelpAfterError()\n .addArgument(common.hostArgumentM)\n .addArgument(common.userArgument)\n .addArgument(common.passwordArgument)\n .addOption(common.insecureOption)\n .addOption(common.verboseOption)\n .addOption(common.debugOption)\n .addOption(common.curlirizeOption)\n .addOption(common.sourcesOptionM)\n .addOption(\n new Option(\n '-l, --level <level>',\n 'Set log level filter. You can specify the level as a number or a string. \\\nFollowing values are possible (values on the same line are equivalent): \\\n\\n0, SEVERE, FATAL, or ERROR\\n1, WARNING, WARN or CONFIG\\\n\\n2, INFO or INFORMATION\\n3, DEBUG, FINE, FINER or FINEST\\\n\\n4 or ALL'\n ).default('ERROR', `${resolveLevel('ERROR')}`)\n )\n .addOption(\n new Option('-t, --transaction-id <txid>', 'Filter by transactionId')\n )\n .addOption(\n new Option('-d, --defaults', 'Use default logging noise filters').default(\n false,\n `Use custom logging noise filters defined in $HOME/${config.FRODO_LOG_NOISEFILTER_FILENAME}`\n )\n )\n .action(async (host, user, password, options, command) => {\n let credsFromParameters = true;\n state.default.session.setTenant(host);\n state.default.session.setUsername(user);\n state.default.session.setPassword(password);\n state.default.session.setAllowInsecureConnection(options.insecure);\n state.default.session.setVerbose(options.verbose);\n state.default.session.setDebug(options.debug);\n state.default.session.setCurlirize(options.curlirize);\n const conn = await getConnectionProfile();\n state.default.session.setTenant(conn.tenant);\n if (conn.logApiKey != null && conn.logApiSecret != null) {\n credsFromParameters = false;\n state.default.session.setLogApiKey(conn.logApiKey);\n state.default.session.setLogApiSecret(conn.logApiSecret);\n } else {\n if (conn.username == null && conn.password == null) {\n if (\n !state.default.session.getUsername() &&\n !state.default.session.getPassword()\n ) {\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.default.session.setUsername(conn.username);\n state.default.session.setPassword(conn.password);\n }\n if (await getTokens()) {\n const creds = await provisionCreds();\n state.default.session.setLogApiKey(creds.api_key_id);\n state.default.session.setLogApiSecret(creds.api_key_secret);\n }\n }\n printMessage(\n `Tailing ID Cloud logs from the following sources: ${\n command.opts().sources\n } and levels [${resolveLevel(command.opts().level)}]...`\n );\n if (credsFromParameters) await saveConnectionProfile(host); // save new values if they were specified on CLI\n await tailLogs(\n command.opts().sources,\n resolveLevel(command.opts().level),\n command.opts().transactionId,\n null,\n config.getNoiseFilters(options.defaults)\n );\n });\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,OAAO,EAAEC,MAAM,QAAQ,WAAW;AAC3C,SACEC,YAAY,EACZC,iBAAiB,EACjBC,GAAG,EACHC,KAAK,QACA,uBAAuB;AAC9B,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,OAAO,KAAKC,MAAM,MAAM,oBAAoB;AAC5C,SAASC,YAAY,QAAQ,qBAAqB;AAElD,MAAM;EAAEC,cAAc;EAAEC,QAAQ;EAAEC;AAAa,CAAC,GAAGP,GAAG;AACtD,MAAM;EAAEQ,oBAAoB;EAAEC;AAAsB,CAAC,GAAGV,iBAAiB;AACzE,MAAM;EAAEW;AAAU,CAAC,GAAGZ,YAAY;AAElC,MAAMa,OAAO,GAAG,IAAIf,OAAO,CAAC,iBAAiB,CAAC;AAC9Ce,OAAO,CACJC,WAAW,CAAC,2BAA2B,CAAC,CACxCC,UAAU,CAAC,YAAY,EAAE,MAAM,CAAC,CAChCC,kBAAkB,EAAE,CACpBC,WAAW,CAACb,MAAM,CAACc,aAAa,CAAC,CACjCD,WAAW,CAACb,MAAM,CAACe,YAAY,CAAC,CAChCF,WAAW,CAACb,MAAM,CAACgB,gBAAgB,CAAC,CACpCC,SAAS,CAACjB,MAAM,CAACkB,cAAc,CAAC,CAChCD,SAAS,CAACjB,MAAM,CAACmB,aAAa,CAAC,CAC/BF,SAAS,CAACjB,MAAM,CAACoB,WAAW,CAAC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AAK,CAAE,MAAK,CACzD;EACD,IAAI3B,mBAAmB,EAAE,MAAMxB,qBAAqB,CAACmB,IAAI,CAAC,CAAC,CAAC;EAC5D,MAAMtB,QAAQ,CACZ0B,OAAO,CAAC0B,IAAI,EAAE,CAACC,OAAO,EACtBpD,YAAY,CAACyB,OAAO,CAAC0B,IAAI,EAAE,CAACE,KAAK,CAAC,EAClC5B,OAAO,CAAC0B,IAAI,EAAE,CAACG,aAAa,EAC5B,IAAI,EACJ1D,MAAM,CAAC2D,eAAe,CAAC/B,OAAO,CAACgC,QAAQ,CAAC,CACzC;AACH,CAAC,CAAC;AAEJpD,OAAO,CAACqD,KAAK,EAAE"}
|
|
@@ -6,7 +6,7 @@ const {
|
|
|
6
6
|
getTokens
|
|
7
7
|
} = Authenticate;
|
|
8
8
|
const program = new Command('frodo service delete');
|
|
9
|
-
program.description('Delete AM services.').helpOption('-h, --help', 'Help').showHelpAfterError().addArgument(common.hostArgumentM).addArgument(common.realmArgument).addArgument(common.userArgument).addArgument(common.passwordArgument).addOption(common.deploymentOption).addOption(common.insecureOption).addOption(common.verboseOption).addOption(common.debugOption).addOption(common.curlirizeOption).addOption(new Option('-i, --id <id>', 'Id of Service to be deleted.')).addOption(new Option('-a, --all', 'Delete all services. Ignored with -i.')).action(async (host, realm, user, password, options) => {
|
|
9
|
+
program.description('Delete AM services.').helpOption('-h, --help', 'Help').showHelpAfterError().addArgument(common.hostArgumentM).addArgument(common.realmArgument).addArgument(common.userArgument).addArgument(common.passwordArgument).addOption(common.deploymentOption).addOption(common.insecureOption).addOption(common.verboseOption).addOption(common.debugOption).addOption(common.curlirizeOption).addOption(new Option('-i, --id <id>', 'Id of Service to be deleted.')).addOption(new Option('-a, --all', 'Delete all services. Ignored with -i.')).addOption(new Option('-g, --global', 'List global services.')).action(async (host, realm, user, password, options) => {
|
|
10
10
|
state.default.session.setTenant(host);
|
|
11
11
|
state.default.session.setRealm(realm);
|
|
12
12
|
state.default.session.setUsername(user);
|
|
@@ -16,10 +16,11 @@ program.description('Delete AM services.').helpOption('-h, --help', 'Help').show
|
|
|
16
16
|
state.default.session.setVerbose(options.verbose);
|
|
17
17
|
state.default.session.setDebug(options.debug);
|
|
18
18
|
state.default.session.setCurlirize(options.curlirize);
|
|
19
|
+
const globalConfig = options.global ?? false;
|
|
19
20
|
if (options.id && (await getTokens())) {
|
|
20
|
-
await deleteService(options.id);
|
|
21
|
+
await deleteService(options.id, globalConfig);
|
|
21
22
|
} else if (options.all && (await getTokens())) {
|
|
22
|
-
await deleteServices();
|
|
23
|
+
await deleteServices(globalConfig);
|
|
23
24
|
} else {
|
|
24
25
|
program.help();
|
|
25
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-delete.js","names":["Authenticate","state","Command","Option","deleteService","deleteServices","common","getTokens","program","description","helpOption","showHelpAfterError","addArgument","hostArgumentM","realmArgument","userArgument","passwordArgument","addOption","deploymentOption","insecureOption","verboseOption","debugOption","curlirizeOption","action","host","realm","user","password","options","default","session","setTenant","setRealm","setUsername","setPassword","setDeploymentType","type","setAllowInsecureConnection","insecure","setVerbose","verbose","setDebug","debug","setCurlirize","curlirize","id","all","help","parse"],"sources":["cli/service/service-delete.ts"],"sourcesContent":["import { Authenticate, state } from '@rockcarver/frodo-lib';\nimport { Command, Option } from 'commander';\nimport { deleteService, deleteServices } from '../../ops/ServiceOps.js';\nimport * as common from '../cmd_common.js';\n\nconst { getTokens } = Authenticate;\n\nconst program = new Command('frodo service delete');\n\ninterface ServiceDeleteOptions {\n id?: string;\n type?: string;\n insecure?: boolean;\n verbose?: boolean;\n debug?: boolean;\n curlirize?: boolean;\n all?: boolean;\n}\n\nprogram\n .description('Delete AM services.')\n .helpOption('-h, --help', 'Help')\n .showHelpAfterError()\n .addArgument(common.hostArgumentM)\n .addArgument(common.realmArgument)\n .addArgument(common.userArgument)\n .addArgument(common.passwordArgument)\n .addOption(common.deploymentOption)\n .addOption(common.insecureOption)\n .addOption(common.verboseOption)\n .addOption(common.debugOption)\n .addOption(common.curlirizeOption)\n .addOption(new Option('-i, --id <id>', 'Id of Service to be deleted.'))\n .addOption(new Option('-a, --all', 'Delete all services. Ignored with -i.'))\n .action(\n async (\n host: string,\n realm: string,\n user: string,\n password: string,\n options: ServiceDeleteOptions\n ) => {\n state.default.session.setTenant(host);\n state.default.session.setRealm(realm);\n state.default.session.setUsername(user);\n state.default.session.setPassword(password);\n state.default.session.setDeploymentType(options.type);\n state.default.session.setAllowInsecureConnection(options.insecure);\n state.default.session.setVerbose(options.verbose);\n state.default.session.setDebug(options.debug);\n state.default.session.setCurlirize(options.curlirize);\n if (options.id && (await getTokens())) {\n await deleteService(options.id);\n } else if (options.all && (await getTokens())) {\n await deleteServices();\n } else {\n program.help();\n }\n }\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,EAAEC,KAAK,QAAQ,uBAAuB;AAC3D,SAASC,OAAO,EAAEC,MAAM,QAAQ,WAAW;AAC3C,SAASC,aAAa,EAAEC,cAAc,QAAQ,yBAAyB;AACvE,OAAO,KAAKC,MAAM,MAAM,kBAAkB;AAE1C,MAAM;EAAEC;AAAU,CAAC,GAAGP,YAAY;AAElC,MAAMQ,OAAO,GAAG,IAAIN,OAAO,CAAC,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"service-delete.js","names":["Authenticate","state","Command","Option","deleteService","deleteServices","common","getTokens","program","description","helpOption","showHelpAfterError","addArgument","hostArgumentM","realmArgument","userArgument","passwordArgument","addOption","deploymentOption","insecureOption","verboseOption","debugOption","curlirizeOption","action","host","realm","user","password","options","default","session","setTenant","setRealm","setUsername","setPassword","setDeploymentType","type","setAllowInsecureConnection","insecure","setVerbose","verbose","setDebug","debug","setCurlirize","curlirize","globalConfig","global","id","all","help","parse"],"sources":["cli/service/service-delete.ts"],"sourcesContent":["import { Authenticate, state } from '@rockcarver/frodo-lib';\nimport { Command, Option } from 'commander';\nimport { deleteService, deleteServices } from '../../ops/ServiceOps.js';\nimport * as common from '../cmd_common.js';\n\nconst { getTokens } = Authenticate;\n\nconst program = new Command('frodo service delete');\n\ninterface ServiceDeleteOptions {\n id?: string;\n type?: string;\n insecure?: boolean;\n verbose?: boolean;\n debug?: boolean;\n curlirize?: boolean;\n all?: boolean;\n global?: boolean;\n}\n\nprogram\n .description('Delete AM services.')\n .helpOption('-h, --help', 'Help')\n .showHelpAfterError()\n .addArgument(common.hostArgumentM)\n .addArgument(common.realmArgument)\n .addArgument(common.userArgument)\n .addArgument(common.passwordArgument)\n .addOption(common.deploymentOption)\n .addOption(common.insecureOption)\n .addOption(common.verboseOption)\n .addOption(common.debugOption)\n .addOption(common.curlirizeOption)\n .addOption(new Option('-i, --id <id>', 'Id of Service to be deleted.'))\n .addOption(new Option('-a, --all', 'Delete all services. Ignored with -i.'))\n .addOption(new Option('-g, --global', 'List global services.'))\n .action(\n async (\n host: string,\n realm: string,\n user: string,\n password: string,\n options: ServiceDeleteOptions\n ) => {\n state.default.session.setTenant(host);\n state.default.session.setRealm(realm);\n state.default.session.setUsername(user);\n state.default.session.setPassword(password);\n state.default.session.setDeploymentType(options.type);\n state.default.session.setAllowInsecureConnection(options.insecure);\n state.default.session.setVerbose(options.verbose);\n state.default.session.setDebug(options.debug);\n state.default.session.setCurlirize(options.curlirize);\n\n const globalConfig = options.global ?? false;\n\n if (options.id && (await getTokens())) {\n await deleteService(options.id, globalConfig);\n } else if (options.all && (await getTokens())) {\n await deleteServices(globalConfig);\n } else {\n program.help();\n }\n }\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,EAAEC,KAAK,QAAQ,uBAAuB;AAC3D,SAASC,OAAO,EAAEC,MAAM,QAAQ,WAAW;AAC3C,SAASC,aAAa,EAAEC,cAAc,QAAQ,yBAAyB;AACvE,OAAO,KAAKC,MAAM,MAAM,kBAAkB;AAE1C,MAAM;EAAEC;AAAU,CAAC,GAAGP,YAAY;AAElC,MAAMQ,OAAO,GAAG,IAAIN,OAAO,CAAC,sBAAsB,C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,CAACO,0BAA0B,CAACT,OAAO,CAACU,QAAQ,CAAC;EAClErC,KAAK,CAAC4B,OAAO,CAACC,OAAO,CAACS,UAAU,CAACX,OAAO,CAACY,OAAO,CAAC;EACjDvC,KAAK,CAAC4B,OAAO,CAACC,OAAO,CAACW,QAAQ,CAACb,OAAO,CAACc,KAAK,CAAC;EAC7CzC,KAAK,CAAC4B,OAAO,CAACC,OAAO,CAACa,YAAY,CAACf,OAAO,CAACgB,SAAS,CAAC;EAErD,MAAMC,YAAY,GAAGjB,OAAO,CAACkB,MAAM,IAAI,KAAK;EAE5C,IAAIlB,OAAO,CAACmB,EAAE,KAAK,MAAMxC,SAAS,EAAE,CAAC,EAAE;IACrC,MAAMH,aAAa,CAACwB,OAAO,CAACmB,EAAE,EAAEF,YAAY,CAAC;EAC/C,CAAC,MAAM,IAAIjB,OAAO,CAACoB,GAAG,KAAK,MAAMzC,SAAS,EAAE,CAAC,EAAE;IAC7C,MAAMF,cAAc,CAACwC,YAAY,CAAC;EACpC,CAAC,MAAM;IACLrC,OAAO,CAACyC,IAAI,EAAE;EAChB;AACF,CAAC,CACF;AAEHzC,OAAO,CAAC0C,KAAK,EAAE"}
|
|
@@ -7,7 +7,7 @@ const {
|
|
|
7
7
|
getTokens
|
|
8
8
|
} = Authenticate;
|
|
9
9
|
const program = new Command('frodo service export');
|
|
10
|
-
program.description('Export AM services.').helpOption('-h, --help', 'Help').showHelpAfterError().addArgument(common.hostArgumentM).addArgument(common.realmArgument).addArgument(common.userArgument).addArgument(common.passwordArgument).addOption(common.deploymentOption).addOption(common.insecureOption).addOption(common.verboseOption).addOption(common.debugOption).addOption(common.curlirizeOption).addOption(new Option('-i, --service-id <service-id>', 'Service id. If specified, -a and -A are ignored.')).addOption(new Option('-f, --file <file>', 'Name of the export file.')).addOption(new Option('-a, --all', 'Export all services to a single file.')).addOption(new Option('-A, --all-separate', 'Export all services to separate files (*.service.json) in the current directory. Ignored with -a.')).action(async (host, realm, user, password, options) => {
|
|
10
|
+
program.description('Export AM services.').helpOption('-h, --help', 'Help').showHelpAfterError().addArgument(common.hostArgumentM).addArgument(common.realmArgument).addArgument(common.userArgument).addArgument(common.passwordArgument).addOption(common.deploymentOption).addOption(common.insecureOption).addOption(common.verboseOption).addOption(common.debugOption).addOption(common.curlirizeOption).addOption(new Option('-i, --service-id <service-id>', 'Service id. If specified, -a and -A are ignored.')).addOption(new Option('-f, --file <file>', 'Name of the export file.')).addOption(new Option('-a, --all', 'Export all services to a single file.')).addOption(new Option('-A, --all-separate', 'Export all services to separate files (*.service.json) in the current directory. Ignored with -a.')).addOption(new Option('-g, --global', 'List global services.')).action(async (host, realm, user, password, options) => {
|
|
11
11
|
state.default.session.setTenant(host);
|
|
12
12
|
state.default.session.setRealm(realm);
|
|
13
13
|
state.default.session.setUsername(user);
|
|
@@ -17,20 +17,22 @@ program.description('Export AM services.').helpOption('-h, --help', 'Help').show
|
|
|
17
17
|
state.default.session.setVerbose(options.verbose);
|
|
18
18
|
state.default.session.setDebug(options.debug);
|
|
19
19
|
state.default.session.setCurlirize(options.curlirize);
|
|
20
|
+
const globalConfig = options.global ?? false;
|
|
21
|
+
|
|
20
22
|
// export by name
|
|
21
23
|
if (options.serviceId && (await getTokens())) {
|
|
22
24
|
verboseMessage('Exporting service...');
|
|
23
|
-
await exportServiceToFile(options.serviceId, options.file);
|
|
25
|
+
await exportServiceToFile(options.serviceId, options.file, globalConfig);
|
|
24
26
|
}
|
|
25
27
|
// -a / --all
|
|
26
28
|
else if (options.all && (await getTokens())) {
|
|
27
29
|
verboseMessage('Exporting all services to a single file...');
|
|
28
|
-
await exportServicesToFile(options.file);
|
|
30
|
+
await exportServicesToFile(options.file, globalConfig);
|
|
29
31
|
}
|
|
30
32
|
// -A / --all-separate
|
|
31
33
|
else if (options.allSeparate && (await getTokens())) {
|
|
32
34
|
verboseMessage('Exporting all services to separate files...');
|
|
33
|
-
await exportServicesToFiles();
|
|
35
|
+
await exportServicesToFiles(globalConfig);
|
|
34
36
|
}
|
|
35
37
|
// unrecognized combination of options or no options
|
|
36
38
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-export.js","names":["Authenticate","state","Command","Option","exportServicesToFile","exportServicesToFiles","exportServiceToFile","printMessage","verboseMessage","common","getTokens","program","description","helpOption","showHelpAfterError","addArgument","hostArgumentM","realmArgument","userArgument","passwordArgument","addOption","deploymentOption","insecureOption","verboseOption","debugOption","curlirizeOption","action","host","realm","user","password","options","default","session","setTenant","setRealm","setUsername","setPassword","setDeploymentType","type","setAllowInsecureConnection","insecure","setVerbose","verbose","setDebug","debug","setCurlirize","curlirize","serviceId","file","all","allSeparate","help","parse"],"sources":["cli/service/service-export.ts"],"sourcesContent":["import { Authenticate, state } from '@rockcarver/frodo-lib';\nimport { Command, Option } from 'commander';\nimport {\n exportServicesToFile,\n exportServicesToFiles,\n exportServiceToFile,\n} from '../../ops/ServiceOps.js';\nimport { printMessage, verboseMessage } from '../../utils/Console.js';\nimport * as common from '../cmd_common.js';\n\nconst { getTokens } = Authenticate;\n\nconst program = new Command('frodo service export');\n\ninterface ServiceExportOptions {\n file?: string;\n all?: boolean;\n serviceId?: string;\n allSeparate?: boolean;\n type?: string;\n insecure?: boolean;\n verbose?: boolean;\n debug?: boolean;\n curlirize?: boolean;\n}\n\nprogram\n .description('Export AM services.')\n .helpOption('-h, --help', 'Help')\n .showHelpAfterError()\n .addArgument(common.hostArgumentM)\n .addArgument(common.realmArgument)\n .addArgument(common.userArgument)\n .addArgument(common.passwordArgument)\n .addOption(common.deploymentOption)\n .addOption(common.insecureOption)\n .addOption(common.verboseOption)\n .addOption(common.debugOption)\n .addOption(common.curlirizeOption)\n .addOption(\n new Option(\n '-i, --service-id <service-id>',\n 'Service id. If specified, -a and -A are ignored.'\n )\n )\n .addOption(new Option('-f, --file <file>', 'Name of the export file.'))\n .addOption(new Option('-a, --all', 'Export all services to a single file.'))\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Export all services to separate files (*.service.json) in the current directory. Ignored with -a.'\n )\n )\n .action(\n async (\n host: string,\n realm: string,\n user: string,\n password: string,\n options: ServiceExportOptions\n ) => {\n state.default.session.setTenant(host);\n state.default.session.setRealm(realm);\n state.default.session.setUsername(user);\n state.default.session.setPassword(password);\n state.default.session.setDeploymentType(options.type);\n state.default.session.setAllowInsecureConnection(options.insecure);\n state.default.session.setVerbose(options.verbose);\n state.default.session.setDebug(options.debug);\n state.default.session.setCurlirize(options.curlirize);\n // export by name\n if (options.serviceId && (await getTokens())) {\n verboseMessage('Exporting service...');\n await exportServiceToFile(options.serviceId
|
|
1
|
+
{"version":3,"file":"service-export.js","names":["Authenticate","state","Command","Option","exportServicesToFile","exportServicesToFiles","exportServiceToFile","printMessage","verboseMessage","common","getTokens","program","description","helpOption","showHelpAfterError","addArgument","hostArgumentM","realmArgument","userArgument","passwordArgument","addOption","deploymentOption","insecureOption","verboseOption","debugOption","curlirizeOption","action","host","realm","user","password","options","default","session","setTenant","setRealm","setUsername","setPassword","setDeploymentType","type","setAllowInsecureConnection","insecure","setVerbose","verbose","setDebug","debug","setCurlirize","curlirize","globalConfig","global","serviceId","file","all","allSeparate","help","parse"],"sources":["cli/service/service-export.ts"],"sourcesContent":["import { Authenticate, state } from '@rockcarver/frodo-lib';\nimport { Command, Option } from 'commander';\nimport {\n exportServicesToFile,\n exportServicesToFiles,\n exportServiceToFile,\n} from '../../ops/ServiceOps.js';\nimport { printMessage, verboseMessage } from '../../utils/Console.js';\nimport * as common from '../cmd_common.js';\n\nconst { getTokens } = Authenticate;\n\nconst program = new Command('frodo service export');\n\ninterface ServiceExportOptions {\n file?: string;\n all?: boolean;\n serviceId?: string;\n allSeparate?: boolean;\n type?: string;\n insecure?: boolean;\n verbose?: boolean;\n debug?: boolean;\n curlirize?: boolean;\n global?: boolean;\n}\n\nprogram\n .description('Export AM services.')\n .helpOption('-h, --help', 'Help')\n .showHelpAfterError()\n .addArgument(common.hostArgumentM)\n .addArgument(common.realmArgument)\n .addArgument(common.userArgument)\n .addArgument(common.passwordArgument)\n .addOption(common.deploymentOption)\n .addOption(common.insecureOption)\n .addOption(common.verboseOption)\n .addOption(common.debugOption)\n .addOption(common.curlirizeOption)\n .addOption(\n new Option(\n '-i, --service-id <service-id>',\n 'Service id. If specified, -a and -A are ignored.'\n )\n )\n .addOption(new Option('-f, --file <file>', 'Name of the export file.'))\n .addOption(new Option('-a, --all', 'Export all services to a single file.'))\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Export all services to separate files (*.service.json) in the current directory. Ignored with -a.'\n )\n )\n .addOption(new Option('-g, --global', 'List global services.'))\n .action(\n async (\n host: string,\n realm: string,\n user: string,\n password: string,\n options: ServiceExportOptions\n ) => {\n state.default.session.setTenant(host);\n state.default.session.setRealm(realm);\n state.default.session.setUsername(user);\n state.default.session.setPassword(password);\n state.default.session.setDeploymentType(options.type);\n state.default.session.setAllowInsecureConnection(options.insecure);\n state.default.session.setVerbose(options.verbose);\n state.default.session.setDebug(options.debug);\n state.default.session.setCurlirize(options.curlirize);\n\n const globalConfig = options.global ?? false;\n\n // export by name\n if (options.serviceId && (await getTokens())) {\n verboseMessage('Exporting service...');\n await exportServiceToFile(\n options.serviceId,\n options.file,\n globalConfig\n );\n }\n // -a / --all\n else if (options.all && (await getTokens())) {\n verboseMessage('Exporting all services to a single file...');\n await exportServicesToFile(options.file, globalConfig);\n }\n // -A / --all-separate\n else if (options.allSeparate && (await getTokens())) {\n verboseMessage('Exporting all services to separate files...');\n await exportServicesToFiles(globalConfig);\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 }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,EAAEC,KAAK,QAAQ,uBAAuB;AAC3D,SAASC,OAAO,EAAEC,MAAM,QAAQ,WAAW;AAC3C,SACEC,oBAAoB,EACpBC,qBAAqB,EACrBC,mBAAmB,QACd,yBAAyB;AAChC,SAASC,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AC2C,YAAY,CAAC;EAC3C;EACA;EAAA,KACK;IACHzC,YAAY,CACV,sDAAsD,EACtD,OAAO,CACR;IACDI,OAAO,CAAC2C,IAAI,EAAE;EAChB;AACF;AACA;AAAA,CACD;;AAEH3C,OAAO,CAAC4C,KAAK,EAAE"}
|
|
@@ -7,7 +7,7 @@ const {
|
|
|
7
7
|
getTokens
|
|
8
8
|
} = Authenticate;
|
|
9
9
|
const program = new Command('frodo service import');
|
|
10
|
-
program.description('Import AM services.').helpOption('-h, --help', 'Help').showHelpAfterError().addArgument(common.hostArgumentM).addArgument(common.realmArgument).addArgument(common.userArgument).addArgument(common.passwordArgument).addOption(common.deploymentOption).addOption(common.insecureOption).addOption(common.verboseOption).addOption(common.debugOption).addOption(common.curlirizeOption).addOption(new Option('-i, --service-id <service-id>', 'Service id. If specified, -a and -A are ignored.')).addOption(new Option('-f, --file <file>', 'Name of the file to import SAML Entity(s) from. Ignored with -A.')).addOption(new Option('-a, --all', 'Import all services from a single file.')).addOption(new Option('-C, --clean', 'Remove existing service(s) before importing.')).addOption(new Option('-A, --all-separate', 'Import all services from separate files <id>.service.json.')).addOption(new Option('-D, --directory <directory>', 'Working directory.')).action(async (host, realm, user, password, options) => {
|
|
10
|
+
program.description('Import AM services.').helpOption('-h, --help', 'Help').showHelpAfterError().addArgument(common.hostArgumentM).addArgument(common.realmArgument).addArgument(common.userArgument).addArgument(common.passwordArgument).addOption(common.deploymentOption).addOption(common.insecureOption).addOption(common.verboseOption).addOption(common.debugOption).addOption(common.curlirizeOption).addOption(new Option('-i, --service-id <service-id>', 'Service id. If specified, -a and -A are ignored.')).addOption(new Option('-f, --file <file>', 'Name of the file to import SAML Entity(s) from. Ignored with -A.')).addOption(new Option('-a, --all', 'Import all services from a single file.')).addOption(new Option('-C, --clean', 'Remove existing service(s) before importing.')).addOption(new Option('-A, --all-separate', 'Import all services from separate files <id>.service.json.')).addOption(new Option('-D, --directory <directory>', 'Working directory.')).addOption(new Option('-g, --global', 'List global services.')).action(async (host, realm, user, password, options) => {
|
|
11
11
|
state.default.session.setTenant(host);
|
|
12
12
|
state.default.session.setRealm(realm);
|
|
13
13
|
state.default.session.setUsername(user);
|
|
@@ -19,26 +19,27 @@ program.description('Import AM services.').helpOption('-h, --help', 'Help').show
|
|
|
19
19
|
state.default.session.setCurlirize(options.curlirize);
|
|
20
20
|
state.default.session.setDirectory(options.directory || '.');
|
|
21
21
|
const clean = options.clean ?? false;
|
|
22
|
+
const globalConfig = options.global ?? false;
|
|
22
23
|
|
|
23
24
|
// import by id
|
|
24
25
|
if (options.serviceId && options.file && (await getTokens())) {
|
|
25
26
|
verboseMessage('Importing service...');
|
|
26
|
-
await importServiceFromFile(options.serviceId, options.file, clean);
|
|
27
|
+
await importServiceFromFile(options.serviceId, options.file, clean, globalConfig);
|
|
27
28
|
}
|
|
28
29
|
// -a / --all
|
|
29
30
|
else if (options.all && options.file && (await getTokens())) {
|
|
30
31
|
verboseMessage('Importing all services from a single file...');
|
|
31
|
-
await importServicesFromFile(options.file, clean);
|
|
32
|
+
await importServicesFromFile(options.file, clean, globalConfig);
|
|
32
33
|
}
|
|
33
34
|
// -A / --all-separate
|
|
34
35
|
else if (options.allSeparate && (await getTokens())) {
|
|
35
36
|
verboseMessage('Importing all services from separate files...');
|
|
36
|
-
await importServicesFromFiles(clean);
|
|
37
|
+
await importServicesFromFiles(clean, globalConfig);
|
|
37
38
|
}
|
|
38
39
|
// import file
|
|
39
40
|
else if (options.file && (await getTokens())) {
|
|
40
41
|
verboseMessage('Importing service...');
|
|
41
|
-
await importFirstServiceFromFile(options.file, clean);
|
|
42
|
+
await importFirstServiceFromFile(options.file, clean, globalConfig);
|
|
42
43
|
}
|
|
43
44
|
// unrecognized combination of options or no options
|
|
44
45
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-import.js","names":["Authenticate","state","Command","Option","importFirstServiceFromFile","importServiceFromFile","importServicesFromFile","importServicesFromFiles","printMessage","verboseMessage","common","getTokens","program","description","helpOption","showHelpAfterError","addArgument","hostArgumentM","realmArgument","userArgument","passwordArgument","addOption","deploymentOption","insecureOption","verboseOption","debugOption","curlirizeOption","action","host","realm","user","password","options","default","session","setTenant","setRealm","setUsername","setPassword","setDeploymentType","type","setAllowInsecureConnection","insecure","setVerbose","verbose","setDebug","debug","setCurlirize","curlirize","setDirectory","directory","clean","serviceId","file","all","allSeparate","help","parse"],"sources":["cli/service/service-import.ts"],"sourcesContent":["import { Authenticate, state } from '@rockcarver/frodo-lib';\nimport { Command, Option } from 'commander';\nimport {\n importFirstServiceFromFile,\n importServiceFromFile,\n importServicesFromFile,\n importServicesFromFiles,\n} from '../../ops/ServiceOps.js';\nimport { printMessage, verboseMessage } from '../../utils/Console.js';\nimport * as common from '../cmd_common.js';\n\nconst { getTokens } = Authenticate;\n\nconst program = new Command('frodo service import');\n\ninterface ServiceImportOptions {\n file?: string;\n all?: boolean;\n serviceId?: string;\n allSeparate?: boolean;\n type?: string;\n insecure?: boolean;\n clean?: boolean;\n directory?: string;\n verbose?: boolean;\n debug?: boolean;\n curlirize?: boolean;\n}\n\nprogram\n .description('Import AM services.')\n .helpOption('-h, --help', 'Help')\n .showHelpAfterError()\n .addArgument(common.hostArgumentM)\n .addArgument(common.realmArgument)\n .addArgument(common.userArgument)\n .addArgument(common.passwordArgument)\n .addOption(common.deploymentOption)\n .addOption(common.insecureOption)\n .addOption(common.verboseOption)\n .addOption(common.debugOption)\n .addOption(common.curlirizeOption)\n .addOption(\n new Option(\n '-i, --service-id <service-id>',\n 'Service id. If specified, -a and -A are ignored.'\n )\n )\n .addOption(\n new Option(\n '-f, --file <file>',\n 'Name of the file to import SAML Entity(s) from. Ignored with -A.'\n )\n )\n .addOption(new Option('-a, --all', 'Import all services from a single file.'))\n .addOption(\n new Option('-C, --clean', 'Remove existing service(s) before importing.')\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Import all services from separate files <id>.service.json.'\n )\n )\n .addOption(new Option('-D, --directory <directory>', 'Working directory.'))\n .action(\n async (\n host: string,\n realm: string,\n user: string,\n password: string,\n options: ServiceImportOptions\n ) => {\n state.default.session.setTenant(host);\n state.default.session.setRealm(realm);\n state.default.session.setUsername(user);\n state.default.session.setPassword(password);\n state.default.session.setDeploymentType(options.type);\n state.default.session.setAllowInsecureConnection(options.insecure);\n state.default.session.setVerbose(options.verbose);\n state.default.session.setDebug(options.debug);\n state.default.session.setCurlirize(options.curlirize);\n state.default.session.setDirectory(options.directory || '.');\n\n const clean = options.clean ?? false;\n\n // import by id\n if (options.serviceId && options.file && (await getTokens())) {\n verboseMessage('Importing service...');\n await importServiceFromFile(options.serviceId
|
|
1
|
+
{"version":3,"file":"service-import.js","names":["Authenticate","state","Command","Option","importFirstServiceFromFile","importServiceFromFile","importServicesFromFile","importServicesFromFiles","printMessage","verboseMessage","common","getTokens","program","description","helpOption","showHelpAfterError","addArgument","hostArgumentM","realmArgument","userArgument","passwordArgument","addOption","deploymentOption","insecureOption","verboseOption","debugOption","curlirizeOption","action","host","realm","user","password","options","default","session","setTenant","setRealm","setUsername","setPassword","setDeploymentType","type","setAllowInsecureConnection","insecure","setVerbose","verbose","setDebug","debug","setCurlirize","curlirize","setDirectory","directory","clean","globalConfig","global","serviceId","file","all","allSeparate","help","parse"],"sources":["cli/service/service-import.ts"],"sourcesContent":["import { Authenticate, state } from '@rockcarver/frodo-lib';\nimport { Command, Option } from 'commander';\nimport {\n importFirstServiceFromFile,\n importServiceFromFile,\n importServicesFromFile,\n importServicesFromFiles,\n} from '../../ops/ServiceOps.js';\nimport { printMessage, verboseMessage } from '../../utils/Console.js';\nimport * as common from '../cmd_common.js';\n\nconst { getTokens } = Authenticate;\n\nconst program = new Command('frodo service import');\n\ninterface ServiceImportOptions {\n file?: string;\n all?: boolean;\n serviceId?: string;\n allSeparate?: boolean;\n type?: string;\n insecure?: boolean;\n clean?: boolean;\n directory?: string;\n verbose?: boolean;\n debug?: boolean;\n curlirize?: boolean;\n global?: boolean;\n}\n\nprogram\n .description('Import AM services.')\n .helpOption('-h, --help', 'Help')\n .showHelpAfterError()\n .addArgument(common.hostArgumentM)\n .addArgument(common.realmArgument)\n .addArgument(common.userArgument)\n .addArgument(common.passwordArgument)\n .addOption(common.deploymentOption)\n .addOption(common.insecureOption)\n .addOption(common.verboseOption)\n .addOption(common.debugOption)\n .addOption(common.curlirizeOption)\n .addOption(\n new Option(\n '-i, --service-id <service-id>',\n 'Service id. If specified, -a and -A are ignored.'\n )\n )\n .addOption(\n new Option(\n '-f, --file <file>',\n 'Name of the file to import SAML Entity(s) from. Ignored with -A.'\n )\n )\n .addOption(new Option('-a, --all', 'Import all services from a single file.'))\n .addOption(\n new Option('-C, --clean', 'Remove existing service(s) before importing.')\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Import all services from separate files <id>.service.json.'\n )\n )\n .addOption(new Option('-D, --directory <directory>', 'Working directory.'))\n .addOption(new Option('-g, --global', 'List global services.'))\n .action(\n async (\n host: string,\n realm: string,\n user: string,\n password: string,\n options: ServiceImportOptions\n ) => {\n state.default.session.setTenant(host);\n state.default.session.setRealm(realm);\n state.default.session.setUsername(user);\n state.default.session.setPassword(password);\n state.default.session.setDeploymentType(options.type);\n state.default.session.setAllowInsecureConnection(options.insecure);\n state.default.session.setVerbose(options.verbose);\n state.default.session.setDebug(options.debug);\n state.default.session.setCurlirize(options.curlirize);\n state.default.session.setDirectory(options.directory || '.');\n\n const clean = options.clean ?? false;\n const globalConfig = options.global ?? false;\n\n // import by id\n if (options.serviceId && options.file && (await getTokens())) {\n verboseMessage('Importing service...');\n await importServiceFromFile(\n options.serviceId,\n options.file,\n clean,\n globalConfig\n );\n }\n // -a / --all\n else if (options.all && options.file && (await getTokens())) {\n verboseMessage('Importing all services from a single file...');\n await importServicesFromFile(options.file, clean, globalConfig);\n }\n // -A / --all-separate\n else if (options.allSeparate && (await getTokens())) {\n verboseMessage('Importing all services from separate files...');\n await importServicesFromFiles(clean, globalConfig);\n }\n // import file\n else if (options.file && (await getTokens())) {\n verboseMessage('Importing service...');\n await importFirstServiceFromFile(options.file, clean, globalConfig);\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 }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,EAAEC,KAAK,QAAQ,uBAAuB;AAC3D,SAASC,OAAO,EAAEC,MAAM,QAAQ,WAAW;AAC3C,SACEC,0BAA0B,EAC1BC,qBAAqB,EACrBC,sBAAsB,EACtBC,uBAAuB,QAClB,yBAAyB;AAChC,SAASC,YAAY,EAAEC,cAAc,QAAQ,wBAAwB;AACrE,OAAO,KAAKC,MAAM,MAAM,kBAAkB;AAE1C,MAAM;EAAEC;AAAU,CAAC,GAAGX,YAAY;AAElC,MAAMY,OAAO,GAAG,IAAIV,OAAO,CAAC,sBAAsB,CAAC;AAiBnDU,OAAO,CACJC,WAAW,CAAC,qBAAqB,CAAC,CAClCC,UAAU,CAAC,YAAY,EAAE,MAAM,CAAC,CAChCC,kBAAkB,EAAE,CACpBC,WAAW,CAACN,MAAM,CAACO,aAAa,CAAC,CACjCD,WAAW,CAACN,MAAM,CAACQ,aAAa,CAAC,CACjCF,WAAW,CAACN,MAAM,CAACS,YAAY,CAAC,CAChCH,WAAW,CAACN,MAAM,CAACU,gBAAgB,CAAC,CACpCC,SAAS,CAACX,MAAM,CAACY,gBAAgB,CAAC,CAClCD,SAAS,CAACX,MAAM,CAACa,cAAc,CAAC,CAChCF,SAAS,CAACX,MAAM,CAACc,aAAa,CAAC,CAC/BH,SAAS,CAACX,MAAM,CAACe,WAAW,CAAC,CAC7BJ,SAAS,CAACX,MAAM,CAACgB,eAAe,CAAC,CACjCL,SAAS,CACR,IAAIlB,MAAM,CACR,+BAA+B,EAC/B,kDAAkD,CACnD,CACF,CACAkB,SAAS,CACR,IAAIlB,MAAM,CACR,mBAAmB,EACnB,kEAAkE,CACnE,CACF,CACAkB,SAAS,CAAC,I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|
const program = new Command('frodo service list');
|
|
10
|
-
program.description('List AM services.').helpOption('-h, --help', 'Help').showHelpAfterError().addArgument(common.hostArgumentM).addArgument(common.realmArgument).addArgument(common.userArgument).addArgument(common.passwordArgument).addOption(common.deploymentOption).addOption(common.insecureOption).addOption(common.verboseOption).addOption(common.debugOption).addOption(common.curlirizeOption).addOption(new Option('-l, --long', 'Long with all fields.').default(false, 'false')).action(async (host, realm, user, password, options) => {
|
|
10
|
+
program.description('List AM services.').helpOption('-h, --help', 'Help').showHelpAfterError().addArgument(common.hostArgumentM).addArgument(common.realmArgument).addArgument(common.userArgument).addArgument(common.passwordArgument).addOption(common.deploymentOption).addOption(common.insecureOption).addOption(common.verboseOption).addOption(common.debugOption).addOption(common.curlirizeOption).addOption(new Option('-l, --long', 'Long with all fields.').default(false, 'false')).addOption(new Option('-g, --global', 'List global services.')).action(async (host, realm, user, password, options) => {
|
|
11
11
|
state.default.session.setTenant(host);
|
|
12
12
|
state.default.session.setRealm(realm);
|
|
13
13
|
state.default.session.setUsername(user);
|
|
@@ -19,7 +19,7 @@ program.description('List AM services.').helpOption('-h, --help', 'Help').showHe
|
|
|
19
19
|
state.default.session.setCurlirize(options.curlirize);
|
|
20
20
|
if (await getTokens()) {
|
|
21
21
|
verboseMessage(`Listing all AM services for realm: ${realm}`);
|
|
22
|
-
await listServices(options.long);
|
|
22
|
+
await listServices(options.long, options.global);
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
25
|
program.parse();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-list.js","names":["Authenticate","state","Command","Option","listServices","verboseMessage","common","getTokens","program","description","helpOption","showHelpAfterError","addArgument","hostArgumentM","realmArgument","userArgument","passwordArgument","addOption","deploymentOption","insecureOption","verboseOption","debugOption","curlirizeOption","default","action","host","realm","user","password","options","session","setTenant","setRealm","setUsername","setPassword","setDeploymentType","type","setAllowInsecureConnection","insecure","setVerbose","verbose","setDebug","debug","setCurlirize","curlirize","long","parse"],"sources":["cli/service/service-list.ts"],"sourcesContent":["import { Authenticate, state } from '@rockcarver/frodo-lib';\nimport { Command, Option } from 'commander';\nimport { listServices } from '../../ops/ServiceOps.js';\nimport { verboseMessage } from '../../utils/Console.js';\nimport * as common from '../cmd_common.js';\n\nconst { getTokens } = Authenticate;\n\nconst program = new Command('frodo service list');\n\nprogram\n .description('List AM services.')\n .helpOption('-h, --help', 'Help')\n .showHelpAfterError()\n .addArgument(common.hostArgumentM)\n .addArgument(common.realmArgument)\n .addArgument(common.userArgument)\n .addArgument(common.passwordArgument)\n .addOption(common.deploymentOption)\n .addOption(common.insecureOption)\n .addOption(common.verboseOption)\n .addOption(common.debugOption)\n .addOption(common.curlirizeOption)\n .addOption(\n new Option('-l, --long', 'Long with all fields.').default(false, 'false')\n )\n .action(async (host, realm, user, password, options) => {\n state.default.session.setTenant(host);\n state.default.session.setRealm(realm);\n state.default.session.setUsername(user);\n state.default.session.setPassword(password);\n state.default.session.setDeploymentType(options.type);\n state.default.session.setAllowInsecureConnection(options.insecure);\n state.default.session.setVerbose(options.verbose);\n state.default.session.setDebug(options.debug);\n state.default.session.setCurlirize(options.curlirize);\n if (await getTokens()) {\n verboseMessage(`Listing all AM services for realm: ${realm}`);\n await listServices(options.long);\n }\n });\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,EAAEC,KAAK,QAAQ,uBAAuB;AAC3D,SAASC,OAAO,EAAEC,MAAM,QAAQ,WAAW;AAC3C,SAASC,YAAY,QAAQ,yBAAyB;AACtD,SAASC,cAAc,QAAQ,wBAAwB;AACvD,OAAO,KAAKC,MAAM,MAAM,kBAAkB;AAE1C,MAAM;EAAEC;AAAU,CAAC,GAAGP,YAAY;AAElC,MAAMQ,OAAO,GAAG,IAAIN,OAAO,CAAC,oBAAoB,CAAC;AAEjDM,OAAO,CACJC,WAAW,CAAC,mBAAmB,CAAC,CAChCC,UAAU,CAAC,YAAY,EAAE,MAAM,CAAC,CAChCC,kBAAkB,EAAE,CACpBC,WAAW,CAACN,MAAM,CAACO,aAAa,CAAC,CACjCD,WAAW,CAACN,MAAM,CAACQ,aAAa,CAAC,CACjCF,WAAW,CAACN,MAAM,CAACS,YAAY,CAAC,CAChCH,WAAW,CAACN,MAAM,CAACU,gBAAgB,CAAC,CACpCC,SAAS,CAACX,MAAM,CAACY,gBAAgB,CAAC,CAClCD,SAAS,CAACX,MAAM,CAACa,cAAc,CAAC,CAChCF,SAAS,CAACX,MAAM,CAACc,aAAa,CAAC,CAC/BH,SAAS,CAACX,MAAM,CAACe,WAAW,CAAC,CAC7BJ,SAAS,CAACX,MAAM,CAACgB,eAAe,CAAC,CACjCL,SAAS,CACR,IAAId,MAAM,CAAC,YAAY,EAAE,uBAAuB,CAAC,CAACoB,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAC1E,
|
|
1
|
+
{"version":3,"file":"service-list.js","names":["Authenticate","state","Command","Option","listServices","verboseMessage","common","getTokens","program","description","helpOption","showHelpAfterError","addArgument","hostArgumentM","realmArgument","userArgument","passwordArgument","addOption","deploymentOption","insecureOption","verboseOption","debugOption","curlirizeOption","default","action","host","realm","user","password","options","session","setTenant","setRealm","setUsername","setPassword","setDeploymentType","type","setAllowInsecureConnection","insecure","setVerbose","verbose","setDebug","debug","setCurlirize","curlirize","long","global","parse"],"sources":["cli/service/service-list.ts"],"sourcesContent":["import { Authenticate, state } from '@rockcarver/frodo-lib';\nimport { Command, Option } from 'commander';\nimport { listServices } from '../../ops/ServiceOps.js';\nimport { verboseMessage } from '../../utils/Console.js';\nimport * as common from '../cmd_common.js';\n\nconst { getTokens } = Authenticate;\n\nconst program = new Command('frodo service list');\n\nprogram\n .description('List AM services.')\n .helpOption('-h, --help', 'Help')\n .showHelpAfterError()\n .addArgument(common.hostArgumentM)\n .addArgument(common.realmArgument)\n .addArgument(common.userArgument)\n .addArgument(common.passwordArgument)\n .addOption(common.deploymentOption)\n .addOption(common.insecureOption)\n .addOption(common.verboseOption)\n .addOption(common.debugOption)\n .addOption(common.curlirizeOption)\n .addOption(\n new Option('-l, --long', 'Long with all fields.').default(false, 'false')\n )\n .addOption(new Option('-g, --global', 'List global services.'))\n .action(async (host, realm, user, password, options) => {\n state.default.session.setTenant(host);\n state.default.session.setRealm(realm);\n state.default.session.setUsername(user);\n state.default.session.setPassword(password);\n state.default.session.setDeploymentType(options.type);\n state.default.session.setAllowInsecureConnection(options.insecure);\n state.default.session.setVerbose(options.verbose);\n state.default.session.setDebug(options.debug);\n state.default.session.setCurlirize(options.curlirize);\n if (await getTokens()) {\n verboseMessage(`Listing all AM services for realm: ${realm}`);\n await listServices(options.long, options.global);\n }\n });\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,EAAEC,KAAK,QAAQ,uBAAuB;AAC3D,SAASC,OAAO,EAAEC,MAAM,QAAQ,WAAW;AAC3C,SAASC,YAAY,QAAQ,yBAAyB;AACtD,SAASC,cAAc,QAAQ,wBAAwB;AACvD,OAAO,KAAKC,MAAM,MAAM,kBAAkB;AAE1C,MAAM;EAAEC;AAAU,CAAC,GAAGP,YAAY;AAElC,MAAMQ,OAAO,GAAG,IAAIN,OAAO,CAAC,oBAAoB,CAAC;AAEjDM,OAAO,CACJC,WAAW,CAAC,mBAAmB,CAAC,CAChCC,UAAU,CAAC,YAAY,EAAE,MAAM,CAAC,CAChCC,kBAAkB,EAAE,CACpBC,WAAW,CAACN,MAAM,CAACO,aAAa,CAAC,CACjCD,WAAW,CAACN,MAAM,CAACQ,aAAa,CAAC,CACjCF,WAAW,CAACN,MAAM,CAACS,YAAY,CAAC,CAChCH,WAAW,CAACN,MAAM,CAACU,gBAAgB,CAAC,CACpCC,SAAS,CAACX,MAAM,CAACY,gBAAgB,CAAC,CAClCD,SAAS,CAACX,MAAM,CAACa,cAAc,CAAC,CAChCF,SAAS,CAACX,MAAM,CAACc,aAAa,CAAC,CAC/BH,SAAS,CAACX,MAAM,CAACe,WAAW,CAAC,CAC7BJ,SAAS,CAACX,MAAM,CAACgB,eAAe,CAA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
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { Authenticate, state } from '@rockcarver/frodo-lib';
|
|
3
|
+
import { failSpinner, showSpinner, succeedSpinner } from '../utils/Console';
|
|
4
|
+
const {
|
|
5
|
+
getAccessTokenForServiceAccount
|
|
6
|
+
} = Authenticate;
|
|
7
|
+
export async function addExistingServiceAccount(serviceAccountId, privateKeyFile, validate) {
|
|
8
|
+
try {
|
|
9
|
+
const data = fs.readFileSync(privateKeyFile);
|
|
10
|
+
const jwk = JSON.parse(data.toString());
|
|
11
|
+
if (validate) {
|
|
12
|
+
showSpinner(`Validating service account ${serviceAccountId}...`);
|
|
13
|
+
const token = await getAccessTokenForServiceAccount(serviceAccountId, jwk);
|
|
14
|
+
if (token === null) {
|
|
15
|
+
failSpinner(`Failed to validate service account ${serviceAccountId}.`);
|
|
16
|
+
return false;
|
|
17
|
+
} else {
|
|
18
|
+
succeedSpinner(`Successfully validated service account ${serviceAccountId}.`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
state.default.session.setServiceAccountId(serviceAccountId);
|
|
22
|
+
state.default.session.setServiceAccountJwk(jwk);
|
|
23
|
+
return true;
|
|
24
|
+
} catch (err) {
|
|
25
|
+
failSpinner(`Failed to validate service account ${serviceAccountId}: ${err}.`);
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=ConnectionProfileOps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConnectionProfileOps.js","names":["fs","Authenticate","state","failSpinner","showSpinner","succeedSpinner","getAccessTokenForServiceAccount","addExistingServiceAccount","serviceAccountId","privateKeyFile","validate","data","readFileSync","jwk","JSON","parse","toString","token","default","session","setServiceAccountId","setServiceAccountJwk","err"],"sources":["ops/ConnectionProfileOps.ts"],"sourcesContent":["import fs from 'fs';\nimport { Authenticate, state } from '@rockcarver/frodo-lib';\nimport { failSpinner, showSpinner, succeedSpinner } from '../utils/Console';\n\nconst { getAccessTokenForServiceAccount } = Authenticate;\n\nexport async function addExistingServiceAccount(\n serviceAccountId: string,\n privateKeyFile: string,\n validate: boolean\n): Promise<boolean> {\n try {\n const data = fs.readFileSync(privateKeyFile);\n const jwk = JSON.parse(data.toString());\n if (validate) {\n showSpinner(`Validating service account ${serviceAccountId}...`);\n const token = await getAccessTokenForServiceAccount(\n serviceAccountId,\n jwk\n );\n if (token === null) {\n failSpinner(`Failed to validate service account ${serviceAccountId}.`);\n return false;\n } else {\n succeedSpinner(\n `Successfully validated service account ${serviceAccountId}.`\n );\n }\n }\n state.default.session.setServiceAccountId(serviceAccountId);\n state.default.session.setServiceAccountJwk(jwk);\n return true;\n } catch (err) {\n failSpinner(\n `Failed to validate service account ${serviceAccountId}: ${err}.`\n );\n return false;\n }\n return false;\n}\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AACnB,SAASC,YAAY,EAAEC,KAAK,QAAQ,uBAAuB;AAC3D,SAASC,WAAW,EAAEC,WAAW,EAAEC,cAAc,QAAQ,kBAAkB;AAE3E,MAAM;EAAEC;AAAgC,CAAC,GAAGL,YAAY;AAExD,OAAO,eAAeM,yBAAyB,CAC7CC,gBAAwB,EACxBC,cAAsB,EACtBC,QAAiB,EACC;EAClB,IAAI;IACF,MAAMC,IAAI,GAAGX,EAAE,CAACY,YAAY,CAACH,cAAc,CAAC;IAC5C,MAAMI,GAAG,GAAGC,IAAI,CAACC,KAAK,CAACJ,IAAI,CAACK,QAAQ,EAAE,CAAC;IACvC,IAAIN,QAAQ,EAAE;MACZN,WAAW,CAAE,8BAA6BI,gBAAiB,KAAI,CAAC;MAChE,MAAMS,KAAK,GAAG,MAAMX,+BAA+B,CACjDE,gBAAgB,EAChBK,GAAG,CACJ;MACD,IAAII,KAAK,KAAK,IAAI,EAAE;QAClBd,WAAW,CAAE,sCAAqCK,gBAAiB,GAAE,CAAC;QACtE,OAAO,KAAK;MACd,CAAC,MAAM;QACLH,cAAc,CACX,0CAAyCG,gBAAiB,GAAE,CAC9D;MACH;IACF;IACAN,KAAK,CAACgB,OAAO,CAACC,OAAO,CAACC,mBAAmB,CAACZ,gBAAgB,CAAC;IAC3DN,KAAK,CAACgB,OAAO,CAACC,OAAO,CAACE,oBAAoB,CAACR,GAAG,CAAC;IAC/C,OAAO,IAAI;EACb,CAAC,CAAC,OAAOS,GAAG,EAAE;IACZnB,WAAW,CACR,sCAAqCK,gBAAiB,KAAIc,GAAI,GAAE,CAClE;IACD,OAAO,KAAK;EACd;EACA,OAAO,KAAK;AACd"}
|
package/esm/ops/ServiceOps.js
CHANGED
|
@@ -25,9 +25,9 @@ const {
|
|
|
25
25
|
/**
|
|
26
26
|
* List services
|
|
27
27
|
*/
|
|
28
|
-
export async function listServices(long = false) {
|
|
28
|
+
export async function listServices(long = false, globalConfig = false) {
|
|
29
29
|
try {
|
|
30
|
-
const services = await getListOfServices();
|
|
30
|
+
const services = await getListOfServices(globalConfig);
|
|
31
31
|
services.sort((a, b) => a._id.localeCompare(b._id));
|
|
32
32
|
if (long) {
|
|
33
33
|
const table = createTable(['Service Id', 'Service Name']);
|
|
@@ -50,8 +50,8 @@ export async function listServices(long = false) {
|
|
|
50
50
|
* Export all services to file
|
|
51
51
|
* @param {string} file file name
|
|
52
52
|
*/
|
|
53
|
-
export async function exportServicesToFile(file) {
|
|
54
|
-
const exportData = await exportServices();
|
|
53
|
+
export async function exportServicesToFile(file, globalConfig = false) {
|
|
54
|
+
const exportData = await exportServices(globalConfig);
|
|
55
55
|
let fileName = getTypedFilename(`all${titleCase(getRealmName(state.default.session.getRealm()))}Services`, `service`);
|
|
56
56
|
if (file) {
|
|
57
57
|
fileName = file;
|
|
@@ -64,8 +64,8 @@ export async function exportServicesToFile(file) {
|
|
|
64
64
|
* @param {string} serviceId service id
|
|
65
65
|
* @param {string} file file name
|
|
66
66
|
*/
|
|
67
|
-
export async function exportServiceToFile(serviceId, file) {
|
|
68
|
-
const exportData = await exportService(serviceId);
|
|
67
|
+
export async function exportServiceToFile(serviceId, file, globalConfig = false) {
|
|
68
|
+
const exportData = await exportService(serviceId, globalConfig);
|
|
69
69
|
let fileName = getTypedFilename(serviceId, `service`);
|
|
70
70
|
if (file) {
|
|
71
71
|
fileName = file;
|
|
@@ -76,9 +76,9 @@ export async function exportServiceToFile(serviceId, file) {
|
|
|
76
76
|
/**
|
|
77
77
|
* Export all services to separate files
|
|
78
78
|
*/
|
|
79
|
-
export async function exportServicesToFiles() {
|
|
79
|
+
export async function exportServicesToFiles(globalConfig = false) {
|
|
80
80
|
debugMessage(`cli.ServiceOps.exportServicesToFiles: start`);
|
|
81
|
-
const services = await getFullServices();
|
|
81
|
+
const services = await getFullServices(globalConfig);
|
|
82
82
|
for (const service of services) {
|
|
83
83
|
const fileName = getTypedFilename(service._type._id, `service`);
|
|
84
84
|
const exportData = createServiceExportTemplate();
|
|
@@ -95,7 +95,7 @@ export async function exportServicesToFiles() {
|
|
|
95
95
|
* @param {string} file import file name
|
|
96
96
|
* @param {boolean} clean remove existing service
|
|
97
97
|
*/
|
|
98
|
-
export async function importServiceFromFile(serviceId, file, clean) {
|
|
98
|
+
export async function importServiceFromFile(serviceId, file, clean, globalConfig = false) {
|
|
99
99
|
debugMessage(`cli.ServiceOps.importServiceFromFile: start [serviceId=${serviceId}, file=${file}]`);
|
|
100
100
|
const verbose = state.default.session.getVerbose();
|
|
101
101
|
fs.readFile(file, 'utf8', async (err, data) => {
|
|
@@ -105,7 +105,7 @@ export async function importServiceFromFile(serviceId, file, clean) {
|
|
|
105
105
|
if (!verbose) showSpinner(`Importing ${serviceId}...`);
|
|
106
106
|
try {
|
|
107
107
|
if (verbose) showSpinner(`Importing ${serviceId}...`);
|
|
108
|
-
await importService(serviceId, importData, clean);
|
|
108
|
+
await importService(serviceId, importData, clean, globalConfig);
|
|
109
109
|
succeedSpinner(`Imported ${serviceId}.`);
|
|
110
110
|
} catch (importError) {
|
|
111
111
|
var _importError$response, _importError$response2, _importError$response3, _importError$response4;
|
|
@@ -127,7 +127,7 @@ export async function importServiceFromFile(serviceId, file, clean) {
|
|
|
127
127
|
* @param {string} file import file name
|
|
128
128
|
* @param {boolean} clean remove existing service
|
|
129
129
|
*/
|
|
130
|
-
export async function importFirstServiceFromFile(file, clean) {
|
|
130
|
+
export async function importFirstServiceFromFile(file, clean, globalConfig = false) {
|
|
131
131
|
debugMessage(`cli.ServiceOps.importFirstServiceFromFile: start [file=${file}]`);
|
|
132
132
|
const verbose = state.default.session.getVerbose();
|
|
133
133
|
fs.readFile(file, 'utf8', async (err, data) => {
|
|
@@ -138,7 +138,7 @@ export async function importFirstServiceFromFile(file, clean) {
|
|
|
138
138
|
if (!verbose) showSpinner(`Importing ${serviceId}...`);
|
|
139
139
|
try {
|
|
140
140
|
if (verbose) showSpinner(`Importing ${serviceId}...`);
|
|
141
|
-
await importService(serviceId, importData, clean);
|
|
141
|
+
await importService(serviceId, importData, clean, globalConfig);
|
|
142
142
|
succeedSpinner(`Imported ${serviceId}.`);
|
|
143
143
|
} catch (importError) {
|
|
144
144
|
var _importError$response5, _importError$response6, _importError$response7, _importError$response8;
|
|
@@ -160,14 +160,14 @@ export async function importFirstServiceFromFile(file, clean) {
|
|
|
160
160
|
* @param {String} file file name
|
|
161
161
|
* @param {boolean} clean remove existing service
|
|
162
162
|
*/
|
|
163
|
-
export async function importServicesFromFile(file, clean) {
|
|
163
|
+
export async function importServicesFromFile(file, clean, globalConfig = false) {
|
|
164
164
|
debugMessage(`cli.ServiceOps.importServiceFromFile: start [file=${file}]`);
|
|
165
165
|
fs.readFile(file, 'utf8', async (err, data) => {
|
|
166
166
|
if (err) throw err;
|
|
167
167
|
debugMessage(`cli.ServiceOps.importServiceFromFile: importing ${file}`);
|
|
168
168
|
const importData = JSON.parse(data);
|
|
169
169
|
try {
|
|
170
|
-
await importServices(importData, clean);
|
|
170
|
+
await importServices(importData, clean, globalConfig);
|
|
171
171
|
} catch (error) {
|
|
172
172
|
printMessage(`${error.message}`, 'error');
|
|
173
173
|
printMessage(error.response.status, 'error');
|
|
@@ -180,12 +180,12 @@ export async function importServicesFromFile(file, clean) {
|
|
|
180
180
|
* Import all services from separate files
|
|
181
181
|
* @param {boolean} clean remove existing service
|
|
182
182
|
*/
|
|
183
|
-
export async function importServicesFromFiles(clean) {
|
|
183
|
+
export async function importServicesFromFiles(clean, globalConfig = false) {
|
|
184
184
|
debugMessage(`cli.ServiceOps.importServicesFromFiles: start`);
|
|
185
185
|
const names = fs.readdirSync(getWorkingDirectory());
|
|
186
186
|
const agentFiles = names.filter(name => name.toLowerCase().endsWith('.service.json'));
|
|
187
187
|
for (const file of agentFiles) {
|
|
188
|
-
await importServicesFromFile(file, clean);
|
|
188
|
+
await importServicesFromFile(file, clean, globalConfig);
|
|
189
189
|
}
|
|
190
190
|
debugMessage(`cli.ServiceOps.importServicesFromFiles: end`);
|
|
191
191
|
}
|
|
@@ -194,9 +194,9 @@ export async function importServicesFromFiles(clean) {
|
|
|
194
194
|
* Delete a service by id/name
|
|
195
195
|
* @param {string} serviceId Reference to the service to delete
|
|
196
196
|
*/
|
|
197
|
-
export async function deleteService(serviceId) {
|
|
197
|
+
export async function deleteService(serviceId, globalConfig = false) {
|
|
198
198
|
try {
|
|
199
|
-
await deleteFullService(serviceId);
|
|
199
|
+
await deleteFullService(serviceId, globalConfig);
|
|
200
200
|
} catch (error) {
|
|
201
201
|
var _error$response, _error$response$data;
|
|
202
202
|
const message = (_error$response = error.response) === null || _error$response === void 0 ? void 0 : (_error$response$data = _error$response.data) === null || _error$response$data === void 0 ? void 0 : _error$response$data.message;
|
|
@@ -207,7 +207,7 @@ export async function deleteService(serviceId) {
|
|
|
207
207
|
/**
|
|
208
208
|
* Delete all services
|
|
209
209
|
*/
|
|
210
|
-
export async function deleteServices() {
|
|
211
|
-
await deleteFullServices();
|
|
210
|
+
export async function deleteServices(globalConfig = false) {
|
|
211
|
+
await deleteFullServices(globalConfig);
|
|
212
212
|
}
|
|
213
213
|
//# sourceMappingURL=ServiceOps.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceOps.js","names":["fs","printMessage","createTable","debugMessage","showSpinner","succeedSpinner","failSpinner","ExportImportUtils","Service","Utils","state","createServiceExportTemplate","deleteFullServices","deleteFullService","getListOfServices","getFullServices","exportServices","exportService","importServices","importService","getTypedFilename","getWorkingDirectory","saveJsonToFile","titleCase","getRealmName","listServices","long","services","sort","a","b","_id","localeCompare","table","service","push","name","toString","error","stack","exportServicesToFile","file","exportData","fileName","default","session","getRealm","exportServiceToFile","serviceId","exportServicesToFiles","_type","importServiceFromFile","clean","verbose","getVerbose","readFile","err","data","importData","JSON","parse","importError","message","response","detail","importFirstServiceFromFile","Object","keys","length","importServicesFromFile","status","importServicesFromFiles","names","readdirSync","agentFiles","filter","toLowerCase","endsWith","deleteService","deleteServices"],"sources":["ops/ServiceOps.ts"],"sourcesContent":["import fs from 'fs';\nimport {\n printMessage,\n createTable,\n debugMessage,\n showSpinner,\n succeedSpinner,\n failSpinner,\n} from '../utils/Console';\nimport {\n ExportImportUtils,\n Service,\n Utils,\n state,\n} from '@rockcarver/frodo-lib';\nimport { ServiceExportInterface } from '@rockcarver/frodo-lib/types/ops/OpsTypes';\n\nconst {\n createServiceExportTemplate,\n deleteFullServices,\n deleteFullService,\n getListOfServices,\n getFullServices,\n exportServices,\n exportService,\n importServices,\n importService,\n} = Service;\nconst { getTypedFilename, getWorkingDirectory, saveJsonToFile, titleCase } =\n ExportImportUtils;\nconst { getRealmName } = Utils;\n\n/**\n * List services\n */\nexport async function listServices(long = false) {\n try {\n const services = await getListOfServices();\n services.sort((a, b) => a._id.localeCompare(b._id));\n if (long) {\n const table = createTable(['Service Id', 'Service Name']);\n for (const service of services) {\n table.push([service._id, service.name]);\n }\n printMessage(table.toString(), 'data');\n } else {\n for (const service of services) {\n printMessage(`${service._id}`, 'data');\n }\n }\n } catch (error) {\n printMessage(`Error listing agents - ${error}`, 'error');\n printMessage(error.stack, 'error');\n }\n}\n\n/**\n * Export all services to file\n * @param {string} file file name\n */\nexport async function exportServicesToFile(file) {\n const exportData = await exportServices();\n let fileName = getTypedFilename(\n `all${titleCase(getRealmName(state.default.session.getRealm()))}Services`,\n `service`\n );\n if (file) {\n fileName = file;\n }\n saveJsonToFile(exportData, fileName);\n}\n\n/**\n * Export service to file\n * @param {string} serviceId service id\n * @param {string} file file name\n */\nexport async function exportServiceToFile(serviceId: string, file: string) {\n const exportData = await exportService(serviceId);\n let fileName = getTypedFilename(serviceId, `service`);\n if (file) {\n fileName = file;\n }\n saveJsonToFile(exportData, fileName);\n}\n\n/**\n * Export all services to separate files\n */\nexport async function exportServicesToFiles() {\n debugMessage(`cli.ServiceOps.exportServicesToFiles: start`);\n const services = await getFullServices();\n for (const service of services) {\n const fileName = getTypedFilename(service._type._id, `service`);\n const exportData = createServiceExportTemplate();\n exportData.service[service._type._id] = service;\n debugMessage(\n `cli.ServiceOps.exportServicesToFiles: exporting ${service._type._id} to ${fileName}`\n );\n saveJsonToFile(exportData, fileName);\n }\n debugMessage(`cli.ServiceOps.exportServicesToFiles: end.`);\n}\n\n/**\n * Import a service from file\n * @param {string} serviceId service id/name\n * @param {string} file import file name\n * @param {boolean} clean remove existing service\n */\nexport async function importServiceFromFile(\n serviceId: string,\n file: string,\n clean: boolean\n) {\n debugMessage(\n `cli.ServiceOps.importServiceFromFile: start [serviceId=${serviceId}, file=${file}]`\n );\n const verbose = state.default.session.getVerbose();\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const importData = JSON.parse(data);\n if (importData && importData.service[serviceId]) {\n if (!verbose) showSpinner(`Importing ${serviceId}...`);\n try {\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n await importService(serviceId, importData, clean);\n succeedSpinner(`Imported ${serviceId}.`);\n } catch (importError) {\n const message = importError.response?.data?.message;\n const detail = importError.response?.data?.detail;\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n failSpinner(`${detail ? message + ' - ' + detail : message}`);\n }\n } else {\n showSpinner(`Importing ${serviceId}...`);\n failSpinner(`${serviceId} not found!`);\n }\n });\n debugMessage(\n `cli.ServiceOps.importServiceFromFile: end [serviceId=${serviceId}, file=${file}]`\n );\n}\n\n/**\n * Import first service from file\n * @param {string} file import file name\n * @param {boolean} clean remove existing service\n */\nexport async function importFirstServiceFromFile(file: string, clean: boolean) {\n debugMessage(\n `cli.ServiceOps.importFirstServiceFromFile: start [file=${file}]`\n );\n const verbose = state.default.session.getVerbose();\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const importData = JSON.parse(data);\n if (importData && Object.keys(importData.service).length) {\n const serviceId = Object.keys(importData.service)[0];\n if (!verbose) showSpinner(`Importing ${serviceId}...`);\n try {\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n await importService(serviceId, importData, clean);\n succeedSpinner(`Imported ${serviceId}.`);\n } catch (importError) {\n const message = importError.response?.data?.message;\n const detail = importError.response?.data?.detail;\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n failSpinner(`${detail ? message + ' - ' + detail : message}`);\n }\n } else {\n showSpinner(`Importing service...`);\n failSpinner(`No service found in ${file}!`);\n }\n debugMessage(\n `cli.ServiceOps.importFirstServiceFromFile: end [file=${file}]`\n );\n });\n}\n\n/**\n * Import services from file\n * @param {String} file file name\n * @param {boolean} clean remove existing service\n */\nexport async function importServicesFromFile(file: string, clean: boolean) {\n debugMessage(`cli.ServiceOps.importServiceFromFile: start [file=${file}]`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n debugMessage(`cli.ServiceOps.importServiceFromFile: importing ${file}`);\n const importData = JSON.parse(data) as ServiceExportInterface;\n try {\n await importServices(importData, clean);\n } catch (error) {\n printMessage(`${error.message}`, 'error');\n printMessage(error.response.status, 'error');\n }\n debugMessage(`cli.ServiceOps.importServiceFromFile: end [file=${file}]`);\n });\n}\n\n/**\n * Import all services from separate files\n * @param {boolean} clean remove existing service\n */\nexport async function importServicesFromFiles(clean: boolean) {\n debugMessage(`cli.ServiceOps.importServicesFromFiles: start`);\n const names = fs.readdirSync(getWorkingDirectory());\n const agentFiles = names.filter((name) =>\n name.toLowerCase().endsWith('.service.json')\n );\n for (const file of agentFiles) {\n await importServicesFromFile(file, clean);\n }\n debugMessage(`cli.ServiceOps.importServicesFromFiles: end`);\n}\n\n/**\n * Delete a service by id/name\n * @param {string} serviceId Reference to the service to delete\n */\nexport async function deleteService(serviceId: string) {\n try {\n await deleteFullService(serviceId);\n } catch (error) {\n const message = error.response?.data?.message;\n printMessage(`Delete service '${serviceId}': ${message}`, 'error');\n }\n}\n\n/**\n * Delete all services\n */\nexport async function deleteServices() {\n await deleteFullServices();\n}\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AACnB,SACEC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,cAAc,EACdC,WAAW,QACN,kBAAkB;AACzB,SACEC,iBAAiB,EACjBC,OAAO,EACPC,KAAK,EACLC,KAAK,QACA,uBAAuB;AAG9B,MAAM;EACJC,2BAA2B;EAC3BC,kBAAkB;EAClBC,iBAAiB;EACjBC,iBAAiB;EACjBC,eAAe;EACfC,cAAc;EACdC,aAAa;EACbC,cAAc;EACdC;AACF,CAAC,GAAGX,OAAO;AACX,MAAM;EAAEY,gBAAgB;EAAEC,mBAAmB;EAAEC,cAAc;EAAEC;AAAU,CAAC,GACxEhB,iBAAiB;AACnB,MAAM;EAAEiB;AAAa,CAAC,GAAGf,KAAK;;AAE9B;AACA;AACA;AACA,OAAO,eAAegB,YAAY,CAACC,IAAI,GAAG,KAAK,EAAE;EAC/C,IAAI;IACF,MAAMC,QAAQ,GAAG,MAAMb,iBAAiB,EAAE;IAC1Ca,QAAQ,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACE,GAAG,CAACC,aAAa,CAACF,CAAC,CAACC,GAAG,CAAC,CAAC;IACnD,IAAIL,IAAI,EAAE;MACR,MAAMO,KAAK,GAAG/B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AC,EAAE,OAAO,CAAC;EACpE;AACF;;AAEA;AACA;AACA;AACA,OAAO,eAAeiB,cAAc,GAAG;EACrC,MAAMnE,kBAAkB,EAAE;AAC5B"}
|
|
1
|
+
{"version":3,"file":"ServiceOps.js","names":["fs","printMessage","createTable","debugMessage","showSpinner","succeedSpinner","failSpinner","ExportImportUtils","Service","Utils","state","createServiceExportTemplate","deleteFullServices","deleteFullService","getListOfServices","getFullServices","exportServices","exportService","importServices","importService","getTypedFilename","getWorkingDirectory","saveJsonToFile","titleCase","getRealmName","listServices","long","globalConfig","services","sort","a","b","_id","localeCompare","table","service","push","name","toString","error","stack","exportServicesToFile","file","exportData","fileName","default","session","getRealm","exportServiceToFile","serviceId","exportServicesToFiles","_type","importServiceFromFile","clean","verbose","getVerbose","readFile","err","data","importData","JSON","parse","importError","message","response","detail","importFirstServiceFromFile","Object","keys","length","importServicesFromFile","status","importServicesFromFiles","names","readdirSync","agentFiles","filter","toLowerCase","endsWith","deleteService","deleteServices"],"sources":["ops/ServiceOps.ts"],"sourcesContent":["import fs from 'fs';\nimport {\n printMessage,\n createTable,\n debugMessage,\n showSpinner,\n succeedSpinner,\n failSpinner,\n} from '../utils/Console';\nimport {\n ExportImportUtils,\n Service,\n Utils,\n state,\n} from '@rockcarver/frodo-lib';\nimport { ServiceExportInterface } from '@rockcarver/frodo-lib/types/ops/OpsTypes';\n\nconst {\n createServiceExportTemplate,\n deleteFullServices,\n deleteFullService,\n getListOfServices,\n getFullServices,\n exportServices,\n exportService,\n importServices,\n importService,\n} = Service;\nconst { getTypedFilename, getWorkingDirectory, saveJsonToFile, titleCase } =\n ExportImportUtils;\nconst { getRealmName } = Utils;\n\n/**\n * List services\n */\nexport async function listServices(long = false, globalConfig = false) {\n try {\n const services = await getListOfServices(globalConfig);\n services.sort((a, b) => a._id.localeCompare(b._id));\n if (long) {\n const table = createTable(['Service Id', 'Service Name']);\n for (const service of services) {\n table.push([service._id, service.name]);\n }\n printMessage(table.toString(), 'data');\n } else {\n for (const service of services) {\n printMessage(`${service._id}`, 'data');\n }\n }\n } catch (error) {\n printMessage(`Error listing agents - ${error}`, 'error');\n printMessage(error.stack, 'error');\n }\n}\n\n/**\n * Export all services to file\n * @param {string} file file name\n */\nexport async function exportServicesToFile(file, globalConfig = false) {\n const exportData = await exportServices(globalConfig);\n let fileName = getTypedFilename(\n `all${titleCase(getRealmName(state.default.session.getRealm()))}Services`,\n `service`\n );\n if (file) {\n fileName = file;\n }\n saveJsonToFile(exportData, fileName);\n}\n\n/**\n * Export service to file\n * @param {string} serviceId service id\n * @param {string} file file name\n */\nexport async function exportServiceToFile(\n serviceId: string,\n file: string,\n globalConfig = false\n) {\n const exportData = await exportService(serviceId, globalConfig);\n let fileName = getTypedFilename(serviceId, `service`);\n if (file) {\n fileName = file;\n }\n saveJsonToFile(exportData, fileName);\n}\n\n/**\n * Export all services to separate files\n */\nexport async function exportServicesToFiles(globalConfig = false) {\n debugMessage(`cli.ServiceOps.exportServicesToFiles: start`);\n const services = await getFullServices(globalConfig);\n for (const service of services) {\n const fileName = getTypedFilename(service._type._id, `service`);\n const exportData = createServiceExportTemplate();\n exportData.service[service._type._id] = service;\n debugMessage(\n `cli.ServiceOps.exportServicesToFiles: exporting ${service._type._id} to ${fileName}`\n );\n saveJsonToFile(exportData, fileName);\n }\n debugMessage(`cli.ServiceOps.exportServicesToFiles: end.`);\n}\n\n/**\n * Import a service from file\n * @param {string} serviceId service id/name\n * @param {string} file import file name\n * @param {boolean} clean remove existing service\n */\nexport async function importServiceFromFile(\n serviceId: string,\n file: string,\n clean: boolean,\n globalConfig = false\n) {\n debugMessage(\n `cli.ServiceOps.importServiceFromFile: start [serviceId=${serviceId}, file=${file}]`\n );\n const verbose = state.default.session.getVerbose();\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const importData = JSON.parse(data);\n if (importData && importData.service[serviceId]) {\n if (!verbose) showSpinner(`Importing ${serviceId}...`);\n try {\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n await importService(serviceId, importData, clean, globalConfig);\n succeedSpinner(`Imported ${serviceId}.`);\n } catch (importError) {\n const message = importError.response?.data?.message;\n const detail = importError.response?.data?.detail;\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n failSpinner(`${detail ? message + ' - ' + detail : message}`);\n }\n } else {\n showSpinner(`Importing ${serviceId}...`);\n failSpinner(`${serviceId} not found!`);\n }\n });\n debugMessage(\n `cli.ServiceOps.importServiceFromFile: end [serviceId=${serviceId}, file=${file}]`\n );\n}\n\n/**\n * Import first service from file\n * @param {string} file import file name\n * @param {boolean} clean remove existing service\n */\nexport async function importFirstServiceFromFile(\n file: string,\n clean: boolean,\n globalConfig = false\n) {\n debugMessage(\n `cli.ServiceOps.importFirstServiceFromFile: start [file=${file}]`\n );\n const verbose = state.default.session.getVerbose();\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const importData = JSON.parse(data);\n if (importData && Object.keys(importData.service).length) {\n const serviceId = Object.keys(importData.service)[0];\n if (!verbose) showSpinner(`Importing ${serviceId}...`);\n try {\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n await importService(serviceId, importData, clean, globalConfig);\n succeedSpinner(`Imported ${serviceId}.`);\n } catch (importError) {\n const message = importError.response?.data?.message;\n const detail = importError.response?.data?.detail;\n if (verbose) showSpinner(`Importing ${serviceId}...`);\n failSpinner(`${detail ? message + ' - ' + detail : message}`);\n }\n } else {\n showSpinner(`Importing service...`);\n failSpinner(`No service found in ${file}!`);\n }\n debugMessage(\n `cli.ServiceOps.importFirstServiceFromFile: end [file=${file}]`\n );\n });\n}\n\n/**\n * Import services from file\n * @param {String} file file name\n * @param {boolean} clean remove existing service\n */\nexport async function importServicesFromFile(\n file: string,\n clean: boolean,\n globalConfig = false\n) {\n debugMessage(`cli.ServiceOps.importServiceFromFile: start [file=${file}]`);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n debugMessage(`cli.ServiceOps.importServiceFromFile: importing ${file}`);\n const importData = JSON.parse(data) as ServiceExportInterface;\n try {\n await importServices(importData, clean, globalConfig);\n } catch (error) {\n printMessage(`${error.message}`, 'error');\n printMessage(error.response.status, 'error');\n }\n debugMessage(`cli.ServiceOps.importServiceFromFile: end [file=${file}]`);\n });\n}\n\n/**\n * Import all services from separate files\n * @param {boolean} clean remove existing service\n */\nexport async function importServicesFromFiles(\n clean: boolean,\n globalConfig = false\n) {\n debugMessage(`cli.ServiceOps.importServicesFromFiles: start`);\n const names = fs.readdirSync(getWorkingDirectory());\n const agentFiles = names.filter((name) =>\n name.toLowerCase().endsWith('.service.json')\n );\n for (const file of agentFiles) {\n await importServicesFromFile(file, clean, globalConfig);\n }\n debugMessage(`cli.ServiceOps.importServicesFromFiles: end`);\n}\n\n/**\n * Delete a service by id/name\n * @param {string} serviceId Reference to the service to delete\n */\nexport async function deleteService(serviceId: string, globalConfig = false) {\n try {\n await deleteFullService(serviceId, globalConfig);\n } catch (error) {\n const message = error.response?.data?.message;\n printMessage(`Delete service '${serviceId}': ${message}`, 'error');\n }\n}\n\n/**\n * Delete all services\n */\nexport async function deleteServices(globalConfig = false) {\n await deleteFullServices(globalConfig);\n}\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AACnB,SACEC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,cAAc,EACdC,WAAW,QACN,kBAAkB;AACzB,SACEC,iBAAiB,EACjBC,OAAO,EACPC,KAAK,EACLC,KAAK,QACA,uBAAuB;AAG9B,MAAM;EACJC,2BAA2B;EAC3BC,kBAAkB;EAClBC,iBAAiB;EACjBC,iBAAiB;EACjBC,eAAe;EACfC,cAAc;EACdC,aAAa;EACbC,cAAc;EACdC;AACF,CAAC,GAAGX,OAAO;AACX,MAAM;EAAEY,gBAAgB;EAAEC,mBAAmB;EAAEC,cAAc;EAAEC;AAAU,CAAC,GACxEhB,iBAAiB;AACnB,MAAM;EAAEiB;AAAa,CAAC,GAAGf,KAAK;;AAE9B;AACA;AACA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,UAAU,GAAGF,KAAK,CAACG,MAAM,CAAEvC,IAAI,IACnCA,IAAI,CAACwC,WAAW,EAAE,CAACC,QAAQ,CAAC,eAAe,CAAC,CAC7C;EACD,KAAK,MAAMpC,IAAI,IAAIiC,UAAU,EAAE;IAC7B,MAAML,sBAAsB,CAAC5B,IAAI,EAAEW,KAAK,EAAE1B,YAAY,CAAC;EACzD;EACAxB,YAAY,CAAE,6CAA4C,CAAC;AAC7D;;AAEA;AACA;AACA;AACA;AACA,OAAO,eAAe4E,aAAa,CAAC9B,SAAiB,EAAEtB,YAAY,GAAG,KAAK,EAAE;EAC3E,IAAI;IACF,MAAMd,iBAAiB,CAACoC,SAAS,EAAEtB,YAAY,CAAC;EAClD,CAAC,CAAC,OAAOY,KAAK,EAAE;IAAA;IACd,MAAMwB,OAAO,sBAAGxB,KAAK,CAACyB,QAAQ,4EAAd,gBAAgBN,IAAI,yDAApB,qBAAsBK,OAAO;IAC7C9D,YAAY,CAAE,mBAAkBgD,SAAU,MAAKc,OAAQ,EAAC,EAAE,OAAO,CAAC;EACpE;AACF;;AAEA;AACA;AACA;AACA,OAAO,eAAeiB,cAAc,CAACrD,YAAY,GAAG,KAAK,EAAE;EACzD,MAAMf,kBAAkB,CAACe,YAAY,CAAC;AACxC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rockcarver/frodo-cli",
|
|
3
|
-
"version": "0.18.2-
|
|
3
|
+
"version": "0.18.2-14",
|
|
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": [
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
]
|
|
89
89
|
},
|
|
90
90
|
"dependencies": {
|
|
91
|
-
"@rockcarver/frodo-lib": "0.16.2-
|
|
91
|
+
"@rockcarver/frodo-lib": "0.16.2-15",
|
|
92
92
|
"cli-progress": "^3.11.2",
|
|
93
93
|
"cli-table3": "^0.6.3",
|
|
94
94
|
"colors": "^1.4.0",
|
package/esm/cli/conn/conn-add.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Command, Option } from 'commander';
|
|
2
|
-
import { Authenticate, ConnectionProfile, state } from '@rockcarver/frodo-lib';
|
|
3
|
-
import * as common from '../cmd_common.js';
|
|
4
|
-
const {
|
|
5
|
-
getTokens
|
|
6
|
-
} = Authenticate;
|
|
7
|
-
const {
|
|
8
|
-
saveConnectionProfile
|
|
9
|
-
} = ConnectionProfile;
|
|
10
|
-
const program = new Command('frodo conn add');
|
|
11
|
-
program.description('Add a new connection profiles. You have to specify a URL, username and password at a minimum.\nOptionally, for Identity Cloud, you can also add a log API key and secret.').helpOption('-h, --help', 'Help').showHelpAfterError().addArgument(common.hostArgumentM).addArgument(common.userArgument).addArgument(common.passwordArgument).addArgument(common.apiKeyArgument).addArgument(common.apiSecretArgument).addOption(common.deploymentOption).addOption(common.insecureOption).addOption(common.verboseOption).addOption(common.debugOption).addOption(common.curlirizeOption).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"}.')).action(
|
|
12
|
-
// implement command logic inside action handler
|
|
13
|
-
async (host, user, password, key, secret, options) => {
|
|
14
|
-
state.default.session.setTenant(host);
|
|
15
|
-
state.default.session.setUsername(user);
|
|
16
|
-
state.default.session.setPassword(password);
|
|
17
|
-
state.default.session.setLogApiKey(key);
|
|
18
|
-
state.default.session.setLogApiSecret(secret);
|
|
19
|
-
state.default.session.setDeploymentType(options.type);
|
|
20
|
-
state.default.session.setAllowInsecureConnection(options.insecure);
|
|
21
|
-
state.default.session.setVerbose(options.verbose);
|
|
22
|
-
state.default.session.setDebug(options.debug);
|
|
23
|
-
state.default.session.setCurlirize(options.curlirize);
|
|
24
|
-
if (options.authenticationService) {
|
|
25
|
-
state.default.session.setAuthenticationService(options.authenticationService);
|
|
26
|
-
}
|
|
27
|
-
if (options.authenticationHeaderOverrides) {
|
|
28
|
-
state.default.session.setAuthenticationHeaderOverrides(JSON.parse(options.authenticationHeaderOverrides));
|
|
29
|
-
}
|
|
30
|
-
if (options.validate && (await getTokens()) || !options.validate) {
|
|
31
|
-
saveConnectionProfile();
|
|
32
|
-
} else {
|
|
33
|
-
process.exitCode = 1;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
// end command logic inside action handler
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
program.parse();
|
|
40
|
-
//# sourceMappingURL=conn-add.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conn-add.js","names":["Command","Option","Authenticate","ConnectionProfile","state","common","getTokens","saveConnectionProfile","program","description","helpOption","showHelpAfterError","addArgument","hostArgumentM","userArgument","passwordArgument","apiKeyArgument","apiSecretArgument","addOption","deploymentOption","insecureOption","verboseOption","debugOption","curlirizeOption","action","host","user","password","key","secret","options","default","session","setTenant","setUsername","setPassword","setLogApiKey","setLogApiSecret","setDeploymentType","type","setAllowInsecureConnection","insecure","setVerbose","verbose","setDebug","debug","setCurlirize","curlirize","authenticationService","setAuthenticationService","authenticationHeaderOverrides","setAuthenticationHeaderOverrides","JSON","parse","validate","process","exitCode"],"sources":["cli/conn/conn-add.ts"],"sourcesContent":["import { Command, Option } from 'commander';\nimport { Authenticate, ConnectionProfile, state } from '@rockcarver/frodo-lib';\nimport * as common from '../cmd_common.js';\n\nconst { getTokens } = Authenticate;\nconst { saveConnectionProfile } = ConnectionProfile;\n\nconst program = new Command('frodo conn add');\n\nprogram\n .description(\n 'Add a new connection profiles. You have to specify a URL, username and password at a minimum.\\nOptionally, for Identity Cloud, you can also add a log API key and secret.'\n )\n .helpOption('-h, --help', 'Help')\n .showHelpAfterError()\n .addArgument(common.hostArgumentM)\n .addArgument(common.userArgument)\n .addArgument(common.passwordArgument)\n .addArgument(common.apiKeyArgument)\n .addArgument(common.apiSecretArgument)\n .addOption(common.deploymentOption)\n .addOption(common.insecureOption)\n .addOption(common.verboseOption)\n .addOption(common.debugOption)\n .addOption(common.curlirizeOption)\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, key, secret, options) => {\n state.default.session.setTenant(host);\n state.default.session.setUsername(user);\n state.default.session.setPassword(password);\n state.default.session.setLogApiKey(key);\n state.default.session.setLogApiSecret(secret);\n state.default.session.setDeploymentType(options.type);\n state.default.session.setAllowInsecureConnection(options.insecure);\n state.default.session.setVerbose(options.verbose);\n state.default.session.setDebug(options.debug);\n state.default.session.setCurlirize(options.curlirize);\n if (options.authenticationService) {\n state.default.session.setAuthenticationService(\n options.authenticationService\n );\n }\n if (options.authenticationHeaderOverrides) {\n state.default.session.setAuthenticationHeaderOverrides(\n JSON.parse(options.authenticationHeaderOverrides)\n );\n }\n if ((options.validate && (await getTokens())) || !options.validate) {\n saveConnectionProfile();\n } else {\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,OAAO,EAAEC,MAAM,QAAQ,WAAW;AAC3C,SAASC,YAAY,EAAEC,iBAAiB,EAAEC,KAAK,QAAQ,uBAAuB;AAC9E,OAAO,KAAKC,MAAM,MAAM,kBAAkB;AAE1C,MAAM;EAAEC;AAAU,CAAC,GAAGJ,YAAY;AAClC,MAAM;EAAEK;AAAsB,CAAC,GAAGJ,iBAAiB;AAEnD,MAAMK,OAAO,GAAG,IAAIR,OAAO,CAAC,gBAAgB,CAAC;AAE7CQ,OAAO,CACJC,WAAW,CACV,2KAA2K,CAC5K,CACAC,UAAU,CAAC,YAAY,EAAE,MAAM,CAAC,C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