@rockcarver/frodo-lib 0.16.2-8 → 0.17.0

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 (434) hide show
  1. package/CHANGELOG.md +221 -1
  2. package/cjs/api/AgentApi.js +14 -61
  3. package/cjs/api/AgentApi.js.map +1 -1
  4. package/cjs/api/AgentApi.test.js.map +1 -1
  5. package/cjs/api/ApiTypes.js +0 -5
  6. package/cjs/api/ApiTypes.js.map +1 -1
  7. package/cjs/api/AuthenticateApi.js +9 -20
  8. package/cjs/api/AuthenticateApi.js.map +1 -1
  9. package/cjs/api/AuthenticateApi.test.js.map +1 -0
  10. package/cjs/api/BaseApi.js +82 -124
  11. package/cjs/api/BaseApi.js.map +1 -1
  12. package/cjs/api/CirclesOfTrustApi.js +8 -32
  13. package/cjs/api/CirclesOfTrustApi.js.map +1 -1
  14. package/cjs/api/IdmConfigApi.js +9 -34
  15. package/cjs/api/IdmConfigApi.js.map +1 -1
  16. package/cjs/api/LogApi.js +8 -31
  17. package/cjs/api/LogApi.js.map +1 -1
  18. package/cjs/api/ManagedObjectApi.js +34 -31
  19. package/cjs/api/ManagedObjectApi.js.map +1 -1
  20. package/cjs/api/NodeApi.js +10 -41
  21. package/cjs/api/NodeApi.js.map +1 -1
  22. package/cjs/api/NodeApi.test.js.map +1 -1
  23. package/cjs/api/OAuth2ClientApi.js +7 -26
  24. package/cjs/api/OAuth2ClientApi.js.map +1 -1
  25. package/cjs/api/OAuth2OIDCApi.js +28 -34
  26. package/cjs/api/OAuth2OIDCApi.js.map +1 -1
  27. package/cjs/api/OAuth2OIDCApi.test.js.map +1 -0
  28. package/cjs/api/OAuth2ProviderApi.js +5 -15
  29. package/cjs/api/OAuth2ProviderApi.js.map +1 -1
  30. package/cjs/api/RealmApi.js +8 -34
  31. package/cjs/api/RealmApi.js.map +1 -1
  32. package/cjs/api/Saml2Api.js +32 -118
  33. package/cjs/api/Saml2Api.js.map +1 -1
  34. package/cjs/api/ScriptApi.js +8 -30
  35. package/cjs/api/ScriptApi.js.map +1 -1
  36. package/cjs/api/SecretsApi.js +14 -64
  37. package/cjs/api/SecretsApi.js.map +1 -1
  38. package/cjs/api/SecretsApi.test.js.map +1 -1
  39. package/cjs/api/ServerInfoApi.js +6 -21
  40. package/cjs/api/ServerInfoApi.js.map +1 -1
  41. package/cjs/api/ServiceApi.js +49 -47
  42. package/cjs/api/ServiceApi.js.map +1 -1
  43. package/cjs/api/SocialIdentityProvidersApi.js +9 -36
  44. package/cjs/api/SocialIdentityProvidersApi.js.map +1 -1
  45. package/cjs/api/StartupApi.js +5 -24
  46. package/cjs/api/StartupApi.js.map +1 -1
  47. package/cjs/api/StartupApi.test.js.map +1 -1
  48. package/cjs/api/TreeApi.js +8 -30
  49. package/cjs/api/TreeApi.js.map +1 -1
  50. package/cjs/api/TreeApi.test.js.map +1 -1
  51. package/cjs/api/VariablesApi.js +9 -37
  52. package/cjs/api/VariablesApi.js.map +1 -1
  53. package/cjs/api/VariablesApi.test.js.map +1 -1
  54. package/cjs/api/utils/ApiUtils.js +47 -57
  55. package/cjs/api/utils/ApiUtils.js.map +1 -1
  56. package/cjs/api/utils/ApiUtils.test.js.map +1 -1
  57. package/cjs/api/utils/Base64.js +6 -15
  58. package/cjs/api/utils/Base64.js.map +1 -1
  59. package/cjs/ext/axios-curlirize/curlirize.js +2 -9
  60. package/cjs/ext/axios-curlirize/curlirize.js.map +1 -1
  61. package/cjs/ext/axios-curlirize/lib/CurlHelper.js +7 -22
  62. package/cjs/ext/axios-curlirize/lib/CurlHelper.js.map +1 -1
  63. package/cjs/index.js +30 -89
  64. package/cjs/index.js.map +1 -1
  65. package/cjs/ops/AdminOps.js +27 -165
  66. package/cjs/ops/AdminOps.js.map +1 -1
  67. package/cjs/ops/AgentOps.js +3 -160
  68. package/cjs/ops/AgentOps.js.map +1 -1
  69. package/cjs/ops/AgentOps.test.js.map +1 -1
  70. package/cjs/ops/AuthenticateOps.js +265 -226
  71. package/cjs/ops/AuthenticateOps.js.map +1 -1
  72. package/cjs/ops/AuthenticateOps.test.js.map +1 -1
  73. package/cjs/ops/CirclesOfTrustOps.js +13 -91
  74. package/cjs/ops/CirclesOfTrustOps.js.map +1 -1
  75. package/cjs/ops/ConnectionProfileOps.js +220 -136
  76. package/cjs/ops/ConnectionProfileOps.js.map +1 -1
  77. package/cjs/ops/ConnectionProfileOps.test.js.map +1 -1
  78. package/cjs/ops/EmailTemplateOps.js +35 -379
  79. package/cjs/ops/EmailTemplateOps.js.map +1 -1
  80. package/cjs/ops/EmailTemplateOps.test.js.map +1 -1
  81. package/cjs/ops/IdmOps.js +52 -426
  82. package/cjs/ops/IdmOps.js.map +1 -1
  83. package/cjs/ops/IdmOps.test.js.map +1 -1
  84. package/cjs/ops/IdpOps.js +11 -94
  85. package/cjs/ops/IdpOps.js.map +1 -1
  86. package/cjs/ops/IdpOps.test.js.map +1 -1
  87. package/cjs/ops/JoseOps.js +81 -0
  88. package/cjs/ops/JoseOps.js.map +1 -0
  89. package/cjs/ops/JoseOps.test.js.map +1 -0
  90. package/cjs/ops/JourneyOps.js +140 -371
  91. package/cjs/ops/JourneyOps.js.map +1 -1
  92. package/cjs/ops/JourneyOps.test.js.map +1 -1
  93. package/cjs/ops/LogOps.js +14 -47
  94. package/cjs/ops/LogOps.js.map +1 -1
  95. package/cjs/ops/ManagedObjectOps.js +4 -12
  96. package/cjs/ops/ManagedObjectOps.js.map +1 -1
  97. package/cjs/ops/NodeOps.js +9 -67
  98. package/cjs/ops/NodeOps.js.map +1 -1
  99. package/cjs/ops/OAuth2ClientOps.js +10 -40
  100. package/cjs/ops/OAuth2ClientOps.js.map +1 -1
  101. package/cjs/ops/OpsTypes.js +0 -5
  102. package/cjs/ops/OpsTypes.js.map +1 -1
  103. package/cjs/ops/OrganizationOps.js +6 -25
  104. package/cjs/ops/OrganizationOps.js.map +1 -1
  105. package/cjs/ops/RealmOps.js +0 -19
  106. package/cjs/ops/RealmOps.js.map +1 -1
  107. package/cjs/ops/Saml2Ops.js +258 -802
  108. package/cjs/ops/Saml2Ops.js.map +1 -1
  109. package/cjs/ops/Saml2Ops.test.js.map +1 -1
  110. package/cjs/ops/ScriptOps.js +28 -73
  111. package/cjs/ops/ScriptOps.js.map +1 -1
  112. package/cjs/ops/SecretsOps.js +2 -58
  113. package/cjs/ops/SecretsOps.js.map +1 -1
  114. package/cjs/ops/ServiceAccountOps.js +61 -0
  115. package/cjs/ops/ServiceAccountOps.js.map +1 -0
  116. package/cjs/ops/ServiceAccountOps.test.js.map +1 -0
  117. package/cjs/ops/ServiceOps.js +55 -101
  118. package/cjs/ops/ServiceOps.js.map +1 -1
  119. package/cjs/ops/StartupOps.js +2 -23
  120. package/cjs/ops/StartupOps.js.map +1 -1
  121. package/cjs/ops/ThemeOps.js +230 -436
  122. package/cjs/ops/ThemeOps.js.map +1 -1
  123. package/cjs/ops/ThemeOps.test.js.map +1 -0
  124. package/cjs/ops/VariablesOps.js +0 -38
  125. package/cjs/ops/VariablesOps.js.map +1 -1
  126. package/cjs/ops/utils/Console.js +29 -62
  127. package/cjs/ops/utils/Console.js.map +1 -1
  128. package/cjs/ops/utils/DataProtection.js +13 -47
  129. package/cjs/ops/utils/DataProtection.js.map +1 -1
  130. package/cjs/ops/utils/DataProtection.test.js.map +1 -1
  131. package/cjs/ops/utils/ExportImportUtils.js +36 -74
  132. package/cjs/ops/utils/ExportImportUtils.js.map +1 -1
  133. package/cjs/ops/utils/ExportImportUtils.test.js.map +1 -1
  134. package/cjs/ops/utils/OpsUtils.js +27 -43
  135. package/cjs/ops/utils/OpsUtils.js.map +1 -1
  136. package/cjs/ops/utils/OpsUtils.test.js.map +1 -1
  137. package/cjs/ops/utils/ValidationUtils.js +0 -13
  138. package/cjs/ops/utils/ValidationUtils.js.map +1 -1
  139. package/cjs/ops/utils/ValidationUtils.test.js.map +1 -1
  140. package/cjs/ops/utils/Version.js +2 -12
  141. package/cjs/ops/utils/Version.js.map +1 -1
  142. package/cjs/ops/utils/Version.test.js.map +1 -1
  143. package/cjs/ops/utils/Wordwrap.js +1 -2
  144. package/cjs/ops/utils/Wordwrap.js.map +1 -1
  145. package/cjs/ops/utils/Wordwrap.test.js.map +1 -0
  146. package/cjs/shared/State.js +239 -0
  147. package/cjs/shared/State.js.map +1 -0
  148. package/cjs/shared/State.test.js.map +1 -0
  149. package/cjs/storage/StaticStorage.js.map +1 -1
  150. package/cjs/test/mocks/AuthenticateApi/step/default_steps.json +88 -0
  151. package/cjs/test/mocks/ForgeRockApiMockEngine.js +184 -80
  152. package/cjs/test/mocks/ForgeRockApiMockEngine.js.map +1 -1
  153. package/cjs/test/mocks/IdmConfigApi/getConfigEntity/managed.json +4420 -0
  154. package/cjs/test/mocks/OAuth2OIDCApi/accessToken/body.json +6 -0
  155. package/cjs/test/mocks/OAuth2OIDCApi/accessToken/headers.json +19 -0
  156. package/cjs/test/mocks/OAuth2OIDCApi/authorize/headers.json +38 -0
  157. package/cjs/test/mocks/Saml2Api/findSaml2Providers/https:sts.windows.net711ffa9c-5972-4713-ace3-688c9732614a_stub.json +18 -0
  158. package/cjs/test/mocks/Saml2Api/findSaml2Providers/iSPAzure_stub.json +18 -0
  159. package/cjs/test/mocks/Saml2Api/getProvider/aVNQQXp1cmU.json +1 -2
  160. package/cjs/test/mocks/Saml2Api/getProvider/dXJuOmZlZGVyYXRpb246TWljcm9zb2Z0T25saW5l.json +1 -3
  161. package/cjs/test/mocks/Saml2Api/getProviderByLocationAndId/hosted/U1BBenVyZQ.json +147 -0
  162. package/cjs/test/mocks/Saml2Api/getProviderByLocationAndId/hosted/aHR0cHM6Ly9pZGMuc2NoZXViZXIuaW8vYW0vc2FtbDIvSURQQXp1cmU.json +182 -0
  163. package/cjs/test/mocks/Saml2Api/getProviderByLocationAndId/hosted/aHR0cHM6Ly9pZGMuc2NoZXViZXIuaW8vYW0vc2FtbDIvSURQQnJvYWRjb20.json +149 -0
  164. package/cjs/test/mocks/Saml2Api/getProviderByLocationAndId/hosted/aHR0cHM6Ly9pZGMuc2NoZXViZXIuaW8vYW0vc2FtbDIvSURQRmVkbGV0.json +141 -0
  165. package/cjs/test/mocks/Saml2Api/getProviderByLocationAndId/hosted/aVNQQXp1cmU.json +1 -2
  166. package/cjs/test/mocks/Saml2Api/getProviderByLocationAndId/hosted/dm9sa2VyRGV2U1A.json +118 -0
  167. package/cjs/test/mocks/Saml2Api/getProviderByLocationAndId/remote/aHR0cHM6Ly9zYW1sLm15dGVzdHJ1bi5jb20vc3A.json +66 -0
  168. package/cjs/test/mocks/Saml2Api/getProviderByLocationAndId/remote/aHR0cHM6Ly9zdHMud2luZG93cy5uZXQvNzExZmZhOWMtNTk3Mi00NzEzLWFjZTMtNjg4Yzk3MzI2MTRhLw.json +35 -0
  169. package/cjs/test/mocks/Saml2Api/getProviderByLocationAndId/remote/aWRw.json +83 -0
  170. package/cjs/test/mocks/Saml2Api/getProviderByLocationAndId/remote/dXJuOmZlZGVyYXRpb246TWljcm9zb2Z0T25saW5l.json +1 -3
  171. package/cjs/test/mocks/Saml2Api/getProviderMetadata/alpha/SPAzure.xml +74 -0
  172. package/cjs/test/mocks/Saml2Api/getProviderMetadata/alpha/https%3A%2F%2Fidc.scheuber.io%2Fam%2Fsaml2%2FIDPAzure.xml +78 -0
  173. package/cjs/test/mocks/Saml2Api/getProviderMetadata/alpha/https%3A%2F%2Fidc.scheuber.io%2Fam%2Fsaml2%2FIDPBroadcom.xml +78 -0
  174. package/cjs/test/mocks/Saml2Api/getProviderMetadata/alpha/https%3A%2F%2Fidc.scheuber.io%2Fam%2Fsaml2%2FIDPFedlet.xml +78 -0
  175. package/cjs/test/mocks/Saml2Api/getProviderMetadata/alpha/https%3A%2F%2Fsaml.mytestrun.com%2Fsp.xml +13 -0
  176. package/cjs/test/mocks/Saml2Api/getProviderMetadata/alpha/{dXJuOmZlZGVyYXRpb246TWljcm9zb2Z0T25saW5l.xml → https%3A%2F%2Fsts.windows.net%2F711ffa9c-5972-4713-ace3-688c9732614a%2F.xml} +0 -0
  177. package/cjs/test/mocks/Saml2Api/getProviderMetadata/alpha/{aVNQQXp1cmU.xml → iSPAzure.xml} +0 -0
  178. package/cjs/test/mocks/Saml2Api/getProviderMetadata/alpha/urn%3Afederation%3AMicrosoftOnline.xml +84 -0
  179. package/cjs/test/mocks/Saml2Ops/importSaml2Provider/SPAzure.saml.json +243 -0
  180. package/cjs/test/mocks/Saml2Ops/importSaml2Provider/iSPAzure.saml.json +242 -0
  181. package/cjs/test/mocks/Saml2Ops/importSaml2Provider/idc.scheuber.ioamsaml2IDPAzure.saml.json +454 -0
  182. package/cjs/test/mocks/Saml2Ops/importSaml2Provider/idc.scheuber.ioamsaml2IDPBroadcom.saml.json +586 -0
  183. package/cjs/test/mocks/Saml2Ops/importSaml2Provider/idc.scheuber.ioamsaml2IDPFedlet.saml.json +241 -0
  184. package/cjs/test/mocks/Saml2Ops/importSaml2Provider/idp.saml.json +185 -0
  185. package/cjs/test/mocks/Saml2Ops/importSaml2Provider/saml.mytestrun.comsp.saml.json +101 -0
  186. package/cjs/test/mocks/Saml2Ops/importSaml2Provider/sts.windows.net711ffa9c-5972-4713-ace3-688c9732614a.saml.json +113 -0
  187. package/cjs/test/mocks/Saml2Ops/importSaml2Provider/urn:federation:MicrosoftOnline.saml.json +199 -0
  188. package/cjs/test/mocks/Saml2Ops/importSaml2Provider/volkerDevSP.saml.json +212 -0
  189. package/cjs/test/mocks/Saml2Ops/importSaml2Providers/allAlphaProviders.saml.json +2414 -0
  190. package/cjs/test/mocks/ScriptApi/getScript/5b29c5b7-b161-4a42-a41f-d6c85316b951.json +13 -0
  191. package/cjs/test/mocks/ScriptApi/getScript/85523e71-2d77-4577-b078-6f9674cc54e2.json +13 -0
  192. package/cjs/test/mocks/ScriptApi/getScript/90c4eca5-05f0-42f5-b9bf-88b693eabbbd.json +13 -0
  193. package/cjs/test/mocks/ServerInfoApi/getServerInfo/info.json +25 -0
  194. package/cjs/test/mocks/ServerInfoApi/getServerVersionInfo/version.json +8 -0
  195. package/cjs/utils/AutoSetupPolly.js +79 -0
  196. package/cjs/utils/AutoSetupPolly.js.map +1 -0
  197. package/cjs/utils/SetupJest.js +6 -0
  198. package/cjs/utils/SetupJest.js.map +1 -0
  199. package/cjs/{test/mocks → utils}/snapshotResolve.js +10 -12
  200. package/cjs/utils/snapshotResolve.js.map +1 -0
  201. package/esm/api/AgentApi.mjs +19 -21
  202. package/esm/api/AgentApi.test.mjs +6 -15
  203. package/esm/api/ApiTypes.mjs +0 -5
  204. package/esm/api/AuthenticateApi.mjs +7 -10
  205. package/esm/api/AuthenticateApi.test.mjs +39 -0
  206. package/esm/api/BaseApi.mjs +96 -81
  207. package/esm/api/CirclesOfTrustApi.mjs +9 -12
  208. package/esm/api/IdmConfigApi.mjs +11 -12
  209. package/esm/api/LogApi.mjs +6 -10
  210. package/esm/api/ManagedObjectApi.mjs +23 -8
  211. package/esm/api/NodeApi.mjs +13 -15
  212. package/esm/api/NodeApi.test.mjs +13 -17
  213. package/esm/api/OAuth2ClientApi.mjs +7 -9
  214. package/esm/api/OAuth2OIDCApi.mjs +15 -9
  215. package/esm/api/OAuth2OIDCApi.test.mjs +53 -0
  216. package/esm/api/OAuth2ProviderApi.mjs +3 -5
  217. package/esm/api/RealmApi.mjs +10 -13
  218. package/esm/api/Saml2Api.mjs +31 -61
  219. package/esm/api/ScriptApi.mjs +9 -11
  220. package/esm/api/SecretsApi.mjs +21 -24
  221. package/esm/api/SecretsApi.test.mjs +9 -31
  222. package/esm/api/ServerInfoApi.mjs +5 -9
  223. package/esm/api/ServiceApi.mjs +53 -26
  224. package/esm/api/SocialIdentityProvidersApi.mjs +11 -13
  225. package/esm/api/StartupApi.mjs +5 -10
  226. package/esm/api/StartupApi.test.mjs +4 -7
  227. package/esm/api/TreeApi.mjs +9 -11
  228. package/esm/api/TreeApi.test.mjs +24 -61
  229. package/esm/api/VariablesApi.mjs +11 -13
  230. package/esm/api/VariablesApi.test.mjs +80 -222
  231. package/esm/api/utils/ApiUtils.mjs +45 -48
  232. package/esm/api/utils/ApiUtils.test.mjs +33 -32
  233. package/esm/api/utils/Base64.mjs +6 -9
  234. package/esm/ext/axios-curlirize/curlirize.mjs +2 -7
  235. package/esm/ext/axios-curlirize/lib/CurlHelper.mjs +7 -20
  236. package/esm/index.mjs +23 -13
  237. package/esm/ops/AdminOps.mjs +33 -119
  238. package/esm/ops/AgentOps.mjs +38 -81
  239. package/esm/ops/AgentOps.test.mjs +5 -45
  240. package/esm/ops/AuthenticateOps.mjs +241 -175
  241. package/esm/ops/AuthenticateOps.test.mjs +7 -9
  242. package/esm/ops/CirclesOfTrustOps.mjs +24 -61
  243. package/esm/ops/ConnectionProfileOps.mjs +192 -82
  244. package/esm/ops/ConnectionProfileOps.test.mjs +19 -19
  245. package/esm/ops/EmailTemplateOps.mjs +18 -276
  246. package/esm/ops/EmailTemplateOps.test.mjs +19 -44
  247. package/esm/ops/IdmOps.mjs +30 -327
  248. package/esm/ops/IdmOps.test.mjs +47 -54
  249. package/esm/ops/IdpOps.mjs +21 -59
  250. package/esm/ops/IdpOps.test.mjs +5 -5
  251. package/esm/ops/JoseOps.mjs +41 -0
  252. package/esm/ops/JoseOps.test.mjs +137 -0
  253. package/esm/ops/JourneyOps.mjs +147 -290
  254. package/esm/ops/JourneyOps.test.mjs +30 -28
  255. package/esm/ops/LogOps.mjs +15 -25
  256. package/esm/ops/ManagedObjectOps.mjs +6 -6
  257. package/esm/ops/NodeOps.mjs +9 -47
  258. package/esm/ops/OAuth2ClientOps.mjs +13 -19
  259. package/esm/ops/OpsTypes.mjs +1 -3
  260. package/esm/ops/OrganizationOps.mjs +7 -14
  261. package/esm/ops/RealmOps.mjs +4 -7
  262. package/esm/ops/Saml2Ops.mjs +199 -587
  263. package/esm/ops/Saml2Ops.test.mjs +303 -84
  264. package/esm/ops/ScriptOps.mjs +31 -47
  265. package/esm/ops/SecretsOps.mjs +15 -31
  266. package/esm/ops/ServiceAccountOps.mjs +41 -0
  267. package/esm/ops/ServiceAccountOps.test.mjs +51 -0
  268. package/esm/ops/ServiceOps.mjs +66 -83
  269. package/esm/ops/StartupOps.mjs +4 -13
  270. package/esm/ops/ThemeOps.mjs +189 -298
  271. package/esm/{api/ThemeApi.test.mjs → ops/ThemeOps.test.mjs} +91 -96
  272. package/esm/ops/VariablesOps.mjs +9 -18
  273. package/esm/ops/utils/Console.mjs +28 -46
  274. package/esm/ops/utils/DataProtection.mjs +15 -28
  275. package/esm/ops/utils/DataProtection.test.mjs +8 -8
  276. package/esm/ops/utils/ExportImportUtils.mjs +34 -43
  277. package/esm/ops/utils/ExportImportUtils.test.mjs +20 -18
  278. package/esm/ops/utils/OpsUtils.mjs +27 -21
  279. package/esm/ops/utils/OpsUtils.test.mjs +155 -27
  280. package/esm/ops/utils/ValidationUtils.mjs +0 -9
  281. package/esm/ops/utils/Version.mjs +2 -3
  282. package/esm/ops/utils/Version.test.mjs +0 -2
  283. package/esm/ops/utils/Wordwrap.mjs +1 -1
  284. package/esm/ops/utils/Wordwrap.test.mjs +19 -0
  285. package/esm/shared/State.mjs +164 -0
  286. package/esm/shared/State.test.mjs +249 -0
  287. package/esm/test/mocks/AuthenticateApi/step/default_steps.json +88 -0
  288. package/esm/test/mocks/ForgeRockApiMockEngine.mjs +169 -33
  289. package/esm/test/mocks/IdmConfigApi/getConfigEntity/managed.json +4420 -0
  290. package/esm/test/mocks/OAuth2OIDCApi/accessToken/body.json +6 -0
  291. package/esm/test/mocks/OAuth2OIDCApi/accessToken/headers.json +19 -0
  292. package/esm/test/mocks/OAuth2OIDCApi/authorize/headers.json +38 -0
  293. package/esm/test/mocks/Saml2Api/findSaml2Providers/https:sts.windows.net711ffa9c-5972-4713-ace3-688c9732614a_stub.json +18 -0
  294. package/esm/test/mocks/Saml2Api/findSaml2Providers/iSPAzure_stub.json +18 -0
  295. package/esm/test/mocks/Saml2Api/getProvider/aVNQQXp1cmU.json +1 -2
  296. package/esm/test/mocks/Saml2Api/getProvider/dXJuOmZlZGVyYXRpb246TWljcm9zb2Z0T25saW5l.json +1 -3
  297. package/esm/test/mocks/Saml2Api/getProviderByLocationAndId/hosted/U1BBenVyZQ.json +147 -0
  298. package/esm/test/mocks/Saml2Api/getProviderByLocationAndId/hosted/aHR0cHM6Ly9pZGMuc2NoZXViZXIuaW8vYW0vc2FtbDIvSURQQXp1cmU.json +182 -0
  299. package/esm/test/mocks/Saml2Api/getProviderByLocationAndId/hosted/aHR0cHM6Ly9pZGMuc2NoZXViZXIuaW8vYW0vc2FtbDIvSURQQnJvYWRjb20.json +149 -0
  300. package/esm/test/mocks/Saml2Api/getProviderByLocationAndId/hosted/aHR0cHM6Ly9pZGMuc2NoZXViZXIuaW8vYW0vc2FtbDIvSURQRmVkbGV0.json +141 -0
  301. package/esm/test/mocks/Saml2Api/getProviderByLocationAndId/hosted/aVNQQXp1cmU.json +1 -2
  302. package/esm/test/mocks/Saml2Api/getProviderByLocationAndId/hosted/dm9sa2VyRGV2U1A.json +118 -0
  303. package/esm/test/mocks/Saml2Api/getProviderByLocationAndId/remote/aHR0cHM6Ly9zYW1sLm15dGVzdHJ1bi5jb20vc3A.json +66 -0
  304. package/esm/test/mocks/Saml2Api/getProviderByLocationAndId/remote/aHR0cHM6Ly9zdHMud2luZG93cy5uZXQvNzExZmZhOWMtNTk3Mi00NzEzLWFjZTMtNjg4Yzk3MzI2MTRhLw.json +35 -0
  305. package/esm/test/mocks/Saml2Api/getProviderByLocationAndId/remote/aWRw.json +83 -0
  306. package/esm/test/mocks/Saml2Api/getProviderByLocationAndId/remote/dXJuOmZlZGVyYXRpb246TWljcm9zb2Z0T25saW5l.json +1 -3
  307. package/esm/test/mocks/Saml2Api/getProviderMetadata/alpha/SPAzure.xml +74 -0
  308. package/esm/test/mocks/Saml2Api/getProviderMetadata/alpha/https%3A%2F%2Fidc.scheuber.io%2Fam%2Fsaml2%2FIDPAzure.xml +78 -0
  309. package/esm/test/mocks/Saml2Api/getProviderMetadata/alpha/https%3A%2F%2Fidc.scheuber.io%2Fam%2Fsaml2%2FIDPBroadcom.xml +78 -0
  310. package/esm/test/mocks/Saml2Api/getProviderMetadata/alpha/https%3A%2F%2Fidc.scheuber.io%2Fam%2Fsaml2%2FIDPFedlet.xml +78 -0
  311. package/esm/test/mocks/Saml2Api/getProviderMetadata/alpha/https%3A%2F%2Fsaml.mytestrun.com%2Fsp.xml +13 -0
  312. package/esm/test/mocks/Saml2Api/getProviderMetadata/alpha/{dXJuOmZlZGVyYXRpb246TWljcm9zb2Z0T25saW5l.xml → https%3A%2F%2Fsts.windows.net%2F711ffa9c-5972-4713-ace3-688c9732614a%2F.xml} +0 -0
  313. package/esm/test/mocks/Saml2Api/getProviderMetadata/alpha/{aVNQQXp1cmU.xml → iSPAzure.xml} +0 -0
  314. package/esm/test/mocks/Saml2Api/getProviderMetadata/alpha/urn%3Afederation%3AMicrosoftOnline.xml +84 -0
  315. package/esm/test/mocks/Saml2Ops/importSaml2Provider/SPAzure.saml.json +243 -0
  316. package/esm/test/mocks/Saml2Ops/importSaml2Provider/iSPAzure.saml.json +242 -0
  317. package/esm/test/mocks/Saml2Ops/importSaml2Provider/idc.scheuber.ioamsaml2IDPAzure.saml.json +454 -0
  318. package/esm/test/mocks/Saml2Ops/importSaml2Provider/idc.scheuber.ioamsaml2IDPBroadcom.saml.json +586 -0
  319. package/esm/test/mocks/Saml2Ops/importSaml2Provider/idc.scheuber.ioamsaml2IDPFedlet.saml.json +241 -0
  320. package/esm/test/mocks/Saml2Ops/importSaml2Provider/idp.saml.json +185 -0
  321. package/esm/test/mocks/Saml2Ops/importSaml2Provider/saml.mytestrun.comsp.saml.json +101 -0
  322. package/esm/test/mocks/Saml2Ops/importSaml2Provider/sts.windows.net711ffa9c-5972-4713-ace3-688c9732614a.saml.json +113 -0
  323. package/esm/test/mocks/Saml2Ops/importSaml2Provider/urn:federation:MicrosoftOnline.saml.json +199 -0
  324. package/esm/test/mocks/Saml2Ops/importSaml2Provider/volkerDevSP.saml.json +212 -0
  325. package/esm/test/mocks/Saml2Ops/importSaml2Providers/allAlphaProviders.saml.json +2414 -0
  326. package/esm/test/mocks/ScriptApi/getScript/5b29c5b7-b161-4a42-a41f-d6c85316b951.json +13 -0
  327. package/esm/test/mocks/ScriptApi/getScript/85523e71-2d77-4577-b078-6f9674cc54e2.json +13 -0
  328. package/esm/test/mocks/ScriptApi/getScript/90c4eca5-05f0-42f5-b9bf-88b693eabbbd.json +13 -0
  329. package/esm/test/mocks/ServerInfoApi/getServerInfo/info.json +25 -0
  330. package/esm/test/mocks/ServerInfoApi/getServerVersionInfo/version.json +8 -0
  331. package/esm/utils/AutoSetupPolly.mjs +72 -0
  332. package/esm/utils/SetupJest.mjs +3 -0
  333. package/esm/{test/mocks → utils}/snapshotResolve.mjs +10 -12
  334. package/package.json +38 -27
  335. package/types/api/AgentApi.d.ts.map +1 -1
  336. package/types/api/ApiTypes.d.ts +19 -15
  337. package/types/api/ApiTypes.d.ts.map +1 -1
  338. package/types/api/AuthenticateApi.d.ts +1 -1
  339. package/types/api/AuthenticateApi.d.ts.map +1 -1
  340. package/types/api/BaseApi.d.ts +2 -0
  341. package/types/api/BaseApi.d.ts.map +1 -1
  342. package/types/api/CirclesOfTrustApi.d.ts.map +1 -1
  343. package/types/api/IdmConfigApi.d.ts.map +1 -1
  344. package/types/api/LogApi.d.ts.map +1 -1
  345. package/types/api/ManagedObjectApi.d.ts +9 -1
  346. package/types/api/ManagedObjectApi.d.ts.map +1 -1
  347. package/types/api/NodeApi.d.ts.map +1 -1
  348. package/types/api/OAuth2ClientApi.d.ts.map +1 -1
  349. package/types/api/OAuth2OIDCApi.d.ts +4 -2
  350. package/types/api/OAuth2OIDCApi.d.ts.map +1 -1
  351. package/types/api/OAuth2ProviderApi.d.ts.map +1 -1
  352. package/types/api/RealmApi.d.ts.map +1 -1
  353. package/types/api/Saml2Api.d.ts +7 -13
  354. package/types/api/Saml2Api.d.ts.map +1 -1
  355. package/types/api/ScriptApi.d.ts.map +1 -1
  356. package/types/api/SecretsApi.d.ts.map +1 -1
  357. package/types/api/ServerInfoApi.d.ts.map +1 -1
  358. package/types/api/ServiceApi.d.ts +14 -7
  359. package/types/api/ServiceApi.d.ts.map +1 -1
  360. package/types/api/SocialIdentityProvidersApi.d.ts.map +1 -1
  361. package/types/api/StartupApi.d.ts.map +1 -1
  362. package/types/api/TreeApi.d.ts.map +1 -1
  363. package/types/api/VariablesApi.d.ts.map +1 -1
  364. package/types/api/utils/ApiUtils.d.ts +1 -0
  365. package/types/api/utils/ApiUtils.d.ts.map +1 -1
  366. package/types/api/utils/Base64.d.ts +1 -0
  367. package/types/api/utils/Base64.d.ts.map +1 -1
  368. package/types/index.d.ts +11 -5
  369. package/types/index.d.ts.map +1 -1
  370. package/types/ops/AgentOps.d.ts +1 -1
  371. package/types/ops/AgentOps.d.ts.map +1 -1
  372. package/types/ops/AuthenticateOps.d.ts +10 -2
  373. package/types/ops/AuthenticateOps.d.ts.map +1 -1
  374. package/types/ops/ConnectionProfileOps.d.ts +49 -21
  375. package/types/ops/ConnectionProfileOps.d.ts.map +1 -1
  376. package/types/ops/EmailTemplateOps.d.ts +14 -33
  377. package/types/ops/EmailTemplateOps.d.ts.map +1 -1
  378. package/types/ops/IdmOps.d.ts +29 -37
  379. package/types/ops/IdmOps.d.ts.map +1 -1
  380. package/types/ops/JoseOps.d.ts +33 -0
  381. package/types/ops/JoseOps.d.ts.map +1 -0
  382. package/types/ops/JourneyOps.d.ts.map +1 -1
  383. package/types/ops/LogOps.d.ts.map +1 -1
  384. package/types/ops/NodeOps.d.ts.map +1 -1
  385. package/types/ops/OAuth2ClientOps.d.ts.map +1 -1
  386. package/types/ops/OpsTypes.d.ts +17 -1
  387. package/types/ops/OpsTypes.d.ts.map +1 -1
  388. package/types/ops/OrganizationOps.d.ts.map +1 -1
  389. package/types/ops/Saml2Ops.d.ts +52 -55
  390. package/types/ops/Saml2Ops.d.ts.map +1 -1
  391. package/types/ops/ScriptOps.d.ts.map +1 -1
  392. package/types/ops/ServiceAccountOps.d.ts +20 -0
  393. package/types/ops/ServiceAccountOps.d.ts.map +1 -0
  394. package/types/ops/ServiceOps.d.ts +18 -10
  395. package/types/ops/ServiceOps.d.ts.map +1 -1
  396. package/types/ops/ThemeOps.d.ts +35 -50
  397. package/types/ops/ThemeOps.d.ts.map +1 -1
  398. package/types/ops/utils/Console.d.ts +1 -1
  399. package/types/ops/utils/Console.d.ts.map +1 -1
  400. package/types/ops/utils/DataProtection.d.ts.map +1 -1
  401. package/types/ops/utils/ExportImportUtils.d.ts +5 -2
  402. package/types/ops/utils/ExportImportUtils.d.ts.map +1 -1
  403. package/types/ops/utils/OpsUtils.d.ts +6 -0
  404. package/types/ops/utils/OpsUtils.d.ts.map +1 -1
  405. package/types/ops/utils/Wordwrap.d.ts.map +1 -1
  406. package/types/shared/State.d.ts +223 -0
  407. package/types/shared/State.d.ts.map +1 -0
  408. package/types/test/mocks/ForgeRockApiMockEngine.d.ts +21 -1
  409. package/types/test/mocks/ForgeRockApiMockEngine.d.ts.map +1 -1
  410. package/types/utils/AutoSetupPolly.d.ts +1 -0
  411. package/types/utils/AutoSetupPolly.d.ts.map +1 -0
  412. package/types/utils/SetupJest.d.ts +1 -0
  413. package/types/utils/SetupJest.d.ts.map +1 -0
  414. package/types/utils/snapshotResolve.d.ts +1 -0
  415. package/types/utils/snapshotResolve.d.ts.map +1 -0
  416. package/cjs/api/EmailTemplateApi.js +0 -73
  417. package/cjs/api/EmailTemplateApi.js.map +0 -1
  418. package/cjs/api/ThemeApi.js +0 -367
  419. package/cjs/api/ThemeApi.js.map +0 -1
  420. package/cjs/api/ThemeApi.test.js.map +0 -1
  421. package/cjs/storage/SessionStorage.js +0 -91
  422. package/cjs/storage/SessionStorage.js.map +0 -1
  423. package/cjs/test/mocks/snapshotResolve.js.map +0 -1
  424. package/esm/api/EmailTemplateApi.mjs +0 -34
  425. package/esm/api/ThemeApi.mjs +0 -271
  426. package/esm/storage/SessionStorage.mjs +0 -79
  427. package/types/api/EmailTemplateApi.d.ts +0 -22
  428. package/types/api/EmailTemplateApi.d.ts.map +0 -1
  429. package/types/api/ThemeApi.d.ts +0 -56
  430. package/types/api/ThemeApi.d.ts.map +0 -1
  431. package/types/storage/SessionStorage.d.ts +0 -71
  432. package/types/storage/SessionStorage.d.ts.map +0 -1
  433. package/types/test/mocks/snapshotResolve.d.ts +0 -1
  434. package/types/test/mocks/snapshotResolve.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/ops/OpsTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,YAAY,EACb,MAAM,iBAAiB,CAAC;AAEzB;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,yBAAyB;IACxC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC1C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACxC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IACtD,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC3D,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IACrD,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IACtD,IAAI,EAAE,YAAY,CAAC;CACpB;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACtC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;CAClD;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACtC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;CAC5C;AAED,MAAM,WAAW,0BAA0B;IACzC,CAAC,CAAC,EAAE,MAAM,GAAG,0BAA0B,EAAE,CAAC;CAC3C;AAED,MAAM,WAAW,2BAA2B;IAC1C,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;CACtD;AAED,oBAAY,kBAAkB;IAC5B,QAAQ,aAAa;IACrB,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,OAAO,YAAY;CACpB;AAED,oBAAY,qBAAqB;IAC/B,QAAQ,aAAa;IACrB,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,OAAO,YAAY;CACpB","file":"OpsTypes.d.ts","sourcesContent":["import {\n AgentSkeleton,\n AmServiceSkeleton,\n CircleOfTrustSkeleton,\n EmailTemplateSkeleton,\n NodeSkeleton,\n Saml2ProviderSkeleton,\n ScriptSkeleton,\n SocialIdpSkeleton,\n ThemeSkeleton,\n TreeSkeleton,\n} from '../api/ApiTypes';\n\n/**\n * Tree export options\n */\nexport interface TreeExportOptions {\n /**\n * Where applicable, use string arrays to store multi-line text (e.g. scripts).\n */\n useStringArrays: boolean;\n /**\n * Include any dependencies (scripts, email templates, SAML entity providers and circles of trust, social identity providers, themes).\n */\n deps: boolean;\n}\n\n/**\n * Tree import options\n */\nexport interface TreeImportOptions {\n /**\n * Generate new UUIDs for all nodes during import.\n */\n reUuid: boolean;\n /**\n * Include any dependencies (scripts, email templates, SAML entity providers and circles of trust, social identity providers, themes).\n */\n deps: boolean;\n}\n\nexport interface ExportMetaData {\n origin: string;\n originAmVersion: string;\n exportedBy: string;\n exportDate: string;\n exportTool: string;\n exportToolVersion: string;\n}\n\nexport interface SingleTreeExportInterface {\n meta?: Record<string, ExportMetaData>;\n innerNodes?: Record<string, NodeSkeleton>;\n innernodes?: Record<string, NodeSkeleton>;\n nodes: Record<string, NodeSkeleton>;\n scripts: Record<string, ScriptSkeleton>;\n emailTemplates: Record<string, EmailTemplateSkeleton>;\n socialIdentityProviders: Record<string, SocialIdpSkeleton>;\n themes: ThemeSkeleton[];\n saml2Entities: Record<string, Saml2ProviderSkeleton>;\n circlesOfTrust: Record<string, CircleOfTrustSkeleton>;\n tree: TreeSkeleton;\n}\n\nexport interface MultiTreeExportInterface {\n meta?: Record<string, ExportMetaData>;\n trees: Record<string, SingleTreeExportInterface>;\n}\n\nexport interface AgentExportInterface {\n meta?: Record<string, ExportMetaData>;\n agents: Record<string, AgentSkeleton>;\n}\n\nexport interface ServiceExportInterface {\n meta?: Record<string, ExportMetaData>;\n service: Record<string, AmServiceSkeleton>;\n}\n\nexport interface TreeDependencyMapInterface {\n [k: string]: TreeDependencyMapInterface[];\n}\n\nexport interface TreeExportResolverInterface {\n (treeId: string): Promise<SingleTreeExportInterface>;\n}\n\nexport enum NodeClassification {\n STANDARD = 'standard',\n CUSTOM = 'custom',\n CLOUD = 'cloud',\n PREMIUM = 'premium',\n}\n\nexport enum JourneyClassification {\n STANDARD = 'standard',\n CUSTOM = 'custom',\n CLOUD = 'cloud',\n PREMIUM = 'premium',\n}\n"]}
