@rockcarver/frodo-cli 2.0.0-27 → 2.0.0-29

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.
Files changed (54) hide show
  1. package/CHANGELOG.md +26 -1
  2. package/esm/app.js +4 -0
  3. package/esm/app.js.map +1 -1
  4. package/esm/cli/FrodoCommand.js +10 -4
  5. package/esm/cli/FrodoCommand.js.map +1 -1
  6. package/esm/cli/admin/admin-get-access-token.js +1 -1
  7. package/esm/cli/admin/admin-get-access-token.js.map +1 -1
  8. package/esm/cli/admin/admin-grant-oauth2-client-admin-privileges.js +1 -1
  9. package/esm/cli/admin/admin-grant-oauth2-client-admin-privileges.js.map +1 -1
  10. package/esm/cli/admin/admin-list-oauth2-clients-with-admin-privileges.js +1 -1
  11. package/esm/cli/admin/admin-list-oauth2-clients-with-admin-privileges.js.map +1 -1
  12. package/esm/cli/admin/admin-list-oauth2-clients-with-custom-privileges.js +1 -1
  13. package/esm/cli/admin/admin-list-oauth2-clients-with-custom-privileges.js.map +1 -1
  14. package/esm/cli/admin/admin-list-static-user-mappings.js +1 -1
  15. package/esm/cli/admin/admin-list-static-user-mappings.js.map +1 -1
  16. package/esm/cli/authz/authz-policy-delete.js +2 -2
  17. package/esm/cli/authz/authz-policy-delete.js.map +1 -1
  18. package/esm/cli/authz/authz-set-delete.js +2 -2
  19. package/esm/cli/authz/authz-set-delete.js.map +1 -1
  20. package/esm/cli/authz/authz-type-delete.js +3 -3
  21. package/esm/cli/authz/authz-type-delete.js.map +1 -1
  22. package/esm/cli/esv/esv-secret-export.js +14 -3
  23. package/esm/cli/esv/esv-secret-export.js.map +1 -1
  24. package/esm/cli/esv/esv-secret.js +1 -2
  25. package/esm/cli/esv/esv-secret.js.map +1 -1
  26. package/esm/cli/esv/esv-variable-delete.js +2 -2
  27. package/esm/cli/esv/esv-variable-delete.js.map +1 -1
  28. package/esm/cli/esv/esv-variable-export.js +15 -4
  29. package/esm/cli/esv/esv-variable-export.js.map +1 -1
  30. package/esm/cli/esv/esv-variable.js +1 -2
  31. package/esm/cli/esv/esv-variable.js.map +1 -1
  32. package/esm/cli/journey/journey-describe.js +1 -0
  33. package/esm/cli/journey/journey-describe.js.map +1 -1
  34. package/esm/cli/journey/journey-export.js +11 -1
  35. package/esm/cli/journey/journey-export.js.map +1 -1
  36. package/esm/ops/CirclesOfTrustOps.js +1 -1
  37. package/esm/ops/CirclesOfTrustOps.js.map +1 -1
  38. package/esm/ops/OAuth2ClientOps.js.map +1 -1
  39. package/esm/ops/PolicyOps.js +5 -15
  40. package/esm/ops/PolicyOps.js.map +1 -1
  41. package/esm/ops/PolicySetOps.js +11 -10
  42. package/esm/ops/PolicySetOps.js.map +1 -1
  43. package/esm/ops/RealmOps.js +3 -3
  44. package/esm/ops/RealmOps.js.map +1 -1
  45. package/esm/ops/ResourceTypeOps.js +11 -25
  46. package/esm/ops/ResourceTypeOps.js.map +1 -1
  47. package/esm/ops/Saml2Ops.js +2 -2
  48. package/esm/ops/Saml2Ops.js.map +1 -1
  49. package/esm/ops/SecretsOps.js +73 -5
  50. package/esm/ops/SecretsOps.js.map +1 -1
  51. package/esm/ops/VariablesOps.js +82 -8
  52. package/esm/ops/VariablesOps.js.map +1 -1
  53. package/global-jest-setup.js +4 -0
  54. package/package.json +4 -3
@@ -1,6 +1,6 @@
1
1
  import { frodo } from '@rockcarver/frodo-lib';
2
2
  import { Option } from 'commander';
3
- import { deleteVariable, deleteVariables } from '../../ops/VariablesOps';
3
+ import { deleteVariableById, deleteVariables } from '../../ops/VariablesOps';
4
4
  import { printMessage, verboseMessage } from '../../utils/Console.js';
5
5
  import { FrodoCommand } from '../FrodoCommand';
