@rockcarver/frodo-cli 0.10.4 → 0.11.1-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.
Files changed (247) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/README.md +3 -3
  3. package/package.json +17 -15
  4. package/src/app.js +7 -6
  5. package/src/cli/_template/cmd-delete.js +9 -8
  6. package/src/cli/_template/cmd-describe.js +9 -8
  7. package/src/cli/_template/cmd-export.js +9 -8
  8. package/src/cli/_template/cmd-import.js +9 -8
  9. package/src/cli/_template/cmd-list.js +9 -8
  10. package/src/cli/_template/cmd-sub1-delete.js +9 -8
  11. package/src/cli/_template/cmd-sub1-describe.js +9 -8
  12. package/src/cli/_template/cmd-sub1-export.js +9 -8
  13. package/src/cli/_template/cmd-sub1-import.js +9 -8
  14. package/src/cli/_template/cmd-sub1-list.js +9 -8
  15. package/src/cli/_template/cmd-sub2-delete.js +9 -8
  16. package/src/cli/_template/cmd-sub2-describe.js +9 -8
  17. package/src/cli/_template/cmd-sub2-export.js +9 -8
  18. package/src/cli/_template/cmd-sub2-import.js +9 -8
  19. package/src/cli/_template/cmd-sub2-list.js +9 -8
  20. package/src/cli/admin/admin-add-autoid-static-user-mapping.js +12 -12
  21. package/src/cli/admin/admin-create-oauth2-client-with-admin-privileges.js +15 -18
  22. package/src/cli/admin/admin-get-access-token.js +12 -12
  23. package/src/cli/admin/admin-grant-oauth2-client-admin-privileges.js +13 -13
  24. package/src/cli/admin/admin-hide-generic-extension-attributes.js +13 -13
  25. package/src/cli/admin/admin-list-oauth2-clients-with-admin-privileges.js +13 -13
  26. package/src/cli/admin/admin-list-oauth2-clients-with-custom-privileges.js +14 -13
  27. package/src/cli/admin/admin-list-static-user-mappings.js +12 -12
  28. package/src/cli/admin/admin-remove-static-user-mapping.js +12 -12
  29. package/src/cli/admin/admin-repair-org-model.js +13 -13
  30. package/src/cli/admin/admin-revoke-oauth2-client-admin-privileges.js +13 -13
  31. package/src/cli/admin/admin-show-generic-extension-attributes.js +13 -13
  32. package/src/cli/app/app-delete.js +9 -8
  33. package/src/cli/app/app-describe.js +9 -8
  34. package/src/cli/app/app-export.js +15 -15
  35. package/src/cli/app/app-import.js +11 -11
  36. package/src/cli/app/app-list.js +11 -12
  37. package/src/cli/conn/conn-add.js +11 -11
  38. package/src/cli/conn/conn-delete.js +3 -1
  39. package/src/cli/conn/conn-describe.js +3 -1
  40. package/src/cli/conn/conn-list.js +3 -4
  41. package/src/cli/email/email-template-export.js +16 -16
  42. package/src/cli/email/email-template-import.js +16 -16
  43. package/src/cli/email/email-template-list.js +11 -11
  44. package/src/cli/esv/esv-apply.js +12 -12
  45. package/src/cli/esv/esv-secret-create.js +11 -11
  46. package/src/cli/esv/esv-secret-delete.js +13 -13
  47. package/src/cli/esv/esv-secret-describe.js +11 -11
  48. package/src/cli/esv/esv-secret-export.js +9 -8
  49. package/src/cli/esv/esv-secret-import.js +9 -8
  50. package/src/cli/esv/esv-secret-list.js +11 -11
  51. package/src/cli/esv/esv-secret-set.js +11 -11
  52. package/src/cli/esv/esv-secret-version-activate.js +12 -12
  53. package/src/cli/esv/esv-secret-version-create.js +11 -11
  54. package/src/cli/esv/esv-secret-version-deactivate.js +12 -12
  55. package/src/cli/esv/esv-secret-version-delete.js +13 -13
  56. package/src/cli/esv/esv-secret-version-list.js +11 -11
  57. package/src/cli/esv/esv-variable-create.js +11 -11
  58. package/src/cli/esv/esv-variable-delete.js +13 -16
  59. package/src/cli/esv/esv-variable-describe.js +11 -11
  60. package/src/cli/esv/esv-variable-export.js +9 -8
  61. package/src/cli/esv/esv-variable-import.js +9 -8
  62. package/src/cli/esv/esv-variable-list.js +11 -11
  63. package/src/cli/esv/esv-variable-set.js +13 -16
  64. package/src/cli/idm/idm-count.js +11 -11
  65. package/src/cli/idm/idm-export.js +16 -16
  66. package/src/cli/idm/idm-list.js +11 -11
  67. package/src/cli/idp/idp-export.js +15 -19
  68. package/src/cli/idp/idp-import.js +18 -18
  69. package/src/cli/idp/idp-list.js +12 -12
  70. package/src/cli/info/info.js +23 -19
  71. package/src/cli/journey/journey-delete.js +14 -14
  72. package/src/cli/journey/journey-describe.js +26 -35
  73. package/src/cli/journey/journey-export.js +18 -21
  74. package/src/cli/journey/journey-import.js +17 -17
  75. package/src/cli/journey/journey-list.js +12 -12
  76. package/src/cli/journey/journey-prune.js +12 -12
  77. package/src/cli/logging/logs-list.js +33 -28
  78. package/src/cli/logging/logs-tail.js +26 -22
  79. package/src/cli/realm/realm-add-custom-domain.js +13 -13
  80. package/src/cli/realm/realm-describe.js +14 -14
  81. package/src/cli/realm/realm-list.js +11 -11
  82. package/src/cli/realm/realm-remove-custom-domain.js +16 -13
  83. package/src/cli/saml/saml-cot-export.js +16 -16
  84. package/src/cli/saml/saml-cot-import.js +18 -18
  85. package/src/cli/saml/saml-cot-list.js +12 -12
  86. package/src/cli/saml/saml-describe.js +12 -12
  87. package/src/cli/saml/saml-export.js +16 -19
  88. package/src/cli/saml/saml-import.js +19 -18
  89. package/src/cli/saml/saml-list.js +12 -12
  90. package/src/cli/saml/saml-metadata-export.js +15 -19
  91. package/src/cli/script/script-delete.js +9 -8
  92. package/src/cli/script/script-describe.js +9 -8
  93. package/src/cli/script/script-export.js +18 -20
  94. package/src/cli/script/script-import.js +13 -12
  95. package/src/cli/script/script-list.js +12 -12
  96. package/src/cli/theme/theme-delete.js +17 -21
  97. package/src/cli/theme/theme-export.js +19 -18
  98. package/src/cli/theme/theme-import.js +21 -20
  99. package/src/cli/theme/theme-list.js +12 -12
  100. package/.eslintrc +0 -29
  101. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -30
  102. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  103. package/.github/README.md +0 -273
  104. package/.github/workflows/pipeline.yml +0 -487
  105. package/.prettierrc +0 -6
  106. package/CODE_OF_CONDUCT.md +0 -128
  107. package/docs/BINARIES.md +0 -22
  108. package/docs/CONTRIBUTE.md +0 -96
  109. package/docs/PIPELINE.md +0 -169
  110. package/docs/images/macos_warn1.png +0 -0
  111. package/docs/images/macos_warn2.png +0 -0
  112. package/docs/images/macos_warn3.png +0 -0
  113. package/docs/images/npm_versioning_guidelines.png +0 -0
  114. package/docs/images/release_pipeline.png +0 -0
  115. package/gulpfile.js +0 -49
  116. package/jsconfig.json +0 -6
  117. package/resources/sampleEntitiesFile.json +0 -8
  118. package/resources/sampleEnvFile.env +0 -2
  119. package/src/api/AuthenticateApi.js +0 -33
  120. package/src/api/BaseApi.js +0 -242
  121. package/src/api/CirclesOfTrustApi.js +0 -87
  122. package/src/api/EmailTemplateApi.js +0 -37
  123. package/src/api/IdmConfigApi.js +0 -88
  124. package/src/api/LogApi.js +0 -45
  125. package/src/api/ManagedObjectApi.js +0 -62
  126. package/src/api/OAuth2ClientApi.js +0 -69
  127. package/src/api/OAuth2OIDCApi.js +0 -73
  128. package/src/api/OAuth2ProviderApi.js +0 -32
  129. package/src/api/RealmApi.js +0 -99
  130. package/src/api/Saml2Api.js +0 -176
  131. package/src/api/ScriptApi.js +0 -84
  132. package/src/api/SecretsApi.js +0 -151
  133. package/src/api/ServerInfoApi.js +0 -41
  134. package/src/api/SocialIdentityProvidersApi.js +0 -114
  135. package/src/api/StartupApi.js +0 -45
  136. package/src/api/ThemeApi.js +0 -181
  137. package/src/api/TreeApi.js +0 -207
  138. package/src/api/VariablesApi.js +0 -104
  139. package/src/api/utils/ApiUtils.js +0 -77
  140. package/src/api/utils/Base64.js +0 -62
  141. package/src/cli/journey/journey-delete.e2e.test.js +0 -380
  142. package/src/cli/journey/journey-list.e2e.test.js +0 -141
  143. package/src/cli/theme/theme-delete.e2e.test.js +0 -178
  144. package/src/cli/theme/theme-list.e2e.test.js +0 -119
  145. package/src/ops/AdminOps.js +0 -901
  146. package/src/ops/AuthenticateOps.js +0 -342
  147. package/src/ops/CirclesOfTrustOps.js +0 -350
  148. package/src/ops/ConnectionProfileOps.js +0 -254
  149. package/src/ops/EmailTemplateOps.js +0 -326
  150. package/src/ops/IdmOps.js +0 -227
  151. package/src/ops/IdpOps.js +0 -342
  152. package/src/ops/JourneyOps.js +0 -2026
  153. package/src/ops/LogOps.js +0 -357
  154. package/src/ops/ManagedObjectOps.js +0 -34
  155. package/src/ops/OAuth2ClientOps.js +0 -151
  156. package/src/ops/OrganizationOps.js +0 -85
  157. package/src/ops/RealmOps.js +0 -139
  158. package/src/ops/SamlOps.js +0 -541
  159. package/src/ops/ScriptOps.js +0 -211
  160. package/src/ops/SecretsOps.js +0 -288
  161. package/src/ops/StartupOps.js +0 -114
  162. package/src/ops/ThemeOps.js +0 -379
  163. package/src/ops/VariablesOps.js +0 -185
  164. package/src/ops/templates/OAuth2ClientTemplate.json +0 -270
  165. package/src/ops/templates/OrgModelUserAttributesTemplate.json +0 -149
  166. package/src/ops/templates/cloud/GenericExtensionAttributesTemplate.json +0 -392
  167. package/src/ops/templates/cloud/managed.json +0 -4119
  168. package/src/ops/utils/Console.js +0 -434
  169. package/src/ops/utils/DataProtection.js +0 -92
  170. package/src/ops/utils/ExportImportUtils.js +0 -146
  171. package/src/ops/utils/OpsUtils.js +0 -76
  172. package/src/ops/utils/Wordwrap.js +0 -11
  173. package/src/storage/SessionStorage.js +0 -45
  174. package/test/client_cli/en/connections.test.js +0 -62
  175. package/test/client_cli/en/connections_add.test.js +0 -34
  176. package/test/client_cli/en/connections_delete.test.js +0 -34
  177. package/test/client_cli/en/connections_list.test.js +0 -34
  178. package/test/client_cli/en/email_templates.test.js +0 -77
  179. package/test/client_cli/en/email_templates_export.test.js +0 -196
  180. package/test/client_cli/en/email_templates_import.test.js +0 -145
  181. package/test/client_cli/en/email_templates_list.test.js +0 -130
  182. package/test/client_cli/en/idm.test.js +0 -111
  183. package/test/client_cli/en/idm_count.test.js +0 -121
  184. package/test/client_cli/en/idm_export.test.js +0 -136
  185. package/test/client_cli/en/idm_exportAll.test.js +0 -156
  186. package/test/client_cli/en/idm_exportAllRaw.test.js +0 -120
  187. package/test/client_cli/en/idm_import.test_.js +0 -103
  188. package/test/client_cli/en/idm_importAll.test_.js +0 -103
  189. package/test/client_cli/en/idm_list.test.js +0 -103
  190. package/test/client_cli/en/info.test.js +0 -125
  191. package/test/client_cli/en/journey.test.js +0 -127
  192. package/test/client_cli/en/journey_describe.test.js +0 -196
  193. package/test/client_cli/en/journey_export.test.js +0 -213
  194. package/test/client_cli/en/journey_import.test.js +0 -195
  195. package/test/client_cli/en/journey_importAll.test.js +0 -180
  196. package/test/client_cli/en/journey_list.test.js +0 -162
  197. package/test/client_cli/en/journey_prune.test.js +0 -148
  198. package/test/client_cli/en/logs.test.js +0 -79
  199. package/test/client_cli/en/logs_list.test.js +0 -83
  200. package/test/client_cli/en/logs_tail.test.js +0 -118
  201. package/test/client_cli/en/root.test.js +0 -91
  202. package/test/client_cli/en/script.test.js +0 -77
  203. package/test/client_cli/en/script_export.test.js +0 -213
  204. package/test/client_cli/en/script_import.test.js +0 -163
  205. package/test/client_cli/en/script_list.test.js +0 -148
  206. package/test/client_cli/utils/utils.js +0 -32
  207. package/test/e2e/journey/baseline/ForgottenUsername.journey.json +0 -216
  208. package/test/e2e/journey/baseline/Login.journey.json +0 -205
  209. package/test/e2e/journey/baseline/PasswordGrant.journey.json +0 -139
  210. package/test/e2e/journey/baseline/ProgressiveProfile.journey.json +0 -198
  211. package/test/e2e/journey/baseline/Registration.journey.json +0 -249
  212. package/test/e2e/journey/baseline/ResetPassword.journey.json +0 -268
  213. package/test/e2e/journey/baseline/UpdatePassword.journey.json +0 -323
  214. package/test/e2e/journey/baseline/allAlphaJourneys.journeys.json +0 -1520
  215. package/test/e2e/journey/delete/ForgottenUsername.journey.json +0 -216
  216. package/test/e2e/journey/delete/Login.journey.json +0 -205
  217. package/test/e2e/journey/delete/PasswordGrant.journey.json +0 -139
  218. package/test/e2e/journey/delete/ProgressiveProfile.journey.json +0 -198
  219. package/test/e2e/journey/delete/Registration.journey.json +0 -249
  220. package/test/e2e/journey/delete/ResetPassword.journey.json +0 -268
  221. package/test/e2e/journey/delete/UpdatePassword.journey.json +0 -323
  222. package/test/e2e/journey/delete/deleteMe.journey.json +0 -230
  223. package/test/e2e/journey/list/Disabled.journey.json +0 -43
  224. package/test/e2e/journey/list/ForgottenUsername.journey.json +0 -216
  225. package/test/e2e/journey/list/Login.journey.json +0 -205
  226. package/test/e2e/journey/list/PasswordGrant.journey.json +0 -139
  227. package/test/e2e/journey/list/ProgressiveProfile.journey.json +0 -198
  228. package/test/e2e/journey/list/Registration.journey.json +0 -249
  229. package/test/e2e/journey/list/ResetPassword.journey.json +0 -268
  230. package/test/e2e/journey/list/UpdatePassword.journey.json +0 -323
  231. package/test/e2e/setup.js +0 -98
  232. package/test/e2e/theme/baseline/Contrast.theme.json +0 -95
  233. package/test/e2e/theme/baseline/Highlander.theme.json +0 -95
  234. package/test/e2e/theme/baseline/Robroy.theme.json +0 -95
  235. package/test/e2e/theme/baseline/Starter-Theme.theme.json +0 -94
  236. package/test/e2e/theme/baseline/Zardoz.theme.json +0 -95
  237. package/test/e2e/theme/import/Contrast.theme.json +0 -95
  238. package/test/e2e/theme/import/Highlander.theme.json +0 -95
  239. package/test/e2e/theme/import/Robroy.theme.json +0 -95
  240. package/test/e2e/theme/import/Starter-Theme.theme.json +0 -94
  241. package/test/e2e/theme/import/Zardoz.default.theme.json +0 -95
  242. package/test/fs_tmp/.gitkeep +0 -2
  243. package/test/global/setup.js +0 -65
  244. package/test/lib_api/unit_tests/ApiUtils.test.js +0 -186
  245. package/test/lib_api/unit_tests/Base64URL.test.js +0 -22
  246. package/test/lib_api/unit_tests/DataProtection.test.js +0 -25
  247. package/test/lib_api/unit_tests/ExportImportUtils.test.js +0 -121