1
+ {"version":3,"sources":["../src/ops/OpsTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,YAAY,EACb,MAAM,iBAAiB,CAAC;AAEzB;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,yBAAyB;IACxC,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC1C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACxC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IACtD,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC3D,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IACrD,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IACtD,IAAI,EAAE,YAAY,CAAC;CACpB;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACtC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;CAClD;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACtC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACvC,IAAI,EAAE;QACJ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;QAC9C,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;QAC9C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;KACpC,CAAC;CACH;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;CAC5C;AAED,MAAM,WAAW,0BAA0B;IACzC,CAAC,CAAC,EAAE,MAAM,GAAG,0BAA0B,EAAE,CAAC;CAC3C;AAED,MAAM,WAAW,2BAA2B;IAC1C,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;CACtD;AAED,oBAAY,kBAAkB;IAC5B,QAAQ,aAAa;IACrB,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,OAAO,YAAY;CACpB;AAED,oBAAY,qBAAqB;IAC/B,QAAQ,aAAa;IACrB,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,OAAO,YAAY;CACpB;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB","file":"OpsTypes.d.ts","sourcesContent":["import {\n AgentSkeleton,\n AmServiceSkeleton,\n CircleOfTrustSkeleton,\n EmailTemplateSkeleton,\n NodeSkeleton,\n Saml2ProviderSkeleton,\n ScriptSkeleton,\n SocialIdpSkeleton,\n ThemeSkeleton,\n TreeSkeleton,\n} from '../api/ApiTypes';\n\n/**\n * Tree export options\n */\nexport interface TreeExportOptions {\n /**\n * Where applicable, use string arrays to store multi-line text (e.g. scripts).\n */\n useStringArrays: boolean;\n /**\n * Include any dependencies (scripts, email templates, SAML entity providers and circles of trust, social identity providers, themes).\n */\n deps: boolean;\n}\n\n/**\n * Tree import options\n */\nexport interface TreeImportOptions {\n /**\n * Generate new UUIDs for all nodes during import.\n */\n reUuid: boolean;\n /**\n * Include any dependencies (scripts, email templates, SAML entity providers and circles of trust, social identity providers, themes).\n */\n deps: boolean;\n}\n\nexport interface ExportMetaData {\n origin: string;\n originAmVersion: string;\n exportedBy: string;\n exportDate: string;\n exportTool: string;\n exportToolVersion: string;\n}\n\nexport interface SingleTreeExportInterface {\n meta?: ExportMetaData;\n innerNodes?: Record<string, NodeSkeleton>;\n innernodes?: Record<string, NodeSkeleton>;\n nodes: Record<string, NodeSkeleton>;\n scripts: Record<string, ScriptSkeleton>;\n emailTemplates: Record<string, EmailTemplateSkeleton>;\n socialIdentityProviders: Record<string, SocialIdpSkeleton>;\n themes: ThemeSkeleton[];\n saml2Entities: Record<string, Saml2ProviderSkeleton>;\n circlesOfTrust: Record<string, CircleOfTrustSkeleton>;\n tree: TreeSkeleton;\n}\n\nexport interface MultiTreeExportInterface {\n meta?: Record<string, ExportMetaData>;\n trees: Record<string, SingleTreeExportInterface>;\n}\n\nexport interface AgentExportInterface {\n meta?: Record<string, ExportMetaData>;\n agents: Record<string, AgentSkeleton>;\n}\n\nexport interface Saml2ExportInterface {\n meta?: ExportMetaData;\n script: Record<string, ScriptSkeleton>;\n saml: {\n hosted: Record<string, Saml2ProviderSkeleton>;\n remote: Record<string, Saml2ProviderSkeleton>;\n metadata: Record<string, string[]>;\n };\n}\n\nexport interface ServiceExportInterface {\n meta?: Record<string, ExportMetaData>;\n service: Record<string, AmServiceSkeleton>;\n}\n\nexport interface TreeDependencyMapInterface {\n [k: string]: TreeDependencyMapInterface[];\n}\n\nexport interface TreeExportResolverInterface {\n (treeId: string): Promise<SingleTreeExportInterface>;\n}\n\nexport enum NodeClassification {\n STANDARD = 'standard',\n CUSTOM = 'custom',\n CLOUD = 'cloud',\n PREMIUM = 'premium',\n}\n\nexport enum JourneyClassification {\n STANDARD = 'standard',\n CUSTOM = 'custom',\n CLOUD = 'cloud',\n PREMIUM = 'premium',\n}\n\nexport interface MultiOpStatusInterface {\n total: number;\n successes: number;\n warnings: number;\n failures: number;\n message?: string;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/ops/OrganizationOps.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAgB,2BAA2B,WAQ1C;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,mBAkCrC;AAGD,wBAAsB,wBAAwB,mBA6B7C","file":"OrganizationOps.d.ts","sourcesContent":["import { queryAllManagedObjectsByType } from '../api/IdmConfigApi';\nimport storage from '../storage/SessionStorage';\nimport { printMessage } from './utils/Console';\n\n/**\n * Get organization managed object type\n * @returns {String} organization managed object type in this realm\n */\nexport function getRealmManagedOrganization() {\n let realmManagedOrg = 'organization';\n if (\n storage.session.getDeploymentType() === global.CLOUD_DEPLOYMENT_TYPE_KEY\n ) {\n realmManagedOrg = `${storage.session.getRealm()}_organization`;\n }\n return realmManagedOrg;\n}\n\n/**\n * Get organizations\n * @returns {Promise} promise resolving to an object containing an array of organization objects\n */\nexport async function getOrganizations() {\n const orgs = [];\n let result = {\n result: [],\n resultCount: 0,\n pagedResultsCookie: null,\n totalPagedResultsPolicy: 'NONE',\n totalPagedResults: -1,\n remainingPagedResults: -1,\n };\n try {\n do {\n try {\n // eslint-disable-next-line no-await-in-loop\n result = await queryAllManagedObjectsByType(\n getRealmManagedOrganization(),\n ['name', 'parent/*/name', 'children/*/name'],\n result.pagedResultsCookie\n );\n } catch (queryAllManagedObjectsByTypeError) {\n printMessage(queryAllManagedObjectsByTypeError, 'error');\n printMessage(\n `Error querying ${getRealmManagedOrganization()} objects: ${queryAllManagedObjectsByTypeError}`,\n 'error'\n );\n }\n orgs.concat(result.result);\n printMessage('.', 'text', false);\n } while (result.pagedResultsCookie);\n } catch (error) {\n printMessage(error.response.data, 'error');\n printMessage(`Error retrieving all organizations: ${error}`, 'error');\n }\n return orgs;\n}\n\n// unfinished work\nexport async function listOrganizationsTopDown() {\n const orgs = [];\n let result = {\n result: [],\n resultCount: 0,\n pagedResultsCookie: null,\n totalPagedResultsPolicy: 'NONE',\n totalPagedResults: -1,\n remainingPagedResults: -1,\n };\n do {\n try {\n // eslint-disable-next-line no-await-in-loop\n result = await queryAllManagedObjectsByType(\n getRealmManagedOrganization(),\n ['name', 'parent/*/name', 'children/*/name'],\n result.pagedResultsCookie\n );\n } catch (queryAllManagedObjectsByTypeError) {\n printMessage(queryAllManagedObjectsByTypeError, 'error');\n printMessage(\n `Error querying ${getRealmManagedOrganization()} objects: ${queryAllManagedObjectsByTypeError}`,\n 'error'\n );\n }\n orgs.concat(result.result);\n printMessage('.', 'text', false);\n } while (result.pagedResultsCookie);\n return orgs;\n}\n"]}
1
+ {"version":3,"sources":["../src/ops/OrganizationOps.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAgB,2BAA2B,WAM1C;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,mBAkCrC;AAGD,wBAAsB,wBAAwB,mBA6B7C","file":"OrganizationOps.d.ts","sourcesContent":["import { queryAllManagedObjectsByType } from '../api/IdmConfigApi';\nimport * as state from '../shared/State';\nimport { printMessage } from './utils/Console';\n\n/**\n * Get organization managed object type\n * @returns {String} organization managed object type in this realm\n */\nexport function getRealmManagedOrganization() {\n let realmManagedOrg = 'organization';\n if (state.getDeploymentType() === global.CLOUD_DEPLOYMENT_TYPE_KEY) {\n realmManagedOrg = `${state.getRealm()}_organization`;\n }\n return realmManagedOrg;\n}\n\n/**\n * Get organizations\n * @returns {Promise} promise resolving to an object containing an array of organization objects\n */\nexport async function getOrganizations() {\n const orgs = [];\n let result = {\n result: [],\n resultCount: 0,\n pagedResultsCookie: null,\n totalPagedResultsPolicy: 'NONE',\n totalPagedResults: -1,\n remainingPagedResults: -1,\n };\n try {\n do {\n try {\n // eslint-disable-next-line no-await-in-loop\n result = await queryAllManagedObjectsByType(\n getRealmManagedOrganization(),\n ['name', 'parent/*/name', 'children/*/name'],\n result.pagedResultsCookie\n );\n } catch (queryAllManagedObjectsByTypeError) {\n printMessage(queryAllManagedObjectsByTypeError, 'error');\n printMessage(\n `Error querying ${getRealmManagedOrganization()} objects: ${queryAllManagedObjectsByTypeError}`,\n 'error'\n );\n }\n orgs.concat(result.result);\n printMessage('.', 'text', false);\n } while (result.pagedResultsCookie);\n } catch (error) {\n printMessage(error.response.data, 'error');\n printMessage(`Error retrieving all organizations: ${error}`, 'error');\n }\n return orgs;\n}\n\n// unfinished work\nexport async function listOrganizationsTopDown() {\n const orgs = [];\n let result = {\n result: [],\n resultCount: 0,\n pagedResultsCookie: null,\n totalPagedResultsPolicy: 'NONE',\n totalPagedResults: -1,\n remainingPagedResults: -1,\n };\n do {\n try {\n // eslint-disable-next-line no-await-in-loop\n result = await queryAllManagedObjectsByType(\n getRealmManagedOrganization(),\n ['name', 'parent/*/name', 'children/*/name'],\n result.pagedResultsCookie\n );\n } catch (queryAllManagedObjectsByTypeError) {\n printMessage(queryAllManagedObjectsByTypeError, 'error');\n printMessage(\n `Error querying ${getRealmManagedOrganization()} objects: ${queryAllManagedObjectsByTypeError}`,\n 'error'\n );\n }\n orgs.concat(result.result);\n printMessage('.', 'text', false);\n } while (result.pagedResultsCookie);\n return orgs;\n}\n"]}
@@ -1,60 +1,70 @@
1
+ import { Saml2ProviderSkeleton, Saml2ProviderStub } from '../api/ApiTypes';
2
+ import { MultiOpStatusInterface, Saml2ExportInterface } from './OpsTypes';
1
3
  export declare const roleMap: {
2
4
  identityProvider: string;
3
5
  serviceProvider: string;
4
6
  attributeQueryProvider: string;
5
7
  xacmlPolicyEnforcementPoint: string;
6
8
  };
9
+ export declare function createSaml2ExportTemplate(): Saml2ExportInterface;
7
10
  /**
8
- * List entity providers
9
- * @param {boolean} long Long list format with details
11
+ * Get SAML2 entity provider stubs
12
+ * @returns {Promise<Saml2ProviderStub[]>} a promise that resolves to an array of saml2 entity stubs
10
13
  */
11
- export declare function listSaml2Providers(long?: boolean): Promise<void>;
14
+ export declare function getSaml2ProviderStubs(): Promise<Saml2ProviderStub[]>;
12
15
  /**
13
- * Export a single entity provider to file
14
- * @param {String} entityId Provider entity id
15
- * @param {String} file Optional filename
16
+ * Geta SAML2 entity provider by location and id
17
+ * @param {string} location Entity provider location (hosted or remote)
18
+ * @param {string} entityId64 Base64-encoded provider entity id
19
+ * @returns {Promise} a promise that resolves to a saml2 entity provider object
16
20
  */
17
- export declare function exportSaml2ProviderToFile(entityId: any, file?: any): Promise<void>;
21
+ export declare function getProviderByLocationAndId(location: string, entityId64: string): Promise<any>;
18
22
  /**
19
- * Export provider metadata to file
20
- * @param {String} entityId Provider entity id
21
- * @param {String} file Optional filename
23
+ * Get a SAML2 entity provider's metadata URL by entity id
24
+ * @param {string} entityId SAML2 entity id
25
+ * @returns {string} the URL to get the metadata from
22
26
  */
23
- export declare function exportSaml2Metadata(entityId: any, file?: any): Promise<void>;
27
+ export declare function getProviderMetadataUrl(entityId: string): string;
24
28
  /**
25
- * Describe an entity provider's configuration
26
- * @param {String} entityId Provider entity id
29
+ * Get a SAML2 entity provider's metadata by entity id
30
+ * @param {String} entityId SAML2 entity id
31
+ * @returns {Promise} a promise that resolves to an object containing a SAML2 metadata
27
32
  */
28
- export declare function describeSaml2Provider(entityId: any): Promise<void>;
33
+ export declare function getProviderMetadata(entityId: any): Promise<any>;
29
34
  /**
30
- * Export all entity providers to one file
31
- * @param {String} file Optional filename
35
+ *
36
+ * @param {String} entityId Provider entity id
37
+ * @returns {Promise<Saml2ProviderStub>} Promise resolving to a Saml2ExportInterface object.
32
38
  */
33
- export declare function exportSaml2ProvidersToFile(file?: any): Promise<void>;
39
+ export declare function getSaml2ProviderStub(entityId: string): Promise<Saml2ProviderStub>;
34
40
  /**
35
- * Export all entity providers to individual files
41
+ * Export a single entity provider. The response can be saved to file as is.
42
+ * @param {String} entityId Provider entity id
43
+ * @returns {Promise<Saml2ProviderSkeleton>} Promise resolving to a Saml2ExportInterface object.
36
44
  */
37
- export declare function exportSaml2ProvidersToFiles(): Promise<void>;
45
+ export declare function getSaml2Provider(entityId: string): Promise<Saml2ProviderSkeleton>;
38
46
  /**
39
- * Import a SAML entity provider by entity id from file
47
+ * Export a single entity provider. The response can be saved to file as is.
40
48
  * @param {String} entityId Provider entity id
41
- * @param {String} file Import file name
49
+ * @returns {Promise<Saml2ExportInterface>} Promise resolving to a Saml2ExportInterface object.
42
50
  */
43
- export declare function importSaml2ProviderFromFile(entityId: any, file: any): Promise<void>;
51
+ export declare function exportSaml2Provider(entityId: string): Promise<Saml2ExportInterface>;
44
52
  /**
45
- * Import first SAML entity provider from file
46
- * @param {String} file Import file name
53
+ * Export all entity providers. The response can be saved to file as is.
54
+ * @returns {Promise<Saml2ExportInterface>} Promise resolving to a Saml2ExportInterface object.
47
55
  */
48
- export declare function importFirstSaml2ProviderFromFile(file: any): Promise<void>;
56
+ export declare function exportSaml2Providers(): Promise<Saml2ExportInterface>;
49
57
  /**
50
- * Import all SAML entity providers from file
51
- * @param {String} file Import file name
58
+ * Import a SAML entity provider
59
+ * @param {string} entityId Provider entity id
60
+ * @param {Saml2ExportInterface} importData Import data
52
61
  */
53
- export declare function importSaml2ProvidersFromFile(file: any): Promise<void>;
62
+ export declare function importSaml2Provider(entityId: string, importData: Saml2ExportInterface): Promise<void>;
54
63
  /**
55
- * Import all SAML entity providers from all *.saml.json files in the current directory
64
+ * Import SAML entity providers
65
+ * @param {Saml2ExportInterface} importData Import data
56
66
  */
57
- export declare function importSaml2ProvidersFromFiles(): Promise<void>;
67
+ export declare function importSaml2Providers(importData: Saml2ExportInterface): Promise<MultiOpStatusInterface>;
58
68
  /**
59
69
  * Deletes entity provider
60
70
  * @param {string} entityId The entity id for the entity to be deleted
@@ -65,33 +75,20 @@ export declare function deleteSaml2Provider(entityId: string): Promise<void>;
65
75
  */
66
76
  export declare function deleteSaml2Providers(): Promise<void>;
67
77
  /**
68
- * Exports a RAW SAML entity, which means the raw xml is included.
69
- * @param {string} entityId Reference to the entity for export
70
- * @param {string} file Optional filename for the exported file
71
- */
72
- export declare function exportRawSaml2ProviderToFile(entityId: any, file?: any): Promise<void>;
73
- /**
74
- * Export all entity providers raw to one file
75
- * @param {String} file Optional filename
76
- */
77
- export declare function exportRawSaml2ProvidersToFile(file?: any): Promise<void>;
78
- /**
79
- * Export all entity providers to individual files
80
- */
81
- export declare function exportRawSaml2ProvidersToFiles(): Promise<void>;
82
- /**
83
- * Imports the RAW provider info from a single file.
84
- * @param file Import file name
78
+ * Retrieves all entity providers using the legacy federation enpoints.
79
+ * @returns {Promise} a promise that resolves to an object containing an array of providers
85
80
  */
86
- export declare function importRawSaml2ProvidersFromFile(file: string): Promise<void>;
81
+ export declare function getRawProviders(): Promise<any>;
87
82
  /**
88
- * Whenever the SAML RAW file were exported using the exportRAW functionality this function
89
- * is used to read them back in. Only files with the .samlRaw.json extension will be imported.
90
- * @param {string} directory The directory from which to import the files
83
+ * Retrieves all entity providers using the legacy federation enpoints.
84
+ * @param {string} entityId The entity provider id
85
+ * @returns {Promise} a promise that resolves to an object containing an array of providers
91
86
  */
92
- export declare function importRawSaml2ProvidersFromFiles(directory: any): Promise<void>;
87
+ export declare function getRawProvider(entityId: string): Promise<any>;
93
88
  /**
94
- * Imports a raw SAML export file (containing one entity).
95
- * @param {string} file The import file
89
+ * Stores a new SAML2 entity provider
90
+ * @param {string} entityId The entity provider id
91
+ * @param {string} entityData The actual data containing the entity provider configuration
92
+ * @returns {Promise} Promise that resolves to a provider object
96
93
  */
97
- export declare function importRawSaml2ProviderFromFile(file: any): Promise<void>;
94
+ export declare function putRawProvider(entityId: string, entityData: any): Promise<any>;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/ops/Saml2Ops.ts"],"names":[],"mappings":"AAuCA,eAAO,MAAM,OAAO;;;;;CAKnB,CAAC;AAeF;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,UAAQ,iBAsBpD;AAuCD;;;;GAIG;AACH,wBAAsB,yBAAyB,CAAC,QAAQ,KAAA,EAAE,IAAI,MAAO,iBA2CpE;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,KAAA,EAAE,IAAI,MAAO,iBAoB9D;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CAAC,QAAQ,KAAA,iBA8CnD;AAED;;;GAGG;AACH,wBAAsB,0BAA0B,CAAC,IAAI,MAAO,iBAgC3D;AAED;;GAEG;AACH,wBAAsB,2BAA2B,kBAsBhD;AAgDD;;;;GAIG;AACH,wBAAsB,2BAA2B,CAAC,QAAQ,KAAA,EAAE,IAAI,KAAA,iBAqC/D;AAED;;;GAGG;AACH,wBAAsB,gCAAgC,CAAC,IAAI,KAAA,iBA8C1D;AAED;;;GAGG;AACH,wBAAsB,4BAA4B,CAAC,IAAI,KAAA,iBAoCtD;AAED;;GAEG;AACH,wBAAsB,6BAA6B,kBAoDlD;AAID;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,iBAMzD;AAED;;GAEG;AACH,wBAAsB,oBAAoB,kBAWzC;AAED;;;;GAIG;AACH,wBAAsB,4BAA4B,CAAC,QAAQ,KAAA,EAAE,IAAI,MAAO,iBAavE;AAED;;;GAGG;AACH,wBAAsB,6BAA6B,CAAC,IAAI,MAAO,iBAuB9D;AAED;;GAEG;AACH,wBAAsB,8BAA8B,kBA6BnD;AAED;;;GAGG;AACH,wBAAsB,+BAA+B,CAAC,IAAI,EAAE,MAAM,iBA6BjE;AAED;;;;GAIG;AACH,wBAAsB,gCAAgC,CAAC,SAAS,KAAA,iBAsC/D;AAED;;;GAGG;AACH,wBAAsB,8BAA8B,CAAC,IAAI,KAAA,iBAexD","file":"Saml2Ops.d.ts","sourcesContent":["import fs from 'fs';\nimport _ from 'lodash';\nimport path from 'path';\nimport {\n createProvider,\n deleteProvider,\n findProviders,\n getProviderByLocationAndId,\n getProviderMetadata,\n getProviderMetadataUrl,\n getRawProvider,\n getProviders,\n getRawProviders,\n putRawProvider,\n} from '../api/Saml2Api';\nimport { getScript } from '../api/ScriptApi';\nimport { decode, encode, encodeBase64Url } from '../api/utils/Base64';\nimport { createOrUpdateScript } from './ScriptOps';\nimport {\n createObjectTable,\n createProgressIndicator,\n createTable,\n printMessage,\n stopProgressIndicator,\n updateProgressIndicator,\n} from './utils/Console';\nimport {\n convertBase64TextToArray,\n convertBase64UrlTextToArray,\n convertTextArrayToBase64,\n convertTextArrayToBase64Url,\n getRealmString,\n getTypedFilename,\n saveJsonToFile,\n saveTextToFile,\n saveToFile,\n validateImport,\n} from './utils/ExportImportUtils';\n\nexport const roleMap = {\n identityProvider: 'IDP',\n serviceProvider: 'SP',\n attributeQueryProvider: 'AttrQuery',\n xacmlPolicyEnforcementPoint: 'XACML PEP',\n};\n\n// use a function vs a template variable to avoid problems in loops\nfunction getFileDataTemplate() {\n return {\n meta: {},\n script: {},\n saml: {\n hosted: {},\n remote: {},\n metadata: {},\n },\n };\n}\n\n/**\n * List entity providers\n * @param {boolean} long Long list format with details\n */\nexport async function listSaml2Providers(long = false) {\n const providerList = (await getProviders()).result;\n providerList.sort((a, b) => a._id.localeCompare(b._id));\n if (!long) {\n for (const provider of providerList) {\n printMessage(`${provider.entityId}`, 'data');\n }\n } else {\n const table = createTable([\n 'Entity Id'['brightCyan'],\n 'Location'['brightCyan'],\n 'Role(s)'['brightCyan'],\n ]);\n for (const provider of providerList) {\n table.push([\n provider.entityId,\n provider.location,\n provider.roles.map((role) => roleMap[role]).join(', '),\n ]);\n }\n printMessage(table.toString());\n }\n}\n\n/**\n * Include dependencies in the export file\n * @param {Object} providerData Object representing a SAML entity provider\n * @param {Object} fileData File data object to add dependencies to\n */\nasync function exportDependencies(providerData, fileData) {\n const attrMapperScriptId = _.get(providerData, [\n 'identityProvider',\n 'assertionProcessing',\n 'attributeMapper',\n 'attributeMapperScript',\n ]);\n if (attrMapperScriptId && attrMapperScriptId !== '[Empty]') {\n const scriptData = await getScript(attrMapperScriptId);\n scriptData.script = convertBase64TextToArray(scriptData.script);\n // eslint-disable-next-line no-param-reassign\n fileData.script[attrMapperScriptId] = scriptData;\n }\n const idpAdapterScriptId = _.get(providerData, [\n 'identityProvider',\n 'advanced',\n 'idpAdapter',\n 'idpAdapterScript',\n ]);\n if (idpAdapterScriptId && idpAdapterScriptId !== '[Empty]') {\n const scriptData = await getScript(idpAdapterScriptId);\n scriptData.script = convertBase64TextToArray(scriptData.script);\n // eslint-disable-next-line no-param-reassign\n fileData.script[idpAdapterScriptId] = scriptData;\n }\n const metaDataResponse = await getProviderMetadata(providerData.entityId);\n // eslint-disable-next-line no-param-reassign\n fileData.saml.metadata[providerData._id] = convertBase64UrlTextToArray(\n encodeBase64Url(metaDataResponse)\n );\n}\n\n/**\n * Export a single entity provider to file\n * @param {String} entityId Provider entity id\n * @param {String} file Optional filename\n */\nexport async function exportSaml2ProviderToFile(entityId, file = null) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(entityId, 'saml');\n }\n createProgressIndicator(1, `Exporting provider ${entityId}`);\n try {\n const found = await findProviders(`entityId eq '${entityId}'`, 'location');\n switch (found.resultCount) {\n case 0:\n printMessage(`No provider with entity id '${entityId}' found`, 'error');\n break;\n case 1:\n {\n const { location } = found.result[0];\n const id = found.result[0]._id;\n try {\n const response = await getProviderByLocationAndId(location, id);\n const providerData = response;\n updateProgressIndicator(`Writing file ${fileName}`);\n const fileData = getFileDataTemplate();\n fileData.saml[location][providerData._id] = providerData;\n await exportDependencies(providerData, fileData);\n saveJsonToFile(fileData, fileName);\n stopProgressIndicator(\n `Exported ${entityId.brightCyan} to ${fileName.brightCyan}.`\n );\n } catch (err) {\n stopProgressIndicator(`${err}`);\n printMessage(err, 'error');\n }\n }\n break;\n default:\n printMessage(\n `Multiple providers with entity id '${entityId}' found`,\n 'error'\n );\n }\n } catch (error) {\n stopProgressIndicator(`${error}`);\n printMessage(error.message, 'error');\n }\n}\n\n/**\n * Export provider metadata to file\n * @param {String} entityId Provider entity id\n * @param {String} file Optional filename\n */\nexport async function exportSaml2Metadata(entityId, file = null) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(entityId, 'metadata', 'xml');\n }\n createProgressIndicator(1, `Exporting metadata for: ${entityId}`);\n getProviderMetadata(entityId)\n .then(async (response) => {\n updateProgressIndicator(`Writing file ${fileName}`);\n // printMessage(response.data, 'error');\n const metaData = response;\n saveTextToFile(metaData, fileName);\n stopProgressIndicator(\n `Exported ${entityId.brightCyan} metadata to ${fileName.brightCyan}.`\n );\n })\n .catch((err) => {\n stopProgressIndicator(`${err}`);\n printMessage(err, 'error');\n });\n}\n\n/**\n * Describe an entity provider's configuration\n * @param {String} entityId Provider entity id\n */\nexport async function describeSaml2Provider(entityId) {\n try {\n const found = await findProviders(\n `entityId eq '${entityId}'`,\n 'location,roles'\n );\n switch (found.resultCount) {\n case 0:\n printMessage(`No provider with entity id '${entityId}' found`, 'error');\n break;\n case 1:\n {\n try {\n const { location } = found.result[0];\n const id = found.result[0]._id;\n const roles = found.result[0].roles\n .map((role) => roleMap[role])\n .join(', ');\n const response = await getProviderByLocationAndId(location, id);\n const rawProviderData = response;\n delete rawProviderData._id;\n delete rawProviderData._rev;\n rawProviderData.location = location;\n rawProviderData.roles = roles;\n rawProviderData.metadataUrl = getProviderMetadataUrl(entityId);\n // const fullProviderData = getFileDataTemplate();\n // fullProviderData.saml[location][rawProviderData._id] =\n // rawProviderData;\n // await exportDependencies(rawProviderData, fullProviderData);\n // describe the provider\n const table = createObjectTable(rawProviderData);\n printMessage(table.toString());\n } catch (err) {\n printMessage(err, 'error');\n }\n }\n break;\n default:\n printMessage(\n `Multiple providers with entity id '${entityId}' found`,\n 'error'\n );\n }\n } catch (error) {\n printMessage(error.message, 'error');\n }\n}\n\n/**\n * Export all entity providers to one file\n * @param {String} file Optional filename\n */\nexport async function exportSaml2ProvidersToFile(file = null) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`all${getRealmString()}Providers`, 'saml');\n }\n try {\n const fileData = getFileDataTemplate();\n const found = await getProviders();\n if (found.resultCount > 0) {\n createProgressIndicator(found.resultCount, 'Exporting providers');\n for (const stubData of found.result) {\n updateProgressIndicator(`Exporting provider ${stubData.entityId}`);\n // eslint-disable-next-line no-await-in-loop\n const providerData = await getProviderByLocationAndId(\n stubData.location,\n stubData._id\n );\n // eslint-disable-next-line no-await-in-loop\n await exportDependencies(providerData, fileData);\n fileData.saml[stubData.location][providerData._id] = providerData;\n }\n saveJsonToFile(fileData, fileName);\n stopProgressIndicator(\n `${found.resultCount} providers exported to ${fileName}.`\n );\n } else {\n printMessage('No entity providers found.', 'info');\n }\n } catch (error) {\n printMessage(error.message, 'error');\n printMessage(`exportProvidersToFile: ${error.response?.status}`, 'error');\n }\n}\n\n/**\n * Export all entity providers to individual files\n */\nexport async function exportSaml2ProvidersToFiles() {\n const found = await getProviders();\n if (found.resultCount > 0) {\n createProgressIndicator(found.resultCount, 'Exporting providers');\n for (const stubData of found.result) {\n updateProgressIndicator(`Exporting provider ${stubData.entityId}`);\n const fileName = getTypedFilename(stubData.entityId, 'saml');\n const fileData = getFileDataTemplate();\n // eslint-disable-next-line no-await-in-loop\n const providerData = await getProviderByLocationAndId(\n stubData.location,\n stubData._id\n );\n // eslint-disable-next-line no-await-in-loop\n await exportDependencies(providerData, fileData);\n fileData.saml[stubData.location][providerData._id] = providerData;\n saveJsonToFile(fileData, fileName);\n }\n stopProgressIndicator(`${found.resultCount} providers exported.`);\n } else {\n printMessage('No entity providers found.', 'info');\n }\n}\n\n/**\n * Include dependencies from the import file\n * @param {Object} providerData Object representing a SAML entity provider\n * @param {Object} fileData File data object to read dependencies from\n */\nasync function importDependencies(providerData, fileData) {\n const attrMapperScriptId = _.get(providerData, [\n 'identityProvider',\n 'assertionProcessing',\n 'attributeMapper',\n 'attributeMapperScript',\n ]);\n if (attrMapperScriptId && attrMapperScriptId !== '[Empty]') {\n const scriptData = _.get(fileData, ['script', attrMapperScriptId]);\n scriptData.script = convertTextArrayToBase64(scriptData.script);\n await createOrUpdateScript(attrMapperScriptId, scriptData);\n }\n const idpAdapterScriptId = _.get(providerData, [\n 'identityProvider',\n 'advanced',\n 'idpAdapter',\n 'idpAdapterScript',\n ]);\n if (idpAdapterScriptId && idpAdapterScriptId !== '[Empty]') {\n const scriptData = _.get(fileData, ['script', idpAdapterScriptId]);\n scriptData.script = convertTextArrayToBase64(scriptData.script);\n await createOrUpdateScript(attrMapperScriptId, scriptData);\n }\n}\n\n/**\n * Find provider in import file and return its location\n * @param {String} entityId64 Base64-encoded provider entity id\n * @param {Object} fileData Import file json data\n * @returns {String} 'hosted' or 'remote' if found, undefined otherwise\n */\nfunction getLocation(entityId64, fileData) {\n if (_.get(fileData, ['saml', 'hosted', entityId64])) {\n return 'hosted';\n }\n if (_.get(fileData, ['saml', 'remote', entityId64])) {\n return 'remote';\n }\n return undefined;\n}\n\n/**\n * Import a SAML entity provider by entity id from file\n * @param {String} entityId Provider entity id\n * @param {String} file Import file name\n */\nexport async function importSaml2ProviderFromFile(entityId, file) {\n const entityId64 = encode(entityId, false);\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n createProgressIndicator(1, 'Importing provider...');\n const location = getLocation(entityId64, fileData);\n if (location) {\n const providerData = _.get(fileData, ['saml', location, entityId64]);\n updateProgressIndicator(`Importing ${entityId}`);\n await importDependencies(providerData, fileData);\n let metaData = null;\n if (location === 'remote') {\n metaData = convertTextArrayToBase64Url(\n fileData.saml.metadata[entityId64]\n );\n }\n createProvider(location, providerData, metaData)\n .then(() => {\n stopProgressIndicator(\n `Successfully imported provider ${entityId}.`\n );\n })\n .catch((createProviderErr) => {\n printMessage(`\\nError importing provider ${entityId}`, 'error');\n printMessage(createProviderErr.response, 'error');\n });\n } else {\n stopProgressIndicator(\n `Provider ${entityId.brightCyan} not found in ${file.brightCyan}!`\n );\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import first SAML entity provider from file\n * @param {String} file Import file name\n */\nexport async function importFirstSaml2ProviderFromFile(file) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n createProgressIndicator(1, 'Importing provider...');\n // find providers in hosted and if none exist in remote\n let location = 'hosted';\n let providerIds = _.keys(fileData.saml[location]);\n if (providerIds.length === 0) {\n location = 'remote';\n providerIds = _.keys(fileData.saml[location]);\n if (providerIds.length === 0) {\n location = null;\n }\n }\n if (location) {\n const entityId64 = providerIds[0];\n const entityId = decode(entityId64);\n const providerData = _.get(fileData, ['saml', location, entityId64]);\n updateProgressIndicator(`Importing ${entityId}`);\n await importDependencies(providerData, fileData);\n let metaData = null;\n if (location === 'remote') {\n metaData = convertTextArrayToBase64Url(\n fileData.saml.metadata[entityId64]\n );\n }\n createProvider(location, providerData, metaData)\n .then(() => {\n stopProgressIndicator(\n `Successfully imported provider ${entityId}.`\n );\n })\n .catch((createProviderErr) => {\n stopProgressIndicator(`Error importing provider ${entityId}`);\n printMessage(`\\nError importing provider ${entityId}`, 'error');\n printMessage(createProviderErr.response.data, 'error');\n });\n } else {\n stopProgressIndicator(`No providers found in ${file.brightCyan}!`);\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import all SAML entity providers from file\n * @param {String} file Import file name\n */\nexport async function importSaml2ProvidersFromFile(file) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n // find providers in hosted and in remote and map locations\n const hostedIds = _.keys(fileData.saml.hosted);\n const remoteIds = _.keys(fileData.saml.remote);\n const providerIds = hostedIds.concat(remoteIds);\n createProgressIndicator(providerIds.length, 'Importing providers...');\n for (const entityId64 of providerIds) {\n const location = hostedIds.includes(entityId64) ? 'hosted' : 'remote';\n const entityId = decode(entityId64);\n const providerData = _.get(fileData, ['saml', location, entityId64]);\n // eslint-disable-next-line no-await-in-loop\n await importDependencies(providerData, fileData);\n let metaData = null;\n if (location === 'remote') {\n metaData = convertTextArrayToBase64Url(\n fileData.saml.metadata[entityId64]\n );\n }\n try {\n // eslint-disable-next-line no-await-in-loop\n await createProvider(location, providerData, metaData);\n updateProgressIndicator(`Imported ${entityId}`);\n } catch (createProviderErr) {\n printMessage(`\\nError importing provider ${entityId}`, 'error');\n printMessage(createProviderErr.response.data, 'error');\n }\n }\n stopProgressIndicator(`Providers imported.`);\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import all SAML entity providers from all *.saml.json files in the current directory\n */\nexport async function importSaml2ProvidersFromFiles() {\n const names = fs.readdirSync('.');\n const jsonFiles = names.filter((name) =>\n name.toLowerCase().endsWith('.saml.json')\n );\n createProgressIndicator(jsonFiles.length, 'Importing providers...');\n let total = 0;\n let totalErrors = 0;\n for (const file of jsonFiles) {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n // find providers in hosted and in remote and map locations\n const hostedIds = _.keys(fileData.saml.hosted);\n const remoteIds = _.keys(fileData.saml.remote);\n const providerIds = hostedIds.concat(remoteIds);\n total += providerIds.length;\n let errors = 0;\n for (const entityId64 of providerIds) {\n const location = hostedIds.includes(entityId64) ? 'hosted' : 'remote';\n const entityId = decode(entityId64);\n const providerData = _.get(fileData, ['saml', location, entityId64]);\n importDependencies(providerData, fileData);\n let metaData = null;\n if (location === 'remote') {\n metaData = convertTextArrayToBase64Url(\n fileData.saml.metadata[entityId64]\n );\n }\n try {\n // eslint-disable-next-line no-await-in-loop\n await createProvider(location, providerData, metaData);\n // updateProgressIndicator(`Imported ${entityId}`);\n } catch (createProviderErr) {\n errors += 1;\n printMessage(`\\nError importing provider ${entityId}`, 'error');\n printMessage(createProviderErr.response.data, 'error');\n }\n }\n totalErrors += errors;\n updateProgressIndicator(\n `Imported ${providerIds.length - errors} provider(s) from ${file}`\n );\n } else {\n printMessage(`Validation of ${file} failed!`, 'error');\n }\n }\n stopProgressIndicator(\n `Imported ${total - totalErrors} of ${total} provider(s) from ${\n jsonFiles.length\n } file(s).`\n );\n}\n\n// Contributions using legacy APIs. Need to investigate if those will be deprecated in the future\n\n/**\n * Deletes entity provider\n * @param {string} entityId The entity id for the entity to be deleted\n */\nexport async function deleteSaml2Provider(entityId: string) {\n try {\n await deleteProvider(entityId);\n } catch (error) {\n printMessage(error.message, 'error');\n }\n}\n\n/**\n * Deletes all entity providers.\n */\nexport async function deleteSaml2Providers() {\n const applicationList = (await getRawProviders()).result;\n const deleteApplicationPromises = [];\n applicationList.forEach((item) => {\n printMessage(`Deleting Application ${item._id}`, 'error');\n deleteApplicationPromises.push(deleteSaml2Provider(item._id));\n });\n const deleteApplicationResult = await Promise.all(deleteApplicationPromises);\n if (deleteApplicationResult.length == applicationList.length) {\n printMessage('SAML Entity cleanup done', 'info');\n }\n}\n\n/**\n * Exports a RAW SAML entity, which means the raw xml is included.\n * @param {string} entityId Reference to the entity for export\n * @param {string} file Optional filename for the exported file\n */\nexport async function exportRawSaml2ProviderToFile(entityId, file = null) {\n printMessage(`Exporting SAML application ${entityId}`, 'info');\n let fileName = entityId;\n if (file) {\n fileName = file;\n }\n createProgressIndicator(1, `Exporting raw entity: ${entityId}`);\n await getRawProvider(entityId).then(async (response) => {\n updateProgressIndicator(`Writing file ${fileName}`);\n const rawData = response;\n saveTextToFile(JSON.stringify(rawData, null, 2), fileName);\n stopProgressIndicator(`Exported ${entityId} metadata to ${fileName}.`);\n });\n}\n\n/**\n * Export all entity providers raw to one file\n * @param {String} file Optional filename\n */\nexport async function exportRawSaml2ProvidersToFile(file = null) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(\n `all${getRealmString()}ProvidersRaw`,\n 'samlRaw'\n );\n }\n try {\n const samlApplicationList = (await getRawProviders()).result;\n\n saveToFile('application', samlApplicationList, '_id', fileName);\n printMessage(\n `All RAW saml entity providers exported to: ${fileName}`,\n 'info'\n );\n } catch (error) {\n printMessage(error.message, 'error');\n printMessage(\n `exportProvidersRawToFile: ${error.response?.status}`,\n 'error'\n );\n }\n}\n\n/**\n * Export all entity providers to individual files\n */\nexport async function exportRawSaml2ProvidersToFiles() {\n const samlApplicationList = (await getRawProviders()).result;\n let hasError = false;\n createProgressIndicator(\n samlApplicationList.length,\n 'Exporting RAW providers'\n );\n let exportedAmount = 0;\n for (const item of samlApplicationList) {\n updateProgressIndicator(`Exporting provider ${item.entityId}`);\n try {\n const samlApplicationData = await getRawProvider(item._id);\n const fileName = getTypedFilename(\n `${item._id}${getRealmString()}ProviderRaw`,\n 'samlRaw'\n );\n saveToFile('application', [samlApplicationData], '_id', fileName);\n exportedAmount++;\n } catch (error) {\n hasError = true;\n printMessage(`Unable to export: ${item._id}`, 'error');\n }\n }\n stopProgressIndicator(`${exportedAmount} providers exported.`);\n if (!hasError) {\n printMessage('All entities exported.', 'info');\n } else {\n printMessage('All other entities exported.', 'info');\n }\n}\n\n/**\n * Imports the RAW provider info from a single file.\n * @param file Import file name\n */\nexport async function importRawSaml2ProvidersFromFile(file: string) {\n fs.readFile(file, 'utf8', async function (err, data) {\n if (err) throw err;\n const samlEntityData = JSON.parse(data);\n let amountOfEntities = 0;\n for (const id in samlEntityData.application) {\n if (id.length) {\n amountOfEntities++;\n }\n }\n if (validateImport(samlEntityData.meta)) {\n createProgressIndicator(amountOfEntities, 'Importing providers...');\n for (const id in samlEntityData.application) {\n // remove the \"_rev\" data before PUT\n delete samlEntityData.application[id]._rev;\n await putRawProvider(id, samlEntityData.application[id]).then(\n (result) => {\n if (result === null) {\n printMessage(`Import validation failed for ${id}`, 'error');\n }\n }\n );\n updateProgressIndicator(`Imported ${id}...`);\n }\n stopProgressIndicator(`Import done`);\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Whenever the SAML RAW file were exported using the exportRAW functionality this function\n * is used to read them back in. Only files with the .samlRaw.json extension will be imported.\n * @param {string} directory The directory from which to import the files\n */\nexport async function importRawSaml2ProvidersFromFiles(directory) {\n const files = fs.readdirSync(directory);\n const filesToImport = files.filter(\n (file) => file.indexOf('.samlRaw.json') > -1\n );\n\n if (filesToImport.length > 0) {\n createProgressIndicator(filesToImport.length, 'Importing providers...');\n filesToImport.forEach(async (file) => {\n const filePathAbsolute = path.join(directory, file);\n filesToImport.push(file);\n const samlEntityData = JSON.parse(\n fs.readFileSync(filePathAbsolute, 'utf8')\n );\n if (validateImport(samlEntityData.meta)) {\n for (const id in samlEntityData.application) {\n // remove the \"_rev\" data before PUT\n delete samlEntityData.application[id]._rev;\n await putRawProvider(id, samlEntityData.application[id]).then(\n (result) => {\n if (result === null) {\n printMessage(`Import validation failed for ${id}`, 'error');\n }\n }\n );\n updateProgressIndicator(`Imported ${id}...`);\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n stopProgressIndicator(`Import done`);\n } else {\n printMessage(\n 'Import failed, no files to import. (check extension to be .samlRaw.json)',\n 'warn'\n );\n }\n}\n\n/**\n * Imports a raw SAML export file (containing one entity).\n * @param {string} file The import file\n */\nexport async function importRawSaml2ProviderFromFile(file) {\n printMessage(`Importing SAML Entity ${file}...`, 'info');\n if (file.indexOf('.samlRaw.json') > -1) {\n const samlEntityData = JSON.parse(fs.readFileSync(file, 'utf8'));\n if (validateImport(samlEntityData.meta)) {\n for (const id in samlEntityData.application) {\n // remove the \"_rev\" data before PUT\n delete samlEntityData.application[id]._rev;\n const result = await putRawProvider(id, samlEntityData.application[id]);\n printMessage(`Imported ${id}`, 'info');\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/ops/Saml2Ops.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AAoBzB,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAgB1E,eAAO,MAAM,OAAO;;;;;CAKnB,CAAC;AAGF,wBAAgB,yBAAyB,IAAI,oBAAoB,CAUhE;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAG1E;AAED;;;;;GAKG;AACH,wBAAsB,0BAA0B,CAC9C,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,gBAGnB;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,KAAA,gBAEjD;AAuCD;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,iBAAiB,CAAC,CAa5B;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,qBAAqB,CAAC,CAQhC;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,oBAAoB,CAAC,CAW/B;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAY1E;AA2DD;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,oBAAoB,GAC/B,OAAO,CAAC,IAAI,CAAC,CAkBf;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,UAAU,EAAE,oBAAoB,GAC/B,OAAO,CAAC,sBAAsB,CAAC,CA0DjC;AAID;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,iBAMzD;AAED;;GAEG;AACH,wBAAsB,oBAAoB,kBAWzC;AAED;;;GAGG;AACH,wBAAsB,eAAe,iBAEpC;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,QAAQ,EAAE,MAAM,gBAEpD;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,KAAA,gBAEhE","file":"Saml2Ops.d.ts","sourcesContent":["import _ from 'lodash';\nimport {\n Saml2ProiderLocation,\n Saml2ProviderSkeleton,\n Saml2ProviderStub,\n} from '../api/ApiTypes';\nimport {\n createProvider,\n deleteProvider,\n findProviders,\n getProviderByLocationAndId as _getProviderByLocationAndId,\n getProviderMetadata as _getProviderMetadata,\n getProviderMetadataUrl as _getProviderMetadataUrl,\n getRawProvider as _getRawProvider,\n getProviders,\n getRawProviders as _getRawProviders,\n putRawProvider as _putRawProvider,\n} from '../api/Saml2Api';\nimport { getScript } from '../api/ScriptApi';\nimport {\n decode,\n decodeBase64Url,\n encode,\n encodeBase64Url,\n} from '../api/utils/Base64';\nimport { MultiOpStatusInterface, Saml2ExportInterface } from './OpsTypes';\nimport { createOrUpdateScript } from './ScriptOps';\nimport {\n createProgressIndicator,\n debugMessage,\n printMessage,\n stopProgressIndicator,\n updateProgressIndicator,\n} from './utils/Console';\nimport {\n convertBase64TextToArray,\n convertBase64UrlTextToArray,\n convertTextArrayToBase64,\n convertTextArrayToBase64Url,\n} from './utils/ExportImportUtils';\n\nexport const roleMap = {\n identityProvider: 'IDP',\n serviceProvider: 'SP',\n attributeQueryProvider: 'AttrQuery',\n xacmlPolicyEnforcementPoint: 'XACML PEP',\n};\n\n// use a function vs a template variable to avoid problems in loops\nexport function createSaml2ExportTemplate(): Saml2ExportInterface {\n return {\n meta: {},\n script: {},\n saml: {\n hosted: {},\n remote: {},\n metadata: {},\n },\n } as Saml2ExportInterface;\n}\n\n/**\n * Get SAML2 entity provider stubs\n * @returns {Promise<Saml2ProviderStub[]>} a promise that resolves to an array of saml2 entity stubs\n */\nexport async function getSaml2ProviderStubs(): Promise<Saml2ProviderStub[]> {\n const { result } = await getProviders();\n return result;\n}\n\n/**\n * Geta SAML2 entity provider by location and id\n * @param {string} location Entity provider location (hosted or remote)\n * @param {string} entityId64 Base64-encoded provider entity id\n * @returns {Promise} a promise that resolves to a saml2 entity provider object\n */\nexport async function getProviderByLocationAndId(\n location: string,\n entityId64: string\n) {\n return _getProviderByLocationAndId(location, entityId64);\n}\n\n/**\n * Get a SAML2 entity provider's metadata URL by entity id\n * @param {string} entityId SAML2 entity id\n * @returns {string} the URL to get the metadata from\n */\nexport function getProviderMetadataUrl(entityId: string): string {\n return _getProviderMetadataUrl(entityId);\n}\n\n/**\n * Get a SAML2 entity provider's metadata by entity id\n * @param {String} entityId SAML2 entity id\n * @returns {Promise} a promise that resolves to an object containing a SAML2 metadata\n */\nexport async function getProviderMetadata(entityId) {\n return _getProviderMetadata(entityId);\n}\n\n/**\n * Include dependencies in the export file\n * @param {Object} providerData Object representing a SAML entity provider\n * @param {Object} fileData File data object to add dependencies to\n */\nasync function exportDependencies(providerData, fileData) {\n const attrMapperScriptId = _.get(providerData, [\n 'identityProvider',\n 'assertionProcessing',\n 'attributeMapper',\n 'attributeMapperScript',\n ]);\n if (attrMapperScriptId && attrMapperScriptId !== '[Empty]') {\n const scriptData = await getScript(attrMapperScriptId);\n scriptData.script = convertBase64TextToArray(scriptData.script);\n // eslint-disable-next-line no-param-reassign\n fileData.script[attrMapperScriptId] = scriptData;\n }\n const idpAdapterScriptId = _.get(providerData, [\n 'identityProvider',\n 'advanced',\n 'idpAdapter',\n 'idpAdapterScript',\n ]);\n if (idpAdapterScriptId && idpAdapterScriptId !== '[Empty]') {\n const scriptData = await getScript(idpAdapterScriptId);\n scriptData.script = convertBase64TextToArray(scriptData.script);\n // eslint-disable-next-line no-param-reassign\n fileData.script[idpAdapterScriptId] = scriptData;\n }\n const metaDataResponse = await getProviderMetadata(providerData.entityId);\n // eslint-disable-next-line no-param-reassign\n fileData.saml.metadata[providerData._id] = convertBase64UrlTextToArray(\n encodeBase64Url(metaDataResponse)\n );\n}\n\n/**\n *\n * @param {String} entityId Provider entity id\n * @returns {Promise<Saml2ProviderStub>} Promise resolving to a Saml2ExportInterface object.\n */\nexport async function getSaml2ProviderStub(\n entityId: string\n): Promise<Saml2ProviderStub> {\n debugMessage(`Saml2Ops.getSaml2ProviderStub: start [entityId=${entityId}]`);\n const found = await findProviders(`entityId eq '${entityId}'`);\n switch (found.resultCount) {\n case 0:\n throw new Error(`No provider with entity id '${entityId}' found`);\n case 1: {\n debugMessage(`Saml2Ops.getSaml2ProviderStub: end [entityId=${entityId}]`);\n return found.result[0];\n }\n default:\n throw new Error(`Multiple providers with entity id '${entityId}' found`);\n }\n}\n\n/**\n * Export a single entity provider. The response can be saved to file as is.\n * @param {String} entityId Provider entity id\n * @returns {Promise<Saml2ProviderSkeleton>} Promise resolving to a Saml2ExportInterface object.\n */\nexport async function getSaml2Provider(\n entityId: string\n): Promise<Saml2ProviderSkeleton> {\n debugMessage(`Saml2Ops.getSaml2Provider: start [entityId=${entityId}]`);\n const stub = await getSaml2ProviderStub(entityId);\n const { location } = stub;\n const id = stub._id;\n const providerData = await getProviderByLocationAndId(location, id);\n debugMessage(`Saml2Ops.getSaml2Provider: end [entityId=${entityId}]`);\n return providerData;\n}\n\n/**\n * Export a single entity provider. The response can be saved to file as is.\n * @param {String} entityId Provider entity id\n * @returns {Promise<Saml2ExportInterface>} Promise resolving to a Saml2ExportInterface object.\n */\nexport async function exportSaml2Provider(\n entityId: string\n): Promise<Saml2ExportInterface> {\n debugMessage(`Saml2Ops.exportSaml2Provider: start [entityId=${entityId}]`);\n const exportData = createSaml2ExportTemplate();\n const stub = await getSaml2ProviderStub(entityId);\n const { location } = stub;\n const id = stub._id;\n const providerData = await getProviderByLocationAndId(location, id);\n exportData.saml[stub.location][providerData._id] = providerData;\n await exportDependencies(providerData, exportData);\n debugMessage(`Saml2Ops.exportSaml2Provider: end [entityId=${entityId}]`);\n return exportData;\n}\n\n/**\n * Export all entity providers. The response can be saved to file as is.\n * @returns {Promise<Saml2ExportInterface>} Promise resolving to a Saml2ExportInterface object.\n */\nexport async function exportSaml2Providers(): Promise<Saml2ExportInterface> {\n const fileData = createSaml2ExportTemplate();\n const stubs = await getSaml2ProviderStubs();\n for (const stub of stubs) {\n const providerData = await getProviderByLocationAndId(\n stub.location,\n stub._id\n );\n await exportDependencies(providerData, fileData);\n fileData.saml[stub.location][providerData._id] = providerData;\n }\n return fileData;\n}\n\n/**\n * Include dependencies from the import file\n * @param {Object} providerData Object representing a SAML entity provider\n * @param {Object} fileData File data object to read dependencies from\n */\nasync function importDependencies(providerData, fileData) {\n debugMessage(`Saml2Ops.importDependencies: start`);\n const attrMapperScriptId = _.get(providerData, [\n 'identityProvider',\n 'assertionProcessing',\n 'attributeMapper',\n 'attributeMapperScript',\n ]);\n if (attrMapperScriptId && attrMapperScriptId !== '[Empty]') {\n debugMessage(\n `Saml2Ops.importDependencies: attributeMapperScript=${attrMapperScriptId}`\n );\n const scriptData = _.get(fileData, ['script', attrMapperScriptId]);\n scriptData.script = convertTextArrayToBase64(scriptData.script);\n await createOrUpdateScript(attrMapperScriptId, scriptData);\n }\n const idpAdapterScriptId = _.get(providerData, [\n 'identityProvider',\n 'advanced',\n 'idpAdapter',\n 'idpAdapterScript',\n ]);\n if (idpAdapterScriptId && idpAdapterScriptId !== '[Empty]') {\n debugMessage(\n `Saml2Ops.importDependencies: idpAdapterScript=${idpAdapterScriptId}`\n );\n const scriptData = _.get(fileData, ['script', idpAdapterScriptId]);\n scriptData.script = convertTextArrayToBase64(scriptData.script);\n await createOrUpdateScript(idpAdapterScriptId, scriptData);\n }\n debugMessage(`Saml2Ops.importDependencies: end`);\n}\n\n/**\n * Find provider in import file and return its location\n * @param {String} entityId64 Base64-encoded provider entity id\n * @param {Object} data Import file json data\n * @returns {String} 'hosted' or 'remote' if found, undefined otherwise\n */\nfunction getLocation(\n entityId64: string,\n data: Saml2ExportInterface\n): Saml2ProiderLocation {\n if (data.saml.hosted[entityId64]) {\n return Saml2ProiderLocation.HOSTED;\n }\n if (data.saml.remote[entityId64]) {\n return Saml2ProiderLocation.REMOTE;\n }\n return undefined;\n}\n\n/**\n * Import a SAML entity provider\n * @param {string} entityId Provider entity id\n * @param {Saml2ExportInterface} importData Import data\n */\nexport async function importSaml2Provider(\n entityId: string,\n importData: Saml2ExportInterface\n): Promise<void> {\n debugMessage(`Saml2Ops.importSaml2Provider: start`);\n const entityId64 = encode(entityId, false);\n const location = getLocation(entityId64, importData);\n if (location) {\n const providerData = importData.saml[location][entityId64];\n await importDependencies(providerData, importData);\n let metaData = null;\n if (location === Saml2ProiderLocation.REMOTE) {\n metaData = convertTextArrayToBase64Url(\n importData.saml.metadata[entityId64]\n );\n }\n await createProvider(location, providerData, metaData);\n } else {\n throw new Error(`Provider ${entityId} not found in import data!`);\n }\n debugMessage(`Saml2Ops.importSaml2Provider: end`);\n}\n\n/**\n * Import SAML entity providers\n * @param {Saml2ExportInterface} importData Import data\n */\nexport async function importSaml2Providers(\n importData: Saml2ExportInterface\n): Promise<MultiOpStatusInterface> {\n debugMessage(`Saml2Ops.importSaml2Providers: start`);\n const myStatus: MultiOpStatusInterface = {\n total: 0,\n successes: 0,\n warnings: 0,\n failures: 0,\n };\n try {\n // find providers in hosted and in remote and map locations\n const hostedIds = Object.keys(importData.saml.hosted);\n const remoteIds = Object.keys(importData.saml.remote);\n const providerIds = hostedIds.concat(remoteIds);\n myStatus.total = providerIds.length;\n createProgressIndicator(providerIds.length, 'Importing providers...');\n for (const entityId64 of providerIds) {\n debugMessage(\n `Saml2Ops.importSaml2Providers: entityId=${decodeBase64Url(entityId64)}`\n );\n const location = hostedIds.includes(entityId64)\n ? Saml2ProiderLocation.HOSTED\n : Saml2ProiderLocation.REMOTE;\n const entityId = decode(entityId64);\n const providerData = importData.saml[location][entityId64];\n try {\n await importDependencies(providerData, importData);\n } catch (importDependenciesErr) {\n myStatus.warnings += 1;\n printMessage(\n `\\nWarning importing dependencies for ${entityId}`,\n 'warn'\n );\n printMessage(importDependenciesErr.response.data, 'error');\n }\n let metaData = null;\n if (location === Saml2ProiderLocation.REMOTE) {\n metaData = convertTextArrayToBase64Url(\n importData.saml.metadata[entityId64]\n );\n }\n try {\n await createProvider(location, providerData, metaData);\n myStatus.successes += 1;\n updateProgressIndicator(`Imported ${entityId}`);\n } catch (createProviderErr) {\n myStatus.failures += 1;\n printMessage(`\\nError importing provider ${entityId}`, 'error');\n printMessage(createProviderErr, 'error');\n }\n }\n myStatus.message = `${myStatus.successes}/${myStatus.total} providers imported.`;\n stopProgressIndicator(myStatus.message);\n } catch (error) {\n myStatus.failures += 1;\n printMessage(`\\nError importing providers ${error.message}`, 'error');\n }\n debugMessage(`Saml2Ops.importSaml2Providers: end`);\n return myStatus;\n}\n\n// Contributions using legacy APIs. Need to investigate if those will be deprecated in the future\n\n/**\n * Deletes entity provider\n * @param {string} entityId The entity id for the entity to be deleted\n */\nexport async function deleteSaml2Provider(entityId: string) {\n try {\n await deleteProvider(entityId);\n } catch (error) {\n printMessage(error.message, 'error');\n }\n}\n\n/**\n * Deletes all entity providers.\n */\nexport async function deleteSaml2Providers() {\n const applicationList = (await getRawProviders()).result;\n const deleteApplicationPromises = [];\n applicationList.forEach((item) => {\n printMessage(`Deleting Application ${item._id}`, 'error');\n deleteApplicationPromises.push(deleteSaml2Provider(item._id));\n });\n const deleteApplicationResult = await Promise.all(deleteApplicationPromises);\n if (deleteApplicationResult.length == applicationList.length) {\n printMessage('SAML Entity cleanup done', 'info');\n }\n}\n\n/**\n * Retrieves all entity providers using the legacy federation enpoints.\n * @returns {Promise} a promise that resolves to an object containing an array of providers\n */\nexport async function getRawProviders() {\n return _getRawProviders();\n}\n\n/**\n * Retrieves all entity providers using the legacy federation enpoints.\n * @param {string} entityId The entity provider id\n * @returns {Promise} a promise that resolves to an object containing an array of providers\n */\nexport async function getRawProvider(entityId: string) {\n return _getRawProvider(entityId);\n}\n\n/**\n * Stores a new SAML2 entity provider\n * @param {string} entityId The entity provider id\n * @param {string} entityData The actual data containing the entity provider configuration\n * @returns {Promise} Promise that resolves to a provider object\n */\nexport async function putRawProvider(entityId: string, entityData) {\n return _putRawProvider(entityId, entityData);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/ops/ScriptOps.ts"],"names":[],"mappings":"AAsBA;;GAEG;AACH,wBAAsB,WAAW,CAAC,IAAI,UAAQ,iBA+B7C;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,KAAA,EAAE,IAAI,KAAA,iBAelD;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,KAAA,iBAwB7C;AAED;;GAEG;AACH,wBAAsB,oBAAoB,kBAgBzC;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CAAC,EAAE,KAAA,EAAE,IAAI,KAAA;;;GAwBlD;AAED,wBAAsB,qBAAqB,CAAC,IAAI,KAAA,EAAE,IAAI,KAAA,EAAE,MAAM,UAAQ,iBAiDrE","file":"ScriptOps.d.ts","sourcesContent":["import fs from 'fs';\nimport { v4 as uuidv4 } from 'uuid';\nimport { applyNameCollisionPolicy } from './utils/OpsUtils';\nimport {\n createProgressIndicator,\n createTable,\n printMessage,\n stopProgressIndicator,\n updateProgressIndicator,\n} from './utils/Console';\nimport { getScriptByName, getScripts, putScript } from '../api/ScriptApi';\nimport wordwrap from './utils/Wordwrap';\nimport {\n convertBase64TextToArray,\n convertTextArrayToBase64,\n getTypedFilename,\n saveToFile,\n titleCase,\n validateImport,\n} from './utils/ExportImportUtils';\nimport storage from '../storage/SessionStorage';\n\n/**\n * List scripts\n */\nexport async function listScripts(long = false) {\n try {\n const scripts = (await getScripts()).result;\n scripts.sort((a, b) => a.name.localeCompare(b.name));\n if (long) {\n const table = createTable([\n 'Name',\n 'UUID',\n 'Language',\n 'Context',\n 'Description',\n ]);\n const langMap = { JAVASCRIPT: 'JS', GROOVY: 'Groovy' };\n scripts.forEach((script) => {\n table.push([\n wordwrap(script.name, 25, ' '),\n script._id,\n langMap[script.language],\n wordwrap(titleCase(script.context.split('_').join(' ')), 25),\n wordwrap(script.description, 30),\n ]);\n });\n printMessage(table.toString(), 'data');\n } else {\n scripts.forEach((script) => {\n printMessage(`${script.name}`, 'data');\n });\n }\n } catch (error) {\n printMessage(`Error listing scripts - ${error}`, 'error');\n }\n}\n\n/**\n * Export script to file\n * @param {String} name script name\n * @param {String} file file name\n */\nexport async function exportScriptByName(name, file) {\n let fileName = getTypedFilename(name, 'script');\n if (file) {\n fileName = file;\n }\n const scriptData = (await getScriptByName(name)).result;\n if (scriptData.length > 1) {\n printMessage(`Multiple scripts with name ${name} found...`, 'error');\n }\n scriptData.forEach((element) => {\n const scriptTextArray = convertBase64TextToArray(element.script);\n // eslint-disable-next-line no-param-reassign\n element.script = scriptTextArray;\n });\n saveToFile('script', scriptData, '_id', fileName);\n}\n\n/**\n * Export all scripts to single file\n * @param {String} file file name\n */\nexport async function exportScriptsToFile(file) {\n let fileName = getTypedFilename(\n `all${storage.session.getRealm()}Scripts`,\n 'script'\n );\n if (file) {\n fileName = file;\n }\n const scriptList = (await getScripts()).result;\n const allScriptsData = [];\n createProgressIndicator(scriptList.length, 'Exporting script');\n for (const item of scriptList) {\n updateProgressIndicator(`Reading script ${item.name}`);\n // eslint-disable-next-line no-await-in-loop\n const scriptData = (await getScriptByName(item.name)).result;\n scriptData.forEach((element) => {\n const scriptTextArray = convertBase64TextToArray(element.script);\n // eslint-disable-next-line no-param-reassign\n element.script = scriptTextArray;\n allScriptsData.push(element);\n });\n }\n stopProgressIndicator('Done');\n saveToFile('script', allScriptsData, '_id', fileName);\n}\n\n/**\n * Export all scripts to individual files\n */\nexport async function exportScriptsToFiles() {\n const scriptList = (await getScripts()).result;\n createProgressIndicator(scriptList.length, 'Exporting script');\n for (const item of scriptList) {\n updateProgressIndicator(`Reading script ${item.name}`);\n // eslint-disable-next-line no-await-in-loop\n const scriptData = (await getScriptByName(item.name)).result;\n scriptData.forEach((element) => {\n const scriptTextArray = convertBase64TextToArray(element.script);\n // eslint-disable-next-line no-param-reassign\n element.script = scriptTextArray;\n });\n const fileName = getTypedFilename(item.name, 'script');\n saveToFile('script', scriptData, '_id', fileName);\n }\n stopProgressIndicator('Done');\n}\n\n/**\n * Import script\n * @param {String} id script uuid\n * @param {Object} data script object\n * @returns {Object} a status object\n */\nexport async function createOrUpdateScript(id, data) {\n try {\n await putScript(id, data);\n return { error: false, name: data.name };\n } catch (e) {\n if (e.response.status === 409) {\n printMessage(\n `createOrUpdateScript WARNING: script with name ${data.name} already exists, using renaming policy... <name> => <name - imported (n)>`,\n 'warn'\n );\n const newName = applyNameCollisionPolicy(data.name);\n // console.log(newName);\n printMessage(`Trying to save script as ${newName}`, 'warn');\n // eslint-disable-next-line no-param-reassign\n data.name = newName;\n await createOrUpdateScript(id, data);\n return { error: false, name: data.name };\n }\n printMessage(\n `createOrUpdateScript ERROR: put script error, script ${id} - ${e.message}`,\n 'error'\n );\n return { error: true, name: data.name };\n }\n}\n\nexport async function importScriptsFromFile(name, file, reUuid = false) {\n fs.readFile(file, 'utf8', (err, data) => {\n if (err) throw err;\n const scriptData = JSON.parse(data);\n if (validateImport(scriptData.meta)) {\n createProgressIndicator(Object.keys(scriptData.script).length, '');\n for (const existingId in scriptData.script) {\n if ({}.hasOwnProperty.call(scriptData.script, existingId)) {\n let newId = existingId;\n // console.log(id);\n const encodedScript = convertTextArrayToBase64(\n scriptData.script[existingId].script\n );\n scriptData.script[existingId].script = encodedScript;\n if (reUuid) {\n newId = uuidv4();\n // printMessage(\n // `Re-uuid-ing script ${scriptData.script[existingId].name} ${existingId} => ${newId}...`\n // );\n scriptData.script[existingId]._id = newId;\n }\n if (name) {\n // printMessage(\n // `Renaming script ${scriptData.script[existingId].name} => ${options.script}...`\n // );\n scriptData.script[existingId].name = name;\n }\n updateProgressIndicator(\n `Importing ${scriptData.script[existingId].name}`\n );\n // console.log(scriptData.script[id]);\n createOrUpdateScript(newId, scriptData.script[existingId]).then(\n (result) => {\n if (result == null)\n printMessage(\n `Error importing ${scriptData.script[existingId].name}`,\n 'error'\n );\n }\n );\n if (name) break;\n }\n }\n stopProgressIndicator('Done');\n // printMessage('Done');\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n"]}
1
+ {"version":3,"sources":["../src/ops/ScriptOps.ts"],"names":[],"mappings":"AAsBA;;GAEG;AACH,wBAAsB,WAAW,CAAC,IAAI,UAAQ,iBA+B7C;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,KAAA,EAAE,IAAI,KAAA,iBAelD;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,KAAA,iBAqB7C;AAED;;GAEG;AACH,wBAAsB,oBAAoB,kBAgBzC;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CAAC,EAAE,KAAA,EAAE,IAAI,KAAA;;;GAwBlD;AAED,wBAAsB,qBAAqB,CAAC,IAAI,KAAA,EAAE,IAAI,KAAA,EAAE,MAAM,UAAQ,iBAiDrE","file":"ScriptOps.d.ts","sourcesContent":["import fs from 'fs';\nimport { v4 as uuidv4 } from 'uuid';\nimport { applyNameCollisionPolicy } from './utils/OpsUtils';\nimport {\n createProgressIndicator,\n createTable,\n printMessage,\n stopProgressIndicator,\n updateProgressIndicator,\n} from './utils/Console';\nimport { getScriptByName, getScripts, putScript } from '../api/ScriptApi';\nimport wordwrap from './utils/Wordwrap';\nimport {\n convertBase64TextToArray,\n convertTextArrayToBase64,\n getTypedFilename,\n saveToFile,\n titleCase,\n validateImport,\n} from './utils/ExportImportUtils';\nimport * as state from '../shared/State';\n\n/**\n * List scripts\n */\nexport async function listScripts(long = false) {\n try {\n const scripts = (await getScripts()).result;\n scripts.sort((a, b) => a.name.localeCompare(b.name));\n if (long) {\n const table = createTable([\n 'Name',\n 'UUID',\n 'Language',\n 'Context',\n 'Description',\n ]);\n const langMap = { JAVASCRIPT: 'JS', GROOVY: 'Groovy' };\n scripts.forEach((script) => {\n table.push([\n wordwrap(script.name, 25, ' '),\n script._id,\n langMap[script.language],\n wordwrap(titleCase(script.context.split('_').join(' ')), 25),\n wordwrap(script.description, 30),\n ]);\n });\n printMessage(table.toString(), 'data');\n } else {\n scripts.forEach((script) => {\n printMessage(`${script.name}`, 'data');\n });\n }\n } catch (error) {\n printMessage(`Error listing scripts - ${error}`, 'error');\n }\n}\n\n/**\n * Export script to file\n * @param {String} name script name\n * @param {String} file file name\n */\nexport async function exportScriptByName(name, file) {\n let fileName = getTypedFilename(name, 'script');\n if (file) {\n fileName = file;\n }\n const scriptData = (await getScriptByName(name)).result;\n if (scriptData.length > 1) {\n printMessage(`Multiple scripts with name ${name} found...`, 'error');\n }\n scriptData.forEach((element) => {\n const scriptTextArray = convertBase64TextToArray(element.script);\n // eslint-disable-next-line no-param-reassign\n element.script = scriptTextArray;\n });\n saveToFile('script', scriptData, '_id', fileName);\n}\n\n/**\n * Export all scripts to single file\n * @param {String} file file name\n */\nexport async function exportScriptsToFile(file) {\n let fileName = getTypedFilename(`all${state.getRealm()}Scripts`, 'script');\n if (file) {\n fileName = file;\n }\n const scriptList = (await getScripts()).result;\n const allScriptsData = [];\n createProgressIndicator(scriptList.length, 'Exporting script');\n for (const item of scriptList) {\n updateProgressIndicator(`Reading script ${item.name}`);\n // eslint-disable-next-line no-await-in-loop\n const scriptData = (await getScriptByName(item.name)).result;\n scriptData.forEach((element) => {\n const scriptTextArray = convertBase64TextToArray(element.script);\n // eslint-disable-next-line no-param-reassign\n element.script = scriptTextArray;\n allScriptsData.push(element);\n });\n }\n stopProgressIndicator('Done');\n saveToFile('script', allScriptsData, '_id', fileName);\n}\n\n/**\n * Export all scripts to individual files\n */\nexport async function exportScriptsToFiles() {\n const scriptList = (await getScripts()).result;\n createProgressIndicator(scriptList.length, 'Exporting script');\n for (const item of scriptList) {\n updateProgressIndicator(`Reading script ${item.name}`);\n // eslint-disable-next-line no-await-in-loop\n const scriptData = (await getScriptByName(item.name)).result;\n scriptData.forEach((element) => {\n const scriptTextArray = convertBase64TextToArray(element.script);\n // eslint-disable-next-line no-param-reassign\n element.script = scriptTextArray;\n });\n const fileName = getTypedFilename(item.name, 'script');\n saveToFile('script', scriptData, '_id', fileName);\n }\n stopProgressIndicator('Done');\n}\n\n/**\n * Import script\n * @param {String} id script uuid\n * @param {Object} data script object\n * @returns {Object} a status object\n */\nexport async function createOrUpdateScript(id, data) {\n try {\n await putScript(id, data);\n return { error: false, name: data.name };\n } catch (e) {\n if (e.response?.status === 409) {\n printMessage(\n `createOrUpdateScript WARNING: script with name ${data.name} already exists, using renaming policy... <name> => <name - imported (n)>`,\n 'warn'\n );\n const newName = applyNameCollisionPolicy(data.name);\n // console.log(newName);\n printMessage(`Trying to save script as ${newName}`, 'warn');\n // eslint-disable-next-line no-param-reassign\n data.name = newName;\n await createOrUpdateScript(id, data);\n return { error: false, name: data.name };\n }\n printMessage(\n `createOrUpdateScript ERROR: put script error, script ${id} - ${e.message}`,\n 'error'\n );\n return { error: true, name: data.name };\n }\n}\n\nexport async function importScriptsFromFile(name, file, reUuid = false) {\n fs.readFile(file, 'utf8', (err, data) => {\n if (err) throw err;\n const scriptData = JSON.parse(data);\n if (validateImport(scriptData.meta)) {\n createProgressIndicator(Object.keys(scriptData.script).length, '');\n for (const existingId in scriptData.script) {\n if ({}.hasOwnProperty.call(scriptData.script, existingId)) {\n let newId = existingId;\n // console.log(id);\n const encodedScript = convertTextArrayToBase64(\n scriptData.script[existingId].script\n );\n scriptData.script[existingId].script = encodedScript;\n if (reUuid) {\n newId = uuidv4();\n // printMessage(\n // `Re-uuid-ing script ${scriptData.script[existingId].name} ${existingId} => ${newId}...`\n // );\n scriptData.script[existingId]._id = newId;\n }\n if (name) {\n // printMessage(\n // `Renaming script ${scriptData.script[existingId].name} => ${options.script}...`\n // );\n scriptData.script[existingId].name = name;\n }\n updateProgressIndicator(\n `Importing ${scriptData.script[existingId].name}`\n );\n // console.log(scriptData.script[id]);\n createOrUpdateScript(newId, scriptData.script[existingId]).then(\n (result) => {\n if (result == null)\n printMessage(\n `Error importing ${scriptData.script[existingId].name}`,\n 'error'\n );\n }\n );\n if (name) break;\n }\n }\n stopProgressIndicator('Done');\n // printMessage('Done');\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n"]}
@@ -0,0 +1,20 @@
1
+ import { JwksInterface } from './JoseOps';
2
+ import { ObjectSkeletonInterface } from '../api/ApiTypes';
3
+ export interface SvcacctInterface {
4
+ name: string;
5
+ description: string;
6
+ accountStatus: 'Active' | 'Inactive';
7
+ scopes: string[];
8
+ jwks: string;
9
+ }
10
+ export declare function isServiceAccountsFeatureAvailable(): Promise<boolean>;
11
+ /**
12
+ * Create service account
13
+ * @param {string} name Human-readable name of service account
14
+ * @param {string} description Description of service account
15
+ * @param {'Active' | 'Inactive'} accountStatus Service account status
16
+ * @param {string[]} scopes Scopes.
17
+ * @param {JwksInterface} jwks Java Web Key Set
18
+ * @returns {Promise<ObjectSkeletonInterface>} A promise resolving to a service account object
19
+ */
20
+ export declare function createServiceAccount(name: string, description: string, accountStatus: 'Active' | 'Inactive', scopes: string[], jwks: JwksInterface): Promise<ObjectSkeletonInterface>;
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ops/ServiceAccountOps.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAM1D,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,QAAQ,GAAG,UAAU,CAAC;IACrC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AAGD,wBAAsB,iCAAiC,IAAI,OAAO,CAAC,OAAO,CAAC,CAe1E;AAED;;;;;;;;GAQG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,QAAQ,GAAG,UAAU,EACpC,MAAM,EAAE,MAAM,EAAE,EAChB,IAAI,EAAE,aAAa,GAClB,OAAO,CAAC,uBAAuB,CAAC,CAYlC","file":"ServiceAccountOps.d.ts","sourcesContent":["import { createManagedObject } from '../api/ManagedObjectApi';\nimport { JwksInterface } from './JoseOps';\nimport { ObjectSkeletonInterface } from '../api/ApiTypes';\nimport { debugMessage } from './utils/Console';\nimport { getConfigEntity } from './IdmOps';\n\nconst moType = 'svcacct';\n\nexport interface SvcacctInterface {\n name: string;\n description: string;\n accountStatus: 'Active' | 'Inactive';\n scopes: string[];\n jwks: string;\n}\n\nlet serviceAccountsFeatureAvailable: boolean = undefined;\nexport async function isServiceAccountsFeatureAvailable(): Promise<boolean> {\n debugMessage(`ServiceAccountOps.isServiceAccountsFeatureAvailable: start`);\n // only look up the schema once\n if (typeof serviceAccountsFeatureAvailable !== 'undefined')\n return serviceAccountsFeatureAvailable;\n\n serviceAccountsFeatureAvailable = false;\n const schema = await getConfigEntity('managed');\n for (const object of schema['objects']) {\n if (object['name'] === 'svcacct') serviceAccountsFeatureAvailable = true;\n }\n debugMessage(\n `ServiceAccountOps.isServiceAccountsFeatureAvailable: end, available=${serviceAccountsFeatureAvailable}`\n );\n return serviceAccountsFeatureAvailable;\n}\n\n/**\n * Create service account\n * @param {string} name Human-readable name of service account\n * @param {string} description Description of service account\n * @param {'Active' | 'Inactive'} accountStatus Service account status\n * @param {string[]} scopes Scopes.\n * @param {JwksInterface} jwks Java Web Key Set\n * @returns {Promise<ObjectSkeletonInterface>} A promise resolving to a service account object\n */\nexport async function createServiceAccount(\n name: string,\n description: string,\n accountStatus: 'Active' | 'Inactive',\n scopes: string[],\n jwks: JwksInterface\n): Promise<ObjectSkeletonInterface> {\n const payload: SvcacctInterface = {\n name,\n description,\n accountStatus,\n scopes,\n jwks: JSON.stringify(jwks),\n };\n debugMessage(`SvcacctOps: createSvcacct: payload:`);\n debugMessage(payload);\n const result = await createManagedObject(moType, payload);\n return result;\n}\n"]}
@@ -11,44 +11,52 @@ interface FullService extends AmServiceSkeleton {
11
11
  export declare function createServiceExportTemplate(): ServiceExportInterface;
12
12
  /**
13
13
  * Get list of services
14
+ * @param {boolean} globalConfig true if the list of global services is requested, false otherwise. Default: false.
14
15
  */
15
- export declare function getListOfServices(): Promise<import("../api/ServiceApi").ServiceListItem[]>;
16
+ export declare function getListOfServices(globalConfig?: boolean): Promise<import("../api/ServiceApi").ServiceListItem[]>;
16
17
  /**
17
18
  * Get all services including their descendents.
19
+ * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.
18
20
  * @returns Promise resolving to an array of services with their descendants
19
21
  */
20
- export declare function getFullServices(): Promise<FullService[]>;
22
+ export declare function getFullServices(globalConfig?: boolean): Promise<FullService[]>;
21
23
  /**
22
24
  * Deletes the specified service
23
25
  * @param {string} serviceId The service to delete
26
+ * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.
24
27
  */
25
- export declare function deleteFullService(serviceId: string): Promise<void>;
28
+ export declare function deleteFullService(serviceId: string, globalConfig?: boolean): Promise<void>;
26
29
  /**
27
30
  * Deletes all services
31
+ * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.
28
32
  */
29
- export declare function deleteFullServices(): Promise<void>;
33
+ export declare function deleteFullServices(globalConfig?: boolean): Promise<void>;
30
34
  /**
31
35
  * Export service. The response can be saved to file as is.
32
36
  * @param serviceId service id/name
37
+ * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.
33
38
  * @returns {Promise<ServiceExportInterface>} Promise resolving to a ServiceExportInterface object.
34
39
  */
35
- export declare function exportService(serviceId: string): Promise<ServiceExportInterface>;
40
+ export declare function exportService(serviceId: string, globalConfig?: boolean): Promise<ServiceExportInterface>;
36
41
  /**
37
42
  * Export all services
38
- * @param {string} file Options filename for the file, otherwise all{realm}Services.service.json will be the name
43
+ * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.
39
44
  */
40
- export declare function exportServices(): Promise<ServiceExportInterface>;
45
+ export declare function exportServices(globalConfig?: boolean): Promise<ServiceExportInterface>;
41
46
  /**
42
47
  * Imports a single service using a reference to the service and a file to read the data from. Optionally clean (remove) an existing service first
43
48
  * @param {string} serviceId The service id/name to add
49
+ * @param {ServiceExportInterface} importData The service configuration export data to import
44
50
  * @param {boolean} clean Indicates whether to remove a possible existing service with the same id first.
45
- * @param {string} file Reference to the filename with the data for the service
51
+ * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.
46
52
  * @returns Promise resolving when the service has been imported
47
53
  */
48
- export declare function importService(serviceId: string, importData: ServiceExportInterface, clean: boolean): Promise<AmServiceSkeleton>;
54
+ export declare function importService(serviceId: string, importData: ServiceExportInterface, clean: boolean, globalConfig?: boolean): Promise<AmServiceSkeleton>;
49
55
  /**
50
56
  * Imports multiple services from the same file. Optionally clean (remove) existing services first
57
+ * @param {ServiceExportInterface} importData The service configuration export data to import
51
58
  * @param {boolean} clean Indicates whether to remove possible existing services first
59
+ * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.
52
60
  */
53
- export declare function importServices(importData: ServiceExportInterface, clean: boolean): Promise<AmServiceSkeleton[]>;
61
+ export declare function importServices(importData: ServiceExportInterface, clean: boolean, globalConfig?: boolean): Promise<AmServiceSkeleton[]>;
54
62
  export {};
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/ops/ServiceOps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAQL,qBAAqB,EACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAGpD,UAAU,WAAY,SAAQ,iBAAiB;IAC7C,eAAe,CAAC,EAAE,qBAAqB,EAAE,CAAC;CAC3C;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,IAAI,sBAAsB,CAKpE;AAED;;GAEG;AACH,wBAAsB,iBAAiB,2DAKtC;AAED;;;GAGG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,CAoC9D;AA0GD;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,SAAS,EAAE,MAAM,iBAcxD;AAED;;GAEG;AACH,wBAAsB,kBAAkB,kBA+BvC;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,sBAAsB,CAAC,CAajC;AAED;;;GAGG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,sBAAsB,CAAC,CActE;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,sBAAsB,EAClC,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,iBAAiB,CAAC,CAM5B;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,UAAU,EAAE,sBAAsB,EAClC,KAAK,EAAE,OAAO,gCAmBf","file":"ServiceOps.d.ts","sourcesContent":["import { AmServiceSkeleton } from '../api/ApiTypes';\nimport {\n deleteService,\n deleteServiceNextDescendent,\n getService,\n getListOfServices as _getListOfServices,\n getServiceDescendents,\n putService,\n putServiceNextDescendent,\n ServiceNextDescendent,\n} from '../api/ServiceApi';\nimport { ServiceExportInterface } from './OpsTypes';\nimport { debugMessage, printMessage } from './utils/Console';\n\ninterface FullService extends AmServiceSkeleton {\n nextDescendents?: ServiceNextDescendent[];\n}\n\n/**\n * Create an empty service export template\n * @returns {SingleTreeExportInterface} an empty service export template\n */\nexport function createServiceExportTemplate(): ServiceExportInterface {\n return {\n meta: {},\n service: {},\n } as ServiceExportInterface;\n}\n\n/**\n * Get list of services\n */\nexport async function getListOfServices() {\n debugMessage(`ServiceOps.getListOfServices: start`);\n const services = (await _getListOfServices()).result;\n debugMessage(`ServiceOps.getListOfServices: end`);\n return services;\n}\n\n/**\n * Get all services including their descendents.\n * @returns Promise resolving to an array of services with their descendants\n */\nexport async function getFullServices(): Promise<FullService[]> {\n debugMessage(`ServiceOps.getFullServices: start`);\n const serviceList = (await _getListOfServices()).result;\n\n const fullServiceData = await Promise.all(\n serviceList.map(async (listItem) => {\n try {\n const [service, nextDescendents] = await Promise.all([\n getService(listItem._id),\n getServiceDescendents(listItem._id),\n ]);\n\n return {\n ...service,\n nextDescendents,\n };\n } catch (error) {\n if (\n !(\n error.response?.status === 403 &&\n error.response?.data?.message ===\n 'This operation is not available in ForgeRock Identity Cloud.'\n )\n ) {\n const message = error.response?.data?.message;\n printMessage(\n `Unable to retrieve data for ${listItem._id} with error: ${message}`,\n 'error'\n );\n }\n }\n })\n );\n\n debugMessage(`ServiceOps.getFullServices: end`);\n return fullServiceData.filter((data) => !!data); // make sure to filter out any undefined objects\n}\n\n/**\n * Saves a service using the provide id and data, including descendents\n * @param {string} serviceId the service id / name\n * @param {string} fullServiceData service object including descendants\n * @returns promise resolving to a service object\n */\nasync function putFullService(\n serviceId: string,\n fullServiceData: FullService,\n clean: boolean\n): Promise<AmServiceSkeleton> {\n debugMessage(`ServiceOps.putFullService: start, serviceId=${serviceId}`);\n const nextDescendents = fullServiceData.nextDescendents;\n\n delete fullServiceData.nextDescendents;\n delete fullServiceData._rev;\n delete fullServiceData.enabled;\n\n if (clean) {\n try {\n debugMessage(`ServiceOps.putFullService: clean`);\n await deleteFullService(serviceId);\n } catch (error) {\n if (\n !(\n error.response?.status === 404 &&\n error.response?.data?.message === 'Not Found'\n )\n ) {\n const message = error.response?.data?.message;\n printMessage(\n `Error deleting service '${serviceId}' before import: ${message}`,\n 'error'\n );\n }\n }\n }\n\n // create service first\n const result = await putService(serviceId, fullServiceData);\n\n // return fast if no next descendents supplied\n if (nextDescendents.length === 0) {\n debugMessage(`ServiceOps.putFullService: end (w/o descendents)`);\n return result;\n }\n\n // now create next descendents\n await Promise.all(\n nextDescendents.map(async (descendent) => {\n const type = descendent._type._id;\n const descendentId = descendent._id;\n debugMessage(`ServiceOps.putFullService: descendentId=${descendentId}`);\n let result = undefined;\n try {\n result = await putServiceNextDescendent(\n serviceId,\n type,\n descendentId,\n descendent\n );\n } catch (error) {\n const message = error.response?.data?.message;\n printMessage(\n `Put descendent '${descendentId}' of service '${serviceId}': ${message}`,\n 'error'\n );\n }\n return result;\n })\n );\n debugMessage(`ServiceOps.putFullService: end (w/ descendents)`);\n}\n\n/**\n * Saves multiple services using the serviceEntries which contain both id and data with descendants\n * @param {[string, FullService][]} serviceEntries The services to add\n * @param {boolean} clean Indicates whether to remove possible existing services first\n * @returns {Promise<AmService[]>} promise resolving to an array of service objects\n */\nasync function putFullServices(\n serviceEntries: [string, FullService][],\n clean: boolean\n): Promise<AmServiceSkeleton[]> {\n debugMessage(`ServiceOps.putFullServices: start`);\n const results: AmServiceSkeleton[] = [];\n for (const [id, data] of serviceEntries) {\n try {\n const result = await putFullService(id, data, clean);\n results.push(result);\n printMessage(`Imported: ${id}`, 'info');\n } catch (error) {\n const message = error.response?.data?.message;\n const detail = error.response?.data?.detail;\n printMessage(`Import service '${id}': ${message}`, 'error');\n if (detail) {\n printMessage(`Details: ${JSON.stringify(detail)}`, 'error');\n }\n }\n }\n debugMessage(`ServiceOps.putFullServices: end`);\n return results;\n}\n\n/**\n * Deletes the specified service\n * @param {string} serviceId The service to delete\n */\nexport async function deleteFullService(serviceId: string) {\n const serviceNextDescendentData = await getServiceDescendents(serviceId);\n\n await Promise.all(\n serviceNextDescendentData.map((nextDescendent) =>\n deleteServiceNextDescendent(\n serviceId,\n nextDescendent._type._id,\n nextDescendent._id\n )\n )\n );\n\n await deleteService(serviceId);\n}\n\n/**\n * Deletes all services\n */\nexport async function deleteFullServices() {\n debugMessage(`ServiceOps.deleteFullServices: start`);\n try {\n const serviceList = (await _getListOfServices()).result;\n\n await Promise.all(\n serviceList.map(async (serviceListItem) => {\n try {\n await deleteFullService(serviceListItem._id);\n } catch (error) {\n if (\n !(\n error.response?.status === 403 &&\n error.response?.data?.message ===\n 'This operation is not available in ForgeRock Identity Cloud.'\n )\n ) {\n const message = error.response?.data?.message;\n printMessage(\n `Delete service '${serviceListItem._id}': ${message}`,\n 'error'\n );\n }\n }\n })\n );\n } catch (error) {\n const message = error.response?.data?.message;\n printMessage(`Delete services: ${message}`, 'error');\n }\n debugMessage(`ServiceOps.deleteFullServices: end`);\n}\n\n/**\n * Export service. The response can be saved to file as is.\n * @param serviceId service id/name\n * @returns {Promise<ServiceExportInterface>} Promise resolving to a ServiceExportInterface object.\n */\nexport async function exportService(\n serviceId: string\n): Promise<ServiceExportInterface> {\n debugMessage(`ServiceOps.exportService: start`);\n const exportData = createServiceExportTemplate();\n try {\n const service = await getService(serviceId);\n service.nextDescendents = await getServiceDescendents(serviceId);\n exportData.service[serviceId] = service;\n } catch (error) {\n const message = error.response?.data?.message;\n printMessage(`Export service '${serviceId}': ${message}`, 'error');\n }\n debugMessage(`ServiceOps.exportService: end`);\n return exportData;\n}\n\n/**\n * Export all services\n * @param {string} file Options filename for the file, otherwise all{realm}Services.service.json will be the name\n */\nexport async function exportServices(): Promise<ServiceExportInterface> {\n debugMessage(`ServiceOps.exportServices: start`);\n const exportData = createServiceExportTemplate();\n try {\n const services = await getFullServices();\n for (const service of services) {\n exportData.service[service._type._id] = service;\n }\n } catch (error) {\n const message = error.response?.data?.message;\n printMessage(`Export servics: ${message}`, 'error');\n }\n debugMessage(`ServiceOps.exportServices: end`);\n return exportData;\n}\n\n/**\n * Imports a single service using a reference to the service and a file to read the data from. Optionally clean (remove) an existing service first\n * @param {string} serviceId The service id/name to add\n * @param {boolean} clean Indicates whether to remove a possible existing service with the same id first.\n * @param {string} file Reference to the filename with the data for the service\n * @returns Promise resolving when the service has been imported\n */\nexport async function importService(\n serviceId: string,\n importData: ServiceExportInterface,\n clean: boolean\n): Promise<AmServiceSkeleton> {\n debugMessage(`ServiceOps.importService: start`);\n const serviceData = importData.service[serviceId];\n const result = await putFullService(serviceId, serviceData, clean);\n debugMessage(`ServiceOps.importService: end`);\n return result;\n}\n\n/**\n * Imports multiple services from the same file. Optionally clean (remove) existing services first\n * @param {boolean} clean Indicates whether to remove possible existing services first\n */\nexport async function importServices(\n importData: ServiceExportInterface,\n clean: boolean\n) {\n debugMessage(`ServiceOps.importServices: start`);\n try {\n const result = await putFullServices(\n Object.entries(importData.service),\n clean\n );\n debugMessage(`ServiceOps.importServices: end`);\n return result;\n } catch (error) {\n const message = error.response?.data?.message;\n const detail = error.response?.data?.detail;\n printMessage(`Unable to import services: error: ${message}`, 'error');\n if (detail) {\n printMessage(`Details: ${JSON.stringify(detail)}`, 'error');\n }\n throw error;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/ops/ServiceOps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAQL,qBAAqB,EACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAGpD,UAAU,WAAY,SAAQ,iBAAiB;IAC7C,eAAe,CAAC,EAAE,qBAAqB,EAAE,CAAC;CAC3C;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,IAAI,sBAAsB,CAKpE;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,YAAY,UAAQ,0DAK3D;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,YAAY,UAAQ,GACnB,OAAO,CAAC,WAAW,EAAE,CAAC,CAsCxB;AAmHD;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,SAAS,EAAE,MAAM,EACjB,YAAY,UAAQ,iBAuBrB;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,YAAY,UAAQ,iBAiC5D;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,SAAS,EAAE,MAAM,EACjB,YAAY,UAAQ,GACnB,OAAO,CAAC,sBAAsB,CAAC,CAgBjC;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,YAAY,UAAQ,GACnB,OAAO,CAAC,sBAAsB,CAAC,CAgBjC;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,sBAAsB,EAClC,KAAK,EAAE,OAAO,EACd,YAAY,UAAQ,GACnB,OAAO,CAAC,iBAAiB,CAAC,CAW5B;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,UAAU,EAAE,sBAAsB,EAClC,KAAK,EAAE,OAAO,EACd,YAAY,UAAQ,gCAsBrB","file":"ServiceOps.d.ts","sourcesContent":["import { AmServiceSkeleton } from '../api/ApiTypes';\nimport {\n deleteService,\n deleteServiceNextDescendent,\n getService,\n getListOfServices as _getListOfServices,\n getServiceDescendents,\n putService,\n putServiceNextDescendent,\n ServiceNextDescendent,\n} from '../api/ServiceApi';\nimport { ServiceExportInterface } from './OpsTypes';\nimport { debugMessage, printMessage } from './utils/Console';\n\ninterface FullService extends AmServiceSkeleton {\n nextDescendents?: ServiceNextDescendent[];\n}\n\n/**\n * Create an empty service export template\n * @returns {SingleTreeExportInterface} an empty service export template\n */\nexport function createServiceExportTemplate(): ServiceExportInterface {\n return {\n meta: {},\n service: {},\n } as ServiceExportInterface;\n}\n\n/**\n * Get list of services\n * @param {boolean} globalConfig true if the list of global services is requested, false otherwise. Default: false.\n */\nexport async function getListOfServices(globalConfig = false) {\n debugMessage(`ServiceOps.getListOfServices: start`);\n const services = (await _getListOfServices(globalConfig)).result;\n debugMessage(`ServiceOps.getListOfServices: end`);\n return services;\n}\n\n/**\n * Get all services including their descendents.\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n * @returns Promise resolving to an array of services with their descendants\n */\nexport async function getFullServices(\n globalConfig = false\n): Promise<FullService[]> {\n debugMessage(\n `ServiceOps.getFullServices: start, globalConfig=${globalConfig}`\n );\n const serviceList = (await _getListOfServices(globalConfig)).result;\n\n const fullServiceData = await Promise.all(\n serviceList.map(async (listItem) => {\n try {\n const [service, nextDescendents] = await Promise.all([\n getService(listItem._id, globalConfig),\n getServiceDescendents(listItem._id, globalConfig),\n ]);\n\n return {\n ...service,\n nextDescendents,\n };\n } catch (error) {\n if (\n !(\n error.response?.status === 403 &&\n error.response?.data?.message ===\n 'This operation is not available in ForgeRock Identity Cloud.'\n )\n ) {\n const message = error.response?.data?.message;\n printMessage(\n `Unable to retrieve data for ${listItem._id} with error: ${message}`,\n 'error'\n );\n }\n }\n })\n );\n\n debugMessage(`ServiceOps.getFullServices: end`);\n return fullServiceData.filter((data) => !!data); // make sure to filter out any undefined objects\n}\n\n/**\n * Saves a service using the provide id and data, including descendents\n * @param {string} serviceId the service id / name\n * @param {string} fullServiceData service object including descendants\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n * @returns promise resolving to a service object\n */\nasync function putFullService(\n serviceId: string,\n fullServiceData: FullService,\n clean: boolean,\n globalConfig = false\n): Promise<AmServiceSkeleton> {\n debugMessage(\n `ServiceOps.putFullService: start, serviceId=${serviceId}, globalConfig=${globalConfig}`\n );\n const nextDescendents = fullServiceData.nextDescendents;\n\n delete fullServiceData.nextDescendents;\n delete fullServiceData._rev;\n delete fullServiceData.enabled;\n\n if (clean) {\n try {\n debugMessage(`ServiceOps.putFullService: clean`);\n await deleteFullService(serviceId, globalConfig);\n } catch (error) {\n if (\n !(\n error.response?.status === 404 &&\n error.response?.data?.message === 'Not Found'\n )\n ) {\n const message = error.response?.data?.message;\n printMessage(\n `Error deleting service '${serviceId}' before import: ${message}`,\n 'error'\n );\n }\n }\n }\n\n // create service first\n const result = await putService(serviceId, fullServiceData, globalConfig);\n\n // return fast if no next descendents supplied\n if (nextDescendents.length === 0) {\n debugMessage(`ServiceOps.putFullService: end (w/o descendents)`);\n return result;\n }\n\n // now create next descendents\n await Promise.all(\n nextDescendents.map(async (descendent) => {\n const type = descendent._type._id;\n const descendentId = descendent._id;\n debugMessage(`ServiceOps.putFullService: descendentId=${descendentId}`);\n let result = undefined;\n try {\n result = await putServiceNextDescendent(\n serviceId,\n type,\n descendentId,\n descendent,\n globalConfig\n );\n } catch (error) {\n const message = error.response?.data?.message;\n printMessage(\n `Put descendent '${descendentId}' of service '${serviceId}': ${message}`,\n 'error'\n );\n }\n return result;\n })\n );\n debugMessage(`ServiceOps.putFullService: end (w/ descendents)`);\n}\n\n/**\n * Saves multiple services using the serviceEntries which contain both id and data with descendants\n * @param {[string, FullService][]} serviceEntries The services to add\n * @param {boolean} clean Indicates whether to remove possible existing services first\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n * @returns {Promise<AmService[]>} promise resolving to an array of service objects\n */\nasync function putFullServices(\n serviceEntries: [string, FullService][],\n clean: boolean,\n globalConfig = false\n): Promise<AmServiceSkeleton[]> {\n debugMessage(\n `ServiceOps.putFullServices: start, globalConfig=${globalConfig}`\n );\n const results: AmServiceSkeleton[] = [];\n for (const [id, data] of serviceEntries) {\n try {\n const result = await putFullService(id, data, clean, globalConfig);\n results.push(result);\n printMessage(`Imported: ${id}`, 'info');\n } catch (error) {\n const message = error.response?.data?.message;\n const detail = error.response?.data?.detail;\n printMessage(`Import service '${id}': ${message}`, 'error');\n if (detail) {\n printMessage(`Details: ${JSON.stringify(detail)}`, 'error');\n }\n }\n }\n debugMessage(`ServiceOps.putFullServices: end`);\n return results;\n}\n\n/**\n * Deletes the specified service\n * @param {string} serviceId The service to delete\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n */\nexport async function deleteFullService(\n serviceId: string,\n globalConfig = false\n) {\n debugMessage(\n `ServiceOps.deleteFullService: start, globalConfig=${globalConfig}`\n );\n const serviceNextDescendentData = await getServiceDescendents(\n serviceId,\n globalConfig\n );\n\n await Promise.all(\n serviceNextDescendentData.map((nextDescendent) =>\n deleteServiceNextDescendent(\n serviceId,\n nextDescendent._type._id,\n nextDescendent._id,\n globalConfig\n )\n )\n );\n\n await deleteService(serviceId, globalConfig);\n debugMessage(`ServiceOps.deleteFullService: end`);\n}\n\n/**\n * Deletes all services\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n */\nexport async function deleteFullServices(globalConfig = false) {\n debugMessage(\n `ServiceOps.deleteFullServices: start, globalConfig=${globalConfig}`\n );\n try {\n const serviceList = (await _getListOfServices(globalConfig)).result;\n\n await Promise.all(\n serviceList.map(async (serviceListItem) => {\n try {\n await deleteFullService(serviceListItem._id, globalConfig);\n } catch (error) {\n if (\n !(\n error.response?.status === 403 &&\n error.response?.data?.message ===\n 'This operation is not available in ForgeRock Identity Cloud.'\n )\n ) {\n const message = error.response?.data?.message;\n printMessage(\n `Delete service '${serviceListItem._id}': ${message}`,\n 'error'\n );\n }\n }\n })\n );\n } catch (error) {\n const message = error.response?.data?.message;\n printMessage(`Delete services: ${message}`, 'error');\n }\n debugMessage(`ServiceOps.deleteFullServices: end`);\n}\n\n/**\n * Export service. The response can be saved to file as is.\n * @param serviceId service id/name\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n * @returns {Promise<ServiceExportInterface>} Promise resolving to a ServiceExportInterface object.\n */\nexport async function exportService(\n serviceId: string,\n globalConfig = false\n): Promise<ServiceExportInterface> {\n debugMessage(`ServiceOps.exportService: start, globalConfig=${globalConfig}`);\n const exportData = createServiceExportTemplate();\n try {\n const service = await getService(serviceId, globalConfig);\n service.nextDescendents = await getServiceDescendents(\n serviceId,\n globalConfig\n );\n exportData.service[serviceId] = service;\n } catch (error) {\n const message = error.response?.data?.message;\n printMessage(`Export service '${serviceId}': ${message}`, 'error');\n }\n debugMessage(`ServiceOps.exportService: end`);\n return exportData;\n}\n\n/**\n * Export all services\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n */\nexport async function exportServices(\n globalConfig = false\n): Promise<ServiceExportInterface> {\n debugMessage(\n `ServiceOps.exportServices: start, globalConfig=${globalConfig}`\n );\n const exportData = createServiceExportTemplate();\n try {\n const services = await getFullServices(globalConfig);\n for (const service of services) {\n exportData.service[service._type._id] = service;\n }\n } catch (error) {\n const message = error.response?.data?.message;\n printMessage(`Export servics: ${message}`, 'error');\n }\n debugMessage(`ServiceOps.exportServices: end`);\n return exportData;\n}\n\n/**\n * Imports a single service using a reference to the service and a file to read the data from. Optionally clean (remove) an existing service first\n * @param {string} serviceId The service id/name to add\n * @param {ServiceExportInterface} importData The service configuration export data to import\n * @param {boolean} clean Indicates whether to remove a possible existing service with the same id first.\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n * @returns Promise resolving when the service has been imported\n */\nexport async function importService(\n serviceId: string,\n importData: ServiceExportInterface,\n clean: boolean,\n globalConfig = false\n): Promise<AmServiceSkeleton> {\n debugMessage(`ServiceOps.importService: start, globalConfig=${globalConfig}`);\n const serviceData = importData.service[serviceId];\n const result = await putFullService(\n serviceId,\n serviceData,\n clean,\n globalConfig\n );\n debugMessage(`ServiceOps.importService: end`);\n return result;\n}\n\n/**\n * Imports multiple services from the same file. Optionally clean (remove) existing services first\n * @param {ServiceExportInterface} importData The service configuration export data to import\n * @param {boolean} clean Indicates whether to remove possible existing services first\n * @param {boolean} globalConfig true if the global service is the target of the operation, false otherwise. Default: false.\n */\nexport async function importServices(\n importData: ServiceExportInterface,\n clean: boolean,\n globalConfig = false\n) {\n debugMessage(\n `ServiceOps.importServices: start, globalConfig=${globalConfig}`\n );\n try {\n const result = await putFullServices(\n Object.entries(importData.service),\n clean,\n globalConfig\n );\n debugMessage(`ServiceOps.importServices: end`);\n return result;\n } catch (error) {\n const message = error.response?.data?.message;\n const detail = error.response?.data?.detail;\n printMessage(`Unable to import services: error: ${message}`, 'error');\n if (detail) {\n printMessage(`Details: ${JSON.stringify(detail)}`, 'error');\n }\n throw error;\n }\n}\n"]}