@rockcarver/frodo-cli 2.0.0-4 → 2.0.0-6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -1
- package/esm/app.js +2 -2
- package/esm/app.js.map +1 -1
- package/esm/cli/admin/admin-federation-export.js +42 -0
- package/esm/cli/admin/admin-federation-export.js.map +1 -0
- package/esm/cli/admin/admin-federation-import.js +46 -0
- package/esm/cli/admin/admin-federation-import.js.map +1 -0
- package/esm/cli/admin/admin-federation-list.js +26 -0
- package/esm/cli/admin/admin-federation-list.js.map +1 -0
- package/esm/cli/admin/admin-federation.js +13 -0
- package/esm/cli/admin/admin-federation.js.map +1 -0
- package/esm/cli/admin/admin.js +1 -0
- package/esm/cli/admin/admin.js.map +1 -1
- package/esm/cli/conn/conn-save.js +6 -3
- package/esm/cli/conn/conn-save.js.map +1 -1
- package/esm/cli/info/info.js +2 -3
- package/esm/cli/info/info.js.map +1 -1
- package/esm/cli/{logging/logs-fetch.js → log/log-fetch.js} +3 -3
- package/esm/cli/log/log-fetch.js.map +1 -0
- package/esm/cli/log/log-key-delete.js +32 -0
- package/esm/cli/log/log-key-delete.js.map +1 -0
- package/esm/cli/log/log-key-describe.js +19 -0
- package/esm/cli/log/log-key-describe.js.map +1 -0
- package/esm/cli/log/log-key-list.js +23 -0
- package/esm/cli/log/log-key-list.js.map +1 -0
- package/esm/cli/log/log-key.js +8 -0
- package/esm/cli/log/log-key.js.map +1 -0
- package/esm/cli/{logging/logs-list.js → log/log-list.js} +2 -2
- package/esm/cli/log/log-list.js.map +1 -0
- package/esm/cli/{logging/logs-tail.js → log/log-tail.js} +3 -3
- package/esm/cli/log/log-tail.js.map +1 -0
- package/esm/cli/{logging/logs.js → log/log.js} +5 -2
- package/esm/cli/log/log.js.map +1 -0
- package/esm/help/SampleData.js +7 -0
- package/esm/help/SampleData.js.map +1 -0
- package/esm/ops/AdminFederationOps.js +208 -0
- package/esm/ops/AdminFederationOps.js.map +1 -0
- package/esm/ops/IdpOps.js +22 -10
- package/esm/ops/IdpOps.js.map +1 -1
- package/esm/ops/LogOps.js +77 -25
- package/esm/ops/LogOps.js.map +1 -1
- package/esm/ops/OAuth2ClientOps.js +1 -1
- package/esm/ops/OAuth2ClientOps.js.map +1 -1
- package/esm/ops/RealmOps.js +6 -4
- package/esm/ops/RealmOps.js.map +1 -1
- package/package.json +2 -2
- package/esm/cli/logging/logs-fetch.js.map +0 -1
- package/esm/cli/logging/logs-list.js.map +0 -1
- package/esm/cli/logging/logs-tail.js.map +0 -1
- package/esm/cli/logging/logs.js.map +0 -1
package/esm/ops/LogOps.js
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
import { frodo, state } from '@rockcarver/frodo-lib';
|
|
2
|
-
import { printMessage, verboseMessage } from '../utils/Console';
|
|
3
|
-
export async function
|
|
2
|
+
import { createTable, debugMessage, failSpinner, printMessage, showSpinner, succeedSpinner, verboseMessage } from '../utils/Console';
|
|
3
|
+
export async function listLogApiKeys(long = false) {
|
|
4
|
+
let outcome = false;
|
|
4
5
|
try {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
const keys = await frodo.cloud.log.getLogApiKeys();
|
|
7
|
+
if (long) {
|
|
8
|
+
const table = createTable(['Key Id', 'Name', 'Created at']);
|
|
9
|
+
for (const key of keys) {
|
|
10
|
+
table.push([key.api_key_id, key.name, key.created_at]);
|
|
11
|
+
}
|
|
12
|
+
printMessage(table.toString(), 'data');
|
|
13
|
+
} else {
|
|
14
|
+
for (const key of keys) {
|
|
15
|
+
printMessage(`${key.api_key_id}`, 'data');
|
|
16
|
+
}
|
|
13
17
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
});
|
|
17
|
-
setTimeout(() => {
|
|
18
|
-
tailLogs(source, levels, txid, logsObject.pagedResultsCookie, nf);
|
|
19
|
-
}, 5000);
|
|
20
|
-
return null;
|
|
21
|
-
} catch (e) {
|
|
22
|
-
printMessage(`tail ERROR: tail data error - ${e}`, 'error');
|
|
23
|
-
return `tail ERROR: tail data error - ${e}`;
|
|
18
|
+
outcome = true;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
printMessage(`Error listing log API keys: ${error}`, 'error');
|
|
24
21
|
}
|
|
22
|
+
return outcome;
|
|
25
23
|
}
|
|
26
24
|
export async function provisionCreds() {
|
|
27
25
|
try {
|
|
@@ -35,11 +33,14 @@ export async function provisionCreds() {
|
|
|
35
33
|
}
|
|
36
34
|
}
|
|
37
35
|
try {
|
|
38
|
-
const resp = await frodo.cloud.log.
|
|
39
|
-
if (resp.name !== keyName) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
const resp = await frodo.cloud.log.createLogApiKey(keyName);
|
|
37
|
+
// if (resp.name !== keyName) {
|
|
38
|
+
// printMessage(
|
|
39
|
+
// `create keys ERROR: could not create log API key ${keyName} [new key name: ${resp.name}]`,
|
|
40
|
+
// 'error'
|
|
41
|
+
// );
|
|
42
|
+
// return null;
|
|
43
|
+
// }
|
|
43
44
|
verboseMessage(`Created a new log API key [${keyName}] in ${state.getHost()}`);
|
|
44
45
|
return resp;
|
|
45
46
|
} catch (error) {
|
|
@@ -54,6 +55,57 @@ export async function provisionCreds() {
|
|
|
54
55
|
return null;
|
|
55
56
|
}
|
|
56
57
|
}
|
|
58
|
+
export async function deleteLogApiKey(keyId) {
|
|
59
|
+
let outcome = false;
|
|
60
|
+
debugMessage(`cli.LogOps.deleteKey: start`);
|
|
61
|
+
showSpinner(`Deleting ${keyId}...`);
|
|
62
|
+
try {
|
|
63
|
+
await frodo.cloud.log.deleteLogApiKey(keyId);
|
|
64
|
+
succeedSpinner(`Deleted ${keyId}.`);
|
|
65
|
+
outcome = true;
|
|
66
|
+
} catch (error) {
|
|
67
|
+
failSpinner(`Error deleting ${keyId}: ${error.message}`);
|
|
68
|
+
}
|
|
69
|
+
debugMessage(`cli.LogOps.deleteKey: end [${outcome}]`);
|
|
70
|
+
return outcome;
|
|
71
|
+
}
|
|
72
|
+
export async function deleteLogApiKeys() {
|
|
73
|
+
let outcome = false;
|
|
74
|
+
debugMessage(`cli.LogOps.deleteKeys: start`);
|
|
75
|
+
showSpinner(`Deleting all keys...`);
|
|
76
|
+
try {
|
|
77
|
+
const response = await frodo.cloud.log.deleteLogApiKeys();
|
|
78
|
+
succeedSpinner(`Deleted ${response.length} keys.`);
|
|
79
|
+
outcome = true;
|
|
80
|
+
} catch (error) {
|
|
81
|
+
failSpinner(`Error deleting keys: ${error.message}`);
|
|
82
|
+
}
|
|
83
|
+
debugMessage(`cli.LogOps.deleteKeys: end [${outcome}]`);
|
|
84
|
+
return outcome;
|
|
85
|
+
}
|
|
86
|
+
export async function tailLogs(source, levels, txid, cookie, nf) {
|
|
87
|
+
try {
|
|
88
|
+
const logsObject = await frodo.cloud.log.tail(source, cookie);
|
|
89
|
+
let filteredLogs = [];
|
|
90
|
+
const noiseFilter = nf == null ? frodo.cloud.log.getDefaultNoiseFilter() : nf;
|
|
91
|
+
if (Array.isArray(logsObject.result)) {
|
|
92
|
+
filteredLogs = logsObject.result.filter(el => {
|
|
93
|
+
var _transactionId;
|
|
94
|
+
return !noiseFilter.includes(el.payload.logger) && !noiseFilter.includes(el.type) && (levels[0] === 'ALL' || levels.includes(frodo.cloud.log.resolvePayloadLevel(el))) && (typeof txid === 'undefined' || txid === null || ((_transactionId = el.payload.transactionId) === null || _transactionId === void 0 ? void 0 : _transactionId.includes(txid)));
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
filteredLogs.forEach(e => {
|
|
98
|
+
printMessage(JSON.stringify(e), 'data');
|
|
99
|
+
});
|
|
100
|
+
setTimeout(() => {
|
|
101
|
+
tailLogs(source, levels, txid, logsObject.pagedResultsCookie, nf);
|
|
102
|
+
}, 5000);
|
|
103
|
+
return null;
|
|
104
|
+
} catch (e) {
|
|
105
|
+
printMessage(`tail ERROR: tail data error - ${e}`, 'error');
|
|
106
|
+
return `tail ERROR: tail data error - ${e}`;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
57
109
|
export async function fetchLogs(source, startTs, endTs, levels, txid, ffString, cookie, nf) {
|
|
58
110
|
try {
|
|
59
111
|
const logsObject = await frodo.cloud.log.fetch(source, startTs, endTs, cookie);
|
package/esm/ops/LogOps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogOps.js","names":["frodo","state","printMessage","verboseMessage","tailLogs","source","levels","txid","cookie","nf","logsObject","cloud","log","tail","filteredLogs","noiseFilter","getDefaultNoiseFilter","Array","isArray","result","filter","el","_transactionId","includes","payload","logger","type","resolvePayloadLevel","transactionId","forEach","e","JSON","stringify","setTimeout","pagedResultsCookie","provisionCreds","keyName","getUsername","keys","getLogApiKeys","key","name","Date","toISOString","resp","createLogApiKeyAndSecret","getHost","error","fetchLogs","startTs","endTs","ffString","fetch","_transactionId2"],"sources":["ops/LogOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport type { LogEventPayloadSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport { printMessage, verboseMessage } from '../utils/Console';\n\nexport async function tailLogs(\n source: string,\n levels: string[],\n txid: string,\n cookie: string,\n nf: string[]\n) {\n try {\n const logsObject = await frodo.cloud.log.tail(source, cookie);\n let filteredLogs = [];\n const noiseFilter =\n nf == null ? frodo.cloud.log.getDefaultNoiseFilter() : nf;\n if (Array.isArray(logsObject.result)) {\n filteredLogs = logsObject.result.filter(\n (el) =>\n !noiseFilter.includes(\n (el.payload as LogEventPayloadSkeleton).logger\n ) &&\n !noiseFilter.includes(el.type) &&\n (levels[0] === 'ALL' ||\n levels.includes(frodo.cloud.log.resolvePayloadLevel(el))) &&\n (typeof txid === 'undefined' ||\n txid === null ||\n (el.payload as LogEventPayloadSkeleton).transactionId?.includes(\n txid\n ))\n );\n }\n\n filteredLogs.forEach((e) => {\n printMessage(JSON.stringify(e), 'data');\n });\n\n setTimeout(() => {\n tailLogs(source, levels, txid, logsObject.pagedResultsCookie, nf);\n }, 5000);\n return null;\n } catch (e) {\n printMessage(`tail ERROR: tail data error - ${e}`, 'error');\n return `tail ERROR: tail data error - ${e}`;\n }\n}\n\nexport async function provisionCreds() {\n try {\n let keyName = `frodo-${state.getUsername()}`;\n try {\n const keys = await frodo.cloud.log.getLogApiKeys();\n for (const key of keys) {\n if (key.name === keyName) {\n // append current timestamp to name if the named key already exists\n keyName = `${keyName}-${new Date().toISOString()}`;\n }\n }\n try {\n const resp = await frodo.cloud.log.createLogApiKeyAndSecret(keyName);\n if (resp.name !== keyName) {\n printMessage(\n `create keys ERROR: could not create log API key ${keyName}`,\n 'error'\n );\n return null;\n }\n verboseMessage(\n `Created a new log API key [${keyName}] in ${state.getHost()}`\n );\n return resp;\n } catch (error) {\n printMessage(\n `create keys ERROR: create keys call returned ${error}`,\n 'error'\n );\n return null;\n }\n } catch (error) {\n printMessage(`get keys ERROR: get keys call returned ${error}`, 'error');\n }\n } catch (e) {\n printMessage(`create keys ERROR: create keys data error - ${e}`, 'error');\n return null;\n }\n}\n\nexport async function fetchLogs(\n source: string,\n startTs: string,\n endTs: string,\n levels: string[],\n txid: string,\n ffString: string,\n cookie: string,\n nf: string[]\n) {\n try {\n const logsObject = await frodo.cloud.log.fetch(\n source,\n startTs,\n endTs,\n cookie\n );\n let filteredLogs = [];\n const noiseFilter =\n nf == null ? frodo.cloud.log.getDefaultNoiseFilter() : nf;\n if (Array.isArray(logsObject.result)) {\n filteredLogs = logsObject.result.filter(\n (el) =>\n !noiseFilter.includes(\n (el.payload as LogEventPayloadSkeleton).logger\n ) &&\n !noiseFilter.includes(el.type) &&\n (levels[0] === 'ALL' ||\n levels.includes(frodo.cloud.log.resolvePayloadLevel(el))) &&\n (typeof txid === 'undefined' ||\n txid === null ||\n (el.payload as LogEventPayloadSkeleton).transactionId?.includes(\n txid\n ))\n );\n }\n\n filteredLogs.forEach((e) => {\n const log = JSON.stringify(e, null, 2);\n if (ffString) {\n if (log.includes(ffString)) {\n printMessage(log, 'data');\n }\n } else {\n printMessage(log, 'data');\n }\n });\n if (logsObject.pagedResultsCookie != null) {\n await fetchLogs(\n source,\n startTs,\n endTs,\n levels,\n txid,\n ffString,\n logsObject.pagedResultsCookie,\n nf\n );\n }\n return null;\n } catch (e) {\n printMessage(`fetch ERROR: fetch data error - ${e}`, 'error');\n return `fetch ERROR: fetch data error - ${e}`;\n }\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAEpD,SAASC,YAAY,EAAEC,cAAc,QAAQ,kBAAkB;AAE/D,OAAO,eAAeC,QAAQA,CAC5BC,MAAc,EACdC,MAAgB,EAChBC,IAAY,EACZC,MAAc,EACdC,EAAY,EACZ;EACA,IAAI;IACF,MAAMC,UAAU,GAAG,MAAMV,KAAK,CAACW,KAAK,CAACC,GAAG,CAACC,IAAI,CAACR,MAAM,EAAEG,MAAM,CAAC;IAC7D,IAAIM,YAAY,GAAG,EAAE;IACrB,MAAMC,WAAW,GACfN,EAAE,IAAI,IAAI,GAAGT,KAAK,CAACW,KAAK,CAACC,GAAG,CAACI,qBAAqB,CAAC,CAAC,GAAGP,EAAE;IAC3D,IAAIQ,KAAK,CAACC,OAAO,CAACR,UAAU,CAACS,MAAM,CAAC,EAAE;MACpCL,YAAY,GAAGJ,UAAU,CAACS,MAAM,CAACC,MAAM,CACpCC,EAAE;QAAA,IAAAC,cAAA;QAAA,OACD,CAACP,WAAW,CAACQ,QAAQ,CAClBF,EAAE,CAACG,OAAO,CAA6BC,MAC1C,CAAC,IACD,CAACV,WAAW,CAACQ,QAAQ,CAACF,EAAE,CAACK,IAAI,CAAC,KAC7BpB,MAAM,CAAC,CAAC,CAAC,KAAK,KAAK,IAClBA,MAAM,CAACiB,QAAQ,CAACvB,KAAK,CAACW,KAAK,CAACC,GAAG,CAACe,mBAAmB,CAACN,EAA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ner","printMessage","showSpinner","succeedSpinner","verboseMessage","listLogApiKeys","long","outcome","keys","cloud","log","getLogApiKeys","table","key","push","api_key_id","name","created_at","toString","error","provisionCreds","keyName","getUsername","Date","toISOString","resp","createLogApiKey","getHost","e","deleteLogApiKey","keyId","message","deleteLogApiKeys","response","length","tailLogs","source","levels","txid","cookie","nf","logsObject","tail","filteredLogs","noiseFilter","getDefaultNoiseFilter","Array","isArray","result","filter","el","_transactionId","includes","payload","logger","type","resolvePayloadLevel","transactionId","forEach","JSON","stringify","setTimeout","pagedResultsCookie","fetchLogs","startTs","endTs","ffString","fetch","_transactionId2"],"sources":["ops/LogOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport type { LogEventPayloadSkeleton } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport {\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n succeedSpinner,\n verboseMessage,\n} from '../utils/Console';\n\nexport async function listLogApiKeys(long = false): Promise<boolean> {\n let outcome = false;\n try {\n const keys = await frodo.cloud.log.getLogApiKeys();\n if (long) {\n const table = createTable(['Key Id', 'Name', 'Created at']);\n for (const key of keys) {\n table.push([key.api_key_id, key.name, key.created_at]);\n }\n printMessage(table.toString(), 'data');\n } else {\n for (const key of keys) {\n printMessage(`${key.api_key_id}`, 'data');\n }\n }\n outcome = true;\n } catch (error) {\n printMessage(`Error listing log API keys: ${error}`, 'error');\n }\n return outcome;\n}\n\nexport async function provisionCreds() {\n try {\n let keyName = `frodo-${state.getUsername()}`;\n try {\n const keys = await frodo.cloud.log.getLogApiKeys();\n for (const key of keys) {\n if (key.name === keyName) {\n // append current timestamp to name if the named key already exists\n keyName = `${keyName}-${new Date().toISOString()}`;\n }\n }\n try {\n const resp = await frodo.cloud.log.createLogApiKey(keyName);\n // if (resp.name !== keyName) {\n // printMessage(\n // `create keys ERROR: could not create log API key ${keyName} [new key name: ${resp.name}]`,\n // 'error'\n // );\n // return null;\n // }\n verboseMessage(\n `Created a new log API key [${keyName}] in ${state.getHost()}`\n );\n return resp;\n } catch (error) {\n printMessage(\n `create keys ERROR: create keys call returned ${error}`,\n 'error'\n );\n return null;\n }\n } catch (error) {\n printMessage(`get keys ERROR: get keys call returned ${error}`, 'error');\n }\n } catch (e) {\n printMessage(`create keys ERROR: create keys data error - ${e}`, 'error');\n return null;\n }\n}\n\nexport async function deleteLogApiKey(keyId) {\n let outcome = false;\n debugMessage(`cli.LogOps.deleteKey: start`);\n showSpinner(`Deleting ${keyId}...`);\n try {\n await frodo.cloud.log.deleteLogApiKey(keyId);\n succeedSpinner(`Deleted ${keyId}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error deleting ${keyId}: ${error.message}`);\n }\n debugMessage(`cli.LogOps.deleteKey: end [${outcome}]`);\n return outcome;\n}\n\nexport async function deleteLogApiKeys() {\n let outcome = false;\n debugMessage(`cli.LogOps.deleteKeys: start`);\n showSpinner(`Deleting all keys...`);\n try {\n const response = await frodo.cloud.log.deleteLogApiKeys();\n succeedSpinner(`Deleted ${response.length} keys.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error deleting keys: ${error.message}`);\n }\n debugMessage(`cli.LogOps.deleteKeys: end [${outcome}]`);\n return outcome;\n}\n\nexport async function tailLogs(\n source: string,\n levels: string[],\n txid: string,\n cookie: string,\n nf: string[]\n) {\n try {\n const logsObject = await frodo.cloud.log.tail(source, cookie);\n let filteredLogs = [];\n const noiseFilter =\n nf == null ? frodo.cloud.log.getDefaultNoiseFilter() : nf;\n if (Array.isArray(logsObject.result)) {\n filteredLogs = logsObject.result.filter(\n (el) =>\n !noiseFilter.includes(\n (el.payload as LogEventPayloadSkeleton).logger\n ) &&\n !noiseFilter.includes(el.type) &&\n (levels[0] === 'ALL' ||\n levels.includes(frodo.cloud.log.resolvePayloadLevel(el))) &&\n (typeof txid === 'undefined' ||\n txid === null ||\n (el.payload as LogEventPayloadSkeleton).transactionId?.includes(\n txid\n ))\n );\n }\n\n filteredLogs.forEach((e) => {\n printMessage(JSON.stringify(e), 'data');\n });\n\n setTimeout(() => {\n tailLogs(source, levels, txid, logsObject.pagedResultsCookie, nf);\n }, 5000);\n return null;\n } catch (e) {\n printMessage(`tail ERROR: tail data error - ${e}`, 'error');\n return `tail ERROR: tail data error - ${e}`;\n }\n}\n\nexport async function fetchLogs(\n source: string,\n startTs: string,\n endTs: string,\n levels: string[],\n txid: string,\n ffString: string,\n cookie: string,\n nf: string[]\n) {\n try {\n const logsObject = await frodo.cloud.log.fetch(\n source,\n startTs,\n endTs,\n cookie\n );\n let filteredLogs = [];\n const noiseFilter =\n nf == null ? frodo.cloud.log.getDefaultNoiseFilter() : nf;\n if (Array.isArray(logsObject.result)) {\n filteredLogs = logsObject.result.filter(\n (el) =>\n !noiseFilter.includes(\n (el.payload as LogEventPayloadSkeleton).logger\n ) &&\n !noiseFilter.includes(el.type) &&\n (levels[0] === 'ALL' ||\n levels.includes(frodo.cloud.log.resolvePayloadLevel(el))) &&\n (typeof txid === 'undefined' ||\n txid === null ||\n (el.payload as LogEventPayloadSkeleton).transactionId?.includes(\n txid\n ))\n );\n }\n\n filteredLogs.forEach((e) => {\n const log = JSON.stringify(e, null, 2);\n if (ffString) {\n if (log.includes(ffString)) {\n printMessage(log, 'data');\n }\n } else {\n printMessage(log, 'data');\n }\n });\n if (logsObject.pagedResultsCookie != null) {\n await fetchLogs(\n source,\n startTs,\n endTs,\n levels,\n txid,\n ffString,\n logsObject.pagedResultsCookie,\n nf\n );\n }\n return null;\n } catch (e) {\n printMessage(`fetch ERROR: fetch data error - ${e}`, 'error');\n return `fetch ERROR: fetch data error - ${e}`;\n }\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAEpD,SACEC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,cAAc,EACdC,cAAc,QACT,kBAAkB;AAEzB,OAAO,eAAeC,cAAcA,CAACC,IAAI,GAAG,KAAK,EAAo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7 +28,7 @@ export async function listOAuth2Clients(long = false) {
|
|
|
28
28
|
'urn:ietf:params:oauth:grant-type:jwt-bearer': 'JWT Bearer'
|
|
29
29
|
};
|
|
30
30
|
clients.forEach(client => {
|
|
31
|
-
table.push([client._id, client.coreOAuth2ClientConfig.status === 'Active' ? 'Active'['brightGreen'] : client.coreOAuth2ClientConfig.status
|
|
31
|
+
table.push([client._id, client.coreOAuth2ClientConfig.status === 'Active' ? 'Active'['brightGreen'] : client.coreOAuth2ClientConfig.status['brightRed'], client.coreOAuth2ClientConfig.clientType, client.advancedOAuth2ClientConfig.grantTypes.map(type => grantTypesMap[type]).join('\n'), client.coreOAuth2ClientConfig.scopes.join('\n'), client.coreOAuth2ClientConfig.redirectionUris.join('\n')
|
|
32
32
|
// wordwrap(client.description, 30),
|
|
33
33
|
]);
|
|
34
34
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OAuth2ClientOps.js","names":["frodo","state","fs","createProgressBar","createTable","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","saveJsonToFile","listOAuth2Clients","long","clients","oauth2oidc","client","getOAuth2Clients","sort","a","b","_id","localeCompare","table","grantTypesMap","authorization_code","client_credentials","refresh_token","password","implicit","forEach","push","coreOAuth2ClientConfig","status","brightRed","clientType","advancedOAuth2ClientConfig","grantTypes","map","type","join","scopes","redirectionUris","toString","error","exportOAuth2ClientToFile","clientId","file","options","useStringArrays","deps","outcome","fileName","utils","impex","getTypedFilename","exportData","exportOAuth2Client","message","exportOAuth2ClientsToFile","titleCase","helper","getRealmName","getRealm","exportOAuth2Clients","exportOAuth2ClientsToFiles","errors","length","importOAuth2ClientFromFile","data","readFileSync","fileData","JSON","parse","importOAuth2Client","importFirstOAuth2ClientFromFile","importFirstOAuth2Client","importOAuth2ClientsFromFile","applicationData","importOAuth2Clients","importOAuth2ClientsFromFiles","names","readdirSync","files","filter","name","toLowerCase","endsWith","total","count","Object","keys","application"],"sources":["ops/OAuth2ClientOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport fs from 'fs';\nimport {\n createProgressBar,\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport { saveJsonToFile } from '../utils/ExportImportUtils';\nimport type {\n OAuth2ClientExportInterface,\n OAuth2ClientExportOptions,\n OAuth2ClientImportOptions,\n} from '@rockcarver/frodo-lib/types/ops/OAuth2ClientOps';\n\n/**\n * List OAuth2 clients\n */\nexport async function listOAuth2Clients(long = false) {\n try {\n const clients = await frodo.oauth2oidc.client.getOAuth2Clients();\n clients.sort((a, b) => a._id.localeCompare(b._id));\n if (long) {\n const table = createTable([\n 'Client Id',\n 'Status',\n 'Client Type',\n 'Grant Types',\n 'Scopes',\n 'Redirect URIs',\n // 'Description',\n ]);\n const grantTypesMap = {\n authorization_code: 'Authz Code',\n client_credentials: 'Client Creds',\n refresh_token: 'Refresh Token',\n password: 'ROPC',\n 'urn:ietf:params:oauth:grant-type:uma-ticket': 'UMA',\n implicit: 'Implicit',\n 'urn:ietf:params:oauth:grant-type:device_code': 'Device Code',\n 'urn:ietf:params:oauth:grant-type:saml2-bearer': 'SAML2 Bearer',\n 'urn:openid:params:grant-type:ciba': 'CIBA',\n 'urn:ietf:params:oauth:grant-type:token-exchange': 'Token Exchange',\n 'urn:ietf:params:oauth:grant-type:jwt-bearer': 'JWT Bearer',\n };\n clients.forEach((client) => {\n table.push([\n client._id,\n client.coreOAuth2ClientConfig.status === 'Active'\n ? 'Active'['brightGreen']\n : client.coreOAuth2ClientConfig.status.brightRed,\n client.coreOAuth2ClientConfig.clientType,\n client.advancedOAuth2ClientConfig.grantTypes\n .map((type) => grantTypesMap[type])\n .join('\\n'),\n client.coreOAuth2ClientConfig.scopes.join('\\n'),\n client.coreOAuth2ClientConfig.redirectionUris.join('\\n'),\n // wordwrap(client.description, 30),\n ]);\n });\n printMessage(table.toString(), 'data');\n } else {\n clients.forEach((client) => {\n printMessage(`${client._id}`, 'data');\n });\n }\n } catch (error) {\n printMessage(`Error listing applications - ${error}`, 'error');\n }\n}\n\n/**\n * Export OAuth2 client to file\n * @param {string} clientId client id\n * @param {string} file file name\n * @param {OAuth2ClientExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportOAuth2ClientToFile(\n clientId: string,\n file: string,\n options: OAuth2ClientExportOptions = { useStringArrays: true, deps: true }\n) {\n let outcome = false;\n debugMessage(`cli.OAuth2ClientOps.exportOAuth2ClientToFile: begin`);\n showSpinner(`Exporting ${clientId}...`);\n try {\n let fileName = frodo.utils.impex.getTypedFilename(clientId, 'oauth2.app');\n if (file) {\n fileName = file;\n }\n const exportData = await frodo.oauth2oidc.client.exportOAuth2Client(\n clientId,\n options\n );\n saveJsonToFile(exportData, fileName);\n succeedSpinner(`Exported ${clientId} to ${fileName}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting ${clientId}: ${error.message}`);\n }\n debugMessage(`cli.OAuth2ClientOps.exportOAuth2ClientToFile: end`);\n return outcome;\n}\n\n/**\n * Export all OAuth2 clients to file\n * @param {string} file file name\n * @param {OAuth2ClientExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportOAuth2ClientsToFile(\n file: string,\n options: OAuth2ClientExportOptions = { useStringArrays: true, deps: true }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.OAuth2ClientOps.exportOAuth2ClientsToFile: begin`);\n showSpinner(`Exporting all clients...`);\n try {\n let fileName = frodo.utils.impex.getTypedFilename(\n `all${frodo.utils.impex.titleCase(\n frodo.helper.utils.getRealmName(state.getRealm())\n )}Applications`,\n 'oauth2.app'\n );\n if (file) {\n fileName = file;\n }\n const exportData = await frodo.oauth2oidc.client.exportOAuth2Clients(\n options\n );\n saveJsonToFile(exportData, fileName);\n succeedSpinner(`Exported all clients to ${fileName}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting all clients`);\n printMessage(`${error.message}`, 'error');\n }\n debugMessage(\n `cli.OAuth2ClientOps.exportOAuth2ClientsToFile: end [${outcome}]`\n );\n return outcome;\n}\n\n/**\n * Export all OAuth2 clients to separate files\n * @param {OAuth2ClientExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportOAuth2ClientsToFiles(\n options: OAuth2ClientExportOptions = { useStringArrays: true, deps: true }\n) {\n debugMessage(`cli.OAuth2ClientOps.exportOAuth2ClientsToFiles: begin`);\n const errors = [];\n try {\n const clients = await frodo.oauth2oidc.client.getOAuth2Clients();\n createProgressBar(clients.length, 'Exporting clients...');\n for (const client of clients) {\n const file = frodo.utils.impex.getTypedFilename(client._id, 'oauth2.app');\n try {\n const exportData: OAuth2ClientExportInterface =\n await frodo.oauth2oidc.client.exportOAuth2Client(client._id, options);\n saveJsonToFile(exportData, file);\n updateProgressBar(`Exported ${client._id}.`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error exporting ${client._id}.`);\n }\n }\n stopProgressBar(`Export complete.`);\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error exporting client(s) to file(s)`);\n }\n debugMessage(`cli.OAuth2ClientOps.exportOAuth2ClientsToFiles: end`);\n return 0 === errors.length;\n}\n\n/**\n * Import first OAuth2 client from file\n * @param {string} clientId client id\n * @param {string} file file name\n * @param {OAuth2ClientImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importOAuth2ClientFromFile(\n clientId: string,\n file: string,\n options: OAuth2ClientImportOptions = { deps: true }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.OAuth2ClientOps.importOAuth2ClientFromFile: begin`);\n showSpinner(`Importing ${clientId}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await frodo.oauth2oidc.client.importOAuth2Client(\n clientId,\n fileData,\n options\n );\n outcome = true;\n succeedSpinner(`Imported ${clientId}.`);\n } catch (error) {\n failSpinner(`Error importing ${clientId}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.OAuth2ClientOps.importOAuth2ClientFromFile: end`);\n return outcome;\n}\n\n/**\n * Import first OAuth2 client from file\n * @param {string} file file name\n * @param {OAuth2ClientImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importFirstOAuth2ClientFromFile(\n file: string,\n options: OAuth2ClientImportOptions = { deps: true }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.OAuth2ClientOps.importFirstOAuth2ClientFromFile: begin`);\n showSpinner(`Importing ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await frodo.oauth2oidc.client.importFirstOAuth2Client(fileData, options);\n outcome = true;\n succeedSpinner(`Imported ${file}.`);\n } catch (error) {\n failSpinner(`Error importing ${file}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.OAuth2ClientOps.importFirstOAuth2ClientFromFile: end`);\n return outcome;\n}\n\n/**\n * Import OAuth2 clients from file\n * @param {string} file file name\n * @param {OAuth2ClientImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importOAuth2ClientsFromFile(\n file: string,\n options: OAuth2ClientImportOptions = { deps: true }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.OAuth2ClientOps.importOAuth2ClientsFromFile: begin`);\n showSpinner(`Importing ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const applicationData = JSON.parse(data);\n await frodo.oauth2oidc.client.importOAuth2Clients(applicationData, options);\n outcome = true;\n succeedSpinner(`Imported ${file}.`);\n } catch (error) {\n failSpinner(`Error importing ${file}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.OAuth2ClientOps.importOAuth2ClientsFromFile: end`);\n return outcome;\n}\n\n/**\n * Import OAuth2 clients from files\n * @param {OAuth2ClientImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importOAuth2ClientsFromFiles(\n options: OAuth2ClientImportOptions = { deps: true }\n): Promise<boolean> {\n const errors = [];\n try {\n debugMessage(`cli.OAuth2ClientOps.importOAuth2ClientsFromFiles: begin`);\n const names = fs.readdirSync('.');\n const files = names.filter((name) =>\n name.toLowerCase().endsWith('.oauth2.app.json')\n );\n createProgressBar(files.length, 'Importing clients...');\n let total = 0;\n for (const file of files) {\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData: OAuth2ClientExportInterface = JSON.parse(data);\n const count = Object.keys(fileData.application).length;\n total += count;\n await frodo.oauth2oidc.client.importOAuth2Clients(fileData, options);\n updateProgressBar(`Imported ${count} client(s) from ${file}`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error importing client(s) from ${file}`);\n printMessage(error, 'error');\n }\n }\n stopProgressBar(\n `Finished importing ${total} client(s) from ${files.length} file(s).`\n );\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error importing client(s) from file(s).`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.OAuth2ClientOps.importOAuth2ClientsFromFiles: end`);\n return 0 === errors.length;\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,OAAOC,EAAE,MAAM,IAAI;AACnB,SACEC,iBAAiB,EACjBC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,cAAc,EACdC,iBAAiB,QACZ,kBAAkB;AACzB,SAASC,cAAc,QAAQ,4BAA4B;AAO3D;AACA;AACA;AACA,OAAO,eAAeC,iBAAiBA,CAACC,IAAI,GAAG,KAAK,EAAE;EACpD,IAAI;IACF,MAAMC,OAAO,GAAG,MAAMf,KAAK,CAACgB,UAAU,CAACC,MAAM,CAACC,gBAAgB,CAAC,CAAC;IAChEH,OAAO,CAACI,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACE,GAAG,CAACC,aAAa,CAACF,CAAC,CAACC,GAAG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K,EAAE;MACxB,IAAI;QACF,MAAMd,IAAI,GAAGpE,EAAE,CAACqE,YAAY,CAACvB,IAAI,EAAE,MAAM,CAAC;QAC1C,MAAMwB,QAAqC,GAAGC,IAAI,CAACC,KAAK,CAACJ,IAAI,CAAC;QAC9D,MAAMoB,KAAK,GAAGC,MAAM,CAACC,IAAI,CAACpB,QAAQ,CAACqB,WAAW,CAAC,CAACzB,MAAM;QACtDqB,KAAK,IAAIC,KAAK;QACd,MAAM1F,KAAK,CAACgB,UAAU,CAACC,MAAM,CAAC+D,mBAAmB,CAACR,QAAQ,EAAEvB,OAAO,CAAC;QACpEtC,iBAAiB,CAAE,YAAW+E,KAAM,mBAAkB1C,IAAK,EAAC,CAAC;MAC/D,CAAC,CAAC,OAAOH,KAAK,EAAE;QACdsB,MAAM,CAACnC,IAAI,CAACa,KAAK,CAAC;QAClBlC,iBAAiB,CAAE,kCAAiCqC,IAAK,EAAC,CAAC;QAC3DzC,YAAY,CAACsC,KAAK,EAAE,OAAO,CAAC;MAC9B;IACF;IACApC,eAAe,CACZ,sBAAqBgF,KAAM,mBAAkBL,KAAK,CAAChB,MAAO,WAC7D,CAAC;EACH,CAAC,CAAC,OAAOvB,KAAK,EAAE;IACdsB,MAAM,CAACnC,IAAI,CAACa,KAAK,CAAC;IAClBpC,eAAe,CAAE,yCAAwC,CAAC;IAC1DF,YAAY,CAACsC,KAAK,EAAE,OAAO,CAAC;EAC9B;EACAxC,YAAY,CAAE,uDAAsD,CAAC;EACrE,OAAO,CAAC,KAAK8D,MAAM,CAACC,MAAM;AAC5B"}
|
|
1
|
+
{"version":3,"file":"OAuth2ClientOps.js","names":["frodo","state","fs","createProgressBar","createTable","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","saveJsonToFile","listOAuth2Clients","long","clients","oauth2oidc","client","getOAuth2Clients","sort","a","b","_id","localeCompare","table","grantTypesMap","authorization_code","client_credentials","refresh_token","password","implicit","forEach","push","coreOAuth2ClientConfig","status","clientType","advancedOAuth2ClientConfig","grantTypes","map","type","join","scopes","redirectionUris","toString","error","exportOAuth2ClientToFile","clientId","file","options","useStringArrays","deps","outcome","fileName","utils","impex","getTypedFilename","exportData","exportOAuth2Client","message","exportOAuth2ClientsToFile","titleCase","helper","getRealmName","getRealm","exportOAuth2Clients","exportOAuth2ClientsToFiles","errors","length","importOAuth2ClientFromFile","data","readFileSync","fileData","JSON","parse","importOAuth2Client","importFirstOAuth2ClientFromFile","importFirstOAuth2Client","importOAuth2ClientsFromFile","applicationData","importOAuth2Clients","importOAuth2ClientsFromFiles","names","readdirSync","files","filter","name","toLowerCase","endsWith","total","count","Object","keys","application"],"sources":["ops/OAuth2ClientOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport fs from 'fs';\nimport {\n createProgressBar,\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport { saveJsonToFile } from '../utils/ExportImportUtils';\nimport type {\n OAuth2ClientExportInterface,\n OAuth2ClientExportOptions,\n OAuth2ClientImportOptions,\n} from '@rockcarver/frodo-lib/types/ops/OAuth2ClientOps';\nimport { ReadableStrings } from '@rockcarver/frodo-lib/types/api/ApiTypes';\n\n/**\n * List OAuth2 clients\n */\nexport async function listOAuth2Clients(long = false) {\n try {\n const clients = await frodo.oauth2oidc.client.getOAuth2Clients();\n clients.sort((a, b) => a._id.localeCompare(b._id));\n if (long) {\n const table = createTable([\n 'Client Id',\n 'Status',\n 'Client Type',\n 'Grant Types',\n 'Scopes',\n 'Redirect URIs',\n // 'Description',\n ]);\n const grantTypesMap = {\n authorization_code: 'Authz Code',\n client_credentials: 'Client Creds',\n refresh_token: 'Refresh Token',\n password: 'ROPC',\n 'urn:ietf:params:oauth:grant-type:uma-ticket': 'UMA',\n implicit: 'Implicit',\n 'urn:ietf:params:oauth:grant-type:device_code': 'Device Code',\n 'urn:ietf:params:oauth:grant-type:saml2-bearer': 'SAML2 Bearer',\n 'urn:openid:params:grant-type:ciba': 'CIBA',\n 'urn:ietf:params:oauth:grant-type:token-exchange': 'Token Exchange',\n 'urn:ietf:params:oauth:grant-type:jwt-bearer': 'JWT Bearer',\n };\n clients.forEach((client) => {\n table.push([\n client._id,\n client.coreOAuth2ClientConfig.status === 'Active'\n ? 'Active'['brightGreen']\n : (client.coreOAuth2ClientConfig.status as string)['brightRed'],\n client.coreOAuth2ClientConfig.clientType,\n (client.advancedOAuth2ClientConfig.grantTypes as ReadableStrings)\n .map((type) => grantTypesMap[type])\n .join('\\n'),\n (client.coreOAuth2ClientConfig.scopes as ReadableStrings).join('\\n'),\n (client.coreOAuth2ClientConfig.redirectionUris as string[]).join(\n '\\n'\n ),\n // wordwrap(client.description, 30),\n ]);\n });\n printMessage(table.toString(), 'data');\n } else {\n clients.forEach((client) => {\n printMessage(`${client._id}`, 'data');\n });\n }\n } catch (error) {\n printMessage(`Error listing applications - ${error}`, 'error');\n }\n}\n\n/**\n * Export OAuth2 client to file\n * @param {string} clientId client id\n * @param {string} file file name\n * @param {OAuth2ClientExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportOAuth2ClientToFile(\n clientId: string,\n file: string,\n options: OAuth2ClientExportOptions = { useStringArrays: true, deps: true }\n) {\n let outcome = false;\n debugMessage(`cli.OAuth2ClientOps.exportOAuth2ClientToFile: begin`);\n showSpinner(`Exporting ${clientId}...`);\n try {\n let fileName = frodo.utils.impex.getTypedFilename(clientId, 'oauth2.app');\n if (file) {\n fileName = file;\n }\n const exportData = await frodo.oauth2oidc.client.exportOAuth2Client(\n clientId,\n options\n );\n saveJsonToFile(exportData, fileName);\n succeedSpinner(`Exported ${clientId} to ${fileName}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting ${clientId}: ${error.message}`);\n }\n debugMessage(`cli.OAuth2ClientOps.exportOAuth2ClientToFile: end`);\n return outcome;\n}\n\n/**\n * Export all OAuth2 clients to file\n * @param {string} file file name\n * @param {OAuth2ClientExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportOAuth2ClientsToFile(\n file: string,\n options: OAuth2ClientExportOptions = { useStringArrays: true, deps: true }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.OAuth2ClientOps.exportOAuth2ClientsToFile: begin`);\n showSpinner(`Exporting all clients...`);\n try {\n let fileName = frodo.utils.impex.getTypedFilename(\n `all${frodo.utils.impex.titleCase(\n frodo.helper.utils.getRealmName(state.getRealm())\n )}Applications`,\n 'oauth2.app'\n );\n if (file) {\n fileName = file;\n }\n const exportData = await frodo.oauth2oidc.client.exportOAuth2Clients(\n options\n );\n saveJsonToFile(exportData, fileName);\n succeedSpinner(`Exported all clients to ${fileName}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting all clients`);\n printMessage(`${error.message}`, 'error');\n }\n debugMessage(\n `cli.OAuth2ClientOps.exportOAuth2ClientsToFile: end [${outcome}]`\n );\n return outcome;\n}\n\n/**\n * Export all OAuth2 clients to separate files\n * @param {OAuth2ClientExportOptions} options export options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportOAuth2ClientsToFiles(\n options: OAuth2ClientExportOptions = { useStringArrays: true, deps: true }\n) {\n debugMessage(`cli.OAuth2ClientOps.exportOAuth2ClientsToFiles: begin`);\n const errors = [];\n try {\n const clients = await frodo.oauth2oidc.client.getOAuth2Clients();\n createProgressBar(clients.length, 'Exporting clients...');\n for (const client of clients) {\n const file = frodo.utils.impex.getTypedFilename(client._id, 'oauth2.app');\n try {\n const exportData: OAuth2ClientExportInterface =\n await frodo.oauth2oidc.client.exportOAuth2Client(client._id, options);\n saveJsonToFile(exportData, file);\n updateProgressBar(`Exported ${client._id}.`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error exporting ${client._id}.`);\n }\n }\n stopProgressBar(`Export complete.`);\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error exporting client(s) to file(s)`);\n }\n debugMessage(`cli.OAuth2ClientOps.exportOAuth2ClientsToFiles: end`);\n return 0 === errors.length;\n}\n\n/**\n * Import first OAuth2 client from file\n * @param {string} clientId client id\n * @param {string} file file name\n * @param {OAuth2ClientImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importOAuth2ClientFromFile(\n clientId: string,\n file: string,\n options: OAuth2ClientImportOptions = { deps: true }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.OAuth2ClientOps.importOAuth2ClientFromFile: begin`);\n showSpinner(`Importing ${clientId}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await frodo.oauth2oidc.client.importOAuth2Client(\n clientId,\n fileData,\n options\n );\n outcome = true;\n succeedSpinner(`Imported ${clientId}.`);\n } catch (error) {\n failSpinner(`Error importing ${clientId}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.OAuth2ClientOps.importOAuth2ClientFromFile: end`);\n return outcome;\n}\n\n/**\n * Import first OAuth2 client from file\n * @param {string} file file name\n * @param {OAuth2ClientImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importFirstOAuth2ClientFromFile(\n file: string,\n options: OAuth2ClientImportOptions = { deps: true }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.OAuth2ClientOps.importFirstOAuth2ClientFromFile: begin`);\n showSpinner(`Importing ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await frodo.oauth2oidc.client.importFirstOAuth2Client(fileData, options);\n outcome = true;\n succeedSpinner(`Imported ${file}.`);\n } catch (error) {\n failSpinner(`Error importing ${file}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.OAuth2ClientOps.importFirstOAuth2ClientFromFile: end`);\n return outcome;\n}\n\n/**\n * Import OAuth2 clients from file\n * @param {string} file file name\n * @param {OAuth2ClientImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importOAuth2ClientsFromFile(\n file: string,\n options: OAuth2ClientImportOptions = { deps: true }\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.OAuth2ClientOps.importOAuth2ClientsFromFile: begin`);\n showSpinner(`Importing ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const applicationData = JSON.parse(data);\n await frodo.oauth2oidc.client.importOAuth2Clients(applicationData, options);\n outcome = true;\n succeedSpinner(`Imported ${file}.`);\n } catch (error) {\n failSpinner(`Error importing ${file}.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.OAuth2ClientOps.importOAuth2ClientsFromFile: end`);\n return outcome;\n}\n\n/**\n * Import OAuth2 clients from files\n * @param {OAuth2ClientImportOptions} options import options\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importOAuth2ClientsFromFiles(\n options: OAuth2ClientImportOptions = { deps: true }\n): Promise<boolean> {\n const errors = [];\n try {\n debugMessage(`cli.OAuth2ClientOps.importOAuth2ClientsFromFiles: begin`);\n const names = fs.readdirSync('.');\n const files = names.filter((name) =>\n name.toLowerCase().endsWith('.oauth2.app.json')\n );\n createProgressBar(files.length, 'Importing clients...');\n let total = 0;\n for (const file of files) {\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData: OAuth2ClientExportInterface = JSON.parse(data);\n const count = Object.keys(fileData.application).length;\n total += count;\n await frodo.oauth2oidc.client.importOAuth2Clients(fileData, options);\n updateProgressBar(`Imported ${count} client(s) from ${file}`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error importing client(s) from ${file}`);\n printMessage(error, 'error');\n }\n }\n stopProgressBar(\n `Finished importing ${total} client(s) from ${files.length} file(s).`\n );\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error importing client(s) from file(s).`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.OAuth2ClientOps.importOAuth2ClientsFromFiles: end`);\n return 0 === errors.length;\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,K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,CAAC;EACH,CAAC,CAAC,OAAOvB,KAAK,EAAE;IACdsB,MAAM,CAAClC,IAAI,CAACY,KAAK,CAAC;IAClBnC,eAAe,CAAE,yCAAwC,CAAC;IAC1DF,YAAY,CAACqC,KAAK,EAAE,OAAO,CAAC;EAC9B;EACAvC,YAAY,CAAE,uDAAsD,CAAC;EACrE,OAAO,CAAC,KAAK6D,MAAM,CAACC,MAAM;AAC5B"}
|
package/esm/ops/RealmOps.js
CHANGED
|
@@ -7,7 +7,7 @@ import { createKeyValueTable, createTable, printMessage } from '../utils/Console
|
|
|
7
7
|
*/
|
|
8
8
|
export async function listRealms(long = false) {
|
|
9
9
|
try {
|
|
10
|
-
const realms = (await frodo.realm.getRealms()).
|
|
10
|
+
const realms = (await frodo.realm.getRealms()).result;
|
|
11
11
|
if (long) {
|
|
12
12
|
const table = createTable(['Name'['brightCyan'], 'Status'['brightCyan'], 'Custom Domains'['brightCyan'], 'Parent'['brightCyan']]);
|
|
13
13
|
realms.forEach(realmConfig => {
|
|
@@ -20,8 +20,10 @@ export async function listRealms(long = false) {
|
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
} catch (error) {
|
|
23
|
+
var _error$response;
|
|
24
|
+
printMessage(error, 'error');
|
|
23
25
|
printMessage(`Error listing realms: ${error.rmessage}`, 'error');
|
|
24
|
-
printMessage(error.response.data, 'error');
|
|
26
|
+
printMessage((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data, 'error');
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
|
|
@@ -61,7 +63,7 @@ export async function addCustomDomain(realm, domain) {
|
|
|
61
63
|
if (!exists) {
|
|
62
64
|
try {
|
|
63
65
|
realmConfig.aliases.push(domain.toLowerCase());
|
|
64
|
-
realmConfig =
|
|
66
|
+
realmConfig = await frodo.realm.putRealm(realmConfig._id, realmConfig);
|
|
65
67
|
const table = createKeyValueTable();
|
|
66
68
|
table.push(['Name'['brightCyan'], realmConfig.name]);
|
|
67
69
|
table.push(['Status'['brightCyan'], realmConfig.active ? 'active'['brightGreen'] : 'inactive'['brightRed']]);
|
|
@@ -90,7 +92,7 @@ export async function removeCustomDomain(realm, domain) {
|
|
|
90
92
|
if (aliases.length < realmConfig.aliases.length) {
|
|
91
93
|
try {
|
|
92
94
|
realmConfig.aliases = aliases;
|
|
93
|
-
realmConfig =
|
|
95
|
+
realmConfig = await frodo.realm.putRealm(realmConfig._id, realmConfig);
|
|
94
96
|
const table = createKeyValueTable();
|
|
95
97
|
table.push(['Name'['brightCyan'], realmConfig.name]);
|
|
96
98
|
table.push(['Status'['brightCyan'], realmConfig.active ? 'active'['brightGreen'] : 'inactive'['brightRed']]);
|
package/esm/ops/RealmOps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RealmOps.js","names":["frodo","createKeyValueTable","createTable","printMessage","listRealms","long","realms","realm","getRealms","
|
|
1
|
+
{"version":3,"file":"RealmOps.js","names":["frodo","createKeyValueTable","createTable","printMessage","listRealms","long","realms","realm","getRealms","result","table","forEach","realmConfig","push","name","active","aliases","join","parentPath","toString","error","_error$response","rmessage","response","data","describeRealm","getRealmByName","_id","addCustomDomain","domain","exists","alias","toLowerCase","putRealm","message","removeCustomDomain","filter","length"],"sources":["ops/RealmOps.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport {\n createKeyValueTable,\n createTable,\n printMessage,\n} from '../utils/Console';\n\n/**\n * List realms\n * @param {boolean} long Long list format with details\n */\nexport async function listRealms(long = false) {\n try {\n const realms = (await frodo.realm.getRealms()).result;\n if (long) {\n const table = createTable([\n 'Name'['brightCyan'],\n 'Status'['brightCyan'],\n 'Custom Domains'['brightCyan'],\n 'Parent'['brightCyan'],\n ]);\n realms.forEach((realmConfig) => {\n table.push([\n realmConfig.name,\n realmConfig.active\n ? 'active'['brightGreen']\n : 'inactive'['brightRed'],\n realmConfig.aliases.join('\\n'),\n realmConfig.parentPath,\n ]);\n });\n printMessage(table.toString());\n } else {\n realms.forEach((realmConfig) => {\n printMessage(realmConfig.name, 'info');\n });\n }\n } catch (error) {\n printMessage(error, 'error');\n printMessage(`Error listing realms: ${error.rmessage}`, 'error');\n printMessage(error.response?.data, 'error');\n }\n}\n\n/**\n * Describe realm\n * @param {String} realm realm name\n */\nexport async function describeRealm(realm: string) {\n try {\n const realmConfig = await frodo.realm.getRealmByName(realm);\n const table = createKeyValueTable();\n table.push(['Name'['brightCyan'], realmConfig.name]);\n table.push([\n 'Status'['brightCyan'],\n realmConfig.active ? 'active'['brightGreen'] : 'inactive'['brightRed'],\n ]);\n table.push([\n 'Custom Domains'['brightCyan'],\n realmConfig.aliases.join('\\n'),\n ]);\n table.push(['Parent'['brightCyan'], realmConfig.parentPath]);\n table.push(['Id'['brightCyan'], realmConfig._id]);\n printMessage(table.toString());\n } catch (error) {\n printMessage(`Realm ${realm} not found!`, 'error');\n }\n}\n\n/**\n * Add custom DNS domain name (realm DNS alias)\n * @param {String} realm realm name\n * @param {String} domain domain name\n */\nexport async function addCustomDomain(realm: string, domain: string) {\n try {\n let realmConfig = await frodo.realm.getRealmByName(realm);\n let exists = false;\n realmConfig.aliases.forEach((alias) => {\n if (domain.toLowerCase() === alias.toLowerCase()) {\n exists = true;\n }\n });\n if (!exists) {\n try {\n realmConfig.aliases.push(domain.toLowerCase());\n realmConfig = await frodo.realm.putRealm(realmConfig._id, realmConfig);\n const table = createKeyValueTable();\n table.push(['Name'['brightCyan'], realmConfig.name]);\n table.push([\n 'Status'['brightCyan'],\n realmConfig.active\n ? 'active'['brightGreen']\n : 'inactive'['brightRed'],\n ]);\n table.push([\n 'Custom Domains'['brightCyan'],\n realmConfig.aliases.join('\\n'),\n ]);\n table.push(['Parent'['brightCyan'], realmConfig.parentPath]);\n table.push(['Id'['brightCyan'], realmConfig._id]);\n printMessage(table.toString());\n } catch (error) {\n printMessage(`Error adding custom domain: ${error.message}`, 'error');\n }\n }\n } catch (error) {\n printMessage(`${error.message}`, 'error');\n }\n}\n\n/**\n * Remove custom DNS domain name (realm DNS alias)\n * @param {String} realm realm name\n * @param {String} domain domain name\n */\nexport async function removeCustomDomain(realm: string, domain: string) {\n try {\n let realmConfig = await frodo.realm.getRealmByName(realm);\n const aliases = realmConfig.aliases.filter(\n (alias) => domain.toLowerCase() !== alias.toLowerCase()\n );\n if (aliases.length < realmConfig.aliases.length) {\n try {\n realmConfig.aliases = aliases;\n realmConfig = await frodo.realm.putRealm(realmConfig._id, realmConfig);\n const table = createKeyValueTable();\n table.push(['Name'['brightCyan'], realmConfig.name]);\n table.push([\n 'Status'['brightCyan'],\n realmConfig.active\n ? 'active'['brightGreen']\n : 'inactive'['brightRed'],\n ]);\n table.push([\n 'Custom Domains'['brightCyan'],\n realmConfig.aliases.join('\\n'),\n ]);\n table.push(['Parent'['brightCyan'], realmConfig.parentPath]);\n table.push(['Id'['brightCyan'], realmConfig._id]);\n printMessage(table.toString());\n } catch (error) {\n printMessage(`Error removing custom domain: ${error.message}`, 'error');\n }\n }\n } catch (error) {\n printMessage(`${error.message}`, 'error');\n }\n}\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,SACEC,mBAAmB,EACnBC,WAAW,EACXC,YAAY,QACP,kBAAkB;;AAEzB;AACA;AACA;AACA;AACA,OAAO,eAAeC,UAAUA,CAACC,IAAI,GAAG,KAAK,EAAE;EAC7C,IAAI;IACF,MAAMC,MAAM,GAAG,CAAC,MAAMN,KAAK,CAACO,KAAK,CAACC,SAAS,CAAC,CAAC,EAAEC,MAAM;IACrD,IAAIJ,IAAI,EAAE;MACR,MAAMK,KAAK,GAAGR,WAAW,CAAC,CACxB,MAAM,CAAC,YAAY,CAAC,EACpB,QAAQ,CAAC,YAAY,CAAC,EACtB,gBAAgB,CAAC,YAAY,CAAC,EAC9B,QAAQ,CAAC,YAAY,CAAC,CACvB,CAAC;MACFI,MAAM,CAACK,OAAO,CAAEC,WAAW,IAAK;QAC9BF,KAAK,CAACG,IAAI,CAAC,CACTD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description": "A command line interface to manage ForgeRock Identity Cloud tenants, ForgeOps deployments, and classic deployments.",
|
|
6
6
|
"keywords": [
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
]
|
|
100
100
|
},
|
|
101
101
|
"dependencies": {
|
|
102
|
-
"@rockcarver/frodo-lib": "2.0.0-
|
|
102
|
+
"@rockcarver/frodo-lib": "2.0.0-8",
|
|
103
103
|
"chokidar": "^3.5.3",
|
|
104
104
|
"cli-progress": "^3.11.2",
|
|
105
105
|
"cli-table3": "^0.6.3",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logs-fetch.js","names":["FrodoCommand","sourcesOptionM","Option","frodo","state","config","printMessage","fetchLogs","provisionCreds","SECONDS_IN_30_DAYS","SECONDS_IN_1_HOUR","LOG_TIME_WINDOW_MAX","LOG_TIME_WINDOW_INCREMENT","program","description","addOption","default","cloud","log","resolveLevel","FRODO_LOG_NOISEFILTER_FILENAME","action","host","user","password","options","command","handleDefaultArgsAndOpts","credsFromParameters","conn","getConnectionProfile","setHost","tenant","logApiKey","logApiSecret","setLogApiKey","setLogApiSecret","username","getUsername","getPassword","setUsername","setPassword","login","getTokens","creds","api_key_id","api_key_secret","now","Date","nowString","toISOString","beginTimestamp","tempStartDate","setTime","tempEndDate","endTimestamp","beginTs","parse","endTs","intermediateEndTs","opts","sources","level","saveConnectionProfile","timeIncrement","transactionId","searchString","getNoiseFilters","defaults"],"sources":["cli/logging/logs-fetch.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { sourcesOptionM } from './logs';\nimport { Option } from 'commander';\nimport { frodo, state } from '@rockcarver/frodo-lib';\nimport * as config from '../../utils/Config';\nimport { printMessage } from '../../utils/Console';\nimport { fetchLogs, provisionCreds } from '../../ops/LogOps';\n\nconst SECONDS_IN_30_DAYS = 2592000;\nconst SECONDS_IN_1_HOUR = 3600;\nconst LOG_TIME_WINDOW_MAX = SECONDS_IN_30_DAYS;\nconst LOG_TIME_WINDOW_INCREMENT = 1;\n\nconst program = new FrodoCommand('frodo logs fetch', ['realm', 'type']);\nprogram\n .description(\n 'Fetch Identity Cloud logs between a specified begin and end time period.\\\n WARNING: depending on filters and time period specified, this could take substantial time to complete.'\n )\n .addOption(sourcesOptionM)\n .addOption(\n new Option(\n '-l, --level <level>',\n 'Set log level filter. You can specify the level as a number or a string. \\\nFollowing values are possible (values on the same line are equivalent): \\\n\\n0, SEVERE, FATAL, or ERROR\\n1, WARNING, WARN or CONFIG\\\n\\n2, INFO or INFORMATION\\n3, DEBUG, FINE, FINER or FINEST\\\n\\n4 or ALL'\n ).default('ERROR', `${frodo.cloud.log.resolveLevel('ERROR')}`)\n )\n .addOption(\n new Option('-t, --transaction-id <txid>', 'Filter by transactionId')\n )\n .addOption(\n new Option(\n '-b, --begin-timestamp <beginTs>',\n 'Begin timestamp for period (in ISO8601, example: \"2022-10-13T19:06:28Z\", or \"2022-09.30\". \\\nCannot be more than 30 days in the past. If not specified, logs from one hour ago are fetched \\\n(-e is ignored)'\n )\n )\n .addOption(\n new Option(\n '-e, --end-timestamp <endTs>',\n 'End timestamp for period. Default: \"now\"'\n )\n )\n .addOption(\n new Option(\n '-s, --search-string <ss>',\n 'Filter by a specific string (ANDed with transactionID filter)'\n )\n )\n .addOption(\n new Option('-d, --defaults', 'Use default logging noise filters').default(\n false,\n `Use custom logging noise filters defined in $HOME/${config.FRODO_LOG_NOISEFILTER_FILENAME}`\n )\n )\n .action(async (host, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(host, user, password, options, command);\n let credsFromParameters = true;\n const conn = await frodo.conn.getConnectionProfile();\n if (conn) {\n state.setHost(conn.tenant);\n if (conn.logApiKey != null && conn.logApiSecret != null) {\n credsFromParameters = false;\n state.setLogApiKey(conn.logApiKey);\n state.setLogApiSecret(conn.logApiSecret);\n } else {\n if (conn.username == null && conn.password == null) {\n if (!state.getUsername() && !state.getPassword()) {\n credsFromParameters = false;\n printMessage(\n 'User credentials not specified as parameters and no saved API key and secret found!',\n 'warn'\n );\n return;\n }\n } else {\n state.setUsername(conn.username);\n state.setPassword(conn.password);\n }\n if (await frodo.login.getTokens(true)) {\n const creds = await provisionCreds();\n state.setLogApiKey(creds.api_key_id as string);\n state.setLogApiSecret(creds.api_key_secret as string);\n }\n }\n const now = Date.now() / 1000;\n const nowString = new Date(now * 1000).toISOString();\n if (\n typeof options.beginTimestamp === 'undefined' ||\n !options.beginTimestamp\n ) {\n // no beginTimestamp value specified, default is 1 hour ago\n const tempStartDate = new Date();\n tempStartDate.setTime((now - SECONDS_IN_1_HOUR) * 1000);\n options.beginTimestamp = tempStartDate.toISOString();\n // also override endTimestamp to now\n const tempEndDate = new Date();\n tempEndDate.setTime(now * 1000);\n options.endTimestamp = tempEndDate;\n printMessage(\n 'No timestamps specified, defaulting to logs from 1 hour ago',\n 'info'\n );\n }\n if (\n typeof options.endTimestamp === 'undefined' ||\n !options.endTimestamp\n ) {\n // no endTimestamp value specified, default is now\n options.endTimestamp = nowString;\n printMessage(\n 'No end timestamp specified, defaulting end timestamp to \"now\"',\n 'info'\n );\n }\n let beginTs = Date.parse(options.beginTimestamp) / 1000;\n const endTs = Date.parse(options.endTimestamp) / 1000;\n if (endTs < beginTs) {\n printMessage(\n 'End timestamp can not be before begin timestamp',\n 'error'\n );\n return;\n }\n if (now - beginTs > LOG_TIME_WINDOW_MAX) {\n printMessage(\n 'Begin timestamp can not be more than 30 days in the past',\n 'error'\n );\n return;\n }\n let intermediateEndTs = 0;\n printMessage(\n `Fetching ID Cloud logs from the following sources: ${\n command.opts().sources\n } and levels [${frodo.cloud.log.resolveLevel(\n command.opts().level\n )}] of ${conn.tenant}...`\n );\n if (credsFromParameters) await frodo.conn.saveConnectionProfile(host); // save new values if they were specified on CLI\n\n let timeIncrement = LOG_TIME_WINDOW_INCREMENT;\n if (endTs - beginTs > 30) {\n timeIncrement = timeIncrement * 30;\n }\n do {\n intermediateEndTs = beginTs + timeIncrement;\n await fetchLogs(\n command.opts().sources,\n new Date(beginTs * 1000).toISOString(),\n new Date(intermediateEndTs * 1000).toISOString(),\n frodo.cloud.log.resolveLevel(command.opts().level),\n command.opts().transactionId,\n command.opts().searchString,\n null,\n config.getNoiseFilters(options.defaults)\n );\n beginTs = intermediateEndTs;\n } while (intermediateEndTs < endTs);\n }\n });\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,cAAc,QAAQ,QAAQ;AACvC,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,OAAO,KAAKC,MAAM,MAAM,oBAAoB;AAC5C,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,SAAS,EAAEC,cAAc,QAAQ,kBAAkB;AAE5D,MAAMC,kBAAkB,GAAG,OAAO;AAClC,MAAMC,iBAAiB,GAAG,IAAI;AAC9B,MAAMC,mBAAmB,GAAGF,kBAAkB;AAC9C,MAAMG,yBAAyB,GAAG,CAAC;AAEnC,MAAMC,OAAO,GAAG,IAAIb,YAAY,CAAC,kBAAkB,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AACvEa,OAAO,CACJC,WAAW,CACV;AACJ,wGACE,CAAC,CACAC,SAAS,CAACd,cAAc,CAAC,CACzBc,SAAS,CACR,IAAIb,MAAM,CACR,qBAAqB,EACrB;AACN;AACA;AACA;AACA,WACI,CAAC,CAACc,OAAO,CAAC,OAAO,EAAG,GAAEb,KAAK,CAACc,KAAK,CAACC,GAAG,CAACC,YAAY,CAAC,OAAO,CAAE,EAAC,CAC/D,CAAC,CACAJ,SAAS,CACR,IAAIb,MAAM,CAAC,6BAA6B,EAAE,yBAAyB,CACrE,CAAC,CACAa,SAAS,CACR,IAAIb,MAAM,CACR,iCAAiC,EACjC;AACN;AACA,gBACI,CACF,CAAC,CACAa,SAAS,CACR,IAAIb,MAAM,CACR,6BAA6B,EAC7B,0CACF,CACF,CAAC,CACAa,SAAS,CACR,IAAIb,MA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AACM,YAAY,EAC3B,IAAI,EACJ7D,MAAM,CAAC8D,eAAe,CAAC1C,OAAO,CAAC2C,QAAQ,CACzC,CAAC;MACDZ,OAAO,GAAGG,iBAAiB;IAC7B,CAAC,QAAQA,iBAAiB,GAAGD,KAAK;EACpC;AACF,CAAC,CAAC;AAEJ7C,OAAO,CAAC4C,KAAK,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logs-list.js","names":["FrodoCommand","frodo","state","printMessage","verboseMessage","provisionCreds","program","description","action","host","user","password","options","command","handleDefaultArgsAndOpts","credsFromParameters","conn","getConnectionProfile","setHost","tenant","logApiKey","logApiSecret","setLogApiKey","setLogApiSecret","username","getUsername","getPassword","setUsername","setPassword","login","getTokens","creds","api_key_id","api_key_secret","sources","cloud","log","getLogSources","length","saveConnectionProfile","forEach","source","parse"],"sources":["cli/logging/logs-list.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { frodo, state } from '@rockcarver/frodo-lib';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { provisionCreds } from '../../ops/LogOps';\n\nconst program = new FrodoCommand('frodo logs list', ['realm', 'type']);\nprogram\n .description('List available ID Cloud log sources.')\n .action(async (host, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(host, user, password, options, command);\n let credsFromParameters = true;\n verboseMessage('Listing available ID Cloud log sources...');\n const conn = await frodo.conn.getConnectionProfile();\n if (conn) {\n state.setHost(conn.tenant);\n if (conn.logApiKey != null && conn.logApiSecret != null) {\n credsFromParameters = false;\n state.setLogApiKey(conn.logApiKey);\n state.setLogApiSecret(conn.logApiSecret);\n } else {\n if (conn.username == null && conn.password == null) {\n if (!state.getUsername() && !state.getPassword()) {\n credsFromParameters = false;\n printMessage(\n 'User credentials not specified as parameters and no saved API key and secret found!',\n 'warn'\n );\n return;\n }\n } else {\n state.setUsername(conn.username);\n state.setPassword(conn.password);\n }\n if (await frodo.login.getTokens(true)) {\n const creds = await provisionCreds();\n state.setLogApiKey(creds.api_key_id as string);\n state.setLogApiSecret(creds.api_key_secret as string);\n }\n }\n\n const sources = await frodo.cloud.log.getLogSources();\n if (sources.length === 0) {\n printMessage(\n \"Can't get sources, possible cause - wrong API key or secret\",\n 'error'\n );\n } else {\n if (credsFromParameters) await frodo.conn.saveConnectionProfile(host); // save new values if they were specified on CLI\n printMessage(`Log sources from ${conn.tenant}`);\n sources.forEach((source) => {\n printMessage(`${source}`, 'data');\n });\n printMessage(\n 'Use any combination of comma separated sources, example:',\n 'info'\n );\n printMessage(`$ frodo logs tail -c am-core,idm-core ${host}`, 'text');\n }\n }\n });\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SAASC,cAAc,QAAQ,kBAAkB;AAEjD,MAAMC,OAAO,GAAG,IAAIN,YAAY,CAAC,iBAAiB,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AACtEM,OAAO,CACJC,WAAW,CAAC,sCAAsC,CAAC,CACnDC,MAAM,CAAC,OAAOC,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EACxDA,OAAO,CAACC,wBAAwB,CAACL,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,CAAC;EACxE,IAAIE,mBAAmB,GAAG,IAAI;EAC9BX,cAAc,CAAC,2CAA2C,CAAC;EAC3D,MAAMY,IAAI,GAAG,MAAMf,KAAK,CAACe,IAAI,CAACC,oBAAoB,CAAC,CAAC;EACpD,IAAID,IAAI,EAAE;IACRd,KAAK,CAACgB,OAAO,CAACF,IAAI,CAACG,MAAM,CAAC;IAC1B,IAAIH,IAAI,CAACI,SAAS,IAAI,IAAI,IAAIJ,IAAI,CAACK,YAAY,IAAI,IAAI,EAAE;M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IAAK;QAC1BtC,YAAY,CAAE,GAAEsC,MAAO,EAAC,EAAE,MAAM,CAAC;MACnC,CAAC,CAAC;MACFtC,YAAY,CACV,0DAA0D,EAC1D,MACF,CAAC;MACDA,YAAY,CAAE,yCAAwCM,IAAK,EAAC,EAAE,MAAM,CAAC;IACvE;EACF;AACF,CAAC,CAAC;AAEJH,OAAO,CAACoC,KAAK,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logs-tail.js","names":["FrodoCommand","sourcesOptionM","Option","frodo","state","config","printMessage","provisionCreds","tailLogs","program","description","addOption","default","cloud","log","resolveLevel","FRODO_LOG_NOISEFILTER_FILENAME","action","host","user","password","options","command","handleDefaultArgsAndOpts","credsFromParameters","conn","getConnectionProfile","setHost","tenant","logApiKey","logApiSecret","setLogApiKey","setLogApiSecret","username","getUsername","getPassword","setUsername","setPassword","login","getTokens","creds","api_key_id","api_key_secret","opts","sources","level","saveConnectionProfile","transactionId","getNoiseFilters","defaults","parse"],"sources":["cli/logging/logs-tail.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { sourcesOptionM } from './logs';\nimport { Option } from 'commander';\nimport { frodo, state } from '@rockcarver/frodo-lib';\nimport * as config from '../../utils/Config';\nimport { printMessage } from '../../utils/Console';\nimport { provisionCreds, tailLogs } from '../../ops/LogOps';\n\nconst program = new FrodoCommand('frodo logs tail', ['realm', 'type']);\nprogram\n .description('Tail Identity Cloud logs.')\n .addOption(sourcesOptionM)\n .addOption(\n new Option(\n '-l, --level <level>',\n 'Set log level filter. You can specify the level as a number or a string. \\\nFollowing values are possible (values on the same line are equivalent): \\\n\\n0, SEVERE, FATAL, or ERROR\\n1, WARNING, WARN or CONFIG\\\n\\n2, INFO or INFORMATION\\n3, DEBUG, FINE, FINER or FINEST\\\n\\n4 or ALL'\n ).default('ERROR', `${frodo.cloud.log.resolveLevel('ERROR')}`)\n )\n .addOption(\n new Option('-t, --transaction-id <txid>', 'Filter by transactionId')\n )\n .addOption(\n new Option('-d, --defaults', 'Use default logging noise filters').default(\n false,\n `Use custom logging noise filters defined in $HOME/${config.FRODO_LOG_NOISEFILTER_FILENAME}`\n )\n )\n .action(async (host, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(host, user, password, options, command);\n let credsFromParameters = true;\n const conn = await frodo.conn.getConnectionProfile();\n if (conn) {\n state.setHost(conn.tenant);\n if (conn.logApiKey != null && conn.logApiSecret != null) {\n credsFromParameters = false;\n state.setLogApiKey(conn.logApiKey);\n state.setLogApiSecret(conn.logApiSecret);\n } else {\n if (conn.username == null && conn.password == null) {\n if (!state.getUsername() && !state.getPassword()) {\n credsFromParameters = false;\n printMessage(\n 'User credentials not specified as parameters and no saved API key and secret found!',\n 'warn'\n );\n return;\n }\n } else {\n state.setUsername(conn.username);\n state.setPassword(conn.password);\n }\n if (await frodo.login.getTokens(true)) {\n const creds = await provisionCreds();\n state.setLogApiKey(creds.api_key_id as string);\n state.setLogApiSecret(creds.api_key_secret as string);\n }\n }\n printMessage(\n `Tailing ID Cloud logs from the following sources: ${\n command.opts().sources\n } and levels [${frodo.cloud.log.resolveLevel(\n command.opts().level\n )}] of ${conn.tenant}...`\n );\n if (credsFromParameters) await frodo.conn.saveConnectionProfile(host); // save new values if they were specified on CLI\n await tailLogs(\n command.opts().sources,\n frodo.cloud.log.resolveLevel(command.opts().level),\n command.opts().transactionId,\n null,\n config.getNoiseFilters(options.defaults)\n );\n }\n });\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,cAAc,QAAQ,QAAQ;AACvC,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,OAAO,KAAKC,MAAM,MAAM,oBAAoB;AAC5C,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,cAAc,EAAEC,QAAQ,QAAQ,kBAAkB;AAE3D,MAAMC,OAAO,GAAG,IAA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3B,OAAO,CAAC4B,QAAQ,CACzC,CAAC;EACH;AACF,CAAC,CAAC;AAEJxC,OAAO,CAACyC,KAAK,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logs.js","names":["FrodoStubCommand","Option","path","fileURLToPath","__dirname","dirname","import","meta","url","sourcesOptionM","makeOptionMandatory","default","setup","program","summary","description","executableDir","command"],"sources":["cli/logging/logs.ts"],"sourcesContent":["import { FrodoStubCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nexport const sourcesOptionM = new Option(\n '-c, --sources <sources>',\n 'Comma separated list of log sources'\n)\n .makeOptionMandatory()\n .default('am-everything,idm-everything', 'Log everything');\n\nexport default function setup() {\n const program = new FrodoStubCommand('logs')\n .summary('List/View Identity Cloud logs')\n .description(\n `View Identity Cloud logs. If valid tenant admin credentials are specified, a log API key and secret are automatically created for that admin user.`\n )\n .executableDir(__dirname);\n\n program.command('list', 'List available ID Cloud log sources.');\n\n program.command('tail', 'Tail Identity Cloud logs.');\n\n program.command('fetch', 'Fetch Identity Cloud logs for a time window.');\n\n return program;\n}\n"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,iBAAiB;AAClD,SAASC,MAAM,QAAQ,WAAW;AAClC,OAAOC,IAAI,MAAM,MAAM;AACvB,SAASC,aAAa,QAAQ,KAAK;AAEnC,MAAMC,SAAS,GAAGF,IAAI,CAACG,OAAO,CAACF,aAAa,CAACG,MAAM,CAACC,IAAI,CAACC,GAAG,CAAC,CAAC;AAE9D,OAAO,MAAMC,cAAc,GAAG,IAAIR,MAAM,CACtC,yBAAyB,EACzB,qCACF,CAAC,CACES,mBAAmB,CAAC,CAAC,CACrBC,OAAO,CAAC,8BAA8B,EAAE,gBAAgB,CAAC;AAE5D,eAAe,SAASC,KAAKA,CAAA,EAAG;EAC9B,MAAMC,OAAO,GAAG,IAAIb,gBAAgB,CAAC,MAAM,CAAC,CACzCc,OAAO,CAAC,+BAA+B,CAAC,CACxCC,WAAW,CACT,oJACH,CAAC,CACAC,aAAa,CAACZ,SAAS,CAAC;EAE3BS,OAAO,CAACI,OAAO,CAAC,MAAM,EAAE,sCAAsC,CAAC;EAE/DJ,OAAO,CAACI,OAAO,CAAC,MAAM,EAAE,2BAA2B,CAAC;EAEpDJ,OAAO,CAACI,OAAO,CAAC,OAAO,EAAE,8CAA8C,CAAC;EAExE,OAAOJ,OAAO;AAChB"}
|