@rockcarver/frodo-cli 0.24.6-0 → 0.24.6-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,40 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.24.6-2] - 2023-06-22
11
+
12
+ ## [0.24.6-1] - 2023-06-22
13
+
14
+ ### Added
15
+
16
+ - \#251: Support for Identity Cloud admin federation configuration:
17
+
18
+ - `frodo admin federation` Manage admin federation configuration.
19
+ - `export` Export admin federation providers.
20
+ - `import` Import admin federation providers.
21
+ - `list` List admin federation providers.
22
+
23
+ Examples:
24
+
25
+ - List all configured admin federation providers:<br>
26
+ `frodo admin federation list <myTenant>`
27
+
28
+ `frodo admin federation list <myTenant> <username> <password>`
29
+ - Export all admin federation providers to a single file:<br>
30
+ `frodo admin federation export -a <myTenant>`
31
+
32
+ `frodo admin federation export -a <myTenant> <username> <password>`
33
+ - Import all admin federation providers from a single file:<br>
34
+ `frodo admin federation import -a -f allProviders.admin.federation.json <myTenant>`
35
+
36
+ `frodo admin federation import -a -f allProviders.admin.federation.json <myTenant> <username> <password>`<br>
37
+
38
+ **_Note_**: Only tenant admins can perform admin federation operations, service accounts do not have the required privileges. Therefore, the connection profile used must contain username and password or they must be provided through command arguments.
39
+
40
+ ### Changed
41
+
42
+ - Update to frodo-lib 1.0.1-0
43
+
10
44
  ## [0.24.6-0] - 2023-06-21
11
45
 
12
46
  ## [0.24.5] - 2023-05-31
@@ -1202,7 +1236,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1202
1236
  - Fixed problem with adding connection profiles
1203
1237
  - Miscellaneous bug fixes
1204
1238
 