6
6
  const {
@@ -14,7 +14,7 @@ async (host, realm, user, password, options, command) => {
14
14
  // delete by id
15
15
  if (options.variableId && (await getTokens())) {
16
16
  verboseMessage('Deleting variable...');
17
- deleteVariable(options.variableId);
17
+ deleteVariableById(options.variableId);
18
18
  }
19
19
  // --all -a
20
20
  else if (options.all && (await getTokens())) {
@@ -1 +1 @@
1
- {"version":3,"file":"esv-variable-delete.js","names":["frodo","Option","deleteVariable","deleteVariables","printMessage","verboseMessage","FrodoCommand","getTokens","login","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","variableId","all","help","process","exitCode","parse"],"sources":["../../../src/cli/esv/esv-variable-delete.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport { deleteVariable, deleteVariables } from '../../ops/VariablesOps';\nimport { printMessage, verboseMessage } from '../../utils/Console.js';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\n\nconst program = new FrodoCommand('frodo cmd sub2 delete');\n\nprogram\n .description('Delete variables.')\n .addOption(\n new Option(\n '-i, --variable-id <variable-id>',\n 'Variable id. If specified, -a is ignored.'\n )\n )\n .addOption(\n new Option('-a, --all', 'Delete all variable in a realm. Ignored with -i.')\n )\n .addOption(\n new Option(\n '--no-deep',\n 'No deep delete. This leaves orphaned configuration artifacts behind.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n // delete by id\n if (options.variableId && (await getTokens())) {\n verboseMessage('Deleting variable...');\n deleteVariable(options.variableId);\n }\n // --all -a\n else if (options.all && (await getTokens())) {\n verboseMessage('Deleting all variables...');\n deleteVariables();\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,KAAK,QAAQ,uBAAuB;AAC7C,SAASC,MAAM,QAAQ,WAAW;AAElC,SAASC,cAAc,EAAEC,eAAe,QAAQ,wBAAwB;AACxE,SAASC,YAAY,EAAEC,cAAc,QAAQ,wBAAwB;AACrE,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAM;EAAEC;AAAU,CAAC,GAAGP,KAAK,CAACQ,KAAK;AAEjC,MAAMC,OAAO,GAAG,IAAIH,YAAY,CAAC,uBAAuB,CAAC;AAEzDG,OAAO,CACJC,WAAW,CAAC,mBAAmB,CAAC,CAChCC,SAAS,CACR,IAAIV,MAAM,CACR,iCAAiC,EACjC,2CACF,CACF,CAAC,CACAU,SAAS,CACR,IAAIV,MAAM,CAAC,WAAW,EAAE,kDAAkD,CAC5E,CAAC,CACAU,SAAS,CACR,IAAIV,MAAM,CACR,WAAW,EACX,sEACF,CACF,CAAC,CACAW,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EACvDA,OAAO,CAACC,wBAAwB,CAC9BN,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,QAAQ,EACRC,OAAO,EACPC,OACF,CAAC;EACD;EACA,IAAID,OAAO,CAACG,UAAU,KAAK,MAAMb,SAAS,CAAC,CAAC,CAAC,EAAE;IAC7CF,cAAc,CAAC,sBAAsB,CAAC;IACtCH,cAAc,CAACe,OAAO,CAACG,UAAU,CAAC;EACpC;EACA;EAAA,KACK,IAAIH,OAAO,CAACI,GAAG,KAAK,MAAMd,SAAS,CAAC,CAAC,CAAC,EAAE;IAC3CF,cAAc,CAAC,2BAA2B,CAAC;IAC3CF,eAAe,CAAC,CAAC;EACnB;EACA;EAAA,KACK;IACHC,YAAY,CAAC,sDAAsD,CAAC;IACpEK,OAAO,CAACa,IAAI,CAAC,CAAC;IACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEHf,OAAO,CAACgB,KAAK,CAAC,CAAC"}
1
+ {"version":3,"file":"esv-variable-delete.js","names":["frodo","Option","deleteVariableById","deleteVariables","printMessage","verboseMessage","FrodoCommand","getTokens","login","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","variableId","all","help","process","exitCode","parse"],"sources":["../../../src/cli/esv/esv-variable-delete.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport { deleteVariableById, deleteVariables } from '../../ops/VariablesOps';\nimport { printMessage, verboseMessage } from '../../utils/Console.js';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\n\nconst program = new FrodoCommand('frodo cmd sub2 delete');\n\nprogram\n .description('Delete variables.')\n .addOption(\n new Option(\n '-i, --variable-id <variable-id>',\n 'Variable id. If specified, -a is ignored.'\n )\n )\n .addOption(\n new Option('-a, --all', 'Delete all variable in a realm. Ignored with -i.')\n )\n .addOption(\n new Option(\n '--no-deep',\n 'No deep delete. This leaves orphaned configuration artifacts behind.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n // delete by id\n if (options.variableId && (await getTokens())) {\n verboseMessage('Deleting variable...');\n deleteVariableById(options.variableId);\n }\n // --all -a\n else if (options.all && (await getTokens())) {\n verboseMessage('Deleting all variables...');\n deleteVariables();\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,KAAK,QAAQ,uBAAuB;AAC7C,SAASC,MAAM,QAAQ,WAAW;AAElC,SAASC,kBAAkB,EAAEC,eAAe,QAAQ,wBAAwB;AAC5E,SAASC,YAAY,EAAEC,cAAc,QAAQ,wBAAwB;AACrE,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAM;EAAEC;AAAU,CAAC,GAAGP,KAAK,CAACQ,KAAK;AAEjC,MAAMC,OAAO,GAAG,IAAIH,YAAY,CAAC,uBAAuB,CAAC;AAEzDG,OAAO,CACJC,WAAW,CAAC,mBAAmB,CAAC,CAChCC,SAAS,CACR,IAAIV,MAAM,CACR,iCAAiC,EACjC,2CACF,CACF,CAAC,CACAU,SAAS,CACR,IAAIV,MAAM,CAAC,WAAW,EAAE,kDAAkD,CAC5E,CAAC,CACAU,SAAS,CACR,IAAIV,MAAM,CACR,WAAW,EACX,sEACF,CACF,CAAC,CACAW,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EACvDA,OAAO,CAACC,wBAAwB,CAC9BN,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,QAAQ,EACRC,OAAO,EACPC,OACF,CAAC;EACD;EACA,IAAID,OAAO,CAACG,UAAU,KAAK,MAAMb,SAAS,CAAC,CAAC,CAAC,EAAE;IAC7CF,cAAc,CAAC,sBAAsB,CAAC;IACtCH,kBAAkB,CAACe,OAAO,CAACG,UAAU,CAAC;EACxC;EACA;EAAA,KACK,IAAIH,OAAO,CAACI,GAAG,KAAK,MAAMd,SAAS,CAAC,CAAC,CAAC,EAAE;IAC3CF,cAAc,CAAC,2BAA2B,CAAC;IAC3CF,eAAe,CAAC,CAAC;EACnB;EACA;EAAA,KACK;IACHC,YAAY,CAAC,sDAAsD,CAAC;IACpEK,OAAO,CAACa,IAAI,CAAC,CAAC;IACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEHf,OAAO,CAACgB,KAAK,CAAC,CAAC"}
@@ -1,17 +1,28 @@
1
- import { frodo } from '@rockcarver/frodo-lib';
1
+ import { frodo, state } from '@rockcarver/frodo-lib';
2
2
  import { Option } from 'commander';
3
+ import { exportVariablesToFile, exportVariablesToFiles, exportVariableToFile } from '../../ops/VariablesOps';
4
+ import { printMessage, verboseMessage } from '../../utils/Console';
3
5
  import { FrodoCommand } from '../FrodoCommand';
4
6
  const {
5
7
  getTokens
6
8
  } = frodo.login;
7
9
  const program = new FrodoCommand('frodo esv variable export');
8
- program.description('Export variables.').addOption(new Option('-i, --variable-id <variable-id>', 'Variable id. If specified, -a and -A are ignored.')).addOption(new Option('-f, --file <file>', 'Name of the export file.')).addOption(new Option('-a, --all', 'Export all variables to a single file. Ignored with -i.')).addOption(new Option('-A, --all-separate', 'Export all variables to separate files (*.variable.json) in the current directory. Ignored with -i or -a.')).action(
10
+ program.description('Export variables.').addOption(new Option('-i, --variable-id <variable-id>', 'Variable id. If specified, -a and -A are ignored.')).addOption(new Option('-f, --file <file>', 'Name of the export file.')).addOption(new Option('-a, --all', 'Export all variables to a single file. Ignored with -i.')).addOption(new Option('-A, --all-separate', 'Export all variables to separate files (*.variable.json) in the current directory. Ignored with -i or -a.')).addOption(new Option('--no-decode', 'Do not include decoded variable value in export').default(false, 'false')).action(
9
11
  // implement command logic inside action handler
10
12
  async (host, realm, user, password, options, command) => {
11
13
  command.handleDefaultArgsAndOpts(host, realm, user, password, options, command);
12
- if (await getTokens()) {
13
- // code goes here
14
+ if (options.variableId && (await getTokens())) {
15
+ verboseMessage(`Exporting variable "${options.variableId}" from realm "${state.getRealm()}"...`);
16
+ await exportVariableToFile(options.variableId, options.file, options.decode);
17
+ } else if (options.all && (await getTokens())) {
18
+ verboseMessage('Exporting all variables to a single file...');
19
+ await exportVariablesToFile(options.file, options.decode);
20
+ } else if (options.allSeparate && (await getTokens())) {
21
+ verboseMessage('Exporting all variables to separate files...');
22
+ await exportVariablesToFiles(options.decode);
14
23
  } else {
24
+ printMessage('Unrecognized combination of options or no options...', 'error');
25
+ program.help();
15
26
  process.exitCode = 1;
16
27
  }
17
28
  }
@@ -1 +1 @@
1
- {"version":3,"file":"esv-variable-export.js","names":["frodo","Option","FrodoCommand","getTokens","login","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","process","exitCode","parse"],"sources":["../../../src/cli/esv/esv-variable-export.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\n\nconst program = new FrodoCommand('frodo esv variable export');\n\nprogram\n .description('Export variables.')\n .addOption(\n new Option(\n '-i, --variable-id <variable-id>',\n 'Variable id. If specified, -a and -A are ignored.'\n )\n )\n .addOption(new Option('-f, --file <file>', 'Name of the export file.'))\n .addOption(\n new Option(\n '-a, --all',\n 'Export all variables to a single file. Ignored with -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Export all variables to separate files (*.variable.json) in the current directory. Ignored with -i or -a.'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n if (await getTokens()) {\n // code goes here\n } else {\n process.exitCode = 1;\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,SAASC,MAAM,QAAQ,WAAW;AAElC,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAM;EAAEC;AAAU,CAAC,GAAGH,KAAK,CAACI,KAAK;AAEjC,MAAMC,OAAO,GAAG,IAAIH,YAAY,CAAC,2BAA2B,CAAC;AAE7DG,OAAO,CACJC,WAAW,CAAC,mBAAmB,CAAC,CAChCC,SAAS,CACR,IAAIN,MAAM,CACR,iCAAiC,EACjC,mDACF,CACF,CAAC,CACAM,SAAS,CAAC,IAAIN,MAAM,CAAC,mBAAmB,EAAE,0BAA0B,CAAC,CAAC,CACtEM,SAAS,CACR,IAAIN,MAAM,CACR,WAAW,EACX,yDACF,CACF,CAAC,CACAM,SAAS,CACR,IAAIN,MAAM,CACR,oBAAoB,EACpB,2GACF,CACF,CAAC,CACAO,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EACvDA,OAAO,CAACC,wBAAwB,CAC9BN,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,QAAQ,EACRC,OAAO,EACPC,OACF,CAAC;EACD,IAAI,MAAMX,SAAS,CAAC,CAAC,EAAE;IACrB;EAAA,CACD,MAAM;IACLa,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEHZ,OAAO,CAACa,KAAK,CAAC,CAAC"}
1
+ {"version":3,"file":"esv-variable-export.js","names":["frodo","state","Option","exportVariablesToFile","exportVariablesToFiles","exportVariableToFile","printMessage","verboseMessage","FrodoCommand","getTokens","login","program","description","addOption","default","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","variableId","getRealm","file","decode","all","allSeparate","help","process","exitCode","parse"],"sources":["../../../src/cli/esv/esv-variable-export.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport {\n exportVariablesToFile,\n exportVariablesToFiles,\n exportVariableToFile,\n} from '../../ops/VariablesOps';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\n\nconst program = new FrodoCommand('frodo esv variable export');\n\nprogram\n .description('Export variables.')\n .addOption(\n new Option(\n '-i, --variable-id <variable-id>',\n 'Variable id. If specified, -a and -A are ignored.'\n )\n )\n .addOption(new Option('-f, --file <file>', 'Name of the export file.'))\n .addOption(\n new Option(\n '-a, --all',\n 'Export all variables to a single file. Ignored with -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Export all variables to separate files (*.variable.json) in the current directory. Ignored with -i or -a.'\n )\n )\n .addOption(\n new Option(\n '--no-decode',\n 'Do not include decoded variable value in export'\n ).default(false, 'false')\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n if (options.variableId && (await getTokens())) {\n verboseMessage(\n `Exporting variable \"${\n options.variableId\n }\" from realm \"${state.getRealm()}\"...`\n );\n await exportVariableToFile(\n options.variableId,\n options.file,\n options.decode\n );\n } else if (options.all && (await getTokens())) {\n verboseMessage('Exporting all variables to a single file...');\n await exportVariablesToFile(options.file, options.decode);\n } else if (options.allSeparate && (await getTokens())) {\n verboseMessage('Exporting all variables to separate files...');\n await exportVariablesToFiles(options.decode);\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 // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,SAASC,MAAM,QAAQ,WAAW;AAElC,SACEC,qBAAqB,EACrBC,sBAAsB,EACtBC,oBAAoB,QACf,wBAAwB;AAC/B,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAM;EAAEC;AAAU,CAAC,GAAGT,KAAK,CAACU,KAAK;AAEjC,MAAMC,OAAO,GAAG,IAAIH,YAAY,CAAC,2BAA2B,CAAC;AAE7DG,OAAO,CACJC,WAAW,CAAC,mBAAmB,CAAC,CAChCC,SAAS,CACR,IAAIX,MAAM,CACR,iCAAiC,EACjC,mDACF,CACF,CAAC,CACAW,SAAS,CAAC,IAAIX,MAAM,CAAC,mBAAmB,EAAE,0BAA0B,CAAC,CAAC,CACtEW,SAAS,CACR,IAAIX,MAAM,CACR,WAAW,EACX,yDACF,CACF,CAAC,CACAW,SAAS,CACR,IAAIX,MAAM,CACR,oBAAoB,EACpB,2GACF,CACF,CAAC,CACAW,SAAS,CACR,IAAIX,MAAM,CACR,aAAa,EACb,iDACF,CAAC,CAACY,OAAO,CAAC,KAAK,EAAE,OAAO,CAC1B,CAAC,CACAC,MAAM;AACL;AACA,OAAOC,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,OAAO,KAAK;EACvDA,OAAO,CAACC,wBAAwB,CAC9BN,IAAI,EACJC,KAAK,EACLC,IAAI,EACJC,QAAQ,EACRC,OAAO,EACPC,OACF,CAAC;EACD,IAAID,OAAO,CAACG,UAAU,KAAK,MAAMd,SAAS,CAAC,CAAC,CAAC,EAAE;IAC7CF,cAAc,CACX,uBACCa,OAAO,CAACG,UACT,iBAAgBtB,KAAK,CAACuB,QAAQ,CAAC,CAAE,MACpC,CAAC;IACD,MAAMnB,oBAAoB,CACxBe,OAAO,CAACG,UAAU,EAClBH,OAAO,CAACK,IAAI,EACZL,OAAO,CAACM,MACV,CAAC;EACH,CAAC,MAAM,IAAIN,OAAO,CAACO,GAAG,KAAK,MAAMlB,SAAS,CAAC,CAAC,CAAC,EAAE;IAC7CF,cAAc,CAAC,6CAA6C,CAAC;IAC7D,MAAMJ,qBAAqB,CAACiB,OAAO,CAACK,IAAI,EAAEL,OAAO,CAACM,MAAM,CAAC;EAC3D,CAAC,MAAM,IAAIN,OAAO,CAACQ,WAAW,KAAK,MAAMnB,SAAS,CAAC,CAAC,CAAC,EAAE;IACrDF,cAAc,CAAC,8CAA8C,CAAC;IAC9D,MAAMH,sBAAsB,CAACgB,OAAO,CAACM,MAAM,CAAC;EAC9C,CAAC,MAAM;IACLpB,YAAY,CACV,sDAAsD,EACtD,OACF,CAAC;IACDK,OAAO,CAACkB,IAAI,CAAC,CAAC;IACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEHpB,OAAO,CAACqB,KAAK,CAAC,CAAC"}
@@ -4,8 +4,7 @@ program.description('Manage variables.');
4
4
  program.command('create', 'Create variables.');
5
5
  program.command('delete', 'Delete variables.');
6
6
  program.command('describe', 'Describe variables.');
7
-
8
- // program.command('export', 'Export variables.');
7
+ program.command('export', 'Export variables.');
9
8
 
10
9
  // program.command('import', 'Import variables.');
11
10
 
@@ -1 +1 @@
1
- {"version":3,"file":"esv-variable.js","names":["FrodoStubCommand","program","description","command","parse"],"sources":["../../../src/cli/esv/esv-variable.ts"],"sourcesContent":["import { FrodoStubCommand } from '../FrodoCommand';\n\nconst program = new FrodoStubCommand('frodo esv variable');\n\nprogram.description('Manage variables.');\n\nprogram.command('create', 'Create variables.');\n\nprogram.command('delete', 'Delete variables.');\n\nprogram.command('describe', 'Describe variables.');\n\n// program.command('export', 'Export variables.');\n\n// program.command('import', 'Import variables.');\n\nprogram.command('list', 'List variables.');\n\nprogram.command('set', 'Set variable descriptions.');\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,iBAAiB;AAElD,MAAMC,OAAO,GAAG,IAAID,gBAAgB,CAAC,oBAAoB,CAAC;AAE1DC,OAAO,CAACC,WAAW,CAAC,mBAAmB,CAAC;AAExCD,OAAO,CAACE,OAAO,CAAC,QAAQ,EAAE,mBAAmB,CAAC;AAE9CF,OAAO,CAACE,OAAO,CAAC,QAAQ,EAAE,mBAAmB,CAAC;AAE9CF,OAAO,CAACE,OAAO,CAAC,UAAU,EAAE,qBAAqB,CAAC;;AAElD;;AAEA;;AAEAF,OAAO,CAACE,OAAO,CAAC,MAAM,EAAE,iBAAiB,CAAC;AAE1CF,OAAO,CAACE,OAAO,CAAC,KAAK,EAAE,4BAA4B,CAAC;AAEpDF,OAAO,CAACG,KAAK,CAAC,CAAC"}
1
+ {"version":3,"file":"esv-variable.js","names":["FrodoStubCommand","program","description","command","parse"],"sources":["../../../src/cli/esv/esv-variable.ts"],"sourcesContent":["import { FrodoStubCommand } from '../FrodoCommand';\n\nconst program = new FrodoStubCommand('frodo esv variable');\n\nprogram.description('Manage variables.');\n\nprogram.command('create', 'Create variables.');\n\nprogram.command('delete', 'Delete variables.');\n\nprogram.command('describe', 'Describe variables.');\n\nprogram.command('export', 'Export variables.');\n\n// program.command('import', 'Import variables.');\n\nprogram.command('list', 'List variables.');\n\nprogram.command('set', 'Set variable descriptions.');\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,iBAAiB;AAElD,MAAMC,OAAO,GAAG,IAAID,gBAAgB,CAAC,oBAAoB,CAAC;AAE1DC,OAAO,CAACC,WAAW,CAAC,mBAAmB,CAAC;AAExCD,OAAO,CAACE,OAAO,CAAC,QAAQ,EAAE,mBAAmB,CAAC;AAE9CF,OAAO,CAACE,OAAO,CAAC,QAAQ,EAAE,mBAAmB,CAAC;AAE9CF,OAAO,CAACE,OAAO,CAAC,UAAU,EAAE,qBAAqB,CAAC;AAElDF,OAAO,CAACE,OAAO,CAAC,QAAQ,EAAE,mBAAmB,CAAC;;AAE9C;;AAEAF,OAAO,CAACE,OAAO,CAAC,MAAM,EAAE,iBAAiB,CAAC;AAE1CF,OAAO,CAACE,OAAO,CAAC,KAAK,EAAE,4BAA4B,CAAC;AAEpDF,OAAO,CAACG,KAAK,CAAC,CAAC"}
@@ -18,6 +18,7 @@ program.description('If -h is supplied, describe the journey/tree indicated by -
18
18
  // implement command logic inside action handler
19
19
  async (host, realm, user, password, options, command) => {
20
20
  command.handleDefaultArgsAndOpts(host, realm, user, password, options, command);
21
+ host = host ? host : state.getHost();
21
22
  if (options.outputFile) state.setOutputFile(options.outputFile);
22
23
  // TODO: review checks for arguments
23
24
  if (typeof host === 'undefined' || typeof options.file !== 'undefined') {
@@ -1 +1 @@
1
- {"version":3,"file":"journey-describe.js","names":["frodo","state","Option","fs","describeJourney","describeJourneyMd","printMessage","verboseMessage","saveTextToFile","FrodoCommand","getTokens","login","createFileParamTreeExportResolver","readJourneys","exportJourney","authn","journey","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","outputFile","setOutputFile","file","process","exitCode","_fileData$tree","_fileData$tree2","overrideVersion","setAmVersion","fileData","JSON","parse","readFileSync","journeyData","journeyId","trees","Object","values","tree","_id","Error","markdown","error","message","getRealm","journeys","treeData"],"sources":["../../../src/cli/journey/journey-describe.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\nimport fs from 'fs';\n\nimport { describeJourney, describeJourneyMd } from '../../ops/JourneyOps';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { saveTextToFile } from '../../utils/ExportImportUtils';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\nconst { createFileParamTreeExportResolver, readJourneys, exportJourney } =\n frodo.authn.journey;\n\nconst program = new FrodoCommand('frodo journey describe');\n\nprogram\n .description(\n 'If -h is supplied, describe the journey/tree indicated by -i, or all journeys/trees in the realm if no -i is supplied, otherwise describe the journey/tree export file indicated by -f.'\n )\n .addOption(\n new Option(\n '-i, --journey-id <journey>',\n 'Name of a journey/tree. If specified, -a and -A are ignored.'\n )\n )\n .addOption(\n new Option(\n '-f, --file <file>',\n 'Name of the journey export file to describe. Ignored with -A.'\n )\n )\n .addOption(\n new Option(\n '-F, --output-file <file>',\n 'Name of the file to write the output to.'\n )\n )\n .addOption(new Option('--markdown', 'Output in markdown.'))\n .addOption(\n new Option(\n '-o, --override-version <version>',\n \"Override version. Notation: '<major>.<minor>.<patch>' e.g. '7.2.0'. Override detected version with any version. This is helpful in order to check if journeys in one environment would be compatible running in another environment (e.g. in preparation of migrating from on-prem to ForgeRock Identity Cloud.\"\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n if (options.outputFile) state.setOutputFile(options.outputFile);\n // TODO: review checks for arguments\n if (typeof host === 'undefined' || typeof options.file !== 'undefined') {\n if (\n typeof host === 'undefined' &&\n typeof options.file === 'undefined'\n ) {\n printMessage('Need either [host] or -f.', 'error');\n process.exitCode = 1;\n return;\n }\n verboseMessage(`Describing local journey file ${options.file}...`);\n try {\n // override version\n if (typeof options.overrideVersion !== 'undefined') {\n state.setAmVersion(options.overrideVersion);\n }\n const fileData = JSON.parse(fs.readFileSync(options.file, 'utf8'));\n let journeyData;\n // single or multi tree export?\n // multi - by id\n if (\n typeof options.journeyId !== 'undefined' &&\n fileData.trees &&\n fileData.trees[options.journeyId]\n ) {\n journeyData = fileData.trees[options.journeyId];\n }\n // multi - first\n else if (typeof options.journeyId === 'undefined' && fileData.trees) {\n [journeyData] = Object.values(fileData.trees);\n }\n // single - by id\n else if (\n typeof options.journeyId !== 'undefined' &&\n options.journeyId === fileData.tree?._id\n ) {\n journeyData = fileData;\n }\n // single\n else if (\n typeof options.journeyId === 'undefined' &&\n fileData.tree?._id\n ) {\n journeyData = fileData;\n }\n // no journey/tree found\n else {\n throw new Error(\n typeof options.journeyId === 'undefined'\n ? `No journey found in ${options.file}`\n : `Journey '${options.journeyId}' not found in ${options.file}`\n );\n }\n // ANSI text output\n if (!options.markdown) {\n await describeJourney(\n journeyData,\n createFileParamTreeExportResolver(options.file)\n );\n }\n // Markdown output\n else {\n // reset output file\n if (options.outputFile) saveTextToFile('', options.outputFile);\n await describeJourneyMd(\n journeyData,\n createFileParamTreeExportResolver(options.file)\n );\n }\n } catch (error) {\n printMessage(error.message, 'error');\n process.exitCode = 1;\n }\n } else if (await getTokens()) {\n verboseMessage(\n `Describing journey(s) in realm \"${state.getRealm()}\"...`\n );\n // override version\n if (typeof options.overrideVersion !== 'undefined') {\n state.setAmVersion(options.overrideVersion);\n }\n if (typeof options.journeyId === 'undefined') {\n let journeys = [];\n journeys = await readJourneys();\n for (const journey of journeys) {\n try {\n // eslint-disable-next-line no-await-in-loop, dot-notation\n const treeData = await exportJourney(journey['_id']);\n // ANSI text output\n if (!options.markdown) {\n await describeJourney(treeData);\n }\n // Markdown output\n else {\n // reset output file\n if (options.outputFile) saveTextToFile('', options.outputFile);\n await describeJourneyMd(treeData);\n }\n } catch (error) {\n printMessage(error.message, 'error');\n process.exitCode = 1;\n }\n }\n } else {\n try {\n const treeData = await exportJourney(options.journeyId);\n // ANSI text output\n if (!options.markdown) {\n await describeJourney(treeData);\n }\n // Markdown output\n else {\n // reset output file\n if (options.outputFile) saveTextToFile('', options.outputFile);\n await describeJourneyMd(treeData);\n }\n } catch (error) {\n printMessage(error.message, 'error');\n process.exitCode = 1;\n }\n }\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],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AAY,CAAC,CAAC;MAC/B,KAAK,MAAMG,OAAO,IAAIqC,QAAQ,EAAE;QAC9B,IAAI;UACF;UACA,MAAMC,QAAQ,GAAG,MAAMxC,aAAa,CAACE,OAAO,CAAC,KAAK,CAAC,CAAC;UACpD;UACA,IAAI,CAACS,OAAO,CAACwB,QAAQ,EAAE;YACrB,MAAM7C,eAAe,CAACkD,QAAQ,CAAC;UACjC;UACA;UAAA,KACK;YACH;YACA,IAAI7B,OAAO,CAACG,UAAU,EAAEpB,cAAc,CAAC,EAAE,EAAEiB,OAAO,CAACG,UAAU,CAAC;YAC9D,MAAMvB,iBAAiB,CAACiD,QAAQ,CAAC;UACnC;QACF,CAAC,CAAC,OAAOJ,KAAK,EAAE;UACd5C,YAAY,CAAC4C,KAAK,CAACC,OAAO,EAAE,OAAO,CAAC;UACpCpB,OAAO,CAACC,QAAQ,GAAG,CAAC;QACtB;MACF;IACF,CAAC,MAAM;MACL,IAAI;QACF,MAAMsB,QAAQ,GAAG,MAAMxC,aAAa,CAACW,OAAO,CAACiB,SAAS,CAAC;QACvD;QACA,IAAI,CAACjB,OAAO,CAACwB,QAAQ,EAAE;UACrB,MAAM7C,eAAe,CAACkD,QAAQ,CAAC;QACjC;QACA;QAAA,KACK;UACH;UACA,IAAI7B,OAAO,CAACG,UAAU,EAAEpB,cAAc,CAAC,EAAE,EAAEiB,OAAO,CAACG,UAAU,CAAC;UAC9D,MAAMvB,iBAAiB,CAACiD,QAAQ,CAAC;QACnC;MACF,CAAC,CAAC,OAAOJ,KAAK,EAAE;QACd5C,YAAY,CAAC4C,KAAK,CAACC,OAAO,EAAE,OAAO,CAAC;QACpCpB,OAAO,CAACC,QAAQ,GAAG,CAAC;MACtB;IACF;EACF;AACF;AACA;AACF,CAAC;;AAEHf,OAAO,CAACsB,KAAK,CAAC,CAAC"}
1
+ {"version":3,"file":"journey-describe.js","names":["frodo","state","Option","fs","describeJourney","describeJourneyMd","printMessage","verboseMessage","saveTextToFile","FrodoCommand","getTokens","login","createFileParamTreeExportResolver","readJourneys","exportJourney","authn","journey","program","description","addOption","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","getHost","outputFile","setOutputFile","file","process","exitCode","_fileData$tree","_fileData$tree2","overrideVersion","setAmVersion","fileData","JSON","parse","readFileSync","journeyData","journeyId","trees","Object","values","tree","_id","Error","markdown","error","message","getRealm","journeys","treeData"],"sources":["../../../src/cli/journey/journey-describe.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\nimport fs from 'fs';\n\nimport { describeJourney, describeJourneyMd } from '../../ops/JourneyOps';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { saveTextToFile } from '../../utils/ExportImportUtils';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\nconst { createFileParamTreeExportResolver, readJourneys, exportJourney } =\n frodo.authn.journey;\n\nconst program = new FrodoCommand('frodo journey describe');\n\nprogram\n .description(\n 'If -h is supplied, describe the journey/tree indicated by -i, or all journeys/trees in the realm if no -i is supplied, otherwise describe the journey/tree export file indicated by -f.'\n )\n .addOption(\n new Option(\n '-i, --journey-id <journey>',\n 'Name of a journey/tree. If specified, -a and -A are ignored.'\n )\n )\n .addOption(\n new Option(\n '-f, --file <file>',\n 'Name of the journey export file to describe. Ignored with -A.'\n )\n )\n .addOption(\n new Option(\n '-F, --output-file <file>',\n 'Name of the file to write the output to.'\n )\n )\n .addOption(new Option('--markdown', 'Output in markdown.'))\n .addOption(\n new Option(\n '-o, --override-version <version>',\n \"Override version. Notation: '<major>.<minor>.<patch>' e.g. '7.2.0'. Override detected version with any version. This is helpful in order to check if journeys in one environment would be compatible running in another environment (e.g. in preparation of migrating from on-prem to ForgeRock Identity Cloud.\"\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n host = host ? host : state.getHost();\n if (options.outputFile) state.setOutputFile(options.outputFile);\n // TODO: review checks for arguments\n if (typeof host === 'undefined' || typeof options.file !== 'undefined') {\n if (\n typeof host === 'undefined' &&\n typeof options.file === 'undefined'\n ) {\n printMessage('Need either [host] or -f.', 'error');\n process.exitCode = 1;\n return;\n }\n verboseMessage(`Describing local journey file ${options.file}...`);\n try {\n // override version\n if (typeof options.overrideVersion !== 'undefined') {\n state.setAmVersion(options.overrideVersion);\n }\n const fileData = JSON.parse(fs.readFileSync(options.file, 'utf8'));\n let journeyData;\n // single or multi tree export?\n // multi - by id\n if (\n typeof options.journeyId !== 'undefined' &&\n fileData.trees &&\n fileData.trees[options.journeyId]\n ) {\n journeyData = fileData.trees[options.journeyId];\n }\n // multi - first\n else if (typeof options.journeyId === 'undefined' && fileData.trees) {\n [journeyData] = Object.values(fileData.trees);\n }\n // single - by id\n else if (\n typeof options.journeyId !== 'undefined' &&\n options.journeyId === fileData.tree?._id\n ) {\n journeyData = fileData;\n }\n // single\n else if (\n typeof options.journeyId === 'undefined' &&\n fileData.tree?._id\n ) {\n journeyData = fileData;\n }\n // no journey/tree found\n else {\n throw new Error(\n typeof options.journeyId === 'undefined'\n ? `No journey found in ${options.file}`\n : `Journey '${options.journeyId}' not found in ${options.file}`\n );\n }\n // ANSI text output\n if (!options.markdown) {\n await describeJourney(\n journeyData,\n createFileParamTreeExportResolver(options.file)\n );\n }\n // Markdown output\n else {\n // reset output file\n if (options.outputFile) saveTextToFile('', options.outputFile);\n await describeJourneyMd(\n journeyData,\n createFileParamTreeExportResolver(options.file)\n );\n }\n } catch (error) {\n printMessage(error.message, 'error');\n process.exitCode = 1;\n }\n } else if (await getTokens()) {\n verboseMessage(\n `Describing journey(s) in realm \"${state.getRealm()}\"...`\n );\n // override version\n if (typeof options.overrideVersion !== 'undefined') {\n state.setAmVersion(options.overrideVersion);\n }\n if (typeof options.journeyId === 'undefined') {\n let journeys = [];\n journeys = await readJourneys();\n for (const journey of journeys) {\n try {\n // eslint-disable-next-line no-await-in-loop, dot-notation\n const treeData = await exportJourney(journey['_id']);\n // ANSI text output\n if (!options.markdown) {\n await describeJourney(treeData);\n }\n // Markdown output\n else {\n // reset output file\n if (options.outputFile) saveTextToFile('', options.outputFile);\n await describeJourneyMd(treeData);\n }\n } catch (error) {\n printMessage(error.message, 'error');\n process.exitCode = 1;\n }\n }\n } else {\n try {\n const treeData = await exportJourney(options.journeyId);\n // ANSI text output\n if (!options.markdown) {\n await describeJourney(treeData);\n }\n // Markdown output\n else {\n // reset output file\n if (options.outputFile) saveTextToFile('', options.outputFile);\n await describeJourneyMd(treeData);\n }\n } catch (error) {\n printMessage(error.message, 'error');\n process.exitCode = 1;\n }\n }\n }\n }\n // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AACpD,SAASC,MAAM,QAAQ,WAAW;AAClC,OAAOC,EAAE,MAAM,IAAI;AAEnB,SAASC,eAAe,EAAEC,iBAAiB,QAAQ,sBAAsB;AACzE,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,SAASC,cAAc,QAAQ,+BAA+B;AAC9D,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAM;EAAEC;AAAU,CAAC,GAAGV,KAAK,CAACW,KAAK;AACjC,MAAM;EAAEC,iCAAiC;EAAEC,YAAY;EAAEC;AAAc,CAAC,GACtEd,KAAK,CAACe,KAAK,CAACC,OAAO;AAErB,MAAMC,OAAO,GAAG,IAAIR,YAAY,CAAC,wBAAwB,CAAC;AAE1DQ,OAAO,CACJC,WAAW,CACV,yLACF,CAAC,CACAC,SAAS,CACR,IAAIjB,MAAM,CACR,4BAA4B,EAC5B,8DACF,CACF,CAAC,CACAiB,SAAS,CACR,IAAIjB,MAAM,CACR,mBAAmB,EACnB,+DACF,CACF,CAAC,CACAiB,SAAS,CACR,IAAIjB,MAAM,CACR,0BAA0B,EAC1B,0CACF,CACF,CAAC,CACAiB,SAAS,CAAC,IAAIjB,MA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QAAQ,EAAE;UACrB,MAAM9C,eAAe,CAACmD,QAAQ,CAAC;QACjC;QACA;QAAA,KACK;UACH;UACA,IAAI9B,OAAO,CAACI,UAAU,EAAErB,cAAc,CAAC,EAAE,EAAEiB,OAAO,CAACI,UAAU,CAAC;UAC9D,MAAMxB,iBAAiB,CAACkD,QAAQ,CAAC;QACnC;MACF,CAAC,CAAC,OAAOJ,KAAK,EAAE;QACd7C,YAAY,CAAC6C,KAAK,CAACC,OAAO,EAAE,OAAO,CAAC;QACpCpB,OAAO,CAACC,QAAQ,GAAG,CAAC;MACtB;IACF;EACF;AACF;AACA;AACF,CAAC;;AAEHhB,OAAO,CAACuB,KAAK,CAAC,CAAC"}
@@ -7,7 +7,17 @@ const {
7
7
  getTokens
8
8
  } = frodo.login;
9
9
  const program = new FrodoCommand('frodo journey export');
10
- program.description('Export journeys/trees.').addOption(new Option('-i, --journey-id <journey>', 'Name of a journey/tree. If specified, -a and -A are ignored.')).addOption(new Option('-f, --file <file>', 'Name of the file to write the exported journey(s) to. Ignored with -A.')).addOption(new Option('-a, --all', 'Export all the journeys/trees in a realm. Ignored with -i.')).addOption(new Option('-A, --all-separate', 'Export all the journeys/trees in a realm as separate files <journey/tree name>.json. Ignored with -i or -a.')).addOption(new Option('--use-string-arrays', 'Where applicable, use string arrays to store multi-line text (e.g. scripts).').default(false, 'off')).addOption(new Option('--no-deps', 'Do not include any dependencies (scripts, email templates, SAML entity providers and circles of trust, social identity providers, themes).')).addOption(new Option('-O, --organize <method>', 'Organize exports into folders using the indicated method. Valid values for method:\n' + 'id: folders named by id of exported object\n' + 'type: folders named by type (e.g. script, journey, idp)\n' + 'type/id: folders named by type with sub-folders named by id')).action(
10
+ program.description('Export journeys/trees.').addOption(new Option('-i, --journey-id <journey>', 'Name of a journey/tree. If specified, -a and -A are ignored.')).addOption(new Option('-f, --file <file>', 'Name of the file to write the exported journey(s) to. Ignored with -A.')).addOption(new Option('-a, --all', 'Export all the journeys/trees in a realm. Ignored with -i.')).addOption(new Option('-A, --all-separate', 'Export all the journeys/trees in a realm as separate files <journey/tree name>.json. Ignored with -i or -a.')).addOption(new Option('--use-string-arrays', 'Where applicable, use string arrays to store multi-line text (e.g. scripts).').default(false, 'off')).addOption(new Option('--no-deps', 'Do not include any dependencies (scripts, email templates, SAML entity providers and circles of trust, social identity providers, themes).'))
11
+ // .addOption(
12
+ // new Option(
13
+ // '-O, --organize <method>',
14
+ // 'Organize exports into folders using the indicated method. Valid values for method:\n' +
15
+ // 'id: folders named by id of exported object\n' +
16
+ // 'type: folders named by type (e.g. script, journey, idp)\n' +
17
+ // 'type/id: folders named by type with sub-folders named by id'
18
+ // )
19
+ // )
20
+ .action(
11
21
  // implement command logic inside action handler
12
22
  async (host, realm, user, password, options, command) => {
13
23
  command.handleDefaultArgsAndOpts(host, realm, user, password, options, command);
@@ -1 +1 @@
1
- {"version":3,"file":"journey-export.js","names":["frodo","Option","exportJourneysToFile","exportJourneysToFiles","exportJourneyToFile","printMessage","verboseMessage","FrodoCommand","getTokens","login","program","description","addOption","default","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","journeyId","file","useStringArrays","deps","all","allSeparate","help","process","exitCode","parse"],"sources":["../../../src/cli/journey/journey-export.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport {\n exportJourneysToFile,\n exportJourneysToFiles,\n exportJourneyToFile,\n} from '../../ops/JourneyOps';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\n\nconst program = new FrodoCommand('frodo journey export');\n\nprogram\n .description('Export journeys/trees.')\n .addOption(\n new Option(\n '-i, --journey-id <journey>',\n 'Name of a journey/tree. 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 journey(s) to. Ignored with -A.'\n )\n )\n .addOption(\n new Option(\n '-a, --all',\n 'Export all the journeys/trees in a realm. Ignored with -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Export all the journeys/trees in a realm as separate files <journey/tree name>.json. Ignored with -i or -a.'\n )\n )\n .addOption(\n new Option(\n '--use-string-arrays',\n 'Where applicable, use string arrays to store multi-line text (e.g. scripts).'\n ).default(false, 'off')\n )\n .addOption(\n new Option(\n '--no-deps',\n 'Do not include any dependencies (scripts, email templates, SAML entity providers and circles of trust, social identity providers, themes).'\n )\n )\n .addOption(\n new Option(\n '-O, --organize <method>',\n 'Organize exports into folders using the indicated method. Valid values for method:\\n' +\n 'id: folders named by id of exported object\\n' +\n 'type: folders named by type (e.g. script, journey, idp)\\n' +\n 'type/id: folders named by type with sub-folders named by id'\n )\n )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n // export\n if (options.journeyId && (await getTokens())) {\n verboseMessage('Exporting journey...');\n await exportJourneyToFile(options.journeyId, options.file, {\n useStringArrays: options.useStringArrays,\n deps: options.deps,\n });\n }\n // --all -a\n else if (options.all && (await getTokens())) {\n verboseMessage('Exporting all journeys to a single file...');\n await exportJourneysToFile(options.file, {\n useStringArrays: options.useStringArrays,\n deps: options.deps,\n });\n }\n // --all-separate -A\n else if (options.allSeparate && (await getTokens())) {\n verboseMessage('Exporting all journeys to separate files...');\n await exportJourneysToFiles({\n useStringArrays: options.useStringArrays,\n deps: options.deps,\n });\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 // end command logic inside action handler\n );\n\nprogram.parse();\n"],"mappings":"AAAA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,SAASC,MAAM,QAAQ,WAAW;AAElC,SACEC,oBAAoB,EACpBC,qBAAqB,EACrBC,mBAAmB,QACd,sBAAsB;AAC7B,SAASC,YAAY,EAAEC,cAAc,QAAQ,qBAAqB;AAClE,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C;EACJ;EACA;EAAA,KACK,IAAIN,OAAO,CAACO,GAAG,KAAK,MAAMlB,SAAS,CAAC,CAAC,CAAC,EAAE;IAC3CF,cAAc,CAAC,4CAA4C,CAAC;IAC5D,MAAMJ,oBAAoB,CAACiB,OAAO,CAACI,IAAI,EAAE;MACvCC,eAAe,EAAEL,OAAO,CAACK,eAAe;MACxCC,IAAI,EAAEN,OAAO,CAACM;IAChB,CAAC,CAAC;EACJ;EACA;EAAA,KACK,IAAIN,OAAO,CAACQ,WAAW,KAAK,MAAMnB,SAAS,CAAC,CAAC,CAAC,EAAE;IACnDF,cAAc,CAAC,6CAA6C,CAAC;IAC7D,MAAMH,qBAAqB,CAAC;MAC1BqB,eAAe,EAAEL,OAAO,CAACK,eAAe;MACxCC,IAAI,EAAEN,OAAO,CAACM;IAChB,CAAC,CAAC;EACJ;EACA;EAAA,KACK;IACHpB,YAAY,CACV,sDAAsD,EACtD,OACF,CAAC;IACDK,OAAO,CAACkB,IAAI,CAAC,CAAC;IACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEHpB,OAAO,CAACqB,KAAK,CAAC,CAAC"}
1
+ {"version":3,"file":"journey-export.js","names":["frodo","Option","exportJourneysToFile","exportJourneysToFiles","exportJourneyToFile","printMessage","verboseMessage","FrodoCommand","getTokens","login","program","description","addOption","default","action","host","realm","user","password","options","command","handleDefaultArgsAndOpts","journeyId","file","useStringArrays","deps","all","allSeparate","help","process","exitCode","parse"],"sources":["../../../src/cli/journey/journey-export.ts"],"sourcesContent":["import { frodo } from '@rockcarver/frodo-lib';\nimport { Option } from 'commander';\n\nimport {\n exportJourneysToFile,\n exportJourneysToFiles,\n exportJourneyToFile,\n} from '../../ops/JourneyOps';\nimport { printMessage, verboseMessage } from '../../utils/Console';\nimport { FrodoCommand } from '../FrodoCommand';\n\nconst { getTokens } = frodo.login;\n\nconst program = new FrodoCommand('frodo journey export');\n\nprogram\n .description('Export journeys/trees.')\n .addOption(\n new Option(\n '-i, --journey-id <journey>',\n 'Name of a journey/tree. 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 journey(s) to. Ignored with -A.'\n )\n )\n .addOption(\n new Option(\n '-a, --all',\n 'Export all the journeys/trees in a realm. Ignored with -i.'\n )\n )\n .addOption(\n new Option(\n '-A, --all-separate',\n 'Export all the journeys/trees in a realm as separate files <journey/tree name>.json. Ignored with -i or -a.'\n )\n )\n .addOption(\n new Option(\n '--use-string-arrays',\n 'Where applicable, use string arrays to store multi-line text (e.g. scripts).'\n ).default(false, 'off')\n )\n .addOption(\n new Option(\n '--no-deps',\n 'Do not include any dependencies (scripts, email templates, SAML entity providers and circles of trust, social identity providers, themes).'\n )\n )\n // .addOption(\n // new Option(\n // '-O, --organize <method>',\n // 'Organize exports into folders using the indicated method. Valid values for method:\\n' +\n // 'id: folders named by id of exported object\\n' +\n // 'type: folders named by type (e.g. script, journey, idp)\\n' +\n // 'type/id: folders named by type with sub-folders named by id'\n // )\n // )\n .action(\n // implement command logic inside action handler\n async (host, realm, user, password, options, command) => {\n command.handleDefaultArgsAndOpts(\n host,\n realm,\n user,\n password,\n options,\n command\n );\n // export\n if (options.journeyId && (await getTokens())) {\n verboseMessage('Exporting journey...');\n await exportJourneyToFile(options.journeyId, options.file, {\n useStringArrays: options.useStringArrays,\n deps: options.deps,\n });\n }\n // --all -a\n else if (options.all && (await getTokens())) {\n verboseMessage('Exporting all journeys to a single file...');\n await exportJourneysToFile(options.file, {\n useStringArrays: options.useStringArrays,\n deps: options.deps,\n });\n }\n // --all-separate -A\n else if (options.allSeparate && (await getTokens())) {\n verboseMessage('Exporting all journeys to separate files...');\n await exportJourneysToFiles({\n useStringArrays: options.useStringArrays,\n deps: options.deps,\n });\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 // end command logic inside action handler\n );\n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e,OAAO,CAACG,SAAS,EAAEH,OAAO,CAACI,IAAI,EAAE;MACzDC,eAAe,EAAEL,OAAO,CAACK,eAAe;MACxCC,IAAI,EAAEN,OAAO,CAACM;IAChB,CAAC,CAAC;EACJ;EACA;EAAA,KACK,IAAIN,OAAO,CAACO,GAAG,KAAK,MAAMlB,SAAS,CAAC,CAAC,CAAC,EAAE;IAC3CF,cAAc,CAAC,4CAA4C,CAAC;IAC5D,MAAMJ,oBAAoB,CAACiB,OAAO,CAACI,IAAI,EAAE;MACvCC,eAAe,EAAEL,OAAO,CAACK,eAAe;MACxCC,IAAI,EAAEN,OAAO,CAACM;IAChB,CAAC,CAAC;EACJ;EACA;EAAA,KACK,IAAIN,OAAO,CAACQ,WAAW,KAAK,MAAMnB,SAAS,CAAC,CAAC,CAAC,EAAE;IACnDF,cAAc,CAAC,6CAA6C,CAAC;IAC7D,MAAMH,qBAAqB,CAAC;MAC1BqB,eAAe,EAAEL,OAAO,CAACK,eAAe;MACxCC,IAAI,EAAEN,OAAO,CAACM;IAChB,CAAC,CAAC;EACJ;EACA;EAAA,KACK;IACHpB,YAAY,CACV,sDAAsD,EACtD,OACF,CAAC;IACDK,OAAO,CAACkB,IAAI,CAAC,CAAC;IACdC,OAAO,CAACC,QAAQ,GAAG,CAAC;EACtB;AACF;AACA;AACF,CAAC;;AAEHpB,OAAO,CAACqB,KAAK,CAAC,CAAC"}
@@ -71,7 +71,7 @@ export async function listCirclesOfTrust(long = false) {
71
71
  cotList.forEach(cot => {
72
72
  table.push([cot._id, cot.description, cot.status, cot.trustedProviders.map(provider => provider.split('|')[0]).join('\n')]);
73
73
  });
74
- printMessage(table.toString());
74
+ printMessage(table.toString(), 'data');
75
75
  outcome = true;
76
76
  }
77
77
  return outcome;
@@ -1 +1 @@
1
- {"version":3,"file":"CirclesOfTrustOps.js","names":["frodo","state","fs","createProgressBar","createTable","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getTypedFilename","saveJsonToFile","titleCase","getRealmName","getFilePath","getWorkingDirectory","utils","readCirclesOfTrust","exportCircleOfTrust","exportCirclesOfTrust","importCircleOfTrust","importCirclesOfTrust","importFirstCircleOfTrust","saml2","circlesOfTrust","getOneLineDescription","cotObj","description","_id","getTableHeaderMd","markdown","getTableRowMd","row","status","trustedProviders","map","provider","split","join","listCirclesOfTrust","long","outcome","cotList","error","sort","a","b","localeCompare","forEach","cot","table","push","toString","exportCircleOfTrustToFile","cotId","file","fileName","filePath","exportData","message","exportCirclesOfTrustToFile","getRealm","exportCirclesOfTrustToFiles","errors","cots","length","name","importCircleOfTrustFromFile","data","readFileSync","fileData","JSON","parse","_error$response","response","importFirstCircleOfTrustFromFile","_error$response2","importCirclesOfTrustFromFile","_error$response3","importCirclesOfTrustFromFiles","names","readdirSync","files","filter","toLowerCase","endsWith","total","count","Object","keys","saml"],"sources":["../../src/ops/CirclesOfTrustOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { type CircleOfTrustSkeleton } from '@rockcarver/frodo-lib/types/api/CirclesOfTrustApi';\nimport { type CirclesOfTrustExportInterface } from '@rockcarver/frodo-lib/types/ops/CirclesOfTrustOps';\nimport fs from 'fs';\n\nimport {\n createProgressBar,\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport {\n getTypedFilename,\n saveJsonToFile,\n titleCase,\n} from '../utils/ExportImportUtils';\n\nconst { getRealmName, getFilePath, getWorkingDirectory } = frodo.utils;\nconst {\n readCirclesOfTrust,\n exportCircleOfTrust,\n exportCirclesOfTrust,\n importCircleOfTrust,\n importCirclesOfTrust,\n importFirstCircleOfTrust,\n} = frodo.saml2.circlesOfTrust;\n\n/**\n * Get a one-line description of the circle of trust object\n * @param {CircleOfTrustSkeleton} cotObj circle of trust object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(cotObj: CircleOfTrustSkeleton): string {\n const description = `[${cotObj._id['brightCyan']}]`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Name/Id | Status | Trusted Providers |\\n';\n markdown += '| ------- | ------ | ----------------- |';\n return markdown;\n}\n\n/**\n * Get a table-row of the circle of trust in markdown\n * @param {SocialIdpSkeleton} cotObj circle of trust object to describe\n * @returns {string} a table-row of the circle of trust in markdown\n */\nexport function getTableRowMd(cotObj: CircleOfTrustSkeleton): string {\n const row = `| ${cotObj._id} | ${\n cotObj.status === 'active'\n ? ':white_check_mark: `active`'\n : ':o: `inactive`'\n } | ${cotObj.trustedProviders\n .map((provider) => provider.split('|')[0])\n .join('<br>')} |`;\n return row;\n}\n\n/**\n * List entity providers\n * @param {String} long Long list format with details\n */\nexport async function listCirclesOfTrust(long = false): Promise<boolean> {\n let outcome = false;\n let cotList = [];\n try {\n cotList = await readCirclesOfTrust();\n } catch (error) {\n printMessage(`readCirclesOfTrust ERROR: ${error}`, 'error');\n printMessage(error, 'data');\n }\n cotList.sort((a, b) => a._id.localeCompare(b._id));\n if (!long) {\n cotList.forEach((cot) => {\n printMessage(`${cot._id}`, 'data');\n });\n outcome = true;\n } else {\n const table = createTable([\n 'Name'['brightCyan'],\n 'Description'['brightCyan'],\n 'Status'['brightCyan'],\n 'Trusted Providers'['brightCyan'],\n ]);\n cotList.forEach((cot) => {\n table.push([\n cot._id,\n cot.description,\n cot.status,\n cot.trustedProviders\n .map((provider) => provider.split('|')[0])\n .join('\\n'),\n ]);\n });\n printMessage(table.toString());\n outcome = true;\n }\n return outcome;\n}\n\n/**\n * Export a single circle of trust to file\n * @param {String} cotId circle of trust id/name\n * @param {String} file Optional filename\n */\nexport async function exportCircleOfTrustToFile(\n cotId: string,\n file: string = null\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.CirclesOfTrustOps.exportCircleOfTrustToFile: begin`);\n showSpinner(`Exporting ${cotId}...`);\n try {\n let fileName = getTypedFilename(cotId, 'cot.saml');\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const exportData = await exportCircleOfTrust(cotId);\n saveJsonToFile(exportData, filePath);\n succeedSpinner(`Exported ${cotId} to ${filePath}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting ${cotId}: ${error.message}`);\n }\n debugMessage(`cli.CirclesOfTrustOps.exportCircleOfTrustToFile: end`);\n return outcome;\n}\n\n/**\n * Export all circles of trust to one file\n * @param {String} file Optional filename\n */\nexport async function exportCirclesOfTrustToFile(\n file: string = null\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.CirclesOfTrustOps.exportCirclesOfTrustToFile: begin`);\n showSpinner(`Exporting all circles of trust...`);\n try {\n let fileName = getTypedFilename(\n `all${titleCase(getRealmName(state.getRealm()))}CirclesOfTrust`,\n 'cot.saml'\n );\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const exportData = await exportCirclesOfTrust();\n saveJsonToFile(exportData, filePath);\n succeedSpinner(`Exported all circles of trust to ${filePath}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting circles of trust: ${error.message}`);\n }\n debugMessage(`cli.CirclesOfTrustOps.exportCirclesOfTrustToFile: end`);\n return outcome;\n}\n\n/**\n * Export all circles of trust to individual files\n */\nexport async function exportCirclesOfTrustToFiles(): Promise<boolean> {\n debugMessage(`cli.CirclesOfTrustOps.exportCirclesOfTrustToFiles: begin`);\n const errors = [];\n try {\n const cots: CircleOfTrustSkeleton[] = await readCirclesOfTrust();\n createProgressBar(cots.length, 'Exporting circles of trust...');\n for (const cot of cots) {\n const file = getTypedFilename(cot._id, 'cot.saml');\n try {\n const exportData: CirclesOfTrustExportInterface =\n await exportCircleOfTrust(cot._id);\n saveJsonToFile(exportData, getFilePath(file, true));\n updateProgressBar(`Exported ${cot.name}.`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error exporting ${cot.name}.`);\n }\n }\n stopProgressBar(`Export complete.`);\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error exporting circles of trust to files`);\n }\n debugMessage(`cli.CirclesOfTrustOps.exportCirclesOfTrustToFiles: end`);\n return 0 === errors.length;\n}\n\n/**\n * Import a SAML circle of trust by id/name from file\n * @param {String} cotId Circle of trust id/name\n * @param {String} file Import file name\n */\nexport async function importCircleOfTrustFromFile(\n cotId: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n const filePath = getFilePath(file);\n showSpinner(`Importing circle of trust ${cotId} from ${filePath}...`);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importCircleOfTrust(cotId, fileData);\n outcome = true;\n succeedSpinner(`Imported circle of trust ${cotId} from ${filePath}.`);\n } catch (error) {\n failSpinner(`Error importing circle of trust ${cotId} from ${filePath}.`);\n printMessage(error.response?.data || error, 'error');\n }\n return outcome;\n}\n\n/**\n * Import first SAML circle of trust from file\n * @param {String} file Import file name\n */\nexport async function importFirstCircleOfTrustFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n const filePath = getFilePath(file);\n showSpinner(`Importing first circle of trust from ${filePath}...`);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importFirstCircleOfTrust(fileData);\n outcome = true;\n succeedSpinner(`Imported first circle of trust from ${filePath}.`);\n } catch (error) {\n failSpinner(`Error importing first circle of trust from ${filePath}.`);\n printMessage(error.response?.data || error, 'error');\n }\n return outcome;\n}\n\n/**\n * Import all SAML circles of trust from file\n * @param {String} file Import file name\n */\nexport async function importCirclesOfTrustFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n const filePath = getFilePath(file);\n showSpinner(`Importing circles of trust from ${filePath}...`);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importCirclesOfTrust(fileData);\n outcome = true;\n succeedSpinner(`Imported circles of trust from ${filePath}.`);\n } catch (error) {\n failSpinner(`Error importing circles of trust from ${filePath}.`);\n printMessage(error.response?.data || error, 'error');\n }\n return outcome;\n}\n\n/**\n * Import all SAML circles of trust from all *.cot.saml.json files in the current directory\n */\nexport async function importCirclesOfTrustFromFiles(): Promise<boolean> {\n const errors = [];\n try {\n debugMessage(`cli.CirclesOfTrustOps.importCirclesOfTrustFromFiles: begin`);\n const names = fs.readdirSync(getWorkingDirectory());\n const files = names\n .filter((name) => name.toLowerCase().endsWith('.cot.saml.json'))\n .map((name) => getFilePath(name));\n createProgressBar(files.length, 'Importing circles of trust...');\n let total = 0;\n for (const file of files) {\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData: CirclesOfTrustExportInterface = JSON.parse(data);\n const count = Object.keys(fileData.saml.cot).length;\n total += count;\n await importCirclesOfTrust(fileData);\n updateProgressBar(`Imported ${count} circles of trust from ${file}`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error importing circles of trust from ${file}`);\n printMessage(error, 'error');\n }\n }\n stopProgressBar(\n `Imported ${total} circles of trust from ${files.length} files.`\n );\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error importing circles of trust from files.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.CirclesOfTrustOps.importCirclesOfTrustFromFiles: end`);\n return 0 === errors.length;\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAGpD,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,iBAAiB,EACjBC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,cAAc,EACdC,iBAAiB,QACZ,kBAAkB;AACzB,SACEC,gBAAgB,EAChBC,cAAc,EACdC,SAAS,QACJ,4BAA4B;AAEnC,MAAM;EAAEC,YAAY;EAAEC,WAAW;EAAEC;AAAoB,CAAC,GAAGjB,KAAK,CAACkB,KAAK;AACtE,MAAM;EACJC,kBAAkB;EAClBC,mBAAmB;EACnBC,oBAAoB;EACpBC,mBAAmB;EACnBC,oBAAoB;E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essage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","getTypedFilename","saveJsonToFile","titleCase","getRealmName","getFilePath","getWorkingDirectory","utils","readCirclesOfTrust","exportCircleOfTrust","exportCirclesOfTrust","importCircleOfTrust","importCirclesOfTrust","importFirstCircleOfTrust","saml2","circlesOfTrust","getOneLineDescription","cotObj","description","_id","getTableHeaderMd","markdown","getTableRowMd","row","status","trustedProviders","map","provider","split","join","listCirclesOfTrust","long","outcome","cotList","error","sort","a","b","localeCompare","forEach","cot","table","push","toString","exportCircleOfTrustToFile","cotId","file","fileName","filePath","exportData","message","exportCirclesOfTrustToFile","getRealm","exportCirclesOfTrustToFiles","errors","cots","length","name","importCircleOfTrustFromFile","data","readFileSync","fileData","JSON","parse","_error$response","response","importFirstCircleOfTrustFromFile","_error$response2","importCirclesOfTrustFromFile","_error$response3","importCirclesOfTrustFromFiles","names","readdirSync","files","filter","toLowerCase","endsWith","total","count","Object","keys","saml"],"sources":["../../src/ops/CirclesOfTrustOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { type CircleOfTrustSkeleton } from '@rockcarver/frodo-lib/types/api/CirclesOfTrustApi';\nimport { type CirclesOfTrustExportInterface } from '@rockcarver/frodo-lib/types/ops/CirclesOfTrustOps';\nimport fs from 'fs';\n\nimport {\n createProgressBar,\n createTable,\n debugMessage,\n failSpinner,\n printMessage,\n showSpinner,\n stopProgressBar,\n succeedSpinner,\n updateProgressBar,\n} from '../utils/Console';\nimport {\n getTypedFilename,\n saveJsonToFile,\n titleCase,\n} from '../utils/ExportImportUtils';\n\nconst { getRealmName, getFilePath, getWorkingDirectory } = frodo.utils;\nconst {\n readCirclesOfTrust,\n exportCircleOfTrust,\n exportCirclesOfTrust,\n importCircleOfTrust,\n importCirclesOfTrust,\n importFirstCircleOfTrust,\n} = frodo.saml2.circlesOfTrust;\n\n/**\n * Get a one-line description of the circle of trust object\n * @param {CircleOfTrustSkeleton} cotObj circle of trust object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(cotObj: CircleOfTrustSkeleton): string {\n const description = `[${cotObj._id['brightCyan']}]`;\n return description;\n}\n\n/**\n * Get markdown table header\n * @returns {string} markdown table header\n */\nexport function getTableHeaderMd(): string {\n let markdown = '';\n markdown += '| Name/Id | Status | Trusted Providers |\\n';\n markdown += '| ------- | ------ | ----------------- |';\n return markdown;\n}\n\n/**\n * Get a table-row of the circle of trust in markdown\n * @param {SocialIdpSkeleton} cotObj circle of trust object to describe\n * @returns {string} a table-row of the circle of trust in markdown\n */\nexport function getTableRowMd(cotObj: CircleOfTrustSkeleton): string {\n const row = `| ${cotObj._id} | ${\n cotObj.status === 'active'\n ? ':white_check_mark: `active`'\n : ':o: `inactive`'\n } | ${cotObj.trustedProviders\n .map((provider) => provider.split('|')[0])\n .join('<br>')} |`;\n return row;\n}\n\n/**\n * List entity providers\n * @param {String} long Long list format with details\n */\nexport async function listCirclesOfTrust(long = false): Promise<boolean> {\n let outcome = false;\n let cotList = [];\n try {\n cotList = await readCirclesOfTrust();\n } catch (error) {\n printMessage(`readCirclesOfTrust ERROR: ${error}`, 'error');\n printMessage(error, 'data');\n }\n cotList.sort((a, b) => a._id.localeCompare(b._id));\n if (!long) {\n cotList.forEach((cot) => {\n printMessage(`${cot._id}`, 'data');\n });\n outcome = true;\n } else {\n const table = createTable([\n 'Name'['brightCyan'],\n 'Description'['brightCyan'],\n 'Status'['brightCyan'],\n 'Trusted Providers'['brightCyan'],\n ]);\n cotList.forEach((cot) => {\n table.push([\n cot._id,\n cot.description,\n cot.status,\n cot.trustedProviders\n .map((provider) => provider.split('|')[0])\n .join('\\n'),\n ]);\n });\n printMessage(table.toString(), 'data');\n outcome = true;\n }\n return outcome;\n}\n\n/**\n * Export a single circle of trust to file\n * @param {String} cotId circle of trust id/name\n * @param {String} file Optional filename\n */\nexport async function exportCircleOfTrustToFile(\n cotId: string,\n file: string = null\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.CirclesOfTrustOps.exportCircleOfTrustToFile: begin`);\n showSpinner(`Exporting ${cotId}...`);\n try {\n let fileName = getTypedFilename(cotId, 'cot.saml');\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const exportData = await exportCircleOfTrust(cotId);\n saveJsonToFile(exportData, filePath);\n succeedSpinner(`Exported ${cotId} to ${filePath}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting ${cotId}: ${error.message}`);\n }\n debugMessage(`cli.CirclesOfTrustOps.exportCircleOfTrustToFile: end`);\n return outcome;\n}\n\n/**\n * Export all circles of trust to one file\n * @param {String} file Optional filename\n */\nexport async function exportCirclesOfTrustToFile(\n file: string = null\n): Promise<boolean> {\n let outcome = false;\n debugMessage(`cli.CirclesOfTrustOps.exportCirclesOfTrustToFile: begin`);\n showSpinner(`Exporting all circles of trust...`);\n try {\n let fileName = getTypedFilename(\n `all${titleCase(getRealmName(state.getRealm()))}CirclesOfTrust`,\n 'cot.saml'\n );\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const exportData = await exportCirclesOfTrust();\n saveJsonToFile(exportData, filePath);\n succeedSpinner(`Exported all circles of trust to ${filePath}.`);\n outcome = true;\n } catch (error) {\n failSpinner(`Error exporting circles of trust: ${error.message}`);\n }\n debugMessage(`cli.CirclesOfTrustOps.exportCirclesOfTrustToFile: end`);\n return outcome;\n}\n\n/**\n * Export all circles of trust to individual files\n */\nexport async function exportCirclesOfTrustToFiles(): Promise<boolean> {\n debugMessage(`cli.CirclesOfTrustOps.exportCirclesOfTrustToFiles: begin`);\n const errors = [];\n try {\n const cots: CircleOfTrustSkeleton[] = await readCirclesOfTrust();\n createProgressBar(cots.length, 'Exporting circles of trust...');\n for (const cot of cots) {\n const file = getTypedFilename(cot._id, 'cot.saml');\n try {\n const exportData: CirclesOfTrustExportInterface =\n await exportCircleOfTrust(cot._id);\n saveJsonToFile(exportData, getFilePath(file, true));\n updateProgressBar(`Exported ${cot.name}.`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error exporting ${cot.name}.`);\n }\n }\n stopProgressBar(`Export complete.`);\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error exporting circles of trust to files`);\n }\n debugMessage(`cli.CirclesOfTrustOps.exportCirclesOfTrustToFiles: end`);\n return 0 === errors.length;\n}\n\n/**\n * Import a SAML circle of trust by id/name from file\n * @param {String} cotId Circle of trust id/name\n * @param {String} file Import file name\n */\nexport async function importCircleOfTrustFromFile(\n cotId: string,\n file: string\n): Promise<boolean> {\n let outcome = false;\n const filePath = getFilePath(file);\n showSpinner(`Importing circle of trust ${cotId} from ${filePath}...`);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importCircleOfTrust(cotId, fileData);\n outcome = true;\n succeedSpinner(`Imported circle of trust ${cotId} from ${filePath}.`);\n } catch (error) {\n failSpinner(`Error importing circle of trust ${cotId} from ${filePath}.`);\n printMessage(error.response?.data || error, 'error');\n }\n return outcome;\n}\n\n/**\n * Import first SAML circle of trust from file\n * @param {String} file Import file name\n */\nexport async function importFirstCircleOfTrustFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n const filePath = getFilePath(file);\n showSpinner(`Importing first circle of trust from ${filePath}...`);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importFirstCircleOfTrust(fileData);\n outcome = true;\n succeedSpinner(`Imported first circle of trust from ${filePath}.`);\n } catch (error) {\n failSpinner(`Error importing first circle of trust from ${filePath}.`);\n printMessage(error.response?.data || error, 'error');\n }\n return outcome;\n}\n\n/**\n * Import all SAML circles of trust from file\n * @param {String} file Import file name\n */\nexport async function importCirclesOfTrustFromFile(\n file: string\n): Promise<boolean> {\n let outcome = false;\n const filePath = getFilePath(file);\n showSpinner(`Importing circles of trust from ${filePath}...`);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importCirclesOfTrust(fileData);\n outcome = true;\n succeedSpinner(`Imported circles of trust from ${filePath}.`);\n } catch (error) {\n failSpinner(`Error importing circles of trust from ${filePath}.`);\n printMessage(error.response?.data || error, 'error');\n }\n return outcome;\n}\n\n/**\n * Import all SAML circles of trust from all *.cot.saml.json files in the current directory\n */\nexport async function importCirclesOfTrustFromFiles(): Promise<boolean> {\n const errors = [];\n try {\n debugMessage(`cli.CirclesOfTrustOps.importCirclesOfTrustFromFiles: begin`);\n const names = fs.readdirSync(getWorkingDirectory());\n const files = names\n .filter((name) => name.toLowerCase().endsWith('.cot.saml.json'))\n .map((name) => getFilePath(name));\n createProgressBar(files.length, 'Importing circles of trust...');\n let total = 0;\n for (const file of files) {\n try {\n const data = fs.readFileSync(file, 'utf8');\n const fileData: CirclesOfTrustExportInterface = JSON.parse(data);\n const count = Object.keys(fileData.saml.cot).length;\n total += count;\n await importCirclesOfTrust(fileData);\n updateProgressBar(`Imported ${count} circles of trust from ${file}`);\n } catch (error) {\n errors.push(error);\n updateProgressBar(`Error importing circles of trust from ${file}`);\n printMessage(error, 'error');\n }\n }\n stopProgressBar(\n `Imported ${total} circles of trust from ${files.length} files.`\n );\n } catch (error) {\n errors.push(error);\n stopProgressBar(`Error importing circles of trust from files.`);\n printMessage(error, 'error');\n }\n debugMessage(`cli.CirclesOfTrustOps.importCirclesOfTrustFromFiles: end`);\n return 0 === errors.length;\n}\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,KAAK,QAAQ,uBAAuB;AAGpD,OAAOC,EAAE,MAAM,IAAI;AAEnB,SACEC,iBAAiB,EACjBC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,WAAW,EACXC,eAAe,EACfC,cAAc,EACdC,iBAAiB,QACZ,kBAAkB;AACzB,SACEC,gBAAgB,EAChBC,cAAc,EACdC,SAAS,QACJ,4BAA4B;AAEnC,MAAM;EAAEC,YAAY;EAAEC,WAAW;EAAEC;AAAoB,CAAC,GAAGjB,KAAK,CAACkB,KAAK;AACtE,MAAM;EACJC,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E,MAAM;AAC5B"}
@@ -1 +1 @@
1
- {"version":3,"file":"OAuth2ClientOps.js","names":["frodo","state","fs","createProgressBar","createTable","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","saveJsonToFile","getTypedFilename","titleCase","getFilePath","getWorkingDirectory","utils","readOAuth2Clients","exportOAuth2Client","exportOAuth2Clients","importOAuth2Client","importFirstOAuth2Client","importOAuth2Clients","oauth2oidc","client","listOAuth2Clients","long","clients","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","filePath","exportData","message","exportOAuth2ClientsToFile","getRealmName","getRealm","exportOAuth2ClientsToFiles","errors","length","importOAuth2ClientFromFile","data","readFileSync","fileData","JSON","parse","importFirstOAuth2ClientFromFile","importOAuth2ClientsFromFile","clientData","importOAuth2ClientsFromFiles","names","readdirSync","files","filter","name","toLowerCase","endsWith","total","count","Object","keys","application"],"sources":["../../src/ops/OAuth2ClientOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { ReadableStrings } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport type {\n OAuth2ClientExportInterface,\n OAuth2ClientExportOptions,\n OAuth2ClientImportOptions,\n} from '@rockcarver/frodo-lib/types/ops/OAuth2ClientOps';\nimport fs from 'fs';\n\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';\n\nconst { getTypedFilename, titleCase, getFilePath, getWorkingDirectory } =\n frodo.utils;\nconst {\n readOAuth2Clients,\n exportOAuth2Client,\n exportOAuth2Clients,\n importOAuth2Client,\n importFirstOAuth2Client,\n importOAuth2Clients,\n} = frodo.oauth2oidc.client;\n\n/**\n * List OAuth2 clients\n */\nexport async function listOAuth2Clients(long = false) {\n try {\n const clients = await readOAuth2Clients();\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 oauth2 clients - ${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 = getTypedFilename(clientId, 'oauth2.app');\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const exportData = await exportOAuth2Client(clientId, options);\n saveJsonToFile(exportData, filePath);\n succeedSpinner(`Exported ${clientId} to ${filePath}.`);\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 = getTypedFilename(\n `all${titleCase(frodo.utils.getRealmName(state.getRealm()))}Applications`,\n 'oauth2.app'\n );\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const exportData = await exportOAuth2Clients(options);\n saveJsonToFile(exportData, filePath);\n succeedSpinner(`Exported all clients to ${filePath}.`);\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 readOAuth2Clients();\n createProgressBar(clients.length, 'Exporting clients...');\n for (const client of clients) {\n const file = getTypedFilename(client._id, 'oauth2.app');\n try {\n const exportData: OAuth2ClientExportInterface =\n await exportOAuth2Client(client._id, options);\n saveJsonToFile(exportData, getFilePath(file, true));\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(getFilePath(file), 'utf8');\n const fileData = JSON.parse(data);\n await importOAuth2Client(clientId, fileData, options);\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 const filePath = getFilePath(file);\n showSpinner(`Importing ${filePath}...`);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importFirstOAuth2Client(fileData, options);\n outcome = true;\n succeedSpinner(`Imported ${filePath}.`);\n } catch (error) {\n failSpinner(`Error importing ${filePath}.`);\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 const filePath = getFilePath(file);\n showSpinner(`Importing ${filePath}...`);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const clientData = JSON.parse(data);\n await importOAuth2Clients(clientData, options);\n outcome = true;\n succeedSpinner(`Imported ${filePath}.`);\n } catch (error) {\n failSpinner(`Error importing ${filePath}.`);\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(getWorkingDirectory());\n const files = names\n .filter((name) => name.toLowerCase().endsWith('.oauth2.app.json'))\n .map((name) => getFilePath(name));\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 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;AAOpD,OAAOC,EAAE,MAAM,IAAI;AAEnB,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;AAE3D,MAAM;EAAEC,gBAAgB;EAAEC,SAAS;EAAEC,WAAW;EAAEC;AAAoB,CAAC,GACrEhB,KAAK,CAACiB,KAAK;AACb,MAAM;EACJC,iBAAiB;EACjBC,kBAAkB;EAClBC,mBAAmB;EACnBC,kBAAkB;EAClBC,uBAAuB;EACvBC;AACF,CAAC,GAAGvB,KAAK,CAACwB,UAAU,CAACC,MAAM;;AAE3B;AACA;AACA;AACA,OAAO,eAAeC,iBAAiBA,CAACC,IAAI,GAAG,KAAK,EAAE;EACpD,IAAI;IACF,MAAMC,OAAO,GAAG,MAAMV,iBAAiB,CAAC,CAAC;IACzCU,OAAO,CAACC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACE,GAAG,CAACC,aAAa,CAACF,CAAC,CAACC,GAAG,CAAC,CAAC;IAClD,IAAIL,IAAI,EAAE;MACR,MAAMO,KAAK,GAAG9B,WAAW,CAAC,CACxB,WAAW,EACX,QAAQ,EACR,aAAa,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,CAACC,KAAK,CAACJ,IAAI,CAAC;QAC9D,MAAMiB,KAAK,GAAGC,MAAM,CAACC,IAAI,CAACjB,QAAQ,CAACkB,WAAW,CAAC,CAACtB,MAAM;QACtDkB,KAAK,IAAIC,KAAK;QACd,MAAMnE,mBAAmB,CAACoD,QAAQ,EAAEjB,OAAO,CAAC;QAC5C/C,iBAAiB,CAAE,YAAW+E,KAAM,mBAAkBjC,IAAK,EAAC,CAAC;MAC/D,CAAC,CAAC,OAAOH,KAAK,EAAE;QACdgB,MAAM,CAAC5B,IAAI,CAACY,KAAK,CAAC;QAClB3C,iBAAiB,CAAE,kCAAiC8C,IAAK,EAAC,CAAC;QAC3DlD,YAAY,CAAC+C,KAAK,EAAE,OAAO,CAAC;MAC9B;IACF;IACA7C,eAAe,CACZ,sBAAqBgF,KAAM,mBAAkBL,KAAK,CAACb,MAAO,WAC7D,CAAC;EACH,CAAC,CAAC,OAAOjB,KAAK,EAAE;IACdgB,MAAM,CAAC5B,IAAI,CAACY,KAAK,CAAC;IAClB7C,eAAe,CAAE,yCAAwC,CAAC;IAC1DF,YAAY,CAAC+C,KAAK,EAAE,OAAO,CAAC;EAC9B;EACAjD,YAAY,CAAE,uDAAsD,CAAC;EACrE,OAAO,CAAC,KAAKiE,MAAM,CAACC,MAAM;AAC5B"}
1
+ {"version":3,"file":"OAuth2ClientOps.js","names":["frodo","state","fs","createProgressBar","createTable","debugMessage","failSpinner","printMessage","showSpinner","stopProgressBar","succeedSpinner","updateProgressBar","saveJsonToFile","getTypedFilename","titleCase","getFilePath","getWorkingDirectory","utils","readOAuth2Clients","exportOAuth2Client","exportOAuth2Clients","importOAuth2Client","importFirstOAuth2Client","importOAuth2Clients","oauth2oidc","client","listOAuth2Clients","long","clients","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","filePath","exportData","message","exportOAuth2ClientsToFile","getRealmName","getRealm","exportOAuth2ClientsToFiles","errors","length","importOAuth2ClientFromFile","data","readFileSync","fileData","JSON","parse","importFirstOAuth2ClientFromFile","importOAuth2ClientsFromFile","clientData","importOAuth2ClientsFromFiles","names","readdirSync","files","filter","name","toLowerCase","endsWith","total","count","Object","keys","application"],"sources":["../../src/ops/OAuth2ClientOps.ts"],"sourcesContent":["import { frodo, state } from '@rockcarver/frodo-lib';\nimport { Readable } from '@rockcarver/frodo-lib/types/api/ApiTypes';\nimport type {\n OAuth2ClientExportInterface,\n OAuth2ClientExportOptions,\n OAuth2ClientImportOptions,\n} from '@rockcarver/frodo-lib/types/ops/OAuth2ClientOps';\nimport fs from 'fs';\n\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';\n\nconst { getTypedFilename, titleCase, getFilePath, getWorkingDirectory } =\n frodo.utils;\nconst {\n readOAuth2Clients,\n exportOAuth2Client,\n exportOAuth2Clients,\n importOAuth2Client,\n importFirstOAuth2Client,\n importOAuth2Clients,\n} = frodo.oauth2oidc.client;\n\n/**\n * List OAuth2 clients\n */\nexport async function listOAuth2Clients(long = false) {\n try {\n const clients = await readOAuth2Clients();\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 Readable<string[]>)\n .map((type) => grantTypesMap[type])\n .join('\\n'),\n (client.coreOAuth2ClientConfig.scopes as Readable<string[]>).join(\n '\\n'\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 oauth2 clients - ${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 = getTypedFilename(clientId, 'oauth2.app');\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const exportData = await exportOAuth2Client(clientId, options);\n saveJsonToFile(exportData, filePath);\n succeedSpinner(`Exported ${clientId} to ${filePath}.`);\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 = getTypedFilename(\n `all${titleCase(frodo.utils.getRealmName(state.getRealm()))}Applications`,\n 'oauth2.app'\n );\n if (file) {\n fileName = file;\n }\n const filePath = getFilePath(fileName, true);\n const exportData = await exportOAuth2Clients(options);\n saveJsonToFile(exportData, filePath);\n succeedSpinner(`Exported all clients to ${filePath}.`);\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 readOAuth2Clients();\n createProgressBar(clients.length, 'Exporting clients...');\n for (const client of clients) {\n const file = getTypedFilename(client._id, 'oauth2.app');\n try {\n const exportData: OAuth2ClientExportInterface =\n await exportOAuth2Client(client._id, options);\n saveJsonToFile(exportData, getFilePath(file, true));\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(getFilePath(file), 'utf8');\n const fileData = JSON.parse(data);\n await importOAuth2Client(clientId, fileData, options);\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 const filePath = getFilePath(file);\n showSpinner(`Importing ${filePath}...`);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const fileData = JSON.parse(data);\n await importFirstOAuth2Client(fileData, options);\n outcome = true;\n succeedSpinner(`Imported ${filePath}.`);\n } catch (error) {\n failSpinner(`Error importing ${filePath}.`);\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 const filePath = getFilePath(file);\n showSpinner(`Importing ${filePath}...`);\n try {\n const data = fs.readFileSync(filePath, 'utf8');\n const clientData = JSON.parse(data);\n await importOAuth2Clients(clientData, options);\n outcome = true;\n succeedSpinner(`Imported ${filePath}.`);\n } catch (error) {\n failSpinner(`Error importing ${filePath}.`);\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(getWorkingDirectory());\n const files = names\n .filter((name) => name.toLowerCase().endsWith('.oauth2.app.json'))\n .map((name) => getFilePath(name));\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 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;AAOpD,OAAOC,EAAE,MAAM,IAAI;AA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,OAAO,CAAC;MAC9B;IACF;IACA7C,eAAe,CACZ,sBAAqBgF,KAAM,mBAAkBL,KAAK,CAACb,MAAO,WAC7D,CAAC;EACH,CAAC,CAAC,OAAOjB,KAAK,EAAE;IACdgB,MAAM,CAAC5B,IAAI,CAACY,KAAK,CAAC;IAClB7C,eAAe,CAAE,yCAAwC,CAAC;IAC1DF,YAAY,CAAC+C,KAAK,EAAE,OAAO,CAAC;EAC9B;EACAjD,YAAY,CAAE,uDAAsD,CAAC;EACrE,OAAO,CAAC,KAAKiE,MAAM,CAACC,MAAM;AAC5B"}
@@ -16,7 +16,8 @@ const {
16
16
  exportPoliciesByPolicySet,
17
17
  importPolicy,
18
18
  importFirstPolicy,
19
- importPolicies
19
+ importPolicies,
20
+ deletePolicy
20
21
  } = frodo.authz.policy;
21
22
 
22
23
  /**
@@ -29,11 +30,6 @@ export async function listPolicies(long = false) {
29
30
  try {
30
31
  const policies = await readPolicies();
31
32
  policies.sort((a, b) => a._id.localeCompare(b._id));
32
- for (const policy of policies) {
33
- if (!long) {
34
- printMessage(`${policy._id}`, 'data');
35
- }
36
- }
37
33
  if (long) {
38
34
  const table = createTable(['Id', 'Description', 'Status']);
39
35
  for (const policy of policies) {
@@ -107,23 +103,17 @@ export async function describePolicy(policyId, json = false) {
107
103
  * @param {string} policyId policy id/name
108
104
  * @returns {Promise<boolean>} true if successful, false otherwise
109
105
  */
110
- export async function deletePolicy(policyId) {
106
+ export async function deletePolicyById(policyId) {
111
107
  debugMessage(`cli.PolicyOps.deletePolicy: begin`);
112
108
  showSpinner(`Deleting ${policyId}...`);
113
109
  let outcome = false;
114
- const errors = [];
115
110
  try {
116
111
  debugMessage(`Deleting policy ${policyId}`);
117
112
  await deletePolicy(policyId);
118
- } catch (error) {
119
- printMessage(`Error deleting policy ${policyId}: ${error}`, 'error');
120
- }
121
- if (errors.length) {
122
- const errorMessages = errors.map(error => error.message).join('\n');
123
- failSpinner(`Error deleting ${policyId}: ${errorMessages}`);
124
- } else {
125
113
  succeedSpinner(`Deleted ${policyId}.`);
126
114
  outcome = true;
115
+ } catch (error) {
116
+ failSpinner(`Error deleting policy ${policyId}: ${error}`);
127
117
  }
128
118
  debugMessage(`cli.PolicyOps.deletePolicy: end [outcome=${outcome}]`);
129
119
  return outcome;