@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,55 +1,58 @@
1
1
  import fs from 'fs';
2
2
  import os from 'os';
3
3
  import path from 'path';
4
- import storage from '../storage/SessionStorage';
4
+ import * as state from '../shared/State';
5
5
  import DataProtection from './utils/DataProtection';
6
- import { createObjectTable, createTable, printMessage } from './utils/Console';
6
+ import { createObjectTable, createTable, debugMessage, printMessage, verboseMessage } from './utils/Console';
7
7
  import { FRODO_CONNECTION_PROFILES_PATH_KEY } from '../storage/StaticStorage';
8
- const dataProtection = new DataProtection();
8
+ import { createJwkRsa, createJwks, getJwkRsaPublic } from './JoseOps';
9
+ import { createServiceAccount } from './ServiceAccountOps';
10
+ import { saveJsonToFile } from './utils/ExportImportUtils';
11
+ import { isValidUrl } from './utils/OpsUtils';
12
+ const crypto = new DataProtection();
9
13
  const fileOptions = {
10
14
  indentation: 4
11
15
  };
16
+ const legacyProfileFilename = '.frodorc';
17
+ const newProfileFilename = 'Connections.json';
18
+
12
19
  /**
13
20
  * Get connection profiles file name
14
21
  * @returns {String} connection profiles file name
15
22
  */
16
-
17
23
  export function getConnectionProfilesPath() {
18
- return storage.session.getConnectionProfilesPath() || process.env[FRODO_CONNECTION_PROFILES_PATH_KEY] || `${os.homedir()}/.frodo/.frodorc`;
24
+ return state.getConnectionProfilesPath() || process.env[FRODO_CONNECTION_PROFILES_PATH_KEY] || `${os.homedir()}/.frodo/${newProfileFilename}`;
19
25
  }
26
+
20
27
  /**
21
- * Find connection profile
22
- * @param {Object} connectionProfiles connection profile object
23
- * @param {String} host tenant host url or unique substring
24
- * @returns {Object} connection profile object or null
28
+ * Find connection profiles
29
+ * @param {ConnectionsFileInterface} connectionProfiles connection profile object
30
+ * @param {string} host host url or unique substring
31
+ * @returns {SecureConnectionProfileInterface[]} Array of connection profiles
25
32
  */