@@ -1,181 +0,0 @@
1
- import { getConfigEntity, putConfigEntity } from './IdmConfigApi.js';
2
- import { getCurrentRealmName } from './utils/ApiUtils.js';
3
-
4
- const THEMEREALM_ID = 'ui/themerealm';
5
-
6
- /**
7
- * Get realm themes
8
- * @param {Object} themes object containing themes
9
- * @returns {Object} array of theme pertaining to the current realm
10
- */
11
- function getRealmThemes(themes) {
12
- return themes.realm[getCurrentRealmName()]
13
- ? themes.realm[getCurrentRealmName()]
14
- : [];
15
- }
16
-
17
- /**
18
- * Get all themes
19
- * @returns {Promise} a promise that resolves to an array of themes
20
- */
21
- export async function getThemes() {
22
- return getConfigEntity(THEMEREALM_ID).then((response) =>
23
- getRealmThemes(response.data)
24
- );
25
- }
26
-
27
- /**
28
- * Get theme by id
29
- * @param {String} id theme id
30
- * @returns {Promise} a promise that resolves to an array of themes
31
- */
32
- export async function getTheme(id) {
33
- const themes = (await getConfigEntity(THEMEREALM_ID)).data;
34
- return getRealmThemes(themes).filter((theme) => theme._id === id);
35
- }
36
-
37
- /**
38
- * Get theme by name
39
- * @param {String} name theme name
40
- * @returns {Promise} a promise that resolves to an array of themes
41
- */
42
- export async function getThemeByName(name) {
43
- const themes = (await getConfigEntity(THEMEREALM_ID)).data;
44
- return getRealmThemes(themes).filter((theme) => theme.name === name);
45
- }
46
-
47
- /**
48
- * Put theme by id
49
- * @param {String} id theme id
50
- * @param {Object} data theme object
51
- * @returns {Promise} a promise that resolves to an object containing a themes object
52
- */
53
- export async function putTheme(id, data) {
54
- const themeData = data;
55
- themeData._id = id;
56
- const themes = (await getConfigEntity(THEMEREALM_ID)).data;
57
- let isNew = true;
58
- const realmThemes = getRealmThemes(themes).map((theme) => {
59
- if (theme._id === id) {
60
- isNew = false;
61
- return themeData;
62
- }
63
- // eslint-disable-next-line no-param-reassign
64
- if (themeData.isDefault) theme.isDefault = false;
65
- return theme;
66
- });
67
- if (isNew) {
68
- realmThemes.push(themeData);
69
- }
70
- themes.realm[getCurrentRealmName()] = realmThemes;
71
- return putConfigEntity(THEMEREALM_ID, themes);
72
- }
73
-
74
- /**
75
- * Put theme by name
76
- * @param {String} name theme name
77
- * @param {Object} data theme object
78
- * @returns {Promise} a promise that resolves to an object containing a themes object
79
- */
80
- export async function putThemeByName(name, data) {
81
- const themeData = data;
82
- themeData.name = name;
83
- const themes = await getConfigEntity(THEMEREALM_ID);
84
- let isNew = true;
85
- const realmThemes = getRealmThemes(themes).map((theme) => {
86
- if (theme.name === name) {
87
- isNew = false;
88
- return themeData;
89
- }
90
- // eslint-disable-next-line no-param-reassign
91
- if (themeData.isDefault) theme.isDefault = false;
92
- return theme;
93
- });
94
- if (isNew) {
95
- realmThemes.push(themeData);
96
- }
97
- themes.realm[getCurrentRealmName()] = realmThemes;
98
- return putConfigEntity(THEMEREALM_ID, themes);
99
- }
100
-
101
- /**
102
- * Put all themes
103
- * @param {Object} data themes object containing all themes for all realms
104
- * @returns {Promise} a promise that resolves to an object containing a themes object
105
- */
106
- export async function putThemes(data) {
107
- const allThemesData = data;
108
- const themes = (await getConfigEntity(THEMEREALM_ID)).data;
109
- const allThemeIDs = Object.keys(allThemesData);
110
- const existingThemeIDs = [];
111
- let defaultThemeId = null;
112
- // update existing themes
113
- let realmThemes = getRealmThemes(themes).map((theme) => {
114
- if (allThemesData[theme._id]) {
115
- existingThemeIDs.push(theme._id);
116
- // remember the id of the last default theme
117
- if (allThemesData[theme._id].isDefault) defaultThemeId = theme._id;
118
- return allThemesData[theme._id];
119
- }
120
- return theme;
121
- });
122
- const newThemeIDs = allThemeIDs.filter(
123
- (id) => !existingThemeIDs.includes(id)
124
- );
125
- // add new themes
126
- newThemeIDs.forEach((themeId) => {
127
- // remember the id of the last default theme
128
- if (allThemesData[themeId].isDefault) defaultThemeId = themeId;
129
- realmThemes.push(allThemesData[themeId]);
130
- });
131
- // if we imported a default theme, flag all the other themes as not default
132
- if (defaultThemeId) {
133
- realmThemes = realmThemes.map((theme) => {
134
- // eslint-disable-next-line no-param-reassign
135
- theme.isDefault = theme._id === defaultThemeId;
136
- return theme;
137
- });
138
- }
139
- themes.realm[getCurrentRealmName()] = realmThemes;
140
- return putConfigEntity(THEMEREALM_ID, themes);
141
- }
142
-
143
- /**
144
- * Delete theme by id
145
- * @param {String} id theme id
146
- * @returns {Promise} a promise that resolves to an object containing a themes object
147
- */
148
- export async function deleteTheme(id) {
149
- const themes = (await getConfigEntity(THEMEREALM_ID)).data;
150
- const realmThemes = getRealmThemes(themes);
151
- const finalThemes = realmThemes.filter((theme) => theme._id !== id);
152
- if (realmThemes.length === finalThemes.length)
153
- throw new Error(`${id} not found`);
154
- themes.realm[getCurrentRealmName()] = realmThemes;
155
- return putConfigEntity(THEMEREALM_ID, themes);
156
- }
157
-
158
- /**
159
- * Delete theme by name
160
- * @param {String} name theme name
161
- * @returns {Promise} a promise that resolves to an object containing a themes object
162
- */
163
- export async function deleteThemeByName(name) {
164
- const themes = (await getConfigEntity(THEMEREALM_ID)).data;
165
- const realmThemes = getRealmThemes(themes);
166
- const finalThemes = realmThemes.filter((theme) => theme.name !== name);
167
- if (realmThemes.length === finalThemes.length)
168
- throw new Error(`${name} not found`);
169
- themes.realm[getCurrentRealmName()] = finalThemes;
170
- return putConfigEntity(THEMEREALM_ID, themes);
171
- }
172
-
173
- /**
174
- * Delete all themes
175
- * @returns {Promise} a promise that resolves to an array of themes
176
- */
177
- export async function deleteThemes() {
178
- const themes = (await getConfigEntity(THEMEREALM_ID)).data;
179
- themes.realm[getCurrentRealmName()] = [];
180
- return putConfigEntity(THEMEREALM_ID, themes);
181
- }
@@ -1,207 +0,0 @@
1
- import util from 'util';
2
- import { deleteDeepByKey, getCurrentRealmPath } from './utils/ApiUtils.js';
3
- import { generateAmApi } from './BaseApi.js';
4
- import storage from '../storage/SessionStorage.js';
5
-
6
- const nodeURLTemplate =
7
- '%s/json%s/realm-config/authentication/authenticationtrees/nodes/%s/%s';
8
- const queryAllNodesByTypeURLTemplate =
9
- '%s/json%s/realm-config/authentication/authenticationtrees/nodes/%s?_queryFilter=true';
10
- const queryAllNodesURLTemplate =
11
- '%s/json%s/realm-config/authentication/authenticationtrees/nodes?_action=nextdescendents';
12
- const queryAllNodeTypesURLTemplate =
13
- '%s/json%s/realm-config/authentication/authenticationtrees/nodes?_action=getAllTypes';
14
- const treeByIdURLTemplate =
15
- '%s/json%s/realm-config/authentication/authenticationtrees/trees/%s';
16
- const queryAllTreesURLTemplate =
17
- '%s/json%s/realm-config/authentication/authenticationtrees/trees?_queryFilter=true';
18
-
19
- const apiVersion = 'protocol=2.1,resource=1.0';
20
- const getTreeApiConfig = () => {
21
- const configPath = getCurrentRealmPath();
22
- return {
23
- path: `${configPath}/authentication/authenticationtrees`,
24
- apiVersion,
25
- };
26
- };
27
-
28
- export async function getNodeTypes() {
29
- const urlString = util.format(
30
- queryAllNodeTypesURLTemplate,
31
- storage.session.getTenant(),
32
- getCurrentRealmPath()
33
- );
34
- return generateAmApi(getTreeApiConfig()).post(
35
- urlString,
36
- {},
37
- {
38
- withCredentials: true,
39
- headers: { 'Accept-Encoding': 'gzip, deflate, br' },
40
- }
41
- );
42
- }
43
-
44
- /**
45
- * Get all nodes
46
- * @returns {Promise} a promise that resolves to an object containing an array of all node objects
47
- */
48
- export async function getNodes() {
49
- const urlString = util.format(
50
- queryAllNodesURLTemplate,
51
- storage.session.getTenant(),
52
- getCurrentRealmPath()
53
- );
54
- return generateAmApi(getTreeApiConfig()).post(
55
- urlString,
56
- {},
57
- {
58
- withCredentials: true,
59
- headers: { 'Accept-Encoding': 'gzip, deflate, br' },
60
- }
61
- );
62
- }
63
-
64
- /**
65
- * Get all nodes by type
66
- * @param {*} type node type
67
- * @returns {Promise} a promise that resolves to an object containing an array of node objects of the requested type
68
- */
69
- export async function getNodesByType(type) {
70
- const urlString = util.format(
71
- queryAllNodesByTypeURLTemplate,
72
- storage.session.getTenant(),
73
- getCurrentRealmPath(),
74
- type
75
- );
76
- return generateAmApi(getTreeApiConfig()).get(urlString, {
77
- withCredentials: true,
78
- });
79
- }
80
-
81
- /**
82
- * Get node by uuid and type
83
- * @param {String} id node uuid
84
- * @param {String} nodeType node type
85
- * @returns {Promise} a promise that resolves to an object containing a node object
86
- */
87
- export async function getNode(id, nodeType) {
88
- const urlString = util.format(
89
- nodeURLTemplate,
90
- storage.session.getTenant(),
91
- getCurrentRealmPath(storage.session.getRealm()),
92
- nodeType,
93
- id
94
- );
95
- return generateAmApi(getTreeApiConfig()).get(urlString, {
96
- withCredentials: true,
97
- });
98
- }
99
-
100
- /**
101
- * Put node by uuid and type
102
- * @param {String} id node uuid
103
- * @param {String} nodeType node type
104
- * @param {Object} data node object
105
- * @returns {Promise} a promise that resolves to an object containing a node object
106
- */
107
- export async function putNode(id, nodeType, nodeData) {
108
- // until we figure out a way to use transport keys in Frodo,
109
- // we'll have to drop those encrypted attributes.
110
- const data = deleteDeepByKey(nodeData, '-encrypted');
111
- const urlString = util.format(
112
- nodeURLTemplate,
113
- storage.session.getTenant(),
114
- getCurrentRealmPath(storage.session.getRealm()),
115
- nodeType,
116
- id
117
- );
118
- return generateAmApi(getTreeApiConfig()).put(urlString, data, {
119
- withCredentials: true,
120
- });
121
- }
122
-
123
- /**
124
- * Delete node by uuid and type
125
- * @param {String} id node uuid
126
- * @param {String} nodeType node type
127
- * @returns {Promise} a promise that resolves to an object containing a node object
128
- */
129
- export async function deleteNode(id, nodeType) {
130
- const urlString = util.format(
131
- nodeURLTemplate,
132
- storage.session.getTenant(),
133
- getCurrentRealmPath(),
134
- nodeType,
135
- id
136
- );
137
- return generateAmApi(getTreeApiConfig()).delete(urlString, {
138
- withCredentials: true,
139
- });
140
- }
141
-
142
- /**
143
- * Get all trees
144
- * @returns {Promise} a promise that resolves to an object containing an array of tree objects
145
- */
146
- export async function getTrees() {
147
- const urlString = util.format(
148
- queryAllTreesURLTemplate,
149
- storage.session.getTenant(),
150
- getCurrentRealmPath()
151
- );
152
- return generateAmApi(getTreeApiConfig()).get(urlString, {
153
- withCredentials: true,
154
- });
155
- }
156
-
157
- /**
158
- * Get tree by id/name
159
- * @param {String} id tree id/name
160
- * @returns {Promise} a promise that resolves to an object containing a tree object
161
- */
162
- export async function getTree(id) {
163
- const urlString = util.format(
164
- treeByIdURLTemplate,
165
- storage.session.getTenant(),
166
- getCurrentRealmPath(),
167
- id
168
- );
169
- return generateAmApi(getTreeApiConfig()).get(urlString, {
170
- withCredentials: true,
171
- });
172
- }
173
-
174
- /**
175
- * Put tree by id/name
176
- * @param {String} id tree id/name
177
- * @param {Object} data tree object
178
- * @returns {Promise} a promise that resolves to an object containing a tree object
179
- */
180
- export async function putTree(id, data) {
181
- const urlString = util.format(
182
- treeByIdURLTemplate,
183
- storage.session.getTenant(),
184
- getCurrentRealmPath(storage.session.getRealm()),
185
- id
186
- );
187
- return generateAmApi(getTreeApiConfig()).put(urlString, data, {
188
- withCredentials: true,
189
- });
190
- }
191
-
192
- /**
193
- * Delete tree by id/name
194
- * @param {String} id tree id/name
195
- * @returns {Promise} a promise that resolves to an object containing a tree object
196
- */
197
- export async function deleteTree(id) {
198
- const urlString = util.format(
199
- treeByIdURLTemplate,
200
- storage.session.getTenant(),
201
- getCurrentRealmPath(),
202
- id
203
- );
204
- return generateAmApi(getTreeApiConfig()).delete(urlString, {
205
- withCredentials: true,
206
- });
207
- }
@@ -1,104 +0,0 @@
1
- import util from 'util';
2
- import { encode } from './utils/Base64.js';
3
- import { getTenantURL, getCurrentRealmPath } from './utils/ApiUtils.js';
4
- import { generateESVApi } from './BaseApi.js';
5
- import storage from '../storage/SessionStorage.js';
6
-
7
- const variablesListURLTemplate = '%s/environment/variables';
8
- const variableURLTemplate = '%s/environment/variables/%s';
9
- const variableSetDescriptionURLTemplate = `${variableURLTemplate}?_action=setDescription`;
10
-
11
- const apiVersion = 'protocol=1.0,resource=1.0';
12
- const getApiConfig = () => {
13
- const configPath = getCurrentRealmPath();
14
- return {
15
- path: `${configPath}/environment/secrets`,
16
- apiVersion,
17
- };
18
- };
19
-
20
- /**
21
- * Get all variables
22
- * @returns {Promise} a promise that resolves to an object containing an array of variable objects
23
- */
24
- export async function getVariables() {
25
- const urlString = util.format(
26
- variablesListURLTemplate,
27
- getTenantURL(storage.session.getTenant())
28
- );
29
- return generateESVApi(getApiConfig()).get(urlString, {
30
- withCredentials: true,
31
- });
32
- }
33
-
34
- /**
35
- * Get variable by id/name
36
- * @param {String} id variable id/name
37
- * @returns {Promise} a promise that resolves to an object containing a variable object
38
- */
39
- export async function getVariable(id) {
40
- const urlString = util.format(
41
- variableURLTemplate,
42
- getTenantURL(storage.session.getTenant()),
43
- id
44
- );
45
- return generateESVApi(getApiConfig()).get(urlString, {
46
- withCredentials: true,
47
- });
48
- }
49
-
50
- /**
51
- * Put variable by id/name
52
- * @param {String} id variable id/name
53
- * @param {String} value variable value
54
- * @param {String} description variable description
55
- * @returns {Promise} a promise that resolves to an object containing a variable object
56
- */
57
- export async function putVariable(id, value, description) {
58
- const data = {};
59
- if (value) data.valueBase64 = encode(value);
60
- if (description) data.description = description;
61
- const urlString = util.format(
62
- variableURLTemplate,
63
- getTenantURL(storage.session.getTenant()),
64
- id
65
- );
66
- return generateESVApi(getApiConfig()).put(urlString, data, {
67
- withCredentials: true,
68
- });
69
- }
70
-
71
- /**
72
- * Set variable description
73
- * @param {*} id variable id/name
74
- * @param {*} description variable description
75
- * @returns {Promise} a promise that resolves to an object containing a status object
76
- */
77
- export async function setVariableDescription(id, description) {
78
- const urlString = util.format(
79
- variableSetDescriptionURLTemplate,
80
- getTenantURL(storage.session.getTenant()),
81
- id
82
- );
83
- return generateESVApi(getApiConfig()).post(
84
- urlString,
85
- { description },
86
- { withCredentials: true }
87
- );
88
- }
89
-
90
- /**
91
- * Delete variable by id/name
92
- * @param {String} id variable id/name
93
- * @returns {Promise} a promise that resolves to an object containing a variable object
94
- */
95
- export async function deleteVariable(id) {
96
- const urlString = util.format(
97
- variableURLTemplate,
98
- getTenantURL(storage.session.getTenant()),
99
- id
100
- );
101
- return generateESVApi(getApiConfig()).delete(urlString, {
102
- withCredentials: true,
103
- });
104
- }
@@ -1,77 +0,0 @@
1
- import util from 'util';
2
- import storage from '../../storage/SessionStorage.js';
3
-
4
- const realmPathTemplate = '/realms/%s';
5
-
6
- /**
7
- * Get current realm path
8
- * @returns {String} a CREST-compliant realm path, e.g. /realms/root/realms/alpha
9
- */
10
- export function getCurrentRealmPath() {
11
- let realm = storage.session.getRealm();
12
- if (realm.startsWith('/') && realm.length > 1) {
13
- realm = realm.substring(1);
14
- }
15
- let realmPath = util.format(realmPathTemplate, 'root');
16
- if (realm !== '/') {
17
- realmPath += util.format(realmPathTemplate, realm);
18
- }
19
- return realmPath;
20
- }
21
-
22
- /**
23
- * Get current realm name
24
- * @returns {String} name of the current realm. /alpha -> alpha
25
- */
26
- export function getCurrentRealmName() {
27
- const realm = storage.session.getRealm();
28
- const components = realm.split('/');
29
- let realmName = '/';
30
- if (components.length > 0 && realmName !== realm) {
31
- realmName = components[components.length - 1];
32
- }
33
- return realmName;
34
- }
35
-
36
- /**
37
- * Get current realm name
38
- * @param {String} realm realm
39
- * @returns {String} name of the realm. /alpha -> alpha
40
- */
41
- export function getRealmName(realm) {
42
- const components = realm.split('/');
43
- let realmName = '/';
44
- if (components.length > 0 && realmName !== realm) {
45
- realmName = components[components.length - 1];
46
- }
47
- return realmName;
48
- }
49
-
50
- /**
51
- * Get tenant base URL
52
- * @param {String} tenant tenant URL with path and query params
53
- * @returns {String} tenant base URL without path and query params
54
- */
55
- export function getTenantURL(tenant) {
56
- const parsedUrl = new URL(tenant);
57
- return `${parsedUrl.protocol}//${parsedUrl.host}`;
58
- }
59
-
60
- /**
61
- * Deep delete keys and their values from an input object. If a key in object contains substring, the key an its value is deleted.
62
- * @param {Object} object input object that needs keys removed
63
- * @param {String} substring substring to search for in key
64
- * @returns the modified object without the matching keys and their values
65
- */
66
- export function deleteDeepByKey(object, substring) {
67
- const obj = object;
68
- const keys = Object.keys(obj);
69
- for (const key of keys) {
70
- if (key.indexOf(substring) > 0) {
71
- delete obj[key];
72
- } else if (Object(obj[key]) === obj[key]) {
73
- obj[key] = deleteDeepByKey(obj[key], substring);
74
- }
75
- }
76
- return obj;
77
- }
@@ -1,62 +0,0 @@
1
- /**
2
- * Regex to determine if a string is Base64-encoded
3
- */
4
- const base64regex =
5
- /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
6
-
7
- /**
8
- * Is input Base64-encoded
9
- * @param {String} input
10
- * @returns {boolean} true if input is Base64-encoded, false otherwise
11
- */
12
- export function isBase64Encoded(input) {
13
- return base64regex.test(input);
14
- }
15
-
16
- /**
17
- * Base64-encode a string
18
- * @param {String} input String to base64-encode
19
- * @returns {String} Base64-encoded input string
20
- */
21
- export function encode(input, padding = true) {
22
- if (padding) {
23
- return Buffer.from(input).toString('base64');
24
- }
25
- return Buffer.from(input).toString('base64').replace(/=/g, '');
26
- }
27
-
28
- /**
29
- * Base64-decode a string
30
- * @param {String} input
31
- * @returns {String} Base64-decoded input string
32
- */
33
- export function decode(input) {
34
- // eslint-disable-next-line no-param-reassign
35
- if (input.length % 4 !== 0) input += '='.repeat(4 - (input.length % 4));
36
- return Buffer.from(input, 'base64').toString();
37
- }
38
-
39
- let enc;
40
- if (Buffer.isEncoding('base64url')) {
41
- enc = (input, encoding = 'utf8') =>
42
- Buffer.from(input, encoding).toString('base64url');
43
- } else {
44
- const fromBase64 = (base64) =>
45
- base64.replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_');
46
- enc = (input, encoding = 'utf8') =>
47
- fromBase64(Buffer.from(input, encoding).toString('base64'));
48
- }
49
-
50
- /**
51
- * Decode Base64URL
52
- * @param {*} input the string to decode
53
- * @returns {String} the decoded string.
54
- */
55
- export const decodeBase64Url = (input) => `${Buffer.from(input, 'base64')}`;
56
-
57
- /**
58
- * Encode Base65URL
59
- * @param {*} input the string to encode
60
- * @returns {String} the encoded string.
61
- */
62
- export const encodeBase64Url = enc;