1205
- [Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v0.24.6-0...HEAD
1239
+ [Unreleased]: https://github.com/rockcarver/frodo-cli/compare/v0.24.6-2...HEAD
1240
+
1241
+ [0.24.6-2]: https://github.com/rockcarver/frodo-cli/compare/v0.24.6-1...v0.24.6-2
1242
+
1243
+ [0.24.6-1]: https://github.com/rockcarver/frodo-cli/compare/v0.24.6-0...v0.24.6-1
1206
1244
 
1207
1245
  [0.24.6-0]: https://github.com/rockcarver/frodo-cli/compare/v0.24.5...v0.24.6-0
1208
1246
 
@@ -0,0 +1,45 @@
1
+ import { FrodoCommand } from '../FrodoCommand';
2
+ import { Option } from 'commander';
3
+ import { Authenticate } from '@rockcarver/frodo-lib';
4
+ import { printMessage, verboseMessage } from '../../utils/Console';
5
+ import { exportAdminFederationProviderToFile, exportAdminFederationProvidersToFile, exportAdminFederationProvidersToFiles } from '../../ops/AdminFederationOps';
6
+ const {
7
+ getTokens
8
+ } = Authenticate;
9
+ const program = new FrodoCommand('frodo admin federation export', ['realm']);
10
+ program.description('Export admin federation providers.').addOption(new Option('-i, --idp-id <idp-id>', 'Id/name of a provider. If specified, -a and -A are ignored.')).addOption(new Option('-f, --file [file]', 'Name of the file to write the exported provider(s) to. Ignored with -A.')).addOption(new Option('-a, --all', 'Export all the providers to a single file. Ignored with -t and -i.')).addOption(new Option('-A, --all-separate', 'Export all the providers as separate files <provider name>.admin.federation.json. Ignored with -t, -i, and -a.')).action(
11
+ // implement command logic inside action handler
12
+ async (host, user, password, options, command) => {
13
+ command.handleDefaultArgsAndOpts(host, user, password, options, command);
14
+ if (await getTokens(true)) {
15
+ // export by id/name
16
+ if (options.idpId) {
17
+ verboseMessage(`Exporting provider "${options.idpId}...`);
18
+ const outcome = await exportAdminFederationProviderToFile(options.idpId, options.file);
19
+ if (!outcome) process.exitCode = 1;
20
+ }
21
+ // --all -a
22
+ else if (options.all) {
23
+ verboseMessage('Exporting all providers to a single file...');
24
+ const outcome = await exportAdminFederationProvidersToFile(options.file);
25
+ if (!outcome) process.exitCode = 1;
26
+ }
27
+ // --all-separate -A
28
+ else if (options.allSeparate) {
29
+ verboseMessage('Exporting all providers to separate files...');
30
+ const outcome = await exportAdminFederationProvidersToFiles();
31
+ if (!outcome) process.exitCode = 1;
32
+ }
33
+ // unrecognized combination of options or no options
34
+ else {
35
+ printMessage('Unrecognized combination of options or no options...', 'error');
36
+ program.help();
37
+ process.exitCode = 1;
38
+ }
39
+ }
40
+ }
41
+ // end command logic inside action handler
42
+ );
43
+
44
+ program.parse();
45
+ //# sourceMappingURL=admin-federation-export.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-federation-export.js","names":["FrodoCommand","Option","Authenticate","printMessage","verboseMessage","exportAdminFederationProviderToFile","exportAdminFederationProvidersToFile","exportAdminFederationProvidersToFiles","getTokens","program","description","addOption","action","host","user","password","options","command","handleDefaultArgsAndOpts","idpId","outcome","file","process","exitCode","all","allSeparate","help","parse"],"sources":["cli/admin/admin-federation-export.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { Authenticate } from '@rockcarver/frodo-lib';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport {\n exportAdminFederationProviderToFile,\n exportAdminFederationProvidersToFile,\n exportAdminFederationProvidersToFiles,\n} from '../../ops/AdminFederationOps';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo admin federation export', ['realm']);\n\nprogram\n .description('Export admin federation providers.')\n .addOption(\n new Option(\n '-i, --idp-id <idp-id>',\n 'Id/name of a provider. If specified, -a and -A are ignored.'\n )\n )\n .addOption(\n new Option(\n '-f, --file [file]',\n 'Name of the file to write the exported provider(s) to. Ignored with -A.'\n )\n )\n .addOption(\n new Option(\n '-a, --all',\n 'Export all the providers to a single file. Ignored with -t and -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Export all the providers as separate files <provider name>.admin.federation.json. Ignored with -t, -i, and -a.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(host, user, password, options, command);\n if (await getTokens(true)) {\n // export by id/name\n if (options.idpId) {\n verboseMessage(`Exporting provider \"${options.idpId}...`);\n const outcome = await exportAdminFederationProviderToFile(\n options.idpId,\n options.file\n );\n if (!outcome) process.exitCode = 1;\n }\n // --all -a\n else if (options.all) {\n verboseMessage('Exporting all providers to a single file...');\n const outcome = await exportAdminFederationProvidersToFile(\n options.file\n );\n if (!outcome) process.exitCode = 1;\n }\n // --all-separate -A\n else if (options.allSeparate) {\n verboseMessage('Exporting all providers to separate files...');\n const outcome = await exportAdminFederationProvidersToFiles();\n if (!outcome) process.exitCode = 1;\n }\n // unrecognized combination of options or no options\n else {\n printMessage(\n 'Unrecognized combination of options or no options...',\n 'error'\n );\n program.help();\n process.exitCode = 1;\n }\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,YAAY,QAAQ,uBAAuB;AACpD,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SACEC,mCAAmC,EACnCC,oCAAoC,EACpCC,qCAAqC,QAChC,8BAA8B;AAErC,MAAM;EAAEC;AAAU,CAAC,GAAGN,YAAY;AAElC,MAAMO,OAAO,GAAG,IAAIT,YAAY,CAAC,+BAA+B,EAAE,CAAC,OAAO,CAAC,CAAC;AAE5ES,OAAO,CACJC,WAAW,CAAC,oCAAoC,CAAC,CACjDC,SAAS,CACR,IAAIV,MAAM,CACR,uBAAuB,EACvB,6DACF,CACF,CAAC,CACAU,SAAS,CACR,IAAIV,MAAM,CACR,mBAAmB,EACnB,yEACF,CACF,CAAC,CACAU,SAAS,CACR,IAAIV,MAAM,CACR,WAAW,EACX,oEACF,CACF,CAAC,CACAU,SAAS,CACR,IAAIV,MAAM,CACR,oBAAoB,EACpB,gHACF,CACF,CAAC,CACAW,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EAChDA,OAAO,CAACC,wBAAwB,CAACL,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,CAAC;EACxE,IAAI,MAAMT,SAAS,CAAC,IAAI,CAAC,EAAE;IACzB;IACA,IAAIQ,OAAO,CAACG,KAAK,EAAE;MACjBf,cAAc,CAAE,uBAAsBY,OAAO,CAACG,KAAM,KAAI,CAAC;MACzD,MAAMC,OAAO,GAAG,MAAMf,mCAAmC,CACvDW,OAAO,CAACG,KAAK,EACbH,OAAO,CAACK,IACV,CAAC;MACD,IAAI,CAACD,OAAO,EAAEE,OAAO,CAACC,QAAQ,GAAG,CAAC;IACpC;IACA;IAAA,KACK,IAAIP,OAAO,CAACQ,GAAG,EAAE;MACpBpB,cAAc,CAAC,6CAA6C,CAAC;MAC7D,MAAMgB,OAAO,GAAG,MAAMd,oCAAoC,CACxDU,OAAO,CAACK,IACV,CAAC;MACD,IAAI,CAACD,OAAO,EAAEE,OAAO,CAACC,QAAQ,GAAG,CAAC;IACpC;IACA;IAAA,KACK,IAAIP,OAAO,CAACS,WAAW,EAAE;MAC5BrB,cAAc,CAAC,8CAA8C,CAAC;MAC9D,MAAMgB,OAAO,GAAG,MAAMb,qCAAqC,CAAC,CAAC;MAC7D,IAAI,CAACa,OAAO,EAAEE,OAAO,CAACC,QAAQ,GAAG,CAAC;IACpC;IACA;IAAA,KACK;MACHpB,YAAY,CACV,sDAAsD,EACtD,OACF,CAAC;MACDM,OAAO,CAACiB,IAAI,CAAC,CAAC;MACdJ,OAAO,CAACC,QAAQ,GAAG,CAAC;IACtB;EACF;AACF;AACA;AACF,CAAC;;AAEHd,OAAO,CAACkB,KAAK,CAAC,CAAC"}
@@ -0,0 +1,49 @@
1
+ import { FrodoCommand } from '../FrodoCommand';
2
+ import { Option } from 'commander';
3
+ import { Authenticate } from '@rockcarver/frodo-lib';
4
+ import { printMessage, verboseMessage } from '../../utils/Console';
5
+ import { importAdminFederationProviderFromFile, importAdminFederationProvidersFromFile, importAdminFederationProvidersFromFiles, importFirstAdminFederationProviderFromFile } from '../../ops/AdminFederationOps';
6
+ const {
7
+ getTokens
8
+ } = Authenticate;
9
+ const program = new FrodoCommand('frodo admin federation import', ['realm']);
10
+ program.description('Import admin federation providers.').addOption(new Option('-i, --idp-id <id>', 'Provider id. If specified, -a and -A are ignored.')).addOption(new Option('-f, --file <file>', 'Name of the file to import the provider(s) from.')).addOption(new Option('-a, --all', 'Import all the providers from single file. Ignored with -t or -i.')).addOption(new Option('-A, --all-separate', 'Import all the providers from separate files (*.admin.federation.json) in the current directory. Ignored with -t or -i or -a.')).action(
11
+ // implement command logic inside action handler
12
+ async (host, user, password, options, command) => {
13
+ command.handleDefaultArgsAndOpts(host, user, password, options, command);
14
+ // import by id
15
+ if (options.file && options.idpId && (await getTokens(true))) {
16
+ verboseMessage(`Importing provider "${options.idpId}"...`);
17
+ const outcome = await importAdminFederationProviderFromFile(options.idpId, options.file);
18
+ if (!outcome) process.exitCode = 1;
19
+ }
20
+ // --all -a
21
+ else if (options.all && options.file && (await getTokens(true))) {
22
+ verboseMessage(`Importing all providers from a single file (${options.file})...`);
23
+ const outcome = await importAdminFederationProvidersFromFile(options.file);
24
+ if (!outcome) process.exitCode = 1;
25
+ }
26
+ // --all-separate -A
27
+ else if (options.allSeparate && !options.file && (await getTokens(true))) {
28
+ verboseMessage('Importing all providers from separate files in current directory...');
29
+ const outcome = await importAdminFederationProvidersFromFiles();
30
+ if (!outcome) process.exitCode = 1;
31
+ }
32
+ // import first provider from file
33
+ else if (options.file && (await getTokens(true))) {
34
+ verboseMessage(`Importing first provider from file "${options.file}"...`);
35
+ const outcome = await importFirstAdminFederationProviderFromFile(options.file);
36
+ if (!outcome) process.exitCode = 1;
37
+ }
38
+ // unrecognized combination of options or no options
39
+ else {
40
+ printMessage('Unrecognized combination of options or no options...');
41
+ program.help();
42
+ process.exitCode = 1;
43
+ }
44
+ }
45
+ // end command logic inside action handler
46
+ );
47
+
48
+ program.parse();
49
+ //# sourceMappingURL=admin-federation-import.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-federation-import.js","names":["FrodoCommand","Option","Authenticate","printMessage","verboseMessage","importAdminFederationProviderFromFile","importAdminFederationProvidersFromFile","importAdminFederationProvidersFromFiles","importFirstAdminFederationProviderFromFile","getTokens","program","description","addOption","action","host","user","password","options","command","handleDefaultArgsAndOpts","file","idpId","outcome","process","exitCode","all","allSeparate","help","parse"],"sources":["cli/admin/admin-federation-import.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Option } from 'commander';\nimport { Authenticate } from '@rockcarver/frodo-lib';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport {\n importAdminFederationProviderFromFile,\n importAdminFederationProvidersFromFile,\n importAdminFederationProvidersFromFiles,\n importFirstAdminFederationProviderFromFile,\n} from '../../ops/AdminFederationOps';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo admin federation import', ['realm']);\n\nprogram\n .description('Import admin federation providers.')\n .addOption(\n new Option(\n '-i, --idp-id <id>',\n 'Provider id. If specified, -a and -A are ignored.'\n )\n )\n .addOption(\n new Option(\n '-f, --file <file>',\n 'Name of the file to import the provider(s) from.'\n )\n )\n .addOption(\n new Option(\n '-a, --all',\n 'Import all the providers from single file. Ignored with -t or -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Import all the providers from separate files (*.admin.federation.json) in the current directory. Ignored with -t or -i or -a.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(host, user, password, options, command);\n // import by id\n if (options.file && options.idpId && (await getTokens(true))) {\n verboseMessage(`Importing provider \"${options.idpId}\"...`);\n const outcome = await importAdminFederationProviderFromFile(\n options.idpId,\n options.file\n );\n if (!outcome) process.exitCode = 1;\n }\n // --all -a\n else if (options.all && options.file && (await getTokens(true))) {\n verboseMessage(\n `Importing all providers from a single file (${options.file})...`\n );\n const outcome = await importAdminFederationProvidersFromFile(\n options.file\n );\n if (!outcome) process.exitCode = 1;\n }\n // --all-separate -A\n else if (\n options.allSeparate &&\n !options.file &&\n (await getTokens(true))\n ) {\n verboseMessage(\n 'Importing all providers from separate files in current directory...'\n );\n const outcome = await importAdminFederationProvidersFromFiles();\n if (!outcome) process.exitCode = 1;\n }\n // import first provider from file\n else if (options.file && (await getTokens(true))) {\n verboseMessage(\n `Importing first provider from file \"${options.file}\"...`\n );\n const outcome = await importFirstAdminFederationProviderFromFile(\n options.file\n );\n if (!outcome) process.exitCode = 1;\n }\n // unrecognized combination of options or no options\n else {\n printMessage('Unrecognized combination of options or no options...');\n program.help();\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,MAAM,QAAQ,WAAW;AAClC,SAASC,YAAY,QAAQ,uBAAuB;AACpD,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SACEC,qCAAqC,EACrCC,sCAAsC,EACtCC,uCAAuC,EACvCC,0CAA0C,QACrC,8BAA8B;AAErC,MAAM;EAAEC;AAAU,CAAC,GAAGP,YAAY;AAElC,MAAMQ,OAAO,GAAG,IAAIV,YAAY,CAAC,+BAA+B,EAAE,CAAC,OAAO,CAAC,CAAC;AAE5EU,OAAO,CACJC,WAAW,CAAC,oCAAoC,CAAC,CACjDC,SAAS,CACR,IAAIX,MAAM,CACR,mBAAmB,EACnB,mDACF,CACF,CAAC,CACAW,SAAS,CACR,IAAIX,MAAM,CACR,mBAAmB,EACnB,kDACF,CACF,CAAC,CACAW,SAAS,CACR,IAAIX,MAAM,CACR,WAAW,EACX,mEACF,CACF,CAAC,CACAW,SAAS,CACR,IAAIX,MAAM,CACR,oBAAoB,EACpB,+HACF,CACF,CAAC,CACAY,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EAChDA,OAA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IACD,IAAI,CAACE,OAAO,EAAEC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC;EACA;EAAA,KACK;IACHrB,YAAY,CAAC,sDAAsD,CAAC;IACpEO,OAAO,CAACiB,IAAI,CAAC,CAAC;IACdJ,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEHd,OAAO,CAACkB,KAAK,CAAC,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { FrodoCommand } from '../FrodoCommand';
2
+ import { Authenticate } from '@rockcarver/frodo-lib';
3
+ import { verboseMessage } from '../../utils/Console';
4
+ import { listAdminFederationProviders } from '../../ops/AdminFederationOps';
5
+ const {
6
+ getTokens
7
+ } = Authenticate;
8
+ const program = new FrodoCommand('frodo admin federation list', ['realm']);
9
+ program.description('List admin federation providers.')
10
+ // .addOption(
11
+ // new Option('-l, --long', 'Long with all fields.').default(false, 'false')
12
+ // )
13
+ .action(
14
+ // implement command logic inside action handler
15
+ async (host, user, password, options, command) => {
16
+ command.handleDefaultArgsAndOpts(host, user, password, options, command);
17
+ if (await getTokens(true)) {
18
+ verboseMessage(`Listing admin federation providers...`);
19
+ const outcome = await listAdminFederationProviders();
20
+ if (!outcome) process.exitCode = 1;
21
+ } else {
22
+ process.exitCode = 1;
23
+ }
24
+ }
25
+ // end command logic inside action handler
26
+ );
27
+
28
+ program.parse();
29
+ //# sourceMappingURL=admin-federation-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-federation-list.js","names":["FrodoCommand","Authenticate","verboseMessage","listAdminFederationProviders","getTokens","program","description","action","host","user","password","options","command","handleDefaultArgsAndOpts","outcome","process","exitCode","parse"],"sources":["cli/admin/admin-federation-list.ts"],"sourcesContent":["import { FrodoCommand } from '../FrodoCommand';\nimport { Authenticate } from '@rockcarver/frodo-lib';\nimport { verboseMessage } from '../../utils/Console';\nimport { listAdminFederationProviders } from '../../ops/AdminFederationOps';\n\nconst { getTokens } = Authenticate;\n\nconst program = new FrodoCommand('frodo admin federation list', ['realm']);\n\nprogram\n .description('List admin federation providers.')\n // .addOption(\n // new Option('-l, --long', 'Long with all fields.').default(false, 'false')\n // )\n .action(\n // implement command logic inside action handler\n async (host, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(host, user, password, options, command);\n if (await getTokens(true)) {\n verboseMessage(`Listing admin federation providers...`);\n const outcome = await listAdminFederationProviders();\n if (!outcome) process.exitCode = 1;\n } else {\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,YAAY,QAAQ,uBAAuB;AACpD,SAASC,cAAc,QAAQ,qBAAqB;AACpD,SAASC,4BAA4B,QAAQ,8BAA8B;AAE3E,MAAM;EAAEC;AAAU,CAAC,GAAGH,YAAY;AAElC,MAAMI,OAAO,GAAG,IAAIL,YAAY,CAAC,6BAA6B,EAAE,CAAC,OAAO,CAAC,CAAC;AAE1EK,OAAO,CACJC,WAAW,CAAC,kCAAkC;AAC/C;AACA;AACA;AAAA,CACCC,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EAChDA,OAAO,CAACC,wBAAwB,CAACL,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,CAAC;EACxE,IAAI,MAAMR,SAAS,CAAC,IAAI,CAAC,EAAE;IACzBF,cAAc,CAAE,uCAAsC,CAAC;IACvD,MAAMY,OAAO,GAAG,MAAMX,4BAA4B,CAAC,CAAC;IACpD,IAAI,CAACW,OAAO,EAAEC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACpC,CAAC,MAAM;IACLD,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEHX,OAAO,CAACY,KAAK,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { FrodoStubCommand } from '../FrodoCommand';
2
+ const program = new FrodoStubCommand('frodo admin federation');
3
+ program.description('Manages admin federation configuration.');
4
+
5
+ // program.command('delete', 'Delete admin federation provider.');
6
+
7
+ // program.command('describe', 'Describe admin federation provider.');
8
+
9
+ program.command('export', 'Export admin federation providers.');
10
+ program.command('import', 'Import admin federation providers.');
11
+ program.command('list', 'List admin federation providers.');
12
+ program.parse();
13
+ //# sourceMappingURL=admin-federation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-federation.js","names":["FrodoStubCommand","program","description","command","parse"],"sources":["cli/admin/admin-federation.ts"],"sourcesContent":["import { FrodoStubCommand } from '../FrodoCommand';\n\nconst program = new FrodoStubCommand('frodo admin federation');\n\nprogram.description('Manages admin federation configuration.');\n\n// program.command('delete', 'Delete admin federation provider.');\n\n// program.command('describe', 'Describe admin federation provider.');\n\nprogram.command('export', 'Export admin federation providers.');\n\nprogram.command('import', 'Import admin federation providers.');\n\nprogram.command('list', 'List admin federation providers.');\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,iBAAiB;AAElD,MAAMC,OAAO,GAAG,IAAID,gBAAgB,CAAC,wBAAwB,CAAC;AAE9DC,OAAO,CAACC,WAAW,CAAC,yCAAyC,CAAC;;AAE9D;;AAEA;;AAEAD,OAAO,CAACE,OAAO,CAAC,QAAQ,EAAE,oCAAoC,CAAC;AAE/DF,OAAO,CAACE,OAAO,CAAC,QAAQ,EAAE,oCAAoC,CAAC;AAE/DF,OAAO,CAACE,OAAO,CAAC,MAAM,EAAE,kCAAkC,CAAC;AAE3DF,OAAO,CAACG,KAAK,CAAC,CAAC"}
@@ -4,6 +4,7 @@ import { fileURLToPath } from 'url';
4
4
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
5
5
  export default function setup() {
6
6
  const program = new FrodoStubCommand('admin').description('Platform admin tasks.').executableDir(__dirname);
7
+ program.command('federation', 'Manage admin federation configuration.');
7
8
  program.command('create-oauth2-client-with-admin-privileges', 'Create an oauth2 client with admin privileges.');
8
9
  program.command('get-access-token', 'Get an access token using client credentials grant type.');
9
10
  program.command('list-oauth2-clients-with-admin-privileges', 'List oauth2 clients with admin privileges.');
@@ -1 +1 @@
1
- {"version":3,"file":"admin.js","names":["FrodoStubCommand","path","fileURLToPath","__dirname","dirname","import","meta","url","setup","program","description","executableDir","command"],"sources":["cli/admin/admin.ts"],"sourcesContent":["import { FrodoStubCommand } from '../FrodoCommand';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nexport default function setup() {\n const program = new FrodoStubCommand('admin')\n .description('Platform admin tasks.')\n .executableDir(__dirname);\n\n program.command(\n 'create-oauth2-client-with-admin-privileges',\n 'Create an oauth2 client with admin privileges.'\n );\n\n program.command(\n 'get-access-token',\n 'Get an access token using client credentials grant type.'\n );\n\n program.command(\n 'list-oauth2-clients-with-admin-privileges',\n 'List oauth2 clients with admin privileges.'\n );\n\n program.command(\n 'grant-oauth2-client-admin-privileges',\n 'Grant an oauth2 client admin privileges.'\n );\n\n program.command(\n 'revoke-oauth2-client-admin-privileges',\n 'Revoke admin privileges from an oauth2 client.'\n );\n\n program.command(\n 'list-oauth2-clients-with-custom-privileges',\n 'List oauth2 clients with custom privileges.'\n );\n\n program.command(\n 'list-static-user-mappings',\n 'List all subjects of static user mappings that are not oauth2 clients.'\n );\n\n program.command(\n 'remove-static-user-mapping',\n \"Remove a subject's static user mapping.\"\n );\n\n program.command(\n 'add-autoid-static-user-mapping',\n 'Add AutoId static user mapping to enable dashboards and other AutoId-based functionality.'\n );\n\n program.command(\n 'hide-generic-extension-attributes',\n 'Hide generic extension attributes.'\n );\n\n program.command(\n 'show-generic-extension-attributes',\n 'Show generic extension attributes.'\n );\n\n program.command('repair-org-model', 'Repair org model.');\n\n return program;\n}\n"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,iBAAiB;AAClD,OAAOC,IAAI,MAAM,MAAM;AACvB,SAASC,aAAa,QAAQ,KAAK;AAEnC,MAAMC,SAAS,GAAGF,IAAI,CAACG,OAAO,CAACF,aAAa,CAACG,MAAM,CAACC,IAAI,CAACC,GAAG,CAAC,CAAC;AAE9D,eAAe,SAASC,KAAKA,CAAA,EAAG;EAC9B,MAAMC,OAAO,GAAG,IAAIT,gBAAgB,CAAC,OAAO,CAAC,CAC1CU,WAAW,CAAC,uBAAuB,CAAC,CACpCC,aAAa,CAACR,SAAS,CAAC;EAE3BM,OAAO,CAACG,OAAO,CACb,4CAA4C,EAC5C,gDACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,kBAAkB,EAClB,0DACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,2CAA2C,EAC3C,4CACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,sCAAsC,EACtC,0CACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,uCAAuC,EACvC,gDACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,4CAA4C,EAC5C,6CACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,2BAA2B,EAC3B,wEACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,4BAA4B,EAC5B,yCACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,gCAAgC,EAChC,2FACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,mCAAmC,EACnC,oCACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,mCAAmC,EACnC,oCACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CAAC,kBAAkB,EAAE,mBAAmB,CAAC;EAExD,OAAOH,OAAO;AAChB"}
1
+ {"version":3,"file":"admin.js","names":["FrodoStubCommand","path","fileURLToPath","__dirname","dirname","import","meta","url","setup","program","description","executableDir","command"],"sources":["cli/admin/admin.ts"],"sourcesContent":["import { FrodoStubCommand } from '../FrodoCommand';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nexport default function setup() {\n const program = new FrodoStubCommand('admin')\n .description('Platform admin tasks.')\n .executableDir(__dirname);\n\n program.command('federation', 'Manage admin federation configuration.');\n\n program.command(\n 'create-oauth2-client-with-admin-privileges',\n 'Create an oauth2 client with admin privileges.'\n );\n\n program.command(\n 'get-access-token',\n 'Get an access token using client credentials grant type.'\n );\n\n program.command(\n 'list-oauth2-clients-with-admin-privileges',\n 'List oauth2 clients with admin privileges.'\n );\n\n program.command(\n 'grant-oauth2-client-admin-privileges',\n 'Grant an oauth2 client admin privileges.'\n );\n\n program.command(\n 'revoke-oauth2-client-admin-privileges',\n 'Revoke admin privileges from an oauth2 client.'\n );\n\n program.command(\n 'list-oauth2-clients-with-custom-privileges',\n 'List oauth2 clients with custom privileges.'\n );\n\n program.command(\n 'list-static-user-mappings',\n 'List all subjects of static user mappings that are not oauth2 clients.'\n );\n\n program.command(\n 'remove-static-user-mapping',\n \"Remove a subject's static user mapping.\"\n );\n\n program.command(\n 'add-autoid-static-user-mapping',\n 'Add AutoId static user mapping to enable dashboards and other AutoId-based functionality.'\n );\n\n program.command(\n 'hide-generic-extension-attributes',\n 'Hide generic extension attributes.'\n );\n\n program.command(\n 'show-generic-extension-attributes',\n 'Show generic extension attributes.'\n );\n\n program.command('repair-org-model', 'Repair org model.');\n\n return program;\n}\n"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,iBAAiB;AAClD,OAAOC,IAAI,MAAM,MAAM;AACvB,SAASC,aAAa,QAAQ,KAAK;AAEnC,MAAMC,SAAS,GAAGF,IAAI,CAACG,OAAO,CAACF,aAAa,CAACG,MAAM,CAACC,IAAI,CAACC,GAAG,CAAC,CAAC;AAE9D,eAAe,SAASC,KAAKA,CAAA,EAAG;EAC9B,MAAMC,OAAO,GAAG,IAAIT,gBAAgB,CAAC,OAAO,CAAC,CAC1CU,WAAW,CAAC,uBAAuB,CAAC,CACpCC,aAAa,CAACR,SAAS,CAAC;EAE3BM,OAAO,CAACG,OAAO,CAAC,YAAY,EAAE,wCAAwC,CAAC;EAEvEH,OAAO,CAACG,OAAO,CACb,4CAA4C,EAC5C,gDACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,kBAAkB,EAClB,0DACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,2CAA2C,EAC3C,4CACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,sCAAsC,EACtC,0CACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,uCAAuC,EACvC,gDACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,4CAA4C,EAC5C,6CACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,2BAA2B,EAC3B,wEACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,4BAA4B,EAC5B,yCACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,gCAAgC,EAChC,2FACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,mCAAmC,EACnC,oCACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CACb,mCAAmC,EACnC,oCACF,CAAC;EAEDH,OAAO,CAACG,OAAO,CAAC,kBAAkB,EAAE,mBAAmB,CAAC;EAExD,OAAOH,OAAO;AAChB"}
@@ -0,0 +1,216 @@
1
+ import fs from 'fs';
2
+ import { AdminFederation } from '@rockcarver/frodo-lib';
3
+ import { createProgressBar, debugMessage, failSpinner, printMessage, showSpinner, stopProgressBar, succeedSpinner, updateProgressBar } from '../utils/Console';
4
+ import { getTypedFilename, saveJsonToFile } from '../utils/ExportImportUtils';
5
+ const {
6
+ getAdminFederationProviders,
7
+ exportAdminFederationProvider,
8
+ exportAdminFederationProviders,
9
+ importAdminFederationProvider,
10
+ importFirstAdminFederationProvider,
11
+ importAdminFederationProviders
12
+ } = AdminFederation;
13
+
14
+ /**
15
+ * List providers
16
+ * @returns {Promise<boolean>} true if successful, false otherwise
17
+ */
18
+ export async function listAdminFederationProviders() {
19
+ let outcome = false;
20
+ try {
21
+ const providers = await getAdminFederationProviders();
22
+ providers.sort((a, b) => a._id.localeCompare(b._id));
23
+ providers.forEach(socialIdentityProvider => {
24
+ printMessage(`${socialIdentityProvider._id}`, 'data');
25
+ });
26
+ outcome = true;
27
+ } catch (err) {
28
+ printMessage(`listAdminFederationProviders ERROR: ${err.message}`, 'error');
29
+ printMessage(err, 'error');
30
+ }
31
+ return outcome;
32
+ }
33
+
34
+ /**
35
+ * Export provider by id
36
+ * @param {string} providerId provider id/name
37
+ * @param {string} file optional export file name
38
+ * @returns {Promise<boolean>} true if successful, false otherwise
39
+ */
40
+ export async function exportAdminFederationProviderToFile(providerId, file = '') {
41
+ let outcome = false;
42
+ let fileName = file;
43
+ if (!fileName) {
44
+ fileName = getTypedFilename(providerId, 'admin.federation');
45
+ }
46
+ createProgressBar(1, `Exporting ${providerId}`);
47
+ try {
48
+ updateProgressBar(`Writing file ${fileName}`);
49
+ const fileData = await exportAdminFederationProvider(providerId);
50
+ saveJsonToFile(fileData, fileName);
51
+ stopProgressBar(`Exported ${providerId['brightCyan']} to ${fileName['brightCyan']}.`);
52
+ outcome = true;
53
+ } catch (err) {
54
+ stopProgressBar(`${err}`);
55
+ printMessage(`${err}`, 'error');
56
+ }
57
+ return outcome;
58
+ }
59
+
60
+ /**
61
+ * Export all providers
62
+ * @param {string} file optional export file name
63
+ * @returns {Promise<boolean>} true if successful, false otherwise
64
+ */
65
+ export async function exportAdminFederationProvidersToFile(file = '') {
66
+ let outcome = false;
67
+ showSpinner(`Exporting all providers...`);
68
+ try {
69
+ let fileName = file;
70
+ if (!fileName) {
71
+ fileName = getTypedFilename(`allProviders`, 'admin.federation');
72
+ }
73
+ const fileData = await exportAdminFederationProviders();
74
+ saveJsonToFile(fileData, fileName);
75
+ succeedSpinner(`Exported all providers to ${fileName}`);
76
+ outcome = true;
77
+ } catch (error) {
78
+ var _error$response;
79
+ failSpinner(`Error exporting all providers.`);
80
+ printMessage(((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data) || error, 'error');
81
+ }
82
+ return outcome;
83
+ }
84
+
85
+ /**
86
+ * Export all providers to individual files
87
+ * @returns {Promise<boolean>} true if successful, false otherwise
88
+ */
89
+ export async function exportAdminFederationProvidersToFiles() {
90
+ let outcome = false;
91
+ try {
92
+ const allIdpsData = await getAdminFederationProviders();
93
+ createProgressBar(allIdpsData.length, 'Exporting providers');
94
+ for (const idpData of allIdpsData) {
95
+ updateProgressBar(`Writing provider ${idpData._id}`);
96
+ const fileName = getTypedFilename(idpData._id, 'admin.federation');
97
+ const fileData = await exportAdminFederationProvider(idpData._id);
98
+ saveJsonToFile(fileData, fileName);
99
+ }
100
+ stopProgressBar(`${allIdpsData.length} providers exported.`);
101
+ outcome = true;
102
+ } catch (error) {
103
+ var _error$response2;
104
+ failSpinner(`Error exporting all providers.`);
105
+ printMessage(((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.data) || error, 'error');
106
+ }
107
+ return outcome;
108
+ }
109
+
110
+ /**
111
+ * Import provider by id/name
112
+ * @param {string} providerId provider id/name
113
+ * @param {string} file import file name
114
+ * @returns {Promise<boolean>} true if successful, false otherwise
115
+ */
116
+ export async function importAdminFederationProviderFromFile(providerId, file) {
117
+ let outcome = false;
118
+ showSpinner(`Importing provider ${providerId} from ${file}...`);
119
+ try {
120
+ const data = fs.readFileSync(file, 'utf8');
121
+ const fileData = JSON.parse(data);
122
+ await importAdminFederationProvider(providerId, fileData);
123
+ succeedSpinner(`Successfully imported provider ${providerId} from ${file}.`);
124
+ outcome = true;
125
+ } catch (error) {
126
+ var _error$response3;
127
+ failSpinner(`Error importing provider ${providerId} from ${file}.`);
128
+ printMessage(((_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data) || error, 'error');
129
+ }
130
+ return outcome;
131
+ }
132
+
133
+ /**
134
+ * Import first provider from file
135
+ * @param {String} file import file name
136
+ * @returns {Promise<boolean>} true if successful, false otherwise
137
+ */
138
+ export async function importFirstAdminFederationProviderFromFile(file) {
139
+ let outcome = false;
140
+ debugMessage(`cli.AdminFederationOps.importFirstAdminFederationProviderFromFile: begin`);
141
+ showSpinner(`Importing first provider from ${file}...`);
142
+ try {
143
+ const data = fs.readFileSync(file, 'utf8');
144
+ const fileData = JSON.parse(data);
145
+ await importFirstAdminFederationProvider(fileData);
146
+ succeedSpinner(`Successfully imported first provider from ${file}.`);
147
+ outcome = true;
148
+ } catch (error) {
149
+ var _error$response4;
150
+ failSpinner(`Error importing first provider from ${file}.`);
151
+ printMessage(((_error$response4 = error.response) === null || _error$response4 === void 0 ? void 0 : _error$response4.data) || error, 'error');
152
+ }
153
+ debugMessage(`cli.AdminFederationOps.importFirstAdminFederationProviderFromFile: end`);
154
+ return outcome;
155
+ }
156
+
157
+ /**
158
+ * Import all providers from file
159
+ * @param {string} file import file name
160
+ * @returns {Promise<boolean>} true if successful, false otherwise
161
+ */
162
+ export async function importAdminFederationProvidersFromFile(file) {
163
+ let outcome = false;
164
+ debugMessage(`cli.AdminFederationOps.importAdminFederationProvidersFromFile: begin`);
165
+ showSpinner(`Importing providers from ${file}...`);
166
+ try {
167
+ const data = fs.readFileSync(file, 'utf8');
168
+ const fileData = JSON.parse(data);
169
+ await importAdminFederationProviders(fileData);
170
+ succeedSpinner(`Imported providers from ${file}.`);
171
+ outcome = true;
172
+ } catch (error) {
173
+ var _error$response5;
174
+ failSpinner(`Error importing ${file}.`);
175
+ printMessage(((_error$response5 = error.response) === null || _error$response5 === void 0 ? void 0 : _error$response5.data) || error, 'error');
176
+ }
177
+ debugMessage(`cli.AdminFederationOps.importAdminFederationProvidersFromFile: end`);
178
+ return outcome;
179
+ }
180
+
181
+ /**
182
+ * Import providers from *.idp.json files in current working directory
183
+ * @returns {Promise<boolean>} true if successful, false otherwise
184
+ */
185
+ export async function importAdminFederationProvidersFromFiles() {
186
+ const errors = [];
187
+ try {
188
+ debugMessage(`cli.AdminFederationOps.importAdminFederationProvidersFromFiles: begin`);
189
+ const names = fs.readdirSync('.');
190
+ const files = names.filter(name => name.toLowerCase().endsWith('.admin.federation.json'));
191
+ createProgressBar(files.length, 'Importing providers...');
192
+ let total = 0;
193
+ for (const file of files) {
194
+ try {
195
+ const data = fs.readFileSync(file, 'utf8');
196
+ const fileData = JSON.parse(data);
197
+ const count = Object.keys(fileData.idp).length;
198
+ total += count;
199
+ await importAdminFederationProviders(fileData);
200
+ updateProgressBar(`Imported ${count} provider(s) from ${file}`);
201
+ } catch (error) {
202
+ errors.push(error);
203
+ updateProgressBar(`Error importing provider(s) from ${file}`);
204
+ printMessage(error, 'error');
205
+ }
206
+ }
207
+ stopProgressBar(`Finished importing ${total} provider(s) from ${files.length} file(s).`);
208
+ } catch (error) {
209
+ errors.push(error);
210
+ stopProgressBar(`Error importing provider(s) from file(s).`);
211
+ printMessage(error, 'error');
212
+ }
213
+ debugMessage(`cli.AdminFederationOps.importAdminFederationProvidersFromFiles: end`);
214
+ return 0 === errors.length;
215
+ }
216
+ //# sourceMappingURL=AdminFederationOps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdminFederationOps.js","names":["fs","AdminFederation","createProgressBar","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getTypedFilename","saveJsonToFile","getAdminFederationProviders","exportAdminFederationProvider","exportAdminFederationProviders","importAdminFederationProvider","importFirstAdminFederationProvider","importAdminFederationProviders","listAdminFederationProviders","outcome","providers","sort","a","b","_id","localeCompare","forEach","socialIdentityProvider","err","message","exportAdminFederationProviderToFile","providerId","file","fileName","fileData","exportAdminFederationProvidersToFile","error","_error$response","response","data","exportAdminFederationProvidersToFiles","allIdpsData","length","idpData","_error$response2","importAdminFederationProviderFromFile","readFileSync","JSON","parse","_error$response3","importFirstAdminFederationProviderFromFile","_error$response4","importAdminFederationProvidersFromFile","_error$response5","importAdminFederationProvidersFromFiles","errors","names","readdirSync","files","filter","name","toLowerCase","endsWith","total","count","Object","keys","idp","push"],"sources":["ops/AdminFederationOps.ts"],"sourcesContent":["import fs from 'fs';\nimport { AdminFederation } from '@rockcarver/frodo-lib';\nimport {\n createProgressBar,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport { getTypedFilename, saveJsonToFile } from '../utils/ExportImportUtils';\n\nconst {\n getAdminFederationProviders,\n exportAdminFederationProvider,\n exportAdminFederationProviders,\n importAdminFederationProvider,\n importFirstAdminFederationProvider,\n importAdminFederationProviders,\n} = AdminFederation;\n\n/**\n * List providers\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function listAdminFederationProviders(): Promise<boolean> {\n let outcome = false;\n try {\n const providers = await getAdminFederationProviders();\n providers.sort((a, b) => a._id.localeCompare(b._id));\n providers.forEach((socialIdentityProvider) => {\n printMessage(`${socialIdentityProvider._id}`, 'data');\n });\n outcome = true;\n } catch (err) {\n printMessage(`listAdminFederationProviders ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n return outcome;\n}\n\n/**\n * Export provider by id\n * @param {string} providerId provider id/name\n * @param {string} file optional export file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportAdminFederationProviderToFile(\n providerId: string,\n file = ''\n): Promise<boolean> {\n let outcome = false;\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(providerId, 'admin.federation');\n }\n createProgressBar(1, `Exporting ${providerId}`);\n try {\n updateProgressBar(`Writing file ${fileName}`);\n const fileData = await exportAdminFederationProvider(providerId);\n saveJsonToFile(fileData, fileName);\n stopProgressBar(\n `Exported ${providerId['brightCyan']} to ${fileName['brightCyan']}.`\n );\n outcome = true;\n } catch (err) {\n stopProgressBar(`${err}`);\n printMessage(`${err}`, 'error');\n }\n return outcome;\n}\n\n/**\n * Export all providers\n * @param {string} file optional export file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportAdminFederationProvidersToFile(\n file = ''\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Exporting all providers...`);\n try {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`allProviders`, 'admin.federation');\n }\n const fileData = await exportAdminFederationProviders();\n saveJsonToFile(fileData, fileName);\n succeedSpinner(`Exported all providers to ${fileName}`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting all providers.`);\n printMessage(error.response?.data || error, 'error');\n }\n return outcome;\n}\n\n/**\n * Export all providers to individual files\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function exportAdminFederationProvidersToFiles(): Promise<boolean> {\n let outcome = false;\n try {\n const allIdpsData = await getAdminFederationProviders();\n createProgressBar(allIdpsData.length, 'Exporting providers');\n for (const idpData of allIdpsData) {\n updateProgressBar(`Writing provider ${idpData._id}`);\n const fileName = getTypedFilename(idpData._id, 'admin.federation');\n const fileData = await exportAdminFederationProvider(idpData._id);\n saveJsonToFile(fileData, fileName);\n }\n stopProgressBar(`${allIdpsData.length} providers exported.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting all providers.`);\n printMessage(error.response?.data || error, 'error');\n }\n return outcome;\n}\n\n/**\n * Import provider by id/name\n * @param {string} providerId provider id/name\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importAdminFederationProviderFromFile(\n providerId: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n showSpinner(`Importing provider ${providerId} from ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await importAdminFederationProvider(providerId, fileData);\n succeedSpinner(\n `Successfully imported provider ${providerId} from ${file}.`\n );\n outcome = true;\n } catch (error) {\n failSpinner(`Error importing provider ${providerId} from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n return outcome;\n}\n\n/**\n * Import first provider from file\n * @param {String} file import file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importFirstAdminFederationProviderFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(\n `cli.AdminFederationOps.importFirstAdminFederationProviderFromFile: begin`\n );\n showSpinner(`Importing first provider from ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await importFirstAdminFederationProvider(fileData);\n succeedSpinner(`Successfully imported first provider from ${file}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error importing first provider from ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n debugMessage(\n `cli.AdminFederationOps.importFirstAdminFederationProviderFromFile: end`\n );\n return outcome;\n}\n\n/**\n * Import all providers from file\n * @param {string} file import file name\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importAdminFederationProvidersFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFile: begin`\n );\n showSpinner(`Importing providers from ${file}...`);\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n await importAdminFederationProviders(fileData);\n succeedSpinner(`Imported providers from ${file}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error importing ${file}.`);\n printMessage(error.response?.data || error, 'error');\n }\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFile: end`\n );\n return outcome;\n}\n\n/**\n * Import providers from *.idp.json files in current working directory\n * @returns {Promise<boolean>} true if successful, false otherwise\n */\nexport async function importAdminFederationProvidersFromFiles(): Promise<boolean> {\n const errors = [];\n try {\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFiles: begin`\n );\n const names = fs.readdirSync('.');\n const files = names.filter((name) =>\n name.toLowerCase().endsWith('.admin.federation.json')\n );\n createProgressBar(files.length, 'Importing providers...');\n let total = 0;\n for (const file of files) {\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n const count = Object.keys(fileData.idp).length;\n total += count;\n await importAdminFederationProviders(fileData);\n updateProgressBar(`Imported ${count} provider(s) from ${file}`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error importing provider(s) from ${file}`);\n printMessage(error, 'error');\n }\n }\n stopProgressBar(\n `Finished importing ${total} provider(s) from ${files.length} file(s).`\n );\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error importing provider(s) from file(s).`);\n printMessage(error, 'error');\n }\n debugMessage(\n `cli.AdminFederationOps.importAdminFederationProvidersFromFiles: end`\n );\n return 0 === errors.length;\n}\n"],"mappings":"AAAA,OAAOA,EAAE,MAAM,IAAI;AACnB,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SACEC,iBAAiB,EACjBC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,cAAc,EACdC,iBAAiB,QACZ,kBAAkB;AACzB,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,4BAA4B;AAE7E,MAAM;EACJC,2BAA2B;EAC3BC,6BAA6B;EAC7BC,8BAA8B;EAC9BC,6BAA6B;EAC7BC,kCAAkC;EAClCC;AACF,CAAC,GAAGhB,eAAe;;AAEnB;AACA;AACA;AACA;AACA,OAAO,eAAeiB,4BAA4BA,CAAA,EAAqB;EACrE,IAAIC,OAAO,GAAG,KAAK;EACnB,IAAI;IACF,MAAMC,SAAS,GAAG,MAAMR,2BAA2B,CAAC,CAAC;IACrDQ,SAAS,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACE,GAAG,CAACC,aAAa,CAACF,CAAC,CAACC,GAAG,CAAC,CAAC;IACpDJ,SAAS,CAACM,OAAO,CAAEC,sBAAsB,IAAK;MAC5CtB,YAAY,CAAE,GAAEsB,sBAAsB,CAACH,GAAI,EAAC,EAAE,MAAM,CAAC;IACvD,CAAC,CAAC;IACFL,OAAO,GAAG,IAAI;EAChB,CAAC,CAAC,OAAOS,GAAG,EAAE;IACZvB,YAAY,CAAE,uCAAsCuB,GAAG,CAACC,OAAQ,EAAC,EAAE,OAAO,CAAC;IAC3ExB,YAAY,CAACuB,GAAG,EAAE,OAAO,CAAC;EAC5B;EACA,OAAOT,OAAO;AAChB;;AAEA;AACA;AACA;AACA;AACA;AACA;AAC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.24.6-0",
3
+ "version": "0.24.6-2",
4
4
  "type": "module",
5
5
  "description": "A command line interface to manage ForgeRock Identity Cloud tenants, ForgeOps deployments, and classic deployments.",
6
6
  "keywords": [
@@ -99,7 +99,7 @@
99
99
  ]
100
100
  },
101
101
  "dependencies": {
102
- "@rockcarver/frodo-lib": "0.19.2",
102
+ "@rockcarver/frodo-lib": "1.0.1-0",
103
103
  "chokidar": "^3.5.3",
104
104
  "cli-progress": "^3.11.2",
105
105
  "cli-table3": "^0.6.3",