26
-
27
- function findConnectionProfile(connectionProfiles, host) {
33
+ function findConnectionProfiles(connectionProfiles, host) {
28
34
  const profiles = [];
29
-
30
35
  for (const tenant in connectionProfiles) {
31
36
  if (tenant.includes(host)) {
32
- const foundProfile = connectionProfiles[tenant];
37
+ const foundProfile = {
38
+ ...connectionProfiles[tenant]
39
+ };
33
40
  foundProfile.tenant = tenant;
34
41
  profiles.push(foundProfile);
35
42
  }
36
43
  }
37
-
38
44
  return profiles;
39
45
  }
46
+
40
47
  /**
41
48
  * List connection profiles
42
49
  * @param {boolean} long Long list format with details
43
50
  */
44
-
45
-
46
51
  export function listConnectionProfiles(long = false) {
47
52
  const filename = getConnectionProfilesPath();
48
-
49
53
  try {
50
54
  const data = fs.readFileSync(filename, 'utf8');
51
55
  const connectionsData = JSON.parse(data);
52
-
53
56
  if (long) {
54
57
  const table = createTable(['Host', 'Username', 'Log API Key']);
55
58
  Object.keys(connectionsData).forEach(c => {
@@ -61,65 +64,86 @@ export function listConnectionProfiles(long = false) {
61
64
  printMessage(`${c}`, 'data');
62
65
  });
63
66
  }
64
-
65
67
  printMessage('Any unique substring of a saved host can be used as the value for host parameter in all commands', 'info');
66
68
  } catch (e) {
67
69
  printMessage(`No connections found in ${filename} (${e.message})`, 'error');
68
70
  }
69
71
  }
72
+
70
73
  /**
71
- * Initialize connection profiles
74
+ * Migrate from .frodorc to Connections.json
72
75
  */
76
+ function migrateFromLegacyProfile() {
77
+ const legacyPath = `${os.homedir()}/.frodo/${legacyProfileFilename}`;
78
+ if (fs.existsSync(legacyPath)) {
79
+ fs.copyFileSync(legacyPath, `${os.homedir()}/.frodo/${newProfileFilename}`);
80
+ // for now, just add a "deprecated" suffix. May delete the old file
81
+ // in a future release
82
+ fs.renameSync(legacyPath, `${legacyPath}.deprecated`);
83
+ }
84
+ }
73
85
 
74
- export function initConnectionProfiles() {
86
+ /**
87
+ * Initialize connection profiles
88
+ *
89
+ * This method is called from app.ts and runs before any of the message handlers are registered.
90
+ * Therefore none of the Console message functions will produce any output.
91
+ */
92
+ export async function initConnectionProfiles() {
75
93
  // create connections.json file if it doesn't exist
76
94
  const filename = getConnectionProfilesPath();
77
95
  const folderName = path.dirname(filename);
78
-
79
96
  if (!fs.existsSync(folderName)) {
80
97
  fs.mkdirSync(folderName, {
81
98
  recursive: true
82
99
  });
83
-
84
100
  if (!fs.existsSync(filename)) {
85
101
  fs.writeFileSync(filename, JSON.stringify({}, null, fileOptions.indentation));
86
102
  }
87
- } // encrypt the password from clear text to aes-256-GCM
103
+ }
104
+ // encrypt the password and logApiSecret from clear text to aes-256-GCM
88
105
  else {
106
+ migrateFromLegacyProfile();
89
107
  const data = fs.readFileSync(filename, 'utf8');
90
108
  const connectionsData = JSON.parse(data);
91
109
  let convert = false;
92
- Object.keys(connectionsData).forEach(async conn => {
93
- if (connectionsData[conn].password) {
110
+ for (const conn of Object.keys(connectionsData)) {
111
+ if (connectionsData[conn]['password']) {
94
112
  convert = true;
95
- connectionsData[conn].encodedPassword = await dataProtection.encrypt(connectionsData[conn].password); // Buffer.from(connectionsData[conn].password).toString('base64');
96
-
97
- delete connectionsData[conn].password;
113
+ connectionsData[conn].encodedPassword = await crypto.encrypt(connectionsData[conn]['password']);
114
+ delete connectionsData[conn]['password'];
98
115
  }
99
- });
100
-
116
+ if (connectionsData[conn]['logApiSecret']) {
117
+ convert = true;
118
+ connectionsData[conn].encodedLogApiSecret = await crypto.encrypt(connectionsData[conn]['logApiSecret']);
119
+ delete connectionsData[conn]['logApiSecret'];
120
+ }
121
+ if (connectionsData[conn]['svcacctJwk']) {
122
+ convert = true;
123
+ connectionsData[conn].encodedSvcacctJwk = await crypto.encrypt(connectionsData[conn]['svcacctJwk']);
124
+ delete connectionsData[conn]['svcacctJwk'];
125
+ }
126
+ }
101
127
  if (convert) {
102
128
  fs.writeFileSync(filename, JSON.stringify(connectionsData, null, fileOptions.indentation));
103
129
  }
104
130
  }
105
131
  }
132
+
106
133
  /**
107
134
  * Get connection profile by host
108
135
  * @param {String} host host tenant host url or unique substring
109
136
  * @returns {Object} connection profile or null
110
137
  */
111
-
112
138
  export async function getConnectionProfileByHost(host) {
113
139
  try {
114
140
  const filename = getConnectionProfilesPath();
115
141
  const connectionsData = JSON.parse(fs.readFileSync(filename, 'utf8'));
116
- const profiles = findConnectionProfile(connectionsData, host);
117
-
142
+ const profiles = findConnectionProfiles(connectionsData, host);
118
143
  if (profiles.length == 0) {
119
144
  printMessage(`Profile for ${host} not found. Please specify credentials on command line`, 'error');
120
145
  return null;
121
146
  }
122
-
123
147
  if (profiles.length > 1) {
124
148
  printMessage(`Multiple matching profiles found.`, 'error');
125
149
  profiles.forEach(p => {
@@ -128,76 +152,117 @@ export async function getConnectionProfileByHost(host) {
128
152
  printMessage(`Please specify a unique sub-string`, 'error');
129
153
  return null;
130
154
  }
131
-
132
155
  return {
133
156
  tenant: profiles[0].tenant,
134
157
  username: profiles[0].username ? profiles[0].username : null,
135
- password: profiles[0].encodedPassword ? await dataProtection.decrypt(profiles[0].encodedPassword) : null,
136
- key: profiles[0].logApiKey ? profiles[0].logApiKey : null,
137
- secret: profiles[0].logApiSecret ? profiles[0].logApiSecret : null,
158
+ password: profiles[0].encodedPassword ? await crypto.decrypt(profiles[0].encodedPassword) : null,
159
+ logApiKey: profiles[0].logApiKey ? profiles[0].logApiKey : null,
160
+ logApiSecret: profiles[0].encodedLogApiSecret ? await crypto.decrypt(profiles[0].encodedLogApiSecret) : null,
138
161
  authenticationService: profiles[0].authenticationService ? profiles[0].authenticationService : null,
139
- authenticationHeaderOverrides: profiles[0].authenticationHeaderOverrides ? profiles[0].authenticationHeaderOverrides : {}
162
+ authenticationHeaderOverrides: profiles[0].authenticationHeaderOverrides ? profiles[0].authenticationHeaderOverrides : {},
163
+ svcacctId: profiles[0].svcacctId ? profiles[0].svcacctId : null,
164
+ svcacctJwk: profiles[0].encodedSvcacctJwk ? await crypto.decrypt(profiles[0].encodedSvcacctJwk) : null
140
165
  };
141
166
  } catch (e) {
142
167
  printMessage(`Can not read saved connection info, please specify credentials on command line: ${e}`, 'error');
143
168
  return null;
144
169
  }
145
170
  }
171
+
146
172
  /**
147
173
  * Get connection profile
148
174
  * @returns {Object} connection profile or null
149
175
  */
150
-
151
176
  export async function getConnectionProfile() {
152
- return getConnectionProfileByHost(storage.session.getTenant());
177
+ return getConnectionProfileByHost(state.getHost());
153
178
  }
179
+
154
180
  /**
155
181
  * Save connection profile
182
+ * @param {string} host host url for new profiles or unique substring for existing profiles
183
+ * @returns {Promise<boolean>} true if the operation succeeded, false otherwise
156
184
  */
157
-
158
- export async function saveConnectionProfile() {
185
+ export async function saveConnectionProfile(host) {
159
186
  const filename = getConnectionProfilesPath();
160
- printMessage(`Saving creds in ${filename}...`);
161
- let connectionsData = {};
162
- let existingData = {};
163
-
187
+ verboseMessage(`Saving connection profile in ${filename}`);
188
+ let profiles = {};
189
+ let profile = {
190
+ tenant: ''
191
+ };
164
192
  try {
165
193
  fs.statSync(filename);
166
194
  const data = fs.readFileSync(filename, 'utf8');
167
- connectionsData = JSON.parse(data);
195
+ profiles = JSON.parse(data);
168
196
 
169
- if (connectionsData[storage.session.getTenant()]) {
170
- existingData = connectionsData[storage.session.getTenant()];
171
- printMessage(`Updating connection profile ${storage.session.getTenant()}`);
172
- } else printMessage(`Adding connection profile ${storage.session.getTenant()}`);
173
- } catch (e) {
174
- printMessage(`Creating connection profiles file ${filename} with ${storage.session.getTenant()}`);
175
- }
197
+ // find tenant
198
+ const found = findConnectionProfiles(profiles, host);
176
199
 
177
- if (storage.session.getUsername()) existingData['username'] = storage.session.getUsername();
178
- if (storage.session.getPassword()) existingData['encodedPassword'] = await dataProtection.encrypt(storage.session.getPassword());
179
- if (storage.session.getLogApiKey()) existingData['logApiKey'] = storage.session.getLogApiKey();
180
- if (storage.session.getLogApiSecret()) existingData['logApiSecret'] = storage.session.getLogApiSecret(); // advanced settings
200
+ // replace tenant in session with real tenant url if necessary
201
+ if (found.length === 1) {
202
+ profile = found[0];
203
+ state.setHost(profile.tenant);
204
+ verboseMessage(`Existing profile: ${profile.tenant}`);
205
+ }
181
206
 
182
- if (storage.session.getAuthenticationService()) {
183
- existingData['authenticationService'] = storage.session.getAuthenticationService();
184
- printMessage('Advanced setting: Authentication Service: ' + storage.session.getAuthenticationService(), 'info');
207
+ // connection profile not found, validate host is a real URL
208
+ if (found.length === 0) {
209
+ if (isValidUrl(host)) {
210
+ state.setHost(host);
211
+ verboseMessage(`New profile: ${host}`);
212
+ } else {
213
+ printMessage(`No existing profile found matching '${host}'. Provide a valid URL as the host argument to create a new profile.`, 'error');
214
+ return false;
215
+ }
216
+ }
217
+ } catch (error) {
218
+ verboseMessage(`New profiles file ${filename} with new profile ${host}`);
185
219
  }
186
220
 
187
- if (storage.session.getAuthenticationHeaderOverrides()) {
188
- existingData['authenticationHeaderOverrides'] = storage.session.getAuthenticationHeaderOverrides();
221
+ // user account
222
+ if (state.getUsername()) profile.username = state.getUsername();
223
+ if (state.getPassword()) profile.encodedPassword = await crypto.encrypt(state.getPassword());
224
+
225
+ // log API
226
+ if (state.getLogApiKey()) profile.logApiKey = state.getLogApiKey();
227
+ if (state.getLogApiSecret()) profile.encodedLogApiSecret = await crypto.encrypt(state.getLogApiSecret());
228
+
229
+ // service account
230
+ if (state.getServiceAccountId()) profile.svcacctId = state.getServiceAccountId();
231
+ if (state.getServiceAccountJwk()) profile.encodedSvcacctJwk = await crypto.encrypt(state.getServiceAccountJwk());
232
+
233
+ // advanced settings
234
+ if (state.getAuthenticationService()) {
235
+ profile.authenticationService = state.getAuthenticationService();
236
+ printMessage('Advanced setting: Authentication Service: ' + state.getAuthenticationService(), 'info');
237
+ }
238
+ if (state.getAuthenticationHeaderOverrides() && Object.entries(state.getAuthenticationHeaderOverrides()).length) {
239
+ profile.authenticationHeaderOverrides = state.getAuthenticationHeaderOverrides();
189
240
  printMessage('Advanced setting: Authentication Header Overrides: ', 'info');
190
- printMessage(storage.session.getAuthenticationHeaderOverrides(), 'info');
241
+ printMessage(state.getAuthenticationHeaderOverrides(), 'info');
191
242
  }
192
243
 
193
- connectionsData[storage.session.getTenant()] = existingData;
194
- fs.writeFileSync(filename, JSON.stringify(connectionsData, null, 2));
244
+ // remove the helper key 'tenant'
245
+ delete profile.tenant;
246
+
247
+ // update profiles
248
+ profiles[state.getHost()] = profile;
249
+
250
+ // sort profiles
251
+ const orderedProfiles = Object.keys(profiles).sort().reduce((obj, key) => {
252
+ obj[key] = profiles[key];
253
+ return obj;
254
+ }, {});
255
+
256
+ // save profiles
257
+ saveJsonToFile(orderedProfiles, filename, false);
258
+ verboseMessage(`Saved connection profile ${state.getHost()} in ${filename}`);
259
+ return true;
195
260
  }
261
+
196
262
  /**
197
263
  * Delete connection profile
198
264
  * @param {String} host host tenant host url or unique substring
199
265
  */
200
-
201
266
  export function deleteConnectionProfile(host) {
202
267
  const filename = getConnectionProfilesPath();
203
268
  let connectionsData = {};
@@ -205,12 +270,11 @@ export function deleteConnectionProfile(host) {
205
270
  if (err == null) {
206
271
  const data = fs.readFileSync(filename, 'utf8');
207
272
  connectionsData = JSON.parse(data);
208
- const profiles = findConnectionProfile(connectionsData, host);
209
-
273
+ const profiles = findConnectionProfiles(connectionsData, host);
210
274
  if (profiles.length == 1) {
211
- printMessage(`Deleting connection profile ${profiles[0].tenant}`);
212
275
  delete connectionsData[profiles[0].tenant];
213
276
  fs.writeFileSync(filename, JSON.stringify(connectionsData, null, 2));
277
+ printMessage(`Deleted connection profile ${profiles[0].tenant}`);
214
278
  } else {
215
279
  if (profiles.length > 1) {
216
280
  printMessage(`Multiple matching profiles found.`, 'error');
@@ -230,33 +294,79 @@ export function deleteConnectionProfile(host) {
230
294
  }
231
295
  });
232
296
  }
297
+
298
+ /**
299
+ * Describe connection profile
300
+ * @param {string} host Host URL or unique substring
301
+ * @param {boolean} showSecrets Whether secrets should be shown in clear text or not
302
+ */
233
303
  export async function describeConnectionProfile(host, showSecrets) {
234
304
  const profile = await getConnectionProfileByHost(host);
235
-
236
305
  if (profile) {
306
+ const present = '[present]';
307
+ const jwk = profile.svcacctJwk;
237
308
  if (!showSecrets) {
309
+ if (profile.password) profile.password = present;
310
+ if (profile.logApiSecret) profile.logApiSecret = present;
311
+ if (profile.svcacctJwk) profile['svcacctJwk'] = present;
312
+ }
313
+ if (!profile.username) {
314
+ delete profile.username;
238
315
  delete profile.password;
239
- delete profile.secret;
240
316
  }
241
-
242
- if (!profile.key) {
243
- delete profile.key;
244
- delete profile.secret;
317
+ if (!profile.logApiKey) {
318
+ delete profile.logApiKey;
319
+ delete profile.logApiSecret;
320
+ }
321
+ if (!profile.svcacctId) {
322
+ delete profile.svcacctId;
323
+ delete profile.svcacctJwk;
324
+ }
325
+ if (showSecrets && jwk) {
326
+ profile['svcacctJwk'] = 'see below';
327
+ }
328
+ if (!profile.authenticationService) {
329
+ delete profile.authenticationService;
245
330
  }
246
-
247
331
  const keyMap = {
248
332
  tenant: 'Host',
249
333
  username: 'Username',
250
334
  password: 'Password',
251
- key: 'Log API Key',
252
- secret: 'Log API Secret',
335
+ logApiKey: 'Log API Key',
336
+ logApiSecret: 'Log API Secret',
253
337
  authenticationService: 'Authentication Service',
254
- authenticationHeaderOverrides: 'Authentication Header Overrides'
338
+ authenticationHeaderOverrides: 'Authentication Header Overrides',
339
+ svcacctId: 'Service Account Id',
340
+ svcacctJwk: 'Service Account JWK'
255
341
  };
256
342
  const table = createObjectTable(profile, keyMap);
257
343
  printMessage(table.toString(), 'data');
344
+ if (showSecrets && jwk) {
345
+ printMessage(jwk, 'data');
346
+ }
258
347
  } else {
259
348
  printMessage(`No connection profile ${host} found`);
260
349
  }
261
350
  }
351
+
352
+ /**
353
+ * Create a new service account using auto-generated parameters
354
+ * @returns {Promise<ObjectSkeletonInterface>} A promise resolving to a service account object
355
+ */
356
+ export async function addNewServiceAccount() {
357
+ debugMessage(`ConnectionProfileOps.addNewServiceAccount: start`);
358
+ const name = `Frodo-SA-${new Date().getTime()}`;
359
+ debugMessage(`ConnectionProfileOps.addNewServiceAccount: name=${name}...`);
360
+ const description = `${state.getUsername()}'s Frodo Service Account`;
361
+ const scope = ['fr:am:*', 'fr:idm:*', 'fr:idc:esv:*'];
362
+ const jwkPrivate = await createJwkRsa();
363
+ const jwkPublic = await getJwkRsaPublic(jwkPrivate);
364
+ const jwks = createJwks(jwkPublic);
365
+ const sa = await createServiceAccount(name, description, 'Active', scope, jwks);
366
+ debugMessage(`ConnectionProfileOps.addNewServiceAccount: id=${sa._id}`);
367
+ state.setServiceAccountId(sa._id);
368
+ state.setServiceAccountJwk(jwkPrivate);
369
+ debugMessage(`ConnectionProfileOps.addNewServiceAccount: end`);
370
+ return sa;
371
+ }
262
372
  //# sourceMappingURL=ConnectionProfileOps.js.map
@@ -8,11 +8,11 @@ describe('ConnectionProfileOps', () => {
8
8
  const user = 'frodo.baggins@shire.me';
9
9
  const password = 'G@nd@lfTheW153';
10
10
  const connectionProfilePath = `${homedir()}/connections1.json`;
11
- state.default.session.setTenant(host);
12
- state.default.session.setUsername(user);
13
- state.default.session.setPassword(password);
14
- state.default.session.setConnectionProfilesPath(connectionProfilePath);
15
- await ConnectionProfile.saveConnectionProfile();
11
+ state.setHost(host);
12
+ state.setUsername(user);
13
+ state.setPassword(password);
14
+ state.setConnectionProfilesPath(connectionProfilePath);
15
+ await ConnectionProfile.saveConnectionProfile(host);
16
16
  expect(fs.existsSync(connectionProfilePath)).toBeTruthy();
17
17
  const connections = JSON.parse(fs.readFileSync(connectionProfilePath, 'utf8'));
18
18
  expect(connections).toBeTruthy();
@@ -24,14 +24,14 @@ describe('ConnectionProfileOps', () => {
24
24
  const host = 'https://openam-tenant-name.forgeblocks.com/am';
25
25
  const user = 'frodo.baggins@shire.me';
26
26
  const password = 'G@nd@lfTheW153';
27
- const connectionProfilePath = `${homedir()}/connections2.json`; // set the hard-coded master key
28
-
27
+ const connectionProfilePath = `${homedir()}/connections2.json`;
28
+ // set the hard-coded master key
29
29
  process.env[FRODO_CONNECTION_PROFILES_PATH_KEY] = connectionProfilePath;
30
- state.default.session.setTenant(host);
31
- state.default.session.setUsername(user);
32
- state.default.session.setPassword(password);
33
- state.default.session.setConnectionProfilesPath(null);
34
- await ConnectionProfile.saveConnectionProfile();
30
+ state.setHost(host);
31
+ state.setUsername(user);
32
+ state.setPassword(password);
33
+ state.setConnectionProfilesPath('');
34
+ await ConnectionProfile.saveConnectionProfile(host);
35
35
  expect(ConnectionProfile.getConnectionProfilesPath()).toEqual(connectionProfilePath);
36
36
  expect(fs.existsSync(connectionProfilePath)).toBeTruthy();
37
37
  const connections = JSON.parse(fs.readFileSync(connectionProfilePath, 'utf8'));
@@ -45,14 +45,14 @@ describe('ConnectionProfileOps', () => {
45
45
  const user = 'frodo.baggins@shire.me';
46
46
  const password = 'G@nd@lfTheW153';
47
47
  const connectionProfilePath = `${homedir()}/connections3.json`;
48
- const masterKey = 'bxnQlhcU5VfyDs+BBPhRhK09yHaNtdIIk85HUMKBnqg='; // set the hard-coded master key
49
-
48
+ const masterKey = 'bxnQlhcU5VfyDs+BBPhRhK09yHaNtdIIk85HUMKBnqg=';
49
+ // set the hard-coded master key
50
50
  process.env[FRODO_MASTER_KEY_KEY] = masterKey;
51
- state.default.session.setTenant(host);
52
- state.default.session.setUsername(user);
53
- state.default.session.setPassword(password);
54
- state.default.session.setConnectionProfilesPath(connectionProfilePath);
55
- await ConnectionProfile.saveConnectionProfile();
51
+ state.setHost(host);
52
+ state.setUsername(user);
53
+ state.setPassword(password);
54
+ state.setConnectionProfilesPath(connectionProfilePath);
55
+ await ConnectionProfile.saveConnectionProfile(host);
56
56
  expect(fs.existsSync(connectionProfilePath)).toBeTruthy();
57
57
  const connections = JSON.parse(fs.readFileSync(connectionProfilePath, 'utf8'));
58
58
  expect(connections).toBeTruthy();