@rockcarver/frodo-lib 0.12.1 → 0.12.2-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -1
- package/cjs/api/BaseApi.js +36 -8
- package/cjs/api/BaseApi.js.map +1 -1
- package/cjs/api/NodeApi.js +190 -0
- package/cjs/api/NodeApi.js.map +1 -0
- package/cjs/api/NodeApi.test.js.map +1 -0
- package/cjs/api/OAuth2ClientApi.js +3 -1
- package/cjs/api/OAuth2ClientApi.js.map +1 -1
- package/cjs/api/SecretsApi.js +59 -29
- package/cjs/api/SecretsApi.js.map +1 -1
- package/cjs/api/StartupApi.js +21 -8
- package/cjs/api/StartupApi.js.map +1 -1
- package/cjs/api/StartupApi.test.js.map +1 -0
- package/cjs/api/TreeApi.js +30 -161
- package/cjs/api/TreeApi.js.map +1 -1
- package/cjs/api/TreeApi.test.js.map +1 -0
- package/cjs/api/VariablesApi.js +35 -20
- package/cjs/api/VariablesApi.js.map +1 -1
- package/cjs/index.js +15 -5
- package/cjs/index.js.map +1 -1
- package/cjs/ops/AuthenticateOps.js +1 -1
- package/cjs/ops/AuthenticateOps.js.map +1 -1
- package/cjs/ops/IdpOps.js +1 -1
- package/cjs/ops/IdpOps.js.map +1 -1
- package/cjs/ops/JourneyOps.js +233 -204
- package/cjs/ops/JourneyOps.js.map +1 -1
- package/cjs/ops/OAuth2ClientOps.js +27 -20
- package/cjs/ops/OAuth2ClientOps.js.map +1 -1
- package/cjs/ops/SecretsOps.js +9 -7
- package/cjs/ops/SecretsOps.js.map +1 -1
- package/cjs/ops/StartupOps.js +61 -71
- package/cjs/ops/StartupOps.js.map +1 -1
- package/cjs/ops/VariablesOps.js +3 -3
- package/cjs/ops/VariablesOps.js.map +1 -1
- package/cjs/ops/utils/Console.js +3 -2
- package/cjs/ops/utils/Console.js.map +1 -1
- package/cjs/ops/utils/ExportImportUtils.js +1 -0
- package/cjs/ops/utils/ExportImportUtils.js.map +1 -1
- package/esm/api/BaseApi.mjs +35 -7
- package/esm/api/NodeApi.mjs +114 -0
- package/esm/api/NodeApi.test.mjs +105 -0
- package/esm/api/OAuth2ClientApi.mjs +4 -2
- package/esm/api/SecretsApi.mjs +59 -29
- package/esm/api/StartupApi.mjs +18 -8
- package/esm/api/StartupApi.test.mjs +56 -0
- package/esm/api/TreeApi.mjs +29 -99
- package/esm/api/TreeApi.test.mjs +175 -0
- package/esm/api/VariablesApi.mjs +35 -20
- package/esm/index.mjs +7 -5
- package/esm/ops/AuthenticateOps.mjs +1 -1
- package/esm/ops/IdpOps.mjs +1 -1
- package/esm/ops/JourneyOps.mjs +186 -154
- package/esm/ops/OAuth2ClientOps.mjs +9 -4
- package/esm/ops/SecretsOps.mjs +9 -7
- package/esm/ops/StartupOps.mjs +59 -62
- package/esm/ops/VariablesOps.mjs +3 -3
- package/esm/ops/utils/Console.mjs +3 -2
- package/esm/ops/utils/ExportImportUtils.mjs +1 -0
- package/package.json +7 -4
- package/types/api/AuthenticateApi.d.ts +2 -0
- package/types/api/AuthenticateApi.d.ts.map +1 -0
- package/types/api/BaseApi.d.ts +50 -0
- package/types/api/BaseApi.d.ts.map +1 -0
- package/types/api/CirclesOfTrustApi.d.ts +24 -0
- package/types/api/CirclesOfTrustApi.d.ts.map +1 -0
- package/types/api/EmailTemplateApi.d.ts +22 -0
- package/types/api/EmailTemplateApi.d.ts.map +1 -0
- package/types/api/IdmConfigApi.d.ts +39 -0
- package/types/api/IdmConfigApi.d.ts.map +1 -0
- package/types/api/LogApi.d.ts +4 -0
- package/types/api/LogApi.d.ts.map +1 -0
- package/types/api/ManagedObjectApi.d.ts +21 -0
- package/types/api/ManagedObjectApi.d.ts.map +1 -0
- package/types/api/NodeApi.d.ts +38 -0
- package/types/api/NodeApi.d.ts.map +1 -0
- package/types/api/OAuth2ClientApi.d.ts +18 -0
- package/types/api/OAuth2ClientApi.d.ts.map +1 -0
- package/types/api/OAuth2OIDCApi.d.ts +22 -0
- package/types/api/OAuth2OIDCApi.d.ts.map +1 -0
- package/types/api/OAuth2ProviderApi.d.ts +5 -0
- package/types/api/OAuth2ProviderApi.d.ts.map +1 -0
- package/types/api/RealmApi.d.ts +30 -0
- package/types/api/RealmApi.d.ts.map +1 -0
- package/types/api/Saml2Api.d.ts +52 -0
- package/types/api/Saml2Api.d.ts.map +1 -0
- package/types/api/ScriptApi.d.ts +24 -0
- package/types/api/ScriptApi.d.ts.map +1 -0
- package/types/api/SecretsApi.d.ts +10 -0
- package/types/api/SecretsApi.d.ts.map +1 -0
- package/types/api/ServerInfoApi.d.ts +10 -0
- package/types/api/ServerInfoApi.d.ts.map +1 -0
- package/types/api/SocialIdentityProvidersApi.d.ts +31 -0
- package/types/api/SocialIdentityProvidersApi.d.ts.map +1 -0
- package/types/api/StartupApi.d.ts +14 -0
- package/types/api/StartupApi.d.ts.map +1 -0
- package/types/api/ThemeApi.d.ts +54 -0
- package/types/api/ThemeApi.d.ts.map +1 -0
- package/types/api/TreeApi.d.ts +24 -0
- package/types/api/TreeApi.d.ts.map +1 -0
- package/types/api/VariablesApi.d.ts +32 -0
- package/types/api/VariablesApi.d.ts.map +1 -0
- package/types/api/utils/ApiUtils.d.ts +29 -0
- package/types/api/utils/ApiUtils.d.ts.map +1 -0
- package/types/api/utils/Base64.d.ts +30 -0
- package/types/api/utils/Base64.d.ts.map +1 -0
- package/types/index.d.ts +26 -0
- package/types/index.d.ts.map +1 -0
- package/types/ops/AdminOps.d.ts +11 -0
- package/types/ops/AdminOps.d.ts.map +1 -0
- package/types/ops/AuthenticateOps.d.ts +6 -0
- package/types/ops/AuthenticateOps.d.ts.map +1 -0
- package/types/ops/CirclesOfTrustOps.d.ts +40 -0
- package/types/ops/CirclesOfTrustOps.d.ts.map +1 -0
- package/types/ops/ConnectionProfileOps.d.ts +47 -0
- package/types/ops/ConnectionProfileOps.d.ts.map +1 -0
- package/types/ops/EmailTemplateOps.d.ts +40 -0
- package/types/ops/EmailTemplateOps.d.ts.map +1 -0
- package/types/ops/IdmOps.d.ts +27 -0
- package/types/ops/IdmOps.d.ts.map +1 -0
- package/types/ops/IdpOps.d.ts +45 -0
- package/types/ops/IdpOps.d.ts.map +1 -0
- package/types/ops/JourneyOps.d.ts +151 -0
- package/types/ops/JourneyOps.d.ts.map +1 -0
- package/types/ops/LogOps.d.ts +5 -0
- package/types/ops/LogOps.d.ts.map +1 -0
- package/types/ops/ManagedObjectOps.d.ts +14 -0
- package/types/ops/ManagedObjectOps.d.ts.map +1 -0
- package/types/ops/OAuth2ClientOps.d.ts +24 -0
- package/types/ops/OAuth2ClientOps.d.ts.map +1 -0
- package/types/ops/OrganizationOps.d.ts +11 -0
- package/types/ops/OrganizationOps.d.ts.map +1 -0
- package/types/ops/RealmOps.d.ts +22 -0
- package/types/ops/RealmOps.d.ts.map +1 -0
- package/types/ops/SamlOps.d.ts +51 -0
- package/types/ops/SamlOps.d.ts.map +1 -0
- package/types/ops/ScriptOps.d.ts +30 -0
- package/types/ops/ScriptOps.d.ts.map +1 -0
- package/types/ops/SecretsOps.d.ts +63 -0
- package/types/ops/SecretsOps.d.ts.map +1 -0
- package/types/ops/StartupOps.d.ts +25 -0
- package/types/ops/StartupOps.d.ts.map +1 -0
- package/types/ops/ThemeOps.d.ts +66 -0
- package/types/ops/ThemeOps.d.ts.map +1 -0
- package/types/ops/VariablesOps.d.ts +39 -0
- package/types/ops/VariablesOps.d.ts.map +1 -0
- package/types/ops/utils/Console.d.ts +63 -0
- package/types/ops/utils/Console.d.ts.map +1 -0
- package/types/ops/utils/DataProtection.d.ts +6 -0
- package/types/ops/utils/DataProtection.d.ts.map +1 -0
- package/types/ops/utils/ExportImportUtils.d.ts +22 -0
- package/types/ops/utils/ExportImportUtils.d.ts.map +1 -0
- package/types/ops/utils/OpsUtils.d.ts +27 -0
- package/types/ops/utils/OpsUtils.d.ts.map +1 -0
- package/types/ops/utils/Wordwrap.d.ts +1 -0
- package/types/ops/utils/Wordwrap.d.ts.map +1 -0
- package/types/storage/SessionStorage.d.ts +47 -0
- package/types/storage/SessionStorage.d.ts.map +1 -0
- package/types/storage/StaticStorage.d.ts +14 -0
- package/types/storage/StaticStorage.d.ts.map +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Console.js","names":["printMessage","message","type","newline","handler","storage","session","getPrintHandler","createProgressIndicator","total","getCreateProgressHandler","updateProgressIndicator","getUpdateProgressHandler","stopProgressIndicator","status","getStopProgressHandler","createTable","head","Table","chars","top","bottom","left","mid","right","style","createKeyValueTable","wordWrap","getObjectDepth","object","Object","Math","max","values","map","hasValues","has","keys","key","addRows","depth","level","table","keyMap","space","push","hAlign","content","indention","Array","fill","join","concat","createObjectTable"],"sources":["ops/utils/Console.ts"],"sourcesContent":["import Table from 'cli-table3';\nimport storage from '../../storage/SessionStorage';\n\n/**\n * Handles data / messages output. The caller decides and implements how\n * the data and messages are handled, by implementing the handler function\n * on its side. `handler` is optional, and if not included by the caller,\n * the data and messages will be lost.\n *\n * @param {string} message The string message to return\n * @param {string} [type=text] \"text\", \"info\", \"warn\", \"error\" or \"data\". All but\n * type=\"data\" will be written to stderr.\n * @param {boolean} [newline=true] Whether to add a newline at the end of message\n * messages returned\n *\n */\nexport function printMessage(message, type = 'text', newline = true) {\n const handler = storage.session.getPrintHandler();\n if (handler) {\n handler(message, type, newline);\n }\n}\n\n/**\n * Calls a callback on client to create a progress indicator.\n * The actual implementation of the indicator is left to the client\n * Two types of indicators are supported:\n * - determinate: should be used when the process completion rate\n * can be detected (example: progress bar showing percentage or count)\n * - indeterminate: used when progress isn’t detectable, or if\n * it’s not necessary to indicate how long an activity will take.\n * (example: spinner showing progress, but not quantifying the progress)\n *\n * Example:\n * [========================================] 100% | 49/49 | Analyzing journey - transactional_auth\n *\n * @param {Number} total The total number of entries to track progress for\n * @param {String} message optional progress bar message\n * @param {String} type optional type of progress indicator. default is 'determinate'\n *\n */\nexport function createProgressIndicator(\n total,\n message = null,\n type = 'determinate'\n) {\n const handler = storage.session.getCreateProgressHandler();\n if (handler) {\n handler(type, total, message);\n }\n}\n\n/**\n * Updates the progress indicator with new data/updated status.\n * @param {string} message optional message to show with the indicator\n *\n */\nexport function updateProgressIndicator(message = null) {\n const handler = storage.session.getUpdateProgressHandler();\n if (handler) {\n handler(message);\n }\n}\n\n/**\n * Stop and hide the progress indicator\n * @param {*} message optional message to show with the indicator\n */\nexport function stopProgressIndicator(message = null, status = 'none') {\n const handler = storage.session.getStopProgressHandler();\n if (handler) {\n handler(message, status);\n }\n}\n\n/**\n * Create an empty table\n * @param {[String]} head header row as an array of strings\n * @returns {CliTable3} an empty table\n */\nexport function createTable(head) {\n return new Table({\n head,\n chars: {\n top: '',\n 'top-mid': '',\n 'top-left': '',\n 'top-right': '',\n bottom: '',\n 'bottom-mid': '',\n 'bottom-left': '',\n 'bottom-right': '',\n left: '',\n 'left-mid': '',\n mid: '',\n 'mid-mid': '',\n right: '',\n 'right-mid': '',\n },\n style: { 'padding-left': 0, 'padding-right': 0, head: ['brightCyan'] },\n });\n}\n\n/**\n * Create a new key/value table\n * @returns {CliTable3} an empty key/value table\n */\nexport function createKeyValueTable() {\n return new Table({\n chars: {\n top: '',\n 'top-mid': '',\n 'top-left': '',\n 'top-right': '',\n bottom: '',\n 'bottom-mid': '',\n 'bottom-left': '',\n 'bottom-right': '',\n left: '',\n 'left-mid': '',\n mid: '',\n 'mid-mid': '',\n right: '',\n 'right-mid': '',\n },\n style: { 'padding-left': 0, 'padding-right': 0 },\n wordWrap: true,\n });\n}\n\n/**\n * Helper function to determine the total depth of an object\n * @param {Object} object input object\n * @returns {Number} total depth of the input object\n */\nfunction getObjectDepth(object) {\n return Object(object) === object\n ? 1 + Math.max(-1, ...Object.values(object).map(getObjectDepth))\n : 0;\n}\n\n/**\n * Helper function to determine if an object has values\n * @param {Object} object input object\n * @returns {boolean} true of the object or any of its sub-objects contain values, false otherwise\n */\nfunction hasValues(object) {\n let has = false;\n const keys = Object.keys(object);\n for (const key of keys) {\n if (Object(object[key]) !== object[key]) {\n return true;\n }\n has = has || hasValues(object[key]);\n }\n return has;\n}\n\n/**\n * Helper function (recursive) to add rows to an object table\n * @param {Object} object object to render\n * @param {Number} depth total depth of initial object\n * @param {Number} level current level\n * @param {CliTable3} table the object table to add the rows to\n * @returns the updated object table\n */\nfunction addRows(object, depth, level, table, keyMap) {\n const space = ' ';\n const keys = Object.keys(object);\n for (const key of keys) {\n if (Object(object[key]) !== object[key]) {\n if (level === 1) {\n table.push([\n keyMap[key] ? keyMap[key]['brightCyan'] : key['brightCyan'],\n object[key],\n ]);\n } else {\n table.push([\n {\n hAlign: 'right',\n content: keyMap[key] ? keyMap[key]['gray'] : key['gray'],\n },\n object[key],\n ]);\n }\n }\n }\n for (const key of keys) {\n if (Object(object[key]) === object[key]) {\n // only print header if there are any values below\n if (hasValues(object[key])) {\n let indention = new Array(level).fill(space).join('');\n if (level < 3) indention = `\\n${indention}`;\n table.push([\n indention.concat(\n keyMap[key] ? keyMap[key]['brightCyan'] : key['brightCyan']\n ),\n '',\n ]);\n }\n // eslint-disable-next-line no-param-reassign\n table = addRows(object[key], depth, level + 1, table, keyMap);\n }\n }\n return table;\n}\n\n/**\n * Create and populate an object table from any JSON object. Use for describe commands.\n * @param {Object} object JSON object to create\n * @returns {CliTable3} a table that can be printed to the console\n */\nexport function createObjectTable(object, keyMap = {}) {\n // eslint-disable-next-line no-param-reassign\n const depth = getObjectDepth(object);\n // eslint-disable-next-line no-param-reassign\n const level = 0;\n // eslint-disable-next-line no-param-reassign\n const table = new Table({\n chars: {\n top: '',\n 'top-mid': '',\n 'top-left': '',\n 'top-right': '',\n bottom: '',\n 'bottom-mid': '',\n 'bottom-left': '',\n 'bottom-right': '',\n left: '',\n 'left-mid': '',\n mid: '',\n 'mid-mid': '',\n right: '',\n 'right-mid': '',\n },\n style: { 'padding-left': 0, 'padding-right': 0, head: ['brightCyan'] },\n });\n addRows(object, depth, level + 1, table, keyMap);\n return table;\n}\n"],"mappings":";;;;;;;;;;;;;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W,EAFN;MAGL,YAAY,EAHP;MAIL,aAAa,EAJR;MAKLC,MAAM,EAAE,EALH;MAML,cAAc,EANT;MAOL,eAAe,EAPV;MAQL,gBAAgB,EARX;MASLC,IAAI,EAAE,EATD;MAUL,YAAY,EAVP;MAWLC,GAAG,EAAE,EAXA;MAYL,WAAW,EAZN;MAaLC,KAAK,EAAE,EAbF;MAcL,aAAa;IAdR,CADe;IAiBtBC,KAAK,EAAE;MAAE,gBAAgB,CAAlB;MAAqB,iBAAiB,CAAtC;MAAyCR,IAAI,EAAE,CAAC,YAAD;IAA/C;EAjBe,CAAV,CAAd;EAmBAsB,OAAO,CAACV,MAAD,EAASW,KAAT,EAAgBC,KAAK,GAAG,CAAxB,EAA2BC,KAA3B,EAAkCC,MAAlC,CAAP;EACA,OAAOD,KAAP;AACD"}
|
|
1
|
+
{"version":3,"file":"Console.js","names":["printMessage","message","type","newline","handler","storage","session","getPrintHandler","createProgressIndicator","total","getCreateProgressHandler","updateProgressIndicator","getUpdateProgressHandler","stopProgressIndicator","status","getStopProgressHandler","createTable","head","Table","chars","top","bottom","left","mid","right","style","createKeyValueTable","wordWrap","getObjectDepth","object","Object","Math","max","values","map","hasValues","has","keys","key","addRows","depth","level","table","keyMap","space","push","hAlign","content","indention","Array","fill","join","concat","createObjectTable"],"sources":["ops/utils/Console.ts"],"sourcesContent":["import Table from 'cli-table3';\nimport storage from '../../storage/SessionStorage';\n\n/**\n * Handles data / messages output. The caller decides and implements how\n * the data and messages are handled, by implementing the handler function\n * on its side. `handler` is optional, and if not included by the caller,\n * the data and messages will be lost.\n *\n * @param {string | unknown} message The string message to return\n * @param {string} [type=text] \"text\", \"info\", \"warn\", \"error\" or \"data\". All but\n * type=\"data\" will be written to stderr.\n * @param {boolean} [newline=true] Whether to add a newline at the end of message\n * messages returned\n *\n */\nexport function printMessage(\n message: string | unknown,\n type = 'text',\n newline = true\n) {\n const handler = storage.session.getPrintHandler();\n if (handler) {\n handler(message, type, newline);\n }\n}\n\n/**\n * Calls a callback on client to create a progress indicator.\n * The actual implementation of the indicator is left to the client\n * Two types of indicators are supported:\n * - determinate: should be used when the process completion rate\n * can be detected (example: progress bar showing percentage or count)\n * - indeterminate: used when progress isn’t detectable, or if\n * it’s not necessary to indicate how long an activity will take.\n * (example: spinner showing progress, but not quantifying the progress)\n *\n * Example:\n * [========================================] 100% | 49/49 | Analyzing journey - transactional_auth\n *\n * @param {Number} total The total number of entries to track progress for\n * @param {String} message optional progress bar message\n * @param {String} type optional type of progress indicator. default is 'determinate'\n *\n */\nexport function createProgressIndicator(\n total,\n message: string = null,\n type = 'determinate'\n) {\n const handler = storage.session.getCreateProgressHandler();\n if (handler) {\n handler(type, total, message);\n }\n}\n\n/**\n * Updates the progress indicator with new data/updated status.\n * @param {string} message optional message to show with the indicator\n *\n */\nexport function updateProgressIndicator(message: string = null) {\n const handler = storage.session.getUpdateProgressHandler();\n if (handler) {\n handler(message);\n }\n}\n\n/**\n * Stop and hide the progress indicator\n * @param {string} message optional message to show with the indicator\n * @param {string} status one of 'none', 'success', 'warn', 'fail'\n */\nexport function stopProgressIndicator(message: string = null, status = 'none') {\n const handler = storage.session.getStopProgressHandler();\n if (handler) {\n handler(message, status);\n }\n}\n\n/**\n * Create an empty table\n * @param {[String]} head header row as an array of strings\n * @returns {CliTable3} an empty table\n */\nexport function createTable(head) {\n return new Table({\n head,\n chars: {\n top: '',\n 'top-mid': '',\n 'top-left': '',\n 'top-right': '',\n bottom: '',\n 'bottom-mid': '',\n 'bottom-left': '',\n 'bottom-right': '',\n left: '',\n 'left-mid': '',\n mid: '',\n 'mid-mid': '',\n right: '',\n 'right-mid': '',\n },\n style: { 'padding-left': 0, 'padding-right': 0, head: ['brightCyan'] },\n });\n}\n\n/**\n * Create a new key/value table\n * @returns {CliTable3} an empty key/value table\n */\nexport function createKeyValueTable() {\n return new Table({\n chars: {\n top: '',\n 'top-mid': '',\n 'top-left': '',\n 'top-right': '',\n bottom: '',\n 'bottom-mid': '',\n 'bottom-left': '',\n 'bottom-right': '',\n left: '',\n 'left-mid': '',\n mid: '',\n 'mid-mid': '',\n right: '',\n 'right-mid': '',\n },\n style: { 'padding-left': 0, 'padding-right': 0 },\n wordWrap: true,\n });\n}\n\n/**\n * Helper function to determine the total depth of an object\n * @param {Object} object input object\n * @returns {Number} total depth of the input object\n */\nfunction getObjectDepth(object) {\n return Object(object) === object\n ? 1 + Math.max(-1, ...Object.values(object).map(getObjectDepth))\n : 0;\n}\n\n/**\n * Helper function to determine if an object has values\n * @param {Object} object input object\n * @returns {boolean} true of the object or any of its sub-objects contain values, false otherwise\n */\nfunction hasValues(object) {\n let has = false;\n const keys = Object.keys(object);\n for (const key of keys) {\n if (Object(object[key]) !== object[key]) {\n return true;\n }\n has = has || hasValues(object[key]);\n }\n return has;\n}\n\n/**\n * Helper function (recursive) to add rows to an object table\n * @param {Object} object object to render\n * @param {Number} depth total depth of initial object\n * @param {Number} level current level\n * @param {CliTable3} table the object table to add the rows to\n * @returns the updated object table\n */\nfunction addRows(object, depth, level, table, keyMap) {\n const space = ' ';\n const keys = Object.keys(object);\n for (const key of keys) {\n if (Object(object[key]) !== object[key]) {\n if (level === 1) {\n table.push([\n keyMap[key] ? keyMap[key]['brightCyan'] : key['brightCyan'],\n object[key],\n ]);\n } else {\n table.push([\n {\n hAlign: 'right',\n content: keyMap[key] ? keyMap[key]['gray'] : key['gray'],\n },\n object[key],\n ]);\n }\n }\n }\n for (const key of keys) {\n if (Object(object[key]) === object[key]) {\n // only print header if there are any values below\n if (hasValues(object[key])) {\n let indention = new Array(level).fill(space).join('');\n if (level < 3) indention = `\\n${indention}`;\n table.push([\n indention.concat(\n keyMap[key] ? keyMap[key]['brightCyan'] : key['brightCyan']\n ),\n '',\n ]);\n }\n // eslint-disable-next-line no-param-reassign\n table = addRows(object[key], depth, level + 1, table, keyMap);\n }\n }\n return table;\n}\n\n/**\n * Create and populate an object table from any JSON object. Use for describe commands.\n * @param {Object} object JSON object to create\n * @returns {CliTable3} a table that can be printed to the console\n */\nexport function createObjectTable(object, keyMap = {}) {\n // eslint-disable-next-line no-param-reassign\n const depth = getObjectDepth(object);\n // eslint-disable-next-line no-param-reassign\n const level = 0;\n // eslint-disable-next-line no-param-reassign\n const table = new Table({\n chars: {\n top: '',\n 'top-mid': '',\n 'top-left': '',\n 'top-right': '',\n bottom: '',\n 'bottom-mid': '',\n 'bottom-left': '',\n 'bottom-right': '',\n left: '',\n 'left-mid': '',\n mid: '',\n 'mid-mid': '',\n right: '',\n 'right-mid': '',\n },\n style: { 'padding-left': 0, 'padding-right': 0, head: ['brightCyan'] },\n });\n addRows(object, depth, level + 1, table, keyMap);\n return table;\n}\n"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,YAAT,CACLC,OADK,EAIL;EAAA,IAFAC,IAEA,uEAFO,MAEP;EAAA,IADAC,OACA,uEADU,IACV;;EACA,IAAMC,OAAO,GAAGC,uBAAA,CAAQC,OAAR,CAAgBC,eAAhB,EAAhB;;EACA,IAAIH,OAAJ,EAAa;IACXA,OAAO,CAACH,OAAD,EAAUC,IAAV,EAAgBC,OAAhB,CAAP;EACD;AACF;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASK,uBAAT,CACLC,KADK,EAIL;EAAA,IAFAR,OAEA,uEAFkB,IAElB;EAAA,IADAC,IACA,uEADO,aACP;;EACA,IAAME,OAAO,GAAGC,uBAAA,CAAQC,OAAR,CAAgBI,wBAAhB,EAAhB;;EACA,IAAIN,OAAJ,EAAa;IACXA,OAAO,CAACF,IAAD,EAAOO,KAAP,EAAcR,OAAd,CAAP;EACD;AACF;AAED;AACA;AACA;AACA;AACA;;;AACO,SAASU,uBAAT,GAAyD;EAAA,IAAxBV,OAAwB,uEAAN,IAAM;;EAC9D,IAAMG,OAAO,GA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KAAd,EAAqBC,KAAK,GAAG,CAA7B,EAAgCC,KAAhC,EAAuCC,MAAvC,CAAf;IACD;EACF;;EACD,OAAOD,KAAP;AACD;AAED;AACA;AACA;AACA;AACA;;;AACO,SAASW,iBAAT,CAA2BxB,MAA3B,EAAgD;EAAA,IAAbc,MAAa,uEAAJ,EAAI;EACrD;EACA,IAAMH,KAAK,GAAGZ,cAAc,CAACC,MAAD,CAA5B,CAFqD,CAGrD;;EACA,IAAMY,KAAK,GAAG,CAAd,CAJqD,CAKrD;;EACA,IAAMC,KAAK,GAAG,IAAIxB,iBAAJ,CAAU;IACtBC,KAAK,EAAE;MACLC,GAAG,EAAE,EADA;MAEL,WAAW,EAFN;MAGL,YAAY,EAHP;MAIL,aAAa,EAJR;MAKLC,MAAM,EAAE,EALH;MAML,cAAc,EANT;MAOL,eAAe,EAPV;MAQL,gBAAgB,EARX;MASLC,IAAI,EAAE,EATD;MAUL,YAAY,EAVP;MAWLC,GAAG,EAAE,EAXA;MAYL,WAAW,EAZN;MAaLC,KAAK,EAAE,EAbF;MAcL,aAAa;IAdR,CADe;IAiBtBC,KAAK,EAAE;MAAE,gBAAgB,CAAlB;MAAqB,iBAAiB,CAAtC;MAAyCR,IAAI,EAAE,CAAC,YAAD;IAA/C;EAjBe,CAAV,CAAd;EAmBAsB,OAAO,CAACV,MAAD,EAASW,KAAT,EAAgBC,KAAK,GAAG,CAAxB,EAA2BC,KAA3B,EAAkCC,MAAlC,CAAP;EACA,OAAOD,KAAP;AACD"}
|
|
@@ -38,6 +38,7 @@ function getCurrentTimestamp() {
|
|
|
38
38
|
function getMetadata() {
|
|
39
39
|
var metadata = {
|
|
40
40
|
origin: _SessionStorage.default.session.getTenant(),
|
|
41
|
+
originAmVersion: _SessionStorage.default.session.getAmVersion(),
|
|
41
42
|
exportedBy: _SessionStorage.default.session.getUsername(),
|
|
42
43
|
exportDate: getCurrentTimestamp(),
|
|
43
44
|
exportTool: _StaticStorage.FRODO_METADATA_ID,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExportImportUtils.js","names":["getCurrentTimestamp","ts","Date","toISOString","getMetadata","metadata","origin","storage","session","getTenant","exportedBy","getUsername","exportDate","exportTool","FRODO_METADATA_ID","exportToolVersion","getFrodoVersion","titleCase","input","str","toString","splitStr","toLowerCase","split","i","length","charAt","toUpperCase","slice","join","getRealmString","realm","getRealm","reduce","result","item","convertBase64TextToArray","b64text","arrayOut","plainText","decode","replace","convertBase64UrlTextToArray","b64UTF8Text","decodeBase64Url","convertTextArrayToBase64","textArray","joinedText","b64encodedScript","encode","convertTextArrayToBase64Url","encodeBase64Url","validateImport","getTypedFilename","name","type","suffix","slug","slugify","saveToFile","data","identifier","filename","exportData","Array","isArray","forEach","element","fs","writeFile","JSON","stringify","err","printMessage","saveJsonToFile","meta","saveTextToFile"],"sources":["ops/utils/ExportImportUtils.ts"],"sourcesContent":["import fs from 'fs';\nimport slugify from 'slugify';\nimport storage from '../../storage/SessionStorage';\nimport { FRODO_METADATA_ID } from '../../storage/StaticStorage';\nimport {\n encode,\n decode,\n encodeBase64Url,\n decodeBase64Url,\n} from '../../api/utils/Base64';\nimport { printMessage } from './Console';\n\nexport function getCurrentTimestamp() {\n const ts = new Date();\n return ts.toISOString();\n}\n\nfunction getMetadata() {\n const metadata = {\n origin: storage.session.getTenant(),\n exportedBy: storage.session.getUsername(),\n exportDate: getCurrentTimestamp(),\n exportTool: FRODO_METADATA_ID,\n exportToolVersion: storage.session.getFrodoVersion(),\n };\n return metadata;\n}\n\n/*\n * Output str in title case\n *\n * e.g.: 'ALL UPPERCASE AND all lowercase' = 'All Uppercase And All Lowercase'\n */\nexport function titleCase(input) {\n const str = input.toString();\n const splitStr = str.toLowerCase().split(' ');\n for (let i = 0; i < splitStr.length; i += 1) {\n splitStr[i] = splitStr[i].charAt(0).toUpperCase() + splitStr[i].slice(1);\n }\n return splitStr.join(' ');\n}\n\nexport function getRealmString() {\n const realm = storage.session.getRealm();\n return realm\n .split('/')\n .reduce((result, item) => `${result}${titleCase(item)}`, '');\n}\n\nexport function convertBase64TextToArray(b64text) {\n let arrayOut = [];\n let plainText = decode(b64text);\n plainText = plainText.replace(/\\t/g, ' ');\n arrayOut = plainText.split('\\n');\n return arrayOut;\n}\n\nexport function convertBase64UrlTextToArray(b64UTF8Text) {\n let arrayOut = [];\n let plainText = decodeBase64Url(b64UTF8Text);\n plainText = plainText.replace(/\\t/g, ' ');\n arrayOut = plainText.split('\\n');\n return arrayOut;\n}\n\nexport function convertTextArrayToBase64(textArray) {\n const joinedText = textArray.join('\\n');\n const b64encodedScript = encode(joinedText);\n return b64encodedScript;\n}\n\nexport function convertTextArrayToBase64Url(textArray) {\n const joinedText = textArray.join('\\n');\n const b64encodedScript = encodeBase64Url(joinedText);\n return b64encodedScript;\n}\n\n// eslint-disable-next-line no-unused-vars\nexport function validateImport(metadata): boolean {\n return metadata || true;\n}\n\nexport function getTypedFilename(name, type, suffix = 'json') {\n const slug = slugify(name.replace(/^http(s?):\\/\\//, ''));\n return `${slug}.${type}.${suffix}`;\n}\n\nexport function saveToFile(type, data, identifier, filename) {\n const exportData = {};\n exportData['meta'] = getMetadata();\n exportData[type] = {};\n if (Array.isArray(data)) {\n data.forEach((element) => {\n exportData[type][element[identifier]] = element;\n });\n } else {\n exportData[type][data[identifier]] = data;\n }\n fs.writeFile(filename, JSON.stringify(exportData, null, 2), (err) => {\n if (err) {\n return printMessage(`ERROR - can't save ${type} to file`, 'error');\n }\n return '';\n });\n}\n\n/**\n * Save JSON object to file\n * @param {Object} data data object\n * @param {String} filename file name\n */\nexport function saveJsonToFile(data, filename) {\n const exportData = data;\n exportData.meta = getMetadata();\n fs.writeFile(filename, JSON.stringify(exportData, null, 2), (err) => {\n if (err) {\n return printMessage(`ERROR - can't save ${filename}`, 'error');\n }\n return '';\n });\n}\n\n/**\n * Save text data to file\n * @param {String} data text data\n * @param {String} filename file name\n */\nexport function saveTextToFile(data, filename) {\n fs.writeFile(filename, data, (err) => {\n if (err) {\n printMessage(`ERROR - can't save ${filename}`, 'error');\n return false;\n }\n return true;\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAMA;;;;AAEO,SAASA,mBAAT,GAA+B;EACpC,IAAMC,EAAE,GAAG,IAAIC,IAAJ,EAAX;EACA,OAAOD,EAAE,CAACE,WAAH,EAAP;AACD;;AAED,SAASC,WAAT,GAAuB;EACrB,IAAMC,QAAQ,GAAG;IACfC,MAAM,EAAEC,uBAAA,CAAQC,OAAR,CAAgBC,SAAhB,EADO;IAEfC,
|
|
1
|
+
{"version":3,"file":"ExportImportUtils.js","names":["getCurrentTimestamp","ts","Date","toISOString","getMetadata","metadata","origin","storage","session","getTenant","originAmVersion","getAmVersion","exportedBy","getUsername","exportDate","exportTool","FRODO_METADATA_ID","exportToolVersion","getFrodoVersion","titleCase","input","str","toString","splitStr","toLowerCase","split","i","length","charAt","toUpperCase","slice","join","getRealmString","realm","getRealm","reduce","result","item","convertBase64TextToArray","b64text","arrayOut","plainText","decode","replace","convertBase64UrlTextToArray","b64UTF8Text","decodeBase64Url","convertTextArrayToBase64","textArray","joinedText","b64encodedScript","encode","convertTextArrayToBase64Url","encodeBase64Url","validateImport","getTypedFilename","name","type","suffix","slug","slugify","saveToFile","data","identifier","filename","exportData","Array","isArray","forEach","element","fs","writeFile","JSON","stringify","err","printMessage","saveJsonToFile","meta","saveTextToFile"],"sources":["ops/utils/ExportImportUtils.ts"],"sourcesContent":["import fs from 'fs';\nimport slugify from 'slugify';\nimport storage from '../../storage/SessionStorage';\nimport { FRODO_METADATA_ID } from '../../storage/StaticStorage';\nimport {\n encode,\n decode,\n encodeBase64Url,\n decodeBase64Url,\n} from '../../api/utils/Base64';\nimport { printMessage } from './Console';\n\nexport function getCurrentTimestamp() {\n const ts = new Date();\n return ts.toISOString();\n}\n\nfunction getMetadata() {\n const metadata = {\n origin: storage.session.getTenant(),\n originAmVersion: storage.session.getAmVersion(),\n exportedBy: storage.session.getUsername(),\n exportDate: getCurrentTimestamp(),\n exportTool: FRODO_METADATA_ID,\n exportToolVersion: storage.session.getFrodoVersion(),\n };\n return metadata;\n}\n\n/*\n * Output str in title case\n *\n * e.g.: 'ALL UPPERCASE AND all lowercase' = 'All Uppercase And All Lowercase'\n */\nexport function titleCase(input) {\n const str = input.toString();\n const splitStr = str.toLowerCase().split(' ');\n for (let i = 0; i < splitStr.length; i += 1) {\n splitStr[i] = splitStr[i].charAt(0).toUpperCase() + splitStr[i].slice(1);\n }\n return splitStr.join(' ');\n}\n\nexport function getRealmString() {\n const realm = storage.session.getRealm();\n return realm\n .split('/')\n .reduce((result, item) => `${result}${titleCase(item)}`, '');\n}\n\nexport function convertBase64TextToArray(b64text) {\n let arrayOut = [];\n let plainText = decode(b64text);\n plainText = plainText.replace(/\\t/g, ' ');\n arrayOut = plainText.split('\\n');\n return arrayOut;\n}\n\nexport function convertBase64UrlTextToArray(b64UTF8Text) {\n let arrayOut = [];\n let plainText = decodeBase64Url(b64UTF8Text);\n plainText = plainText.replace(/\\t/g, ' ');\n arrayOut = plainText.split('\\n');\n return arrayOut;\n}\n\nexport function convertTextArrayToBase64(textArray) {\n const joinedText = textArray.join('\\n');\n const b64encodedScript = encode(joinedText);\n return b64encodedScript;\n}\n\nexport function convertTextArrayToBase64Url(textArray) {\n const joinedText = textArray.join('\\n');\n const b64encodedScript = encodeBase64Url(joinedText);\n return b64encodedScript;\n}\n\n// eslint-disable-next-line no-unused-vars\nexport function validateImport(metadata): boolean {\n return metadata || true;\n}\n\nexport function getTypedFilename(name, type, suffix = 'json') {\n const slug = slugify(name.replace(/^http(s?):\\/\\//, ''));\n return `${slug}.${type}.${suffix}`;\n}\n\nexport function saveToFile(type, data, identifier, filename) {\n const exportData = {};\n exportData['meta'] = getMetadata();\n exportData[type] = {};\n if (Array.isArray(data)) {\n data.forEach((element) => {\n exportData[type][element[identifier]] = element;\n });\n } else {\n exportData[type][data[identifier]] = data;\n }\n fs.writeFile(filename, JSON.stringify(exportData, null, 2), (err) => {\n if (err) {\n return printMessage(`ERROR - can't save ${type} to file`, 'error');\n }\n return '';\n });\n}\n\n/**\n * Save JSON object to file\n * @param {Object} data data object\n * @param {String} filename file name\n */\nexport function saveJsonToFile(data, filename) {\n const exportData = data;\n exportData.meta = getMetadata();\n fs.writeFile(filename, JSON.stringify(exportData, null, 2), (err) => {\n if (err) {\n return printMessage(`ERROR - can't save ${filename}`, 'error');\n }\n return '';\n });\n}\n\n/**\n * Save text data to file\n * @param {String} data text data\n * @param {String} filename file name\n */\nexport function saveTextToFile(data, filename) {\n fs.writeFile(filename, data, (err) => {\n if (err) {\n printMessage(`ERROR - can't save ${filename}`, 'error');\n return false;\n }\n return true;\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAMA;;;;AAEO,SAASA,mBAAT,GAA+B;EACpC,IAAMC,EAAE,GAAG,IAAIC,IAAJ,EAAX;EACA,OAAOD,EAAE,CAACE,WAAH,EAAP;AACD;;AAED,SAASC,WAAT,GAAuB;EACrB,IAAMC,QAAQ,GAAG;IACfC,MAAM,EAAEC,uBAAA,CAAQC,OAAR,CAAgBC,SAAhB,EADO;IAEfC,eAAe,EAAEH,uBAAA,CAAQC,OAAR,CAAgBG,YAAhB,EAFF;IAGfC,UAAU,EAAEL,uBAAA,CAAQC,OAAR,CAAgBK,WAAhB,EAHG;IAIfC,UAAU,EAAEd,mBAAmB,EAJhB;IAKfe,UAAU,EAAEC,gCALG;IAMfC,iBAAiB,EAAEV,uBAAA,CAAQC,OAAR,CAAgBU,eAAhB;EANJ,CAAjB;EAQA,OAAOb,QAAP;AACD;AAED;AACA;AACA;AACA;AACA;;;AACO,SAASc,SAAT,CAAmBC,KAAnB,EAA0B;EAC/B,IAAMC,GAAG,GAAGD,KAAK,CAACE,QAAN,EAAZ;EACA,IAAMC,QAAQ,GAAGF,GAAG,CAACG,WAAJ,GAAkBC,KAAlB,CAAwB,GAA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AArC;EACD;;EACDQ,WAAA,CAAGC,SAAH,CAAaP,QAAb,EAAuBQ,IAAI,CAACC,SAAL,CAAeR,UAAf,EAA2B,IAA3B,EAAiC,CAAjC,CAAvB,EAA6DS,GAAD,IAAS;IACnE,IAAIA,GAAJ,EAAS;MACP,OAAO,IAAAC,qBAAA,+BAAmClB,IAAnC,eAAmD,OAAnD,CAAP;IACD;;IACD,OAAO,EAAP;EACD,CALD;AAMD;AAED;AACA;AACA;AACA;AACA;;;AACO,SAASmB,cAAT,CAAwBd,IAAxB,EAA8BE,QAA9B,EAAwC;EAC7C,IAAMC,UAAU,GAAGH,IAAnB;EACAG,UAAU,CAACY,IAAX,GAAkBzE,WAAW,EAA7B;;EACAkE,WAAA,CAAGC,SAAH,CAAaP,QAAb,EAAuBQ,IAAI,CAACC,SAAL,CAAeR,UAAf,EAA2B,IAA3B,EAAiC,CAAjC,CAAvB,EAA6DS,GAAD,IAAS;IACnE,IAAIA,GAAJ,EAAS;MACP,OAAO,IAAAC,qBAAA,+BAAmCX,QAAnC,GAA+C,OAA/C,CAAP;IACD;;IACD,OAAO,EAAP;EACD,CALD;AAMD;AAED;AACA;AACA;AACA;AACA;;;AACO,SAASc,cAAT,CAAwBhB,IAAxB,EAA8BE,QAA9B,EAAwC;EAC7CM,WAAA,CAAGC,SAAH,CAAaP,QAAb,EAAuBF,IAAvB,EAA8BY,GAAD,IAAS;IACpC,IAAIA,GAAJ,EAAS;MACP,IAAAC,qBAAA,+BAAmCX,QAAnC,GAA+C,OAA/C;MACA,OAAO,KAAP;IACD;;IACD,OAAO,IAAP;EACD,CAND;AAOD"}
|
package/esm/api/BaseApi.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import Agent from 'agentkeepalive';
|
|
1
2
|
import axios from 'axios';
|
|
2
3
|
import axiosRetry from 'axios-retry';
|
|
3
|
-
import * as https from 'https';
|
|
4
4
|
import HttpsProxyAgent from 'https-proxy-agent';
|
|
5
5
|
import url from 'url';
|
|
6
6
|
import fs from 'fs';
|
|
@@ -17,15 +17,32 @@ axiosRetry(axios, {
|
|
|
17
17
|
shouldResetTimeout: true,
|
|
18
18
|
retryCondition: _error => true // retry no matter what
|
|
19
19
|
|
|
20
|
-
});
|
|
21
|
-
|
|
20
|
+
}); // all agents
|
|
21
|
+
|
|
22
|
+
const timeout = 30000; // agentkeepalive
|
|
23
|
+
|
|
24
|
+
const maxSockets = 100;
|
|
25
|
+
const maxFreeSockets = 10;
|
|
26
|
+
const freeSocketTimeout = 30000;
|
|
22
27
|
const userAgent = `${pkg.name}/${pkg.version}`;
|
|
23
|
-
let httpsAgent;
|
|
28
|
+
let httpAgent, httpsAgent;
|
|
29
|
+
|
|
30
|
+
function getHttpAgent() {
|
|
31
|
+
if (httpAgent) return httpAgent;
|
|
32
|
+
httpAgent = new Agent({
|
|
33
|
+
maxSockets,
|
|
34
|
+
maxFreeSockets,
|
|
35
|
+
timeout,
|
|
36
|
+
freeSocketTimeout
|
|
37
|
+
});
|
|
38
|
+
return httpAgent;
|
|
39
|
+
}
|
|
24
40
|
/**
|
|
25
41
|
* Helper method to create properly configured httpsAgent
|
|
26
42
|
* @returns {any} appropriate httpsAgent
|
|
27
43
|
*/
|
|
28
44
|
|
|
45
|
+
|
|
29
46
|
function getHttpsAgent() {
|
|
30
47
|
if (httpsAgent) return httpsAgent;
|
|
31
48
|
const options = {
|
|
@@ -45,7 +62,12 @@ function getHttpsAgent() {
|
|
|
45
62
|
return httpsAgent;
|
|
46
63
|
}
|
|
47
64
|
|
|
48
|
-
httpsAgent = new
|
|
65
|
+
httpsAgent = new Agent.HttpsAgent({ ...options,
|
|
66
|
+
maxSockets,
|
|
67
|
+
maxFreeSockets,
|
|
68
|
+
timeout,
|
|
69
|
+
freeSocketTimeout
|
|
70
|
+
});
|
|
49
71
|
return httpsAgent;
|
|
50
72
|
}
|
|
51
73
|
/**
|
|
@@ -73,7 +95,7 @@ export function generateAmApi(resource, requestOverride = {}) {
|
|
|
73
95
|
'User-Agent': userAgent,
|
|
74
96
|
'Content-Type': 'application/json',
|
|
75
97
|
'Accept-API-Version': resource.apiVersion,
|
|
76
|
-
Cookie: `${storage.session.
|
|
98
|
+
Cookie: `${storage.session.getCookieName()}=${storage.session.getCookieValue()}`
|
|
77
99
|
};
|
|
78
100
|
|
|
79
101
|
if (requestOverride['headers']) {
|
|
@@ -83,10 +105,11 @@ export function generateAmApi(resource, requestOverride = {}) {
|
|
|
83
105
|
}
|
|
84
106
|
|
|
85
107
|
const requestDetails = {
|
|
86
|
-
baseURL: `${storage.session.getTenant()}/json
|
|
108
|
+
baseURL: `${storage.session.getTenant()}/json`,
|
|
87
109
|
timeout,
|
|
88
110
|
...requestOverride,
|
|
89
111
|
headers,
|
|
112
|
+
httpAgent: getHttpAgent(),
|
|
90
113
|
httpsAgent: getHttpsAgent(),
|
|
91
114
|
proxy: getProxy()
|
|
92
115
|
};
|
|
@@ -120,6 +143,7 @@ export function generateOauth2Api(resource, requestOverride = {}) {
|
|
|
120
143
|
timeout,
|
|
121
144
|
...requestOverride,
|
|
122
145
|
headers,
|
|
146
|
+
httpAgent: getHttpAgent(),
|
|
123
147
|
httpsAgent: getHttpsAgent(),
|
|
124
148
|
proxy: getProxy()
|
|
125
149
|
};
|
|
@@ -143,6 +167,7 @@ export function generateIdmApi(requestOverride = {}) {
|
|
|
143
167
|
'Content-Type': 'application/json'
|
|
144
168
|
},
|
|
145
169
|
...requestOverride,
|
|
170
|
+
httpAgent: getHttpAgent(),
|
|
146
171
|
httpsAgent: getHttpsAgent(),
|
|
147
172
|
proxy: getProxy()
|
|
148
173
|
};
|
|
@@ -172,6 +197,7 @@ export function generateLogKeysApi(requestOverride = {}) {
|
|
|
172
197
|
timeout,
|
|
173
198
|
headers,
|
|
174
199
|
...requestOverride,
|
|
200
|
+
httpAgent: getHttpAgent(),
|
|
175
201
|
httpsAgent: getHttpsAgent(),
|
|
176
202
|
proxy: getProxy()
|
|
177
203
|
};
|
|
@@ -202,6 +228,7 @@ export function generateLogApi(requestOverride = {}) {
|
|
|
202
228
|
timeout,
|
|
203
229
|
headers,
|
|
204
230
|
...requestOverride,
|
|
231
|
+
httpAgent: getHttpAgent(),
|
|
205
232
|
httpsAgent: getHttpsAgent(),
|
|
206
233
|
proxy: getProxy()
|
|
207
234
|
};
|
|
@@ -227,6 +254,7 @@ export function generateESVApi(resource, requestOverride = {}) {
|
|
|
227
254
|
timeout,
|
|
228
255
|
headers,
|
|
229
256
|
...requestOverride,
|
|
257
|
+
httpAgent: getHttpAgent(),
|
|
230
258
|
httpsAgent: getHttpsAgent(),
|
|
231
259
|
proxy: getProxy()
|
|
232
260
|
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import util from 'util';
|
|
2
|
+
import { deleteDeepByKey, getCurrentRealmPath } from './utils/ApiUtils';
|
|
3
|
+
import { generateAmApi } from './BaseApi';
|
|
4
|
+
import storage from '../storage/SessionStorage';
|
|
5
|
+
const queryAllNodeTypesURLTemplate = '%s/json%s/realm-config/authentication/authenticationtrees/nodes?_action=getAllTypes';
|
|
6
|
+
const queryAllNodesByTypeURLTemplate = '%s/json%s/realm-config/authentication/authenticationtrees/nodes/%s?_queryFilter=true';
|
|
7
|
+
const queryAllNodesURLTemplate = '%s/json%s/realm-config/authentication/authenticationtrees/nodes?_action=nextdescendents';
|
|
8
|
+
const nodeURLTemplate = '%s/json%s/realm-config/authentication/authenticationtrees/nodes/%s/%s';
|
|
9
|
+
const apiVersion = 'protocol=2.1,resource=1.0';
|
|
10
|
+
|
|
11
|
+
const getNodeApiConfig = () => {
|
|
12
|
+
const configPath = getCurrentRealmPath();
|
|
13
|
+
return {
|
|
14
|
+
path: `${configPath}/authentication/authenticationtrees`,
|
|
15
|
+
apiVersion
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Get all node types
|
|
20
|
+
* @returns {Promise} a promise that resolves to an array of node type objects
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
export async function getNodeTypes() {
|
|
25
|
+
const urlString = util.format(queryAllNodeTypesURLTemplate, storage.session.getTenant(), getCurrentRealmPath());
|
|
26
|
+
const response = await generateAmApi(getNodeApiConfig()).post(urlString, {}, {
|
|
27
|
+
withCredentials: true,
|
|
28
|
+
headers: {
|
|
29
|
+
'Accept-Encoding': 'gzip, deflate, br'
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return response.data.result;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Get all nodes
|
|
36
|
+
* @returns {Promise} a promise that resolves to an array of node objects
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
export async function getNodes() {
|
|
40
|
+
const urlString = util.format(queryAllNodesURLTemplate, storage.session.getTenant(), getCurrentRealmPath());
|
|
41
|
+
const response = await generateAmApi(getNodeApiConfig()).post(urlString, {}, {
|
|
42
|
+
withCredentials: true,
|
|
43
|
+
headers: {
|
|
44
|
+
'Accept-Encoding': 'gzip, deflate, br'
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
return response.data.result;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get all nodes by type
|
|
51
|
+
* @param {string} nodeType node type
|
|
52
|
+
* @returns {Promise} a promise that resolves to an array of node objects of the requested type
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
export async function getNodesByType(nodeType) {
|
|
56
|
+
const urlString = util.format(queryAllNodesByTypeURLTemplate, storage.session.getTenant(), getCurrentRealmPath(), nodeType);
|
|
57
|
+
const response = await generateAmApi(getNodeApiConfig()).get(urlString, {
|
|
58
|
+
withCredentials: true
|
|
59
|
+
});
|
|
60
|
+
return response.data.result;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get node by uuid and type
|
|
64
|
+
* @param {String} nodeId node uuid
|
|
65
|
+
* @param {String} nodeType node type
|
|
66
|
+
* @returns {Promise} a promise that resolves to a node object
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
export async function getNode(nodeId, nodeType) {
|
|
70
|
+
const urlString = util.format(nodeURLTemplate, storage.session.getTenant(), getCurrentRealmPath(), nodeType, nodeId);
|
|
71
|
+
const {
|
|
72
|
+
data
|
|
73
|
+
} = await generateAmApi(getNodeApiConfig()).get(urlString, {
|
|
74
|
+
withCredentials: true
|
|
75
|
+
});
|
|
76
|
+
return data;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Put node by uuid and type
|
|
80
|
+
* @param {String} nodeId node uuid
|
|
81
|
+
* @param {String} nodeType node type
|
|
82
|
+
* @param {Object} nodeData node object
|
|
83
|
+
* @returns {Promise} a promise that resolves to an object containing a node object
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
export async function putNode(nodeId, nodeType, nodeData) {
|
|
87
|
+
// until we figure out a way to use transport keys in Frodo,
|
|
88
|
+
// we'll have to drop those encrypted attributes.
|
|
89
|
+
const cleanData = deleteDeepByKey(nodeData, '-encrypted');
|
|
90
|
+
const urlString = util.format(nodeURLTemplate, storage.session.getTenant(), getCurrentRealmPath(), nodeType, nodeId);
|
|
91
|
+
const {
|
|
92
|
+
data
|
|
93
|
+
} = await generateAmApi(getNodeApiConfig()).put(urlString, cleanData, {
|
|
94
|
+
withCredentials: true
|
|
95
|
+
});
|
|
96
|
+
return data;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Delete node by uuid and type
|
|
100
|
+
* @param {String} nodeId node uuid
|
|
101
|
+
* @param {String} nodeType node type
|
|
102
|
+
* @returns {Promise} a promise that resolves to an object containing a node object
|
|
103
|
+
*/
|
|
104
|
+
|
|
105
|
+
export async function deleteNode(nodeId, nodeType) {
|
|
106
|
+
const urlString = util.format(nodeURLTemplate, storage.session.getTenant(), getCurrentRealmPath(), nodeType, nodeId);
|
|
107
|
+
const {
|
|
108
|
+
data
|
|
109
|
+
} = await generateAmApi(getNodeApiConfig()).delete(urlString, {
|
|
110
|
+
withCredentials: true
|
|
111
|
+
});
|
|
112
|
+
return data;
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=NodeApi.js.map
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
3
|
+
import { NodeRaw, state } from '../index';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
7
|
+
|
|
8
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
|
|
10
|
+
const mock = new MockAdapter(axios);
|
|
11
|
+
state.default.session.setTenant('');
|
|
12
|
+
state.default.session.setRealm('alpha');
|
|
13
|
+
state.default.session.setCookieName('cookieName');
|
|
14
|
+
state.default.session.setCookieValue('cookieValue');
|
|
15
|
+
describe('NodeApi - getNodeTypes()', () => {
|
|
16
|
+
test('getNodeTypes() 1: Get all node types', async () => {
|
|
17
|
+
const response = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../../test/mocks/NodeApi/getNodeTypes/types.json'), 'utf8'));
|
|
18
|
+
mock.onPost('/json/realms/root/realms/alpha/realm-config/authentication/authenticationtrees/nodes?_action=getAllTypes').reply(200, response);
|
|
19
|
+
const types = await NodeRaw.getNodeTypes();
|
|
20
|
+
expect(types).toBeTruthy();
|
|
21
|
+
expect(types.length).toBe(99);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
describe('NodeApi - getNodesByType()', () => {
|
|
25
|
+
test('getNodesByType() 1: Get all page nodes', async () => {
|
|
26
|
+
const response = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../../test/mocks/NodeApi/getNodesByType/PageNode.json'), 'utf8'));
|
|
27
|
+
mock.onGet('/json/realms/root/realms/alpha/realm-config/authentication/authenticationtrees/nodes/PageNode?_queryFilter=true').reply(200, response);
|
|
28
|
+
const nodes = await NodeRaw.getNodesByType('PageNode');
|
|
29
|
+
expect(nodes).toBeTruthy();
|
|
30
|
+
expect(nodes.length).toBe(161);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
describe('NodeApi - getNode()', () => {
|
|
34
|
+
test('getNode() 1: Get existing page node [1aea363f-d8d2-4711-b88d-d58fff92dbae]', async () => {
|
|
35
|
+
const response = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../../test/mocks/NodeApi/getNode/PageNode_1aea363f-d8d2-4711-b88d-d58fff92dbae.json'), 'utf8'));
|
|
36
|
+
mock.onGet('/json/realms/root/realms/alpha/realm-config/authentication/authenticationtrees/nodes/PageNode/1aea363f-d8d2-4711-b88d-d58fff92dbae').reply(200, response);
|
|
37
|
+
const node = await NodeRaw.getNode('1aea363f-d8d2-4711-b88d-d58fff92dbae', 'PageNode');
|
|
38
|
+
expect(node).toBeTruthy();
|
|
39
|
+
expect(node).toMatchObject(response);
|
|
40
|
+
});
|
|
41
|
+
test('getNode() 2: Get non-existing page node [00000000-0000-0000-0000-000000000000]', async () => {
|
|
42
|
+
mock.onGet('/json/realms/root/realms/alpha/realm-config/authentication/authenticationtrees/nodes/PageNode/00000000-0000-0000-0000-000000000000').reply(404, {
|
|
43
|
+
code: 404,
|
|
44
|
+
reason: 'Not Found',
|
|
45
|
+
message: 'Not Found'
|
|
46
|
+
});
|
|
47
|
+
expect.assertions(2);
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
await NodeRaw.getNode('00000000-0000-0000-0000-000000000000', 'PageNode');
|
|
51
|
+
} catch (error) {
|
|
52
|
+
expect(error.response).toBeTruthy();
|
|
53
|
+
expect(error.response.data).toMatchObject({
|
|
54
|
+
code: 404,
|
|
55
|
+
reason: 'Not Found',
|
|
56
|
+
message: 'Not Found'
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
describe('NodeApi - putNode()', () => {
|
|
62
|
+
test('putNode() 1: Create page node [0ad90971-d08a-4af3-86f3-01729572dc8f]', async () => {
|
|
63
|
+
const nodeData = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../../test/mocks/NodeApi/putNode/PageNode_0ad90971-d08a-4af3-86f3-01729572dc8f.json'), 'utf8'));
|
|
64
|
+
mock.onPut('/json/realms/root/realms/alpha/realm-config/authentication/authenticationtrees/nodes/PageNode/0ad90971-d08a-4af3-86f3-01729572dc8f').reply(201, nodeData);
|
|
65
|
+
const node = await NodeRaw.putNode('0ad90971-d08a-4af3-86f3-01729572dc8f', 'PageNode', nodeData);
|
|
66
|
+
expect(node).toBeTruthy();
|
|
67
|
+
expect(node).toMatchObject(nodeData);
|
|
68
|
+
});
|
|
69
|
+
test('putNode() 1: Update existing page node [1aea363f-d8d2-4711-b88d-d58fff92dbae]', async () => {
|
|
70
|
+
const nodeData = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../../test/mocks/NodeApi/putNode/PageNode_1aea363f-d8d2-4711-b88d-d58fff92dbae.json'), 'utf8'));
|
|
71
|
+
mock.onPut('/json/realms/root/realms/alpha/realm-config/authentication/authenticationtrees/nodes/PageNode/1aea363f-d8d2-4711-b88d-d58fff92dbae').reply(200, nodeData);
|
|
72
|
+
const node = await NodeRaw.putNode('1aea363f-d8d2-4711-b88d-d58fff92dbae', 'PageNode', nodeData);
|
|
73
|
+
expect(node).toBeTruthy();
|
|
74
|
+
expect(node).toMatchObject(nodeData);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
describe('NodeApi - deleteNode()', () => {
|
|
78
|
+
test('deleteNode() 1: Delete existing node [1aea363f-d8d2-4711-b88d-d58fff92dbae]', async () => {
|
|
79
|
+
const response = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../../test/mocks/NodeApi/deleteNode/PageNode_1aea363f-d8d2-4711-b88d-d58fff92dbae.json'), 'utf8'));
|
|
80
|
+
mock.onDelete('/json/realms/root/realms/alpha/realm-config/authentication/authenticationtrees/nodes/PageNode/1aea363f-d8d2-4711-b88d-d58fff92dbae').reply(200, response);
|
|
81
|
+
const node = await NodeRaw.deleteNode('1aea363f-d8d2-4711-b88d-d58fff92dbae', 'PageNode');
|
|
82
|
+
expect(node).toBeTruthy();
|
|
83
|
+
expect(node._id).toEqual('1aea363f-d8d2-4711-b88d-d58fff92dbae');
|
|
84
|
+
});
|
|
85
|
+
test('deleteNode() 2: Delete non-existing node [00000000-0000-0000-0000-000000000000]', async () => {
|
|
86
|
+
mock.onDelete('/json/realms/root/realms/alpha/realm-config/authentication/authenticationtrees/nodes/PageNode/00000000-0000-0000-0000-000000000000').reply(404, {
|
|
87
|
+
code: 404,
|
|
88
|
+
reason: 'Not Found',
|
|
89
|
+
message: 'Not Found'
|
|
90
|
+
});
|
|
91
|
+
expect.assertions(2);
|
|
92
|
+
|
|
93
|
+
try {
|
|
94
|
+
await NodeRaw.deleteNode('00000000-0000-0000-0000-000000000000', 'PageNode');
|
|
95
|
+
} catch (error) {
|
|
96
|
+
expect(error.response).toBeTruthy();
|
|
97
|
+
expect(error.response.data).toMatchObject({
|
|
98
|
+
code: 404,
|
|
99
|
+
reason: 'Not Found',
|
|
100
|
+
message: 'Not Found'
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
//# sourceMappingURL=NodeApi.test.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import util from 'util';
|
|
2
2
|
import { generateAmApi } from './BaseApi';
|
|
3
|
-
import { getCurrentRealmPath } from './utils/ApiUtils';
|
|
3
|
+
import { deleteDeepByKey, getCurrentRealmPath } from './utils/ApiUtils';
|
|
4
4
|
import storage from '../storage/SessionStorage';
|
|
5
5
|
const oauth2ClientURLTemplate = '%s/json%s/realm-config/agents/OAuth2Client/%s';
|
|
6
6
|
const oauth2ClientListURLTemplate = '%s/json%s/realm-config/agents/OAuth2Client?_queryFilter=true';
|
|
@@ -45,7 +45,9 @@ export async function getOAuth2Client(id) {
|
|
|
45
45
|
*/
|
|
46
46
|
|
|
47
47
|
export async function putOAuth2Client(id, data) {
|
|
48
|
-
|
|
48
|
+
// until we figure out a way to use transport keys in Frodo,
|
|
49
|
+
// we'll have to drop those encrypted attributes.
|
|
50
|
+
const client = deleteDeepByKey(data, '-encrypted');
|
|
49
51
|
delete client._provider;
|
|
50
52
|
delete client._rev;
|
|
51
53
|
const urlString = util.format(oauth2ClientURLTemplate, storage.session.getTenant(), getCurrentRealmPath(), id);
|
package/esm/api/SecretsApi.mjs
CHANGED
|
@@ -19,75 +19,105 @@ const getApiConfig = () => ({
|
|
|
19
19
|
|
|
20
20
|
export async function getSecrets() {
|
|
21
21
|
const urlString = util.format(secretsListURLTemplate, getTenantURL(storage.session.getTenant()));
|
|
22
|
-
|
|
22
|
+
const {
|
|
23
|
+
data
|
|
24
|
+
} = await generateESVApi(getApiConfig()).get(urlString, {
|
|
23
25
|
withCredentials: true
|
|
24
26
|
});
|
|
27
|
+
return data.result;
|
|
25
28
|
}
|
|
26
|
-
export async function getSecret(
|
|
27
|
-
const urlString = util.format(secretURLTemplate, getTenantURL(storage.session.getTenant()),
|
|
28
|
-
|
|
29
|
+
export async function getSecret(secretId) {
|
|
30
|
+
const urlString = util.format(secretURLTemplate, getTenantURL(storage.session.getTenant()), secretId);
|
|
31
|
+
const {
|
|
32
|
+
data
|
|
33
|
+
} = await generateESVApi(getApiConfig()).get(urlString, {
|
|
29
34
|
withCredentials: true
|
|
30
35
|
});
|
|
36
|
+
return data;
|
|
31
37
|
}
|
|
32
|
-
export async function putSecret(
|
|
38
|
+
export async function putSecret(secretId, value, description, encoding = 'generic', useInPlaceholders = true) {
|
|
33
39
|
if (encoding !== 'generic') throw new Error(`Unsupported encoding: ${encoding}`);
|
|
34
|
-
const
|
|
40
|
+
const secretData = {
|
|
35
41
|
valueBase64: encode(value),
|
|
36
42
|
description,
|
|
37
43
|
encoding,
|
|
38
44
|
useInPlaceholders
|
|
39
45
|
};
|
|
40
|
-
const urlString = util.format(secretURLTemplate, getTenantURL(storage.session.getTenant()),
|
|
41
|
-
|
|
46
|
+
const urlString = util.format(secretURLTemplate, getTenantURL(storage.session.getTenant()), secretId);
|
|
47
|
+
const {
|
|
48
|
+
data
|
|
49
|
+
} = await generateESVApi(getApiConfig()).put(urlString, secretData, {
|
|
42
50
|
withCredentials: true
|
|
43
51
|
});
|
|
52
|
+
return data;
|
|
44
53
|
}
|
|
45
|
-
export async function setSecretDescription(
|
|
46
|
-
const urlString = util.format(secretSetDescriptionURLTemplate, getTenantURL(storage.session.getTenant()),
|
|
47
|
-
|
|
54
|
+
export async function setSecretDescription(secretId, description) {
|
|
55
|
+
const urlString = util.format(secretSetDescriptionURLTemplate, getTenantURL(storage.session.getTenant()), secretId);
|
|
56
|
+
const {
|
|
57
|
+
data
|
|
58
|
+
} = await generateESVApi(getApiConfig()).post(urlString, {
|
|
48
59
|
description
|
|
49
60
|
}, {
|
|
50
61
|
withCredentials: true
|
|
51
62
|
});
|
|
63
|
+
return data;
|
|
52
64
|
}
|
|
53
|
-
export async function deleteSecret(
|
|
54
|
-
const urlString = util.format(secretURLTemplate, getTenantURL(storage.session.getTenant()),
|
|
55
|
-
|
|
65
|
+
export async function deleteSecret(secretId) {
|
|
66
|
+
const urlString = util.format(secretURLTemplate, getTenantURL(storage.session.getTenant()), secretId);
|
|
67
|
+
const {
|
|
68
|
+
data
|
|
69
|
+
} = await generateESVApi(getApiConfig()).delete(urlString, {
|
|
56
70
|
withCredentials: true
|
|
57
71
|
});
|
|
72
|
+
return data;
|
|
58
73
|
}
|
|
59
|
-
export async function getSecretVersions(
|
|
60
|
-
const urlString = util.format(secretListVersionsURLTemplate, getTenantURL(storage.session.getTenant()),
|
|
61
|
-
|
|
74
|
+
export async function getSecretVersions(secretId) {
|
|
75
|
+
const urlString = util.format(secretListVersionsURLTemplate, getTenantURL(storage.session.getTenant()), secretId);
|
|
76
|
+
const {
|
|
77
|
+
data
|
|
78
|
+
} = await generateESVApi(getApiConfig()).get(urlString, {
|
|
62
79
|
withCredentials: true
|
|
63
80
|
});
|
|
81
|
+
return data;
|
|
64
82
|
}
|
|
65
|
-
export async function createNewVersionOfSecret(
|
|
66
|
-
const urlString = util.format(secretCreateNewVersionURLTemplate, getTenantURL(storage.session.getTenant()),
|
|
67
|
-
|
|
83
|
+
export async function createNewVersionOfSecret(secretId, value) {
|
|
84
|
+
const urlString = util.format(secretCreateNewVersionURLTemplate, getTenantURL(storage.session.getTenant()), secretId);
|
|
85
|
+
const {
|
|
86
|
+
data
|
|
87
|
+
} = await generateESVApi(getApiConfig()).post(urlString, {
|
|
68
88
|
valueBase64: encode(value)
|
|
69
89
|
}, {
|
|
70
90
|
withCredentials: true
|
|
71
91
|
});
|
|
92
|
+
return data;
|
|
72
93
|
}
|
|
73
|
-
export async function getVersionOfSecret(
|
|
74
|
-
const urlString = util.format(secretGetVersionURLTemplate, getTenantURL(storage.session.getTenant()),
|
|
75
|
-
|
|
94
|
+
export async function getVersionOfSecret(secretId, version) {
|
|
95
|
+
const urlString = util.format(secretGetVersionURLTemplate, getTenantURL(storage.session.getTenant()), secretId, version);
|
|
96
|
+
const {
|
|
97
|
+
data
|
|
98
|
+
} = await generateESVApi(getApiConfig()).get(urlString, {
|
|
76
99
|
withCredentials: true
|
|
77
100
|
});
|
|
101
|
+
return data;
|
|
78
102
|
}
|
|
79
|
-
export async function setStatusOfVersionOfSecret(
|
|
80
|
-
const urlString = util.format(secretVersionStatusURLTemplate, getTenantURL(storage.session.getTenant()),
|
|
81
|
-
|
|
103
|
+
export async function setStatusOfVersionOfSecret(secretId, version, status) {
|
|
104
|
+
const urlString = util.format(secretVersionStatusURLTemplate, getTenantURL(storage.session.getTenant()), secretId, version);
|
|
105
|
+
const {
|
|
106
|
+
data
|
|
107
|
+
} = await generateESVApi(getApiConfig()).post(urlString, {
|
|
82
108
|
status
|
|
83
109
|
}, {
|
|
84
110
|
withCredentials: true
|
|
85
111
|
});
|
|
112
|
+
return data;
|
|
86
113
|
}
|
|
87
|
-
export async function deleteVersionOfSecret(
|
|
88
|
-
const urlString = util.format(secretGetVersionURLTemplate, getTenantURL(storage.session.getTenant()),
|
|
89
|
-
|
|
114
|
+
export async function deleteVersionOfSecret(secretId, version) {
|
|
115
|
+
const urlString = util.format(secretGetVersionURLTemplate, getTenantURL(storage.session.getTenant()), secretId, version);
|
|
116
|
+
const {
|
|
117
|
+
data
|
|
118
|
+
} = await generateESVApi(getApiConfig()).delete(urlString, {
|
|
90
119
|
withCredentials: true
|
|
91
120
|
});
|
|
121
|
+
return data;
|
|
92
122
|
}
|
|
93
123
|
//# sourceMappingURL=SecretsApi.js.map
|